Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Fixed payee.taxCode & payee.name mapping #74

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,12 @@ private String getDebtorTaxCode(BizEvent event) throws TemplateDataMappingExcept
}

private String getPayeeName(BizEvent event) {
return event.getCreditor() != null ? event.getCreditor().getOfficeName() : null;
return event.getCreditor() != null ? event.getCreditor().getCompanyName() : null;
}

private String getPayeeTaxCode(BizEvent event) throws TemplateDataMappingException {
if (event.getCreditor() != null && event.getCreditor().getCompanyName() != null) {
return event.getCreditor().getCompanyName();
if (event.getCreditor() != null && event.getCreditor().getIdPA() != null) {
return event.getCreditor().getIdPA();
}
throw new TemplateDataMappingException(formatErrorMessage(TemplateDataField.CART_ITEM_PAYEE_TAX_CODE), ReasonErrorCode.ERROR_TEMPLATE_PDF.getCode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

class BuildTemplateServiceImplTest {
public static final String COMPANY_NAME = "PA paolo";
public static final String OFFICE_NAME = "office PA";
public static final String ID_PSP = "ID_PSP";
public static final String DEBTOR_FULL_NAME = "John Doe";
public static final String DEBTOR_VALID_CF = "CF_DEBTOR";
Expand Down Expand Up @@ -61,6 +60,7 @@ class BuildTemplateServiceImplTest {
private static final String PAGO_PA_CHANNEL_IO = "IO";
private static final String PAGO_PA_CHANNEL_IO_PAY = "IO-PAY";
private static final String NOT_PAGO_PA_CHANNEL = "NOT_PAGO_PA_CHANNEL";
public static final String ID_PA = "idPa";
private BuildTemplateServiceImpl buildTemplateService;

@BeforeEach
Expand All @@ -82,7 +82,7 @@ void mapTemplateAllFieldsSuccessCompleteTemplateAndIOChannel() throws Exception
.build())
.creditor(Creditor.builder()
.companyName(COMPANY_NAME)
.officeName(OFFICE_NAME)
.idPA(ID_PA)
.build())
.psp(Psp.builder()
.idPsp(ID_PSP)
Expand Down Expand Up @@ -156,8 +156,8 @@ void mapTemplateAllFieldsSuccessCompleteTemplateAndIOChannel() throws Exception
assertEquals(DEBTOR_FULL_NAME, cart.getItems().get(0).getDebtor().getFullName());
assertEquals(DEBTOR_VALID_CF, cart.getItems().get(0).getDebtor().getTaxCode());
assertEquals(REMITTANCE_INFORMATION, cart.getItems().get(0).getSubject());
assertEquals(OFFICE_NAME, cart.getItems().get(0).getPayee().getName());
assertEquals(COMPANY_NAME, cart.getItems().get(0).getPayee().getTaxCode());
assertEquals(COMPANY_NAME, cart.getItems().get(0).getPayee().getName());
assertEquals(ID_PA, cart.getItems().get(0).getPayee().getTaxCode());
assertEquals(MODEL_TYPE_IUV_TEXT, cart.getItems().get(0).getRefNumber().getType());
assertEquals(IUV, cart.getItems().get(0).getRefNumber().getValue());
}
Expand All @@ -172,7 +172,7 @@ void mapTemplateAllFieldsSuccessCompleteTemplateAndIOPAYChannel() throws Excepti
.build())
.creditor(Creditor.builder()
.companyName(COMPANY_NAME)
.officeName(OFFICE_NAME)
.idPA(ID_PA)
.build())
.psp(Psp.builder()
.idPsp(ID_PSP)
Expand Down Expand Up @@ -246,8 +246,8 @@ void mapTemplateAllFieldsSuccessCompleteTemplateAndIOPAYChannel() throws Excepti
assertEquals(DEBTOR_FULL_NAME, cart.getItems().get(0).getDebtor().getFullName());
assertEquals(DEBTOR_VALID_CF, cart.getItems().get(0).getDebtor().getTaxCode());
assertEquals(REMITTANCE_INFORMATION, cart.getItems().get(0).getSubject());
assertEquals(OFFICE_NAME, cart.getItems().get(0).getPayee().getName());
assertEquals(COMPANY_NAME, cart.getItems().get(0).getPayee().getTaxCode());
assertEquals(COMPANY_NAME, cart.getItems().get(0).getPayee().getName());
assertEquals(ID_PA, cart.getItems().get(0).getPayee().getTaxCode());
assertEquals(MODEL_TYPE_IUV_TEXT, cart.getItems().get(0).getRefNumber().getType());
assertEquals(IUV, cart.getItems().get(0).getRefNumber().getValue());
}
Expand All @@ -262,7 +262,7 @@ void mapTemplateAllFieldsSuccessPartialTemplateAndNotPagoPaChannel() throws Exce
.build())
.creditor(Creditor.builder()
.companyName(COMPANY_NAME)
.officeName(OFFICE_NAME)
.idPA(ID_PA)
.build())
.psp(Psp.builder()
.idPsp(ID_PSP)
Expand Down Expand Up @@ -335,8 +335,8 @@ void mapTemplateAllFieldsSuccessPartialTemplateAndNotPagoPaChannel() throws Exce
assertEquals(DEBTOR_FULL_NAME, cart.getItems().get(0).getDebtor().getFullName());
assertEquals(DEBTOR_VALID_CF, cart.getItems().get(0).getDebtor().getTaxCode());
assertEquals(REMITTANCE_INFORMATION, cart.getItems().get(0).getSubject());
assertEquals(OFFICE_NAME, cart.getItems().get(0).getPayee().getName());
assertEquals(COMPANY_NAME, cart.getItems().get(0).getPayee().getTaxCode());
assertEquals(COMPANY_NAME, cart.getItems().get(0).getPayee().getName());
assertEquals(ID_PA, cart.getItems().get(0).getPayee().getTaxCode());
assertEquals(MODEL_TYPE_NOTICE_TEXT, cart.getItems().get(0).getRefNumber().getType());
assertEquals(IUV, cart.getItems().get(0).getRefNumber().getValue());
}
Expand All @@ -351,7 +351,7 @@ void mapTemplateWithoutTransactionDetailsSuccess() throws Exception {
.build())
.creditor(Creditor.builder()
.companyName(COMPANY_NAME)
.officeName(OFFICE_NAME)
.idPA(ID_PA)
.build())
.psp(Psp.builder()
.idPsp(ID_PSP)
Expand Down Expand Up @@ -407,8 +407,8 @@ void mapTemplateWithoutTransactionDetailsSuccess() throws Exception {
assertEquals(DEBTOR_FULL_NAME, cart.getItems().get(0).getDebtor().getFullName());
assertEquals(DEBTOR_VALID_CF, cart.getItems().get(0).getDebtor().getTaxCode());
assertEquals(REMITTANCE_INFORMATION, cart.getItems().get(0).getSubject());
assertEquals(OFFICE_NAME, cart.getItems().get(0).getPayee().getName());
assertEquals(COMPANY_NAME, cart.getItems().get(0).getPayee().getTaxCode());
assertEquals(COMPANY_NAME, cart.getItems().get(0).getPayee().getName());
assertEquals(ID_PA, cart.getItems().get(0).getPayee().getTaxCode());
assertEquals(MODEL_TYPE_IUV_TEXT, cart.getItems().get(0).getRefNumber().getType());
assertEquals(IUV, cart.getItems().get(0).getRefNumber().getValue());
}
Expand All @@ -423,7 +423,7 @@ void mapTemplateWithoutTransactionDetailsAndPaymentTokenSuccess() throws Excepti
.build())
.creditor(Creditor.builder()
.companyName(COMPANY_NAME)
.officeName(OFFICE_NAME)
.idPA(ID_PA)
.build())
.psp(Psp.builder()
.idPsp(ID_PSP)
Expand Down Expand Up @@ -477,8 +477,8 @@ void mapTemplateWithoutTransactionDetailsAndPaymentTokenSuccess() throws Excepti
assertEquals(DEBTOR_FULL_NAME, cart.getItems().get(0).getDebtor().getFullName());
assertEquals(DEBTOR_VALID_CF, cart.getItems().get(0).getDebtor().getTaxCode());
assertEquals(REMITTANCE_INFORMATION, cart.getItems().get(0).getSubject());
assertEquals(OFFICE_NAME, cart.getItems().get(0).getPayee().getName());
assertEquals(COMPANY_NAME, cart.getItems().get(0).getPayee().getTaxCode());
assertEquals(COMPANY_NAME, cart.getItems().get(0).getPayee().getName());
assertEquals(ID_PA, cart.getItems().get(0).getPayee().getTaxCode());
assertEquals(MODEL_TYPE_IUV_TEXT, cart.getItems().get(0).getRefNumber().getType());
assertEquals(IUV, cart.getItems().get(0).getRefNumber().getValue());
}
Expand Down Expand Up @@ -508,7 +508,7 @@ void mapTemplateLeastAmountOfInfoSuccess() {
.entityUniqueIdentifierValue(DEBTOR_VALID_CF)
.build())
.creditor(Creditor.builder()
.companyName(COMPANY_NAME)
.idPA(ID_PA)
.build())
.transactionDetails(TransactionDetails.builder()
.transaction(Transaction.builder()
Expand Down Expand Up @@ -918,6 +918,7 @@ void mapTemplateNoCartItemAmountValueError() {
.build())
.creditor(Creditor.builder()
.companyName(COMPANY_NAME)
.idPA(ID_PA)
.build())
.transactionDetails(TransactionDetails.builder()
.transaction(Transaction.builder()
Expand Down
Loading