Skip to content

Commit 75fcd45

Browse files
committed
fix: controlli su gestionale
1 parent c15ba01 commit 75fcd45

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

modules/aggiornamenti/src/Controlli/DatiFattureElettroniche.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ protected function checkTotaliData(Fattura $fattura_vendita, $xml)
487487
}
488488

489489
foreach ($riepiloghi as $riepilogo) {
490-
$totale_documento_xml = sum([$totale_documento_xml, $riepilogo['ImponibileImporto'], $riepilogo['Imposta']]);
490+
$totale_documento_xml = sum([$totale_documento_xml, abs(floatval($riepilogo['ImponibileImporto'])), abs(floatval($riepilogo['Imposta']))]);
491491
}
492492

493493
$totale_documento_xml = abs($totale_documento_xml);
@@ -533,8 +533,8 @@ protected function checkTotaliData(Fattura $fattura_vendita, $xml)
533533
$totale_imposta_xml = 0;
534534

535535
foreach ($riepiloghi_xml as $riepilogo_xml) {
536-
$totale_imponibile_xml += floatval($riepilogo_xml['ImponibileImporto']);
537-
$totale_imposta_xml += floatval($riepilogo_xml['Imposta']);
536+
$totale_imponibile_xml += abs(floatval($riepilogo_xml['ImponibileImporto']));
537+
$totale_imposta_xml += abs(floatval($riepilogo_xml['Imposta']));
538538
}
539539

540540
// Controllo totale imponibile complessivo
@@ -577,18 +577,18 @@ protected function checkTotaliData(Fattura $fattura_vendita, $xml)
577577
$sconti_xml = [$sconti_xml];
578578
}
579579

580-
$sconto_totale_gestionale = $fattura_vendita->sconto;
580+
$sconto_totale_gestionale = abs($fattura_vendita->sconto);
581581
$sconto_totale_xml = 0;
582582

583583
foreach ($sconti_xml as $sconto_xml) {
584584
if ($sconto_xml['Tipo'] === 'SC') { // Sconto
585-
$sconto_totale_xml += floatval($sconto_xml['Importo'] ?? 0);
585+
$sconto_totale_xml += abs(floatval($sconto_xml['Importo'] ?? 0));
586586
} elseif ($sconto_xml['Tipo'] === 'MG') { // Maggiorazione
587-
$sconto_totale_xml -= floatval($sconto_xml['Importo'] ?? 0);
587+
$sconto_totale_xml -= abs(floatval($sconto_xml['Importo'] ?? 0));
588588
}
589589
}
590590

591-
if (numberFormat($sconto_totale_xml, 2) !== numberFormat($sconto_totale_gestionale, 2)) {
591+
if (numberFormat(abs($sconto_totale_xml), 2) !== numberFormat($sconto_totale_gestionale, 2)) {
592592
$errors[] = [
593593
'type' => self::ERROR_WARNING,
594594
'category' => self::CATEGORY_TOTALI,

0 commit comments

Comments
 (0)