Remove commented codes

This commit is contained in:
BLasan
2021-07-11 22:23:31 +05:30
parent a2c937b164
commit 31860f0960
4 changed files with 0 additions and 166 deletions
@@ -977,98 +977,6 @@ public class Loan extends AbstractPersistableCustom {
return amount; return amount;
} }
// public LoanTransaction undoWaiveLoanCharge(final LoanCharge loanCharge, final LoanLifecycleStateMachine
// loanLifecycleStateMachine,
// final Map<String, Object> changes, final List<Long> existingTransactionIds, final List<Long>
// 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<LoanTransaction> 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, public LoanTransaction waiveLoanCharge(final LoanCharge loanCharge, final LoanLifecycleStateMachine loanLifecycleStateMachine,
final Map<String, Object> changes, final List<Long> existingTransactionIds, final List<Long> existingReversedTransactionIds, final Map<String, Object> changes, final List<Long> existingTransactionIds, final List<Long> existingReversedTransactionIds,
final Integer loanInstallmentNumber, final ScheduleGeneratorDTO scheduleGeneratorDTO, final Money accruedCharge, final Integer loanInstallmentNumber, final ScheduleGeneratorDTO scheduleGeneratorDTO, final Money accruedCharge,
@@ -353,30 +353,6 @@ public class LoanCharge extends AbstractPersistableCustom {
this.amountOutstanding = amountOutstanding; 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) { public Money waive(final MonetaryCurrency currency, final Integer loanInstallmentNumber) {
if (isInstalmentFee()) { if (isInstalmentFee()) {
final LoanInstallmentCharge chargePerInstallment = getInstallmentLoanCharge(loanInstallmentNumber); final LoanInstallmentCharge chargePerInstallment = getInstallmentLoanCharge(loanInstallmentNumber);
@@ -346,18 +346,6 @@ public class LoanTransaction extends AbstractPersistableCustom {
return waiver; 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, public static LoanTransaction writeoff(final Loan loan, final Office office, final LocalDate writeOffDate, final String externalId,
final LocalDateTime createdDate, final AppUser appUser) { final LocalDateTime createdDate, final AppUser appUser) {
return new LoanTransaction(loan, office, LoanTransactionType.WRITEOFF, null, writeOffDate, externalId, createdDate, appUser); return new LoanTransaction(loan, office, LoanTransactionType.WRITEOFF, null, writeOffDate, externalId, createdDate, appUser);
@@ -1603,8 +1603,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
@Override @Override
public CommandProcessingResult undoWaiveLoanCharge(final JsonCommand command) { public CommandProcessingResult undoWaiveLoanCharge(final JsonCommand command) {
// validateUndoWaiveCharge(command);
LoanTransaction loanTransaction = this.loanTransactionRepository.findById(command.entityId()) LoanTransaction loanTransaction = this.loanTransactionRepository.findById(command.entityId())
.orElseThrow(() -> new LoanTransactionNotFoundException(command.entityId())); .orElseThrow(() -> new LoanTransactionNotFoundException(command.entityId()));
@@ -1656,12 +1654,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
// Get installment charge. // Get installment charge.
chargePerInstallment = loanCharge.getInstallmentLoanCharge(installmentNumber); 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()) { if (!loanTransaction.isNotReversed()) {
throw new LoanChargeWaiveCannotBeReversedException(LoanChargeWaiveCannotUndoReason.ALREADY_REVERSED, throw new LoanChargeWaiveCannotBeReversedException(LoanChargeWaiveCannotUndoReason.ALREADY_REVERSED,
loanTransaction.getId()); loanTransaction.getId());
@@ -1730,19 +1722,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
loan.updateLoanSummaryForUndoWaiveCharge(amountWaived); loan.updateLoanSummaryForUndoWaiveCharge(amountWaived);
// Set reschedule installment
// final List<LoanRepaymentScheduleInstallment> loanRepaymentScheduleInstallments =
// loan.getRepaymentScheduleInstallments();
// for (LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment :
// loanRepaymentScheduleInstallments) {
// if (loanRepaymentScheduleInstallment.getInstallmentNumber().equals(installmentNumber)) {
// loanRepaymentScheduleInstallment.updateLoanRepaymentSchedule(amountWaived);
// this.repaymentScheduleInstallmentRepository.saveAndFlush(loanRepaymentScheduleInstallment);
// break;
// }
// }
changes.put("amount", amountWaived); changes.put("amount", amountWaived);
} else { } else {
@@ -1774,23 +1753,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
.with(changes).build(); .with(changes).build();
} }
// private void validateUndoWaiveCharge(JsonCommand command) {
// final List<ApiParameterError> 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 @Transactional
@Override @Override
public CommandProcessingResult waiveLoanCharge(final Long loanId, final Long loanChargeId, final JsonCommand command) { public CommandProcessingResult waiveLoanCharge(final Long loanId, final Long loanChargeId, final JsonCommand command) {