From a4ced31e009fa7181c4a793a6b3943e1fcf56846 Mon Sep 17 00:00:00 2001 From: Dasc3er Date: Fri, 2 Apr 2021 15:01:11 +0200 Subject: [PATCH] Fix calcolo Fatturato per Statistiche Anagrafiche --- plugins/statistiche_anagrafiche/info.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/statistiche_anagrafiche/info.php b/plugins/statistiche_anagrafiche/info.php index 697e8cc52..00982bb41 100755 --- a/plugins/statistiche_anagrafiche/info.php +++ b/plugins/statistiche_anagrafiche/info.php @@ -83,10 +83,18 @@ $totale_ddt_uscita = $ddt_uscita->sum('totale_imponibile'); $fatture_vendita = Fattura::whereBetween('data', [$start, $end]) ->where('idanagrafica', $id_record) ->whereHas('tipo', function ($query) { - $query->where('co_tipidocumento.dir', '=', 'entrata'); + return $query->where('co_tipidocumento.dir', '=', 'entrata') + ->where('co_tipidocumento.reversed', '=', 0); }) ->get(); -$totale_fatture_vendita = $fatture_vendita->sum('totale_imponibile'); +$note_credito = Fattura::whereBetween('data', [$start, $end]) + ->where('idanagrafica', $id_record) + ->whereHas('tipo', function ($query) { + return $query->where('co_tipidocumento.dir', '=', 'entrata') + ->where('co_tipidocumento.reversed', '=', 1); + }) + ->get(); +$totale_fatture_vendita = $fatture_vendita->sum('totale_imponibile') - $note_credito->sum('totale_imponibile'); echo '