Skip to content

Commit

Permalink
NEW: add column to store a label for the price (#27238)
Browse files Browse the repository at this point in the history
* NEW: add column to store a label for the price

* review
  • Loading branch information
FHenry authored Jan 11, 2024
1 parent 7021cb2 commit f00c80f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 54 deletions.
7 changes: 7 additions & 0 deletions htdocs/install/mysql/migration/19.0.0-20.0.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -191,3 +197,4 @@ CREATE TABLE llx_c_product_thirdparty_relation_type
label varchar(128),
active tinyint default 1 NOT NULL
) ENGINE = innodb;

1 change: 1 addition & 0 deletions htdocs/install/mysql/tables/llx_product.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 13 additions & 12 deletions htdocs/install/mysql/tables/llx_product_customer_price.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
31 changes: 16 additions & 15 deletions htdocs/install/mysql/tables/llx_product_customer_price_log.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
52 changes: 25 additions & 27 deletions htdocs/install/mysql/tables/llx_product_price.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit f00c80f

Please sign in to comment.