Skip to content

Commit b1a0f2c

Browse files
committed
fix: generazione fattura elettronica per sedi committente paesi esteri
1 parent 12690fe commit b1a0f2c

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎plugins/exportFE/src/FatturaElettronica.php‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,16 +1129,24 @@ protected static function getDatiTrasporto($fattura)
11291129
$result['IndirizzoResa']['Indirizzo'] = $sede['indirizzo'];
11301130
}
11311131

1132-
if (!empty($sede['cap'])) {
1132+
// CAP: per nazioni estere usare '00000', altrimenti il CAP reale
1133+
if (!empty($sede['id_nazione'])) {
1134+
$rs_nazione = Nazione::find($sede['id_nazione']);
1135+
$result['IndirizzoResa']['CAP'] = ($rs_nazione['iso2'] == 'IT') ? $sede['cap'] : '00000';
1136+
} elseif (!empty($sede['cap'])) {
11331137
$result['IndirizzoResa']['CAP'] = $sede['cap'];
11341138
}
11351139

11361140
if (!empty($sede['citta'])) {
11371141
$result['IndirizzoResa']['Comune'] = $sede['citta'];
11381142
}
11391143

1140-
if (!empty($sede['provincia'])) {
1141-
$result['IndirizzoResa']['Provincia'] = $sede['provincia'];
1144+
// Provincia impostata SOLO SE nazione ITALIA
1145+
if (!empty($sede['provincia']) && !empty($sede['id_nazione'])) {
1146+
$rs_nazione = Nazione::find($sede['id_nazione']);
1147+
if ($rs_nazione['iso2'] == 'IT') {
1148+
$result['IndirizzoResa']['Provincia'] = strtoupper((string) $sede['provincia']);
1149+
}
11421150
}
11431151

11441152
if (!empty($sede['id_nazione'])) {

0 commit comments

Comments
 (0)