From ff33a1852f8ff9c8acd68c97f06f3f4c6fd33a8f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 6 Oct 2022 20:21:31 +0200 Subject: [PATCH] FIX Remove use of code we should not have --- htdocs/compta/facture/card.php | 4 +++- htdocs/fourn/facture/card.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 7348cca6fd4..d635d477a09 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3919,7 +3919,9 @@ if ($action == 'create') { $multicurrency_totaldeposits = $object->getSumDepositsUsed(1); $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT'); // Code to fix case of corrupted data - if ($resteapayer == 0 && $multicurrency_resteapayer != 0) { + // TODO We should not need this. Also data comes from a not reliable value of $object->multicurrency_total_ttc that may be wrong if it was + // calculated by summing lines that were in a currency for some of them and into another for others (lines from discount/down payment into another currency for example) + if ($resteapayer == 0 && $multicurrency_resteapayer != 0 && $object->multicurrency_code != $conf->currency) { $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); } } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b9837542582..a1fa9a0c0e6 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2616,7 +2616,9 @@ if ($action == 'create') { $multicurrency_totaldeposits = $object->getSumDepositsUsed(1); $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT'); // Code to fix case of corrupted data - if ($resteapayer == 0 && $multicurrency_resteapayer != 0) { + // TODO We should not need this. Also data comes from not reliable value of $object->multicurrency_total_ttc that may be wrong if it was + // calculated by summing lines that were in a currency for some of them and into another for others (lines from discount/down payment into another currency for example) + if ($resteapayer == 0 && $multicurrency_resteapayer != 0 && $object->multicurrency_code != $conf->currency) { $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); } }