fix overdraft account balance (PR #659 for FINERACT-753)

This commit is contained in:
andrew-dzak
2019-12-11 07:59:50 +01:00
committed by Michael Vorburger ⛑️
parent 26b4e0000c
commit 0474f59bcf
3 changed files with 96 additions and 0 deletions
@@ -851,6 +851,15 @@ public class SavingsAccount extends AbstractPersistableCustom<Long> {
transaction.updateOverdraftAmount(overdraftAmount.getAmount());
} else if (overdraftAmount.isNotEqualTo(transaction.getOverdraftAmount(getCurrency()))) {
SavingsAccountTransaction accountTransaction = SavingsAccountTransaction.copyTransaction(transaction);
if(transaction.isChargeTransaction()){
Set<SavingsAccountChargePaidBy> chargesPaidBy = transaction.getSavingsAccountChargesPaid();
final Set<SavingsAccountChargePaidBy> newChargePaidBy = new HashSet<>();
chargesPaidBy.forEach(x->
newChargePaidBy.add(SavingsAccountChargePaidBy.instance(accountTransaction,x.getSavingsAccountCharge(),
x.getAmount()))
);
accountTransaction.getSavingsAccountChargesPaid().addAll(newChargePaidBy);
}
transaction.reverse();
if (overdraftAmount.isGreaterThanZero()) {
accountTransaction.updateOverdraftAmount(overdraftAmount.getAmount());