diff --git a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/entity/BusinessData.java b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/entity/BusinessData.java index 45b3d4ee5..e8d8f8405 100644 --- a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/entity/BusinessData.java +++ b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/entity/BusinessData.java @@ -5,6 +5,7 @@ public class BusinessData { private String businessRegisterNumber; private String legalRegisterNumber; private String legalRegisterName; + private boolean longTermPayments; public String getBusinessRegisterNumber() { return businessRegisterNumber; @@ -29,4 +30,12 @@ public String getLegalRegisterName() { public void setLegalRegisterName(String legalRegisterName) { this.legalRegisterName = legalRegisterName; } + + public boolean isLongTermPayments() { + return longTermPayments; + } + + public void setLongTermPayments(boolean longTermPayments) { + this.longTermPayments = longTermPayments; + } } diff --git a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/OnboardingService.java b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/OnboardingService.java index 30d3d0d5a..bcf811fc3 100644 --- a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/OnboardingService.java +++ b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/OnboardingService.java @@ -157,7 +157,7 @@ public void saveTokenWithAttachment(OnboardingAttachment onboardingAttachment) { private boolean checkTokenExist(Onboarding onboarding) { // Skip if token already exists - Optional optToken = tokenRepository.findByOnboardingId(onboarding.getId()); + Optional optToken = tokenRepository.findByIdOptional(onboarding.getId()); if (optToken.isPresent()) { log.debug("Token has already exists for onboarding {}", onboarding.getId()); return true; 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 c89765b2b..63b40af68 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 @@ -109,6 +109,9 @@ public static Map setUpCommonData( public static Map setUpAttachmentData(Onboarding onboarding) { Map map = new HashMap<>(); + map.put(INSTITUTION_NAME, onboarding.getInstitution().getDescription()); + map.put("institutionTaxCode", Optional.ofNullable(onboarding.getInstitution().getTaxCode()).orElse(UNDERSCORE)); + map.put("institutionMail", onboarding.getInstitution().getDigitalAddress()); if (Objects.nonNull(onboarding.getInstitution().getGpuData())) { map.put( "businessRegisterNumber", @@ -122,19 +125,12 @@ public static Map setUpAttachmentData(Onboarding onboarding) { "legalRegisterName", Optional.ofNullable(onboarding.getInstitution().getGpuData().getLegalRegisterName()) .orElse(UNDERSCORE)); - 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"); + map.put("businessRegisterCheckbox1", StringUtils.isNotEmpty(onboarding.getInstitution().getGpuData().getBusinessRegisterNumber()) ? "X" : ""); + map.put("businessRegisterCheckbox2", StringUtils.isEmpty(onboarding.getInstitution().getGpuData().getBusinessRegisterNumber()) ? "X" : ""); + map.put("publicServicesCheckbox1", StringUtils.isNotEmpty(onboarding.getInstitution().getGpuData().getLegalRegisterName()) ? "X" : ""); + map.put("publicServicesCheckbox2", StringUtils.isEmpty(onboarding.getInstitution().getGpuData().getLegalRegisterName()) ? "X" : ""); + map.put("longTermPaymentsCheckbox1", onboarding.getInstitution().getGpuData().isLongTermPayments() ? "X" : ""); + map.put("longTermPaymentsCheckbox2", !onboarding.getInstitution().getGpuData().isLongTermPayments() ? "X" : ""); } return map; } diff --git a/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/service/OnboardingServiceTest.java b/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/service/OnboardingServiceTest.java index d7dd033c3..0f43dba3e 100644 --- a/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/service/OnboardingServiceTest.java +++ b/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/service/OnboardingServiceTest.java @@ -258,11 +258,11 @@ void saveToken_shouldSkipIfTokenExists() { Token token = createDummyToken(); onboardingWorkflow.setOnboarding(onboarding); - when(tokenRepository.findByOnboardingId(onboarding.getId())).thenReturn(Optional.of(token)); + when(tokenRepository.findByIdOptional(onboarding.getId())).thenReturn(Optional.of(token)); onboardingService.saveTokenWithContract(onboardingWorkflow); - Mockito.verify(tokenRepository, Mockito.times(1)).findByOnboardingId(onboarding.getId()); + Mockito.verify(tokenRepository, Mockito.times(1)).findByIdOptional(onboarding.getId()); Mockito.verifyNoMoreInteractions(tokenRepository); } diff --git a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/entity/registry/RegistryManagerSELC.java b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/entity/registry/RegistryManagerSELC.java index b2878474e..f53ccc37a 100644 --- a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/entity/registry/RegistryManagerSELC.java +++ b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/entity/registry/RegistryManagerSELC.java @@ -35,7 +35,8 @@ public Uni customValidation(Product product) { protected boolean isWorkflowTypeAllowed(WorkflowType workflowType) { return workflowType == WorkflowType.FOR_APPROVE || workflowType == WorkflowType.IMPORT || - workflowType == WorkflowType.FOR_APPROVE_PT; + workflowType == WorkflowType.FOR_APPROVE_PT || + workflowType == WorkflowType.FOR_APPROVE_GPU; } @Override diff --git a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/service/TokenServiceDefault.java b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/service/TokenServiceDefault.java index fdd2650d6..d474f8bf2 100644 --- a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/service/TokenServiceDefault.java +++ b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/service/TokenServiceDefault.java @@ -1,6 +1,7 @@ package it.pagopa.selfcare.onboarding.service; import static it.pagopa.selfcare.onboarding.common.TokenType.ATTACHMENT; +import static it.pagopa.selfcare.onboarding.common.TokenType.INSTITUTION; import io.smallrye.mutiny.Uni; import it.pagopa.selfcare.azurestorage.AzureBlobClient; @@ -38,7 +39,7 @@ public Uni> getToken(String onboardingId) { } @Override public Uni> retrieveContractNotSigned(String onboardingId) { - return Token.find("onboardingId", onboardingId) + return Token.find("onboardingId = ?1 and type = ?2", onboardingId, INSTITUTION.name()) .firstResult() .map(Token.class::cast) .onItem().transformToUni(token -> diff --git a/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/service/TokenServiceDefaultTest.java b/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/service/TokenServiceDefaultTest.java index ece3a12ea..50deea65a 100644 --- a/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/service/TokenServiceDefaultTest.java +++ b/apps/onboarding-ms/src/test/java/it/pagopa/selfcare/onboarding/service/TokenServiceDefaultTest.java @@ -1,6 +1,7 @@ package it.pagopa.selfcare.onboarding.service; import static it.pagopa.selfcare.onboarding.common.TokenType.ATTACHMENT; +import static it.pagopa.selfcare.onboarding.common.TokenType.INSTITUTION; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.ArgumentMatchers.anyString; @@ -18,6 +19,7 @@ import io.smallrye.mutiny.Uni; import io.smallrye.mutiny.helpers.test.UniAssertSubscriber; import it.pagopa.selfcare.azurestorage.AzureBlobClient; +import it.pagopa.selfcare.onboarding.common.TokenType; import it.pagopa.selfcare.onboarding.entity.Token; import it.pagopa.selfcare.onboarding.util.QueryUtils; import jakarta.inject.Inject; @@ -59,12 +61,13 @@ void getToken() { void retrieveContractNotSigned() { Token token = new Token(); token.setContractFilename("fileName"); + token.setType(TokenType.INSTITUTION); ReactivePanacheQuery queryPage = mock(ReactivePanacheQuery.class); when(queryPage.firstResult()).thenReturn(Uni.createFrom().item(token)); PanacheMock.mock(Token.class); - when(Token.find("onboardingId", onboardingId)) - .thenReturn(queryPage); + when(Token.find("onboardingId = ?1 and type = ?2", onboardingId, INSTITUTION.name())) + .thenReturn(queryPage); when(azureBlobClient.getFileAsPdf(anyString())).thenReturn(new File("fileName"));