Skip to main content
The Expense model represents a single expense transaction within a group. It tracks who paid, the amount, and how the expense should be split among group members.

Data Class Definition

Expense.kt
Source: Expense.kt

Fields

String
default:"\"\""
Unique identifier for the expense
String
default:"\"\""
ID of the group this expense belongs to. Serialized as group_id in JSON/database.
String
default:"\"\""
Name of the merchant or description of the expense (e.g., “Grocery Store”, “Dinner at Restaurant”)
Long
default:"0L"
Total amount of the expense in cents. Serialized as amount_cents in JSON/database.
String
default:"\"EQUAL\""
Method for splitting the expense among members. Common values:
  • "EQUAL" - Split evenly among all participants
  • "PERCENTAGE" - Split by custom percentages
  • "EXACT" - Split by exact amounts
Serialized as split_method in JSON/database.
String
default:"\"USD\""
Three-letter ISO currency code for the transaction
String
default:"\"\""
User ID of the member who paid for the expense. Serialized as paid_by_user_id in JSON/database.
String
default:"\"\""
ISO timestamp when the expense was created. Serialized as created_at in JSON/database.

Serialization

The Expense model uses Kotlin Serialization with snake_case field names for database compatibility:

GroupExpense

For a more comprehensive expense model with split details, see GroupExpense. The GroupExpense model extends Expense with:
  • Detailed split information per user
  • title field instead of merchant
  • List of ExpenseSplit objects

ExpenseSplit

From [GroupExpense.kt]:

Split

A simpler split model used in some contexts:
Split.kt
Source: Split.kt

Usage Examples

Creating an Expense

Repository Operations

From [ExpensesRepository.kt]:

Converting to GroupExpense

From [ExpensesRepository.kt:158]:

Split Methods

Equal Split

From [GroupExpense.kt:30]:

Percentage Split

From [GroupExpense.kt:44]: