mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-01 10:56:13 +01:00
Add recurring expense functionality (#263)
* code complete * Smaller updates * delete ambitious TODOs (add to PR) * add transactionality to recurring expense creation * Remove unnecessary `let`s * Add default english labels to non-en-US translations * Accept `es.json` translations * add condition to ensure links are only modified when applicable
This commit is contained in:
@@ -55,6 +55,10 @@ model Expense {
|
||||
createdAt DateTime @default(now())
|
||||
documents ExpenseDocument[]
|
||||
notes String?
|
||||
|
||||
recurrenceRule RecurrenceRule? @default(NONE)
|
||||
recurringExpenseLink RecurringExpenseLink?
|
||||
recurringExpenseLinkId String?
|
||||
}
|
||||
|
||||
model ExpenseDocument {
|
||||
@@ -73,6 +77,29 @@ enum SplitMode {
|
||||
BY_AMOUNT
|
||||
}
|
||||
|
||||
model RecurringExpenseLink {
|
||||
id String @id
|
||||
groupId String
|
||||
currentFrameExpense Expense @relation(fields: [currentFrameExpenseId], references: [id], onDelete: Cascade)
|
||||
currentFrameExpenseId String @unique
|
||||
|
||||
// Note: We do not want to link to the next expense because once it is created, it should be
|
||||
// treated as it's own independent entity. This means that if a user wants to delete an Expense
|
||||
// and any prior related recurring expenses, they'll need to delete them one by one.
|
||||
nextExpenseCreatedAt DateTime?
|
||||
nextExpenseDate DateTime
|
||||
|
||||
@@index([groupId])
|
||||
@@index([groupId, nextExpenseCreatedAt, nextExpenseDate(sort: Desc)])
|
||||
}
|
||||
|
||||
enum RecurrenceRule {
|
||||
NONE
|
||||
DAILY
|
||||
WEEKLY
|
||||
MONTHLY
|
||||
}
|
||||
|
||||
model ExpensePaidFor {
|
||||
expense Expense @relation(fields: [expenseId], references: [id], onDelete: Cascade)
|
||||
participant Participant @relation(fields: [participantId], references: [id], onDelete: Cascade)
|
||||
|
||||
Reference in New Issue
Block a user