feat(finance): Phase 6 — Budget & Analytics
Add monthly budgets per category with spend-vs-budget dashboard and 6-month trend table. Includes upsert budget API, monthly analytics endpoint, inline budget editing, and route auth fixes.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS budgets (
|
||||
id SERIAL PRIMARY KEY,
|
||||
owner_id INTEGER NOT NULL REFERENCES participants(id),
|
||||
category TEXT NOT NULL,
|
||||
month DATE NOT NULL,
|
||||
amount_limit NUMERIC(10,2) NOT NULL,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
UNIQUE(owner_id, category, month)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_budgets_owner_month ON budgets(owner_id, month);
|
||||
@@ -65,3 +65,15 @@ model transaction_tags {
|
||||
|
||||
@@id([transaction_id, tag_id])
|
||||
}
|
||||
|
||||
model budgets {
|
||||
id Int @id @default(autoincrement())
|
||||
owner_id Int
|
||||
category String
|
||||
month DateTime @db.Date
|
||||
amount_limit Decimal @db.Decimal(10, 2)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @default(now()) @updatedAt
|
||||
|
||||
@@unique([owner_id, category, month])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user