Skip to content

Commit

Permalink
Rimosse le verifiche sulla sintassi del numero avviso nelle richieste…
Browse files Browse the repository at this point in the history
… di pagamento.
  • Loading branch information
nardil committed Nov 21, 2019
1 parent d55b81d commit 6cf9d81
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private void handleAnnullamentoException(IContext ctx, Exception e) throws GovPa

public it.govpay.bd.model.Versamento chiediVersamento(RefVersamentoAvviso ref, Dominio dominio) throws ServiceException, GovPayException, UtilsException {
// conversione numeroAvviso in iuv
String iuv = VersamentoUtils.getIuvFromNumeroAvviso(ref.getNumeroAvviso(),dominio.getCodDominio(),dominio.getStazione().getCodStazione(),dominio.getStazione().getApplicationCode(),dominio.getSegregationCode());
String iuv = VersamentoUtils.getIuvFromNumeroAvviso(ref.getNumeroAvviso());
return this.chiediVersamento(null, null, null, null, ref.getIdDominio(), iuv);
}

Expand Down
44 changes: 22 additions & 22 deletions jars/core/src/main/java/it/govpay/core/utils/VersamentoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,8 @@ public static Versamento inoltroPendenza(Applicazione applicazione, String codDo
}
return versamento;
}


public static String getIuvFromNumeroAvviso(String numeroAvviso,String codDominio, String codStazione, Integer applicationCode, Integer segregationCode) throws GovPayException {

public static String getIuvFromNumeroAvviso(String numeroAvviso) throws GovPayException {
if(numeroAvviso == null)
return null;

Expand All @@ -386,6 +385,22 @@ public static String getIuvFromNumeroAvviso(String numeroAvviso,String codDomini
throw new GovPayException(EsitoOperazione.VER_017, numeroAvviso);
}

if(numeroAvviso.startsWith("0")) { // '0' + applicationCode(2) + ref(13) + check(2)
return numeroAvviso.substring(3);
}else if(numeroAvviso.startsWith("1")) // '1' + reference(17)
return numeroAvviso.substring(1);
else if(numeroAvviso.startsWith("2")) // '2' + ref(15) + check(2)
return numeroAvviso.substring(1);
else if(numeroAvviso.startsWith("3")) { // '3' + segregationCode(2) + ref(13) + check(2)
return numeroAvviso.substring(1);
}else
throw new GovPayException(EsitoOperazione.VER_017, numeroAvviso);
}


public static void verifyNumeroAvviso(String numeroAvviso,String codDominio, String codStazione, Integer applicationCode, Integer segregationCode) throws GovPayException {

getIuvFromNumeroAvviso(numeroAvviso);

if(numeroAvviso.startsWith("0")) { // '0' + applicationCode(2) + ref(13) + check(2)
// controllo che l'application code coincida con quello previsto
Expand All @@ -394,24 +409,14 @@ public static String getIuvFromNumeroAvviso(String numeroAvviso,String codDomini

if(applicationCode != null && applicationCode.intValue() != appCode.intValue())
throw new GovPayException(EsitoOperazione.VER_026, numeroAvviso, appCodeS, codStazione);

return numeroAvviso.substring(3);
}else if(numeroAvviso.startsWith("1")) // '1' + reference(17)
return numeroAvviso.substring(1);
else if(numeroAvviso.startsWith("2")) // '2' + ref(15) + check(2)
return numeroAvviso.substring(1);
else if(numeroAvviso.startsWith("3")) { // '3' + segregationCode(2) + ref(13) + check(2)
} else if(numeroAvviso.startsWith("3")) { // '3' + segregationCode(2) + ref(13) + check(2)
// controllo che segregationCode coincida con quello previsto
String segCodeS = numeroAvviso.substring(1, 3);
Integer segCode = Integer.parseInt(segCodeS);

if(segregationCode != null && segregationCode.intValue() != segCode.intValue())
throw new GovPayException(EsitoOperazione.VER_027, numeroAvviso, segCodeS, codDominio);

return numeroAvviso.substring(1);
}else
throw new GovPayException(EsitoOperazione.VER_017, numeroAvviso);
// return numeroAvviso;
}
}

public static Versamento toVersamentoModel(it.govpay.core.dao.commons.Versamento versamento, BasicBD bd) throws ServiceException, GovPayException, ValidationException {
Expand Down Expand Up @@ -502,7 +507,8 @@ public static Versamento toVersamentoModel(it.govpay.core.dao.commons.Versamento
model.setNumeroAvviso(versamento.getNumeroAvviso());

if(versamento.getNumeroAvviso() != null) {
String iuvFromNumeroAvviso = it.govpay.core.utils.VersamentoUtils.getIuvFromNumeroAvviso(versamento.getNumeroAvviso(),dominio.getCodDominio(),dominio.getStazione().getCodStazione(),
String iuvFromNumeroAvviso = it.govpay.core.utils.VersamentoUtils.getIuvFromNumeroAvviso(versamento.getNumeroAvviso());
it.govpay.core.utils.VersamentoUtils.verifyNumeroAvviso(versamento.getNumeroAvviso(),dominio.getCodDominio(),dominio.getStazione().getCodStazione(),
dominio.getStazione().getApplicationCode(), dominio.getSegregationCode());

// check sulla validita' dello iuv
Expand All @@ -517,12 +523,6 @@ public static Versamento toVersamentoModel(it.govpay.core.dao.commons.Versamento
model.setIuvVersamento(iuvFromNumeroAvviso);
model.setIuvProposto(iuvFromNumeroAvviso);

// if(versamento.getIuv().startsWith("0")) {
// model.setIuvVersamento(versamento.getIuv().substring(1));
// } else {
// model.setIuvVersamento(versamento.getIuv().substring(3));
// }
// model.setNumeroAvviso(versamento.getIuv());
model.setAvvisaturaOperazione(AvvisaturaOperazione.CREATE.getValue());
model.setAvvisaturaDaInviare(true);
}
Expand Down

0 comments on commit 6cf9d81

Please sign in to comment.