feat(payments): add payments:restore-legacy-links

Walks the transitional link table and re-applies preserved draft-invoice
credit through the allocation service once an invoice leaves DRAFT, deleting
each link as it is restored. Mismatched links are reported and never
auto-applied. Supports --dry-run.
This commit is contained in:
Darko Gjorgjijoski
2026-08-22 14:27:26 +02:00
parent aaee3087b1
commit 31bfb7a0e9
3 changed files with 455 additions and 0 deletions
@@ -7,6 +7,7 @@ use App\Adapters\Receivables\MoneyPaymentExchangeRateRecorder;
use App\Adapters\Receivables\SalesInvoiceBalanceUpdater;
use App\Adapters\Receivables\SalesPaymentNumberAssigner;
use App\Domains\Receivables\Application\PaymentService;
use App\Domains\Receivables\Console\RestoreLegacyPaymentLinks;
use App\Domains\Receivables\Contracts\InvoiceBalanceUpdater;
use App\Domains\Receivables\Contracts\PaymentEmailSender;
use App\Domains\Receivables\Contracts\PaymentExchangeRateRecorder;
@@ -32,6 +33,10 @@ class ReceivablesServiceProvider extends ServiceProvider
public function boot(): void
{
$this->commands([
RestoreLegacyPaymentLinks::class,
]);
Gate::policy(Payment::class, PaymentPolicy::class);
Gate::policy(PaymentMethod::class, PaymentMethodPolicy::class);
$abilities = [