<?php

namespace App\Console\Commands\V2;


use App\Classes\Jobs\Commands\V2\CreateInvoiceTransactionV2CommandJob;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Classes\ValueObjects\Constants\TransactionType;
use Illuminate\Console\Command;
use App\Models\Booking;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Log;

class TestCreateEInvoiceV2Command extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */

    protected $signature = 'test-create-einvoice-command';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Test Create E-Invoices';


    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        // $bookings = Booking::whereIn('marking', ['644794'])->get();
        $bookings = Booking::whereIn('marking', ['507945'])->get();

        $count = 0;
        foreach ($bookings as $booking) {
            CreateInvoiceTransactionV2CommandJob::dispatch($booking);
            $count++;
            Log::info('Processed: ' . $count);
            Log::info('Booking ID: ' . $booking->marking . ' for E-Invoice ');
        }
    }
}
