From 46b39dd6a97bd802cb97059f4e43060efaa51cf9 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 16 Mar 2019 18:13:43 +0100 Subject: [PATCH] Fix #9961 : deal with supplier credit note refund like with customers --- htdocs/fourn/facture/paiement.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 8a87d4903a1..57ca70dfa98 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -71,7 +71,7 @@ if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="p.rowid"; $optioncss = GETPOST('optioncss','alpha'); -$amounts = array();array(); +$amounts = array(); $amountsresttopay=array(); $addwarning=0; @@ -251,6 +251,22 @@ if (empty($reshook)) $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + // Clean parameters amount if payment is for a credit note + if (GETPOST('type') == FactureFournisseur::TYPE_CREDIT_NOTE) + { + foreach ($amounts as $key => $value) // How payment is dispatch + { + $newvalue = price2num($value,'MT'); + $amounts[$key] = -$newvalue; + } + + foreach ($multicurrency_amounts as $key => $value) // How payment is dispatch + { + $newvalue = price2num($value,'MT'); + $multicurrency_amounts[$key] = -$newvalue; + } + } + if (! $error) { $db->begin(); @@ -431,6 +447,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; print ''; + print ''; print ''; dol_fiche_head(null); @@ -600,14 +617,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; } - print ''.price($objp->total_ttc).''; + print ''.price($sign * $objp->total_ttc).''; - print ''.price($objp->am); + print ''.price($sign * $objp->am); if ($creditnotes) print '+'.price($creditnotes); if ($deposits) print '+'.price($deposits); print ''; - print ''.price($remaintopay).''; + print ''.price($sign * $remaintopay).''; // Amount print '';