mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-23 16:06:12 +01:00
Add splitmode and shares to expenses (#11)
* Add splitmode and shares to expenses * Update balances based on shares * Change field size * Form validation * Redesign expense form * Split unevenly by amount
This commit is contained in:
committed by
GitHub
parent
0fb0c42ff5
commit
0a8e56f800
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "ExpensePaidFor" ADD COLUMN "shares" INTEGER NOT NULL DEFAULT 1;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "SplitMode" AS ENUM ('EVENLY', 'BY_SHARES', 'BY_PERCENTAGE', 'BY_AMOUNT');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Expense" ADD COLUMN "splitMode" "SplitMode" NOT NULL DEFAULT 'EVENLY';
|
||||
@@ -39,14 +39,23 @@ model Expense {
|
||||
paidFor ExpensePaidFor[]
|
||||
groupId String
|
||||
isReimbursement Boolean @default(false)
|
||||
splitMode SplitMode @default(EVENLY)
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
enum SplitMode {
|
||||
EVENLY
|
||||
BY_SHARES
|
||||
BY_PERCENTAGE
|
||||
BY_AMOUNT
|
||||
}
|
||||
|
||||
model ExpensePaidFor {
|
||||
expense Expense @relation(fields: [expenseId], references: [id], onDelete: Cascade)
|
||||
participant Participant @relation(fields: [participantId], references: [id], onDelete: Cascade)
|
||||
expenseId String
|
||||
participantId String
|
||||
shares Int @default(1)
|
||||
|
||||
@@id([expenseId, participantId])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user