Overview
ExpensesRepository handles all expense-related operations including creating expenses with splits, updating existing expenses, and tracking expenses across groups.
Interface: backend/ExpensesRepository.kt:15Implementation:
backend/SupabaseExpensesRepository.kt:21
Interface Definition
Implementation
SupabaseExpensesRepository
Basic Expense Methods
listExpenses
Fetches all expenses from the database.List<Expense> - All expenses in the system
Supabase Query:
listExpensesByGroup
Fetches all expenses for a specific group.String
required
The ID of the group to fetch expenses for
List<Expense> - All expenses in the specified group
Example Usage:
listGroupExpenses
Fetches expenses with their splits for a specific group.String
required
The ID of the group to fetch expenses for
List<GroupExpense> - Expenses with split information
Supabase Query:
group_expenses_with_splits view that joins expenses with their splits
getExpenseById
Fetches a single expense by ID.String
required
The unique identifier of the expense
Expense? - The expense or null if not found
Supabase Query:
getGroupExpenseById
Fetches a single expense with its splits.String
required
The unique identifier of the expense
GroupExpense? - The expense with splits or null if not found
Supabase Implementation:
Creating Expenses
createExpense
Creates a basic expense without custom splits.String
required
The group this expense belongs to
String
required
The merchant or description of the expense
Long
required
The total amount in cents (e.g., 1000 = $10.00)
String
required
How to split the expense: “EQUAL”, “PERCENTAGE”, or “EXACT”
Expense - The created expense
Example Usage:
createExpenseWithSplits
Creates an expense with custom split amounts for each member.String
required
The group this expense belongs to
String
required
The merchant or description of the expense
Long
required
The total amount in cents
String
required
Currency code (e.g., “USD”, “EUR”)
String
required
Split method: “EQUAL”, “PERCENTAGE”, “EXACT”
List<ExpenseSplit>
required
List of split allocations for each member
GroupExpense - The created expense with splits
Example Usage:
create_expense_with_splits - Atomically creates expense and splits
Updating Expenses
updateExpense
Updates an expense’s basic properties.String
required
The ID of the expense to update
String
required
The group ID (can be changed to move expense)
String
required
Updated description/merchant
Long
required
Updated amount in cents
String
required
Updated split method
String
required
Updated currency code
Expense - The updated expense
Supabase Implementation:
updateExpenseSplits
Updates the split allocations for an expense.String
required
The ID of the expense to update splits for
List<ExpenseSplit>
required
New split allocations
update_expense_splits - Replaces all splits for an expense
deleteExpense
Deletes an expense and all its splits.String
required
The ID of the expense to delete
Reactive Observations
observeGroupExpenses
Returns a Flow of expenses for a specific group.String
required
The group ID to observe expenses for
Flow<List<GroupExpense>> - Stream of expense updates
Example Usage:
observeAllGroupExpenses
Returns a Flow of all expenses across all groups.Flow<List<GroupExpense>> - Stream of all expenses
Implementation:
refreshGroupExpenses
Forces a refresh of expenses for a specific group.String
required
The group ID to refresh expenses for
refreshAllExpenses
Forces a refresh of all expenses.Data Models
Expense
Source:models/Expense.kt:7
ExpenseSplit
Source:models/GroupExpense.kt:8
userId: The member this split belongs toamountCents: This member’s share of the expenseisCoveredBy: Optional user ID if someone is covering this member’s share
GroupExpense
Source:models/GroupExpense.kt:15
Split Calculation Utilities
Source:models/GroupExpense.kt:30