disabilita la lettura delle info sull'indirizzo quando si verifica la partita iva da wingest

This commit is contained in:
2024-10-02 12:14:03 +02:00
parent b96479962c
commit 4335c1b0f7
2 changed files with 31 additions and 28 deletions

View File

@@ -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);
}

View File

@@ -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,6 +569,7 @@ public class ContabilService {
response.setValid(valid.value);
if (response.isValid()) {
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())));
@@ -596,6 +597,7 @@ public class ContabilService {
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));