Skip to content

Commit

Permalink
Merge branch 'release-v0.4.x' into PAGOPA-2249
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-ang authored Oct 10, 2024
2 parents 2bf17a8 + 25c7345 commit a993080
Show file tree
Hide file tree
Showing 17 changed files with 155 additions and 80 deletions.
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-wisp-converter
description: A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, interfacing them with GPD system
type: application
version: 0.224.0
appVersion: 0.4.4-2-release-v0.4.x
version: 0.225.0
appVersion: 0.4.4-3-release-v0.4.x
dependencies:
- name: microservice-chart
version: 3.0.0
Expand Down
2 changes: 1 addition & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter
tag: "0.4.4-2-release-v0.4.x"
tag: "0.4.4-3-release-v0.4.x"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter
tag: "0.4.4-2-release-v0.4.x"
tag: "0.4.4-3-release-v0.4.x"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter
tag: "0.4.4-2-release-v0.4.x"
tag: "0.4.4-3-release-v0.4.x"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion openapi/openapi_redirect.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.1",
"info": {
"title": "WISP-Converter-redirect",
"version": "0.4.4-2-release-v0.4.x"
"version": "0.4.4-3-release-v0.4.x"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>it.gov.pagopa</groupId>
<artifactId>wisp-converter</artifactId>
<version>0.4.4-2-release-v0.4.x</version>
<version>0.4.4-3-release-v0.4.x</version>
<name>pagoPA WISP Converter</name>
<description>A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments.</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import it.gov.pagopa.wispconverter.controller.model.RecoveryReceiptByPartitionRequest;
import it.gov.pagopa.wispconverter.controller.model.RecoveryReceiptReportResponse;
import it.gov.pagopa.wispconverter.controller.model.RecoveryReceiptRequest;
import it.gov.pagopa.wispconverter.controller.model.RecoveryReceiptResponse;
Expand Down Expand Up @@ -92,7 +93,7 @@ public ResponseEntity<RecoveryReceiptResponse> recoverReceiptKOForCreditorInstit

@Operation(summary = "Execute reconciliation for passed receipts.", description = "Execute reconciliation of all receipts in the request, searching by passed identifier", security = {@SecurityRequirement(name = "ApiKey")}, tags = {"Recovery"})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Reconciliation completed")
@ApiResponse(responseCode = "200", description = "Reconciliation scheduled")
})
@PostMapping(value = "/receipts")
public ResponseEntity<RecoveryReceiptReportResponse> recoverReceiptToBeReSent(@RequestBody RecoveryReceiptRequest request) {
Expand All @@ -108,4 +109,23 @@ public ResponseEntity<RecoveryReceiptReportResponse> recoverReceiptToBeReSent(@R
throw ex;
}
}

@Operation(summary = "Execute reconciliation for passed receipts by partition.", description = "Execute reconciliation of all receipts contained in the partitions of the request", security = {@SecurityRequirement(name = "ApiKey")}, tags = {"Recovery"})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Reconciliation scheduled")
})
@PostMapping(value = "/partitions")
public ResponseEntity<RecoveryReceiptReportResponse> recoverReceiptToBeReSentByPartition(@RequestBody RecoveryReceiptByPartitionRequest request) {
try {
log.info("Invoking API operation recoverReceiptToBeReSentByPartition - args: {}", request);
return ResponseEntity.ok(recoveryService.recoverReceiptToBeReSentByPartition(request));
} catch (Exception ex) {
String operationId = MDC.get(Constants.MDC_OPERATION_ID);
log.error(String.format("GenericException: operation-id=[%s]", operationId != null ? operationId : "n/a"), ex);
AppException appException = new AppException(ex, AppErrorCodeMessageEnum.ERROR, ex.getMessage());
ErrorResponse errorResponse = errorUtil.forAppException(appException);
log.error("Failed API operation recoverReceiptToBeReSentByPartition - error: {}", errorResponse);
throw ex;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package it.gov.pagopa.wispconverter.controller.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.List;

@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class RecoveryReceiptByPartitionRequest {

private List<String> partitionKeys;
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ List<ReEventEntity> findBySessionIdAndStatusAndPartitionKey(@Param("date") Strin
"AND c.eventCategory = 'INTERFACE' AND c.eventSubcategory = 'REQ' " +
"AND c.businessProcess = @businessProcess " +
"AND c.operationId = @operationId " +
"AND c.status = @status ORDER BY c._ts OFFSET 0 LIMIT 1")
Optional<ReEventEntity> findFirstInterfaceRequestByPartitionKey(
"AND c.status = null ORDER BY c._ts OFFSET 0 LIMIT 1")
List<ReEventEntity> findFirstInterfaceRequestByPartitionKey(
@Param("date") String partitionKey,
@Param("businessProcess") String businessProcess,
@Param("operationId") String operationId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ public void refreshCache() {
it.gov.pagopa.gen.wispconverter.client.cache.api.CacheApi apiInstance = new it.gov.pagopa.gen.wispconverter.client.cache.api.CacheApi(configCacheClient);
if (configData == null) {
configData = apiInstance.get(cacheKeys);
log.info("loadCache from cache api...done");
} else {
CacheVersionDto id = apiInstance.id();
if (!configData.getVersion().equals(id.getVersion())) {
configData = apiInstance.get(cacheKeys);
log.info("loadCache from cache api...done");
}
}

} catch (RestClientException e) {
throw new AppException(AppErrorCodeMessageEnum.CLIENT_DECOUPLER_CACHING,
throw new AppException(AppErrorCodeMessageEnum.CLIENT_APICONFIGCACHE,
String.format("RestClientException ERROR [%s] - %s", e.getCause().getClass().getCanonicalName(), e.getMessage()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,40 @@ public static IntestazionePPT generateHeader(String creditorInstitutionId, Strin
return header;
}

public static List<RPTContentDTO> extractRequiredRPTs(SessionDataDTO sessionData, String iuv, String creditorInstiutionId) {
List<RPTContentDTO> rpts;
if (Boolean.TRUE.equals(sessionData.getCommonFields().getIsMultibeneficiary())) {
rpts = sessionData.getAllRPTs().stream().toList();
} else {
rpts = sessionData.getAllRPTs().stream()
.filter(rpt -> rpt.getIuv().equals(iuv) && rpt.getRpt().getDomain().getDomainId().equals(creditorInstiutionId))
.toList();
}
return rpts;
}

public static PaSendRTV2Request extractDataFromPaSendRT(JaxbElementUtil jaxbElementUtil, String payload, RPTContentDTO rpt) {
SOAPMessage deepCopyMessage = jaxbElementUtil.getMessage(payload);
PaSendRTV2Request deepCopySendRTV2 = jaxbElementUtil.getBody(deepCopyMessage, PaSendRTV2Request.class);

List<CtTransferPAReceiptV2> transfers = deepCopySendRTV2.getReceipt().getTransferList().getTransfer();
transfers = transfers.stream()
.filter(transfer -> transfer.getFiscalCodePA().equals(rpt.getRpt().getDomain().getDomainId()))
.toList();

BigDecimal amount = transfers.stream()
.map(CtTransferPAReceiptV2::getTransferAmount)
.reduce(BigDecimal::add)
.orElse(deepCopySendRTV2.getReceipt().getPaymentAmount());
deepCopySendRTV2.getReceipt().setPaymentAmount(amount);
deepCopySendRTV2.setIdPA(rpt.getRpt().getDomain().getDomainId());

CtTransferListPAReceiptV2 transferList = new CtTransferListPAReceiptV2();
transferList.getTransfer().addAll(transfers);
deepCopySendRTV2.getReceipt().setTransferList(transferList);
return deepCopySendRTV2;
}

/**
* @param payload a list of {@link ReceiptDto} elements
* @deprecated use {@code sendKoPaaInviaRtToCreditorInstitution(List<ReceiptDto> receipts)} method instead
Expand Down Expand Up @@ -261,7 +295,7 @@ public void sendOkPaaInviaRtToCreditorInstitution(String payload) {
for (RPTContentDTO rpt : rpts) {

// actualize content for correctly handle multibeneficiary carts
PaSendRTV2Request deepCopySendRTV2 = extractDataFromPaSendRT(payload, rpt);
PaSendRTV2Request deepCopySendRTV2 = extractDataFromPaSendRT(jaxbElementUtil, payload, rpt);

// generate the header for the paaInviaRT SOAP request. This object is different for each generated request
IntestazionePPT intestazionePPT = generateHeader(
Expand Down Expand Up @@ -289,28 +323,6 @@ public void sendOkPaaInviaRtToCreditorInstitution(String payload) {
}
}

private PaSendRTV2Request extractDataFromPaSendRT(String payload, RPTContentDTO rpt) {
SOAPMessage deepCopyMessage = jaxbElementUtil.getMessage(payload);
PaSendRTV2Request deepCopySendRTV2 = jaxbElementUtil.getBody(deepCopyMessage, PaSendRTV2Request.class);

List<CtTransferPAReceiptV2> transfers = deepCopySendRTV2.getReceipt().getTransferList().getTransfer();
transfers = transfers.stream()
.filter(transfer -> transfer.getFiscalCodePA().equals(rpt.getRpt().getDomain().getDomainId()))
.toList();

BigDecimal amount = transfers.stream()
.map(CtTransferPAReceiptV2::getTransferAmount)
.reduce(BigDecimal::add)
.orElse(deepCopySendRTV2.getReceipt().getPaymentAmount());
deepCopySendRTV2.getReceipt().setPaymentAmount(amount);
deepCopySendRTV2.setIdPA(rpt.getRpt().getDomain().getDomainId());

CtTransferListPAReceiptV2 transferList = new CtTransferListPAReceiptV2();
transferList.getTransfer().addAll(transfers);
deepCopySendRTV2.getReceipt().setTransferList(transferList);
return deepCopySendRTV2;
}

public String generateKoRtFromSessionData(String creditorInstitutionId, String iuv, RPTContentDTO rpt,
CommonFieldsDTO commonFields, gov.telematici.pagamenti.ws.papernodo.ObjectFactory objectFactory,
Map<String, ConfigurationKeyDto> configurations, ReceiptStatusEnum receiptStatus) {
Expand Down Expand Up @@ -360,6 +372,7 @@ public SessionDataDTO getSessionDataFromSessionId(String sessionId) {
return this.rptExtractorService.extractSessionData(rptRequestEntity.getPrimitive(), rptRequestEntity.getPayload());
}


private SessionDataDTO getSessionDataFromCachedKeys(CachedKeysMapping cachedMapping) {

// retrieve cached session identifier form
Expand Down Expand Up @@ -445,17 +458,6 @@ From station identifier (the common one defined, not the payment reference), ret
return isSuccessful;
}

private List<RPTContentDTO> extractRequiredRPTs(SessionDataDTO sessionData, String iuv, String creditorInstiutionId) {
List<RPTContentDTO> rpts;
if (Boolean.TRUE.equals(sessionData.getCommonFields().getIsMultibeneficiary())) {
rpts = sessionData.getAllRPTs().stream().toList();
} else {
rpts = sessionData.getAllRPTs().stream()
.filter(rpt -> rpt.getIuv().equals(iuv) && rpt.getRpt().getDomain().getDomainId().equals(creditorInstiutionId))
.toList();
}
return rpts;
}

private CtRicevutaTelematica generateRTContentForKoReceipt(RPTContentDTO rpt, Map<String, ConfigurationKeyDto> configurations, Instant now, String paymentOutcome) {

Expand Down
Loading

0 comments on commit a993080

Please sign in to comment.