feat(BE-229,234,235,230,231,232,233): purchase request and purchase order and fix master data dto

This commit is contained in:
ragilap
2025-11-17 09:39:30 +07:00
parent 8f74391f1e
commit 11f2389ec5
22 changed files with 2184 additions and 437 deletions
@@ -1,17 +1,19 @@
CREATE TABLE IF NOT EXISTS purchases (
id BIGSERIAL PRIMARY KEY,
pr_number VARCHAR NOT NULL,
po_number VARCHAR,
po_date TIMESTAMPTZ,
po_number VARCHAR NULL,
po_date TIMESTAMPTZ NULL,
supplier_id BIGINT NOT NULL,
credit_term INT,
credit_term INT NOT NULL,
due_date TIMESTAMPTZ,
grand_total NUMERIC(15, 3) DEFAULT 0,
grand_total NUMERIC(15, 3) NOT NULL,
notes TEXT,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),
created_at TIMESTAMPTZ NOT NULL,
updated_at TIMESTAMPTZ NOT NULL,
deleted_at TIMESTAMPTZ,
created_by BIGINT NOT NULL
created_by BIGINT NOT NULL,
CONSTRAINT uq_purchases_pr_number UNIQUE (pr_number),
CONSTRAINT uq_purchases_po_number UNIQUE (po_number)
);
DO $$
@@ -50,14 +52,6 @@ BEGIN
END IF;
END $$;
CREATE UNIQUE INDEX IF NOT EXISTS idx_purchases_pr_number_unique
ON purchases (pr_number)
WHERE deleted_at IS NULL;
CREATE UNIQUE INDEX IF NOT EXISTS idx_purchases_po_number_unique
ON purchases (po_number)
WHERE deleted_at IS NULL AND po_number IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_purchases_supplier_id ON purchases (supplier_id);
CREATE INDEX IF NOT EXISTS idx_purchases_created_by ON purchases (created_by);
CREATE INDEX IF NOT EXISTS idx_purchases_po_date ON purchases (po_date);