<?php

namespace App\Classes\Modules\Bookings\DataTransferObjects;

use App\Classes\General\Interfaces\DataTransferObject;

class UpdateBookingSalesInvoiceDTO implements DataTransferObject
{
    private ?string $docNo;
    private ?string $docDate;
    private ?string $debtorCode;
    private ?string $ref;
    private ?string $shipInfo;
    private ?string $accNo;
    private ?string $detailDescription;
    private ?string $furtherDescription;
    private ?string $classification;
    private ?string $deptNo;
    private float $qty;
    private float $unitPrice;
    private bool $submitEinvoice;
    private bool $consolidatedEinvoice;
    private ?string $einvoiceValidationLink;

    public function __construct(array $data)
    {
        $this->docNo = $data['docno'];
        $this->docDate = $data['docdate'];
        $this->debtorCode = $data['debtorcode'];
        $this->ref = $data['ref'] ?? null;
        $this->shipInfo = $data['shipinfo'] ?? null;
        $this->accNo = $data['accno'] ?? null;
        $this->detailDescription = $data['detaildescription'] ?? null;
        $this->furtherDescription = $data['furtherdescription'] ?? null;
        $this->classification = $data['classification'] ?? null;
        $this->deptNo = $data['deptno'] ?? null;
        $this->qty = (float) ($data['qty'] ?? 0);
        $this->unitPrice = (float) ($data['unitprice'] ?? 0);
        $this->submitEinvoice = filter_var($data['submiteinvoice'] ?? false, FILTER_VALIDATE_BOOLEAN);
        $this->consolidatedEinvoice = filter_var($data['consolidatedeinvoice'] ?? false, FILTER_VALIDATE_BOOLEAN);
        $this->einvoiceValidationLink = $data['einvoicevalidationlink'] ?? null;
    }

    /**
     * @return string|null
     */
    public function getDocNo(): ?string
    {
        return $this->docNo;
    }

    /**
     * @return string|null
     */
    public function getDocDate(): ?string
    {
        return $this->docDate;
    }

    /**
     * @return string|null
     */
    public function getDebtorCode(): ?string
    {
        return $this->debtorCode;
    }

    /**
     * @return string|null
     */
    public function getRef(): ?string
    {
        return $this->ref;
    }

    /**
     * @return string|null
     */
    public function getShipInfo(): ?string
    {
        return $this->shipInfo;
    }

    /**
     * @return string|null
     */
    public function getAccNo(): ?string
    {
        return $this->accNo;
    }

    /**
     * @return string|null
     */
    public function getDetailDescription(): ?string
    {
        return $this->detailDescription;
    }

    /**
     * @return string|null
     */
    public function getFurtherDescription(): ?string
    {
        return $this->furtherDescription;
    }

    /**
     * @return string|null
     */
    public function getClassification(): ?string
    {
        return $this->classification;
    }

    /**
     * @return string|null
     */
    public function getDeptNo(): ?string
    {
        return $this->deptNo;
    }

    /**
     * @return float
     */
    public function getQty(): float
    {
        return $this->qty;
    }

    /**
     * @return float
     */
    public function getUnitPrice(): float
    {
        return $this->unitPrice;
    }

    /**
     * @return bool
     */
    public function getSubmitEinvoice(): bool
    {
        return $this->submitEinvoice;
    }

    /**
     * @return bool
     */
    public function getConsolidatedEinvoice(): bool
    {
        return $this->consolidatedEinvoice;
    }

    /**
     * @return string|null
     */
    public function getEinvoiceValidationLink(): ?string
    {
        return $this->einvoiceValidationLink;
    }

    public function toArray(): array
    {
        return [
            'docno' => $this->docNo,
            'docdate' => $this->docDate,
            'debtorcode' => $this->debtorCode,
            'ref' => $this->ref,
            'shipinfo' => $this->shipInfo,
            'accno' => $this->accNo,
            'detaildescription' => $this->detailDescription,
            'furtherdescription' => $this->furtherDescription,
            'classification' => $this->classification,
            'deptno' => $this->deptNo,
            'qty' => $this->qty,
            'unitprice' => $this->unitPrice,
            'submiteinvoice' => $this->submitEinvoice,
            'consolidatedeinvoice' => $this->consolidatedEinvoice,
            'einvoicevalidationlink' => $this->einvoiceValidationLink,
        ];
    }
}
