<?php

namespace KupShop\OrderingBundle\Entity\Purchase;

use KupShop\KupShopBundle\Util\Price\Price;
use KupShop\OrderingBundle\Util\Order\OrderItemInfo;

class DiscountPurchaseItem extends AbstractPurchaseItem implements PurchaseItemInterface
{
    public $id_discount;

    protected $type = OrderItemInfo::TYPE_DISCOUNT;

    public function __construct($name, Price $price, $id_discount, ?array $note = null)
    {
        $this->name = $name;
        $this->price = $price;
        $this->id_discount = $id_discount;
        $this->note = $note;
    }

    public function getName()
    {
        return $this->name;
    }

    public function getPriceWithVat(): \Decimal
    {
        return $this->price->getPriceWithVat(false)->value(2);
    }

    public function getPriceWithoutVat(): \Decimal
    {
        return $this->getPriceWithVat()->removeVat($this->price->getVat());
    }

    public function getIdDiscount()
    {
        return $this->id_discount;
    }
}
