forked from apache/fineract
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jose Alberto Hernandez
committed
Sep 13, 2023
1 parent
a4b6fe8
commit 178808f
Showing
15 changed files
with
296 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...e/fineract/accounting/accrual/handler/ExecutePeriodicAccrualForSavingsCommandHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.fineract.accounting.accrual.handler; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.apache.fineract.accounting.accrual.service.AccrualAccountingWritePlatformService; | ||
import org.apache.fineract.commands.annotation.CommandType; | ||
import org.apache.fineract.commands.handler.NewCommandSourceHandler; | ||
import org.apache.fineract.infrastructure.core.api.JsonCommand; | ||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@CommandType(entity = "PERIODICACCRUALACCOUNTINGFORSAVINGS", action = "EXECUTE") | ||
@RequiredArgsConstructor | ||
public class ExecutePeriodicAccrualForSavingsCommandHandler implements NewCommandSourceHandler { | ||
|
||
private final AccrualAccountingWritePlatformService writePlatformService; | ||
|
||
@Transactional | ||
@Override | ||
public CommandProcessingResult processCommand(final JsonCommand command) { | ||
return this.writePlatformService.executeLoansPeriodicAccrual(command); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...o/savings/jobs/addaccrualtransactionforsavings/AddAccrualTransactionForSavingsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.fineract.portfolio.savings.jobs.addaccrualtransactionforsavings; | ||
|
||
import org.apache.fineract.infrastructure.jobs.service.JobName; | ||
import org.apache.fineract.portfolio.savings.service.SavingsAccountChargeReadPlatformService; | ||
import org.apache.fineract.portfolio.savings.service.SavingsAccountWritePlatformService; | ||
import org.springframework.batch.core.Job; | ||
import org.springframework.batch.core.Step; | ||
import org.springframework.batch.core.job.builder.JobBuilder; | ||
import org.springframework.batch.core.launch.support.RunIdIncrementer; | ||
import org.springframework.batch.core.repository.JobRepository; | ||
import org.springframework.batch.core.step.builder.StepBuilder; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
|
||
@Configuration | ||
public class AddAccrualTransactionForSavingsConfig { | ||
|
||
@Autowired | ||
private JobRepository jobRepository; | ||
@Autowired | ||
private PlatformTransactionManager transactionManager; | ||
@Autowired | ||
private SavingsAccountChargeReadPlatformService savingsAccountChargeReadPlatformService; | ||
@Autowired | ||
private SavingsAccountWritePlatformService savingsAccountWritePlatformService; | ||
|
||
@Bean | ||
protected Step addAccrualTransactionForSavingsStep() { | ||
return new StepBuilder(JobName.ADD_PERIODIC_ACCRUAL_ENTRIES_FOR_SAVINGS_WITH_INCOME_POSTED_AS_TRANSACTIONS.name(), jobRepository) | ||
.tasklet(addAccrualTransactionForSavingsTasklet(), transactionManager).build(); | ||
} | ||
|
||
@Bean | ||
public Job addAccrualTransactionForSavingsJob() { | ||
return new JobBuilder(JobName.ADD_PERIODIC_ACCRUAL_ENTRIES_FOR_SAVINGS_WITH_INCOME_POSTED_AS_TRANSACTIONS.name(), jobRepository).start(addAccrualTransactionForSavingsStep()) | ||
.incrementer(new RunIdIncrementer()).build(); | ||
} | ||
|
||
@Bean | ||
public AddAccrualTransactionForSavingsTasklet addAccrualTransactionForSavingsTasklet() { | ||
return new AddAccrualTransactionForSavingsTasklet(savingsAccountChargeReadPlatformService, savingsAccountWritePlatformService); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
.../savings/jobs/addaccrualtransactionforsavings/AddAccrualTransactionForSavingsTasklet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.fineract.portfolio.savings.jobs.addaccrualtransactionforsavings; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.fineract.infrastructure.core.data.ApiParameterError; | ||
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; | ||
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil; | ||
import org.apache.fineract.portfolio.savings.data.SavingsAccountAnnualFeeData; | ||
import org.apache.fineract.portfolio.savings.service.SavingsAccountChargeReadPlatformService; | ||
import org.apache.fineract.portfolio.savings.service.SavingsAccountWritePlatformService; | ||
import org.springframework.batch.core.StepContribution; | ||
import org.springframework.batch.core.scope.context.ChunkContext; | ||
import org.springframework.batch.core.step.tasklet.Tasklet; | ||
import org.springframework.batch.repeat.RepeatStatus; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class AddAccrualTransactionForSavingsTasklet implements Tasklet { | ||
|
||
private final SavingsAccountChargeReadPlatformService savingsAccountChargeReadPlatformService; | ||
private final SavingsAccountWritePlatformService savingsAccountWritePlatformService; | ||
|
||
@Override | ||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { | ||
final Collection<SavingsAccountAnnualFeeData> annualFeeData = savingsAccountChargeReadPlatformService | ||
.retrieveChargesWithAnnualFeeDue(); | ||
|
||
for (final SavingsAccountAnnualFeeData savingsAccountReference : annualFeeData) { | ||
try { | ||
savingsAccountWritePlatformService.applyAnnualFee(savingsAccountReference.getId(), savingsAccountReference.getAccountId()); | ||
} catch (final PlatformApiDataValidationException e) { | ||
final List<ApiParameterError> errors = e.getErrors(); | ||
for (final ApiParameterError error : errors) { | ||
log.error("Add Accrual Transaction failed for account: {} with message {}", savingsAccountReference.getAccountNo(), error); | ||
} | ||
} catch (final Exception ex) { | ||
log.error("Add Accrual Transaction failed for account: {}", savingsAccountReference.getAccountNo(), ex); | ||
} | ||
} | ||
|
||
log.debug("{}: Records affected by addAccrualTransactionForSavings: {}", ThreadLocalContextUtil.getTenant().getName(), | ||
annualFeeData.size()); | ||
return RepeatStatus.FINISHED; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
fineract-provider/src/main/resources/db/custom-changelog/0002_add_savings_accrual_job.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.3.xsd"> | ||
<changeSet author="fineract" id="1"> | ||
<insert tableName="job"> | ||
<column name="name" value="Add Accrual Transactions For Savings"/> | ||
<column name="display_name" value="Add Accrual Transactions For Savings"/> | ||
<column name="cron_expression" value="0 1 0 1/1 * ? *"/> | ||
<column name="create_time" valueDate="${current_datetime}"/> | ||
<column name="task_priority" valueNumeric="5"/> | ||
<column name="group_name"/> | ||
<column name="previous_run_start_time"/> | ||
<column name="job_key" value="Add Accrual Transactions For Savings _ DEFAULT"/> | ||
<column name="initializing_errorlog"/> | ||
<column name="is_active" valueBoolean="false"/> | ||
<column name="currently_running" valueBoolean="false"/> | ||
<column name="updates_allowed" valueBoolean="true"/> | ||
<column name="scheduler_group" valueNumeric="0"/> | ||
<column name="is_misfired" valueBoolean="false"/> | ||
<column name="node_id" valueNumeric="1"/> | ||
<column name="is_mismatched_job" valueBoolean="true"/> | ||
</insert> | ||
</changeSet> | ||
</databaseChangeLog> |
Oops, something went wrong.