Added transaction feature, fixed some mistakes

This commit is contained in:
2026-04-11 11:12:54 +03:00
parent 6872563c62
commit 545b05d5a0
37 changed files with 2509 additions and 115 deletions
@@ -1,6 +1,25 @@
CREATE TABLE transactions
(
id BIGSERIAL PRIMARY KEY,
family_id BIGINT NOT NULL REFERENCES families (id) ON DELETE CASCADE,
description TEXT,
type TEXT NOT NULL,
datetime TIMESTAMP NOT NULL,
category TEXT NOT NULL,
amount NUMERIC(14, 2) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
created_by BIGINT NOT NULL REFERENCES users (id) ON DELETE RESTRICT
);
CREATE INDEX idx_transactions_family_id ON transactions (family_id);
CREATE INDEX idx_transactions_datetime ON transactions (datetime);
CREATE INDEX idx_transactions_created_by ON transactions (created_by);
CREATE INDEX idx_transactions_family_datetime ON transactions (family_id, datetime DESC);
CREATE TABLE receipts
(
id BIGSERIAL PRIMARY KEY,
transaction_id BIGINT UNIQUE REFERENCES transactions (id) ON DELETE SET NULL,
receipt_number TEXT NOT NULL UNIQUE,
ui TEXT NOT NULL,
status INTEGER NOT NULL,
@@ -29,7 +48,8 @@ CREATE TABLE receipts
skno_number TEXT,
unp TEXT,
success TEXT,
created_at TIMESTAMP DEFAULT NOW()
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_receipts_issued_at ON receipts(issued_at);
CREATE INDEX idx_receipts_issued_at ON receipts (issued_at);
CREATE INDEX idx_receipts_transaction_id ON receipts (transaction_id);