From 15d26822b35bbc22edf9305a72a7cd36d472110b Mon Sep 17 00:00:00 2001 From: gianmarcoplutino Date: Wed, 27 Nov 2024 11:47:26 +0100 Subject: [PATCH] feat: added attachment mapping --- .../selfcare/onboarding/utils/PdfMapper.java | 30 ++++++++++++++- .../service/ContractServiceDefaultTest.java | 38 ++++++++++++++++--- apps/onboarding-ms/src/main/docs/openapi.json | 6 +-- apps/onboarding-ms/src/main/docs/openapi.yaml | 4 +- 4 files changed, 67 insertions(+), 11 deletions(-) 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 3113903f8..e0cb188b9 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 @@ -99,7 +99,35 @@ public static Map setUpCommonData( } public static Map setUpAttachmentData(Onboarding onboarding) { - return new HashMap<>(); + Map map = new HashMap<>(); + if (Objects.nonNull(onboarding.getInstitution().getPaymentServiceProvider())) { + map.put( + "businessRegisterNumber", + onboarding.getInstitution().getPaymentServiceProvider().getBusinessRegisterNumber()); + map.put( + "legalRegisterNumber", + onboarding.getInstitution().getPaymentServiceProvider().getLegalRegisterNumber()); + map.put( + "legalRegisterName", + onboarding.getInstitution().getPaymentServiceProvider().getLegalRegisterName()); + } + + if (Objects.nonNull(onboarding.getInstitution().getGpuData())) { + map.put("manager", onboarding.getInstitution().getGpuData().isManager() ? "Si" : "No"); + map.put( + "managerAuthorized", + onboarding.getInstitution().getGpuData().isManagerAuthorized() ? "Si" : "No"); + map.put( + "managerEligible", + onboarding.getInstitution().getGpuData().isManagerEligible() ? "Si" : "No"); + map.put( + "managerProsecution", + onboarding.getInstitution().getGpuData().isManagerProsecution() ? "Si" : "No"); + map.put( + "institutionCourtMeasures", + onboarding.getInstitution().getGpuData().isInstitutionCourtMeasures() ? "Si" : "No"); + } + return map; } private static String getMailManager(UserResource manager, String userMailUuid) { diff --git a/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefaultTest.java b/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefaultTest.java index 77746ba2a..59ce40c77 100644 --- a/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefaultTest.java +++ b/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefaultTest.java @@ -66,20 +66,48 @@ private Onboarding createOnboarding() { onboarding.setProductId("productId"); onboarding.setUsers(List.of()); + createInstitution(onboarding); + + User user = new User(); + user.setId(UUID.randomUUID().toString()); + user.setUserMailUuid("setUserMailUuid"); + onboarding.setUsers(List.of(user)); + return onboarding; + } + + private static void createInstitution(Onboarding onboarding) { Institution institution = new Institution(); institution.setInstitutionType(InstitutionType.PSP); institution.setDescription("42"); + PaymentServiceProvider paymentServiceProvider = createPaymentServiceProvider(); + institution.setPaymentServiceProvider(paymentServiceProvider); + + GPUData gpuData = createGpuData(); + institution.setGpuData(gpuData); + institution.setRea("rea"); institution.setBusinessRegisterPlace("place"); institution.setShareCapital("10000"); onboarding.setInstitution(institution); + } - User user = new User(); - user.setId(UUID.randomUUID().toString()); - user.setUserMailUuid("setUserMailUuid"); - onboarding.setUsers(List.of(user)); - return onboarding; + private static GPUData createGpuData() { + GPUData gpuData = new GPUData(); + gpuData.setManager(true); + gpuData.setManagerAuthorized(true); + gpuData.setManagerEligible(true); + gpuData.setManagerProsecution(true); + gpuData.setInstitutionCourtMeasures(true); + return gpuData; + } + + private static PaymentServiceProvider createPaymentServiceProvider() { + PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); + paymentServiceProvider.setBusinessRegisterNumber("businessRegisterNumber"); + paymentServiceProvider.setLegalRegisterName("legalRegisterName"); + paymentServiceProvider.setLegalRegisterNumber("legalRegisterNumber"); + return paymentServiceProvider; } AggregateInstitution createAggregateInstitutionIO(int number) { diff --git a/apps/onboarding-ms/src/main/docs/openapi.json b/apps/onboarding-ms/src/main/docs/openapi.json index c06c2b2c9..234f6c08b 100644 --- a/apps/onboarding-ms/src/main/docs/openapi.json +++ b/apps/onboarding-ms/src/main/docs/openapi.json @@ -2564,9 +2564,6 @@ "PaymentServiceProviderRequest" : { "type" : "object", "properties" : { - "abiCode" : { - "type" : "string" - }, "businessRegisterNumber" : { "type" : "string" }, @@ -2576,6 +2573,9 @@ "legalRegisterName" : { "type" : "string" }, + "abiCode" : { + "type" : "string" + }, "vatNumberGroup" : { "type" : "boolean" }, diff --git a/apps/onboarding-ms/src/main/docs/openapi.yaml b/apps/onboarding-ms/src/main/docs/openapi.yaml index add68e7d4..818259255 100644 --- a/apps/onboarding-ms/src/main/docs/openapi.yaml +++ b/apps/onboarding-ms/src/main/docs/openapi.yaml @@ -1893,14 +1893,14 @@ components: PaymentServiceProviderRequest: type: object properties: - abiCode: - type: string businessRegisterNumber: type: string legalRegisterNumber: type: string legalRegisterName: type: string + abiCode: + type: string vatNumberGroup: type: boolean providerNames: