File: /home/xedaptot/ai.naniguide.com/app/Notifications/System/InvoiceCounterReset.php
<?php
namespace App\Notifications\System;
use App\Notifications\AppNotification;
/**
* Invoice number counter (Setting 'invoice.current') was found at or below
* MAX(invoices.number) and was snapped up to MAX+1. Surfaces to admins so
* the reset is visible — root cause is usually DB restore, manual SQL, a
* plugin inserting invoices outside the counter, or a prior save failure
* that left the counter stuck.
*/
class InvoiceCounterReset extends AppNotification
{
public function __construct(
public int $from,
public int $to,
public int $maxExisting,
) {}
public function audience(): string { return self::AUDIENCE_ADMINS; }
public function category(): string { return self::CATEGORY_ALERT; }
public function severity(): string { return self::SEVERITY_WARNING; }
public function groupKey(): string { return 'invoice-counter-reset'; }
public function toArray(object $notifiable = null): array
{
return [
'title' => 'Invoice number counter reset',
'body' => sprintf(
'Invoice.current value is reset from %d to %d (max existing invoice number: %d).',
$this->from,
$this->to,
$this->maxExisting
),
'meta' => [
'from' => $this->from,
'to' => $this->to,
'max_existing' => $this->maxExisting,
],
];
}
}