FINERACT-2181: Add customData field to LoanAccountDelinquencyRangeBusinessEvent

This commit is contained in:
Jose Alberto Hernandez
2025-04-15 15:16:03 +02:00
committed by Adam Saghy
parent 2eca91eb98
commit 6a65bc6592
3 changed files with 80 additions and 5 deletions
@@ -36,7 +36,8 @@ import org.apache.fineract.infrastructure.event.external.service.serialization.m
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.loan.LoanChargeDataMapper;
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.loan.LoanDelinquencyRangeDataMapper;
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.support.AvroDateTimeMapper;
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.BusinessEventSerializer;
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.AbstractBusinessEventWithCustomDataSerializer;
import org.apache.fineract.infrastructure.event.external.service.serialization.serializer.ExternalEventCustomDataSerializer;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.portfolio.delinquency.service.DelinquencyReadPlatformService;
import org.apache.fineract.portfolio.loanaccount.data.CollectionData;
@@ -52,7 +53,8 @@ import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
@Order(Ordered.LOWEST_PRECEDENCE - 1)
public class LoanDelinquencyRangeChangeBusinessEventSerializer implements BusinessEventSerializer {
public class LoanDelinquencyRangeChangeBusinessEventSerializer
extends AbstractBusinessEventWithCustomDataSerializer<LoanDelinquencyRangeChangeBusinessEvent> {
private final LoanReadPlatformService service;
@@ -67,6 +69,7 @@ public class LoanDelinquencyRangeChangeBusinessEventSerializer implements Busine
private final CurrencyDataMapper currencyMapper;
private final AvroDateTimeMapper dataTimeMapper;
private final LoanInstallmentLevelDelinquencyEventProducer installmentLevelDelinquencyEventProducer;
private final List<ExternalEventCustomDataSerializer<LoanDelinquencyRangeChangeBusinessEvent>> externalEventCustomDataSerializers;
@Override
public <T> ByteBufferSerializable toAvroDTO(BusinessEvent<T> rawEvent) {
@@ -111,7 +114,8 @@ public class LoanDelinquencyRangeChangeBusinessEventSerializer implements Busine
.setAmount(amount)//
.setCurrency(currencyMapper.map(data.getCurrency()))//
.setDelinquentDate(delinquentDate)//
.setInstallmentDelinquencyBuckets(installmentsDelinquencyData).build();
.setInstallmentDelinquencyBuckets(installmentsDelinquencyData)//
.setCustomData(collectCustomData(event)).build();
}
private BigDecimal calculateDataSummary(Loan loan, BiFunction<Loan, LoanRepaymentScheduleInstallment, BigDecimal> mapper) {
@@ -129,4 +133,9 @@ public class LoanDelinquencyRangeChangeBusinessEventSerializer implements Busine
public Class<? extends GenericContainer> getSupportedSchema() {
return LoanAccountDelinquencyRangeDataV1.class;
}
@Override
protected List<ExternalEventCustomDataSerializer<LoanDelinquencyRangeChangeBusinessEvent>> getExternalEventCustomDataSerializers() {
return externalEventCustomDataSerializers;
}
}