feat(finance): Phase 5 — Rules Engine

Add rules engine with CRUD API, condition/action evaluation, and apply-all endpoint.
UI: rule builder form with field/operator/value conditions, tag multi-select, apply button with result stats.
This commit is contained in:
2026-03-08 16:48:35 +11:00
parent 93450f7caa
commit 31cffbe1bb
9 changed files with 653 additions and 8 deletions
@@ -0,0 +1,12 @@
CREATE TABLE IF NOT EXISTS rules (
id SERIAL PRIMARY KEY,
owner_id INTEGER NOT NULL REFERENCES participants(id),
name TEXT NOT NULL,
conditions JSONB NOT NULL DEFAULT '[]',
actions JSONB NOT NULL DEFAULT '{}',
enabled BOOLEAN NOT NULL DEFAULT true,
priority INTEGER NOT NULL DEFAULT 0,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_rules_owner ON rules(owner_id);
+24
View File
@@ -65,3 +65,27 @@ model transaction_tags {
@@id([transaction_id, tag_id])
}
model rules {
id Int @id @default(autoincrement())
owner_id Int
name String
conditions Json @default("[]")
actions Json @default("{}")
enabled Boolean @default(true)
priority Int @default(0)
created_at DateTime @default(now())
updated_at DateTime @default(now()) @updatedAt
}
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])
}