bug fixes for accrual based accounting
This commit is contained in:
+4
-3
@@ -77,6 +77,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
final String transactionId = loanTransactionDTO.getTransactionId();
|
final String transactionId = loanTransactionDTO.getTransactionId();
|
||||||
final Date transactionDate = loanTransactionDTO.getTransactionDate();
|
final Date transactionDate = loanTransactionDTO.getTransactionDate();
|
||||||
final BigDecimal disbursalAmount = loanTransactionDTO.getAmount();
|
final BigDecimal disbursalAmount = loanTransactionDTO.getAmount();
|
||||||
|
final BigDecimal interestAmount = loanDTO.getCalculatedInterest();
|
||||||
final boolean isReversed = loanTransactionDTO.isReversed();
|
final boolean isReversed = loanTransactionDTO.isReversed();
|
||||||
|
|
||||||
// create journal entries for the disbursement (or disbursement
|
// create journal entries for the disbursement (or disbursement
|
||||||
@@ -88,7 +89,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
BigDecimal interestApplied = loanDTO.getCalculatedInterest();
|
BigDecimal interestApplied = loanDTO.getCalculatedInterest();
|
||||||
if (interestApplied != null && !(interestApplied.compareTo(BigDecimal.ZERO) == 0)) {
|
if (interestApplied != null && !(interestApplied.compareTo(BigDecimal.ZERO) == 0)) {
|
||||||
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE,
|
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, loanProductId, loanId, transactionId, transactionDate, disbursalAmount,
|
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, loanProductId, loanId, transactionId, transactionDate, interestAmount,
|
||||||
isReversed);
|
isReversed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,8 +238,8 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
// create journal entries for the penalties application (or reversal)
|
// create journal entries for the penalties application (or reversal)
|
||||||
else if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
else if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||||
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE,
|
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES, loanProductId, loanId, transactionId, transactionDate, feesAmount,
|
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES, loanProductId, loanId, transactionId, transactionDate,
|
||||||
isReversed);
|
penaltiesAmount, isReversed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-8
@@ -411,6 +411,11 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
|
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
|
||||||
.determineProcessor(this.transactionProcessingStrategy);
|
.determineProcessor(this.transactionProcessingStrategy);
|
||||||
|
|
||||||
|
// store Id's of existing loan transactions and existing reversed loan
|
||||||
|
// transactions
|
||||||
|
existingTransactionIds.addAll(findExistingTransactionIds());
|
||||||
|
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
||||||
|
|
||||||
if (!loanCharge.isDueAtDisbursement()) {
|
if (!loanCharge.isDueAtDisbursement()) {
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
||||||
@@ -426,16 +431,13 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
|
|
||||||
existingTransactionIds.addAll(findExistingTransactionIds());
|
|
||||||
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
|
||||||
|
|
||||||
return changedTransactionDetail;
|
return changedTransactionDetail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a loanTransaction for "Apply Charge Event" with transaction date
|
* Creates a loanTransaction for "Apply Charge Event" with transaction date
|
||||||
* set to "suppliedTransactionDate"
|
* set to "suppliedTransactionDate". The newly created transaction is also
|
||||||
|
* added to the Loan on which this method is called.
|
||||||
*
|
*
|
||||||
* If "suppliedTransactionDate" is not passed Id, the transaction date is
|
* If "suppliedTransactionDate" is not passed Id, the transaction date is
|
||||||
* set to the loans due date if the due date is lesser than todays date. If
|
* set to the loans due date if the due date is lesser than todays date. If
|
||||||
@@ -445,7 +447,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
* @param suppliedTransactionDate
|
* @param suppliedTransactionDate
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public LoanTransaction getChargeAppliedTransaction(final LoanCharge loanCharge, final LocalDate suppliedTransactionDate) {
|
public LoanTransaction handleChargeAppliedTransaction(final LoanCharge loanCharge, final LocalDate suppliedTransactionDate) {
|
||||||
final Money chargeAmount = loanCharge.getAmount(getCurrency());
|
final Money chargeAmount = loanCharge.getAmount(getCurrency());
|
||||||
Money feeCharges = chargeAmount;
|
Money feeCharges = chargeAmount;
|
||||||
Money penaltyCharges = Money.zero(loanCurrency());
|
Money penaltyCharges = Money.zero(loanCurrency());
|
||||||
@@ -471,6 +473,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
final LoanTransaction applyLoanChargeTransaction = LoanTransaction.applyLoanCharge(this, chargeAmount, transactionDate, feeCharges,
|
final LoanTransaction applyLoanChargeTransaction = LoanTransaction.applyLoanCharge(this, chargeAmount, transactionDate, feeCharges,
|
||||||
penaltyCharges);
|
penaltyCharges);
|
||||||
|
this.loanTransactions.add(applyLoanChargeTransaction);
|
||||||
return applyLoanChargeTransaction;
|
return applyLoanChargeTransaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,6 +632,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
final LoanTransaction waiveLoanChargeTransaction = LoanTransaction.waiveLoanCharge(this, amountWaived, transactionDate,
|
final LoanTransaction waiveLoanChargeTransaction = LoanTransaction.waiveLoanCharge(this, amountWaived, transactionDate,
|
||||||
feeChargesWaived, penaltyChargesWaived);
|
feeChargesWaived, penaltyChargesWaived);
|
||||||
|
this.loanTransactions.add(waiveLoanChargeTransaction);
|
||||||
|
|
||||||
// Waive of charges whose due date falls after latest 'repayment'
|
// Waive of charges whose due date falls after latest 'repayment'
|
||||||
// transaction dont require entire loan schedule to be reprocessed.
|
// transaction dont require entire loan schedule to be reprocessed.
|
||||||
@@ -1338,8 +1342,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
if (charge.isDueAtDisbursement()) {
|
if (charge.isDueAtDisbursement()) {
|
||||||
charge.markAsFullyPaid();
|
charge.markAsFullyPaid();
|
||||||
} else {
|
} else {
|
||||||
LoanTransaction loanChargeAppliedTransaction = getChargeAppliedTransaction(charge, disbursedOn);
|
handleChargeAppliedTransaction(charge, disbursedOn);
|
||||||
this.loanTransactions.add(loanChargeAppliedTransaction);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -96,7 +96,6 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
|
|||||||
final Money penaltyCharges) {
|
final Money penaltyCharges) {
|
||||||
LoanTransaction applyCharge = new LoanTransaction(loan, LoanTransactionType.APPLY_CHARGES, amount.getAmount(), applyDate);
|
LoanTransaction applyCharge = new LoanTransaction(loan, LoanTransactionType.APPLY_CHARGES, amount.getAmount(), applyDate);
|
||||||
applyCharge.updateChargesComponents(feeCharges, penaltyCharges);
|
applyCharge.updateChargesComponents(feeCharges, penaltyCharges);
|
||||||
|
|
||||||
return applyCharge;
|
return applyCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -552,7 +552,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
final List<Long> existingReversedTransactionIds = new ArrayList<Long>();
|
final List<Long> existingReversedTransactionIds = new ArrayList<Long>();
|
||||||
this.loanChargeRepository.save(loanCharge);
|
this.loanChargeRepository.save(loanCharge);
|
||||||
|
|
||||||
final LoanTransaction applyLoanChargeTransaction = loan.getChargeAppliedTransaction(loanCharge, null);
|
final LoanTransaction applyLoanChargeTransaction = loan.handleChargeAppliedTransaction(loanCharge, null);
|
||||||
final ChangedTransactionDetail changedTransactionDetail = loan.addLoanCharge(loanCharge, existingTransactionIds,
|
final ChangedTransactionDetail changedTransactionDetail = loan.addLoanCharge(loanCharge, existingTransactionIds,
|
||||||
existingReversedTransactionIds);
|
existingReversedTransactionIds);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user