FINERACT-2181: fix Charges using percentage calculation with min and max gap values

This commit is contained in:
Jose Alberto Hernandez
2025-05-16 15:44:37 +02:00
committed by Adam Saghy
parent 793dcd8e8b
commit 62afd41182
6 changed files with 51 additions and 3 deletions
@@ -84,6 +84,8 @@ public class ChargesApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Retrieve a Charge", description = "Returns the details of a defined Charge.\n" + "\n" + "Example Requests:\n"
+ "\n" + "charges/1")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = ChargesApiResourceSwagger.GetChargesResponse.class))) })
public ChargeData retrieveCharge(@PathParam("chargeId") @Parameter(description = "chargeId") final Long chargeId,
@Context final UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.charge.api;
import io.swagger.v3.oas.annotations.media.Schema;
import java.math.BigDecimal;
import java.util.Set;
/**
@@ -110,6 +111,8 @@ final class ChargesApiResourceSwagger {
public GetChargesAppliesToResponse chargeAppliesTo;
public GetChargesCalculationTypeResponse chargeCalculationType;
public GetChargesPaymentModeResponse chargePaymentMode;
public BigDecimal minCap;
public BigDecimal maxCap;
}
@Schema(description = "PostChargesRequest")
@@ -139,6 +142,10 @@ final class ChargesApiResourceSwagger {
public String monthDayFormat;
@Schema(example = "false")
public boolean penalty;
@Schema(example = "23.43")
public BigDecimal minCap;
@Schema(example = "45.56")
public BigDecimal maxCap;
}
@Schema(description = "PostChargesResponse")
@@ -196,9 +203,9 @@ final class ChargesApiResourceSwagger {
@Schema(example = "1")
public Long paymentTypeId;
@Schema(example = "10.0")
public Double minCap;
public BigDecimal minCap;
@Schema(example = "120.0")
public Double maxCap;
public BigDecimal maxCap;
}
@Schema(description = "PutChargesChargeIdResponse")
@@ -262,7 +262,7 @@ public class Charge extends AbstractPersistableCustom<Long> {
}
}
if (isPercentageOfApprovedAmount()) {
if (isPercentageOfDisbursementAmount() || isPercentageOfApprovedAmount()) {
this.minCap = minCap;
this.maxCap = maxCap;
}
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.charge.request;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@@ -48,5 +49,7 @@ public class ChargeRequest implements Serializable {
private String feeFrequency;
private Long paymentTypeId;
private Boolean enablePaymentType;
private BigDecimal minCap;
private BigDecimal maxCap;
}