diff --git a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefault.java b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefault.java index 1174271d8..cf63f4c5b 100644 --- a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefault.java +++ b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefault.java @@ -307,26 +307,23 @@ private File createPdfFileContract( String contractTemplateText = azureBlobClient.getFileAsText(contractTemplatePath); // Create a temporary PDF file to store the contract. Path temporaryPdfFile = Files.createTempFile(builder, ".pdf"); + // Setting baseUrl used to construct aggregates csv url + String baseUrl = templatePlaceholdersConfig.rejectOnboardingUrlValue(); // Prepare common data for the contract document. - Map data = setUpCommonData(manager, users, onboarding); - - StringBuilder baseUrl = - new StringBuilder(templatePlaceholdersConfig.rejectOnboardingUrlValue()); - + Map data = setUpCommonData(manager, users, onboarding, baseUrl); // Customize data based on the product and institution type. if (PROD_PAGOPA.getValue().equalsIgnoreCase(productId) && InstitutionType.PSP == institution.getInstitutionType()) { setupPSPData(data, manager, onboarding); } else if (PROD_PAGOPA.getValue().equalsIgnoreCase(productId) && InstitutionType.PRV == institution.getInstitutionType() || InstitutionType.GPU == institution.getInstitutionType()) { - setupPRVData(data, onboarding, baseUrl.toString(), users); + setupPRVData(data, onboarding, users); } else if (PROD_PAGOPA.getValue().equalsIgnoreCase(productId) && InstitutionType.PSP != institution.getInstitutionType() && InstitutionType.PT != institution.getInstitutionType()) { setECData(data, onboarding); - } else if (PROD_IO.getValue().equalsIgnoreCase(productId)) { - setupProdIODataAggregates(onboarding, data, manager, baseUrl.toString()); - } else if (PROD_IO_PREMIUM.getValue().equalsIgnoreCase(productId) + } else if (PROD_IO.getValue().equalsIgnoreCase(productId) + || PROD_IO_PREMIUM.getValue().equalsIgnoreCase(productId) || PROD_IO_SIGN.getValue().equalsIgnoreCase(productId)) { setupProdIOData(onboarding, data, manager); } else if (PROD_PN.getValue().equalsIgnoreCase(productId)) { diff --git a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/utils/PdfMapper.java b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/utils/PdfMapper.java index b822e58eb..3b09ada8e 100644 --- a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/utils/PdfMapper.java +++ b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/utils/PdfMapper.java @@ -1,27 +1,20 @@ package it.pagopa.selfcare.onboarding.utils; -import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_IO; -import static it.pagopa.selfcare.onboarding.utils.GenericError.MANAGER_EMAIL_NOT_FOUND; - import it.pagopa.selfcare.onboarding.common.InstitutionType; import it.pagopa.selfcare.onboarding.common.Origin; import it.pagopa.selfcare.onboarding.common.PricingPlan; -import it.pagopa.selfcare.onboarding.entity.Billing; -import it.pagopa.selfcare.onboarding.entity.GeographicTaxonomy; -import it.pagopa.selfcare.onboarding.entity.Institution; -import it.pagopa.selfcare.onboarding.entity.Onboarding; -import it.pagopa.selfcare.onboarding.entity.User; +import it.pagopa.selfcare.onboarding.entity.*; import it.pagopa.selfcare.onboarding.exception.GenericOnboardingException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.openapi.quarkus.user_registry_json.model.CertifiableFieldResourceOfstring; import org.openapi.quarkus.user_registry_json.model.UserResource; +import java.util.*; + +import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_IO; +import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_PN; +import static it.pagopa.selfcare.onboarding.utils.GenericError.MANAGER_EMAIL_NOT_FOUND; + public class PdfMapper { private static final String UNDERSCORE = "_______________"; @@ -42,14 +35,15 @@ public class PdfMapper { "
  • codice di iscrizione all’Indice delle Pubbliche Amministrazioni e dei gestori di pubblici servizi (I.P.A.) ${originId}
  • "; public static final String CSV_AGGREGATES_LABEL = " - %s"; - public static final String CSV_AGGREGATES_TEXT_PAGOPA = "Dati di Enti Aggregati"; + public static final String CSV_AGGREGATES_LABEL_SEND = "%s"; + public static final String CSV_AGGREGATES_TEXT = "Dati di Enti Aggregati"; public static final String CSV_AGGREGATES_TEXT_IO = "Dati degli Enti Aggregati_IO"; public static final String INSTITUTION_RECIPIENT_CODE = "institutionRecipientCode"; private PdfMapper() {} public static Map setUpCommonData( - UserResource manager, List users, Onboarding onboarding) { + UserResource manager, List users, Onboarding onboarding, String baseUrl) { Institution institution = onboarding.getInstitution(); Billing billing = onboarding.getBilling(); @@ -86,7 +80,9 @@ public static Map setUpCommonData( map.put("institutionMail", institution.getDigitalAddress()); map.put("managerTaxCode", manager.getFiscalCode()); map.put("managerEmail", mailManager); + map.put("managerPhone", "_____________"); map.put("delegates", delegatesToText(users, onboarding.getUsers())); + map.put("delegatesSend", delegatesSendToText(users, onboarding.getUsers())); map.put("institutionType", decodeInstitutionType(institution.getInstitutionType())); map.put( "institutionVatNumber", @@ -94,6 +90,8 @@ public static Map setUpCommonData( map.put( "taxCodeInvoicing", Optional.ofNullable(billing).map(Billing::getTaxCodeInvoicing).orElse(UNDERSCORE)); + addAggregatesCsvLink(onboarding, map, baseUrl); + if (!geographicTaxonomies.isEmpty()) { map.put("institutionGeoTaxonomies", geographicTaxonomies); @@ -199,7 +197,7 @@ public static void setECData(Map map, Onboarding onboarding) { } public static void setupPRVData( - Map map, Onboarding onboarding, String baseUrl, List users) { + Map map, Onboarding onboarding, List users) { addInstitutionRegisterLabelValue(onboarding.getInstitution(), map); map.put("delegatesPrv", delegatesPrvToText(users, onboarding.getUsers())); @@ -213,7 +211,6 @@ public static void setupPRVData( map.put("isAggregatorCheckbox", Boolean.TRUE.equals(onboarding.getIsAggregator()) ? "X" : ""); setECData(map, onboarding); - addAggregatesCsvLink(onboarding, map, baseUrl); } public static void setupProdIOData( @@ -260,12 +257,6 @@ public static void setupProdIOData( addPricingPlan(onboarding.getPricingPlan(), map); } - public static void setupProdIODataAggregates( - Onboarding onboarding, Map map, UserResource validManager, String baseUrl) { - setupProdIOData(onboarding, map, validManager); - addAggregatesCsvLink(onboarding, map, baseUrl); - } - public static void setupSAProdInteropData(Map map, Institution institution) { map.put(INSTITUTION_REA, Optional.ofNullable(institution.getRea()).orElse(UNDERSCORE)); @@ -319,8 +310,11 @@ private static void addAggregatesCsvLink( String csvText = PROD_IO.getValue().equals(onboarding.getProductId()) ? CSV_AGGREGATES_TEXT_IO - : CSV_AGGREGATES_TEXT_PAGOPA; - csvLink = String.format(CSV_AGGREGATES_LABEL, url, csvText); + : CSV_AGGREGATES_TEXT; + csvLink = + PROD_PN.getValue().equals(onboarding.getProductId()) + ? String.format(CSV_AGGREGATES_LABEL_SEND, url, csvText) + : String.format(CSV_AGGREGATES_LABEL, url, csvText); } map.put(CSV_AGGREGATES_LABEL_VALUE, csvLink); @@ -433,6 +427,35 @@ private static String delegatesPrvToText(List userResources, List< return builder.toString(); } + private static String delegatesSendToText(List userResources, List users) { + StringBuilder builder = new StringBuilder(); + builder.append("

      { + builder + .append("
    1. ") + .append("Nome e Cognome: ") + .append(getStringValue(userResource.getName())) + .append(" ") + .append(getStringValue(userResource.getFamilyName())) + .append("
    2. ") + .append("
    3. ") + .append("Codice Fiscale: ") + .append(userResource.getFiscalCode()) + .append("
    4. ") + .append("
    5. ") + .append("Posta Elettronica aziendale: "); + + printUserWorkEmail(users, userResource, builder); + + builder.append("

    6. "); // Close list item + }); + + builder.append("

    "); + + return builder.toString(); + } + private static void printUserWorkEmail( List users, UserResource userResource, StringBuilder builder) { users.stream()