FINERACT-2092: Fix adjust transactions handling
This commit is contained in:
+4
@@ -1040,6 +1040,10 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getChargeRefundChargeType() {
|
||||||
|
return chargeRefundChargeType;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO missing hashCode(), equals(Object obj), but probably OK as long as
|
// TODO missing hashCode(), equals(Object obj), but probably OK as long as
|
||||||
// this is never stored in a Collection.
|
// this is never stored in a Collection.
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1444,8 +1444,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
|
|
||||||
final Money transactionAmountAsMoney = Money.of(loan.getCurrency(), transactionAmount);
|
final Money transactionAmountAsMoney = Money.of(loan.getCurrency(), transactionAmount);
|
||||||
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createPaymentDetail(command, changes);
|
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createPaymentDetail(command, changes);
|
||||||
LoanTransaction newTransactionDetail = LoanTransaction.repayment(loan.getOffice(), transactionAmountAsMoney, paymentDetail,
|
LoanTransaction newTransactionDetail = LoanTransaction.repaymentType(transactionToAdjust.getTypeOf(), loan.getOffice(),
|
||||||
transactionDate, txnExternalId);
|
transactionAmountAsMoney, paymentDetail, transactionDate, txnExternalId, transactionToAdjust.getChargeRefundChargeType());
|
||||||
if (transactionToAdjust.isInterestWaiver()) {
|
if (transactionToAdjust.isInterestWaiver()) {
|
||||||
Money unrecognizedIncome = transactionAmountAsMoney.zero();
|
Money unrecognizedIncome = transactionAmountAsMoney.zero();
|
||||||
Money interestComponent = transactionAmountAsMoney;
|
Money interestComponent = transactionAmountAsMoney;
|
||||||
|
|||||||
+45
@@ -1579,6 +1579,51 @@ public class LoanTransactionInterestPaymentWaiverTest extends BaseLoanIntegratio
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInterestPaymentWaiverAdjustTransaction() {
|
||||||
|
runAt("15 January 2023", () -> {
|
||||||
|
Integer numberOfRepayments = 4;
|
||||||
|
double amount = 1000.0;
|
||||||
|
String loanDisbursementDate = "1 January 2023";
|
||||||
|
|
||||||
|
Long clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
|
||||||
|
|
||||||
|
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||||
|
PostLoanProductsResponse loanProductResponse = loanProductHelper
|
||||||
|
.createLoanProduct(createOnePeriod30DaysLongNoInterestPeriodicAccrualProductWithAdvancedPaymentAllocation()
|
||||||
|
.loanScheduleType(LoanScheduleType.PROGRESSIVE.toString()));
|
||||||
|
|
||||||
|
Long loanId = applyAndApproveLoanProgressiveAdvancedPaymentAllocationStrategyMonthlyRepayments(clientId,
|
||||||
|
loanProductResponse.getResourceId(), numberOfRepayments, loanDisbursementDate, amount, null);
|
||||||
|
|
||||||
|
verifyRepaymentSchedule(loanId, //
|
||||||
|
installment(1000.0, null, "01 January 2023"), //
|
||||||
|
installment(250.0, false, "01 February 2023"), //
|
||||||
|
installment(250.0, false, "01 March 2023"), //
|
||||||
|
installment(250.0, false, "01 April 2023"), //
|
||||||
|
installment(250.0, false, "01 May 2023") //
|
||||||
|
);
|
||||||
|
|
||||||
|
loanTransactionHelper.disburseLoan(loanId, new PostLoansLoanIdRequest().actualDisbursementDate("1 January 2023")
|
||||||
|
.dateFormat(DATETIME_PATTERN).transactionAmount(BigDecimal.valueOf(1000.0)).locale("en"));
|
||||||
|
|
||||||
|
// loan should be active
|
||||||
|
Long transactionId = addInterestPaymentWaiverForLoan(loanId, 250.0, "2 January 2023");
|
||||||
|
|
||||||
|
verifyTransactions(loanId, //
|
||||||
|
transaction(1000.0, "Disbursement", "01 January 2023", 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
|
||||||
|
transaction(250.0, "Interest Payment Waiver", "02 January 2023", 750.0, 250.0, 0.0, 0.0, 0, 0.0, 0.0));
|
||||||
|
|
||||||
|
loanTransactionHelper.adjustLoanTransaction(loanId, transactionId, new PostLoansLoanIdTransactionsTransactionIdRequest()
|
||||||
|
.transactionAmount(200.0).dateFormat(DATETIME_PATTERN).transactionDate("3 January 2023").locale("en"));
|
||||||
|
|
||||||
|
verifyTransactions(loanId, //
|
||||||
|
transaction(1000.0, "Disbursement", "01 January 2023", 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
|
||||||
|
transaction(250.0, "Interest Payment Waiver", "02 January 2023", 750.0, 250.0, 0.0, 0.0, 0, 0.0, 0.0, true),
|
||||||
|
transaction(200.0, "Interest Payment Waiver", "03 January 2023", 800.0, 200.0, 0.0, 0.0, 0, 0.0, 0.0));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void chargeFee(Long loanId, Double amount, String dueDate) {
|
private void chargeFee(Long loanId, Double amount, String dueDate) {
|
||||||
PostChargesResponse feeCharge = chargesHelper.createCharges(new PostChargesRequest().penalty(false).amount(9.0)
|
PostChargesResponse feeCharge = chargesHelper.createCharges(new PostChargesRequest().penalty(false).amount(9.0)
|
||||||
.chargeCalculationType(ChargeCalculationType.FLAT.getValue()).chargeTimeType(ChargeTimeType.SPECIFIED_DUE_DATE.getValue())
|
.chargeCalculationType(ChargeCalculationType.FLAT.getValue()).chargeTimeType(ChargeTimeType.SPECIFIED_DUE_DATE.getValue())
|
||||||
|
|||||||
Reference in New Issue
Block a user