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

# [Model]BillReturn

## Connections
[[_Purchases]] · [[[Model]PurchaseBill]] · [[[Model]Supplier]] · [[[Model]SupplierPaymentReceipt]] · [[[Controller]Controllers]] · [[[Service]BillReturnServices]] · [[[Repo]Repositories]] · [[[Cross]CrossModuleDependencies]]

## Source
`Modules/Purchases/Models/BillReturn.php`  
Related: `BillReturnDetail.php` · `BillReturnAttachment.php` · `BillReturnPaymentReceipt.php`

## Responsibilities
- Reversal of a PurchaseBill — credits the supplier back
- Always linked to parent `purchase_bill_id` (nullable for standalone returns)
- Requires a "purchase returns" account to be active before creation
- Auditable, FormatDateAndTimeTrait, SoftDeletes, UsesTenantConnection

## Key Relationships
| Relation | Type | Target |
|---|---|---|
| purchaseBill | belongsTo | PurchaseBill (withTrashed) |
| supplier | belongsTo | Supplier (withTrashed) |
| paymentTerm | belongsTo | PaymentTerm |
| paymentAccount | belongsTo | Account (Accounting) |
| billReturnDetails | hasMany | BillReturnDetail |
| attachments | hasMany | BillReturnAttachment |
| assignedReceipts | belongsToMany | SupplierPaymentReceipt via BillReturnPaymentReceipt (active) |
| allAssignedReceipts | belongsToMany | SupplierPaymentReceipt (includes trashed) |
| payments | hasMany | BillReturnPaymentReceipt |
| costCenter | belongsTo | CostCenter (Products) |
| journalEntry | belongsTo | JournalEntry (Accounting) |
| fiscalYear | belongsTo | FiscalYear (Settings) |
| formDesign | belongsTo | FormDesign (Settings) |
| addedBy / updatedBy / deletedBy | belongsTo | User (CompanyUser) withTrashed |

## Accessors / Mutators
`total` · `total_vat` · `total_amount` · `paid_amount` · `supplier_balance_after_transaction` (all trimNumber)

---

## [Model]BillReturnDetail

**Table:** `bill_return_details`

| Relation | Type | Target |
|---|---|---|
| billReturn | belongsTo | BillReturn (withTrashed) |
| product | belongsTo | Product (withTrashed) |
| warehouseProduct | belongsTo | WarehouseProduct (withTrashed) |
| tax | belongsTo | Tax (withTrashed) |

---

## [Model]BillReturnPaymentReceipt (pivot)

**Table:** `bills_returns_payment_receipts`  
Links `BillReturn` ↔ `SupplierPaymentReceipt` with `allocated_amount`. SoftDeletes.

---

## [Model]BillReturnAttachment

**Table:** `bill_return_attachments`  
Appends: `file_path`
