fc22a61a43
- Add POST /api/transactions to create manual transactions (statement_id=NULL, owner_id set directly) - Queries switch from JOIN to LEFT JOIN statements so manual transactions are visible - COALESCE(t.owner_id, s.owner_id) throughout for owner resolution - Add "Manual" bank filter option in getTransactions - Search extended to include merchant_normalized override - Split data fetched via lateral subquery on every transaction row - getParticipantBalances rewritten as UNION for bidirectional net balances (credits/refunds negate, split from either side of the relationship) - getSharedTransactions: remove my_share_percent from SELECT (fixes GROUP BY error), WHERE rewritten as two distinct cases (owner with others split vs participant on others' txn) - getTransactions: OR EXISTS condition so split participants see shared transactions - add-transaction-modal component for creating manual transactions with splits - 0008_my_share_percent migration adds my_share_percent to transaction_overrides
93 lines
2.7 KiB
Plaintext
93 lines
2.7 KiB
Plaintext
generator client {
|
|
provider = "prisma-client"
|
|
output = "../src/generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
}
|
|
|
|
model transaction_overrides {
|
|
id Int @id @default(autoincrement())
|
|
transaction_id Int @unique
|
|
merchant_normalized String?
|
|
category_override String?
|
|
notes String?
|
|
my_share_percent Decimal? @db.Decimal(5, 2)
|
|
updated_at DateTime @default(now()) @updatedAt
|
|
}
|
|
|
|
model participants {
|
|
id Int @id @default(autoincrement())
|
|
name String @unique
|
|
email String? @unique
|
|
created_at DateTime @default(now())
|
|
splits transaction_splits[]
|
|
account_owner_mappings account_owner_mappings[]
|
|
}
|
|
|
|
model account_owner_mappings {
|
|
id Int @id @default(autoincrement())
|
|
bank_name String
|
|
account_number String
|
|
owner_id Int
|
|
created_at DateTime @default(now())
|
|
owner participants @relation(fields: [owner_id], references: [id])
|
|
|
|
@@unique([bank_name, account_number])
|
|
}
|
|
|
|
model transaction_splits {
|
|
id Int @id @default(autoincrement())
|
|
transaction_id Int
|
|
participant_id Int
|
|
share_percent Decimal @db.Decimal(5, 2)
|
|
settled Boolean @default(false)
|
|
settled_at DateTime?
|
|
created_at DateTime @default(now())
|
|
participant participants @relation(fields: [participant_id], references: [id])
|
|
|
|
@@unique([transaction_id, participant_id])
|
|
}
|
|
|
|
model tags {
|
|
id Int @id @default(autoincrement())
|
|
name String @unique
|
|
color String @default("#6366f1")
|
|
created_at DateTime @default(now())
|
|
transaction_tags transaction_tags[]
|
|
}
|
|
|
|
model transaction_tags {
|
|
transaction_id Int
|
|
tag_id Int
|
|
created_at DateTime @default(now())
|
|
tag tags @relation(fields: [tag_id], references: [id], onDelete: Cascade)
|
|
|
|
@@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])
|
|
}
|