FINERACT-2181: fix Charges using percentage calculation with min and max gap values
This commit is contained in:
committed by
Adam Saghy
parent
793dcd8e8b
commit
62afd41182
@@ -23,10 +23,18 @@ import io.restassured.builder.ResponseSpecBuilder;
|
||||
import io.restassured.http.ContentType;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import io.restassured.specification.ResponseSpecification;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import org.apache.fineract.client.models.ChargeRequest;
|
||||
import org.apache.fineract.client.models.GetChargesResponse;
|
||||
import org.apache.fineract.client.models.PostChargesResponse;
|
||||
import org.apache.fineract.integrationtests.common.Utils;
|
||||
import org.apache.fineract.integrationtests.common.charges.ChargesHelper;
|
||||
import org.apache.fineract.portfolio.charge.domain.ChargeCalculationType;
|
||||
import org.apache.fineract.portfolio.charge.domain.ChargePaymentMode;
|
||||
import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -321,4 +329,27 @@ public class ChargesTest {
|
||||
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, overdraftFeeChargeId);
|
||||
Assertions.assertEquals(overdraftFeeChargeId, chargeIdAfterDeletion, "Verifying Charge ID after deletion");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChargeUsingPercentageCalculationWithMinAndMaxGapValues() {
|
||||
final ChargesHelper chargesHelper = new ChargesHelper();
|
||||
final BigDecimal minCapVal = BigDecimal.valueOf(23);
|
||||
final BigDecimal maxCapVal = BigDecimal.valueOf(45);
|
||||
|
||||
final PostChargesResponse feeCharge = chargesHelper.createCharges(
|
||||
new ChargeRequest().penalty(false).amount(9.0).chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT.getValue())
|
||||
.chargeTimeType(ChargeTimeType.DISBURSEMENT.getValue()).chargePaymentMode(ChargePaymentMode.REGULAR.getValue())
|
||||
.currencyCode("USD").name(Utils.randomStringGenerator("FEE_" + Calendar.getInstance().getTimeInMillis(), 5))
|
||||
.chargeAppliesTo(1).locale("en").active(true).minCap(minCapVal).maxCap(maxCapVal));
|
||||
|
||||
Assertions.assertNotNull(feeCharge);
|
||||
final Long chargeId = feeCharge.getResourceId();
|
||||
Assertions.assertNotNull(chargeId);
|
||||
|
||||
final GetChargesResponse chargeResponseData = chargesHelper.retrieveCharge(chargeId);
|
||||
Assertions.assertNotNull(chargeResponseData);
|
||||
Assertions.assertEquals(minCapVal.stripTrailingZeros(), chargeResponseData.getMinCap().stripTrailingZeros());
|
||||
Assertions.assertEquals(maxCapVal.stripTrailingZeros(), chargeResponseData.getMaxCap().stripTrailingZeros());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -24,6 +24,7 @@ import io.restassured.specification.ResponseSpecification;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import org.apache.fineract.client.models.ChargeRequest;
|
||||
import org.apache.fineract.client.models.GetChargesResponse;
|
||||
import org.apache.fineract.client.models.PostChargesResponse;
|
||||
import org.apache.fineract.client.util.Calls;
|
||||
import org.apache.fineract.client.util.JSON;
|
||||
@@ -810,4 +811,8 @@ public final class ChargesHelper {
|
||||
public PostChargesResponse createCharges(ChargeRequest request) {
|
||||
return Calls.ok(FineractClientHelper.getFineractClient().charges.createCharge(request));
|
||||
}
|
||||
|
||||
public GetChargesResponse retrieveCharge(final Long chargeId) {
|
||||
return Calls.ok(FineractClientHelper.getFineractClient().charges.retrieveCharge(chargeId));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user