mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-03-30 11:00:23 +02:00
Fix arrotondamenti in importazione fattura elettronica
This commit is contained in:
parent
55bb478c1c
commit
85665a9e97
@ -87,12 +87,15 @@ class FatturaOrdinaria extends FatturaElettronica
|
|||||||
{
|
{
|
||||||
$result = $this->getBody()['DatiBeniServizi']['DettaglioLinee'];
|
$result = $this->getBody()['DatiBeniServizi']['DettaglioLinee'];
|
||||||
$result = $this->forceArray($result);
|
$result = $this->forceArray($result);
|
||||||
|
foreach ($result as $res){
|
||||||
|
$totale_imposta += $res['PrezzoTotale']*$res['AliquotaIVA']/100;
|
||||||
|
}
|
||||||
// Aggiunta degli arrotondamenti IVA come righe indipendenti
|
// Aggiunta degli arrotondamenti IVA come righe indipendenti
|
||||||
$riepiloghi = $this->getBody()['DatiBeniServizi']['DatiRiepilogo'];
|
$riepiloghi = $this->getBody()['DatiBeniServizi']['DatiRiepilogo'];
|
||||||
$riepiloghi = $this->forceArray($riepiloghi);
|
$riepiloghi = $this->forceArray($riepiloghi);
|
||||||
|
|
||||||
foreach ($riepiloghi as $riepilogo) {
|
foreach ($riepiloghi as $riepilogo) {
|
||||||
$valore = isset($riepilogo['Arrotondamento']) ? floatval($riepilogo['Arrotondamento']) : 0;
|
$valore = (isset($riepilogo['Arrotondamento']) && (string)round($totale_imposta, 2) != $riepilogo['Imposta']) ? $riepilogo['Arrotondamento'] : 0;
|
||||||
if (!empty($valore)) {
|
if (!empty($valore)) {
|
||||||
$descrizione = tr('Arrotondamento IVA _VALUE_', [
|
$descrizione = tr('Arrotondamento IVA _VALUE_', [
|
||||||
'_VALUE_' => empty($riepilogo['Natura']) ? numberFormat($riepilogo['AliquotaIVA']).'%' : $riepilogo['Natura'],
|
'_VALUE_' => empty($riepilogo['Natura']) ? numberFormat($riepilogo['AliquotaIVA']).'%' : $riepilogo['Natura'],
|
||||||
@ -222,10 +225,9 @@ class FatturaOrdinaria extends FatturaElettronica
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Totale documento
|
// Totale documento
|
||||||
$totale_righe = 0;
|
|
||||||
$dati_riepilogo = $this->getBody()['DatiBeniServizi']['DatiRiepilogo'];
|
$dati_riepilogo = $this->getBody()['DatiBeniServizi']['DatiRiepilogo'];
|
||||||
if (!empty($dati_riepilogo['ImponibileImporto'])) {
|
if (!empty($dati_riepilogo['ImponibileImporto'])) {
|
||||||
$totale_righe = $dati_riepilogo['ImponibileImporto'];
|
$totale_righe += $riga['PrezzoTotale'];
|
||||||
} elseif (is_array($dati_riepilogo)) {
|
} elseif (is_array($dati_riepilogo)) {
|
||||||
foreach ($dati_riepilogo as $dato) {
|
foreach ($dati_riepilogo as $dato) {
|
||||||
$totale_righe += $dato['ImponibileImporto'];
|
$totale_righe += $dato['ImponibileImporto'];
|
||||||
@ -356,7 +358,10 @@ class FatturaOrdinaria extends FatturaElettronica
|
|||||||
|
|
||||||
// Arrotondamenti differenti nella fattura XML
|
// Arrotondamenti differenti nella fattura XML
|
||||||
$diff = round(abs($totale_righe) - abs($fattura->totale_imponibile + $fattura->rivalsa_inps), 2);
|
$diff = round(abs($totale_righe) - abs($fattura->totale_imponibile + $fattura->rivalsa_inps), 2);
|
||||||
if (!empty($diff)) {
|
if (!empty($diff) && $diff != abs($dati_riepilogo['Arrotondamento']) || (empty($dati_riepilogo['Arrotondamento']) && abs($dati_riepilogo['ImponibileImporto']) != abs($totale_righe))) {
|
||||||
|
if (empty($dati_riepilogo['Arrotondamento'])){
|
||||||
|
$diff = abs($dati_riepilogo['ImponibileImporto']) - abs($totale_righe);
|
||||||
|
}
|
||||||
// Rimozione dell'IVA calcolata automaticamente dal gestionale
|
// Rimozione dell'IVA calcolata automaticamente dal gestionale
|
||||||
$iva_arrotondamento = database()->fetchOne('SELECT * FROM co_iva WHERE percentuale=0 AND deleted_at IS NULL');
|
$iva_arrotondamento = database()->fetchOne('SELECT * FROM co_iva WHERE percentuale=0 AND deleted_at IS NULL');
|
||||||
$diff = $diff * 100 / (100 + $iva_arrotondamento['percentuale']);
|
$diff = $diff * 100 / (100 + $iva_arrotondamento['percentuale']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user