MIFOSX-827 corrected update loan charge functionality from modify application
This commit is contained in:
committed by
Vishwas Babu A J
parent
d365545ec1
commit
097189621f
+34
@@ -221,6 +221,35 @@ public class LoanChargeData {
|
|||||||
this.loanId = chargeData.loanId;
|
this.loanId = chargeData.loanId;
|
||||||
this.installmentChargeData = installmentChargeData;
|
this.installmentChargeData = installmentChargeData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LoanChargeData(final Long id, final LocalDate dueAsOfDate, final BigDecimal amountOrPercentage) {
|
||||||
|
this.id = id;
|
||||||
|
this.chargeId = null;
|
||||||
|
this.name = null;
|
||||||
|
this.currency = null;
|
||||||
|
this.amount = null;
|
||||||
|
this.amountPaid = null;
|
||||||
|
this.amountWaived = null;
|
||||||
|
this.amountWrittenOff = null;
|
||||||
|
this.amountOutstanding = null;
|
||||||
|
this.chargeTimeType = null;
|
||||||
|
this.dueDate = dueAsOfDate;
|
||||||
|
this.chargeCalculationType = null;
|
||||||
|
this.percentage = null;
|
||||||
|
this.amountPercentageAppliedTo = null;
|
||||||
|
this.penalty = false;
|
||||||
|
this.chargePaymentMode = null;
|
||||||
|
this.paid = false;
|
||||||
|
this.waived = false;
|
||||||
|
this.amountOrPercentage = amountOrPercentage;
|
||||||
|
this.chargeOptions = null;
|
||||||
|
this.chargePayable = false;
|
||||||
|
this.loanId = null;
|
||||||
|
this.minCap = null;
|
||||||
|
this.maxCap = null;
|
||||||
|
this.installmentChargeData = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isChargePayable() {
|
public boolean isChargePayable() {
|
||||||
@@ -254,4 +283,9 @@ public class LoanChargeData {
|
|||||||
}
|
}
|
||||||
return isInstalmentFee;
|
return isInstalmentFee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public BigDecimal amountOrPercentage() {
|
||||||
|
return this.amountOrPercentage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+2
-4
@@ -963,7 +963,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> loanApplicationModification(final JsonCommand command, final Set<LoanCharge> possiblyModifedLoanCharges,
|
public Map<String, Object> loanApplicationModification(final JsonCommand command, final Set<LoanCharge> possiblyModifedLoanCharges,
|
||||||
final Set<LoanCollateral> possiblyModifedLoanCollateralItems, final AprCalculator aprCalculator) {
|
final Set<LoanCollateral> possiblyModifedLoanCollateralItems, final AprCalculator aprCalculator, boolean isChargesModified) {
|
||||||
|
|
||||||
final Map<String, Object> actualChanges = this.loanRepaymentScheduleDetail.updateLoanApplicationAttributes(command, aprCalculator);
|
final Map<String, Object> actualChanges = this.loanRepaymentScheduleDetail.updateLoanApplicationAttributes(command, aprCalculator);
|
||||||
if (!actualChanges.isEmpty()) {
|
if (!actualChanges.isEmpty()) {
|
||||||
@@ -1141,9 +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 = charges();
|
if (isChargesModified) {
|
||||||
|
|
||||||
if (!possiblyModifedLoanCharges.equals(existingLoanCharges)) {
|
|
||||||
actualChanges.put(chargesParamName, getLoanCharges(possiblyModifedLoanCharges));
|
actualChanges.put(chargesParamName, getLoanCharges(possiblyModifedLoanCharges));
|
||||||
|
|
||||||
actualChanges.put(chargesParamName, getLoanCharges(possiblyModifedLoanCharges));
|
actualChanges.put(chargesParamName, getLoanCharges(possiblyModifedLoanCharges));
|
||||||
|
|||||||
+6
-1
@@ -352,10 +352,10 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
|||||||
loanCharge = percentageOf(this.amountPercentageAppliedTo);
|
loanCharge = percentageOf(this.amountPercentageAppliedTo);
|
||||||
}
|
}
|
||||||
this.amount = minimumAndMaximumCap(loanCharge);
|
this.amount = minimumAndMaximumCap(loanCharge);
|
||||||
this.amountOutstanding = calculateOutstanding();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.amountOrPercentage = amount;
|
this.amountOrPercentage = amount;
|
||||||
|
this.amountOutstanding = calculateOutstanding();
|
||||||
if(this.loan !=null && isInstalmentFee()){
|
if(this.loan !=null && isInstalmentFee()){
|
||||||
final Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this);
|
final Set<LoanInstallmentCharge> chargePerInstallments = this.loan.generateInstallmentLoanCharges(this);
|
||||||
if(this.loanInstallmentCharge.isEmpty()){
|
if(this.loanInstallmentCharge.isEmpty()){
|
||||||
@@ -786,4 +786,9 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
|||||||
public void setActive(boolean active) {
|
public void setActive(boolean active) {
|
||||||
this.active = active;
|
this.active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public BigDecimal amountOrPercentage() {
|
||||||
|
return this.amountOrPercentage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+24
-2
@@ -7,6 +7,7 @@ package org.mifosplatform.portfolio.loanaccount.service;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -45,6 +46,7 @@ import org.mifosplatform.portfolio.fund.domain.Fund;
|
|||||||
import org.mifosplatform.portfolio.group.domain.Group;
|
import org.mifosplatform.portfolio.group.domain.Group;
|
||||||
import org.mifosplatform.portfolio.group.domain.GroupRepositoryWrapper;
|
import org.mifosplatform.portfolio.group.domain.GroupRepositoryWrapper;
|
||||||
import org.mifosplatform.portfolio.group.exception.GroupNotActiveException;
|
import org.mifosplatform.portfolio.group.exception.GroupNotActiveException;
|
||||||
|
import org.mifosplatform.portfolio.loanaccount.data.LoanChargeData;
|
||||||
import org.mifosplatform.portfolio.loanaccount.domain.DefaultLoanLifecycleStateMachine;
|
import org.mifosplatform.portfolio.loanaccount.domain.DefaultLoanLifecycleStateMachine;
|
||||||
import org.mifosplatform.portfolio.loanaccount.domain.Loan;
|
import org.mifosplatform.portfolio.loanaccount.domain.Loan;
|
||||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanCharge;
|
import org.mifosplatform.portfolio.loanaccount.domain.LoanCharge;
|
||||||
@@ -267,13 +269,33 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
|
|||||||
|
|
||||||
if (!existingLoanApplication.isSubmittedAndPendingApproval()) { throw new LoanApplicationNotInSubmittedAndPendingApprovalStateCannotBeModified(
|
if (!existingLoanApplication.isSubmittedAndPendingApproval()) { throw new LoanApplicationNotInSubmittedAndPendingApprovalStateCannotBeModified(
|
||||||
loanId); }
|
loanId); }
|
||||||
|
|
||||||
|
final Set<LoanCharge> existingCharges = existingLoanApplication.charges();
|
||||||
|
Map<Long,LoanChargeData> chargesMap = new HashMap<Long, LoanChargeData>();
|
||||||
|
for(LoanCharge charge:existingCharges){
|
||||||
|
LoanChargeData chargeData = new LoanChargeData(charge.getId(),charge.getDueLocalDate() ,charge.amountOrPercentage());
|
||||||
|
chargesMap.put(charge.getId(), chargeData);
|
||||||
|
}
|
||||||
|
|
||||||
final Set<LoanCharge> possiblyModifedLoanCharges = this.loanChargeAssembler.fromParsedJson(command.parsedJson());
|
final Set<LoanCharge> possiblyModifedLoanCharges = this.loanChargeAssembler.fromParsedJson(command.parsedJson());
|
||||||
|
boolean isChargeModified = false;
|
||||||
|
for(LoanCharge loanCharge : possiblyModifedLoanCharges){
|
||||||
|
if(loanCharge.getId() == null){
|
||||||
|
isChargeModified = true;
|
||||||
|
}else{
|
||||||
|
LoanChargeData chargeData = chargesMap.get(loanCharge.getId());
|
||||||
|
if(loanCharge.amountOrPercentage().compareTo(chargeData.amountOrPercentage()) != 0 ||
|
||||||
|
(loanCharge.isSpecifiedDueDate() && !loanCharge.getDueLocalDate().equals(chargeData.getDueDate()))){
|
||||||
|
isChargeModified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Set<LoanCollateral> possiblyModifedLoanCollateralItems = this.loanCollateralAssembler
|
final Set<LoanCollateral> possiblyModifedLoanCollateralItems = this.loanCollateralAssembler
|
||||||
.fromParsedJson(command.parsedJson());
|
.fromParsedJson(command.parsedJson());
|
||||||
|
|
||||||
final Map<String, Object> changes = existingLoanApplication.loanApplicationModification(command, possiblyModifedLoanCharges,
|
final Map<String, Object> changes = existingLoanApplication.loanApplicationModification(command, possiblyModifedLoanCharges,
|
||||||
possiblyModifedLoanCollateralItems, this.aprCalculator);
|
possiblyModifedLoanCollateralItems, this.aprCalculator, isChargeModified);
|
||||||
|
|
||||||
if (changes.containsKey("expectedDisbursementDate")) {
|
if (changes.containsKey("expectedDisbursementDate")) {
|
||||||
this.loanAssembler.validateExpectedDisbursementForHolidayAndNonWorkingDay(existingLoanApplication);
|
this.loanAssembler.validateExpectedDisbursementForHolidayAndNonWorkingDay(existingLoanApplication);
|
||||||
|
|||||||
Reference in New Issue
Block a user