From c487ca451cf3e62d5be7fac24af2cb6cd2e48a7c Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Tue, 23 Jan 2024 16:48:20 +0100 Subject: [PATCH] [PRDP-335] feat: Add checks on remittance info --- .../ConvertBizEventListToTransactionDetailResponse.java | 8 +++++++- .../bizeventsservice/service/TransactionServiceTest.java | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/gov/pagopa/bizeventsservice/mapper/ConvertBizEventListToTransactionDetailResponse.java b/src/main/java/it/gov/pagopa/bizeventsservice/mapper/ConvertBizEventListToTransactionDetailResponse.java index 3cf4d36a..f6a8f8d2 100644 --- a/src/main/java/it/gov/pagopa/bizeventsservice/mapper/ConvertBizEventListToTransactionDetailResponse.java +++ b/src/main/java/it/gov/pagopa/bizeventsservice/mapper/ConvertBizEventListToTransactionDetailResponse.java @@ -29,6 +29,8 @@ public class ConvertBizEventListToTransactionDetailResponse { private static final String REF_TYPE_IUV = "IUV"; private static final String RECEIPT_DATE_FORMAT = "dd MMMM yyyy, HH:mm:ss"; + private static final String[] UNWANTED_REMITTANCE_INFO = System.getenv().getOrDefault("UNWANTED_REMITTANCE_INFO", "pagamento multibeneficiario").split(","); + private ConvertBizEventListToTransactionDetailResponse(){} public static TransactionDetailResponse convert(List listOfBizEvents) { @@ -251,7 +253,11 @@ private static UserDetail getPayer(BizEvent bizEvent) { } private static String getItemSubject(BizEvent bizEvent, int index) { - if (bizEvent.getPaymentInfo() != null && bizEvent.getPaymentInfo().getRemittanceInformation() != null) { + if ( + bizEvent.getPaymentInfo() != null && + bizEvent.getPaymentInfo().getRemittanceInformation() != null && + !Arrays.asList(UNWANTED_REMITTANCE_INFO).contains(bizEvent.getPaymentInfo().getRemittanceInformation()) + ) { return bizEvent.getPaymentInfo().getRemittanceInformation(); } List transferList = bizEvent.getTransferList(); diff --git a/src/test/java/it/gov/pagopa/bizeventsservice/service/TransactionServiceTest.java b/src/test/java/it/gov/pagopa/bizeventsservice/service/TransactionServiceTest.java index 0bf12a2f..4bc6178a 100644 --- a/src/test/java/it/gov/pagopa/bizeventsservice/service/TransactionServiceTest.java +++ b/src/test/java/it/gov/pagopa/bizeventsservice/service/TransactionServiceTest.java @@ -26,6 +26,9 @@ @SpringBootTest public class TransactionServiceTest { + public static final String INVALID_REMITTANCE_INFORMATION = "pagamento multibeneficiario"; + + @Mock private BizEventsRepository bizEventsRepository; @@ -359,7 +362,7 @@ void idAndTaxCodeWithOneEventShouldReturnTransactionDetailsTransactionDateFromPa @Test void idAndTaxCodeWithOneEventShouldReturnTransactionDetailsWithRemmittanceInformationInTransferList() { BizEvent bizEvent = BizEventGenerator.generateValidBizEvent(0); - bizEvent.getPaymentInfo().setRemittanceInformation(null); + bizEvent.getPaymentInfo().setRemittanceInformation(INVALID_REMITTANCE_INFORMATION); List listOfBizEvents = Collections.singletonList(bizEvent); when(bizEventsRepository.getBizEventByFiscalCodeAndId(eq(USER_TAX_CODE_WITH_TX), anyString())) .thenReturn(listOfBizEvents);