diff --git a/app/Middleware/QuotaMiddleware.php b/app/Middleware/QuotaMiddleware.php index 6eb38d0..fa09e02 100644 --- a/app/Middleware/QuotaMiddleware.php +++ b/app/Middleware/QuotaMiddleware.php @@ -73,7 +73,7 @@ final class QuotaMiddleware $used = (int)$sub['invoices_used_this_month']; $limit = (int)$sub['max_invoices_per_month']; - if ($used >= $limit && false) { // BYPASS QUOTA FOR TESTING + if ($used >= $limit) { json_error('لقد وصلت للحد الأقصى من الفواتير المسموحة هذا الشهر (' . $limit . ' فاتورة). يرجى ترقية باقتك.', 429, [ 'quota_type' => 'invoices', 'used' => $used, diff --git a/app/middleware/QuotaMiddleware.php b/app/middleware/QuotaMiddleware.php index 6eb38d0..fa09e02 100644 --- a/app/middleware/QuotaMiddleware.php +++ b/app/middleware/QuotaMiddleware.php @@ -73,7 +73,7 @@ final class QuotaMiddleware $used = (int)$sub['invoices_used_this_month']; $limit = (int)$sub['max_invoices_per_month']; - if ($used >= $limit && false) { // BYPASS QUOTA FOR TESTING + if ($used >= $limit) { json_error('لقد وصلت للحد الأقصى من الفواتير المسموحة هذا الشهر (' . $limit . ' فاتورة). يرجى ترقية باقتك.', 429, [ 'quota_type' => 'invoices', 'used' => $used, diff --git a/public/shell.php b/public/shell.php index 2560064..52abc74 100644 --- a/public/shell.php +++ b/public/shell.php @@ -1751,14 +1751,20 @@ x-text="parseFloat(inv.grand_total).toLocaleString() + ' JOD'"> + :class="inv.status==='extracted' ? 'badge-blue' : (inv.status==='approved' ? 'badge-teal' : (inv.status==='submitted' ? 'badge-purple' : (inv.status==='rejected'||inv.status==='failed'?'badge-red':'badge-gray')))" + x-text="inv.status === 'approved' ? '✓ مدققة' : (inv.status === 'submitted' ? '🚀 مُرسلة للفوترة' : (inv.status === 'extracted' ? 'جاهزة للتدقيق' : (inv.status === 'rejected' ? 'مرفوضة' : inv.status)))"> + @@ -3230,6 +3236,29 @@ } }, + async submitToJoFotara(id) { + if (this.isBusy) return; + this.isBusy = true; + try { + const res = await fetch('/index.php?route=v1/invoices/submit-jofotara', { + method: 'POST', + headers: { 'Authorization': 'Bearer ' + this.token(), 'Content-Type': 'application/json' }, + body: JSON.stringify({ invoice_id: id }) + }); + const json = await res.json(); + this.isBusy = false; + if (json.success) { + alert('تم إرسال الفاتورة لجوفتورة بنجاح!'); + this.loadAll(); + } else { + this.showError(json.message); + } + } catch (e) { + this.isBusy = false; + this.showError('حدث خطأ أثناء الإرسال لجوفتورة'); + } + }, + async updateInvoice() { if (!this.currentInvoice || this.isBusy) return; this.isBusy = true;