dodil/erp-brick-tax
DODIL ERP brick: tax
src/brick_tax/migrations/00004_v6/up.sql
-- 00004_v6 (spec v6): a line says how it is consumed (eat_in | takeaway) and a rule may tell the two apart (TAX-51). Rules of consumption
-- `any` stay where they are; those that distinguish live in tax_rule_consumption, whose key carries direction and consumption (no key changes in
-- place). ADD COLUMN is DISRUPTIVE: migrate the test copy first, the live one at a quiet hour.
ALTER TABLE tax_document_line ADD COLUMN consumption VARCHAR;
CREATE TABLE IF NOT EXISTS tax_rule_consumption (
category_code VARCHAR NOT NULL,
treatment_code VARCHAR NOT NULL,
supply VARCHAR NOT NULL,
direction VARCHAR NOT NULL,
consumption VARCHAR NOT NULL,
valid_from DATE NOT NULL,
tax_code VARCHAR,
priority INTEGER,
valid_to DATE,
change_state VARCHAR,
created_by VARCHAR,
approved_by VARCHAR,
withdrawn_by VARCHAR,
created_at TIMESTAMP,
updated_at TIMESTAMP,
created_sub VARCHAR,
PRIMARY KEY (category_code, treatment_code, supply, direction, consumption, valid_from)
);