---
tags: [reports, model]
module: Reports
---

# [Model]Models

## Connections
[[_Reports]] · [[[Service]CustomerAgingService]] · [[[Service]UtilityServices]] · [[[DB]DatabaseTables]] · [[[Cross]CrossModuleDependencies]]

## Source
`Modules/Reports/Models/`

---

## Favorite

**Table:** `favorites` · Traits: `UsesTenantConnection`

| Field | Type | Notes |
|---|---|---|
| report_id | — | references `ReportsEnum` ID |

No relations. Simple per-user bookmark. Created/deleted via `ReportFavoriteController`.

---

## ReportCustomerAging

**Table:** `report_customer_aging` · Traits: `UsesTenantConnection`

Pre-computed AR aging cache table. Populated by `PopulateAgingReportForTenantJob` / `PopulateReportCustomerAgingTransactionsCommand`. Read by `ReportsAgingCustomerService`.

### Fillable
`customer_id` · `transaction_id` · `transaction_type` · `reference` · `cost_center_id` · `fiscal_year_id` · `transaction_date` · `transaction_due_date` · `amount` · `paid_amount`

### Casts
`transaction_date` / `transaction_due_date` → datetime

### Relationships
| Relation | Type | Target |
|---|---|---|
| customer | belongsTo | Customer (Sales, withTrashed) |
| costCenter | belongsTo | CostCenter (Products, withTrashed) |
| fiscalYear | belongsTo | FiscalYear (Settings) |
| transaction | belongsTo | Invoice or InvoiceReturn (polymorphic via transaction_type) |

### Scopes
`forCustomers(array)` · `forCostCenters(array)` (null = main center) · `forFiscalYear(int)` · `transactionDateBetween($start, $end)` · `outstanding()` (amount > paid_amount)

### Accessors
`balance` — `amount - paid_amount`  
`days_overdue` — days from due_date to today  
`display_type` — localized transaction type label

### Static Methods
`getTransactionTypeForInvoice(Invoice)` — returns `'debit_note'` or `'invoice'`

### transaction_type enum values
`invoice` · `invoice_return` · `debit_note`
