dodil/erp-brick-ar
DODIL ERP brick: accounts receivable
src/brick_ar/migrations/00002_audit1/up.sql
-- 00002_audit1 (v0.1.1): the proposer's and drafter's sub beside their email (self-approval holds for either identity),
-- the invoice-number claim (no two documents share a number) and the per-invoice credit claim (credits cannot
-- together exceed the invoice). ADD COLUMN is DISRUPTIVE: migrate the test copy first, the live one at a quiet hour.
ALTER TABLE ar_writeoffs ADD COLUMN proposed_by_sub VARCHAR;
ALTER TABLE ar_credit_notes ADD COLUMN drafted_by_sub VARCHAR;
CREATE TABLE IF NOT EXISTS ar_invoice_no_claims (
invoice_no VARCHAR NOT NULL,
document_id VARCHAR,
claimed_at TIMESTAMP,
created_at TIMESTAMP,
updated_at TIMESTAMP,
PRIMARY KEY (invoice_no)
);
CREATE TABLE IF NOT EXISTS ar_credit_claim (
invoice_id VARCHAR NOT NULL,
n INTEGER NOT NULL,
credit_id VARCHAR,
claimed_at TIMESTAMP,
created_at TIMESTAMP,
updated_at TIMESTAMP,
PRIMARY KEY (invoice_id, n)
);