feat(shared): replace settle buttons with payment ledger
- New split_payments table records actual payments between participants - Balance = total split obligations - total payments (splits never marked settled) - Record Payment modal per participant: direction toggle, amount pre-filled with balance, date, notes - Payment history inline on each balance card with +/- display and delete - Per-transaction Settle button removed; Action column removed from shared table - Splits always show the true cost breakdown regardless of payment state
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
CREATE TABLE split_payments (
|
||||
id SERIAL PRIMARY KEY,
|
||||
from_participant_id INTEGER NOT NULL REFERENCES participants(id),
|
||||
to_participant_id INTEGER NOT NULL REFERENCES participants(id),
|
||||
amount DECIMAL(10,2) NOT NULL CHECK (amount > 0),
|
||||
payment_date DATE NOT NULL,
|
||||
notes TEXT,
|
||||
linked_transaction_id INTEGER REFERENCES transactions(id) ON DELETE SET NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_split_payments_from ON split_payments(from_participant_id);
|
||||
CREATE INDEX idx_split_payments_to ON split_payments(to_participant_id);
|
||||
@@ -24,6 +24,8 @@ model participants {
|
||||
created_at DateTime @default(now())
|
||||
splits transaction_splits[]
|
||||
account_owner_mappings account_owner_mappings[]
|
||||
payments_sent split_payments[] @relation("payments_from")
|
||||
payments_received split_payments[] @relation("payments_to")
|
||||
}
|
||||
|
||||
model account_owner_mappings {
|
||||
@@ -50,6 +52,19 @@ model transaction_splits {
|
||||
@@unique([transaction_id, participant_id])
|
||||
}
|
||||
|
||||
model split_payments {
|
||||
id Int @id @default(autoincrement())
|
||||
from_participant_id Int
|
||||
to_participant_id Int
|
||||
amount Decimal @db.Decimal(10, 2)
|
||||
payment_date DateTime @db.Date
|
||||
notes String?
|
||||
linked_transaction_id Int?
|
||||
created_at DateTime @default(now())
|
||||
from_participant participants @relation("payments_from", fields: [from_participant_id], references: [id])
|
||||
to_participant participants @relation("payments_to", fields: [to_participant_id], references: [id])
|
||||
}
|
||||
|
||||
model tags {
|
||||
id Int @id @default(autoincrement())
|
||||
name String @unique
|
||||
|
||||
Reference in New Issue
Block a user