]> git.ktnx.net Git - mobile-ledger.git/commitdiff
add support for transaction-level comments in the JSON-based parser
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 14 Jun 2020 11:23:42 +0000 (14:23 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 16 Jun 2020 05:23:36 +0000 (05:23 +0000)
app/src/main/java/net/ktnx/mobileledger/json/v1_14/ParsedLedgerTransaction.java
app/src/main/java/net/ktnx/mobileledger/json/v1_15/ParsedLedgerTransaction.java
app/src/main/java/net/ktnx/mobileledger/utils/Misc.java

index 058319a3b4e250b12cc19b33afa241915b149af9..926717cc9f7570862915a98dba2907e5ce02c2a8 100644 (file)
@@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import net.ktnx.mobileledger.model.LedgerTransaction;
 import net.ktnx.mobileledger.model.LedgerTransactionAccount;
 import net.ktnx.mobileledger.utils.Globals;
+import net.ktnx.mobileledger.utils.Misc;
 
 import java.text.ParseException;
 import java.util.ArrayList;
@@ -146,6 +147,7 @@ public class ParsedLedgerTransaction implements net.ktnx.mobileledger.json.Parse
     public LedgerTransaction asLedgerTransaction() throws ParseException {
         Date date = Globals.parseIsoDate(tdate);
         LedgerTransaction tr = new LedgerTransaction(tindex, date, tdescription);
+        tr.setComment(Misc.trim(Misc.emptyIsNull(tcomment)));
 
         List<ParsedPosting> postings = tpostings;
 
index 1cffcfac2a5bafe104d179af65efbb9a6d6db59b..305a2adef949287f4283fd785edfcfaa9229148f 100644 (file)
@@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import net.ktnx.mobileledger.model.LedgerTransaction;
 import net.ktnx.mobileledger.model.LedgerTransactionAccount;
 import net.ktnx.mobileledger.utils.Globals;
+import net.ktnx.mobileledger.utils.Misc;
 
 import java.text.ParseException;
 import java.util.ArrayList;
@@ -144,6 +145,7 @@ public class ParsedLedgerTransaction implements net.ktnx.mobileledger.json.Parse
     public LedgerTransaction asLedgerTransaction() throws ParseException {
         Date date = Globals.parseIsoDate(tdate);
         LedgerTransaction tr = new LedgerTransaction(tindex, date, tdescription);
+        tr.setComment(Misc.trim(Misc.emptyIsNull(tcomment)));
 
         List<ParsedPosting> postings = tpostings;
 
index c4dc78750b97d3951c3876c9b901b8b8375151f4..b912541fcd351f20d92b948c846ab481cb289d14 100644 (file)
@@ -21,6 +21,7 @@ import android.app.Activity;
 import android.content.res.Configuration;
 import android.view.WindowManager;
 
+import androidx.annotation.Nullable;
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentActivity;
 
@@ -77,4 +78,10 @@ public class Misc {
             return true;
         return text.length() == 0;
     }
+    public static String trim(@Nullable String string) {
+        if (string == null)
+            return null;
+
+        return string.trim();
+    }
 }