X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=sql%2FPg-upgrade2%2Fprice_factors.sql;fp=sql%2FPg-upgrade2%2Fprice_factors.sql;h=3d45a8916dc6f14a8538b6d702b2431504847660;hb=1e25131315e72036aa6df1d626011a761218d233;hp=0000000000000000000000000000000000000000;hpb=0615efffa2877049ace481d767752db358c35cdb;p=kivitendo-erp.git diff --git a/sql/Pg-upgrade2/price_factors.sql b/sql/Pg-upgrade2/price_factors.sql new file mode 100644 index 000000000..3d45a8916 --- /dev/null +++ b/sql/Pg-upgrade2/price_factors.sql @@ -0,0 +1,36 @@ +-- @tag: price_factors +-- @description: Tabellen und Spalten für Preisfaktoren +-- @depends: release_2_4_3 + +CREATE TABLE price_factors ( + "id" integer DEFAULT nextval('id'::text), + "description" text, + "factor" numeric(15,5), + "sortkey" integer, + + PRIMARY KEY (id) + ); + +ALTER TABLE parts ADD COLUMN price_factor_id integer; + +ALTER TABLE invoice ADD COLUMN price_factor_id integer; +ALTER TABLE invoice ADD COLUMN price_factor numeric(15,5); +ALTER TABLE invoice ALTER COLUMN price_factor SET DEFAULT 1; +UPDATE invoice SET price_factor = 1; + +ALTER TABLE invoice ADD COLUMN marge_price_factor numeric(15,5); +ALTER TABLE invoice ALTER COLUMN marge_price_factor SET DEFAULT 1; +UPDATE invoice SET marge_price_factor = 1; + +ALTER TABLE orderitems ADD COLUMN price_factor_id integer; +ALTER TABLE orderitems ADD COLUMN price_factor numeric(15,5); +ALTER TABLE orderitems ALTER COLUMN price_factor SET DEFAULT 1; +UPDATE orderitems SET price_factor = 1; + +ALTER TABLE orderitems ADD COLUMN marge_price_factor numeric(15,5); +ALTER TABLE orderitems ALTER COLUMN marge_price_factor SET DEFAULT 1; +UPDATE orderitems SET marge_price_factor = 1; + +INSERT INTO price_factors (description, factor, sortkey) VALUES ('pro 10', 10, 1); +INSERT INTO price_factors (description, factor, sortkey) VALUES ('pro 100', 100, 2); +INSERT INTO price_factors (description, factor, sortkey) VALUES ('pro 1.000', 1000, 3);