diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java index 259841f2f..5974c3d83 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java @@ -977,98 +977,6 @@ public class Loan extends AbstractPersistableCustom { return amount; } - // public LoanTransaction undoWaiveLoanCharge(final LoanCharge loanCharge, final LoanLifecycleStateMachine - // loanLifecycleStateMachine, - // final Map changes, final List existingTransactionIds, final List - // existingReversedTransactionIds, - // final Integer loanInstallmentNumber, final ScheduleGeneratorDTO scheduleGeneratorDTO, final Money accruedCharge, - // final AppUser currentUser) { - // - // validateLoanIsNotClosed(loanCharge); - // - // //final Money amountUndoWaived = loanCharge.undoWaive(loanCurrency(), loanInstallmentNumber); - // - // changes.put("amount", amountUndoWaived.getAmount()); - // - // Money unrecognizedIncome = amountUndoWaived.zero(); - // Money chargeComponent = amountUndoWaived; - // if (isPeriodicAccrualAccountingEnabledOnLoanProduct()) { - // Money receivableCharge = Money.zero(getCurrency()); - // if (loanInstallmentNumber != null) { - // receivableCharge = accruedCharge - // .add(loanCharge.getInstallmentLoanCharge(loanInstallmentNumber).getAmountPaid(getCurrency())); - // } else { - // receivableCharge = accruedCharge.add(loanCharge.getAmountPaid(getCurrency())); - // } - // - // if (amountUndoWaived.isLessThan(receivableCharge)) { - // chargeComponent = receivableCharge; - // unrecognizedIncome = amountUndoWaived.add(receivableCharge); - // } - // } - // Money feeChargesUndoWaived = chargeComponent; - // Money penaltyChargesUndoWaived = Money.zero(loanCurrency()); - // if (loanCharge.isPenaltyCharge()) { - // penaltyChargesUndoWaived = chargeComponent; - // feeChargesUndoWaived = Money.zero(loanCurrency()); - // } - // - // LocalDate transactionDate = getDisbursementDate(); - // if (loanCharge.isDueDateCharge()) { - // if (loanCharge.getDueLocalDate().isAfter(DateUtils.getLocalDateOfTenant())) { - // transactionDate = DateUtils.getLocalDateOfTenant(); - // } else { - // transactionDate = loanCharge.getDueLocalDate(); - // } - // } else if (loanCharge.isInstalmentFee()) { - // transactionDate = - // loanCharge.getInstallmentLoanCharge(loanInstallmentNumber).getRepaymentInstallment().getDueDate(); - // } - // - // scheduleGeneratorDTO.setRecalculateFrom(transactionDate); - // - // updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement()); - // - // // existingTransactionIds.addAll(findExistingTransactionIds()); - // // existingReversedTransactionIds.addAll(findExistingReversedTransactionIds()); - // - // final LoanTransaction waiveLoanChargeTransaction = LoanTransaction.waiveLoanCharge(this, getOffice(), - // amountUndoWaived, - // transactionDate, feeChargesUndoWaived, penaltyChargesUndoWaived, unrecognizedIncome, - // DateUtils.getLocalDateTimeOfTenant(), - // currentUser); - // final LoanChargePaidBy loanChargePaidBy = new LoanChargePaidBy(waiveLoanChargeTransaction, loanCharge, - // waiveLoanChargeTransaction.getAmount(getCurrency()).getAmount(), loanInstallmentNumber); - // waiveLoanChargeTransaction.getLoanChargesPaid().add(loanChargePaidBy); - // addLoanTransaction(waiveLoanChargeTransaction); - // if (this.repaymentScheduleDetail().isInterestRecalculationEnabled() && (loanCharge.getDueLocalDate() == null - // || LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).isAfter(loanCharge.getDueLocalDate()))) { - // regenerateRepaymentScheduleWithInterestRecalculation(scheduleGeneratorDTO, currentUser); - // } - // // Waive of charges whose due date falls after latest 'repayment' - // // transaction dont require entire loan schedule to be reprocessed. - // final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = - // this.transactionProcessorFactory - // .determineProcessor(this.transactionProcessingStrategy); - // if (!loanCharge.isDueAtDisbursement() && loanCharge.isPaidOrPartiallyPaid(loanCurrency())) { - // final List allNonContraTransactionsPostDisbursement = - // retreiveListOfTransactionsPostDisbursement(); - // loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), - // allNonContraTransactionsPostDisbursement, - // getCurrency(), getRepaymentScheduleInstallments(), charges()); - // } else { - // // reprocess loan schedule based on charge been waived. - // final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper(); - // wrapper.reprocess(getCurrency(), getDisbursementDate(), getRepaymentScheduleInstallments(), charges()); - // } - // - // updateLoanSummaryDerivedFields(); - // - // doPostLoanTransactionChecks(waiveLoanChargeTransaction.getTransactionDate(), loanLifecycleStateMachine); - // - // return waiveLoanChargeTransaction; - // } - public LoanTransaction waiveLoanCharge(final LoanCharge loanCharge, final LoanLifecycleStateMachine loanLifecycleStateMachine, final Map changes, final List existingTransactionIds, final List existingReversedTransactionIds, final Integer loanInstallmentNumber, final ScheduleGeneratorDTO scheduleGeneratorDTO, final Money accruedCharge, diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java index 4e381ef2a..88a622f00 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java @@ -353,30 +353,6 @@ public class LoanCharge extends AbstractPersistableCustom { this.amountOutstanding = amountOutstanding; } - // public Money undoWaive(final MonetaryCurrency currency, final Integer loanInstallmentNumber) { - // if (isInstalmentFee()) { - // final LoanInstallmentCharge chargePerInstallment = getInstallmentLoanCharge(loanInstallmentNumber); - // final Money amountWaived = chargePerInstallment.waive(currency); - // if (this.amountWaived != null) { - // this.amountWaived = this.amountWaived.add(amountWaived.getAmount()); - // } else { - // } - // - // this.amountOutstanding = this.amountOutstanding.add(amountWaived.getAmount()); - // if (determineIfFullyPaid()) { - // this.paid = false; - // this.waived = false; - // } - // return amountWaived; - // } - // this.amountWaived = BigDecimal.ZERO; - // // this.amountOutstanding = BigDecimal.ZERO; - // this.paid = false; - // this.waived = false; - // return getAmountWaived(currency); - // - // } - public Money waive(final MonetaryCurrency currency, final Integer loanInstallmentNumber) { if (isInstalmentFee()) { final LoanInstallmentCharge chargePerInstallment = getInstallmentLoanCharge(loanInstallmentNumber); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java index 9735c350b..c3bbeaf4e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java @@ -346,18 +346,6 @@ public class LoanTransaction extends AbstractPersistableCustom { return waiver; } - // public static LoanTransaction undoWaiveLoanCharge(final Loan loan, final Office office, final Money undoWaived, - // final LocalDate undoWaiveDate, final Money feeChargesWaived, final Money penaltyChargesWaived, final Money - // unrecognizedCharge, - // final LocalDateTime createdDate, final AppUser appUser) { - // final LoanTransaction undoWaiver = new LoanTransaction(loan, office, LoanTransactionType.UNDO_WAIVE_CHARGE, - // undoWaived.getAmount(), - // undoWaiveDate, null, createdDate, appUser); - // undoWaiver.updateChargesComponents(feeChargesWaived, penaltyChargesWaived, unrecognizedCharge); - // - // return undoWaiver; - // } - public static LoanTransaction writeoff(final Loan loan, final Office office, final LocalDate writeOffDate, final String externalId, final LocalDateTime createdDate, final AppUser appUser) { return new LoanTransaction(loan, office, LoanTransactionType.WRITEOFF, null, writeOffDate, externalId, createdDate, appUser); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java index 0a7a31c0c..f28a021b3 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -1603,8 +1603,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf @Override public CommandProcessingResult undoWaiveLoanCharge(final JsonCommand command) { - // validateUndoWaiveCharge(command); - LoanTransaction loanTransaction = this.loanTransactionRepository.findById(command.entityId()) .orElseThrow(() -> new LoanTransactionNotFoundException(command.entityId())); @@ -1656,12 +1654,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf // Get installment charge. chargePerInstallment = loanCharge.getInstallmentLoanCharge(installmentNumber); - // // Get relevant LoanChargePaidBy row - // final LoanChargePaidBy loanChargePaidBy = - // this.loanChargePaidByRepository.getLoanChargePaidByLoanCharge(loanCharge, - // chargePerInstallment.getInstallment().getInstallmentNumber()); - // LoanTransaction loanTransaction = loanChargePaidBy.getLoanTransaction(); - if (!loanTransaction.isNotReversed()) { throw new LoanChargeWaiveCannotBeReversedException(LoanChargeWaiveCannotUndoReason.ALREADY_REVERSED, loanTransaction.getId()); @@ -1730,19 +1722,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf loan.updateLoanSummaryForUndoWaiveCharge(amountWaived); - // Set reschedule installment - - // final List loanRepaymentScheduleInstallments = - // loan.getRepaymentScheduleInstallments(); - // for (LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : - // loanRepaymentScheduleInstallments) { - // if (loanRepaymentScheduleInstallment.getInstallmentNumber().equals(installmentNumber)) { - // loanRepaymentScheduleInstallment.updateLoanRepaymentSchedule(amountWaived); - // this.repaymentScheduleInstallmentRepository.saveAndFlush(loanRepaymentScheduleInstallment); - // break; - // } - // } - changes.put("amount", amountWaived); } else { @@ -1774,23 +1753,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf .with(changes).build(); } - // private void validateUndoWaiveCharge(JsonCommand command) { - // final List dataValidationErrors = new ArrayList<>(); - // final DataValidatorBuilder baseDataValidator = new - // DataValidatorBuilder(dataValidationErrors).resource("transaction"); - // - // if (!command.parameterExists("transactionId")) { - // baseDataValidator.reset().parameter("transactionId").failWithCode("trasactionId.not.exists"); - // } else { - // final Long transactionId = command.longValueOfParameterNamed("transactionId"); - // baseDataValidator.reset().parameter("transactionId").value(transactionId).notNull().notBlank(); - // } - // - // if (!dataValidationErrors.isEmpty()) { - // throw new PlatformApiDataValidationException(dataValidationErrors); - // } - // } - @Transactional @Override public CommandProcessingResult waiveLoanCharge(final Long loanId, final Long loanChargeId, final JsonCommand command) {