Invoices
ZATCA Invoice System Documentation
Table of Contents
Invoice Setup
Adding ZATCA Invoice Capability
use Hazem\Zatca\Traits\HasZatcaInvoice;
class Order extends Model
{
use HasZatcaInvoice;
protected function prepareZatcaInvoiceData()
{
$items = $this->prepareZatcaItems();
return [
'invoice_number' => $this->invoice_no,
'total_amount' => round($this->final_total, 2),
'vat_amount' => collect($items)->sum(function ($item) {
return round($item['vat'] * $item['quantity'], 2);
}),
'is_pos' => true,
'is_invoice' => $this->type === 'sell',
'items' => $items,
'date' => $this->transaction_date,
// Buyer information
'buyer_name' => $this->contact->name ?? null,
'buyer_tax_number' => null,
'buyer_address' => null,
'buyer_city' => null,
'buyer_state' => null,
'buyer_postal' => null,
'buyer_building_no' => null
];
}
protected function prepareZatcaItems()
{
return $this->sell_lines->map(function($item) {
return [
'name' => $item->product?->name,
'quantity' => $item->quantity,
'price' => round($item->unit_price, 2),
'vat' => round(round($item->unit_price, 2) * 0.15, 2)
];
})->toArray();
}
}Creating Invoices
Using the Fluent Interface
Submitting Invoices
1. Basic Submission
2. Custom Data Submission
Returns and Credit Notes
Status Checking
Available Methods
Invoice Operations
Important Notes
General Guidelines
Common Pitfalls to Avoid
Best Practices
Security Considerations
Last updated