Skip to content

Commit

Permalink
Corretto comportamento del servizio paVerifyPaymentNotice nel caso di…
Browse files Browse the repository at this point in the history
… pagamento gia' in corso, non viene piu' restituito un fault, ma la lista dei tipi di pagamento disponibili.

Corretto CodeFault restituito in caso di acquisizione duplicata della CtReceipt.
Corretto problema di connessione con autocommit nella procedura di chiusura delle RPT SANP 2.4 scadute dopo il timeuot.
Aggiunto ordinamento per data alla lista transazioni associate ad una pendenza.
Corretta valorizzazione dell'importo della CtPaymentPA ora viene utilizzato l'importo ricevuto nella richiesta se specificato.
  • Loading branch information
pintorig committed Oct 5, 2021
1 parent 7d24f21 commit ea37a2b
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ Then assert responseStatus == 200 || responseStatus == 201
"faultString":"Pagamento in attesa risulta concluso all'Ente Creditore.",
"id":"#(idDominio)",
"description":"#notnull",
"serial":'##null'
"serial":'##null',
"originalFaultCode":'##null',
"originalFaultString":'##null',
"originalDescription":'##null'
}
"""
* def ccp = response.ccp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@ Then assert responseStatus == 200 || responseStatus == 201
* match response.stato == 'ESEGUITA'
* match response.dataPagamento == '#regex \\d\\d\\d\\d-\\d\\d-\\d\\d'
* match response.voci[0].stato == 'Eseguito'
* match response.rpp == '#[1]'
* match response.rpp[0].stato == 'RT_ACCETTATA_PA'
* match response.rpp[0].rt == '#notnull'
* match response.rpp == '#[2]'
* match response.rpp[0].stato == 'RPT_ANNULLATA'
* match response.rpp[0].rt == '#notpresent'
* match response.rpp[1].stato == 'RT_ACCETTATA_PA'
* match response.rpp[1].rt == '#notnull'


# ripristino dominio e stazione
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public String chiusuraRPTScadute(IContext ctx) throws GovPayException {
oldPagamentoPortale.setDescrizioneStato("Tentativo di pagamento scaduto dopo timeout di "+GovpayConfig.getInstance().getTimeoutPendentiModello3_SANP_24_Mins()+" minuti.");

rptBD.updateRpt(rpt.getId(), rpt);
ppbd.updatePagamento(oldPagamentoPortale);
ppbd.updatePagamento(oldPagamentoPortale, false, true);

rptBD.commit();
log.info("RPT [idDominio:"+rpt.getCodDominio()+"][iuv:"+rpt.getIuv()+"][ccp:"+rpt.getCcp()+"] annullata con successo.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@
import org.apache.commons.lang.StringUtils;
import org.openspcoop2.generic_project.exception.NotFoundException;
import org.openspcoop2.generic_project.exception.ServiceException;
import org.openspcoop2.generic_project.expression.SortOrder;
import org.openspcoop2.utils.json.ValidationException;
import org.openspcoop2.utils.serialization.IOException;
import org.openspcoop2.utils.service.context.ContextThreadLocal;
import org.springframework.security.core.Authentication;

import it.govpay.bd.BDConfigWrapper;
import it.govpay.bd.BasicBD;
import it.govpay.bd.FilterSortWrapper;
import it.govpay.bd.anagrafica.AnagraficaManager;
import it.govpay.bd.model.Dominio;
//import it.govpay.bd.model.Evento;
Expand Down Expand Up @@ -493,6 +495,8 @@ private LeggiPendenzaDTOResponse _leggiPendenza(String idA2A, String idPendenza,
RptFilter newFilter2 = rptBD.newFilter();
newFilter2.setIdPendenza(versamento.getCodVersamentoEnte());
newFilter2.setCodApplicazione(versamento.getApplicazione(configWrapper).getCodApplicazione());
FilterSortWrapper ordinamentoRPT = new FilterSortWrapper(it.govpay.orm.RPT.model().DATA_MSG_RICHIESTA,SortOrder.ASC);
newFilter2.addFilterSort(ordinamentoRPT);
long count = rptBD.count(newFilter2);

if(count > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public enum FaultPa {
PAA_PAGAMENTO_SCONOSCIUTO("Pagamento in attesa risulta sconosciuto all’Ente Creditore."),
PAA_RPT_SCONOSCIUTA("La RPT risulta sconosciuta."),
PAA_RT_DUPLICATA("La RT \u00E8 gi\u00E0 stata accettata."),
PAA_RECEIPT_DUPLICATA("La CtReceipt \u00E8 gi\u00E0 stata accettata."),
PAA_SEMANTICA("Errore semantico."),
PAA_SINTASSI_EXTRAXSD("Errore di sintassi extra XSD."),
PAA_SINTASSI_XSD("Errore di sintassi XSD."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -137,7 +136,17 @@ private Rpt buildRpt(PaGetPaymentReq requestBody,
*/

ctRpt.setCreditorReferenceId(iuv);
ctRpt.setPaymentAmount(versamento.getImportoTotale());

if(requestBody.getAmount() != null) {
if(requestBody.getAmount().equals(versamento.getImportoTotale())) {
ctRpt.setPaymentAmount(versamento.getImportoTotale());
} else {
ctRpt.setPaymentAmount(requestBody.getAmount());
}
} else {
ctRpt.setPaymentAmount(versamento.getImportoTotale());
}

if(versamento.getDataValidita() != null) {
ctRpt.setDueDate(versamento.getDataValidita()); // indicates the expiration payment date
} else if(versamento.getDataScadenza() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static Rpt acquisisciRT(String codDominio, String iuv, PaSendRTReq ctRt,

if(!acquisizioneDaCruscotto) {
if(rpt.getStato().equals(StatoRpt.RT_ACCETTATA_PA)) {
throw new NdpException(FaultPa.PAA_RT_DUPLICATA, "RT già acquisita in data " + rpt.getDataMsgRicevuta(), rpt.getCodDominio());
throw new NdpException(FaultPa.PAA_RECEIPT_DUPLICATA, "CtReceipt già acquisita in data " + rpt.getDataMsgRicevuta(), rpt.getCodDominio());
}
}

Expand Down Expand Up @@ -240,7 +240,7 @@ public static Rpt acquisisciRT(String codDominio, String iuv, PaSendRTReq ctRt,
case DECORRENZA_TERMINI_PARZIALE:
case PAGAMENTO_ESEGUITO:
case PAGAMENTO_PARZIALMENTE_ESEGUITO:
throw new NdpException(FaultPa.PAA_RT_DUPLICATA, "Aggiornamento di RT in pagamenti con esito "+rpt.getEsitoPagamento()+" non supportata.", rpt.getCodDominio());
throw new NdpException(FaultPa.PAA_RECEIPT_DUPLICATA, "Aggiornamento di CtReceipt in pagamenti con esito "+rpt.getEsitoPagamento()+" non supportata.", rpt.getCodDominio());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1245,29 +1245,29 @@ public PaVerifyPaymentNoticeRes paVerifyPaymentNotice(PaVerifyPaymentNoticeReq r
}


RptBD rptBD = new RptBD(configWrapper);
if(GovpayConfig.getInstance().isTimeoutPendentiModello3()) {
// Controllo che non ci sia un pagamento in corso
// Prendo tutte le RPT pendenti
RptFilter filter = rptBD.newFilter();
filter.setStato(Rpt.stati_pendenti);
filter.setIdVersamento(versamento.getId());
List<Rpt> rpt_pendenti = rptBD.findAll(filter);

// Per tutte quelle in corso controllo se hanno passato la soglia di timeout
// Altrimenti lancio il fault
Date dataSoglia = new Date(new Date().getTime() - GovpayConfig.getInstance().getTimeoutPendentiModello3Mins() * 60000);

for(Rpt rpt_pendente : rpt_pendenti) {
if(rpt_pendente.getPagamentoPortale() != null)
appContext.getEventoCtx().setIdPagamento(rpt_pendente.getPagamentoPortale().getIdSessione());
Date dataMsgRichiesta = rpt_pendente.getDataMsgRichiesta();
// se l'RPT e' bloccata allora controllo che il blocco sia indefinito oppure definito, altrimenti passo
if(rpt_pendente.isBloccante() && (GovpayConfig.getInstance().getTimeoutPendentiModello3Mins() == 0 || dataSoglia.before(dataMsgRichiesta))) {
throw new NdpException(FaultPa.PAA_PAGAMENTO_IN_CORSO, "Pagamento in corso [CCP:" + rpt_pendente.getCcp() + "].", codDominio);
}
}
}
// RptBD rptBD = new RptBD(configWrapper);
// if(GovpayConfig.getInstance().isTimeoutPendentiModello3()) {
// // Controllo che non ci sia un pagamento in corso
// // Prendo tutte le RPT pendenti
// RptFilter filter = rptBD.newFilter();
// filter.setStato(Rpt.stati_pendenti);
// filter.setIdVersamento(versamento.getId());
// List<Rpt> rpt_pendenti = rptBD.findAll(filter);
//
// // Per tutte quelle in corso controllo se hanno passato la soglia di timeout
// // Altrimenti lancio il fault
// Date dataSoglia = new Date(new Date().getTime() - GovpayConfig.getInstance().getTimeoutPendentiModello3Mins() * 60000);
//
// for(Rpt rpt_pendente : rpt_pendenti) {
// if(rpt_pendente.getPagamentoPortale() != null)
// appContext.getEventoCtx().setIdPagamento(rpt_pendente.getPagamentoPortale().getIdSessione());
// Date dataMsgRichiesta = rpt_pendente.getDataMsgRichiesta();
// // se l'RPT e' bloccata allora controllo che il blocco sia indefinito oppure definito, altrimenti passo
// if(rpt_pendente.isBloccante() && (GovpayConfig.getInstance().getTimeoutPendentiModello3Mins() == 0 || dataSoglia.before(dataMsgRichiesta))) {
// throw new NdpException(FaultPa.PAA_PAGAMENTO_IN_CORSO, "Pagamento in corso [CCP:" + rpt_pendente.getCcp() + "].", codDominio);
// }
// }
// }

// Verifico che abbia un solo singolo versamento N.B. controllo eliminato perche' e' consentito pagare pendenze multibeneficiario
// if(versamento.getSingoliVersamenti().size() != 1) {
Expand Down

0 comments on commit ea37a2b

Please sign in to comment.