diff --git a/app/src/main/java/com/yoshione/fingen/FragmentSimpleDebts.java b/app/src/main/java/com/yoshione/fingen/FragmentSimpleDebts.java index 0d468ee2..9186fa25 100644 --- a/app/src/main/java/com/yoshione/fingen/FragmentSimpleDebts.java +++ b/app/src/main/java/com/yoshione/fingen/FragmentSimpleDebts.java @@ -314,11 +314,11 @@ public void onSelectionChange(int selectedCount) { ListSumsByCabbage listSumsByCabbage = new ListSumsByCabbage(); for (SimpleDebt dept : adapterD.getSelectedDebts()) { + boolean startAmountIsPositive = dept.getStartAmount().abs().equals(dept.getStartAmount()); SumsByCabbage sumsByCabbage = new SumsByCabbage(dept.getCabbageID(), - dept.getOweMe(), - BigDecimal.ZERO.subtract(dept.getAmount())); - sumsByCabbage.setStartBalance(dept.getStartAmount()); - listSumsByCabbage.getmList().add(sumsByCabbage); + dept.getOweMe().add(startAmountIsPositive ? dept.getStartAmount() : BigDecimal.ZERO), + BigDecimal.ZERO.subtract(dept.getAmount()).add(!startAmountIsPositive ? dept.getStartAmount() : BigDecimal.ZERO)); + listSumsByCabbage.appendSumFact(sumsByCabbage); } updateSums(listSumsByCabbage); } diff --git a/app/src/main/java/com/yoshione/fingen/classes/ListSumsByCabbage.java b/app/src/main/java/com/yoshione/fingen/classes/ListSumsByCabbage.java index 6c371c01..f5124750 100644 --- a/app/src/main/java/com/yoshione/fingen/classes/ListSumsByCabbage.java +++ b/app/src/main/java/com/yoshione/fingen/classes/ListSumsByCabbage.java @@ -33,7 +33,7 @@ public SumsByCabbage getSumsByCabbageId(long cabbageId) { return result; } - private void appendSumFact(SumsByCabbage input) { + public void appendSumFact(SumsByCabbage input) { SumsByCabbage sumsByCabbage = getSumsByCabbageId(input.getCabbageId()); if (sumsByCabbage == null) { mList.add(new SumsByCabbage(input.getCabbageId(), input.getInTrSum(), input.getOutTrSum()));