Merge pull request #843 from lingalamadhukar/MIFOSX-1049
MIFOSX-1053 Fix PAY_DUE_SAVINGS_CHARGES job
This commit is contained in:
+1
-1
@@ -837,7 +837,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
|
|
||||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern("dd MM yyyy");
|
final DateTimeFormatter fmt = DateTimeFormat.forPattern("dd MM yyyy");
|
||||||
|
|
||||||
while (transactionDate.isAfter(savingsAccountCharge.getDueLocalDate())) {
|
while (transactionDate.isAfter(savingsAccountCharge.getDueLocalDate()) && savingsAccountCharge.isNotFullyPaid()) {
|
||||||
payCharge(savingsAccountCharge, transactionDate, savingsAccountCharge.amoutOutstanding(), fmt);
|
payCharge(savingsAccountCharge, transactionDate, savingsAccountCharge.amoutOutstanding(), fmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -5,6 +5,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.scheduledjobs.service;
|
package org.mifosplatform.scheduledjobs.service;
|
||||||
|
|
||||||
|
import org.mifosplatform.infrastructure.jobs.exception.JobExecutionException;
|
||||||
|
|
||||||
public interface ScheduledJobRunnerService {
|
public interface ScheduledJobRunnerService {
|
||||||
|
|
||||||
void updateLoanSummaryDetails();
|
void updateLoanSummaryDetails();
|
||||||
@@ -15,5 +17,5 @@ public interface ScheduledJobRunnerService {
|
|||||||
|
|
||||||
void applyAnnualFeeForSavings();
|
void applyAnnualFeeForSavings();
|
||||||
|
|
||||||
void applyDueChargesForSavings();
|
void applyDueChargesForSavings() throws JobExecutionException;
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-7
@@ -13,6 +13,7 @@ import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidation
|
|||||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSourceServiceFactory;
|
import org.mifosplatform.infrastructure.core.service.RoutingDataSourceServiceFactory;
|
||||||
import org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil;
|
import org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil;
|
||||||
import org.mifosplatform.infrastructure.jobs.annotation.CronTarget;
|
import org.mifosplatform.infrastructure.jobs.annotation.CronTarget;
|
||||||
|
import org.mifosplatform.infrastructure.jobs.exception.JobExecutionException;
|
||||||
import org.mifosplatform.infrastructure.jobs.service.JobName;
|
import org.mifosplatform.infrastructure.jobs.service.JobName;
|
||||||
import org.mifosplatform.portfolio.savings.data.SavingsAccountAnnualFeeData;
|
import org.mifosplatform.portfolio.savings.data.SavingsAccountAnnualFeeData;
|
||||||
import org.mifosplatform.portfolio.savings.service.SavingsAccountChargeReadPlatformService;
|
import org.mifosplatform.portfolio.savings.service.SavingsAccountChargeReadPlatformService;
|
||||||
@@ -225,23 +226,32 @@ public class ScheduledJobRunnerServiceImpl implements ScheduledJobRunnerService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CronTarget(jobName = JobName.PAY_DUE_SAVINGS_CHARGES)
|
@CronTarget(jobName = JobName.PAY_DUE_SAVINGS_CHARGES)
|
||||||
public void applyDueChargesForSavings() {
|
public void applyDueChargesForSavings() throws JobExecutionException {
|
||||||
final Collection<SavingsAccountAnnualFeeData> chargesDueData = this.savingsAccountChargeReadPlatformService
|
final Collection<SavingsAccountAnnualFeeData> chargesDueData = this.savingsAccountChargeReadPlatformService
|
||||||
.retrieveChargesWithDue();
|
.retrieveChargesWithDue();
|
||||||
|
final StringBuilder errorMsg = new StringBuilder();
|
||||||
|
|
||||||
for (final SavingsAccountAnnualFeeData savingsAccountReference : chargesDueData) {
|
for (final SavingsAccountAnnualFeeData savingsAccountReference : chargesDueData) {
|
||||||
try {
|
try {
|
||||||
this.savingsAccountWritePlatformService.applyChargeDue(savingsAccountReference.getId(), savingsAccountReference.getAccountId());
|
this.savingsAccountWritePlatformService.applyChargeDue(savingsAccountReference.getId(),
|
||||||
|
savingsAccountReference.getAccountId());
|
||||||
} catch (final PlatformApiDataValidationException e) {
|
} catch (final PlatformApiDataValidationException e) {
|
||||||
final List<ApiParameterError> errors = e.getErrors();
|
final List<ApiParameterError> errors = e.getErrors();
|
||||||
for (final ApiParameterError error : errors) {
|
for (final ApiParameterError error : errors) {
|
||||||
logger.error("Apply Charges due for savings failed for account:" + savingsAccountReference.getAccountNo() + " with message "
|
logger.error("Apply Charges due for savings failed for account:" + savingsAccountReference.getAccountNo()
|
||||||
+ error.getDeveloperMessage());
|
+ " with message " + error.getDeveloperMessage());
|
||||||
|
errorMsg.append("Apply Charges due for savings failed for account:").append(savingsAccountReference.getAccountNo())
|
||||||
|
.append(" with message ").append(error.getDeveloperMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(ThreadLocalContextUtil.getTenant().getName() + ": Savings accounts affected by update: " + chargesDueData.size());
|
logger.info(ThreadLocalContextUtil.getTenant().getName() + ": Savings accounts affected by update: " + chargesDueData.size());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* throw exception if any charge payment fails.
|
||||||
|
*/
|
||||||
|
if (errorMsg.length() > 0) { throw new JobExecutionException(errorMsg.toString()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user