[FINERACT-1922] Skip business date job when business date is not enabled

This commit is contained in:
taskain7
2023-04-19 12:21:15 +02:00
committed by Adam Saghy
parent e4c26e7e5c
commit 82231101c8
6 changed files with 184 additions and 4 deletions
@@ -18,6 +18,7 @@
*/
package org.apache.fineract.infrastructure.jobs.service.increasedateby1day.increasebusinessdateby1day;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.jobs.service.JobName;
import org.apache.fineract.infrastructure.jobs.service.increasedateby1day.IncreaseDateBy1DayService;
import org.springframework.batch.core.Job;
@@ -38,6 +39,8 @@ public class IncreaseBusinessDateBy1DayConfig {
private StepBuilderFactory steps;
@Autowired
private IncreaseDateBy1DayService increaseDateBy1DayService;
@Autowired
private ConfigurationDomainService configurationDomainService;
@Bean
protected Step increaseBusinessDateBy1DayStep() {
@@ -52,6 +55,6 @@ public class IncreaseBusinessDateBy1DayConfig {
@Bean
public IncreaseBusinessDateBy1DayTasklet increaseBusinessDateBy1DayTasklet() {
return new IncreaseBusinessDateBy1DayTasklet(increaseDateBy1DayService);
return new IncreaseBusinessDateBy1DayTasklet(increaseDateBy1DayService, configurationDomainService);
}
}
@@ -21,7 +21,9 @@ package org.apache.fineract.infrastructure.jobs.service.increasedateby1day.incre
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.jobs.service.increasedateby1day.IncreaseDateBy1DayService;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
@@ -32,10 +34,15 @@ import org.springframework.batch.repeat.RepeatStatus;
public class IncreaseBusinessDateBy1DayTasklet implements Tasklet {
private final IncreaseDateBy1DayService increaseDateBy1DayService;
private final ConfigurationDomainService configurationDomainService;
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
increaseDateBy1DayService.increaseDateByTypeByOneDay(BusinessDateType.BUSINESS_DATE);
if (configurationDomainService.isBusinessDateEnabled()) {
increaseDateBy1DayService.increaseDateByTypeByOneDay(BusinessDateType.BUSINESS_DATE);
} else {
contribution.setExitStatus(ExitStatus.NOOP);
}
return RepeatStatus.FINISHED;
}
}
@@ -18,6 +18,7 @@
*/
package org.apache.fineract.infrastructure.jobs.service.increasedateby1day.increasecobdateby1day;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.jobs.service.JobName;
import org.apache.fineract.infrastructure.jobs.service.increasedateby1day.IncreaseDateBy1DayService;
import org.springframework.batch.core.Job;
@@ -38,6 +39,8 @@ public class IncreaseCobDateBy1DayConfig {
private StepBuilderFactory steps;
@Autowired
private IncreaseDateBy1DayService increaseDateBy1DayService;
@Autowired
private ConfigurationDomainService configurationDomainService;
@Bean
protected Step increaseCobDateBy1DayStep() {
@@ -52,6 +55,6 @@ public class IncreaseCobDateBy1DayConfig {
@Bean
public IncreaseCobDateBy1DayTasklet increaseCobDateBy1DayTasklet() {
return new IncreaseCobDateBy1DayTasklet(increaseDateBy1DayService);
return new IncreaseCobDateBy1DayTasklet(increaseDateBy1DayService, configurationDomainService);
}
}
@@ -21,7 +21,9 @@ package org.apache.fineract.infrastructure.jobs.service.increasedateby1day.incre
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.jobs.service.increasedateby1day.IncreaseDateBy1DayService;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
@@ -32,10 +34,15 @@ import org.springframework.batch.repeat.RepeatStatus;
public class IncreaseCobDateBy1DayTasklet implements Tasklet {
private final IncreaseDateBy1DayService increaseDateBy1DayService;
private final ConfigurationDomainService configurationDomainService;
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
increaseDateBy1DayService.increaseDateByTypeByOneDay(BusinessDateType.COB_DATE);
if (configurationDomainService.isBusinessDateEnabled()) {
increaseDateBy1DayService.increaseDateByTypeByOneDay(BusinessDateType.COB_DATE);
} else {
contribution.setExitStatus(ExitStatus.NOOP);
}
return RepeatStatus.FINISHED;
}
}