From 538921f47977c56cbf9aadbdb87bc60b705f6f5a Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Thu, 19 Dec 2019 10:35:38 +0100 Subject: [PATCH] #FIX Error Margin with Situation Invoice Fix an issue that show a negative margin when $line->situation_percent is not 100% Now, the margin price take progress into account. --- htdocs/core/class/html.formmargin.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index ea038fa8131..6b7ba7348ff 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -98,7 +98,11 @@ class FormMargin $pv = $line->total_ht; $pa_ht = ($pv < 0 ? - $line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign - $pa = $line->qty * $pa_ht; + if ($object->type == Facture::TYPE_SITUATION) { + $pa = $line->qty * $pa_ht * ($line->situation_percent / 100); + } else { + $pa = $line->qty * $pa_ht; + } // calcul des marges if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise