dodil/erp-brick-expenses

DODIL ERP brick: expenses

src/brick_expenses/migrations/00005_fx_vat/up.sql

-- 00005_fx_vat - slice B item 3: foreign-currency lines (EXP-05: gl's rate, frozen on the line), tax's answer for each receipt and the receipt's
-- particulars for tax's content check (EXP-11, EXP-18), and the categories mileage and per diem (EXP-03, EXP-04) plus the correction that makes
-- a client meal business entertainment for tax. Additive only. ADD COLUMN is DISRUPTIVE on DataK3: migrate the test copy first, the live one at
-- a quiet hour.

ALTER TABLE exp_line ADD COLUMN fx_rate NUMERIC(19,6);

ALTER TABLE exp_line ADD COLUMN treatment_code VARCHAR;

ALTER TABLE exp_line ADD COLUMN contents_json VARCHAR;

ALTER TABLE exp_line ADD COLUMN tax_code VARCHAR;

ALTER TABLE exp_line ADD COLUMN vat_reclaimable NUMERIC(18,2);

ALTER TABLE exp_line ADD COLUMN vat_non_reclaimable NUMERIC(18,2);

ALTER TABLE exp_line ADD COLUMN tax_json VARCHAR;

ALTER TABLE exp_line ADD COLUMN receipt_vat NUMERIC(18,2);

INSERT INTO exp_category (company_code, category_code, valid_from, name, gl_purpose, tax_category, receipt_required, kind, created_at, updated_at) VALUES
    ('*', 'MEALS_CLIENT', DATE '2000-01-02', 'Meals with clients', 'entertainment', 'entertainment', TRUE, 'receipt', NOW(), NOW()),
    ('*', 'MILEAGE', DATE '2000-01-01', 'Mileage in your own vehicle', 'mileage', 'outside_scope', FALSE, 'mileage', NOW(), NOW()),
    ('*', 'PER_DIEM', DATE '2000-01-01', 'Daily allowance', 'per_diem', 'outside_scope', FALSE, 'per_diem', NOW(), NOW());