josehernandezfintecheandomx commented on code in PR #2614:
URL: https://github.com/apache/fineract/pull/2614#discussion_r983623751
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -1184,6 +1189,105 @@ public CommandProcessingResult
adjustLoanTransaction(final Long loanId, final Lo
.with(changes).build();
}
+ @Transactional
+ @Override
+ public CommandProcessingResult chargebackLoanTransaction(final Long
loanId, final Long transactionId, final JsonCommand command) {
+ final boolean paymentDetailRequired = true;
+ this.loanEventApiJsonValidator.validateTransaction(command.json(),
paymentDetailRequired);
+
+ Loan loan = this.loanAssembler.assembleFrom(loanId);
+ if
(this.accountTransfersReadPlatformService.isAccountTransfer(transactionId,
PortfolioAccountType.LOAN)) {
+ throw new
PlatformServiceUnavailableException("error.msg.loan.transfer.transaction.update.not.allowed",
+ "Loan transaction:" + transactionId + " chargeback not
allowed as it involves in account transfer", transactionId);
+ }
+ if (loan.isClosedWrittenOff()) {
+ throw new
PlatformServiceUnavailableException("error.msg.loan.chargeback.operation.not.allowed",
+ "Loan transaction:" + transactionId + " chargeback not
allowed as loan status is written off", transactionId);
+ }
+ if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
+ throw new
PlatformServiceUnavailableException("error.msg.loan.chargeback.operation.not.allowed",
+ "Loan transaction:" + transactionId + " chargeback not
allowed as loan product is interest recalculation enabled",
+ transactionId);
+ }
+
+ final List<Long> existingTransactionIds = new ArrayList<>();
+ final List<Long> existingReversedTransactionIds = new ArrayList<>();
+
+ checkClientOrGroupActive(loan);
+
+ LoanTransaction loanTransaction =
this.loanTransactionRepository.findById(transactionId)
+ .orElseThrow(() -> new
LoanTransactionNotFoundException(transactionId));
+
+ if (!loanTransaction.isRepayment()) {
+ throw new
PlatformServiceUnavailableException("error.msg.loan.chargeback.operation.not.allowed",
+ "Loan transaction:" + transactionId + " chargeback not
allowed as loan transaction is not repayment", transactionId);
+ }
+
+ businessEventNotifierService.notifyPreBusinessEvent(new
LoanChargebackTransactionBusinessEvent(loanTransaction));
+
+ final LocalDate transactionDate =
command.localDateValueOfParameterNamed(LoanApiConstants.transactionDateParamName);
+ final BigDecimal transactionAmount =
command.bigDecimalValueOfParameterNamed(LoanApiConstants.TRANSACTION_AMOUNT_PARAMNAME);
+ final String txnExternalId =
command.stringValueOfParameterNamedAllowingNull(LoanApiConstants.externalIdParameterName);
+
+ final Map<String, Object> changes = new LinkedHashMap<>();
+ changes.put("transactionDate",
command.stringValueOfParameterNamed(LoanApiConstants.transactionDateParamName));
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]