removed all references to credits. now credits are completely replaced by addons.

This commit is contained in:
Codex Agent
2025-12-01 15:50:17 +01:00
parent b8e515a03c
commit 28539754a7
76 changed files with 97 additions and 2533 deletions

View File

@@ -142,7 +142,6 @@ class CheckoutAssignmentService
'email' => $user->email,
'is_active' => true,
'is_suspended' => false,
'event_credits_balance' => 0,
'subscription_tier' => 'free',
'subscription_status' => 'active',
'settings' => [

View File

@@ -16,33 +16,37 @@ class PackageLimitEvaluator
$package = $tenant->getActiveResellerPackage();
if ($package) {
$limit = $package->package->max_events_per_year ?? 0;
if (! $package) {
return [
'code' => 'event_limit_exceeded',
'title' => 'Event quota reached',
'message' => 'Your current package has no remaining event slots. Please upgrade or renew your subscription.',
'code' => 'event_limit_missing',
'title' => 'No package assigned',
'message' => 'Assign a package or addon to create events.',
'status' => 402,
'meta' => [
'scope' => 'events',
'used' => (int) $package->used_events,
'limit' => $limit,
'remaining' => max(0, $limit - $package->used_events),
'tenant_package_id' => $package->id,
'package_id' => $package->package_id,
'used' => 0,
'limit' => 0,
'remaining' => 0,
'tenant_package_id' => null,
'package_id' => null,
],
];
}
$limit = $package->package->max_events_per_year ?? 0;
return [
'code' => 'event_credits_exhausted',
'title' => 'No event credits remaining',
'message' => 'You have no event credits remaining. Purchase additional credits or a package to create new events.',
'code' => 'event_limit_exceeded',
'title' => 'Event quota reached',
'message' => 'Your current package has no remaining event slots. Please upgrade or renew your subscription.',
'status' => 402,
'meta' => [
'scope' => 'credits',
'balance' => (int) ($tenant->event_credits_balance ?? 0),
'scope' => 'events',
'used' => (int) $package->used_events,
'limit' => $limit,
'remaining' => max(0, $limit - $package->used_events),
'tenant_package_id' => $package->id,
'package_id' => $package->package_id,
],
];
}

View File

@@ -17,7 +17,6 @@ class TenantNotificationPreferences
'event_limits' => true,
'package_expiring' => true,
'package_expired' => true,
'credits_low' => true,
];
public static function defaults(): array

View File

@@ -2,7 +2,6 @@
namespace App\Services\Packages;
use App\Events\Packages\TenantCreditsLow;
use App\Events\Packages\TenantPackageEventLimitReached;
use App\Events\Packages\TenantPackageEventThresholdReached;
use App\Models\Tenant;
@@ -66,32 +65,4 @@ class TenantUsageTracker
$this->dispatcher->dispatch(new TenantPackageEventLimitReached($tenantPackage, $limit));
}
}
public function recordCreditBalance(Tenant $tenant, int $previousBalance, int $newBalance): void
{
$thresholds = collect(config('package-limits.credit_thresholds', []))
->filter(fn ($value) => is_numeric($value) && $value >= 0)
->map(fn ($value) => (int) $value)
->sortDesc()
->values();
$currentThreshold = $tenant->credit_warning_threshold ?? null;
foreach ($thresholds as $threshold) {
if ($previousBalance > $threshold && $newBalance <= $threshold) {
if ($currentThreshold !== null && $threshold >= $currentThreshold) {
continue;
}
$tenant->forceFill([
'credit_warning_sent_at' => now(),
'credit_warning_threshold' => $threshold,
])->save();
$this->dispatcher->dispatch(new TenantCreditsLow($tenant, $newBalance, $threshold));
break;
}
}
}
}