OrderInvoiceStatus.php 1.65 KB
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
<?php
/**
 * @copyright  Vertex. All rights reserved.  https://www.vertexinc.com/
 * @author     Mediotype                     https://www.mediotype.com/
 */

namespace Vertex\Tax\Model\Data;

use Magento\Framework\Model\AbstractModel;
use Vertex\Tax\Model\ResourceModel\OrderInvoiceStatus as ResourceModel;

/**
 * Model for storage of the invoice sent flag on the order level
 *
 * This model is primarily used to prevent double commits to the Tax Log while an Order goes through statuses
 */
class OrderInvoiceStatus extends AbstractModel
{
    const FIELD_ID = ResourceModel::FIELD_ID;
    const FIELD_SENT = ResourceModel::FIELD_SENT;

    /**
     * {@inheritdoc}
     *
     * MEQP2 Warning: Protected method.  Needed to override AbstractDb's _construct
     */
    protected function _construct()
    {
        $this->_init(ResourceModel::class);
    }

    /**
     * Retrieve ID of Order with sent status
     *
     * @return int|null
     */
    public function getOrderId()
    {
        return $this->getId();
    }

    /**
     * Set ID of Order with sent status
     *
     * @param int $orderId
     * @return OrderInvoiceStatus
     */
    public function setOrderId($orderId)
    {
        return $this->setId($orderId);
    }

    /**
     * Retrieve status of Order being sent to Vertex
     *
     * @return bool|null
     */
    public function isSent()
    {
        return $this->getData(static::FIELD_SENT);
    }

    /**
     * Set status of Order being sent to Vertex
     *
     * @param bool $isSent
     * @return OrderInvoiceStatus
     */
    public function setIsSent($isSent)
    {
        return $this->setData(static::FIELD_SENT, (bool)$isSent);
    }
}