Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ protected Money handleTransactionThatIsOnTimePaymentOfInstallment(final LoanRepa
penaltyChargesPortion = penaltyChargesPortion.add(subPenaltyPortion);

Money subFeePortion;

if (!ignoreDueDateCheck) {
if (calculatedFeeCharge.isGreaterThan(transactionAmountRemaining)) {
calculatedFeeCharge = transactionAmountRemaining;
Expand All @@ -174,14 +173,16 @@ protected Money handleTransactionThatIsOnTimePaymentOfInstallment(final LoanRepa
transactionAmountRemaining = transactionAmountRemaining.minus(subFeePortion);
feeChargesPortion = feeChargesPortion.add(subFeePortion);

Money subInterestPortion;
if (ignoreDueDateCheck || !transactionDate.isBefore(currentInstallment.getDueDate())) {
interestPortion = currentInstallment.payInterestComponent(transactionDate, transactionAmountRemaining);
transactionAmountRemaining = transactionAmountRemaining.minus(interestPortion);
subInterestPortion = currentInstallment.payInterestComponent(transactionDate, transactionAmountRemaining);
transactionAmountRemaining = transactionAmountRemaining.minus(subInterestPortion);
interestPortion = interestPortion.add(subInterestPortion);
}

principalPortion = principalPortion
.add(currentInstallment.payPrincipalComponent(transactionDate, transactionAmountRemaining));
transactionAmountRemaining = transactionAmountRemaining.minus(principalPortion);
Money subPrincipalPortion = currentInstallment.payPrincipalComponent(transactionDate, transactionAmountRemaining);
transactionAmountRemaining = transactionAmountRemaining.minus(subPrincipalPortion);
principalPortion = principalPortion.add(subPrincipalPortion);
// If the transactionAmountRemaining is greater than zero, rerun the allocation without due date check
// to distribute the in advance portions
if (transactionAmountRemaining.isGreaterThanZero()) {
Expand Down
Loading