You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@fineract.apache.org by AvinashKumarG <gi...@git.apache.org> on 2016/05/09 13:02:31 UTC
[GitHub] incubator-fineract pull request: 293_post_interest_job
GitHub user AvinashKumarG opened a pull request:
https://github.com/apache/incubator-fineract/pull/103
293_post_interest_job
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/AvinashKumarG/incubator-fineract post_interestjob
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-fineract/pull/103.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #103
----
commit c991449da731f3938dc6a6fc3d17a18523c32cad
Author: AvinashKumarG <av...@confluxtechnologies.com>
Date: 2016-05-09T12:41:29Z
293_post_interest_job
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-fineract pull request: 293_post_interest_job
Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:
https://github.com/apache/incubator-fineract/pull/103#discussion_r63004045
--- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsSchedularServiceImpl.java ---
@@ -37,42 +41,73 @@
private final SavingsAccountAssembler savingAccountAssembler;
private final SavingsAccountWritePlatformService savingsAccountWritePlatformService;
- private final SavingsAccountRepository savingAccountRepository;
private final SavingsAccountReadPlatformService savingAccountReadPlatformService;
@Autowired
public SavingsSchedularServiceImpl(final SavingsAccountAssembler savingAccountAssembler,
final SavingsAccountWritePlatformService savingsAccountWritePlatformService,
- final SavingsAccountRepository savingAccountRepository,
final SavingsAccountReadPlatformService savingAccountReadPlatformService) {
this.savingAccountAssembler = savingAccountAssembler;
this.savingsAccountWritePlatformService = savingsAccountWritePlatformService;
- this.savingAccountRepository = savingAccountRepository;
this.savingAccountReadPlatformService = savingAccountReadPlatformService;
}
- @CronTarget(jobName = JobName.POST_INTEREST_FOR_SAVINGS)
- @Override
- public void postInterestForAccounts() throws JobExecutionException {
- final List<SavingsAccount> savingsAccounts = this.savingAccountRepository.findSavingAccountByStatus(SavingsAccountStatusType.ACTIVE
- .getValue());
- StringBuffer sb = new StringBuffer();
- for (final SavingsAccount savingsAccount : savingsAccounts) {
- try {
- this.savingAccountAssembler.assignSavingAccountHelpers(savingsAccount);
- this.savingsAccountWritePlatformService.postInterest(savingsAccount);
- } catch (Exception e) {
- Throwable realCause = e;
- if (e.getCause() != null) {
- realCause = e.getCause();
- }
- sb.append("failed to post interest for Savings with id " + savingsAccount.getId() + " with message "
- + realCause.getMessage());
- }
- }
-
- if (sb.length() > 0) { throw new JobExecutionException(sb.toString()); }
- }
+ @Transactional
+ @CronTarget(jobName = JobName.POST_INTEREST_FOR_SAVINGS)
+ @Override
+ public void postInterestForAccounts() throws JobExecutionException {
+ final int maxPazeSize = 10;
+ boolean hasErrorOccurred = false;
+ boolean tempHasErrorOccured = false;
+ int offSet = 0;
+ final Integer status = SavingsAccountStatusType.ACTIVE.getValue();
+ List<SavingsAccount> savings = new ArrayList<>();
+
+ Page<SavingsAccountData> savingsAccounts = this.savingAccountReadPlatformService
--- End diff --
You never using this savingsAccounts .
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-fineract pull request: 293_post_interest_job
Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:
https://github.com/apache/incubator-fineract/pull/103#discussion_r63004091
--- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsSchedularServiceImpl.java ---
@@ -37,42 +41,73 @@
private final SavingsAccountAssembler savingAccountAssembler;
private final SavingsAccountWritePlatformService savingsAccountWritePlatformService;
- private final SavingsAccountRepository savingAccountRepository;
private final SavingsAccountReadPlatformService savingAccountReadPlatformService;
@Autowired
public SavingsSchedularServiceImpl(final SavingsAccountAssembler savingAccountAssembler,
final SavingsAccountWritePlatformService savingsAccountWritePlatformService,
- final SavingsAccountRepository savingAccountRepository,
final SavingsAccountReadPlatformService savingAccountReadPlatformService) {
this.savingAccountAssembler = savingAccountAssembler;
this.savingsAccountWritePlatformService = savingsAccountWritePlatformService;
- this.savingAccountRepository = savingAccountRepository;
this.savingAccountReadPlatformService = savingAccountReadPlatformService;
}
- @CronTarget(jobName = JobName.POST_INTEREST_FOR_SAVINGS)
- @Override
- public void postInterestForAccounts() throws JobExecutionException {
- final List<SavingsAccount> savingsAccounts = this.savingAccountRepository.findSavingAccountByStatus(SavingsAccountStatusType.ACTIVE
- .getValue());
- StringBuffer sb = new StringBuffer();
- for (final SavingsAccount savingsAccount : savingsAccounts) {
- try {
- this.savingAccountAssembler.assignSavingAccountHelpers(savingsAccount);
- this.savingsAccountWritePlatformService.postInterest(savingsAccount);
- } catch (Exception e) {
- Throwable realCause = e;
- if (e.getCause() != null) {
- realCause = e.getCause();
- }
- sb.append("failed to post interest for Savings with id " + savingsAccount.getId() + " with message "
- + realCause.getMessage());
- }
- }
-
- if (sb.length() > 0) { throw new JobExecutionException(sb.toString()); }
- }
+ @Transactional
+ @CronTarget(jobName = JobName.POST_INTEREST_FOR_SAVINGS)
+ @Override
+ public void postInterestForAccounts() throws JobExecutionException {
+ final int maxPazeSize = 10;
+ boolean hasErrorOccurred = false;
+ boolean tempHasErrorOccured = false;
+ int offSet = 0;
+ final Integer status = SavingsAccountStatusType.ACTIVE.getValue();
+ List<SavingsAccount> savings = new ArrayList<>();
+
+ Page<SavingsAccountData> savingsAccounts = this.savingAccountReadPlatformService
+ .retrieveActiveSavingsAccount(maxPazeSize, offSet, status);
+
+ while (savingsAccounts.getPageItems().size() < savingsAccounts.getTotalFilteredRecords()) {
+ offSet += savingsAccounts.getPageItems().size();
+ savingsAccounts = this.savingAccountReadPlatformService.retrieveActiveSavingsAccount(maxPazeSize, offSet,
+ status);
+ for (SavingsAccountData savingsAccountData : savingsAccounts.getPageItems()) {
+ SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(savingsAccountData.id());
+ savings.add(savingsAccount);
+ }
+ postInterestInBatch(savings);
--- End diff --
Why do we need to call postInterestInBatch() method two times?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-fineract pull request: 293_post_interest_job
Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:
https://github.com/apache/incubator-fineract/pull/103#discussion_r63003311
--- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java ---
@@ -200,6 +200,30 @@ public SavingsAccountReadPlatformServiceImpl(final PlatformSecurityContext conte
return this.paginationHelper.fetchPage(this.jdbcTemplate, sqlCountRows, sqlBuilder.toString(), finalObjectArray,
this.savingAccountMapper);
}
+
+ //Pagination Read service for Active Savings Account Post Interest Job
+ @Override
+ public Page<SavingsAccountData> retrieveActiveSavingsAccount(final Integer maxPazeSize,final Integer pageNumber, final Integer status) {
--- End diff --
The method itself is to retrieve active savings accounts. Do we need to pass status as param?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-fineract pull request: 293_post_interest_job
Posted by AvinashKumarG <gi...@git.apache.org>.
Github user AvinashKumarG closed the pull request at:
https://github.com/apache/incubator-fineract/pull/103
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---