savings charge currency must match savings account currency
This commit is contained in:
-3
@@ -336,9 +336,6 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
if (!CollectionUtils.isEmpty(savingsAccountCharges)) {
|
if (!CollectionUtils.isEmpty(savingsAccountCharges)) {
|
||||||
this.charges = associateChargesWithThisSavingsAccount(savingsAccountCharges);
|
this.charges = associateChargesWithThisSavingsAccount(savingsAccountCharges);
|
||||||
// TODO:Add charges details to savings summary
|
|
||||||
// this.summary =
|
|
||||||
// updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.summary = new SavingsAccountSummary();
|
this.summary = new SavingsAccountSummary();
|
||||||
|
|||||||
+1
-1
@@ -236,7 +236,7 @@ public class SavingsAccountAssembler {
|
|||||||
monthDayOfAnnualFee = product.monthDayOfAnnualFee();
|
monthDayOfAnnualFee = product.monthDayOfAnnualFee();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Set<SavingsAccountCharge> charges = this.savingsAccountChargeAssembler.fromParsedJson(element);
|
final Set<SavingsAccountCharge> charges = this.savingsAccountChargeAssembler.fromParsedJson(element, product.currency().getCode());
|
||||||
|
|
||||||
final SavingsAccount account = SavingsAccount.createNewApplicationForSubmittal(client, group, product, fieldOfficer, accountNo,
|
final SavingsAccount account = SavingsAccount.createNewApplicationForSubmittal(client, group, product, fieldOfficer, accountNo,
|
||||||
externalId, accountType, submittedOnDate, interestRate, interestCompoundingPeriodType, interestPostingPeriodType,
|
externalId, accountType, submittedOnDate, interestRate, interestCompoundingPeriodType, interestPostingPeriodType,
|
||||||
|
|||||||
+5
@@ -506,6 +506,11 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
|
|||||||
return this.savingsAccount;
|
return this.savingsAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasCurrencyCodeOf(final String matchingCurrencyCode) {
|
||||||
|
if (this.currencyCode() == null || matchingCurrencyCode == null) { return false; }
|
||||||
|
return this.currencyCode().equalsIgnoreCase(matchingCurrencyCode);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (obj == null) { return false; }
|
if (obj == null) { return false; }
|
||||||
|
|||||||
+21
-1
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.portfolio.savings.domain;
|
package org.mifosplatform.portfolio.savings.domain;
|
||||||
|
|
||||||
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME;
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.amountParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.amountParamName;
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.chargeCalculationTypeParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.chargeCalculationTypeParamName;
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.chargeIdParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.chargeIdParamName;
|
||||||
@@ -14,11 +15,16 @@ import static org.mifosplatform.portfolio.savings.SavingsApiConstants.dueAsOfDat
|
|||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.idParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.idParamName;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
||||||
|
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||||
import org.mifosplatform.portfolio.charge.domain.Charge;
|
import org.mifosplatform.portfolio.charge.domain.Charge;
|
||||||
import org.mifosplatform.portfolio.charge.domain.ChargeCalculationType;
|
import org.mifosplatform.portfolio.charge.domain.ChargeCalculationType;
|
||||||
@@ -48,7 +54,7 @@ public class SavingsAccountChargeAssembler {
|
|||||||
this.savingsAccountChargeRepository = savingsAccountChargeRepository;
|
this.savingsAccountChargeRepository = savingsAccountChargeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<SavingsAccountCharge> fromParsedJson(final JsonElement element) {
|
public Set<SavingsAccountCharge> fromParsedJson(final JsonElement element, final String productCurrencyCode) {
|
||||||
|
|
||||||
final Set<SavingsAccountCharge> savingsAccountCharges = new HashSet<SavingsAccountCharge>();
|
final Set<SavingsAccountCharge> savingsAccountCharges = new HashSet<SavingsAccountCharge>();
|
||||||
|
|
||||||
@@ -106,6 +112,20 @@ public class SavingsAccountChargeAssembler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.validateSavingsCharges(savingsAccountCharges, productCurrencyCode);
|
||||||
return savingsAccountCharges;
|
return savingsAccountCharges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateSavingsCharges(final Set<SavingsAccountCharge> charges, final String productCurrencyCode) {
|
||||||
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||||
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||||
|
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME);
|
||||||
|
for (SavingsAccountCharge savingsAccountCharge : charges) {
|
||||||
|
if(!savingsAccountCharge.hasCurrencyCodeOf(productCurrencyCode)){
|
||||||
|
baseDataValidator.reset().parameter("currency").value(savingsAccountCharge.getCharge().getId())
|
||||||
|
.failWithCodeNoParameterAddedToErrorCode("currency.and.charge.currency.not.same");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-4
@@ -233,10 +233,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (changes.containsKey("charges")) {
|
if (changes.containsKey("charges")) {
|
||||||
// final Set<Charge> savingsProductCharges =
|
final Set<SavingsAccountCharge> charges = this.savingsAccountChargeAssembler.fromParsedJson(command.parsedJson(), account.getCurrency().getCode());
|
||||||
// this.savi.assembleListOfSavingsProductCharges(command,
|
|
||||||
// product.currency().getCode());
|
|
||||||
final Set<SavingsAccountCharge> charges = this.savingsAccountChargeAssembler.fromParsedJson(command.parsedJson());
|
|
||||||
final boolean updated = account.update(charges);
|
final boolean updated = account.update(charges);
|
||||||
if (!updated) {
|
if (!updated) {
|
||||||
changes.remove("charges");
|
changes.remove("charges");
|
||||||
|
|||||||
Reference in New Issue
Block a user