From: Damyan Ivanov Date: Thu, 14 Mar 2019 20:05:50 +0000 (+0200) Subject: fix duplication af account amounts on refresh X-Git-Tag: v0.8~15 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=010406b05a5a4f8447af34187afef8c1e78a4552;p=mobile-ledger.git fix duplication af account amounts on refresh --- 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 dfb1f745..8f1a764b 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java @@ -170,9 +170,10 @@ public class RetrieveTransactionsTask L(String.format("found account: %s", acct_name)); lastAccount = profile.tryLoadAccount(db, acct_name); - if (lastAccount == null) { + if (lastAccount == null) lastAccount = new LedgerAccount(acct_name); - } + else + lastAccount.removeAmounts(); profile.storeAccount(db, lastAccount); // make sure the parent account(s) are present, diff --git a/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java index 93c78de2..0751d10a 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java @@ -160,4 +160,7 @@ public class LedgerAccount { public void toggleExpanded() { expanded = !expanded; } + public void removeAmounts() { + amounts.clear(); + } }