Aggiunta fallback selezione iva su natura

This commit is contained in:
loviuz 2021-01-04 19:22:11 +01:00
parent 136730a696
commit b5e99dcfe3
1 changed files with 6 additions and 0 deletions

View File

@ -300,9 +300,15 @@ if (!empty($righe)) {
foreach ($righe as $key => $riga) {
$query = "SELECT id, IF(codice IS NULL, descrizione, CONCAT(codice, ' - ', descrizione)) AS descrizione FROM co_iva WHERE deleted_at IS NULL AND percentuale = ".prepare($riga['AliquotaIVA']);
$start_query = $query;
if (!empty($riga['Natura'])) {
$query .= ' AND codice_natura_fe = '.prepare($riga['Natura']);
// Fallback per natura iva mancante
if( empty($dbo->fetchArray($query)) ){
$query = $start_query;
}
}
$query .= ' ORDER BY descrizione ASC';