Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute deposit accrual accounting #6

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,7 +53,8 @@
public final class AccrualAccountingDataValidator {

private static final Set<String> 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
Expand Down
Loading