1. Go to this page and download the library: Download mak8tech/zra-smart-invoice library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mak8tech / zra-smart-invoice example snippets
use Mak8Tech\ZraSmartInvoice\Facades\Zra;
// Initialize device
$result = Zra::initializeDevice('1234567890', '001', 'DEVICE123456');
use Mak8Tech\ZraSmartInvoice\Facades\Zra;
// Prepare sales data
$salesData = [
'invoiceNumber' => 'INV-1234',
'timestamp' => now()->format('Y-m-d H:i:s'),
'invoiceType' => 'NORMAL', // Can also be COPY, TRAINING, PROFORMA
'transactionType' => 'SALE', // Can also be CREDIT_NOTE, DEBIT_NOTE, ADJUSTMENT, REFUND
'items' => [
[
'name' => 'Product 1',
'quantity' => 2,
'unitPrice' => 100.00,
'totalAmount' => 200.00,
'taxRate' => 16,
'taxAmount' => 32.00,
'taxCategory' => 'VAT', // Can also be TOURISM_LEVY, EXCISE_DUTY, etc.
],
],
'totalAmount' => 200.00,
'totalTax' => 32.00,
'paymentType' => 'CASH',
'customerTpin' => '', // Optional for customer without TPIN
];
// Send to ZRA
$result = Zra::sendSalesData($salesData);
use Mak8Tech\ZraSmartInvoice\Facades\Zra;
// Generate X report (interim report)
$xReport = Zra::generateXReport();
// Generate Z report (end of day report)
$zReport = Zra::generateZReport();
// Get daily summary report
$dailyReport = Zra::getDailyReport('2025-04-11');
use Mak8Tech\ZraSmartInvoice\Facades\Zra;
// Add new product to inventory
$product = Zra::addInventoryProduct([
'code' => 'PROD001',
'name' => 'Product Name',
'description' => 'Product Description',
'unitPrice' => 100.00,
'taxRate' => 16,
'taxCategory' => 'VAT',
'initialStock' => 50
]);
// Update stock quantity
Zra::updateStockQuantity('PROD001', 60, 'STOCK_ADJUSTMENT', 'Inventory count adjustment');
// Check if product has sufficient stock
$hasStock = Zra::checkProductStock('PROD001', 5); // Returns true if at least 5 units available