LedgerEntry model represents a financial transaction in a group’s ledger. It tracks both expenses and settlements, recording who paid whom and for what amount.
Data Class Definition
LedgerEntry.kt
LedgerEntryType Enum
- EXPENSE: Represents a shared expense that was split among group members
- SETTLEMENT: Represents a direct payment from one user to another to settle debts
Fields
Unique identifier for the ledger entry
Type of transaction:
EXPENSE or SETTLEMENTDescription of the transaction (e.g., “Grocery Store”, “Payment to Sarah”)
Transaction amount in cents
ID of the group this ledger entry belongs to
User ID of the person who made the payment
Human-readable date label (e.g., “Today”, “Yesterday”, “Mar 1”)
For settlements, the user ID of the person receiving the payment. Empty for expenses.
For expenses, the method used to split the cost (e.g., “EQUAL”, “PERCENTAGE”). Empty for settlements.
Name of the group (denormalized for display purposes)
Display name of the user who paid (denormalized for display purposes)
Display name of the user who received payment in a settlement (denormalized for display purposes)
Whether the current user made this payment
Usage Examples
Expense Ledger Entry
Settlement Ledger Entry
Related Models
ActivityItem
A simplified model for displaying activity feed items:ActivityItem.kt
ActivityItem model is a simpler representation used in activity feeds, while LedgerEntry contains more detailed transaction information.
Relationships
- Group: Each ledger entry belongs to a Group via
groupId - User: The
paidByUserIdandtoUserIdfields reference UserProfile IDs - Expense: Expense-type ledger entries are derived from Expense or GroupExpense records
Use Cases
Transaction History
Ledger entries provide a complete audit trail of all financial transactions within a group:- Who paid for what expenses
- Who settled debts with whom
- When transactions occurred
Balance Calculation
Ledger entries are used to calculate member balances:- Expenses increase what others owe the payer
- Settlements reduce outstanding debts between members
Activity Feed
The denormalized fields (groupName, paidByName, toName) allow ledger entries to be displayed in activity feeds without additional database lookups.