From 1bffaaa4121ae0e63453cf725b26c769b5ae0e39 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 21 Dec 2018 19:39:56 +0000 Subject: [PATCH] implement parsing of account currency --- .../ktnx/mobileledger/async/RetrieveTransactionsTask.java | 5 +++-- app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java | 2 +- app/src/main/res/raw/sql_10.sql | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/raw/sql_10.sql diff --git a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java index 190aa7ed..8902d455 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java @@ -50,7 +50,7 @@ public class RetrieveTransactionsTask extends private static final Pattern transactionDescriptionPattern = Pattern.compile(" 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( diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java b/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java index 96cc2020..1073a88f 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java @@ -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 index 00000000..48e7b790 --- /dev/null +++ b/app/src/main/res/raw/sql_10.sql @@ -0,0 +1,2 @@ +delete from transaction_accounts; +delete from transactions; \ No newline at end of file -- 2.39.5