FINERACT-1981: Loan schedule handling of tranche disbursement charges

This commit is contained in:
budaidev
2025-05-29 15:01:23 +02:00
committed by Adam Saghy
parent 96d6099cc1
commit 6e77b0702a
9 changed files with 888 additions and 31 deletions
@@ -31,7 +31,9 @@ public enum ChargeProductType {
LOAN_INSTALLMENT_PERCENTAGE_FEE(9L), //
LOAN_PERCENTAGE_LATE_FEE_AMOUNT_PLUS_INTEREST(10L), //
CLIENT_TEST_CHARGE_FEE(11L), //
LOAN_DISBURSEMENT_CHARGE(12L); //
LOAN_DISBURSEMENT_CHARGE(12L), //
CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT(13L), //
CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT(14L); //
public final Long value;
@@ -55,6 +55,8 @@ public class ChargeGlobalInitializerStep implements FineractGlobalInitializerSte
public static final String CHARGE_LOAN_INSTALLMENT_PERCENT_FEE = "Installment percentage fee";
public static final String CHARGE_CLIENT_FIXED_FEE = "Fixed fee for Client";
public static final String CHARGE_DISBURSEMENT_CHARGE = "Disbursement Charge";
public static final String CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT = "Tranche Disbursement Charge Amount";
public static final String CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT = "Tranche Disbursement Charge Percent";
public static final Double CHARGE_AMOUNT_FLAT = 25D;
public static final Double CHARGE_AMOUNT_PERCENTAGE = 5D;
public static final Double CHARGE_AMOUNT_DISBURSEMENT_PERCENTAGE = 1.5D;
@@ -155,6 +157,24 @@ public class ChargeGlobalInitializerStep implements FineractGlobalInitializerSte
CHARGE_TIME_TYPE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, false);
Response<PostChargesResponse> responseDisbursementCharge = chargesApi.createCharge(requestDisbursementCharge).execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_DISBURSEMENT_CHARGE_CREATE_RESPONSE, responseDisbursementCharge);
// Loan - Tranche Disbursement Charge (Flat)
ChargeRequest requestTrancheDisbursementCharge = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT, CHARGE_TIME_TYPE_TRANCHE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_FLAT, 10.0,
true, false);
Response<PostChargesResponse> responseTrancheDisbursementCharge = chargesApi.createCharge(requestTrancheDisbursementCharge)
.execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_CHARGE_FLAT_CREATE_RESPONSE,
responseTrancheDisbursementCharge);
// Loan - Tranche Disbursement Charge (%)
ChargeRequest requestTrancheDisbursementChargePercent = defaultChargesRequest(CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT, CHARGE_TIME_TYPE_TRANCHE_DISBURSEMENT,
CHARGE_CALCULATION_TYPE_PERCENTAGE_DISBURSEMENT_AMOUNT, 2.0, true, false);
Response<PostChargesResponse> responseTrancheDisbursementChargePercent = chargesApi
.createCharge(requestTrancheDisbursementChargePercent).execute();
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT_CREATE_RESPONSE,
responseTrancheDisbursementChargePercent);
}
public static ChargeRequest defaultChargesRequest(Enum<ChargeProductAppliesTo> appliesTo, String name, Integer chargeTimeType,
@@ -48,4 +48,18 @@ public class ChargeStepDef extends AbstractStepDef {
.execute();
ErrorHelper.checkSuccessfulApiCall(responseDisbursementCharge);
}
@When("Admin updates charge {string} with {string} calculation type and {double} EUR amount")
public void updateChargeWithFlatAmount(String chargeType, String chargeCalculationType, double flatAmount) throws IOException {
ChargeRequest disbursementChargeUpdateRequest = new ChargeRequest();
ChargeCalculationType chargeProductTypeValue = ChargeCalculationType.valueOf(chargeCalculationType);
disbursementChargeUpdateRequest.chargeCalculationType(chargeProductTypeValue.value).amount(flatAmount).locale("en");
ChargeProductType chargeProductType = ChargeProductType.valueOf(chargeType);
Long chargeId = chargeProductType.getValue();
Response<PutChargesChargeIdResponse> responseDisbursementCharge = chargesApi.updateCharge(chargeId, disbursementChargeUpdateRequest)
.execute();
ErrorHelper.checkSuccessfulApiCall(responseDisbursementCharge);
}
}
@@ -168,6 +168,7 @@ public abstract class TestContextKey {
public static final String CHARGE_FOR_LOAN_NSF_FEE_CREATE_RESPONSE = "ChargeForLoanNsfFeeCreateResponse";
public static final String CHARGE_FOR_LOAN_DISBURSEMENET_FEE_CREATE_RESPONSE = "ChargeForLoanDisbursementCreateResponse";
public static final String CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_PERCENT_CREATE_RESPONSE = "ChargeForLoanTrancheDisbursementPercentCreateResponse";
public static final String CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT_CREATE_RESPONSE = "ChargeForLoanTrancheDisbursementChargePercentCreateResponse";
public static final String CHARGE_FOR_LOAN_INSTALLMENT_FEE_CREATE_RESPONSE = "ChargeForLoanInstallmentCreateResponse";
public static final String CHARGE_FOR_CLIENT_FIXED_FEE_CREATE_RESPONSE = "ChargeForClientFixedFeeCreateResponse";
public static final String CHARGE_FOR_LOAN_DISBURSEMENT_CHARGE_CREATE_RESPONSE = "ChargeForLoanDisbursementChargeCreateResponse";
@@ -200,6 +201,7 @@ public abstract class TestContextKey {
public static final String TRANSACTION_IDEMPOTENCY_KEY = "transactionIdempotencyKey";
public static final String LOAN_CHARGE_OFF_RESPONSE = "loanChargeOffResponse";
public static final String LOAN_CHARGE_OFF_UNDO_RESPONSE = "loanChargeOffUndoResponse";
public static final String CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_CHARGE_FLAT_CREATE_RESPONSE = "ChargeForLoanTrancheDisbursementChargeCreateResponse";
public static final String CREATED_SIMPLE_USER_RESPONSE = "createdSimpleUserResponse";
public static final String ASSET_EXTERNALIZATION_RESPONSE = "assetExternalizationResponse";
public static final String ASSET_EXTERNALIZATION_TRANSFER_EXTERNAL_ID_USER_GENERATED = "assetExternalizationTransferExternalIdUserGenerated";