<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class AutobillTenants extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'tenants:autobill {--force}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Automatically generate subscription invoices for tenants based on global settings.';

    /**
     * Execute the console command.
     */
    public function handle(\App\Services\CentralBillingService $billingService)
    {
        $force = $this->option('force');
        $this->info('Starting automated tenant billing' . ($force ? ' (FORCED)' : '') . '...');
        
        $billingService->runAutobilling($force);
        
        $this->info('Automated billing process check completed.');
        $this->comment('Check storage/logs/laravel.log for detailed processing logs.');
    }
}
