added status for charges
This commit is contained in:
committed by
Vishwas Babu A J
parent
45785dff42
commit
8b5eab1d87
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE `m_loan_charge`
|
||||||
|
ADD COLUMN `is_active` TINYINT(1) NOT NULL DEFAULT '1' AFTER `max_cap`;
|
||||||
+1
-1
@@ -217,7 +217,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
|
|||||||
sql.append("and (gp.status_enum = 300 or (gp.status_enum = 600 and gp.closedon_date >= :dueDate)) ")
|
sql.append("and (gp.status_enum = 300 or (gp.status_enum = 600 and gp.closedon_date >= :dueDate)) ")
|
||||||
.append("and (cl.status_enum = 300 or (cl.status_enum = 600 and cl.closedon_date >= :dueDate)) ")
|
.append("and (cl.status_enum = 300 or (cl.status_enum = 600 and cl.closedon_date >= :dueDate)) ")
|
||||||
.append("GROUP BY gp.id ,cl.id , ln.id ORDER BY gp.id , cl.id , ln.id ").append(") loandata ")
|
.append("GROUP BY gp.id ,cl.id , ln.id ORDER BY gp.id , cl.id , ln.id ").append(") loandata ")
|
||||||
.append("LEFT JOIN m_loan_charge lc ON lc.loan_id = loandata.loanId AND lc.is_paid_derived = 0 ")
|
.append("LEFT JOIN m_loan_charge lc ON lc.loan_id = loandata.loanId AND lc.is_paid_derived = 0 AND lc.is_active = 1")
|
||||||
.append("AND ( lc.due_for_collection_as_of_date <= :dueDate OR lc.charge_time_enum = 1) ")
|
.append("AND ( lc.due_for_collection_as_of_date <= :dueDate OR lc.charge_time_enum = 1) ")
|
||||||
.append("GROUP BY loandata.groupId, ").append("loandata.clientId, ").append("loandata.loanId ")
|
.append("GROUP BY loandata.groupId, ").append("loandata.clientId, ").append("loandata.loanId ")
|
||||||
.append("ORDER BY loandata.groupId, ").append("loandata.clientId, ").append("loandata.loanId ");
|
.append("ORDER BY loandata.groupId, ").append("loandata.clientId, ").append("loandata.loanId ");
|
||||||
|
|||||||
+74
-41
@@ -83,6 +83,7 @@ import org.mifosplatform.portfolio.loanaccount.loanschedule.domain.LoanScheduleM
|
|||||||
import org.mifosplatform.portfolio.loanaccount.loanschedule.domain.LoanScheduleModelPeriod;
|
import org.mifosplatform.portfolio.loanaccount.loanschedule.domain.LoanScheduleModelPeriod;
|
||||||
import org.mifosplatform.portfolio.loanproduct.domain.InterestMethod;
|
import org.mifosplatform.portfolio.loanproduct.domain.InterestMethod;
|
||||||
import org.mifosplatform.portfolio.loanproduct.domain.LoanProduct;
|
import org.mifosplatform.portfolio.loanproduct.domain.LoanProduct;
|
||||||
|
import org.mifosplatform.portfolio.loanproduct.domain.LoanProductBorrowerCycleVariations;
|
||||||
import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRelatedDetail;
|
import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRelatedDetail;
|
||||||
import org.mifosplatform.portfolio.loanproduct.domain.LoanTransactionProcessingStrategy;
|
import org.mifosplatform.portfolio.loanproduct.domain.LoanTransactionProcessingStrategy;
|
||||||
import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType;
|
import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType;
|
||||||
@@ -374,7 +375,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
Money chargesDue = Money.of(getCurrency(), BigDecimal.ZERO);
|
Money chargesDue = Money.of(getCurrency(), BigDecimal.ZERO);
|
||||||
|
|
||||||
for (final LoanCharge charge : setOfLoanCharges()) {
|
for (final LoanCharge charge : charges()) {
|
||||||
if (charge.isDueAtDisbursement()) {
|
if (charge.isDueAtDisbursement()) {
|
||||||
chargesDue = chargesDue.plus(charge.amount());
|
chargesDue = chargesDue.plus(charge.amount());
|
||||||
}
|
}
|
||||||
@@ -453,7 +454,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
// NOTE: must add new loan charge to set of loan charges before
|
// NOTE: must add new loan charge to set of loan charges before
|
||||||
// reporcessing the repayment schedule.
|
// reporcessing the repayment schedule.
|
||||||
setOfLoanCharges().add(loanCharge);
|
charges().add(loanCharge);
|
||||||
|
|
||||||
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
|
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
|
||||||
.determineProcessor(this.transactionProcessingStrategy);
|
.determineProcessor(this.transactionProcessingStrategy);
|
||||||
@@ -463,11 +464,11 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
existingTransactionIds.addAll(findExistingTransactionIds());
|
existingTransactionIds.addAll(findExistingTransactionIds());
|
||||||
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
||||||
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
||||||
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges());
|
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, charges());
|
||||||
if (!loanCharge.isDueAtDisbursement()) {
|
if (!loanCharge.isDueAtDisbursement()) {
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
||||||
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges());
|
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, charges());
|
||||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||||
mapEntry.getValue().updateLoan(this);
|
mapEntry.getValue().updateLoan(this);
|
||||||
}
|
}
|
||||||
@@ -591,10 +592,12 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
// if you want ability to remove loan charges that are waived.
|
// if you want ability to remove loan charges that are waived.
|
||||||
validateLoanChargeIsNotWaived(loanCharge);
|
validateLoanChargeIsNotWaived(loanCharge);
|
||||||
|
|
||||||
final boolean removed = setOfLoanCharges().remove(loanCharge);
|
LoanCharge charge = fetchLoanChargesById(loanCharge.getId());
|
||||||
|
final boolean removed = charge.isActive();
|
||||||
if (removed) {
|
if (removed) {
|
||||||
|
charge.setActive(false);
|
||||||
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
||||||
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges());
|
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, charges());
|
||||||
updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
|
updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -613,7 +616,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
***/
|
***/
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement,
|
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement,
|
||||||
getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges());
|
getCurrency(), this.repaymentScheduleInstallments, charges());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
@@ -651,7 +654,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(3);
|
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(3);
|
||||||
|
|
||||||
validateLoanIsNotClosed(loanCharge);
|
validateLoanIsNotClosed(loanCharge);
|
||||||
if (setOfLoanCharges().contains(loanCharge)) {
|
if (charges().contains(loanCharge)) {
|
||||||
final BigDecimal amount = calculateAmountPercentageAppliedTo(loanCharge);
|
final BigDecimal amount = calculateAmountPercentageAppliedTo(loanCharge);
|
||||||
final Map<String, Object> loanChargeChanges = loanCharge.update(command, amount);
|
final Map<String, Object> loanChargeChanges = loanCharge.update(command, amount);
|
||||||
actualChanges.putAll(loanChargeChanges);
|
actualChanges.putAll(loanChargeChanges);
|
||||||
@@ -671,11 +674,11 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
***/
|
***/
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement,
|
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement,
|
||||||
getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges());
|
getCurrency(), this.repaymentScheduleInstallments, charges());
|
||||||
} else {
|
} else {
|
||||||
// reprocess loan schedule based on charge been waived.
|
// reprocess loan schedule based on charge been waived.
|
||||||
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
||||||
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges());
|
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, charges());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
@@ -798,11 +801,11 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
***/
|
***/
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement,
|
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement,
|
||||||
getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges());
|
getCurrency(), this.repaymentScheduleInstallments, charges());
|
||||||
} else {
|
} else {
|
||||||
// reprocess loan schedule based on charge been waived.
|
// reprocess loan schedule based on charge been waived.
|
||||||
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
||||||
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges());
|
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, charges());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
@@ -861,9 +864,16 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateLoanCharges(final Set<LoanCharge> loanCharges) {
|
public void updateLoanCharges(final Set<LoanCharge> loanCharges) {
|
||||||
setOfLoanCharges().clear();
|
List<Long> existingCharges = fetchAllLoanChargeIds();
|
||||||
for (final LoanCharge loanCharge : loanCharges) {
|
for (final LoanCharge loanCharge : loanCharges) {
|
||||||
loanCharge.update(this);
|
LoanCharge charge = loanCharge;
|
||||||
|
if(loanCharge.getId() == null){
|
||||||
|
loanCharge.update(this);
|
||||||
|
this.charges.add(loanCharge);
|
||||||
|
}else{
|
||||||
|
charge = fetchLoanChargesById(charge.getId());
|
||||||
|
existingCharges.remove(charge.getId());
|
||||||
|
}
|
||||||
final BigDecimal amount = calculateAmountPercentageAppliedTo(loanCharge);
|
final BigDecimal amount = calculateAmountPercentageAppliedTo(loanCharge);
|
||||||
BigDecimal chargeAmt = BigDecimal.ZERO;
|
BigDecimal chargeAmt = BigDecimal.ZERO;
|
||||||
BigDecimal totalChargeAmt = BigDecimal.ZERO;
|
BigDecimal totalChargeAmt = BigDecimal.ZERO;
|
||||||
@@ -878,10 +888,12 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
chargeAmt = chargeAmt.divide(BigDecimal.valueOf(repaymentScheduleDetail().getNumberOfRepayments()));
|
chargeAmt = chargeAmt.divide(BigDecimal.valueOf(repaymentScheduleDetail().getNumberOfRepayments()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loanCharge.update(chargeAmt, loanCharge.getDueLocalDate(), amount, repaymentScheduleDetail().getNumberOfRepayments(),
|
charge.update(chargeAmt, loanCharge.getDueLocalDate(), amount, repaymentScheduleDetail().getNumberOfRepayments(),
|
||||||
totalChargeAmt);
|
totalChargeAmt);
|
||||||
}
|
}
|
||||||
setOfLoanCharges().addAll(loanCharges);
|
for(Long id:existingCharges){
|
||||||
|
fetchLoanChargesById(id).setActive(false);
|
||||||
|
}
|
||||||
updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
|
updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -915,7 +927,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void clearInstallmentLoanCharge() {
|
private void clearInstallmentLoanCharge() {
|
||||||
for (final LoanCharge loanCharge : setOfLoanCharges()) {
|
for (final LoanCharge loanCharge : charges()) {
|
||||||
if (loanCharge.isInstalmentFee()) {
|
if (loanCharge.isInstalmentFee()) {
|
||||||
loanCharge.clearLoanInstallmentCharges();
|
loanCharge.clearLoanInstallmentCharges();
|
||||||
}
|
}
|
||||||
@@ -1129,7 +1141,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final String chargesParamName = "charges";
|
final String chargesParamName = "charges";
|
||||||
if (command.parameterExists(chargesParamName)) {
|
if (command.parameterExists(chargesParamName)) {
|
||||||
|
|
||||||
final Set<LoanCharge> existingLoanCharges = setOfLoanCharges();
|
final Set<LoanCharge> existingLoanCharges = charges();
|
||||||
|
|
||||||
if (!possiblyModifedLoanCharges.equals(existingLoanCharges)) {
|
if (!possiblyModifedLoanCharges.equals(existingLoanCharges)) {
|
||||||
actualChanges.put(chargesParamName, getLoanCharges(possiblyModifedLoanCharges));
|
actualChanges.put(chargesParamName, getLoanCharges(possiblyModifedLoanCharges));
|
||||||
@@ -1185,14 +1197,6 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
return actualChanges;
|
return actualChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<LoanCharge> setOfLoanCharges() {
|
|
||||||
Set<LoanCharge> loanCharges = this.charges;
|
|
||||||
if (this.charges == null) {
|
|
||||||
loanCharges = new HashSet<LoanCharge>();
|
|
||||||
}
|
|
||||||
return loanCharges;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CollateralData[] listOfLoanCollateralData(final Set<LoanCollateral> setOfLoanCollateral) {
|
private CollateralData[] listOfLoanCollateralData(final Set<LoanCollateral> setOfLoanCollateral) {
|
||||||
|
|
||||||
CollateralData[] existingLoanCollateral = null;
|
CollateralData[] existingLoanCollateral = null;
|
||||||
@@ -1284,7 +1288,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// charges are optional
|
// charges are optional
|
||||||
for (final LoanCharge loanCharge : setOfLoanCharges()) {
|
for (final LoanCharge loanCharge : charges()) {
|
||||||
final BigDecimal amount = calculateAmountPercentageAppliedTo(loanCharge);
|
final BigDecimal amount = calculateAmountPercentageAppliedTo(loanCharge);
|
||||||
BigDecimal chargeAmt = BigDecimal.ZERO;
|
BigDecimal chargeAmt = BigDecimal.ZERO;
|
||||||
BigDecimal totalChargeAmt = BigDecimal.ZERO;
|
BigDecimal totalChargeAmt = BigDecimal.ZERO;
|
||||||
@@ -1588,7 +1592,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
loanTermPeriodFrequencyType, getDisbursementDate(), getExpectedFirstRepaymentOnDate(),
|
loanTermPeriodFrequencyType, getDisbursementDate(), getExpectedFirstRepaymentOnDate(),
|
||||||
calculatedRepaymentsStartingFromDate, getInArrearsTolerance(), this.loanRepaymentScheduleDetail);
|
calculatedRepaymentsStartingFromDate, getInArrearsTolerance(), this.loanRepaymentScheduleDetail);
|
||||||
|
|
||||||
final LoanScheduleModel loanSchedule = loanScheduleGenerator.generate(mc, applicationCurrency, loanApplicationTerms, this.charges,
|
final LoanScheduleModel loanSchedule = loanScheduleGenerator.generate(mc, applicationCurrency, loanApplicationTerms,charges(),
|
||||||
isHolidayEnabled, holidays, workingDays);
|
isHolidayEnabled, holidays, workingDays);
|
||||||
|
|
||||||
updateLoanSchedule(loanSchedule);
|
updateLoanSchedule(loanSchedule);
|
||||||
@@ -1618,7 +1622,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
Money disbursentMoney = Money.zero(getCurrency());
|
Money disbursentMoney = Money.zero(getCurrency());
|
||||||
final LoanTransaction chargesPayment = LoanTransaction.repaymentAtDisbursement(getOffice(), disbursentMoney, null, disbursedOn,
|
final LoanTransaction chargesPayment = LoanTransaction.repaymentAtDisbursement(getOffice(), disbursentMoney, null, disbursedOn,
|
||||||
null);
|
null);
|
||||||
for (final LoanCharge charge : setOfLoanCharges()) {
|
for (final LoanCharge charge : charges()) {
|
||||||
if (charge.isDueAtDisbursement()) {
|
if (charge.isDueAtDisbursement()) {
|
||||||
if (totalFeeChargesDueAtDisbursement.isGreaterThanZero() && !charge.getChargePaymentMode().isPaymentModeAccountTransfer()) {
|
if (totalFeeChargesDueAtDisbursement.isGreaterThanZero() && !charge.getChargePaymentMode().isPaymentModeAccountTransfer()) {
|
||||||
charge.markAsFullyPaid();
|
charge.markAsFullyPaid();
|
||||||
@@ -1662,7 +1666,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
||||||
LoanCharge charge = null;
|
LoanCharge charge = null;
|
||||||
for (final LoanCharge loanCharge : this.charges) {
|
for (final LoanCharge loanCharge : this.charges) {
|
||||||
if (chargeId.equals(loanCharge.getId())) {
|
if (loanCharge.isActive() && chargeId.equals(loanCharge.getId())) {
|
||||||
charge = loanCharge;
|
charge = loanCharge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1728,7 +1732,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
private void updateLoanToPreDisbursalState() {
|
private void updateLoanToPreDisbursalState() {
|
||||||
this.actualDisbursementDate = null;
|
this.actualDisbursementDate = null;
|
||||||
|
|
||||||
for (final LoanCharge charge : setOfLoanCharges()) {
|
for (final LoanCharge charge : charges()) {
|
||||||
charge.resetToOriginal(loanCurrency());
|
charge.resetToOriginal(loanCurrency());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1737,7 +1741,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
||||||
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges());
|
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, charges());
|
||||||
|
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
}
|
}
|
||||||
@@ -1799,7 +1803,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
||||||
LoanCharge charge = null;
|
LoanCharge charge = null;
|
||||||
for (final LoanCharge loanCharge : this.charges) {
|
for (final LoanCharge loanCharge : this.charges) {
|
||||||
if (chargeId.equals(loanCharge.getId())) {
|
if (loanCharge.isActive() && chargeId.equals(loanCharge.getId())) {
|
||||||
charge = loanCharge;
|
charge = loanCharge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1890,11 +1894,11 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
.determineProcessor(this.transactionProcessingStrategy);
|
.determineProcessor(this.transactionProcessingStrategy);
|
||||||
if (isTransactionChronologicallyLatest && adjustedTransaction == null) {
|
if (isTransactionChronologicallyLatest && adjustedTransaction == null) {
|
||||||
loanRepaymentScheduleTransactionProcessor.handleTransaction(loanTransaction, getCurrency(), this.repaymentScheduleInstallments,
|
loanRepaymentScheduleTransactionProcessor.handleTransaction(loanTransaction, getCurrency(), this.repaymentScheduleInstallments,
|
||||||
setOfLoanCharges());
|
charges());
|
||||||
} else {
|
} else {
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
||||||
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges());
|
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, charges());
|
||||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||||
mapEntry.getValue().updateLoan(this);
|
mapEntry.getValue().updateLoan(this);
|
||||||
}
|
}
|
||||||
@@ -1939,7 +1943,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
boolean isAllChargesPaid = true;
|
boolean isAllChargesPaid = true;
|
||||||
for (final LoanCharge loanCharge : this.charges) {
|
for (final LoanCharge loanCharge : this.charges) {
|
||||||
if (!(loanCharge.isPaid() || loanCharge.isWaived())) {
|
if (loanCharge.isActive()
|
||||||
|
&& !(loanCharge.isPaid() || loanCharge.isWaived())) {
|
||||||
isAllChargesPaid = false;
|
isAllChargesPaid = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2138,7 +2143,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
.determineProcessor(this.transactionProcessingStrategy);
|
.determineProcessor(this.transactionProcessingStrategy);
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
ChangedTransactionDetail changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
ChangedTransactionDetail changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
||||||
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges());
|
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, charges());
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
return changedTransactionDetail;
|
return changedTransactionDetail;
|
||||||
}
|
}
|
||||||
@@ -3046,7 +3051,15 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<LoanCharge> charges() {
|
public Set<LoanCharge> charges() {
|
||||||
return this.charges;
|
Set<LoanCharge> loanCharges = new HashSet<LoanCharge>();
|
||||||
|
if(this.charges != null){
|
||||||
|
for(LoanCharge charge:this.charges){
|
||||||
|
if(charge.isActive()){
|
||||||
|
loanCharges.add(charge);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return loanCharges;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<LoanInstallmentCharge> generateInstallmentLoanCharges(final LoanCharge loanCharge) {
|
public Set<LoanInstallmentCharge> generateInstallmentLoanCharges(final LoanCharge loanCharge) {
|
||||||
@@ -3115,7 +3128,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LOAN_REJECTED:
|
case LOAN_REJECTED:
|
||||||
if (!isClosedWrittenOff()) {
|
if (!isSubmittedAndPendingApproval()) {
|
||||||
final String defaultUserMessage = "Loan application cannot be rejected. Loan Account is not in Submitted and Pending approval state.";
|
final String defaultUserMessage = "Loan application cannot be rejected. Loan Account is not in Submitted and Pending approval state.";
|
||||||
final ApiParameterError error = ApiParameterError.generalError(
|
final ApiParameterError error = ApiParameterError.generalError(
|
||||||
"error.msg.loan.reject.account.is.not.submitted.pending.approval.state", defaultUserMessage);
|
"error.msg.loan.reject.account.is.not.submitted.pending.approval.state", defaultUserMessage);
|
||||||
@@ -3149,7 +3162,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
case REPAID_IN_FULL:
|
case REPAID_IN_FULL:
|
||||||
break;
|
break;
|
||||||
case LOAN_CHARGE_PAYMENT:
|
case LOAN_CHARGE_PAYMENT:
|
||||||
if (!isClosedWrittenOff()) {
|
if (!isOpen()) {
|
||||||
final String defaultUserMessage = "Charge payment is not allowed. Loan Account is not Active.";
|
final String defaultUserMessage = "Charge payment is not allowed. Loan Account is not Active.";
|
||||||
final ApiParameterError error = ApiParameterError.generalError("error.msg.loan.charge.payment.account.is.not.active",
|
final ApiParameterError error = ApiParameterError.generalError("error.msg.loan.charge.payment.account.is.not.active",
|
||||||
defaultUserMessage);
|
defaultUserMessage);
|
||||||
@@ -3157,7 +3170,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LOAN_CLOSED:
|
case LOAN_CLOSED:
|
||||||
if (!isClosedWrittenOff()) {
|
if (!isOpen()) {
|
||||||
final String defaultUserMessage = "Closing Loan Account is not allowed. Loan Account is not Active.";
|
final String defaultUserMessage = "Closing Loan Account is not allowed. Loan Account is not Active.";
|
||||||
final ApiParameterError error = ApiParameterError.generalError("error.msg.loan.close.account.is.not.active",
|
final ApiParameterError error = ApiParameterError.generalError("error.msg.loan.close.account.is.not.active",
|
||||||
defaultUserMessage);
|
defaultUserMessage);
|
||||||
@@ -3171,4 +3184,24 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LoanCharge fetchLoanChargesById(Long id) {
|
||||||
|
LoanCharge charge = null;
|
||||||
|
for (LoanCharge loanCharge : this.charges) {
|
||||||
|
if (id.equals(loanCharge.getId())) {
|
||||||
|
charge = loanCharge;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return charge;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Long> fetchAllLoanChargeIds() {
|
||||||
|
List<Long> list = new ArrayList<Long>();
|
||||||
|
for (LoanCharge loanCharge : this.charges) {
|
||||||
|
list.add(loanCharge.getId());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+13
@@ -108,6 +108,10 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
|||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@LazyCollection(LazyCollectionOption.FALSE)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loancharge", orphanRemoval = true)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loancharge", orphanRemoval = true)
|
||||||
private final Set<LoanInstallmentCharge> loanInstallmentCharge = new HashSet<LoanInstallmentCharge>();
|
private final Set<LoanInstallmentCharge> loanInstallmentCharge = new HashSet<LoanInstallmentCharge>();
|
||||||
|
|
||||||
|
@Column(name = "is_active", nullable = false)
|
||||||
|
private boolean active = true;
|
||||||
|
|
||||||
|
|
||||||
public static LoanCharge createNewFromJson(final Loan loan, final Charge chargeDefinition, final JsonCommand command) {
|
public static LoanCharge createNewFromJson(final Loan loan, final Charge chargeDefinition, final JsonCommand command) {
|
||||||
|
|
||||||
@@ -769,4 +773,13 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isActive(){
|
||||||
|
return this.active;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setActive(boolean active) {
|
||||||
|
this.active = active;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -151,7 +151,7 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
|||||||
|
|
||||||
final LoanChargeMapper rm = new LoanChargeMapper();
|
final LoanChargeMapper rm = new LoanChargeMapper();
|
||||||
|
|
||||||
final String sql = "select " + rm.schema() + " where lc.loan_id=? "
|
final String sql = "select " + rm.schema() + " where lc.loan_id=? AND lc.is_active = 1"
|
||||||
+ " order by lc.charge_time_enum ASC, lc.due_for_collection_as_of_date ASC, lc.is_penalty ASC";
|
+ " order by lc.charge_time_enum ASC, lc.due_for_collection_as_of_date ASC, lc.is_penalty ASC";
|
||||||
|
|
||||||
return this.jdbcTemplate.query(sql, rm, new Object[] { loanId });
|
return this.jdbcTemplate.query(sql, rm, new Object[] { loanId });
|
||||||
@@ -161,7 +161,7 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
|||||||
public Collection<LoanChargeData> retrieveLoanChargesForFeePayment(final Integer paymentMode, final Integer loanStatus) {
|
public Collection<LoanChargeData> retrieveLoanChargesForFeePayment(final Integer paymentMode, final Integer loanStatus) {
|
||||||
final LoanChargeMapperWithLoanId rm = new LoanChargeMapperWithLoanId();
|
final LoanChargeMapperWithLoanId rm = new LoanChargeMapperWithLoanId();
|
||||||
final String sql = "select " + rm.schema()
|
final String sql = "select " + rm.schema()
|
||||||
+ "where loan.loan_status_id= ? and lc.charge_payment_mode_enum=? and lc.waived =0 and lc.is_paid_derived=0";
|
+ "where loan.loan_status_id= ? and lc.charge_payment_mode_enum=? and lc.waived =0 and lc.is_paid_derived=0 and lc.is_active = 1";
|
||||||
return this.jdbcTemplate.query(sql, rm, new Object[] { loanStatus, paymentMode });
|
return this.jdbcTemplate.query(sql, rm, new Object[] { loanStatus, paymentMode });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1156,7 +1156,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
|||||||
+ " where DATE_SUB(CURDATE(),INTERVAL ? DAY) > ls.duedate "
|
+ " where DATE_SUB(CURDATE(),INTERVAL ? DAY) > ls.duedate "
|
||||||
+ " and ls.completed_derived <> 1 and mc.charge_applies_to_enum =1 "
|
+ " and ls.completed_derived <> 1 and mc.charge_applies_to_enum =1 "
|
||||||
+ " and mc.charge_time_enum = 9 and ml.loan_status_id = 300 "
|
+ " and mc.charge_time_enum = 9 and ml.loan_status_id = 300 "
|
||||||
+ " and plc.charge_id not in (SELECT charge_id from m_loan_charge as mlc where mlc.loan_id = ml.id and mlc.charge_id = plc.charge_id and mlc.due_for_collection_as_of_date > fromdate AND mlc.due_for_collection_as_of_date <= duedate) ";
|
+ " and plc.charge_id not in (SELECT charge_id from m_loan_charge as mlc where mlc.loan_id = ml.id and mlc.charge_id = plc.charge_id and mlc.is_active = 1 and mlc.due_for_collection_as_of_date > fromdate AND mlc.due_for_collection_as_of_date <= duedate) ";
|
||||||
return this.jdbcTemplate.query(sql, rm, new Object[] { penaltyWaitPeriod });
|
return this.jdbcTemplate.query(sql, rm, new Object[] { penaltyWaitPeriod });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user