---
tags: [purchases, model]
module: Purchases
---

# [Model]Expense

## Connections
[[_Purchases]] · [[[Model]Supplier]] · [[[Controller]Controllers]] · [[[Service]ExpenseServices]] · [[[Repo]Repositories]] · [[[Observer]Observers]] · [[[Cross]CrossModuleDependencies]]

## Source
`Modules/Purchases/Models/Expense.php`  
Related: `ExpenseDetail.php` · `ExpenseAttachment.php`

## Responsibilities
- Records a one-time cost that doesn't go through the full purchase bill flow
- Can be linked to a Supplier OR a Customer (flexible payee)
- Has two journal entries: `journal_entry_id` (main) + `supplier_customer_journal_entry_id` (counterparty)
- Has `ExpenseObserver` → records usage for `ExpensesLimits` feature + updates last activity
- Auditable, FormatDateAndTimeTrait, SoftDeletes, UsesTenantConnection
- `UPLOAD_PATH = 'expenses'`

## Key Relationships
| Relation | Type | Target |
|---|---|---|
| supplier | belongsTo | Supplier (withTrashed) |
| customer | belongsTo | Customer (Sales, withTrashed) |
| account | belongsTo | Account (Accounting) via `payment_account_id` |
| details | hasMany | ExpenseDetail |
| attachments | hasMany | ExpenseAttachment |
| costCenter | belongsTo | CostCenter (Products) |
| journalEntry | belongsTo | JournalEntry (Accounting) |
| supplierCustomerJournalEntry | belongsTo | JournalEntry (separate counterparty entry) |
| fiscalYear | belongsTo | FiscalYear (Settings) |
| formDesign | belongsTo | FormDesign (Settings) |
| addedBy / updatedBy / deletedBy | belongsTo | User (CompanyUser) withTrashed |

## Notable Fields
`taxes_status` · `reference` (auto-generated code) · `supplier_id` nullable · `customer_id` nullable

---

## [Model]ExpenseDetail

**Table:** `expense_details` (originally `bill_expenses_details`)

| Relation | Type | Target |
|---|---|---|
| expense | belongsTo | Expense |
| product | belongsTo | Product (withTrashed) |
| tax | belongsTo | Tax (withTrashed) |

Fields: `quantity` · `price` · `discount` · `gross` · `vat_value` · `total`

---

## [Model]ExpenseAttachment

**Table:** `expense_attachments` — `UPLOAD_PATH = 'expenses'`  
Appends: `file_path`
