From b472a244db5ebacdc6b448bd4053c57b4e428dc8 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Mon, 25 Apr 2016 18:33:39 +0200 Subject: [PATCH 1/4] NEW decrease stock on expedition closing/classifying --- htdocs/admin/stock.php | 25 +++++- htdocs/commande/list.php | 2 +- htdocs/core/class/conf.class.php | 1 + htdocs/expedition/class/expedition.class.php | 81 ++++++++++++++++++++ htdocs/product/class/product.class.php | 2 +- htdocs/product/stock/product.php | 2 +- htdocs/product/stock/replenish.php | 4 +- 7 files changed, 112 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 98ff43360a8..6d40faecf4b 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -52,14 +52,17 @@ if($action) // Mode of stock decrease if ($action == 'STOCK_CALCULATE_ON_BILL' || $action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER' - || $action == 'STOCK_CALCULATE_ON_SHIPMENT') + || $action == 'STOCK_CALCULATE_ON_SHIPMENT' + || $action == 'STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED') { $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", '','chaine',0,'',$conf->entity); $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", '','chaine',0,'',$conf->entity); $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", '','chaine',0,'',$conf->entity); + $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED", '','chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", GETPOST('STOCK_CALCULATE_ON_BILL','alpha'),'chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_SHIPMENT') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", GETPOST('STOCK_CALCULATE_ON_SHIPMENT','alpha'),'chaine',0,'',$conf->entity); + if ($action == 'STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED", GETPOST('STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED','alpha'),'chaine',0,'',$conf->entity); } // Mode of stock increase if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL' @@ -203,6 +206,26 @@ else print "\n\n"; $found++; +$var=!$var; +print ""; +print ''.$langs->trans("DeStockOnShipmentClassifyBilled").''; +print ''; +if (! empty($conf->expedition->enabled)) +{ + print "
"; + print ''; + print ""; + print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED",$conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED,1,$disabled); + print ''; + print "
\n"; +} +else +{ + print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name")); +} +print "\n\n"; +$found++; + /*if (! $found) { $var=!$var; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index d26c5dea5dd..8894b40b9e3 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -471,7 +471,7 @@ if ($resql) // stock order and stock order_supplier $stock_order=0; $stock_order_supplier=0; - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) // What about other options ? + if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED)) // What about other options ? { if (! empty($conf->commande->enabled)) { diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 0bd28092bff..4e5a64722e4 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -379,6 +379,7 @@ class Conf $this->global->STOCK_CALCULATE_ON_BILL=0; $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER=0; $this->global->STOCK_CALCULATE_ON_SHIPMENT=1; + $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED=0; $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL=0; $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER=0; $this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER=1; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 373cb5f2666..9fd9448a955 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1779,6 +1779,87 @@ class Expedition extends CommonObject //TODO: Option to set order billed if 100% of order is shipped $this->statut=2; $this->billed=1; + + + // If stock increment is done on sending (recommanded choice) + if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED)) + { + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; + + $langs->load("agenda"); + + // Loop on each product line to add a stock movement + // TODO possibilite d'expedier a partir d'une propale ou autre origine + $sql = "SELECT cd.fk_product, cd.subprice,"; + $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; + $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; + $sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; + $sql.= " WHERE ed.fk_expedition = ".$this->id; + $sql.= " AND cd.rowid = ed.fk_origin_line"; + + dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $cpt = $this->db->num_rows($resql); + for ($i = 0; $i < $cpt; $i++) + { + $obj = $this->db->fetch_object($resql); + if (empty($obj->edbrowid)) + { + $qty = $obj->qty; + } + else + { + $qty = $obj->edbqty; + } + if ($qty <= 0) continue; + dol_syslog(get_class($this)."::valid movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid); + + //var_dump($this->lines[$i]); + $mouvS = new MouvementStock($this->db); + $mouvS->origin = &$this; + + if (empty($obj->edbrowid)) + { + // line without batch detail + + // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref)); + if ($result < 0) { + $error++; break; + } + } + else + { + // line with batch detail + + // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch); + if ($result < 0) { + $error++; break; + } + + // We update content of table llx_product_batch (will be rename into llx_product_stock_batch inantoher version) + // We can set livraison_batch to deprecated and adapt livraison to handle batch too (mouvS->_create also calls mouvS->_create_batch) + if (! empty($conf->productbatch->enabled)) + { + $result=$mouvS->livraison_batch($obj->fk_origin_stock, $qty); // ->fk_origin_stock = id into table llx_product_batch (will be rename into llx_product_stock_batch in another version) + if ($result < 0) { $error++; $this->errors[]=$mouvS->error; break; } + } + } + } + } + else + { + $this->db->rollback(); + $this->error=$this->db->error(); + return -2; + } + } + return 1; } else diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1939299cf63..0b86747b614 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3401,7 +3401,7 @@ class Product extends CommonObject } // Stock decrease mode - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { + if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED)) { $this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client; } if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 42fadf54923..eb5e8cdb3e3 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -483,7 +483,7 @@ if ($id > 0 || $ref) // Real stock $object->load_stock(); $text_stock_options = ''; - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)?$langs->trans("DeStockOnShipment").'
':''); + $text_stock_options.= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED)?$langs->trans("DeStockOnShipment").'
':''); $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'
':''); $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_BILL)?$langs->trans("DeStockOnBill").'
':''); $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)?$langs->trans("ReStockOnBill").'
':''); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 8773d10ad4d..af840e5119e 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -228,7 +228,9 @@ if ($action == 'order' && isset($_POST['valid'])) $form = new Form($db); $virtualdiffersfromphysical=0; -if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) +if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) + || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED) + || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. } From bf1f805bf6a268ab7fa571a6565cfaed39211e04 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Mon, 25 Apr 2016 18:40:38 +0200 Subject: [PATCH 2/4] FIX trad --- htdocs/langs/en_US/stocks.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index e6b9f82730c..16d46f0af98 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -59,6 +59,7 @@ RuleForStockManagementIncrease=Rule for automatic stock management increase (man DeStockOnBill=Decrease real stocks on customers invoices/credit notes validation DeStockOnValidateOrder=Decrease real stocks on customers orders validation DeStockOnShipment=Decrease real stocks on shipping validation +DeStockOnShipmentClassifyBilled=Decrease real stocks on shipping classification billed ReStockOnBill=Increase real stocks on suppliers invoices/credit notes validation ReStockOnValidateOrder=Increase real stocks on suppliers orders approbation ReStockOnDispatchOrder=Increase real stocks on manual dispatching into warehouses, after supplier order receiving From 91bea8b9fea47e61db78791074e63487730ce2bb Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Mon, 25 Apr 2016 18:54:28 +0200 Subject: [PATCH 3/4] fix inclusion --- htdocs/expedition/class/expedition.class.php | 89 +++++++++++++++++++- htdocs/langs/en_US/other.lang | 2 + 2 files changed, 87 insertions(+), 4 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 68091044951..9468475c32c 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1801,7 +1801,7 @@ class Expedition extends CommonObject */ function set_billed() { - global $conf; + global $conf,$langs,$user; $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; @@ -1851,7 +1851,6 @@ class Expedition extends CommonObject if ($qty <= 0) continue; dol_syslog(get_class($this)."::valid movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid); - //var_dump($this->lines[$i]); $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; @@ -1860,7 +1859,7 @@ class Expedition extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref)); + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyBilledInDolibarr",$numref)); if ($result < 0) { $error++; break; } @@ -1909,7 +1908,7 @@ class Expedition extends CommonObject */ function reOpen() { - global $conf; + global $conf,$langs,$user; $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; @@ -1919,6 +1918,88 @@ class Expedition extends CommonObject { $this->statut=1; $this->billed=0; + + + // If stock increment is done on sending (recommanded choice) + if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED)) + { + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; + + $langs->load("agenda"); + + // Loop on each product line to add a stock movement + // TODO possibilite d'expedier a partir d'une propale ou autre origine + $sql = "SELECT cd.fk_product, cd.subprice,"; + $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; + $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; + $sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; + $sql.= " WHERE ed.fk_expedition = ".$this->id; + $sql.= " AND cd.rowid = ed.fk_origin_line"; + + dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $cpt = $this->db->num_rows($resql); + for ($i = 0; $i < $cpt; $i++) + { + $obj = $this->db->fetch_object($resql); + if (empty($obj->edbrowid)) + { + $qty = $obj->qty; + } + else + { + $qty = $obj->edbqty; + } + if ($qty <= 0) continue; + dol_syslog(get_class($this)."::reopen expedition movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid); + + //var_dump($this->lines[$i]); + $mouvS = new MouvementStock($this->db); + $mouvS->origin = &$this; + + if (empty($obj->edbrowid)) + { + // line without batch detail + + // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyBilledInDolibarr",$numref)); + if ($result < 0) { + $error++; break; + } + } + else + { + // line with batch detail + + // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch); + if ($result < 0) { + $error++; break; + } + + // We update content of table llx_product_batch (will be rename into llx_product_stock_batch inantoher version) + // We can set livraison_batch to deprecated and adapt livraison to handle batch too (mouvS->_create also calls mouvS->_create_batch) + if (! empty($conf->productbatch->enabled)) + { + $result=$mouvS->livraison_batch($obj->fk_origin_stock, -$qty); // ->fk_origin_stock = id into table llx_product_batch (will be rename into llx_product_stock_batch in another version) + if ($result < 0) { $error++; $this->errors[]=$mouvS->error; break; } + } + } + } + } + else + { + $this->db->rollback(); + $this->error=$this->db->error(); + return -2; + } + } + + return 1; } else diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 3000eecf33b..489a0b82fdd 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -228,6 +228,8 @@ MemberResiliatedInDolibarr=Member %s resiliated MemberDeletedInDolibarr=Member %s deleted MemberSubscriptionAddedInDolibarr=Subscription for member %s added ShipmentValidatedInDolibarr=Shipment %s validated +ShipmentClassifyBilledInDolibarr=Shipment %s classify billed +ShipmentUnClassifyBilledInDolibarr=Shipment %s classify reopened ShipmentDeletedInDolibarr=Shipment %s deleted ##### Export ##### Export=Export From 8d0e5479a0f61cb87812151348f825debffc52a0 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Sat, 14 May 2016 19:22:27 +0200 Subject: [PATCH 4/4] Rename var --- htdocs/admin/stock.php | 12 ++++++------ htdocs/commande/list.php | 2 +- htdocs/core/class/conf.class.php | 2 +- htdocs/expedition/class/expedition.class.php | 12 ++++++------ htdocs/langs/en_US/other.lang | 4 ++-- htdocs/langs/en_US/stocks.lang | 2 +- htdocs/product/class/product.class.php | 2 +- htdocs/product/stock/product.php | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 6d40faecf4b..4e9957fe48d 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -53,16 +53,16 @@ if($action) if ($action == 'STOCK_CALCULATE_ON_BILL' || $action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER' || $action == 'STOCK_CALCULATE_ON_SHIPMENT' - || $action == 'STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED') + || $action == 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') { $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", '','chaine',0,'',$conf->entity); $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", '','chaine',0,'',$conf->entity); $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", '','chaine',0,'',$conf->entity); - $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED", '','chaine',0,'',$conf->entity); + $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT_CLOSE", '','chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_BILL", GETPOST('STOCK_CALCULATE_ON_BILL','alpha'),'chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity); if ($action == 'STOCK_CALCULATE_ON_SHIPMENT') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT", GETPOST('STOCK_CALCULATE_ON_SHIPMENT','alpha'),'chaine',0,'',$conf->entity); - if ($action == 'STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED", GETPOST('STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED','alpha'),'chaine',0,'',$conf->entity); + if ($action == 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SHIPMENT_CLOSE", GETPOST('STOCK_CALCULATE_ON_SHIPMENT_CLOSE','alpha'),'chaine',0,'',$conf->entity); } // Mode of stock increase if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL' @@ -208,14 +208,14 @@ $found++; $var=!$var; print ""; -print ''.$langs->trans("DeStockOnShipmentClassifyBilled").''; +print ''.$langs->trans("DeStockOnShipmentOnClosing").''; print ''; if (! empty($conf->expedition->enabled)) { print "
"; print ''; - print ""; - print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED",$conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED,1,$disabled); + print ""; + print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT_CLOSE",$conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE,1,$disabled); print ''; print "
\n"; } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 769e2ba5054..cb39e41869d 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -740,7 +740,7 @@ if ($resql) // stock order and stock order_supplier $stock_order=0; $stock_order_supplier=0; - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED)) // What about other options ? + if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) // What about other options ? { if (! empty($conf->commande->enabled)) { diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 5cfb7ffb00e..c2fa67a7493 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -403,7 +403,7 @@ class Conf $this->global->STOCK_CALCULATE_ON_BILL=0; $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER=0; $this->global->STOCK_CALCULATE_ON_SHIPMENT=1; - $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED=0; + $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE=0; $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL=0; $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER=0; $this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER=1; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 21e0adf518b..201e2edaa08 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1856,7 +1856,7 @@ class Expedition extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyBilledInDolibarr",$numref)); + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr",$numref)); if ($result < 0) { $error++; break; } @@ -1866,7 +1866,7 @@ class Expedition extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch); + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch); if ($result < 0) { $error++; break; } @@ -1943,8 +1943,8 @@ class Expedition extends CommonObject $this->billed=0; - // If stock increment is done on sending (recommanded choice) - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED)) + // If stock increment is done on closing + if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -1989,7 +1989,7 @@ class Expedition extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyBilledInDolibarr",$numref)); + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr",$numref)); if ($result < 0) { $error++; break; } @@ -1999,7 +1999,7 @@ class Expedition extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch); + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch); if ($result < 0) { $error++; break; } diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index c8e417f9d0c..0d57f7bf11b 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -229,8 +229,8 @@ MemberResiliatedInDolibarr=Member %s resiliated MemberDeletedInDolibarr=Member %s deleted MemberSubscriptionAddedInDolibarr=Subscription for member %s added ShipmentValidatedInDolibarr=Shipment %s validated -ShipmentClassifyBilledInDolibarr=Shipment %s classify billed -ShipmentUnClassifyBilledInDolibarr=Shipment %s classify reopened +ShipmentClassifyClosedInDolibarr=Shipment %s classify billed +ShipmentUnClassifyCloseddInDolibarr=Shipment %s classify reopened ShipmentDeletedInDolibarr=Shipment %s deleted ##### Export ##### Export=Export diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 5d35d32d32a..6b1a28eae17 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -59,7 +59,7 @@ RuleForStockManagementIncrease=Rule for automatic stock management increase (man DeStockOnBill=Decrease real stocks on customers invoices/credit notes validation DeStockOnValidateOrder=Decrease real stocks on customers orders validation DeStockOnShipment=Decrease real stocks on shipping validation -DeStockOnShipmentClassifyBilled=Decrease real stocks on shipping classification billed +DeStockOnShipmentOnClosing=Decrease real stocks on shipping classification closed ReStockOnBill=Increase real stocks on suppliers invoices/credit notes validation ReStockOnValidateOrder=Increase real stocks on suppliers orders approbation ReStockOnDispatchOrder=Increase real stocks on manual dispatching into warehouses, after supplier order receiving diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 7006f7c459a..ed3acf69931 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3416,7 +3416,7 @@ class Product extends CommonObject } // Stock decrease mode - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED)) { + if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { $this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client; } if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index f84180240b8..c4201896dc6 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -482,7 +482,7 @@ if ($id > 0 || $ref) // Real stock $text_stock_options = ''; - $text_stock_options.= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLASSIFY_BILLED)?$langs->trans("DeStockOnShipment").'
':''); + $text_stock_options.= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)?$langs->trans("DeStockOnShipment").'
':''); $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'
':''); $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_BILL)?$langs->trans("DeStockOnBill").'
':''); $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)?$langs->trans("ReStockOnBill").'
':'');