From 4335c1b0f7e654a37669e1952802222c4da4bfad Mon Sep 17 00:00:00 2001 From: MinaR Date: Wed, 2 Oct 2024 12:14:03 +0200 Subject: [PATCH] disabilita la lettura delle info sull'indirizzo quando si verifica la partita iva da wingest --- .../controller/ContabilController.java | 5 +- .../ems/contabil/service/ContabilService.java | 54 ++++++++++--------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/ems-engine/src/main/java/it/integry/ems/contabil/controller/ContabilController.java b/ems-engine/src/main/java/it/integry/ems/contabil/controller/ContabilController.java index c4f3a46cf5..64bc0e6f47 100644 --- a/ems-engine/src/main/java/it/integry/ems/contabil/controller/ContabilController.java +++ b/ems-engine/src/main/java/it/integry/ems/contabil/controller/ContabilController.java @@ -217,8 +217,9 @@ public class ContabilController { @RequestMapping(value = "/checkPartitaIva", method = RequestMethod.POST) public @ResponseBody - ServiceRestResponse checkPartitaIva(HttpServletResponse response, HttpServletRequest request, @RequestBody CheckVat json) throws Exception { - CheckVatRestResponse checkVatRestResponse = contabilService.checkVat(json.getCountryCode(), json.getVatNumber()); + ServiceRestResponse checkPartitaIva(@RequestParam(required = false, defaultValue = "true") boolean enableLocationCheck, + @RequestBody CheckVat json) throws Exception { + CheckVatRestResponse checkVatRestResponse = contabilService.checkVat(json.getCountryCode(), json.getVatNumber(), enableLocationCheck); return ServiceRestResponse.createPositiveResponse(checkVatRestResponse); } diff --git a/ems-engine/src/main/java/it/integry/ems/contabil/service/ContabilService.java b/ems-engine/src/main/java/it/integry/ems/contabil/service/ContabilService.java index db116336c4..0e469616a0 100644 --- a/ems-engine/src/main/java/it/integry/ems/contabil/service/ContabilService.java +++ b/ems-engine/src/main/java/it/integry/ems/contabil/service/ContabilService.java @@ -509,7 +509,7 @@ public class ContabilService { return null; } - public CheckVatRestResponse checkVat(String countryCode, String vatNumber) throws Exception { + public CheckVatRestResponse checkVat(String countryCode, String vatNumber, boolean enableLocationCheck) throws Exception { String sql = "SELECT IsNull(cod_nazi_alpha_2, gtb_nazi.nazione) as nazione , gtb_nazi.chk_part_iva " + " FROM gtb_nazi INNER JOIN gtb_nazi_iso ON gtb_nazi.cod_nazione_iso = gtb_nazi_iso.cod_nazione_iso " + @@ -522,12 +522,12 @@ public class ContabilService { Boolean chkPartIva = (Boolean) datiNazione.get("chk_part_iva"); if (chkPartIva) { - return checkVatNazioneIso(isoCountry, vatNumber); + return checkVatNazioneIso(isoCountry, vatNumber, enableLocationCheck); } else { return null; } } - private CheckVatRestResponse checkVatNazioneIso(String countryCode, String vatNumber) throws Exception { + private CheckVatRestResponse checkVatNazioneIso(String countryCode, String vatNumber, boolean enableLocationCheck) throws Exception { SupportedStates state = SupportedStates.fromString(countryCode); if (state == null) { @@ -569,33 +569,35 @@ public class ContabilService { response.setValid(valid.value); if (response.isValid()) { - response.setCountryCode(code.value); - response.setVatNumber(pIva.value); - response.setRequestDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(date.value.toGregorianCalendar().getTimeInMillis()))); + if (enableLocationCheck) { + response.setCountryCode(code.value); + response.setVatNumber(pIva.value); + response.setRequestDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(date.value.toGregorianCalendar().getTimeInMillis()))); - response.setName(name.value); - response.setAddress(address.value); - response.setRagSoc(name.value);// alias di 'name' + response.setName(name.value); + response.setAddress(address.value); + response.setRagSoc(name.value);// alias di 'name' - String indirizzo = null, cap = null, citta = null, prov = null; - if (address.value != null) { - IndirizzoDTO indirizzoDTO = null; - try { - indirizzoDTO = mapService.geocode(address.value); - } catch (Exception e) { - logger.error("checkVat", e); - } - if (indirizzoDTO != null) { - indirizzo = indirizzoDTO.getIndirizzo(); - cap = indirizzoDTO.getCap(); - citta = indirizzoDTO.getCitta(); - prov = indirizzoDTO.getProv(); + String indirizzo = null, cap = null, citta = null, prov = null; + if (address.value != null) { + IndirizzoDTO indirizzoDTO = null; + try { + indirizzoDTO = mapService.geocode(address.value); + } catch (Exception e) { + logger.error("checkVat", e); + } + if (indirizzoDTO != null) { + indirizzo = indirizzoDTO.getIndirizzo(); + cap = indirizzoDTO.getCap(); + citta = indirizzoDTO.getCitta(); + prov = indirizzoDTO.getProv(); + } } + response.setIndirizzo(indirizzo); + response.setCap(cap); + response.setCitta(citta); + response.setProv(prov); } - response.setIndirizzo(indirizzo); - response.setCap(cap); - response.setCitta(citta); - response.setProv(prov); } else { throw new CheckVatException(String.format("Partita IVA %s [Stato: %s] non registrata al VIES", partitaIVA, countryCode));