]> git.ktnx.net Git - mobile-ledger.git/commitdiff
a single positive amount (with multiple negative amounts) is omitted
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 25 Jan 2020 13:09:56 +0000 (15:09 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 25 Jan 2020 13:09:56 +0000 (15:09 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java

index b956c7e8ea34a019e3986ed3300a45e2bb46505f..4d18db6a05e2d82d10a4b59c405788b6ceed42f2 100644 (file)
@@ -227,7 +227,9 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter<NewTransactionItem
             tr = profile.loadTransaction(transactionId);
             ArrayList<LedgerTransactionAccount> accounts = tr.getAccounts();
             NewTransactionModel.Item firstNegative = null;
+            NewTransactionModel.Item firstPositive = null;
             boolean singleNegative = false;
+            boolean singlePositive = false;
             int negativeCount = 0;
             for (int i = 0; i < accounts.size(); i++) {
                 LedgerTransactionAccount acc = accounts.get(i);
@@ -251,6 +253,14 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter<NewTransactionItem
                         else
                             singleNegative = false;
                     }
+                    else {
+                        if (firstPositive == null) {
+                            firstPositive = item;
+                            singlePositive = true;
+                        }
+                        else
+                            singlePositive = false;
+                    }
                 }
                 else
                     item.getAccount()
@@ -262,6 +272,10 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter<NewTransactionItem
                 firstNegative.getAccount()
                              .resetAmount();
             }
+            else if (singlePositive) {
+                firstPositive.getAccount()
+                             .resetAmount();
+            }
         }
         model.checkTransactionSubmittable(this);
         model.setFocusedItem(1);