]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java
support both 1.14 and 1.15 JSON APIs
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / model / LedgerTransaction.java
index 2be23ae4961371fe050eac85440764afe508a02b..696803670c51067b88a3f002d282db95fe19e8c0 100644 (file)
@@ -20,8 +20,6 @@ package net.ktnx.mobileledger.model;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 
-import net.ktnx.mobileledger.json.ParsedLedgerTransaction;
-import net.ktnx.mobileledger.json.ParsedPosting;
 import net.ktnx.mobileledger.utils.Digest;
 import net.ktnx.mobileledger.utils.Globals;
 
@@ -32,8 +30,6 @@ import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.Date;
 
-import static net.ktnx.mobileledger.utils.Logger.debug;
-
 public class LedgerTransaction {
     private static final String DIGEST_TYPE = "SHA-256";
     public final Comparator<LedgerTransactionAccount> comparator =
@@ -68,7 +64,7 @@ public class LedgerTransaction {
         dataLoaded = false;
     }
     public LedgerTransaction(Integer id, Date date, String description) {
-        this(id, date, description, Data.profile.get());
+        this(id, date, description, Data.profile.getValue());
     }
     public LedgerTransaction(Date date, String description) {
         this(null, date, description);
@@ -142,8 +138,8 @@ public class LedgerTransaction {
                 .rawQuery("SELECT 1 from transactions where data_hash = ?", new String[]{dataHash}))
         {
             boolean result = c.moveToFirst();
-            debug("db", String.format("Transaction %d (%s) %s", id, dataHash,
-                    result ? "already present" : "not present"));
+//            debug("db", String.format("Transaction %d (%s) %s", id, dataHash,
+//                    result ? "already present" : "not present"));
             return result;
         }
     }
@@ -192,21 +188,4 @@ public class LedgerTransaction {
     public void finishLoading() {
         dataLoaded = true;
     }
-    public ParsedLedgerTransaction toParsedLedgerTransaction() {
-        ParsedLedgerTransaction result = new ParsedLedgerTransaction();
-        result.setTcomment("");
-        result.setTprecedingcomment("");
-
-        ArrayList<ParsedPosting> postings = new ArrayList<>();
-        for (LedgerTransactionAccount acc : accounts) {
-            if (!acc.getAccountName().isEmpty()) postings.add(acc.asParsedPosting());
-        }
-
-        result.setTpostings(postings);
-        result.setTdate(Globals.formatIsoDate(date));
-        result.setTdate2(null);
-        result.setTindex(1);
-        result.setTdescription(description);
-        return result;
-    }
 }