mifosx 344
This commit is contained in:
+2
@@ -22,6 +22,8 @@ public interface SavingsAccountWritePlatformService {
|
|||||||
|
|
||||||
CommandProcessingResult withdrawal(Long savingsId, JsonCommand command);
|
CommandProcessingResult withdrawal(Long savingsId, JsonCommand command);
|
||||||
|
|
||||||
|
CommandProcessingResult addAnnualFee(Long savingsId);
|
||||||
|
|
||||||
CommandProcessingResult calculateInterest(Long savingsId, JsonCommand command);
|
CommandProcessingResult calculateInterest(Long savingsId, JsonCommand command);
|
||||||
|
|
||||||
CommandProcessingResult postInterest(Long savingsId, JsonCommand command);
|
CommandProcessingResult postInterest(Long savingsId, JsonCommand command);
|
||||||
|
|||||||
+23
@@ -314,6 +314,29 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public CommandProcessingResult addAnnualFee(final Long savingsId) {
|
||||||
|
|
||||||
|
final SavingsAccount account = this.savingAccountRepository.findOneWithNotFoundDetection(savingsId);
|
||||||
|
|
||||||
|
final LocalDate transactionDate = LocalDate.now();
|
||||||
|
|
||||||
|
final DateTimeFormatter fmt = DateTimeFormat.forPattern("dd MM yyyy");
|
||||||
|
|
||||||
|
final SavingsAccountTransaction annualFee = account.addAnnualFee(fmt, transactionDate);
|
||||||
|
final Long transactionId = saveTransactionToGenerateTransactionId(annualFee);
|
||||||
|
this.savingAccountRepository.save(account);
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withEntityId(transactionId) //
|
||||||
|
.withOfficeId(account.officeId()) //
|
||||||
|
.withClientId(account.clientId()) //
|
||||||
|
.withGroupId(account.groupId()) //
|
||||||
|
.withSavingsId(savingsId) //
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult calculateInterest(final Long savingsId, final JsonCommand command) {
|
public CommandProcessingResult calculateInterest(final Long savingsId, final JsonCommand command) {
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
package org.mifosplatform.scheduledjobs;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.mifosplatform.scheduledjobs.service.ScheduledJobRunnerService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class CheckAnnualFeeDueDateScheduledJob {
|
||||||
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(CheckAnnualFeeDueDateScheduledJob.class);
|
||||||
|
|
||||||
|
private final ScheduledJobRunnerService scheduledJobRunnerService;
|
||||||
|
|
||||||
|
public CheckAnnualFeeDueDateScheduledJob(final ScheduledJobRunnerService scheduledJobRunnerService) {
|
||||||
|
this.scheduledJobRunnerService = scheduledJobRunnerService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
logger.info("Running Job C " + new Date());
|
||||||
|
|
||||||
|
this.scheduledJobRunnerService.checkAnnualFeeDueDate();
|
||||||
|
|
||||||
|
logger.info("Finishing Job C " + new Date());
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -10,4 +10,6 @@ public interface ScheduledJobRunnerService {
|
|||||||
void updateLoanSummaryDetails();
|
void updateLoanSummaryDetails();
|
||||||
|
|
||||||
void updateLoanArrearsAgeingDetails();
|
void updateLoanArrearsAgeingDetails();
|
||||||
|
|
||||||
|
void checkAnnualFeeDueDate();
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-1
@@ -5,10 +5,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.scheduledjobs.service;
|
package org.mifosplatform.scheduledjobs.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant;
|
import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant;
|
||||||
import org.mifosplatform.infrastructure.core.service.DataSourcePerTenantService;
|
import org.mifosplatform.infrastructure.core.service.DataSourcePerTenantService;
|
||||||
import org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil;
|
import org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil;
|
||||||
import org.mifosplatform.infrastructure.security.service.TenantDetailsService;
|
import org.mifosplatform.infrastructure.security.service.TenantDetailsService;
|
||||||
|
import org.mifosplatform.portfolio.savings.service.SavingsAccountWritePlatformService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -23,12 +26,14 @@ public class ScheduledJobRunnerServiceImpl implements ScheduledJobRunnerService
|
|||||||
|
|
||||||
private final TenantDetailsService tenantDetailsService;
|
private final TenantDetailsService tenantDetailsService;
|
||||||
private final DataSourcePerTenantService dataSourcePerTenantService;
|
private final DataSourcePerTenantService dataSourcePerTenantService;
|
||||||
|
private final SavingsAccountWritePlatformService savingsAccountWritePlatformService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ScheduledJobRunnerServiceImpl(final DataSourcePerTenantService dataSourcePerTenantService,
|
public ScheduledJobRunnerServiceImpl(final DataSourcePerTenantService dataSourcePerTenantService,
|
||||||
final TenantDetailsService tenantDetailsService) {
|
final TenantDetailsService tenantDetailsService, final SavingsAccountWritePlatformService savingsAccountWritePlatformService) {
|
||||||
this.dataSourcePerTenantService = dataSourcePerTenantService;
|
this.dataSourcePerTenantService = dataSourcePerTenantService;
|
||||||
this.tenantDetailsService = tenantDetailsService;
|
this.tenantDetailsService = tenantDetailsService;
|
||||||
|
this.savingsAccountWritePlatformService = savingsAccountWritePlatformService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -137,4 +142,22 @@ public class ScheduledJobRunnerServiceImpl implements ScheduledJobRunnerService
|
|||||||
|
|
||||||
logger.info("Results affected by update: " + result);
|
logger.info("Results affected by update: " + result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkAnnualFeeDueDate() {
|
||||||
|
final MifosPlatformTenant tenant = this.tenantDetailsService.loadTenantById("default");
|
||||||
|
|
||||||
|
ThreadLocalContextUtil.setTenant(tenant);
|
||||||
|
|
||||||
|
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSourcePerTenantService.retrieveTenantAwareDataSource());
|
||||||
|
|
||||||
|
String sql = "SELECT ms.id as savingsAccountId FROM m_savings_account ms WHERE ms.annual_fee_next_due_date <= NOW() ";
|
||||||
|
List<Long> savingsIds = jdbcTemplate.queryForList(sql, Long.class);
|
||||||
|
|
||||||
|
for (Long savingsId : savingsIds) {
|
||||||
|
this.savingsAccountWritePlatformService.addAnnualFee(savingsId);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("Results affected by update: " + savingsIds.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,9 @@
|
|||||||
<bean id="cronQuartzJobB" class="org.mifosplatform.scheduledjobs.UpdateLoanArrearsAgeingScheduledJob">
|
<bean id="cronQuartzJobB" class="org.mifosplatform.scheduledjobs.UpdateLoanArrearsAgeingScheduledJob">
|
||||||
<constructor-arg ref="scheduledJobRunnerService" />
|
<constructor-arg ref="scheduledJobRunnerService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
<bean id="cronQuartzJobC" class="org.mifosplatform.scheduledjobs.CheckAnnualFeeDueDateScheduledJob">
|
||||||
|
<constructor-arg ref="scheduledJobRunnerService" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="jobADetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
<bean id="jobADetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||||
<property name="group" value="mifosJobs" />
|
<property name="group" value="mifosJobs" />
|
||||||
@@ -31,6 +34,13 @@
|
|||||||
<property name="concurrent" value="false" />
|
<property name="concurrent" value="false" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="jobCDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||||
|
<property name="group" value="mifosJobs" />
|
||||||
|
<property name="targetObject" ref="cronQuartzJobC" />
|
||||||
|
<property name="targetMethod" value="execute" />
|
||||||
|
<property name="concurrent" value="false" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="cronTriggerA" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
|
<bean id="cronTriggerA" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
|
||||||
<property name="jobDetail" ref="jobADetail" />
|
<property name="jobDetail" ref="jobADetail" />
|
||||||
<property name="cronExpression" value="0 0 22 1/1 * ? *" />
|
<property name="cronExpression" value="0 0 22 1/1 * ? *" />
|
||||||
@@ -41,11 +51,17 @@
|
|||||||
<property name="cronExpression" value="0 10 22 1/1 * ? *" />
|
<property name="cronExpression" value="0 10 22 1/1 * ? *" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="cronTriggerC" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
|
||||||
|
<property name="jobDetail" ref="jobCDetail" />
|
||||||
|
<property name="cronExpression" value="0 20 22 1/1 * ? *" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean name="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
<bean name="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
||||||
<property name="triggers">
|
<property name="triggers">
|
||||||
<list>
|
<list>
|
||||||
<ref bean="cronTriggerA" />
|
<ref bean="cronTriggerA" />
|
||||||
<ref bean="cronTriggerB" />
|
<ref bean="cronTriggerB" />
|
||||||
|
<ref bean="cronTriggerC" />
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|||||||
Reference in New Issue
Block a user