Skip to content

Commit

Permalink
fix: Remove replace from transfer response
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-ang committed Oct 31, 2023
1 parent 7fac0f2 commit 884a71b
Showing 1 changed file with 49 additions and 49 deletions.
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

0 comments on commit 884a71b

Please sign in to comment.