FINERACT-2326: Charges with Tax group Id ignored
This commit is contained in:
committed by
Adam Saghy
parent
c55cfe9d08
commit
33fae09afb
@@ -27,9 +27,18 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
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.models.PostTaxesComponentsRequest;
|
||||
import org.apache.fineract.client.models.PostTaxesComponentsResponse;
|
||||
import org.apache.fineract.client.models.PostTaxesGroupRequest;
|
||||
import org.apache.fineract.client.models.PostTaxesGroupResponse;
|
||||
import org.apache.fineract.client.models.PostTaxesGroupTaxComponents;
|
||||
import org.apache.fineract.integrationtests.common.TaxComponentHelper;
|
||||
import org.apache.fineract.integrationtests.common.TaxGroupHelper;
|
||||
import org.apache.fineract.integrationtests.common.Utils;
|
||||
import org.apache.fineract.integrationtests.common.charges.ChargesHelper;
|
||||
import org.apache.fineract.portfolio.charge.domain.ChargeCalculationType;
|
||||
@@ -352,4 +361,39 @@ public class ChargesTest {
|
||||
Assertions.assertEquals(maxCapVal.stripTrailingZeros(), chargeResponseData.getMaxCap().stripTrailingZeros());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChargeCreationWithTaxGroup() {
|
||||
final ChargesHelper chargesHelper = new ChargesHelper();
|
||||
|
||||
final PostTaxesComponentsRequest taxComponentRequest = new PostTaxesComponentsRequest()
|
||||
.name(Utils.randomStringGenerator("TAX_COM_", 4)).percentage(12.0f).startDate("01 January 2023").dateFormat("dd MMMM yyyy")
|
||||
.locale("en");
|
||||
|
||||
final PostTaxesComponentsResponse taxComponentRespose = TaxComponentHelper.createTaxComponent(taxComponentRequest);
|
||||
Assertions.assertNotNull(taxComponentRequest);
|
||||
|
||||
final Set<PostTaxesGroupTaxComponents> taxComponentsSet = new HashSet<>();
|
||||
taxComponentsSet
|
||||
.add(new PostTaxesGroupTaxComponents().taxComponentId(taxComponentRespose.getResourceId()).startDate("01 January 2023"));
|
||||
final PostTaxesGroupRequest taxGroupRequest = new PostTaxesGroupRequest().name(Utils.randomStringGenerator("TAX_GRP_", 4))
|
||||
.taxComponents(taxComponentsSet).dateFormat("dd MMMM yyyy").locale("en");
|
||||
final PostTaxesGroupResponse taxGroupResponse = TaxGroupHelper.createTaxGroup(taxGroupRequest);
|
||||
Assertions.assertNotNull(taxGroupResponse);
|
||||
|
||||
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).taxGroupId(taxGroupResponse.getResourceId()));
|
||||
|
||||
Assertions.assertNotNull(feeCharge);
|
||||
final Long chargeId = feeCharge.getResourceId();
|
||||
Assertions.assertNotNull(chargeId);
|
||||
|
||||
final GetChargesResponse chargeResponseData = chargesHelper.retrieveCharge(chargeId);
|
||||
Assertions.assertNotNull(chargeResponseData);
|
||||
Assertions.assertNotNull(chargeResponseData.getTaxGroup());
|
||||
Assertions.assertEquals(chargeResponseData.getTaxGroup().getId(), taxGroupResponse.getResourceId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-3
@@ -22,6 +22,9 @@ import com.google.gson.Gson;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import io.restassured.specification.ResponseSpecification;
|
||||
import java.util.HashMap;
|
||||
import org.apache.fineract.client.models.PostTaxesComponentsRequest;
|
||||
import org.apache.fineract.client.models.PostTaxesComponentsResponse;
|
||||
import org.apache.fineract.client.util.Calls;
|
||||
import org.apache.fineract.integrationtests.common.accounting.Account;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -66,7 +69,7 @@ public final class TaxComponentHelper {
|
||||
@Deprecated(forRemoval = true)
|
||||
public static HashMap<String, String> getBasicTaxComponentMap(final String percentage) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("name", randomNameGenerator("Tax_component_Name_", 5));
|
||||
map.put("name", Utils.randomStringGenerator("Tax_component_Name_", 5));
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
map.put("percentage", percentage);
|
||||
@@ -74,8 +77,8 @@ public final class TaxComponentHelper {
|
||||
return map;
|
||||
}
|
||||
|
||||
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
|
||||
public static PostTaxesComponentsResponse createTaxComponent(PostTaxesComponentsRequest request) {
|
||||
return Calls.ok(FineractClientHelper.getFineractClient().taxComponents.createTaxComponent(request));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-3
@@ -25,6 +25,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.apache.fineract.client.models.PostTaxesGroupRequest;
|
||||
import org.apache.fineract.client.models.PostTaxesGroupResponse;
|
||||
import org.apache.fineract.client.util.Calls;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -54,7 +57,7 @@ public final class TaxGroupHelper {
|
||||
@Deprecated(forRemoval = true)
|
||||
public static String getTaxGroupAsJSON(final Collection<Integer> taxComponentIds) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("name", randomNameGenerator("Tax_component_Name_", 5));
|
||||
map.put("name", Utils.randomStringGenerator("Tax_group_Name_", 5));
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
map.put("taxComponents", getTaxGroupComponents(taxComponentIds));
|
||||
@@ -84,8 +87,8 @@ public final class TaxGroupHelper {
|
||||
return map;
|
||||
}
|
||||
|
||||
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
|
||||
public static PostTaxesGroupResponse createTaxGroup(PostTaxesGroupRequest request) {
|
||||
return Calls.ok(FineractClientHelper.getFineractClient().taxGroups.createTaxGroup(request));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-4
@@ -65,10 +65,6 @@ public final class ChargesHelper {
|
||||
public static final Integer SHARE_PURCHASE = 14;
|
||||
public static final Integer SHARE_REDEEM = 15;
|
||||
|
||||
private static final Integer CHARGE_SAVINGS_NO_ACTIVITY_FEE = 16;
|
||||
|
||||
private static final Integer CHARGE_CLIENT_SPECIFIED_DUE_DATE = 1;
|
||||
|
||||
public static final Integer CHARGE_CALCULATION_TYPE_FLAT = 1;
|
||||
public static final Integer CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT = 2;
|
||||
public static final Integer CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST = 3;
|
||||
|
||||
Reference in New Issue
Block a user