Update: 2026-05-09 17:09:49

This commit is contained in:
Hamza-Ayed
2026-05-09 17:09:49 +03:00
parent 47df9253f9
commit 32b9d829eb
6 changed files with 249 additions and 130 deletions

View File

@@ -2093,13 +2093,18 @@
</div>
<!-- QR Code -->
<div x-show="currentInvoice?.jofotara?.qr_image_uri || currentInvoice?.qr_code"
<div x-show="currentInvoice?.status === 'approved' || currentInvoice?.qr_code || currentInvoice?.jofotara?.qr_image_uri"
style="background:white; border:1px solid var(--border); border-radius:12px; padding:16px; display:flex; flex-direction:column; align-items:center; gap:8px;">
<div
style="font-size:11px; font-weight:700; color:var(--text-3); text-transform:uppercase; letter-spacing:0.07em;">
رمز QR الضريبي</div>
<img :src="getQrSrc(currentInvoice)" style="width:140px; height:140px; object-fit:contain;"
alt="QR Code">
<template x-if="getQrSrc(currentInvoice)">
<img :src="getQrSrc(currentInvoice)" style="width:140px; height:140px; object-fit:contain;"
alt="QR Code">
</template>
<div x-show="!getQrSrc(currentInvoice)" style="font-size:12px; color:var(--text-3); text-align:center;">
جاري توليد الرمز...
</div>
</div>
</div>
@@ -2412,15 +2417,27 @@
getQrSrc(inv) {
if (!inv) return '';
if (inv.jofotara?.qr_image_uri) return inv.jofotara.qr_image_uri;
if (inv.qr_code) {
if (inv.qr_code.startsWith('data:')) return inv.qr_code;
let qrData = inv.qr_code;
// If no QR data in DB but approved, generate a fallback data string
if (!qrData && inv.status === 'approved') {
qrData = `Invoice: ${inv.invoice_number || 'N/A'}\nSupplier: ${inv.supplier_name || 'N/A'}\nTotal: ${inv.grand_total || '0'} JOD\nDate: ${inv.invoice_date || ''}`;
}
if (qrData) {
if (qrData.startsWith('data:')) return qrData;
try {
const qr = new QRious({
value: inv.qr_code,
size: 250
value: qrData,
size: 300,
level: 'M'
});
return qr.toDataURL();
} catch (e) { return ''; }
} catch (e) {
console.error('QR Gen Error:', e);
return '';
}
}
return '';
},