disabilita la lettura delle info sull'indirizzo quando si verifica la partita iva da wingest
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user