From 5217ae28f8159ace983f4ddfdf2f2cb0b7f4ef9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Feb 2023 21:35:48 +0100 Subject: [PATCH] Fix load of margin infos --- htdocs/compta/facture/list.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 40b672cbd9e..1fea36daf54 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1199,6 +1199,18 @@ if ($resql) { $i = 0; $totalarray = array(); + + $with_margin_info = false; + if (!empty($conf->margin->enabled) && ( + !empty($arrayfields['total_pa']['checked']) + || !empty($arrayfields['total_margin']['checked']) + || !empty($arrayfields['total_margin_rate']['checked']) + || !empty($arrayfields['total_mark_rate']['checked']) + ) + ) { + $with_margin_info = true; + } + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -1281,7 +1293,7 @@ if ($resql) $facturestatic->alreadypaid = $paiement; $marginInfo = array(); - if (!empty($conf->margin->enabled)) { + if ($with_margin_info === true) { $facturestatic->fetch_lines(); $marginInfo = $formmargin->getMarginInfosArray($facturestatic); }