Skip to content

Commit

Permalink
Fixes earnings widget where interest charge was added instead of subt…
Browse files Browse the repository at this point in the history
  • Loading branch information
buchen committed Jun 4, 2023
1 parent b528b92 commit e8f03f1
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ public Supplier<Model> getUpdateTask()
final MonthData monthData = months.get(monthOfYear - 1);

Money value = grossNetType == GrossNetType.GROSS ? tx.getGrossValue() : tx.getMonetaryAmount();
monthData.sum = monthData.sum.add(value.with(converter.at(tx.getDateTime())));

monthData.sum = tx.getType().isCredit()
? monthData.sum.add(value.with(converter.at(tx.getDateTime())))
: monthData.sum.subtract(value.with(converter.at(tx.getDateTime())));

monthData.transactions.add(new TransactionPair<>(account, tx));
}
}
Expand Down Expand Up @@ -308,8 +312,11 @@ protected Composite createItem(Composite parent, TransactionPair<AccountTransact
name.addListener(SWT.MouseUp, event -> view.setInformationPaneInput(pair.getTransaction().getSecurity()));

Label earning = new Label(composite, SWT.RIGHT);
earning.setText(Values.Money.format(grossNetType == GrossNetType.GROSS ? pair.getTransaction().getGrossValue()
: pair.getTransaction().getMonetaryAmount(), getClient().getBaseCurrency()));
Money value = grossNetType == GrossNetType.GROSS ? pair.getTransaction().getGrossValue()
: pair.getTransaction().getMonetaryAmount();
if (pair.getTransaction().getType().isDebit())
value = value.multiply(-1);
earning.setText(Values.Money.format(value, getClient().getBaseCurrency()));

FormDataFactory.startingWith(logo).thenRight(name).right(new FormAttachment(earning, -5, SWT.LEFT));
FormDataFactory.startingWith(earning).right(new FormAttachment(100));
Expand Down

0 comments on commit e8f03f1

Please sign in to comment.