Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove replace from transfer response #71

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-gpd-payments
description: Microservice that exposes API for payment receipts retrieving and other operations
type: application
version: 0.36.0
appVersion: 0.11.2
version: 0.37.0
appVersion: 0.11.2-1-PAGOPA-1328-fix-transfer-category-replace
dependencies:
- name: microservice-chart
version: 2.4.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-gpd-payments
tag: "0.11.2"
tag: "0.11.2-1-PAGOPA-1328-fix-transfer-category-replace"
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-gpd-payments
tag: "0.11.2"
tag: "0.11.2-1-PAGOPA-1328-fix-transfer-category-replace"
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-gpd-payments
tag: "0.11.2"
tag: "0.11.2-1-PAGOPA-1328-fix-transfer-category-replace"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Payments",
"description": "Payments",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "0.11.2"
"version": "0.11.2-1-PAGOPA-1328-fix-transfer-category-replace"
},
"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>payments</artifactId>
<version>0.11.2</version>
<version>0.11.2-1-PAGOPA-1328-fix-transfer-category-replace</version>
<name>Payments</name>
<description>Payments</description>

Expand Down
98 changes: 49 additions & 49 deletions src/main/java/it/gov/pagopa/payments/service/PartnerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
import it.gov.pagopa.payments.model.spontaneous.*;
import it.gov.pagopa.payments.utils.CommonUtil;
import it.gov.pagopa.payments.utils.CustomizedMapper;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.xml.sax.SAXException;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.net.URISyntaxException;
import java.security.InvalidKeyException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
Expand All @@ -39,16 +39,15 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.net.URISyntaxException;
import java.security.InvalidKeyException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.xml.sax.SAXException;

@Service
@Slf4j
Expand Down Expand Up @@ -129,9 +128,7 @@ public PaGetPaymentRes paGetPayment(PaGetPaymentReq request)
log.debug(
"[paGetPayment] method call [noticeNumber={}]", request.getQrCode().getNoticeNumber());
PaymentsModelResponse paymentOption =
this.manageGetPaymentRequest(
request.getIdPA(),
request.getQrCode());
this.manageGetPaymentRequest(request.getIdPA(), request.getQrCode());
log.info(
"[paGetPayment] Response OK generation [noticeNumber={}]",
request.getQrCode().getNoticeNumber());
Expand All @@ -144,9 +141,7 @@ public PaGetPaymentV2Response paGetPaymentV2(PaGetPaymentV2Request request)
log.debug(
"[paGetPaymentV2] method call [noticeNumber={}]", request.getQrCode().getNoticeNumber());
PaymentsModelResponse paymentOption =
this.manageGetPaymentRequest(
request.getIdPA(),
request.getQrCode());
this.manageGetPaymentRequest(request.getIdPA(), request.getQrCode());
log.info(
"[paGetPaymentV2] Response OK generation [noticeNumber={}]",
request.getQrCode().getNoticeNumber());
Expand Down Expand Up @@ -193,12 +188,9 @@ public PaSendRTV2Response paSendRTV2(PaSendRTV2Request request) {

@Transactional
public PaDemandPaymentNoticeResponse paDemandPaymentNotice(PaDemandPaymentNoticeRequest request)
throws DatatypeConfigurationException,
ParserConfigurationException,
IOException,
SAXException,
XMLStreamException {

throws DatatypeConfigurationException, ParserConfigurationException, IOException,
SAXException, XMLStreamException {

List<ServicePropertyModel> attributes = mapDatiSpecificiServizio(request);

SpontaneousPaymentModel spontaneousPayment =
Expand Down Expand Up @@ -274,7 +266,11 @@ private PaDemandPaymentNoticeResponse createPaDemandPaymentNoticeResponse(
factory.createCtPaymentOptionDescriptionPA();

var ccp =
gpsResponse.getPaymentOption().get(0).getTransfer().stream()
gpsResponse
.getPaymentOption()
.get(0)
.getTransfer()
.stream()
.noneMatch(elem -> elem.getPostalIban() == null || elem.getPostalIban().isBlank());
ctPaymentOptionDescriptionPA.setAllCCP(ccp);

Expand Down Expand Up @@ -358,7 +354,9 @@ private PaGetPaymentRes generatePaGetPaymentResponse(
transferList
.getTransfer()
.addAll(
source.getTransfer().stream()
source
.getTransfer()
.stream()
.map(
paymentsTransferModelResponse ->
getTransferResponse(
Expand Down Expand Up @@ -414,7 +412,9 @@ private PaGetPaymentV2Response generatePaGetPaymentResponse(
transferList
.getTransfer()
.addAll(
source.getTransfer().stream()
source
.getTransfer()
.stream()
.map(
paymentsTransferModelResponse ->
getTransferResponseV2(
Expand Down Expand Up @@ -449,13 +449,13 @@ private PaVerifyPaymentNoticeRes generatePaVerifyPaymentNoticeResponse(
paymentOption.setAmount(BigDecimal.valueOf(source.getAmount()));
paymentOption.setOptions(StAmountOption.EQ); // de-scoping
paymentOption.setDueDate(
DatatypeFactory.newInstance().newXMLGregorianCalendar(
CommonUtil.convertToGregorianCalendar(
source.getDueDate()
)));
DatatypeFactory.newInstance()
.newXMLGregorianCalendar(CommonUtil.convertToGregorianCalendar(source.getDueDate())));
paymentOption.setDetailDescription(source.getDescription());
var cpp =
source.getTransfer().stream()
source
.getTransfer()
.stream()
.noneMatch(elem -> elem.getPostalIban() == null || elem.getPostalIban().isBlank());
paymentOption.setAllCCP(cpp); // allCPP fa parte del modello del option
paymentList.setPaymentOptionDescription(paymentOption);
Expand All @@ -482,7 +482,7 @@ private CtTransferPA getTransferResponse(
transferPa.setIdTransfer(Integer.parseInt(transfer.getIdTransfer()));
transferPa.setRemittanceInformation(transfer.getRemittanceInformation());
transferPa.setTransferAmount(BigDecimal.valueOf(transfer.getAmount()));
transferPa.setTransferCategory(transfer.getCategory().replace("/", ""));
transferPa.setTransferCategory(transfer.getCategory());
return transferPa;
}

Expand Down Expand Up @@ -562,7 +562,8 @@ private String marshalV2(PaSendRTV2Request paSendRTV2Request) throws JAXBExcepti
private void saveReceipt(ReceiptEntity receiptEntity)
throws InvalidKeyException, URISyntaxException, StorageException {
try {
TableEntity tableEntity = new TableEntity(receiptEntity.getOrganizationFiscalCode(), receiptEntity.getIuv());
TableEntity tableEntity =
new TableEntity(receiptEntity.getOrganizationFiscalCode(), receiptEntity.getIuv());
Map<String, Object> properties = new HashMap<>();
properties.put(DEBTOR_PROPERTY, receiptEntity.getDebtor());
properties.put(DOCUMENT_PROPERTY, receiptEntity.getDocument());
Expand All @@ -572,8 +573,7 @@ private void saveReceipt(ReceiptEntity receiptEntity)
tableClient.createEntity(tableEntity);
} catch (TableServiceException e) {
log.error(DBERROR, e);
if(e.getValue().getErrorCode() == TableErrorCode.ENTITY_ALREADY_EXISTS)
{
if (e.getValue().getErrorCode() == TableErrorCode.ENTITY_ALREADY_EXISTS) {
throw new PartnerValidationException(PaaErrorEnum.PAA_RECEIPT_DUPLICATA);
}
throw new AppException(AppError.DB_ERROR);
Expand All @@ -582,7 +582,7 @@ private void saveReceipt(ReceiptEntity receiptEntity)

private ReceiptEntity getReceipt(String organizationFiscalCode, String iuv)
throws InvalidKeyException, URISyntaxException, StorageException {
try{
try {
TableEntity tableEntity = tableClient.getEntity(organizationFiscalCode, iuv);
return ConvertTableEntityToReceiptEntity.mapTableEntityToReceiptEntity(tableEntity);
} catch (TableServiceException e) {
Expand All @@ -594,7 +594,8 @@ private ReceiptEntity getReceipt(String organizationFiscalCode, String iuv)
private void updateReceipt(ReceiptEntity receiptEntity)
throws InvalidKeyException, URISyntaxException, StorageException {
try {
TableEntity tableEntity = tableClient.getEntity(receiptEntity.getOrganizationFiscalCode(), receiptEntity.getIuv());
TableEntity tableEntity =
tableClient.getEntity(receiptEntity.getOrganizationFiscalCode(), receiptEntity.getIuv());
Map<String, Object> properties = new HashMap<>();
properties.put(DEBTOR_PROPERTY, receiptEntity.getDebtor());
properties.put(DOCUMENT_PROPERTY, receiptEntity.getDocument());
Expand Down Expand Up @@ -652,8 +653,7 @@ private CtSubject getDebtor(PaymentsModelResponse source) {
return debtor;
}

private PaymentsModelResponse manageGetPaymentRequest(
String idPa, CtQrCode qrCode) {
private PaymentsModelResponse manageGetPaymentRequest(String idPa, CtQrCode qrCode) {

log.debug(
"[manageGetPaymentRequest] get payment option [noticeNumber={}]", qrCode.getNoticeNumber());
Expand Down Expand Up @@ -686,7 +686,7 @@ private PaymentOptionModelResponse managePaSendRtRequest(PaSendRTReq request) {
log.debug(
"[managePaSendRtRequest] save receipt [noticeNumber={}]",
request.getReceipt().getNoticeNumber());

ReceiptEntity receiptEntity =
this.getReceiptEntity(
request.getIdPA(),
Expand Down