Charts data is mandatory for creating a fixed deposit product
This commit is contained in:
committed by
Arnold Gálovics
parent
4fdee75beb
commit
4ebe645c58
+1
-1
@@ -95,7 +95,7 @@ public class BusinessDateApiResource {
|
||||
@Operation(summary = "Update Business Date", description = "")
|
||||
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = BusinessDateApiResourceSwagger.BusinessDateRequest.class)))
|
||||
@ApiResponses({
|
||||
@ApiResponse(responseCode = "200", description = "", content = @Content(schema = @Schema(implementation = BusinessDateApiResourceSwagger.BusinessDateRequest.class))) })
|
||||
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = BusinessDateApiResourceSwagger.BusinessDateRequest.class))) })
|
||||
public String updateBusinessDate(final String jsonRequestBody, @Context UriInfo uriInfo) {
|
||||
securityContext.authenticatedUser().validateHasUpdatePermission("BUSINESS_DATE");
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateBusinessDate().withJson(jsonRequestBody).build();
|
||||
|
||||
+12
-12
@@ -395,18 +395,18 @@ public class DepositProductDataValidator {
|
||||
|
||||
private void validateChartsData(JsonElement element, DataValidatorBuilder baseDataValidator) {
|
||||
if (element.isJsonObject()) {
|
||||
final JsonObject topLevelJsonElement = element.getAsJsonObject();
|
||||
if (topLevelJsonElement.has(chartsParamName) && topLevelJsonElement.get(chartsParamName).isJsonArray()) {
|
||||
final JsonArray array = topLevelJsonElement.get(chartsParamName).getAsJsonArray();
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
final JsonObject interestRateChartElement = array.get(i).getAsJsonObject();
|
||||
final String json = this.fromApiJsonHelper.toJson(interestRateChartElement);
|
||||
// chart for create
|
||||
if (!this.fromApiJsonHelper.parameterExists(idParamName, interestRateChartElement)) {
|
||||
this.chartDataValidator.validateForCreate(json, baseDataValidator);
|
||||
} else { // chart for update
|
||||
this.chartDataValidator.validateForUpdate(json, baseDataValidator);
|
||||
}
|
||||
|
||||
final JsonArray array = this.fromApiJsonHelper.extractJsonArrayNamed(chartsParamName, element);
|
||||
baseDataValidator.reset().parameter(chartsParamName).value(array).notNull().jsonArrayNotEmpty();
|
||||
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
final JsonObject interestRateChartElement = array.get(i).getAsJsonObject();
|
||||
final String json = this.fromApiJsonHelper.toJson(interestRateChartElement);
|
||||
// chart for create
|
||||
if (!this.fromApiJsonHelper.parameterExists(idParamName, interestRateChartElement)) {
|
||||
this.chartDataValidator.validateForCreate(json, baseDataValidator);
|
||||
} else { // chart for update
|
||||
this.chartDataValidator.validateForUpdate(json, baseDataValidator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+55
-1
@@ -128,6 +128,45 @@ public class FixedDepositTest {
|
||||
this.systemTimeZone = TimeZone.getTimeZone(Utils.TENANT_TIME_ZONE);
|
||||
}
|
||||
|
||||
/***
|
||||
* Test case for Fixed Deposit Product with default attributes
|
||||
*/
|
||||
@Test
|
||||
public void testFixedDepositProductCreation() {
|
||||
this.fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
/***
|
||||
* Create GL Accounts for product account mapping
|
||||
*/
|
||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
||||
final Account liabilityAccount = this.accountHelper.createLiabilityAccount();
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
todaysDate.add(Calendar.YEAR, 10);
|
||||
final String VALID_TO = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
final String accountingRule = CASH_BASED;
|
||||
/***
|
||||
* Create FD product with charts (must be 200 OK)
|
||||
*/
|
||||
Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO, accountingRule, assetAccount, liabilityAccount,
|
||||
incomeAccount, expenseAccount);
|
||||
Assertions.assertNotNull(fixedDepositProductId);
|
||||
|
||||
/***
|
||||
* Create FD product without charts (must be 400 Bad Request)
|
||||
*/
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
createFixedDepositProductWithoutCharts(VALID_FROM, VALID_TO, accountingRule, assetAccount, liabilityAccount, incomeAccount,
|
||||
expenseAccount);
|
||||
}
|
||||
|
||||
/***
|
||||
* Test case for Fixed Deposit Account premature closure with transaction type withdrawal and Cash Based accounting
|
||||
* enabled
|
||||
@@ -2543,7 +2582,21 @@ public class FixedDepositTest {
|
||||
fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsNone();
|
||||
}
|
||||
final String fixedDepositProductJSON = fixedDepositProductHelper.withPeriodRangeChart() //
|
||||
.build(validFrom, validTo);
|
||||
.build(validFrom, validTo, true);
|
||||
return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
private Integer createFixedDepositProductWithoutCharts(final String validFrom, final String validTo, final String accountingRule,
|
||||
Account... accounts) {
|
||||
LOG.info("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------");
|
||||
FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
if (accountingRule.equals(CASH_BASED)) {
|
||||
fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts);
|
||||
} else if (accountingRule.equals(NONE)) {
|
||||
fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsNone();
|
||||
}
|
||||
final String fixedDepositProductJSON = fixedDepositProductHelper.withPeriodRangeChart() //
|
||||
.build(validFrom, validTo, false);
|
||||
return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
@@ -2706,6 +2759,7 @@ public class FixedDepositTest {
|
||||
*/
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec);
|
||||
for (HashMap financialActivity : financialActivities) {
|
||||
Integer financialActivityAccountId = (Integer) financialActivity.get("id");
|
||||
|
||||
+14
-8
@@ -99,17 +99,23 @@ public class FixedDepositProductHelper {
|
||||
private String taxGroupId = null;
|
||||
|
||||
public String build(final String validFrom, final String validTo) {
|
||||
return build(validFrom, validTo, true);
|
||||
}
|
||||
|
||||
public String build(final String validFrom, final String validTo, final boolean withCharts) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
List<HashMap<String, Object>> charts = new ArrayList<HashMap<String, Object>>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<>();
|
||||
chartsMap.put("fromDate", validFrom);
|
||||
chartsMap.put("endDate", validTo);
|
||||
chartsMap.put("dateFormat", "dd MMMM yyyy");
|
||||
chartsMap.put("locale", LOCALE);
|
||||
chartsMap.put("chartSlabs", this.chartSlabs);
|
||||
chartsMap.put("isPrimaryGroupingByAmount", this.isPrimaryGroupingByAmount);
|
||||
charts.add(chartsMap);
|
||||
if (withCharts) {
|
||||
HashMap<String, Object> chartsMap = new HashMap<>();
|
||||
chartsMap.put("fromDate", validFrom);
|
||||
chartsMap.put("endDate", validTo);
|
||||
chartsMap.put("dateFormat", "dd MMMM yyyy");
|
||||
chartsMap.put("locale", LOCALE);
|
||||
chartsMap.put("chartSlabs", this.chartSlabs);
|
||||
chartsMap.put("isPrimaryGroupingByAmount", this.isPrimaryGroupingByAmount);
|
||||
charts.add(chartsMap);
|
||||
}
|
||||
|
||||
map.put("charts", charts);
|
||||
map.put("name", this.name);
|
||||
|
||||
Reference in New Issue
Block a user