Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW: Add management of date begin/end and discount for a customer price (SQL) #33223

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions htdocs/install/mysql/migration/21.0.0-22.0.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,18 @@ CREATE TABLE llx_bank_record_link

ALTER TABLE llx_bank_record_link ADD CONSTRAINT fk_bank_record_bank_record FOREIGN KEY (fk_bank_record) REFERENCES llx_bank_record (rowid);
ALTER TABLE llx_bank_record_link ADD CONSTRAINT fk_bank_import_bank_import FOREIGN KEY (fk_bank_import) REFERENCES llx_bank_import (rowid);

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 remise_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 remise_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;
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions htdocs/install/mysql/tables/llx_product_customer_price.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 NOT NULL,
date_end date,
price double(24,8) DEFAULT 0,
price_ttc double(24,8) DEFAULT 0,
price_min double(24,8) DEFAULT 0,
Expand All @@ -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',
remise_percent real DEFAULT 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use name discount_percent instead of remise_percent ?

Renaming remise_percent into discount_percent into other table is not yet planned, but we should have to do it one day...

fk_user integer,
price_label varchar(255),
import_key varchar(14) -- Import key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 NOT NULL,
date_end date,
price double(24,8) DEFAULT 0,
price_ttc double(24,8) DEFAULT 0,
price_min double(24,8) DEFAULT 0,
Expand All @@ -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',
remise_percent real DEFAULT 0,
fk_user integer,
price_label varchar(255),
import_key varchar(14) -- Import key
Expand Down