diff --git a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql index f4a8631477166..60142101c29e1 100644 --- a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql +++ b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql @@ -179,3 +179,17 @@ ALTER TABLE llx_supplier_proposaldet ADD COLUMN extraparams varchar(255); ALTER TABLE llx_facture_rec ADD COLUMN rule_for_lines_dates varchar(255) DEFAULT 'prepaid'; +ALTER TABLE llx_product_customer_price ADD COLUMN date_begin date AFTER ref_customer; +ALTER TABLE llx_product_customer_price ADD COLUMN date_end date AFTER date_begin; +ALTER TABLE llx_product_customer_price ADD COLUMN discount_percent real DEFAULT 0 AFTER localtax2_type; +ALTER TABLE llx_product_customer_price_log ADD COLUMN date_begin date AFTER ref_customer; +ALTER TABLE llx_product_customer_price_log ADD COLUMN date_end date AFTER date_begin; +ALTER TABLE llx_product_customer_price_log ADD COLUMN discount_percent real DEFAULT 0 AFTER localtax2_type; +ALTER TABLE llx_product_customer_price DROP CONSTRAINT fk_product_customer_price_fk_product; +ALTER TABLE llx_product_customer_price DROP CONSTRAINT fk_product_customer_price_fk_soc; +ALTER TABLE llx_product_customer_price DROP INDEX uk_customer_price_fk_product_fk_soc; +ALTER TABLE llx_product_customer_price ADD UNIQUE INDEX uk_customer_price_fk_product_fk_soc (fk_product, fk_soc, date_begin); +ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_product_customer_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product(rowid); +ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_product_customer_price_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); +UPDATE llx_product_customer_price SET date_begin = datec WHERE date_begin IS NULL; +UPDATE llx_product_customer_price_log SET date_begin = datec WHERE date_begin IS NULL; diff --git a/htdocs/install/mysql/tables/llx_product_customer_price.key.sql b/htdocs/install/mysql/tables/llx_product_customer_price.key.sql index 2b827740b6051..afb4300856930 100644 --- a/htdocs/install/mysql/tables/llx_product_customer_price.key.sql +++ b/htdocs/install/mysql/tables/llx_product_customer_price.key.sql @@ -20,7 +20,7 @@ ALTER TABLE llx_product_customer_price ADD INDEX idx_product_customer_price_fk_user (fk_user); ALTER TABLE llx_product_customer_price ADD INDEX idx_product_customer_price_fk_soc (fk_soc); -ALTER TABLE llx_product_customer_price ADD UNIQUE INDEX uk_customer_price_fk_product_fk_soc (fk_product, fk_soc); +ALTER TABLE llx_product_customer_price ADD UNIQUE INDEX uk_customer_price_fk_product_fk_soc (fk_product, fk_soc, date_begin); ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_product_customer_price_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); ALTER TABLE llx_product_customer_price ADD CONSTRAINT fk_product_customer_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product(rowid); diff --git a/htdocs/install/mysql/tables/llx_product_customer_price.sql b/htdocs/install/mysql/tables/llx_product_customer_price.sql index bc25a0f0b2de8..04757667cad18 100644 --- a/htdocs/install/mysql/tables/llx_product_customer_price.sql +++ b/htdocs/install/mysql/tables/llx_product_customer_price.sql @@ -29,6 +29,8 @@ create table llx_product_customer_price fk_product integer NOT NULL, fk_soc integer NOT NULL, ref_customer varchar(128), + date_begin date, + date_end date, price double(24,8) DEFAULT 0, price_ttc double(24,8) DEFAULT 0, price_min double(24,8) DEFAULT 0, @@ -41,6 +43,7 @@ create table llx_product_customer_price localtax1_type varchar(10) NOT NULL DEFAULT '0', localtax2_tx double(7,4) DEFAULT 0, -- Other local VAT 2 localtax2_type varchar(10) NOT NULL DEFAULT '0', + discount_percent real DEFAULT 0, fk_user integer, price_label varchar(255), import_key varchar(14) -- Import key diff --git a/htdocs/install/mysql/tables/llx_product_customer_price_log.sql b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql index 43f70f4f984ac..e7761bc022ed6 100644 --- a/htdocs/install/mysql/tables/llx_product_customer_price_log.sql +++ b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql @@ -28,6 +28,8 @@ create table llx_product_customer_price_log fk_product integer NOT NULL, fk_soc integer DEFAULT 0 NOT NULL, ref_customer varchar(30), + date_begin date, + date_end date, price double(24,8) DEFAULT 0, price_ttc double(24,8) DEFAULT 0, price_min double(24,8) DEFAULT 0, @@ -40,6 +42,7 @@ create table llx_product_customer_price_log localtax1_type varchar(10) NOT NULL DEFAULT '0', localtax2_tx double(7,4) DEFAULT 0, -- Other local VAT 2 localtax2_type varchar(10) NOT NULL DEFAULT '0', + discount_percent real DEFAULT 0, fk_user integer, price_label varchar(255), import_key varchar(14) -- Import key