<?php

namespace App\Modules\CommercialInvoice\Application\Update;

use App\Modules\Booking\Domain\IdBooking;
use App\Modules\BookingExtraPassenger\Domain\IdBookingExtraPassenger;
use App\Modules\BookingUpgradePassenger\Domain\IdBookingUpgradePassenger;
use App\Modules\CommercialInvoice\Domain\CommercialInvoiceAmountWithIgv;
use App\Modules\CommercialInvoice\Domain\CommercialInvoiceAmountWithoutIgv;
use App\Modules\CommercialInvoice\Domain\CommercialInvoiceCodeReservation;
use App\Modules\CommercialInvoice\Domain\CommercialInvoiceIssueDate;
use App\Modules\CommercialInvoice\Domain\CommercialInvoiceNumberSerie;
use App\Modules\CommercialInvoice\Domain\CommercialInvoiceStatus;
use App\Modules\CommercialInvoice\Domain\CommercialInvoiceType;
use App\Modules\CommercialInvoice\Domain\CommercialInvoiceVersion;
use App\Modules\CommercialInvoice\Domain\IdCommercialInvoice;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;

final class UpdateCommercialInvoiceQueryHandler implements QueryHandler
{
    public function __construct(private CommercialInvoiceUpdater $updater) {}

    public function __invoke(UpdateCommercialInvoiceQuery $query): UpdateCommercialInvoiceResponse
    {
        $this->updater->__invoke(
            new IdCommercialInvoice($query->id()),
            new CommercialInvoiceVersion($query->version()),
            new CommercialInvoiceIssueDate($query->issueDate()),
            new CommercialInvoiceCodeReservation($query->codeReservation()),
            new CommercialInvoiceNumberSerie($query->numberSerie()),
            new CommercialInvoiceType($query->type()),
            new CommercialInvoiceAmountWithoutIgv($query->amountWithoutIgv()),
            new CommercialInvoiceAmountWithIgv($query->amountWithIgv()),
            new CommercialInvoiceStatus($query->status()),
            new IdBookingUpgradePassenger($query->idBookingUpgradePassenger()),
            new IdBookingExtraPassenger($query->idBookingExtraPassenger()),
            new IdBooking($query->idBooking()),
            $query->idAdmin()
        );
        return new UpdateCommercialInvoiceResponse();
    }
}
