]> git.ktnx.net Git - mobile-ledger.git/commitdiff
implement parsing of account currency
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 21 Dec 2018 19:39:56 +0000 (19:39 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 21 Dec 2018 19:39:56 +0000 (19:39 +0000)
app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java
app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java
app/src/main/res/raw/sql_10.sql [new file with mode: 0644]

index 190aa7ed543cb9918706fd1591b1068acb4febab..8902d455a91bb02f591408a0dd5358118e8d0153 100644 (file)
@@ -50,7 +50,7 @@ public class RetrieveTransactionsTask extends
     private static final Pattern transactionDescriptionPattern =
             Pattern.compile("<tr class=\"posting\" title=\"(\\S+)\\s(.+)");
     private static final Pattern transactionDetailsPattern =
-            Pattern.compile("^\\s+" + "(\\S[\\S\\s]+\\S)\\s\\s+([-+]?\\d[\\d,.]*)");
+            Pattern.compile("^\\s+" + "(\\S[\\S\\s]+\\S)\\s\\s+([-+]?\\d[\\d,.]*)(?:\\s+(\\S+)$)?");
     private static final Pattern endPattern = Pattern.compile("\\bid=\"addmodal\"");
     protected WeakReference<TransactionListActivity> contextRef;
     protected int error;
@@ -214,10 +214,11 @@ public class RetrieveTransactionsTask extends
                                         if (m.find()) {
                                             String acc_name = m.group(1);
                                             String amount = m.group(2);
+                                            String currency = m.group(3);
                                             amount = amount.replace(',', '.');
                                             transaction.addAccount(
                                                     new LedgerTransactionAccount(acc_name,
-                                                            Float.valueOf(amount)));
+                                                            Float.valueOf(amount), currency));
                                             L(String.format("%s = %s", acc_name, amount));
                                         }
                                         else throw new IllegalStateException(
index 96cc20205601b6af03b968a126ae3bd2331303a0..1073a88f58edc8c7745452de5e0a30ae7ae3c3fb 100644 (file)
@@ -118,7 +118,7 @@ public final class MLDB {
 
 class MobileLedgerDatabase extends SQLiteOpenHelper implements AutoCloseable {
     public static final String DB_NAME = "mobile-ledger.db";
-    public static final int LATEST_REVISION = 9;
+    public static final int LATEST_REVISION = 10;
 
     private final Context mContext;
 
diff --git a/app/src/main/res/raw/sql_10.sql b/app/src/main/res/raw/sql_10.sql
new file mode 100644 (file)
index 0000000..48e7b79
--- /dev/null
@@ -0,0 +1,2 @@
+delete from transaction_accounts;
+delete from transactions;
\ No newline at end of file