# Saudi Invoice Setup Guide (Urdu)

## Kya Banaya Gaya Hai

Maine aapke liye ek **professional Saudi-style invoice design** banaya hai jo:
- ✅ Arabic aur English dono languages mein hai (bilingual)
- ✅ Saudi Arabia ke green colors use karta hai
- ✅ Bara QR code dikhata hai (ZATCA compliant)
- ✅ Logo aur company details properly show karta hai
- ✅ Tax information prominently display hoti hai
- ✅ Modern aur professional look hai

## Files Banayi Gayi

1. **saudi-invoice.blade.php** - Naya invoice design template
2. **SAUDI_INVOICE_SETUP.md** - Detailed English guide
3. **setup_saudi_invoice.sql** - Quick setup SQL script

## Kaise Use Karein (3 Easy Steps)

### Step 1: SQL Script Run Karein

1. **phpMyAdmin ya MySQL Workbench open karein**
2. **Apna database select karein**
3. **SQL tab mein jaaein**
4. **`setup_saudi_invoice.sql` file ka content copy karein aur run karein**

Ya direct yeh command run karein:

```sql
UPDATE invoice_layouts 
SET design = 'saudi-invoice',
    show_logo = 1,
    show_qr_code = 1,
    qr_code_fields = '["business_name","tax_1","invoice_no","invoice_datetime","total_amount","customer_name"]'
WHERE id = 1;
```

### Step 2: Logo Upload Karein

1. **Settings → Invoice Layouts** mein jaaein
2. **Edit** button click karein
3. **"Show Logo"** checkbox check karein
4. **Logo file upload karein** (PNG format, 200x80 pixels recommended)
5. **Save** karein

### Step 3: Test Karein

1. **POS Pro** page open karein
2. **Koi sale complete karein**
3. **Invoice automatically open hoga** - check karein:
   - Logo dikh raha hai?
   - QR code dikh raha hai?
   - Green colors hai?
   - Arabic/English text hai?

## Invoice Ka Design

### Header Section (Upar):
- **Green background** with company logo
- **Company name** Arabic aur English mein
- **Address aur contact** details

### Tax Banner (Yellow Box):
- **VAT Number** prominently displayed
- Yellow color mein highlight

### Invoice Details:
- **Invoice number** aur date
- **Customer information**
- **Sales person** name

### Items Table:
- **Bilingual headers** (Arabic/English)
- Item name, quantity, price, discount, tax, total
- Clean aur organized layout

### Totals Section:
- **Left side:** Subtotal, discount, tax, grand total
- **Right side:** Large QR code (200x200px)
- **Payment details** green box mein

### Footer:
- Thank you message (Arabic/English)
- Electronic invoice note
- Custom footer text

## Important Settings

### QR Code Enable Karne Ke Liye:

Database mein yeh run karein:
```sql
UPDATE invoice_layouts 
SET show_qr_code = 1,
    qr_code_fields = '["business_name","tax_1","invoice_no","invoice_datetime","total_amount","customer_name"]'
WHERE id = 1;
```

### Logo Enable Karne Ke Liye:

1. Logo file upload karein: `public/uploads/invoice_logos/` folder mein
2. Database mein:
```sql
UPDATE invoice_layouts 
SET show_logo = 1,
    logo = 'your-logo-filename.png'
WHERE id = 1;
```

### Tax Information Set Karne Ke Liye:

**Settings → Business Settings → Tax** mein jaaein:
- Tax Label 1: "VAT Number" ya "الرقم الضريبي"
- Tax Number 1: Apna 15-digit VAT number (e.g., 300000000000003)

## Colors Customize Karna

Agar aap colors change karna chahte hain:

1. **File open karein:** `resources/views/sale_pos/receipts/saudi-invoice.blade.php`
2. **CSS section mein jaaein** (style tag ke andar)
3. **Green color change karein:**
   - `#1a5f3f` → Apna color code
   - `#2d8659` → Apna color code

Example:
```css
/* Saudi green se blue change karne ke liye */
background: linear-gradient(135deg, #1a5f3f 0%, #2d8659 100%);
/* Change to: */
background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
```

## QR Code Size Change Karna

File mein yeh line dhundein:
```php
DNS2D::getBarcodePNG($receipt_details->qr_code_text, 'QRCODE', 6, 6)
```

Size change karein:
- **Bara karne ke liye:** `6, 6` → `8, 8`
- **Chota karne ke liye:** `6, 6` → `4, 4`

## Troubleshooting (Agar Problem Ho)

### QR Code Nahi Dikh Raha:

1. Check karein "Show QR Code" enabled hai
2. QR code fields select kiye hain
3. Transaction status "final" hai
4. Diagnostic run karein: `http://127.0.0.1:8001/sells/{transaction_id}/diagnostic`

### Logo Nahi Dikh Raha:

1. "Show Logo" enabled hai?
2. Logo file exist karti hai `public/uploads/invoice_logos/` mein?
3. File ka naam database mein sahi hai?

### Design Apply Nahi Ho Raha:

1. Cache clear karein:
   ```bash
   php artisan cache:clear
   php artisan view:clear
   ```

2. Database check karein:
   ```sql
   SELECT design FROM invoice_layouts WHERE id = 1;
   ```
   Result: `saudi-invoice` hona chahiye

### Arabic Text Sahi Nahi Dikh Raha:

1. Browser encoding UTF-8 hai?
2. Database charset UTF-8 hai?
3. Font Arabic support karta hai?

## Quick Commands

### Current design check karne ke liye:
```sql
SELECT id, name, design, show_logo, show_qr_code FROM invoice_layouts;
```

### Saudi design set karne ke liye:
```sql
UPDATE invoice_layouts SET design = 'saudi-invoice' WHERE id = 1;
```

### Logo aur QR enable karne ke liye:
```sql
UPDATE invoice_layouts SET show_logo = 1, show_qr_code = 1 WHERE id = 1;
```

### Sab kuch ek saath set karne ke liye:
```sql
UPDATE invoice_layouts 
SET design = 'saudi-invoice',
    show_logo = 1,
    show_qr_code = 1,
    show_barcode = 0,
    qr_code_fields = '["business_name","tax_1","invoice_no","invoice_datetime","total_amount","customer_name"]',
    invoice_heading = 'فاتورة ضريبية / TAX INVOICE'
WHERE id = 1;
```

## ZATCA Compliance (Saudi Tax Authority)

Agar aapko ZATCA compliant QR code chahiye:

1. **Settings → Invoice Layouts** mein jaaein
2. **"ZATCA QR Code"** option enable karein
3. **ZATCA Phase** select karein (Phase 1 ya Phase 2)
4. **VAT number** properly set karein (15 digits)

ZATCA QR code automatically generate hoga with:
- Business name (Arabic)
- VAT registration number
- Invoice date/time
- Total amount with VAT
- VAT amount

## Testing Checklist

Sale complete karne ke baad check karein:

- [ ] Invoice open ho raha hai?
- [ ] Logo dikh raha hai (upar)?
- [ ] Company name aur address sahi hai?
- [ ] VAT number yellow box mein hai?
- [ ] Items table properly formatted hai?
- [ ] QR code dikh raha hai (neeche right side)?
- [ ] Totals sahi calculate ho rahe hain?
- [ ] Payment details show ho rahe hain?
- [ ] Colors green theme mein hain?
- [ ] Arabic aur English dono languages hain?

## Summary

**3 Simple Steps:**
1. SQL script run karein (`setup_saudi_invoice.sql`)
2. Logo upload karein (Settings → Invoice Layouts)
3. Test sale karein aur invoice check karein

**Result:** Professional Saudi-style invoice with logo, QR code, bilingual text, aur green theme! 🇸🇦

Agar koi problem ho to diagnostic tool use karein:
```
http://127.0.0.1:8001/sells/{transaction_id}/diagnostic
```

Yeh aapko exactly batayega kya issue hai aur kaise fix karna hai.

**Enjoy your professional invoices!** ✨
