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

# [Model]PurchaseOrder

## Connections
[[_Purchases]] · [[[Model]Supplier]] · [[[Model]PurchaseBill]] · [[[Controller]Controllers]] · [[[Service]PurchaseOrderServices]] · [[[Repo]Repositories]] · [[[Enum]Enums]] · [[[Cross]CrossModuleDependencies]]

## Source
`Modules/Purchases/Models/PurchaseOrder.php`  
Related: `PurchaseOrderDetail.php` · `PurchaseOrderAttachment.php`

## Responsibilities
- Pre-purchase document sent to a supplier before goods are received
- Status lifecycle: PLANNED → ACTIVE → INVOICED → EXPIRED
- Convertible to PurchaseBill via `MappingPurchaseOrderDataToPurchaseBillService`
- Traits: AuditableTrait, ConvertToInvoiceTrait, FormatDateAndTimeTrait, SoftDeletes, UsesPublicUrl, UsesTenantConnection
- `UPLOAD_PATH = 'purchase_orders'`

## Key Relationships
| Relation | Type | Target |
|---|---|---|
| supplier | belongsTo | Supplier (withTrashed) |
| formDesign | belongsTo | FormDesign (Settings) |
| attachments | hasMany | PurchaseOrderAttachment |
| products | hasMany | PurchaseOrderDetail (with warehouseProduct) |
| purchaseOrderProducts | hasManyThrough | Product via PurchaseOrderDetail |
| addedBy / updatedBy | belongsTo | User (CompanyUser) withTrashed |

## Fillable Fields
`code` · `issue_date` · `due_date` · `status` · `total_vat` · `total_amount` · `total` · `total_discount` · `notes` · `terms` · `supplier_id` · `form_design_id` · `custom_fields` · `description` · `currency_code` · `exchange_rate` · `taxes_status`

---

## [Model]PurchaseOrderDetail

**Table:** `purchase_order_details`

| Relation | Type | Target |
|---|---|---|
| purchaseOrder | belongsTo | PurchaseOrder |
| product | belongsTo | Product (withTrashed) |
| warehouseProduct | belongsTo | WarehouseProduct (withTrashed) |
| tax | belongsTo | Tax (withTrashed) |

Fields: `quantity` · `unit_price` · `total` · `discount` · `gross` · `vat`

---

## [Model]PurchaseOrderAttachment

**Table:** `purchase_order_attachments`  
Appends: `file_path`
