From 2721ccd23c6886ae1ceef2c55a43aab2b30ede05 Mon Sep 17 00:00:00 2001 From: priojk Date: Wed, 29 Mar 2023 11:43:31 +0200 Subject: [PATCH] add hook to modify amount to pay --- htdocs/compta/facture/prelevement.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 319b93c4dcb..17b45162974 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -676,6 +676,16 @@ if ($object->id > 0) { $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); + // Hook to change amount for other reasons, e.g. apply cash discount for payment before agreed date + $parameters = array('remaintopay' => $resteapayer); + $reshook = $hookmanager->executeHooks('finalizeAmountOfSupplierInvoice', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + print $hookmanager->resPrint; + if (!empty($remaintopay = $hookmanager->resArray['remaintopay'])) { + $resteapayer = $remaintopay; + } + } + // TODO Replace this by an include with same code to show already done payment visible in invoice card print ''.$langs->trans('RemainderToPay').''.price($resteapayer, 1, '', 1, - 1, - 1, $conf->currency).'';