Skip to content

Commit

Permalink
FINERACT-1818-Credit-Refund-Payout-Not-Getting-Created
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchiD authored and taskain7 committed Jan 10, 2023
1 parent 61ca7bb commit 145adaa
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3253,10 +3253,11 @@ private ChangedTransactionDetail handleRepaymentOrRecoveryOrWaiverTransaction(fi

if (this.loanProduct.isMultiDisburseLoan() && adjustedTransaction == null) {
BigDecimal totalDisbursed = getDisbursedAmount();
if (totalDisbursed.compareTo(this.summary.getTotalPrincipalRepaid()) < 0) {
final String errorMessage = "The transaction cannot be done before the loan disbursement: "
+ getApprovedOnDate().toString();
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.done.before.disbursement", errorMessage);
BigDecimal totalPrincipalAdjusted = this.summary.getTotalPrincipalAdjustments();
BigDecimal totalPrincipalCredited = totalDisbursed.add(totalPrincipalAdjusted);
if (totalPrincipalCredited.compareTo(this.summary.getTotalPrincipalRepaid()) < 0) {
final String errorMessage = "The transaction amount cannot exceed threshold.";
throw new InvalidLoanStateTransitionException("transaction", "amount.exceeds.threshold", errorMessage);
}
}

Expand Down Expand Up @@ -3318,11 +3319,12 @@ private ChangedTransactionDetail handleRepaymentOrRecoveryOrWaiverTransaction(fi

if (this.loanProduct.isMultiDisburseLoan()) {
BigDecimal totalDisbursed = getDisbursedAmount();
if (totalDisbursed.compareTo(this.summary.getTotalPrincipalRepaid()) < 0
BigDecimal totalPrincipalAdjusted = this.summary.getTotalPrincipalAdjustments();
BigDecimal totalPrincipalCredited = totalDisbursed.add(totalPrincipalAdjusted);
if (totalPrincipalCredited.compareTo(this.summary.getTotalPrincipalRepaid()) < 0
&& this.repaymentScheduleDetail().getPrincipal().minus(totalDisbursed).isGreaterThanZero()) {
final String errorMessage = "The transaction cannot be done before the loan disbursement: "
+ getApprovedOnDate().toString();
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.done.before.disbursement", errorMessage);
final String errorMessage = "The transaction amount cannot exceed threshold.";
throw new InvalidLoanStateTransitionException("transaction", "amount.exceeds.threshold", errorMessage);
}
}

Expand Down Expand Up @@ -6197,10 +6199,11 @@ private ChangedTransactionDetail handleRefundTransaction(final LoanTransaction l

if (this.loanProduct.isMultiDisburseLoan() && adjustedTransaction == null) {
BigDecimal totalDisbursed = getDisbursedAmount();
if (totalDisbursed.compareTo(this.summary.getTotalPrincipalRepaid()) < 0) {
final String errorMessage = "The transaction cannot be done before the loan disbursement: "
+ getApprovedOnDate().toString();
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.done.before.disbursement", errorMessage);
BigDecimal totalPrincipalAdjusted = this.summary.getTotalPrincipalAdjustments();
BigDecimal totalPrincipalCredited = totalDisbursed.add(totalPrincipalAdjusted);
if (totalPrincipalCredited.compareTo(this.summary.getTotalPrincipalRepaid()) < 0) {
final String errorMessage = "The transaction amount cannot exceed threshold.";
throw new InvalidLoanStateTransitionException("transaction", "amount.exceeds.threshold", errorMessage);
}
}

Expand Down

0 comments on commit 145adaa

Please sign in to comment.