diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index 4a9649a79..27a3e0400 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -11072,6 +11072,26 @@ Request Body: This field is mandatory if chargeTimeType is of type Monthly Fee + + minCap + + + minimum cap: a 2% fee with a minimum cap of 500
+ In case of a 5000 loan, the 2% is 100, and therefore automatically 500 is used as the value of the charge.
+ This field is optional and can be used along when ChargeCalculationType equals (2) PERCENT_OF_AMOUNT + + + + + + maxCap + + + maximum cap: A 2% fee, with a maximum of 2000.
+ In case of a 150000 loan, the 2% adds up to 3000 charge, and therefore the maximum cap of 2000 will be used.
+ This field is optional and can be used along when ChargeCalculationType equals (2) PERCENT_OF_AMOUNT + + diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/Charge.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/Charge.java index 9b59c3d80..820754e81 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/Charge.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/Charge.java @@ -123,8 +123,7 @@ public class Charge extends AbstractPersistable { this.penalty = penalty; this.active = active; this.chargePaymentMode = paymentMode == null ? null : paymentMode.getValue(); - this.minCap = minCap; - this.maxCap = maxCap; + final List dataValidationErrors = new ArrayList(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("charges"); @@ -162,6 +161,10 @@ public class Charge extends AbstractPersistable { .failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.loan"); } } + if(isPercentageOfAmount()){ + this.minCap = minCap; + this.maxCap = maxCap; + } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } }