FINERACT-1972 Custom Snapshot Event Triggered by COB
This commit is contained in:
committed by
Peter Bagrij
parent
4cb8946bc1
commit
8b379695d7
+2
-1
@@ -36,6 +36,7 @@ import org.apache.fineract.cob.loan.LoanCOBConstant;
|
||||
import org.apache.fineract.cob.loan.RetrieveLoanIdService;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.apache.fineract.infrastructure.core.boot.FineractProfiles;
|
||||
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
|
||||
@@ -43,7 +44,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Profile("test")
|
||||
@Profile(FineractProfiles.TEST)
|
||||
@Component
|
||||
@Path("/v1/internal/cob")
|
||||
@RequiredArgsConstructor
|
||||
|
||||
+2
-1
@@ -35,13 +35,14 @@ import org.apache.fineract.cob.domain.LoanAccountLock;
|
||||
import org.apache.fineract.cob.domain.LoanAccountLockRepository;
|
||||
import org.apache.fineract.cob.domain.LockOwner;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.core.boot.FineractProfiles;
|
||||
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@Profile("test")
|
||||
@Profile(FineractProfiles.TEST)
|
||||
@Component
|
||||
@Path("/v1/internal/loans")
|
||||
@RequiredArgsConstructor
|
||||
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* 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.cob.loan;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.infrastructure.event.business.domain.loan.LoanAccountCustomSnapshotBusinessEvent;
|
||||
import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CheckDueInstallmentsBusinessStep implements LoanCOBBusinessStep {
|
||||
|
||||
private final BusinessEventNotifierService businessEventNotifierService;
|
||||
|
||||
@Override
|
||||
public Loan execute(Loan loan) {
|
||||
log.debug("start processing custom snapshot event trigger business step loan for loan with id [{}]", loan.getId());
|
||||
|
||||
if (loan.getRepaymentScheduleInstallments() != null && loan.getRepaymentScheduleInstallments().size() > 0) {
|
||||
final LocalDate currentDate = DateUtils.getBusinessLocalDate();
|
||||
boolean shouldPostCustomSnapshotBusinessEvent = false;
|
||||
for (int i = 0; i < loan.getRepaymentScheduleInstallments().size(); i++) {
|
||||
if (loan.getRepaymentScheduleInstallments().get(i).getDueDate().equals(currentDate)
|
||||
&& loan.getRepaymentScheduleInstallments().get(i).isNotFullyPaidOff()) {
|
||||
shouldPostCustomSnapshotBusinessEvent = true;
|
||||
}
|
||||
}
|
||||
if (shouldPostCustomSnapshotBusinessEvent) {
|
||||
businessEventNotifierService.notifyPostBusinessEvent(new LoanAccountCustomSnapshotBusinessEvent(loan));
|
||||
}
|
||||
}
|
||||
|
||||
log.debug("end processing custom snapshot event trigger business step for loan with id [{}]", loan.getId());
|
||||
return loan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnumStyledName() {
|
||||
return "CHECK_DUE_INSTALLMENTS";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHumanReadableName() {
|
||||
return "Check Due Installments";
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -33,12 +33,13 @@ import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.infrastructure.core.boot.FineractProfiles;
|
||||
import org.apache.fineract.infrastructure.core.config.FineractProperties;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Profile("test")
|
||||
@Profile(FineractProfiles.TEST)
|
||||
@Component
|
||||
@Path("/v1/instance-mode")
|
||||
@Tag(name = "Instance Mode", description = "Instance mode changing API")
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ package org.apache.fineract.infrastructure.s3;
|
||||
|
||||
import java.net.URI;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.infrastructure.core.boot.FineractProfiles;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.core.env.Environment;
|
||||
@@ -28,7 +29,7 @@ import software.amazon.awssdk.services.s3.S3ClientBuilder;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Profile("test")
|
||||
@Profile(FineractProfiles.TEST)
|
||||
public class LocalstackS3ClientCustomizer implements S3ClientCustomizer {
|
||||
|
||||
private final Environment environment;
|
||||
|
||||
+2
-1
@@ -37,6 +37,7 @@ import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.apache.fineract.infrastructure.core.boot.FineractProfiles;
|
||||
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.apache.fineract.portfolio.client.domain.Client;
|
||||
@@ -45,7 +46,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Profile("test")
|
||||
@Profile(FineractProfiles.TEST)
|
||||
@Component
|
||||
@Path("/v1/internal/client")
|
||||
@RequiredArgsConstructor
|
||||
|
||||
+2
-1
@@ -38,6 +38,7 @@ import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.apache.fineract.infrastructure.core.boot.FineractProfiles;
|
||||
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||
@@ -50,7 +51,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Profile("test")
|
||||
@Profile(FineractProfiles.TEST)
|
||||
@Component
|
||||
@Path("/v1/internal/loan")
|
||||
@RequiredArgsConstructor
|
||||
|
||||
Reference in New Issue
Block a user