From f00c80f33eed3f8b905b1c4d6fadf4a5f8cce7f5 Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Thu, 11 Jan 2024 10:51:49 +0100 Subject: [PATCH] NEW: add column to store a label for the price (#27238) * NEW: add column to store a label for the price * review --- .../install/mysql/migration/19.0.0-20.0.0.sql | 7 +++ htdocs/install/mysql/tables/llx_product.sql | 1 + .../tables/llx_product_customer_price.sql | 25 ++++----- .../tables/llx_product_customer_price_log.sql | 31 +++++------ .../mysql/tables/llx_product_price.sql | 52 +++++++++---------- 5 files changed, 62 insertions(+), 54 deletions(-) diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index efbd730b5e5d4..339f970c31111 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -161,6 +161,12 @@ ALTER TABLE llx_usergroup_extrafields ADD UNIQUE INDEX uk_usergroup_extrafields UPDATE llx_categorie SET date_creation = tms, tms = tms WHERE date_creation IS NULL AND tms IS NOT NULL; +ALTER TABLE llx_product_price ADD COLUMN price_label varchar(255) AFTER fk_user_author; +ALTER TABLE llx_product_customer_price_log ADD COLUMN price_label varchar(255) AFTER fk_user; +ALTER TABLE llx_product_customer_price ADD COLUMN price_label varchar(255) AFTER fk_user; +ALTER TABLE llx_product ADD COLUMN price_label varchar(255) AFTER price_base_type; + + CREATE TABLE llx_product_thirdparty ( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, @@ -191,3 +197,4 @@ CREATE TABLE llx_c_product_thirdparty_relation_type label varchar(128), active tinyint default 1 NOT NULL ) ENGINE = innodb; + diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index bbe9af415d726..f63a414556936 100644 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -46,6 +46,7 @@ create table llx_product price_min double(24,8) DEFAULT 0, price_min_ttc double(24,8) DEFAULT 0, price_base_type varchar(3) DEFAULT 'HT', + price_label varchar(255), cost_price double(24,8) DEFAULT NULL, -- Cost price without tax. Can be used for margin calculation. default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product. tva_tx double(7,4), -- Default VAT rate of product diff --git a/htdocs/install/mysql/tables/llx_product_customer_price.sql b/htdocs/install/mysql/tables/llx_product_customer_price.sql index 7f843a8784eb2..bc25a0f0b2de8 100644 --- a/htdocs/install/mysql/tables/llx_product_customer_price.sql +++ b/htdocs/install/mysql/tables/llx_product_customer_price.sql @@ -29,18 +29,19 @@ create table llx_product_customer_price fk_product integer NOT NULL, fk_soc integer NOT NULL, ref_customer varchar(128), - price double(24,8) DEFAULT 0, - price_ttc double(24,8) DEFAULT 0, - price_min double(24,8) DEFAULT 0, - price_min_ttc double(24,8) DEFAULT 0, - price_base_type varchar(3) DEFAULT 'HT', - default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product. - tva_tx double(7,4), - recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT - localtax1_tx double(7,4) DEFAULT 0, -- Other local VAT 1 - 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', + price double(24,8) DEFAULT 0, + price_ttc double(24,8) DEFAULT 0, + price_min double(24,8) DEFAULT 0, + price_min_ttc double(24,8) DEFAULT 0, + price_base_type varchar(3) DEFAULT 'HT', + default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product. + tva_tx double(7,4), + recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT + localtax1_tx double(7,4) DEFAULT 0, -- Other local VAT 1 + 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', fk_user integer, + price_label varchar(255), import_key varchar(14) -- Import key )ENGINE=innodb; 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 cd591b410997c..43f70f4f984ac 100644 --- a/htdocs/install/mysql/tables/llx_product_customer_price_log.sql +++ b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql @@ -22,24 +22,25 @@ create table llx_product_customer_price_log ( - rowid integer AUTO_INCREMENT PRIMARY KEY, + rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id - datec datetime, + datec datetime, fk_product integer NOT NULL, fk_soc integer DEFAULT 0 NOT NULL, ref_customer varchar(30), - price double(24,8) DEFAULT 0, - price_ttc double(24,8) DEFAULT 0, - price_min double(24,8) DEFAULT 0, - price_min_ttc double(24,8) DEFAULT 0, - price_base_type varchar(3) DEFAULT 'HT', - default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product. - tva_tx double(7,4), - recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT - localtax1_tx double(7,4) DEFAULT 0, -- Other local VAT 1 - 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', + price double(24,8) DEFAULT 0, + price_ttc double(24,8) DEFAULT 0, + price_min double(24,8) DEFAULT 0, + price_min_ttc double(24,8) DEFAULT 0, + price_base_type varchar(3) DEFAULT 'HT', + default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product. + tva_tx double(7,4), + recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT + localtax1_tx double(7,4) DEFAULT 0, -- Other local VAT 1 + 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', fk_user integer, - import_key varchar(14) -- Import key + price_label varchar(255), + import_key varchar(14) -- Import key )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_product_price.sql b/htdocs/install/mysql/tables/llx_product_price.sql index 2a64fc92c3002..56457ab7bc494 100644 --- a/htdocs/install/mysql/tables/llx_product_price.sql +++ b/htdocs/install/mysql/tables/llx_product_price.sql @@ -23,35 +23,33 @@ create table llx_product_price ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - entity integer DEFAULT 1 NOT NULL, -- Multi company id - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - fk_product integer NOT NULL, - date_price datetime NOT NULL, - price_level smallint NULL DEFAULT 1, - price double(24,8) DEFAULT NULL, -- price without tax - price_ttc double(24,8) DEFAULT NULL, -- price inc vat (but not localtax1 nor localtax2) - price_min double(24,8) default NULL, - price_min_ttc double(24,8) default NULL, - price_base_type varchar(3) DEFAULT 'HT', - default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product. - tva_tx double(7,4) DEFAULT 0 NOT NULL, -- Used only when option PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on (not supported) - recuperableonly integer NOT NULL DEFAULT '0', - localtax1_tx double(7,4) DEFAULT 0, - localtax1_type varchar(10) NOT NULL DEFAULT '0', - localtax2_tx double(7,4) DEFAULT 0, - localtax2_type varchar(10) NOT NULL DEFAULT '0', - fk_user_author integer, - tosell tinyint DEFAULT 1, - price_by_qty integer NOT NULL DEFAULT 0, - fk_price_expression integer, -- Link to the rule for dynamic price calculation - import_key varchar(14), - + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- Multi company id + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_product integer NOT NULL, + date_price datetime NOT NULL, + price_level smallint NULL DEFAULT 1, + price double(24,8) DEFAULT NULL, -- price without tax + price_ttc double(24,8) DEFAULT NULL, -- price inc vat (but not localtax1 nor localtax2) + price_min double(24,8) default NULL, + price_min_ttc double(24,8) default NULL, + price_base_type varchar(3) DEFAULT 'HT', + default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product. + tva_tx double(7,4) DEFAULT 0 NOT NULL, -- Used only when option PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on (not supported) + recuperableonly integer NOT NULL DEFAULT '0', + localtax1_tx double(7,4) DEFAULT 0, + localtax1_type varchar(10) NOT NULL DEFAULT '0', + localtax2_tx double(7,4) DEFAULT 0, + localtax2_type varchar(10) NOT NULL DEFAULT '0', + fk_user_author integer, + price_label varchar(255), + tosell tinyint DEFAULT 1, + price_by_qty integer NOT NULL DEFAULT 0, + fk_price_expression integer, -- Link to the rule for dynamic price calculation + import_key varchar(14), fk_multicurrency integer, multicurrency_code varchar(3), - multicurrency_tx double(24,8) DEFAULT 1, + multicurrency_tx double(24,8) DEFAULT 1, multicurrency_price double(24,8) DEFAULT NULL, multicurrency_price_ttc double(24,8) DEFAULT NULL - )ENGINE=innodb; -