<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Services\Billing\DunningService;
use Illuminate\Console\Command;

class ProcessDunning extends Command
{
    protected $signature = 'billing:process-dunning';

    protected $description = 'Suspend overdue subscriptions and terminate long-suspended services';

    public function handle(DunningService $dunningService): int
    {
        $suspended = $dunningService->suspendOverdueSubscriptions();
        $this->info("Suspended services for {$suspended} overdue subscriptions.");

        $terminated = $dunningService->terminateLongSuspendedSubscriptions();
        $this->info("Terminated {$terminated} long-suspended services.");

        return self::SUCCESS;
    }
}
