FINERACT-1822: Fix Undo waive loan charge API response inconsistency

This commit is contained in:
Adam Saghy
2022-11-28 21:26:19 +01:00
parent 66aab8d157
commit 82641f6357
5 changed files with 44 additions and 25 deletions
@@ -350,7 +350,7 @@ final class LoanTransactionsApiResourceSwagger {
@Schema(example = "95174ff9-1a75-4d72-a413-6f9b1cb988b7")
public String externalId;
@Schema(example = "28 June 2022")
public String date;
public LocalDate date;
}
@@ -479,6 +479,18 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom {
return this.principalPortion;
}
public BigDecimal getInterestPortion() {
return this.interestPortion;
}
public BigDecimal getPenaltyChargesPortion() {
return this.penaltyChargesPortion;
}
public BigDecimal getFeeChargesPortion() {
return this.feeChargesPortion;
}
public Money getInterestPortion(final MonetaryCurrency currency) {
return Money.of(currency, this.interestPortion);
}
@@ -364,11 +364,10 @@ public class LoanChargeWritePlatformServiceImpl implements LoanChargeWritePlatfo
businessEventNotifierService.notifyPostBusinessEvent(new LoanWaiveChargeUndoBusinessEvent(loanCharge));
// TODO: this needs to be fixed in the future! Principal portion is bigdecimal, interest portion is money, ...
changes.put("principalPortion", loanTransaction.getPrincipalPortion());
changes.put("interestPortion", loanTransaction.getInterestPortion(loan.getCurrency()));
changes.put("feeChargesPortion", loanTransaction.getFeeChargesPortion(loan.getCurrency()));
changes.put("penaltyChargesPortion", loanTransaction.getPenaltyChargesPortion(loan.getCurrency()));
changes.put("interestPortion", loanTransaction.getInterestPortion());
changes.put("feeChargesPortion", loanTransaction.getFeeChargesPortion());
changes.put("penaltyChargesPortion", loanTransaction.getPenaltyChargesPortion());
changes.put("outstandingLoanBalance", loanTransaction.getOutstandingLoanBalance());
changes.put("id", loanTransaction.getId());
changes.put("externalId", loanTransaction.getExternalId());