From 9f5ef68123ad6336f99a36a7c791afaa7f4547e3 Mon Sep 17 00:00:00 2001 From: thomas-Ngr Date: Thu, 5 Sep 2024 16:01:31 +0200 Subject: [PATCH] fix replenish with multicurrency (#30832) * fix replenish * Use multicurrency supplier price instead of recomputing from EUR supplier price --- htdocs/product/stock/replenish.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index e3f27476488..a1a99523d91 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -194,6 +194,13 @@ if ($action == 'order' && GETPOST('valid')) { // TODO Get desc in language of thirdparty } + // If we use multicurrency + if (isModEnabled('multicurrency') && !empty($productsupplier->fourn_multicurrency_code) && $productsupplier->fourn_multicurrency_code != $conf->currency) { + $line->multicurrency_code = $productsupplier->fourn_multicurrency_code; + $line->fk_multicurrency = $productsupplier->fourn_multicurrency_id; + $line->multicurrency_subprice = $productsupplier->fourn_multicurrency_unitprice; + } + $line->tva_tx = $productsupplier->vatrate_supplier; $line->subprice = $productsupplier->fourn_pu; $line->total_ht = $productsupplier->fourn_pu * $qty; @@ -262,7 +269,8 @@ if ($action == 'order' && GETPOST('valid')) { null, null, 0, - $line->fk_unit + $line->fk_unit, + $line->multicurrency_subprice ?? 0 ); } if ($result < 0) { @@ -277,6 +285,7 @@ if ($action == 'order' && GETPOST('valid')) { } else { $order->socid = $suppliersid[$i]; $order->fetch_thirdparty(); + $order->multicurrency_code = $order->thirdparty->multicurrency_code; // Trick to know which orders have been generated using the replenishment feature $order->source = $order::SOURCE_ID_REPLENISHMENT;