diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 2ae43f39766..855fced7310 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -61,6 +61,8 @@ ShipmentCreationIsDoneFromOrder=For the moment, creation of a new shipment is do RelatedShippings=Related shippings ShipmentLine=Shipment line CarrierList=List of transporters +SendingRunning=Product from customer order already sent +SuppliersReceiptRunning=Product from supplier order alrady received # Sending methods SendingMethodCATCH=Catch by customer diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang index 47b359318e4..59c937c97b6 100644 --- a/htdocs/langs/fr_FR/sendings.lang +++ b/htdocs/langs/fr_FR/sendings.lang @@ -61,6 +61,8 @@ ShipmentCreationIsDoneFromOrder=Pour le moment, la création d'une nouvelle exp RelatedShippings=Expédition(s) associée(s) ShipmentLine=Ligne d'expédition CarrierList=Liste des transporteurs +SendingRunning=Produits de commandes clients déjà expédiés +SuppliersReceiptRunning=Produit de commandes fournisseurs déjà réceptionnés # Sending methods SendingMethodCATCH=Enlèvement par le client diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 226a3501652..98b5d155ba7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3032,42 +3032,56 @@ class Product extends CommonObject * * @return int < 0 if KO, > 0 if OK */ - function load_virtual_stock() - { - global $conf; + function load_virtual_stock() + { + global $conf; - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) - { - $stock_commande_client=$stock_commande_fournisseur=0; - $stock_sending_client=$stock_reception_fournisseur=0; + $stock_commande_client=0; + $stock_commande_fournisseur=0; + $stock_sending_client=0; + $stock_reception_fournisseur=0; - if (! empty($conf->commande->enabled)) - { - $result=$this->load_stats_commande(0,'1,2'); - if ($result < 0) dol_print_error($db,$this->error); - $stock_commande_client=$this->stats_commande['qty']; - } - if (! empty($conf->expedition->enabled)) - { - $result=$this->load_stats_sending(0,'1,2'); - if ($result < 0) dol_print_error($db,$this->error); - $stock_sending_client=$this->stats_expedition['qty']; - } - if (! empty($conf->fournisseur->enabled)) - { - $result=$this->load_stats_commande_fournisseur(0,'3'); - if ($result < 0) dol_print_error($db,$this->error); - $stock_commande_fournisseur=$this->stats_commande_fournisseur['qty']; + if (! empty($conf->commande->enabled)) { + $result=$this->load_stats_commande(0,'1,2'); + if ($result < 0) dol_print_error($db,$this->error); + $stock_commande_client=$this->stats_commande['qty']; + } + if (! empty($conf->expedition->enabled)) { + $result=$this->load_stats_sending(0,'1,2'); + if ($result < 0) dol_print_error($db,$this->error); + $stock_sending_client=$this->stats_expedition['qty']; + } + if (! empty($conf->fournisseur->enabled)) { + $result=$this->load_stats_commande_fournisseur(0,'3,4'); + if ($result < 0) dol_print_error($db,$this->error); + $stock_commande_fournisseur=$this->stats_commande_fournisseur['qty']; - $result=$this->load_stats_reception(0,'3'); - if ($result < 0) dol_print_error($db,$this->error); - $stock_reception_fournisseur=$this->stats_reception['qty']; - } + $result=$this->load_stats_reception(0,'4'); + if ($result < 0) dol_print_error($db,$this->error); + $stock_reception_fournisseur=$this->stats_reception['qty']; + } - $this->stock_theorique=$this->stock_reel-($stock_commande_client-$stock_sending_client)+($stock_commande_fournisseur-$stock_reception_fournisseur); - //echo $this->stock_theorique.' = '.$this->stock_reel.' - ('.$stock_commande_client.' - '.$stock_sending_client.') + ('.$stock_commande_fournisseur.' - '.$stock_reception_fournisseur.')'; - } - } + // Stock decrease mode + if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { + $this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client; + } + if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { + $this->stock_theorique=$this->stock_reel; + } + if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) { + $this->stock_theorique=$this->stock_reel-$stock_commande_client; + } + // Stock Increase mode + if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { + $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; + } + if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { + $this->stock_theorique-=$stock_reception_fournisseur; + } + if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { + $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; + } + } /** * Move an uploaded file described into $file array into target directory $sdir. diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 7885553095e..22dc080d6e2 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -39,6 +39,7 @@ $langs->load("products"); $langs->load("orders"); $langs->load("bills"); $langs->load("stocks"); +$langs->load("sendings"); if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); @@ -331,58 +332,62 @@ if ($id > 0 || $ref) print ''; print ''; - // Calculating a theorical value + // Calculating a theorical value + print '