<?php

declare(strict_types=1);

namespace External\HannahBundle\Feed\Wrapper;

class OrderWrapper extends \KupShop\OrderingBundle\Feed\Wrapper\OrderWrapper
{
    /** SAP datum vychystávání */
    public function field_sap_date_picking(): ?\DateTimeInterface
    {
        $timestamp = $this->object->getData('sapDatePicking');

        if ($timestamp) {
            $datetime = new \DateTime();

            return $datetime->setTimestamp((int) $timestamp);
        }

        return null;
    }

    /** SAP datum vyřízení */
    public function field_sap_date_handle(): ?\DateTimeInterface
    {
        if (!($timestamp = $this->object->getData('sapDatePrepared'))) {
            $timestamp = $this->object->getData('sapDateSent');
        }

        if ($timestamp) {
            $datetime = new \DateTime();

            return $datetime->setTimestamp((int) $timestamp);
        }

        return null;
    }

    /** SAP číslo objednávky */
    public function field_sap_invoice_number()
    {
        $invoiceNumber = $this->object->getData('sapInvoiceNumber');

        return $invoiceNumber;
    }
}
