Add comment to show directoves to solve conception error on lot

management (add a table to store all lots and their properties: date,
note, ...)
Removed deprecated field pmp at stock level (pmp is at product level)
This commit is contained in:
Laurent Destailleur 2016-04-09 10:01:22 +02:00
parent 3827a06796
commit 7b16482cee
10 changed files with 64 additions and 17 deletions

View File

@ -36,6 +36,21 @@ ALTER TABLE llx_product_customer_price_log ADD COLUMN localtax1_type varchar(10)
ALTER TABLE llx_product_customer_price_log ADD COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0' after localtax2_tx;
CREATE TABLE llx_product_lot (
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
batch varchar(30) NOT NULL,
eatby datetime DEFAULT NULL,
sellby datetime DEFAULT NULL,
note_public text,
note_private text,
qty double NOT NULL DEFAULT 0,
import_key varchar(14) DEFAULT NULL
) ENGINE=InnoDB;
ALTER TABLE llx_product ADD COLUMN note_public text;
ALTER TABLE llx_user ADD COLUMN note_public text;
ALTER TABLE llx_c_type_contact ADD COLUMN position integer NOT NULL DEFAULT 0;
@ -362,3 +377,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_RECEIVE','Supplier order request received','Executed when a supplier order is received','order_supplier',12);
ALTER TABLE llx_product_fournisseur_price ADD supplier_reputation varchar(10) NULL;
-- Delete old deprecated field
ALTER TABLE llx_product_stock DROP COLUMN pmp;

View File

@ -35,6 +35,7 @@ create table llx_product
label varchar(255) NOT NULL,
description text,
note_public text,
note text,
customcode varchar(32), -- Optionnal custom code
fk_country integer DEFAULT NULL, -- Optionnal id of original country

View File

@ -1,5 +1,6 @@
-- ============================================================================
-- Copyright (C) 2014 Cédric GROSS <c.gross@kreiz-it.fr>
-- Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
@ -14,13 +15,14 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- This table is dedicated to store detail (lots/serial) of a stock
-- ============================================================================
CREATE TABLE llx_product_batch (
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_product_stock integer NOT NULL,
eatby datetime DEFAULT NULL,
sellby datetime DEFAULT NULL,
eatby datetime DEFAULT NULL, -- deprecated. should not be used here but should be stored into a table llx_product_lot
sellby datetime DEFAULT NULL, -- deprecated. should not be used here but should be stored into a table llx_product_lot
batch varchar(30) NOT NULL,
qty double NOT NULL DEFAULT 0,
import_key varchar(14) DEFAULT NULL

View File

@ -0,0 +1,30 @@
-- ============================================================================
-- Copyright (C) 2014 Cédric GROSS <c.gross@kreiz-it.fr>
-- Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- This table is dedicated to store lots with detail of each lot
-- ============================================================================
CREATE TABLE llx_product_lot (
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
batch varchar(30) NOT NULL,
eatby datetime DEFAULT NULL,
sellby datetime DEFAULT NULL,
note_public text,
note_private text,
qty double NOT NULL DEFAULT 0,
import_key varchar(14) DEFAULT NULL
) ENGINE=InnoDB;

View File

@ -1,7 +1,7 @@
-- ============================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2009-2016 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
@ -24,8 +24,7 @@ create table llx_product_stock
tms timestamp,
fk_product integer NOT NULL,
fk_entrepot integer NOT NULL,
reel real, -- physical stock
pmp double(24,8) default 0 NOT NULL, -- PMP value for product in this warehouse (deprecated. no sens for warehouse)
import_key varchar(14) -- Import key
reel real, -- physical stock
import_key varchar(14) -- Import key
)ENGINE=innodb;

View File

@ -61,6 +61,7 @@ create table llx_user
fk_socpeople integer,
fk_member integer,
fk_user integer, -- Hierarchic parent
note_public text,
note text DEFAULT NULL,
datelastlogin datetime,
datepreviouslogin datetime,

View File

@ -3338,7 +3338,7 @@ class Product extends CommonObject
$this->stock_reel = 0;
$this->stock_warehouse = array();
$sql = "SELECT ps.reel, ps.fk_entrepot, ps.pmp, ps.rowid";
$sql = "SELECT ps.rowid, ps.reel, ps.fk_entrepot";
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
$sql.= ", ".MAIN_DB_PREFIX."entrepot as w";
$sql.= " WHERE w.entity IN (".getEntity('stock', 1).")";
@ -3358,7 +3358,6 @@ class Product extends CommonObject
$row = $this->db->fetch_object($result);
$this->stock_warehouse[$row->fk_entrepot] = new stdClass();
$this->stock_warehouse[$row->fk_entrepot]->real = $row->reel;
$this->stock_warehouse[$row->fk_entrepot]->pmp = $row->pmp;
$this->stock_warehouse[$row->fk_entrepot]->id = $row->rowid;
if ($this->hasbatch()) $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db,$row->rowid,1);
$this->stock_reel+=$row->reel;

View File

@ -384,7 +384,7 @@ else
print_liste_field_titre($langs->trans("Product"),"", "p.ref","&amp;id=".$id,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),"", "p.label","&amp;id=".$id,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Units"),"", "ps.reel","&amp;id=".$id,"",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "ps.pmp","&amp;id=".$id,"",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "p.pmp","&amp;id=".$id,"",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EstimatedStockValueShort"),"", "","&amp;id=".$id,"",'align="right"',$sortfield,$sortorder);
if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellPriceMin"),"", "p.price","&amp;id=".$id,"",'align="right"',$sortfield,$sortorder);
if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("EstimatedStockValueSellShort"),"", "","&amp;id=".$id,"",'align="right"',$sortfield,$sortorder);
@ -396,7 +396,7 @@ else
$totalvalue=$totalvaluesell=0;
$sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,";
$sql.= " ps.pmp, ps.reel as value";
$sql.= " ps.reel as value";
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
$sql.= " WHERE ps.fk_product = p.rowid";
$sql.= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse)

View File

@ -304,15 +304,12 @@ class MouvementStock extends CommonObject
{
if ($num > 0)
{
//$sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET pmp = ".$newpmpwarehouse.", reel = reel + ".$qty;
$sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + ".$qty;
$sql.= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product;
}
else
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_stock";
//$sql.= " (pmp, reel, fk_entrepot, fk_product) VALUES ";
//$sql.= " (".$newpmpwarehouse.", ".$qty.", ".$entrepot_id.", ".$fk_product.")";
$sql.= " (reel, fk_entrepot, fk_product) VALUES ";
$sql.= " (".$qty.", ".$entrepot_id.", ".$fk_product.")";
}

View File

@ -229,7 +229,6 @@ if ($action == "transfert_stock" && ! $cancel)
// Define value of products moved
$pricesrc=0;
//if (isset($object->stock_warehouse[GETPOST("id_entrepot_source")]->pmp)) $pricesrc=$object->stock_warehouse[GETPOST("id_entrepot_source")]->pmp;
if (isset($object->pmp)) $pricesrc=$object->pmp;
$pricedest=$pricesrc;
@ -677,7 +676,7 @@ if ((! empty($conf->productbatch->enabled)) && $object->hasbatch())
print '</tr>';
}
$sql = "SELECT e.rowid, e.label, e.lieu, ps.reel, ps.pmp, ps.rowid as product_stock_id";
$sql = "SELECT e.rowid, e.label, e.lieu, ps.reel, ps.rowid as product_stock_id, 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";