Expenses
Expense routes manage account expenses, including list/count screens, single expense view, create/update/delete actions, and expense category pickers for the New Expense modal.
Expense Data
- Expenses can include category, amount, tax/VAT, date, vendor, notes, files, customer/project links, and payment status when available.
- Send dates as UTC Y-m-d H:i:s unless the route asks for date-only.
- Use ids returned from list routes for update and delete actions.
Expense Categories
- Use ExpensesCategories.List for the Expenses New modal SELECT CATEGORY dropdown (table expenses_categories, default parent_id=0).
- For SELECT SUB CATEGORY, call ExpensesCategories.List again with parent_id set to the selected category id.
- Use returned data[].id as category_id on Expenses.Add. Do not use Categories.List (that lists product categories).
- ExpensesCategories.Count / ExpensesCategories.Get use the same filters / id. Alias: Expenses.CategoriesList.
Expenses.Add Mapping
- Expenses.Add mirrors dashboard Expences::add_expenses: expense_name → expenses_name, customer_id → customer_id, month YYYY-MM → stored mmyy.
- receipt / receipt_tax_invoice set paid_status=1; payment_date and document_date default to today when omitted.
Filters
- List screens should use customer, project, category, date range, payment status, and search filters when documented.
- Use Expenses.Count with the same filters to show paging totals.
Common Flow
- Load expense permissions from User.Basic.
- Load category options with ExpensesCategories.List (and parent_id for sub-categories).
- Use Expenses.List and Expenses.Count for tables.
- Open one record with Expenses.Get.
- Use Add/Update/Delete only when the user has permission; send category_id from ExpensesCategories.List.