diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 27df1302919d0613d5c8b144c87a9c0595a806b4..d4465a43ff56448f7f1b57136dae3a50a0709807 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -367,7 +367,7 @@ class Commande extends CommonOrder { $mouvP = new MouvementStock($this->db); // We increment stock of product (and sub-products) - $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderBackToDraftInDolibarr",$this->ref)); + $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr",$this->ref)); if ($result < 0) { $error++; } } } @@ -555,7 +555,7 @@ class Commande extends CommonOrder { $mouvP = new MouvementStock($this->db); // We increment stock of product (and sub-products) - $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderCanceledInDolibarr",$this->ref)); + $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderCanceledInDolibarr",$this->ref)); if ($result < 0) { $error++; } @@ -881,6 +881,7 @@ class Commande extends CommonOrder // Clear fields $this->user_author_id = $user->id; $this->user_valid = ''; + $this->date = dol_now(); $this->date_creation = ''; $this->date_validation = ''; $this->ref_client = ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 9086b3c7d1dbf94f1c5f0047463fc28b1bae85dc..9f78a9b7efc79ae8e0cef53b684277154483bab6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1812,7 +1812,7 @@ class Facture extends CommonInvoice { $mouvP = new MouvementStock($this->db); // We decrease stock for product - if ($this->type == 2) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); + if ($this->type == 2) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr",$num)); else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); if ($result < 0) { $error++; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index fa25c48366d85b33858dc27806a9a80d54b8c9a8..92fb1f0c8a0f9783c42f9b8b7f74cbe34378d685 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -847,7 +847,7 @@ class Expedition extends CommonObject $mouvS = new MouvementStock($this->db); // We decrement stock of product (and sub-products) // We use warehouse selected for each line - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentDeletedInDolibarr",$this->ref)); + $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ShipmentDeletedInDolibarr",$this->ref)); if ($result < 0) { $error++; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 87ad0bb8f707d3d602d5d017bc0de1f0818dcc11..9ef8f5412486eccb29d06c30cb7b0248fa4af977 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2672,7 +2672,7 @@ class Product extends CommonObject $sql = "SELECT ps.reel, ps.fk_entrepot, ps.pmp"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= ", ".MAIN_DB_PREFIX."entrepot as w"; - $sql.= " WHERE w.entity IN (".getEntity('warehouse', 1).")"; + $sql.= " WHERE w.entity IN (".getEntity('stock', 1).")"; $sql.= " AND w.rowid = ps.fk_entrepot"; $sql.= " AND ps.fk_product = ".$this->id; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 384b371267498672dee81ea28d6707d0280835f6..a21c57e2657455a213a31a096ab3a6736e9430ff 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -358,7 +358,7 @@ class Entrepot extends CommonObject $sql = "SELECT rowid, label"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot"; - $sql.= " WHERE entity IN (".getEntity('warehouse', 1).")"; + $sql.= " WHERE entity IN (".getEntity('stock', 1).")"; $sql.= " AND statut = ".$status; $result = $this->db->query($sql); @@ -418,7 +418,7 @@ class Entrepot extends CommonObject { $ret=array(); - $sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * ps.pmp) as value"; + $sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * p.pmp) as value"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE ps.fk_entrepot = ".$this->id; diff --git a/htdocs/product/stock/fiche.php b/htdocs/product/stock/fiche.php index a60deff921ed990128988b7007dc3c03963e7b8e..22b70fda2803e3a7aae984edbcf63fa14df1a74b 100644 --- a/htdocs/product/stock/fiche.php +++ b/htdocs/product/stock/fiche.php @@ -364,7 +364,7 @@ else print_liste_field_titre($langs->trans("Product"),"", "p.ref","&id=".$_GET['id'],"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),"", "p.label","&id=".$_GET['id'],"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Units"),"", "ps.reel","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "ps.pmp","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "p.pmp","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("EstimatedStockValueShort"),"", "","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellPriceMin"),"", "p.price","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("EstimatedStockValueSellShort"),"", "","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); @@ -426,10 +426,10 @@ else $totalunit+=$objp->value; // Price buy PMP - print '<td align="right">'.price(price2num($objp->pmp,'MU')).'</td>'; + print '<td align="right">'.price(price2num($objp->ppmp,'MU')).'</td>'; // Total PMP - print '<td align="right">'.price(price2num($objp->pmp*$objp->value,'MT')).'</td>'; - $totalvalue+=price2num($objp->pmp*$objp->value,'MT'); + print '<td align="right">'.price(price2num($objp->ppmp*$objp->value,'MT')).'</td>'; + $totalvalue+=price2num($objp->ppmp*$objp->value,'MT'); // Price sell min if (empty($conf->global->PRODUIT_MULTIPRICES)) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 6beeaa74c4c2dceab3ccffd8d149d0edd4b72c28..65dd9664c8b510632f29ef562e0f28bacb985f37 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -528,9 +528,10 @@ print '<td align="right">'.$langs->trans("SellPriceMin").'</td>'; print '<td align="right">'.$langs->trans("EstimatedStockValueSellShort").'</td>'; print '</tr>'; -$sql = "SELECT e.rowid, e.label, ps.reel, ps.pmp"; +$sql = "SELECT e.rowid, e.label, ps.reel, p.pmp"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " ".MAIN_DB_PREFIX."product_stock as ps"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; $sql.= " WHERE ps.reel != 0"; $sql.= " AND ps.fk_entrepot = e.rowid"; $sql.= " AND e.entity IN (".getEntity('stock',1).")"; diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index d920033b298fc4ea1380b47f50c4bc3d0b2ff07b..7707e729d502f836e85c69d480e9a19601115e04 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -53,7 +53,7 @@ $year = strftime("%Y",time()); // Affichage valorisation par entrepot $sql = "SELECT e.rowid as ref, e.label, e.statut, e.lieu,"; -$sql.= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; +$sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";