fix: bypass invoice quota checks for super_admin in all upload and creation endpoints

This commit is contained in:
Hamza-Ayed
2026-05-15 23:41:48 +03:00
parent 3f0534ba0d
commit a98a5abcce
2 changed files with 9 additions and 5 deletions

View File

@@ -53,11 +53,13 @@ if ($decoded['role'] !== 'super_admin' && $company['tenant_id'] !== $tenantId) {
$targetTenantId = $company['tenant_id']; $targetTenantId = $company['tenant_id'];
// 3. Check quota (preview — don't increment yet) // 3. Check quota (preview — don't increment yet)
if ($decoded['role'] !== 'super_admin') {
try { try {
QuotaMiddleware::checkInvoiceQuota($targetTenantId); QuotaMiddleware::checkInvoiceQuota($targetTenantId);
} catch (\Exception $e) { } catch (\Exception $e) {
json_error('تم استنفاد رصيد الفواتير لهذا الشهر. قم بترقية باقتك.', 429); json_error('تم استنفاد رصيد الفواتير لهذا الشهر. قم بترقية باقتك.', 429);
} }
}
// 4. Generate batch ID // 4. Generate batch ID
$batchId = vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(random_bytes(16)), 4)); $batchId = vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(random_bytes(16)), 4));

View File

@@ -50,7 +50,9 @@ try {
try { try {
// Check quota for each invoice (preventive) // Check quota for each invoice (preventive)
if ($decoded['role'] !== 'super_admin') {
QuotaMiddleware::checkInvoiceQuota($tenantId); QuotaMiddleware::checkInvoiceQuota($tenantId);
}
$invoiceData = [ $invoiceData = [
'id' => Database::generateUuid(), 'id' => Database::generateUuid(),