Skip to content

Commit

Permalink
[PRDP-335] feat: Add checks on remittance info
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-cialini committed Jan 23, 2024
1 parent d437220 commit c487ca4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<BizEvent> listOfBizEvents) {
Expand Down Expand Up @@ -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<Transfer> transferList = bizEvent.getTransferList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
@SpringBootTest
public class TransactionServiceTest {

public static final String INVALID_REMITTANCE_INFORMATION = "pagamento multibeneficiario";


@Mock
private BizEventsRepository bizEventsRepository;

Expand Down Expand Up @@ -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<BizEvent> listOfBizEvents = Collections.singletonList(bizEvent);
when(bizEventsRepository.getBizEventByFiscalCodeAndId(eq(USER_TAX_CODE_WITH_TX), anyString()))
.thenReturn(listOfBizEvents);
Expand Down

0 comments on commit c487ca4

Please sign in to comment.