From 6dc29b3392bc664a50190d82a67b65a4bdbdd149 Mon Sep 17 00:00:00 2001 From: Matteo Date: Mon, 25 Jul 2022 11:28:54 +0200 Subject: [PATCH] Fix controllo totali fattura elettronica --- modules/fatture/actions.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/fatture/actions.php b/modules/fatture/actions.php index 15a799930..dd9d7a038 100755 --- a/modules/fatture/actions.php +++ b/modules/fatture/actions.php @@ -244,10 +244,20 @@ switch (post('op')) { } } catch (Exception $e) { } + + $calculated = 0; + + $fattura->scadenze()->each(function($scadenza) use (&$calculated) { + $calculated += abs($scadenza->da_pagare); + }); + + if(empty($calculated)){ + $calculated = $fattura->netto; + } echo json_encode([ 'stored' => round($totale_documento,2), - 'calculated' => round($fattura->totale,2), + 'calculated' => round($calculated,2), ]); break;