From 5d9598fdf1b077277ac80d77f1f68ceb274b0401 Mon Sep 17 00:00:00 2001 From: franciscocuandon Date: Mon, 11 Sep 2023 08:23:52 -0600 Subject: [PATCH] Execute deposit accrual accounting --- .../accrual/api/AccrualAccountingApiResource.java | 4 ++-- .../api/AccrualAccountingApiResourceSwagger.java | 2 ++ .../accrual/api/AccrualAccountingConstants.java | 3 +++ .../AccrualAccountingDataValidator.java | 4 +++- .../AccrualAccountingWritePlatformServiceImpl.java | 12 +++++++++++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/api/AccrualAccountingApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/api/AccrualAccountingApiResource.java index c14e5965bca..6d11069a148 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/api/AccrualAccountingApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/api/AccrualAccountingApiResource.java @@ -41,7 +41,7 @@ @Path("/v1/runaccruals") @Component -@Tag(name = "Periodic Accrual Accounting", description = "Periodic Accrual is to accrue the loan income till the specific date or till batch job scheduled time.\n") +@Tag(name = "Periodic Accrual Accounting", description = "Periodic Accrual is to accrue the loan income or deposit income/expense till the specific date or till batch job scheduled time.\n") @RequiredArgsConstructor public class AccrualAccountingApiResource { @@ -51,7 +51,7 @@ public class AccrualAccountingApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @Operation(summary = "Executes Periodic Accrual Accounting", method = "POST", description = "Mandatory Fields\n" + "\n" + "tillDate\n") + @Operation(summary = "Executes Periodic Accrual Accounting", method = "POST", description = "Mandatory Fields\n" + "\n" + "tillDate\n" + "\n" + "products\n") @RequestBody(required = true, content = @Content(schema = @Schema(implementation = AccrualAccountingApiResourceSwagger.PostRunaccrualsRequest.class))) @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK") }) public String executePeriodicAccrualAccounting(@Parameter(hidden = true) final String jsonRequestBody) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/api/AccrualAccountingApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/api/AccrualAccountingApiResourceSwagger.java index c18a55b90fc..bda6fe8a681 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/api/AccrualAccountingApiResourceSwagger.java +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/api/AccrualAccountingApiResourceSwagger.java @@ -42,6 +42,8 @@ private PostRunaccrualsRequest() { public String dateFormat; @Schema(example = "04 June 2014", description = "which specifies periodic accruals should happen till the given Date", required = true) public String tillDate; + @Schema(example = "Deposit", description = "which specifies products type to accrue", required = true) + public String products; } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/api/AccrualAccountingConstants.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/api/AccrualAccountingConstants.java index 1a67ca6724d..afcab494be2 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/api/AccrualAccountingConstants.java +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/api/AccrualAccountingConstants.java @@ -27,7 +27,10 @@ private AccrualAccountingConstants() { public static final String accrueTillParamName = "tillDate"; public static final String localeParamName = "locale"; public static final String dateFormatParamName = "dateFormat"; + public static final String productsParamName = "products"; public static final String PERIODIC_ACCRUAL_ACCOUNTING_RESOURCE_NAME = "periodicaccrual"; public static final String PERIODIC_ACCRUAL_ACCOUNTING_EXECUTION_ERROR_CODE = "execution.failed"; + public static final String PERIODIC_ACCRUAL_ACCOUNTING_DEPOSIT = "Deposit"; + public static final String PERIODIC_ACCRUAL_ACCOUNTING_LOAN = "Loan"; } diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/serialization/AccrualAccountingDataValidator.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/serialization/AccrualAccountingDataValidator.java index 65c52753593..e8a3b3977f4 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/serialization/AccrualAccountingDataValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/serialization/AccrualAccountingDataValidator.java @@ -20,6 +20,7 @@ import static org.apache.fineract.accounting.accrual.api.AccrualAccountingConstants.PERIODIC_ACCRUAL_ACCOUNTING_RESOURCE_NAME; import static org.apache.fineract.accounting.accrual.api.AccrualAccountingConstants.accrueTillParamName; +import static org.apache.fineract.accounting.accrual.api.AccrualAccountingConstants.productsParamName; import com.google.gson.JsonElement; import com.google.gson.reflect.TypeToken; @@ -52,7 +53,8 @@ public final class AccrualAccountingDataValidator { private static final Set LOAN_PERIODIC_REQUEST_DATA_PARAMETERS = new HashSet<>( - Arrays.asList(accrueTillParamName, AccrualAccountingConstants.localeParamName, AccrualAccountingConstants.dateFormatParamName)); + Arrays.asList(accrueTillParamName, AccrualAccountingConstants.localeParamName, + AccrualAccountingConstants.dateFormatParamName, productsParamName)); private final FromJsonHelper fromApiJsonHelper; diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/service/AccrualAccountingWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/service/AccrualAccountingWritePlatformServiceImpl.java index 7856cf65e52..18099091d57 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/service/AccrualAccountingWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/accrual/service/AccrualAccountingWritePlatformServiceImpl.java @@ -20,7 +20,10 @@ import static org.apache.fineract.accounting.accrual.api.AccrualAccountingConstants.PERIODIC_ACCRUAL_ACCOUNTING_EXECUTION_ERROR_CODE; import static org.apache.fineract.accounting.accrual.api.AccrualAccountingConstants.PERIODIC_ACCRUAL_ACCOUNTING_RESOURCE_NAME; +import static org.apache.fineract.accounting.accrual.api.AccrualAccountingConstants.PERIODIC_ACCRUAL_ACCOUNTING_DEPOSIT; +import static org.apache.fineract.accounting.accrual.api.AccrualAccountingConstants.PERIODIC_ACCRUAL_ACCOUNTING_LOAN; import static org.apache.fineract.accounting.accrual.api.AccrualAccountingConstants.accrueTillParamName; +import static org.apache.fineract.accounting.accrual.api.AccrualAccountingConstants.productsParamName; import java.time.LocalDate; import java.util.ArrayList; @@ -48,7 +51,14 @@ public CommandProcessingResult executeLoansPeriodicAccrual(JsonCommand command) this.accountingDataValidator.validateLoanPeriodicAccrualData(command.json()); LocalDate tillDate = command.localDateValueOfParameterNamed(accrueTillParamName); try { - this.loanAccrualPlatformService.addPeriodicAccruals(tillDate); + String products = command.stringValueOfParameterNamed(productsParamName); + if (products.contains(PERIODIC_ACCRUAL_ACCOUNTING_DEPOSIT)){ + + } + if (products.contains(PERIODIC_ACCRUAL_ACCOUNTING_LOAN)){ + this.loanAccrualPlatformService.addPeriodicAccruals(tillDate); + } + } catch (MultiException e) { final List dataValidationErrors = new ArrayList<>(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)