From a98a5abccee2cbfa9be85002436ba5f31bb78a1f Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Fri, 15 May 2026 23:41:48 +0300 Subject: [PATCH] fix: bypass invoice quota checks for super_admin in all upload and creation endpoints --- app/modules_app/batches/create.php | 10 ++++++---- app/modules_app/excel/import.php | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/modules_app/batches/create.php b/app/modules_app/batches/create.php index fae4831..4283b35 100644 --- a/app/modules_app/batches/create.php +++ b/app/modules_app/batches/create.php @@ -53,10 +53,12 @@ if ($decoded['role'] !== 'super_admin' && $company['tenant_id'] !== $tenantId) { $targetTenantId = $company['tenant_id']; // 3. Check quota (preview — don't increment yet) -try { - QuotaMiddleware::checkInvoiceQuota($targetTenantId); -} catch (\Exception $e) { - json_error('تم استنفاد رصيد الفواتير لهذا الشهر. قم بترقية باقتك.', 429); +if ($decoded['role'] !== 'super_admin') { + try { + QuotaMiddleware::checkInvoiceQuota($targetTenantId); + } catch (\Exception $e) { + json_error('تم استنفاد رصيد الفواتير لهذا الشهر. قم بترقية باقتك.', 429); + } } // 4. Generate batch ID diff --git a/app/modules_app/excel/import.php b/app/modules_app/excel/import.php index d1db626..7864af3 100644 --- a/app/modules_app/excel/import.php +++ b/app/modules_app/excel/import.php @@ -50,7 +50,9 @@ try { try { // Check quota for each invoice (preventive) - QuotaMiddleware::checkInvoiceQuota($tenantId); + if ($decoded['role'] !== 'super_admin') { + QuotaMiddleware::checkInvoiceQuota($tenantId); + } $invoiceData = [ 'id' => Database::generateUuid(),