fix financial and certificates

This commit is contained in:
root
2026-06-05 01:51:08 -04:00
parent d28d11e2e5
commit ad968eaff7
94 changed files with 9654 additions and 214 deletions
@@ -0,0 +1,43 @@
<?php
namespace App\Services\Promotions\Placement;
use App\Models\Configuration;
use Illuminate\Support\Facades\Log;
use RuntimeException;
class PromotionSectionCapacityService
{
public const CONFIG_KEY = 'promotion.section_capacity';
public const DEFAULT_CAPACITY = 20;
public function capacity(): array
{
$raw = Configuration::getConfigValueByKey(self::CONFIG_KEY);
$usedDefault = false;
if ($raw === null || trim((string) $raw) === '') {
$usedDefault = true;
Log::warning('Missing promotion section capacity configuration; using fallback.', [
'config_key' => self::CONFIG_KEY,
'fallback' => self::DEFAULT_CAPACITY,
]);
$value = self::DEFAULT_CAPACITY;
} elseif (!ctype_digit((string) $raw)) {
throw new RuntimeException('promotion.section_capacity must be a positive integer.');
} else {
$value = (int) $raw;
}
if ($value <= 0) {
throw new RuntimeException('promotion.section_capacity must be greater than zero.');
}
return [
'key' => self::CONFIG_KEY,
'value' => $value,
'used_default' => $usedDefault,
'warnings' => $usedDefault ? ['promotion.section_capacity missing; fallback capacity 20 used.'] : [],
];
}
}