Overview
Thetransacciones table stores all financial transactions (income and expenses) linked to user wallets. Each transaction is categorized and includes amount, type, date, and optional description.
Table Schema
Columns
Primary key. Auto-generated unique identifier for the transaction.
Transaction amount in USD. Stored with 2 decimal precision.
Transaction type. Either
"gasto" (expense) or "ingreso" (income).Optional description or note about the transaction (max 280 characters in UI).
Date and time when the transaction occurred.
Foreign key to
categorias. Links the transaction to a category.Foreign key to
billeteras. Links the transaction to a wallet.Foreign key to
auth.users. Links the transaction to its owner.Timestamp when the transaction was created. Auto-set by database.
Timestamp when the transaction was last modified. Auto-updated.
Relationships
- Many-to-One with
billeteras: Each transaction belongs to one wallet - Many-to-One with
categorias: Each transaction belongs to one category - Many-to-One with
auth.users: Each transaction belongs to one user
Row Level Security (RLS)
The table enforces RLS policies:Example Queries
Fetch Transactions with Category Info
Create a New Transaction
Filter by Date Range
Calculate Wallet Balance
Transaction Types
- Gasto (Expense)
- Ingreso (Income)
Represents money spent or outgoing transactions.
- Decreases wallet balance
- Linked to expense categories
- Displayed with red color indicators
- Used for budget tracking
Validation Rules
- Amount: Must be greater than 0 (enforced in UI)
- Type: Must be either
"gasto"or"ingreso" - Category Match: Category type must match transaction type
- Wallet Selection: Cannot create transactions in global wallet mode
- Date: Cannot be in the future (recommended)
Indexes
Related Tables
Wallets
Parent wallet for transactions
Categories
Transaction categories
Budgets
Budget tracking by category
