diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 167697f..0935fdb 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -124,6 +124,7 @@ microservice-chart: RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS: "0" RECOVER_NOT_NOTIFIED_MASSIVE_MAX_RECORDS: "200" ECOMMERCE_FILTER_ENABLED: "true" + UNWANTED_REMITTANCE_INFO: "pagamento multibeneficiario,pagamento bpay" envConfigMapExternals: template-maps: BRAND_LOGO_MAP: brand-logo-map diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 0b66cec..76fd62f 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -113,17 +113,18 @@ microservice-chart: MAX_DATE_DIFF_MILLIS: "1800000" # 30min MAX_DATE_DIFF_NOTIFY_MILLIS: "1800000" # 30nin MAX_DATE_DIFF_CART_MILLIS: "1800000" # 30nin - TRIGGER_NOTIFY_REC_SCHEDULE: "0 0 */1 * * *" - RECOVER_FAILED_CRON: "0 0 */1 * * *" - RECOVER_FAILED_CART_CRON: "0 0 */1 * * *" + TRIGGER_NOTIFY_REC_SCHEDULE: "0 0 */1 * * *" # https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=python-v2%2Cisolated-process%2Cnodejs-v4&pivots=programming-language-java#function-apps-sharing-storage + RECOVER_FAILED_CRON: "0 0 */1 * * *" # https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=python-v2%2Cisolated-process%2Cnodejs-v4&pivots=programming-language-java#function-apps-sharing-storage + RECOVER_FAILED_CART_CRON: "0 0 */1 * * *" # https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=python-v2%2Cisolated-process%2Cnodejs-v4&pivots=programming-language-java#function-apps-sharing-storage AZURE_FUNCTIONS_MESH_JAVA_OPTS: "-javaagent:/home/site/wwwroot/jmx_prometheus_javaagent-0.19.0.jar=12345:/home/site/wwwroot/config.yaml -javaagent:/home/site/wwwroot/opentelemetry-javaagent.jar -Xmx768m -XX:+UseG1GC" - FAILED_AUTORECOVER_ENABLED: "false" - NOT_NOTIFIED_AUTORECOVER_ENABLED: "false" - FAILED_CART_AUTORECOVER_ENABLED: "false" + FAILED_AUTORECOVER_ENABLED: "true" # https://pagopa.atlassian.net/wiki/spaces/PPR/pages/822870269/Analisi+APIs+Monitoring+Recover+helpdesk-receipt + NOT_NOTIFIED_AUTORECOVER_ENABLED: "true" # https://pagopa.atlassian.net/wiki/spaces/PPR/pages/822870269/Analisi+APIs+Monitoring+Recover+helpdesk-receipt + FAILED_CART_AUTORECOVER_ENABLED: "true" # https://pagopa.atlassian.net/wiki/spaces/PPR/pages/822870269/Analisi+APIs+Monitoring+Recover+helpdesk-receipt RECOVER_FAILED_MASSIVE_MAX_DAYS: "1" RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS: "1" RECOVER_NOT_NOTIFIED_MASSIVE_MAX_RECORDS: "200" ECOMMERCE_FILTER_ENABLED: "true" + UNWANTED_REMITTANCE_INFO: "pagamento multibeneficiario,pagamento bpay" envConfigMapExternals: template-maps: BRAND_LOGO_MAP: brand-logo-map diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index ed04e5d..5969dcd 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -124,6 +124,7 @@ microservice-chart: RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS: "0" RECOVER_NOT_NOTIFIED_MASSIVE_MAX_RECORDS: "200" ECOMMERCE_FILTER_ENABLED: "true" + UNWANTED_REMITTANCE_INFO: "pagamento multibeneficiario,pagamento bpay" envConfigMapExternals: template-maps: BRAND_LOGO_MAP: brand-logo-map diff --git a/integration-test/src/step_definitions/common.js b/integration-test/src/step_definitions/common.js index 6091abd..d30d015 100644 --- a/integration-test/src/step_definitions/common.js +++ b/integration-test/src/step_definitions/common.js @@ -132,7 +132,7 @@ function createEvent(id, status, transactionId, totalNotice, orgCode, iuv) { "idTransaction": "123456", "transactionId": transactionId || "123456", "grandTotal": 0, - "amount": 0, + "amount": 1000, "fee": 0 } }, diff --git a/src/main/java/it/gov/pagopa/receipt/pdf/helpdesk/utils/BizEventToReceiptUtils.java b/src/main/java/it/gov/pagopa/receipt/pdf/helpdesk/utils/BizEventToReceiptUtils.java index 4372efa..2f89a54 100644 --- a/src/main/java/it/gov/pagopa/receipt/pdf/helpdesk/utils/BizEventToReceiptUtils.java +++ b/src/main/java/it/gov/pagopa/receipt/pdf/helpdesk/utils/BizEventToReceiptUtils.java @@ -254,6 +254,14 @@ public static boolean isBizEventInvalid(BizEvent bizEvent, ExecutionContext cont return true; } + if (!isCartMod1(bizEvent)) { + logger.debug("[{}] event with id {} contain either an invalid amount value," + + " or it is a legacy cart element", + context.getFunctionName(), bizEvent.getId()); + return true; + } + + if (bizEvent.getPaymentInfo() != null) { String totalNotice = bizEvent.getPaymentInfo().getTotalNotice(); @@ -513,4 +521,21 @@ public static Integer getTotalNotice(BizEvent bizEvent, ExecutionContext context } return 1; } + + /** + * Method to check if the content comes from a legacy cart model (see https://pagopa.atlassian.net/browse/VAS-1167) + * @param bizEvent bizEvent to validate + * @return flag to determine if it is a manageable cart, or otherwise, will return false if + * it is considered a legacy cart content (not having a totalNotice field and having amount values != 0) + */ + public static boolean isCartMod1(BizEvent bizEvent) { + if (bizEvent.getPaymentInfo() != null && bizEvent.getPaymentInfo().getTotalNotice() == null) { + return bizEvent.getTransactionDetails() != null && + new BigDecimal(bizEvent.getPaymentInfo().getAmount()).subtract( + formatEuroCentAmount(bizEvent.getTransactionDetails().getTransaction().getAmount())) + .floatValue() == 0; + } + return true; + } + } diff --git a/src/test/java/it/gov/pagopa/receipt/pdf/helpdesk/RecoverFailedReceiptTest.java b/src/test/java/it/gov/pagopa/receipt/pdf/helpdesk/RecoverFailedReceiptTest.java index 9ef8941..8881f5a 100644 --- a/src/test/java/it/gov/pagopa/receipt/pdf/helpdesk/RecoverFailedReceiptTest.java +++ b/src/test/java/it/gov/pagopa/receipt/pdf/helpdesk/RecoverFailedReceiptTest.java @@ -35,6 +35,7 @@ import org.mockito.stubbing.Answer; import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -386,6 +387,8 @@ void runDiscardedWithEventNotDONE() throws BizEventNotFoundException { verifyNoInteractions(queueClientMock); } + + @Test void generateAnonymousDebtorBizEvent() throws BizEventNotFoundException { BizEvent bizEvent = generateAnonymDebtorBizEvent(); @@ -431,8 +434,9 @@ void runDiscardedWithEventNull() throws BizEventNotFoundException { } @Test - void runDiscardedWithCartEvent() throws BizEventNotFoundException { - when(bizEventCosmosClientMock.getBizEventDocument(EVENT_ID)).thenReturn(generateValidBizEvent("2")); + void runDiscardedWithCartEventWithInvalidTotalNotice() throws BizEventNotFoundException { + when(bizEventCosmosClientMock.getBizEventDocument(EVENT_ID)) + .thenReturn(generateValidBizEvent("invalid string")); doAnswer((Answer) invocation -> { HttpStatus status = (HttpStatus) invocation.getArguments()[0]; @@ -452,16 +456,17 @@ void runDiscardedWithCartEvent() throws BizEventNotFoundException { } @Test - void runDiscardedWithCartEventWithInvalidTotalNotice() throws BizEventNotFoundException { + void runDiscardedWithInvalidCartAmounts() throws BizEventNotFoundException { + BizEvent bizEvent = generateValidBizEvent(null); + bizEvent.getTransactionDetails().getTransaction().setAmount(10); when(bizEventCosmosClientMock.getBizEventDocument(EVENT_ID)) - .thenReturn(generateValidBizEvent("invalid string")); + .thenReturn(bizEvent); doAnswer((Answer) invocation -> { HttpStatus status = (HttpStatus) invocation.getArguments()[0]; return new HttpResponseMessageMock.HttpResponseMessageBuilderMock().status(status); }).when(requestMock).createResponseBuilder(any(HttpStatus.class)); - // test execution HttpResponseMessage response = assertDoesNotThrow(() -> sut.run(requestMock, EVENT_ID, documentdb, contextMock)); // test assertion @@ -471,6 +476,7 @@ void runDiscardedWithCartEventWithInvalidTotalNotice() throws BizEventNotFoundEx verifyNoInteractions(receiptCosmosServiceMock); verifyNoInteractions(queueClientMock); + } @Test @@ -539,11 +545,13 @@ private BizEvent generateValidBizEvent(String totalNotice){ TransactionDetails transactionDetails = new TransactionDetails(); Transaction transaction = new Transaction(); transaction.setCreationDate(String.valueOf(LocalDateTime.now())); + transaction.setAmount(10000); transactionDetails.setTransaction(transaction); transactionDetails.setOrigin("INFO"); PaymentInfo paymentInfo = new PaymentInfo(); paymentInfo.setTotalNotice(totalNotice); + paymentInfo.setAmount("100.0"); item.setEventStatus(BizEventStatusType.DONE); item.setId(EVENT_ID);