josehernandezfintecheandomx commented on code in PR #2633:
URL: https://github.com/apache/fineract/pull/2633#discussion_r991269762
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java:
##########
@@ -6125,6 +6133,43 @@ private ChangedTransactionDetail
handleRefundTransaction(final LoanTransaction l
return changedTransactionDetail;
}
+ public void handleChargebackTransaction(final LoanTransaction
chargebackTransaction,
+ final LoanLifecycleStateMachine loanLifecycleStateMachine) {
+
+ chargebackTransaction.updateLoan(this);
+
+ if (!chargebackTransaction.isChargeback()) {
+ final String errorMessage = "A transaction of type chargeback was
expected but not received.";
+ throw new InvalidLoanTransactionTypeException("transaction",
"is.not.a.chargeback.transaction", errorMessage);
+ }
+
+ final LocalDate loanTransactionDate =
chargebackTransaction.getTransactionDate();
+ if (loanTransactionDate.isBefore(getDisbursementDate())) {
+ final String errorMessage = "The transaction date cannot be before
the loan disbursement date: "
+ + getApprovedOnDate().toString();
+ throw new InvalidLoanStateTransitionException("transaction",
"cannot.be.before.disbursement.date", errorMessage,
+ loanTransactionDate, getDisbursementDate());
+ }
+
+ if (loanTransactionDate.isAfter(DateUtils.getBusinessLocalDate())) {
+ final String errorMessage = "The transaction date cannot be in the
future.";
+ throw new InvalidLoanStateTransitionException("transaction",
"cannot.be.a.future.date", errorMessage, loanTransactionDate);
+ }
+
+ if (chargebackTransaction.isNotZero(loanCurrency())) {
+ addLoanTransaction(chargebackTransaction);
+ }
+
+ final LoanRepaymentScheduleTransactionProcessor
loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
+ .determineProcessor(this.transactionProcessingStrategy);
+
loanRepaymentScheduleTransactionProcessor.handleChargeback(chargebackTransaction,
getCurrency(),
+ getRepaymentScheduleInstallments());
+
+ updateLoanSummarAndStatus();
Review Comment:
Done!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]