From 5f02432d90a7d813f2df75a211c48095872ed942 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 18 Dec 2011 20:59:05 +0100 Subject: [PATCH] Fix: add possibility to force date of stock movement --- htdocs/expedition/class/expedition.class.php | 2 +- .../stock/class/mouvementstock.class.php | 33 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index ccbdf9fb1b2..0a0080e8877 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -485,7 +485,7 @@ class Expedition extends CommonObject // If stock increment is done on sending (recommanded choice) if (! $error && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT) { - require_once DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"; + require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); $langs->load("agenda"); diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 8dd66a154c1..135d8efd85a 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -44,26 +44,28 @@ class MouvementStock } /** - * Add a movement of stock (in one direction only) - * @param user User object - * @param fk_product Id of product - * @param entrepot_id Id of warehouse - * @param qty Qty of movement (can be <0 or >0) - * @param type Direction of movement: - * 0=input (stock increase after stock transfert), 1=output (stock decrease after stock transfer), - * 2=output (stock decrease), 3=input (stock increase) - * @param price Unit price HT of product - * @param label Label of stock movement - * @return int <0 if KO, >0 if OK + * Add a movement of stock (in one direction only) + * + * @param User $user User object + * @param int $fk_product Id of product + * @param int $entrepot_id Id of warehouse + * @param int $qty Qty of movement (can be <0 or >0) + * @param int $type Direction of movement: + * 0=input (stock increase after stock transfert), 1=output (stock decrease after stock transfer), + * 2=output (stock decrease), 3=input (stock increase) + * @param int $price Unit price HT of product + * @param string $label Label of stock movement + * @param string $datem Force date of movement + * @return int <0 if KO, >0 if OK */ - function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='') + function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='', $datem='') { global $conf, $langs; $error = 0; dol_syslog("MouvementStock::_create start userid=$user->id, fk_product=$fk_product, warehouse=$entrepot_id, qty=$qty, type=$type, price=$price label=$label"); - $now=dol_now(); + $now=(! empty($datem) ? $datem : dol_now()); $this->db->begin(); @@ -305,11 +307,12 @@ class MouvementStock * @param int $qty Quantity * @param int $price Price * @param string $label Label of stock movement + * @param string $datem Force date of movement * @return int <0 if KO, >0 if OK */ - function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='') + function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='', $datem='') { - return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label); + return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, $datem); }