<?php

namespace AppBundle\Entity\Product;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Dunglas\ApiBundle\Annotation\Iri;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Entity\Traits\TimestampableEntity;
use AppBundle\Entity\Traits\CreatorUpdaterEntity;

/**
 * Prix et application d'éventuelles réductions sur un Intangible
 *
 * @Iri("http://schema.org/IntangiblePriceAndDiscount")
 */
#[ORM\Entity]
class IntangiblePriceAndDiscount
{
    use TimestampableEntity;
    use CreatorUpdaterEntity;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer')]
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[Groups(['intangiblepriceanddiscount', 'educational_project_intangible_list', 'access_intangible_list', 'intangible_list'])]
    private $id;
    /**
     * @var string
     */
    #[ORM\Column(type: 'string', nullable: true)]
    #[Assert\Type(type: 'string')]
    #[Assert\Choice(callback: ['AppBundle\Enum\Product\IntangibleAmountTypeEnum', 'toArray'])]
    #[Groups(['intangiblepriceanddiscount', 'educational_project_intangible_list_intangiblepriceanddiscount', 'access_intangible_list_intangiblepriceanddiscount', 'intangible_list_intangiblepriceanddiscount', 'access_intangible_list_intangible'])]
    private $amountType;
    /**
     * @var bool
     */
    #[ORM\Column(type: 'boolean', options: ['default' => true])]
    #[Assert\Type(type: 'boolean')]
    #[Assert\NotNull]
    #[Groups(['intangiblepriceanddiscount', 'educational_project_intangible_list_intangiblepriceanddiscount', 'access_intangible_list_intangiblepriceanddiscount', 'intangible_list_intangiblepriceanddiscount', 'access_intangible_list_intangible'])]
    private $applyDiscount = true;
    /**
     * @var ArrayCollection<IntangibleDiscountDetail>
     */
    #[Assert\Valid]
    #[ORM\OneToMany(targetEntity: 'IntangibleDiscountDetail', mappedBy: 'intangiblePriceAndDiscount', cascade: ['persist'], orphanRemoval: true)]
    #[Groups(['intangiblepriceanddiscount_intangiblediscountdetail'])]
    private $intangibleDiscountDetails;
    /**
     * @var float
     */
    #[ORM\Column(type: 'float', nullable: true)]
    #[Assert\Type(type: 'float')]
    #[Groups(['intangiblepriceanddiscount', 'educational_project_intangible_list_intangiblepriceanddiscount', 'access_intangible_list_intangiblepriceanddiscount'])]
    private $price;
    /**
     * @var bool
     */
    #[ORM\Column(type: 'boolean', options: ['default' => true])]
    #[Assert\Type(type: 'boolean')]
    #[Assert\NotNull]
    #[Groups(['intangiblepriceanddiscount'])]
    private $automaticDiscountCalculation = true;
    /**
     * Sets id.
     *
     * @param int $id
     *
     * @return $this
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }
    /**
     * Gets id.
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->intangibleDiscountDetail = new ArrayCollection();
    }
    /**
     * Set amountType
     *
     * @param string $amountType
     *
     * @return IntangiblePriceAndDiscount
     */
    public function setAmountType($amountType)
    {
        $this->amountType = $amountType;

        return $this;
    }
    /**
     * Get amountType
     *
     * @return string
     */
    public function getAmountType()
    {
        return $this->amountType;
    }
    /**
     * Set applyDiscount
     *
     * @param boolean $applyDiscount
     *
     * @return IntangiblePriceAndDiscount
     */
    public function setApplyDiscount($applyDiscount)
    {
        $this->applyDiscount = $applyDiscount;

        return $this;
    }
    /**
     * Get applyDiscount
     *
     * @return boolean
     */
    public function getApplyDiscount()
    {
        return $this->applyDiscount;
    }
    /**
     * Set price
     *
     * @param float $price
     *
     * @return IntangiblePriceAndDiscount
     */
    public function setPrice($price)
    {
        $this->price = floatval($price);

        return $this;
    }
    /**
     * Get price
     *
     * @return float
     */
    public function getPrice()
    {
        return $this->price;
    }
    /**
     * Add intangibleDiscountDetail
     *
     * @param \AppBundle\Entity\Product\IntangibleDiscountDetail $intangibleDiscountDetail
     *
     * @return IntangiblePriceAndDiscount
     */
    public function addIntangibleDiscountDetail(\AppBundle\Entity\Product\IntangibleDiscountDetail $intangibleDiscountDetail)
    {
        $intangibleDiscountDetail->setIntangiblePriceAndDiscount($this);
        $this->intangibleDiscountDetails[] = $intangibleDiscountDetail;

        return $this;
    }
    /**
     * Remove intangibleDiscountDetail
     *
     * @param \AppBundle\Entity\Product\IntangibleDiscountDetail $intangibleDiscountDetail
     */
    public function removeIntangibleDiscountDetail(\AppBundle\Entity\Product\IntangibleDiscountDetail $intangibleDiscountDetail)
    {
        $this->intangibleDiscountDetails->removeElement($intangibleDiscountDetail);
    }
    /**
     * Get intangibleDiscountDetails
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getIntangibleDiscountDetails()
    {
        return $this->intangibleDiscountDetails;
    }
    /**
     * Set automaticDiscountCalculation
     *
     * @param boolean $automaticDiscountCalculation
     *
     * @return IntangiblePriceAndDiscount
     */
    public function setAutomaticDiscountCalculation($automaticDiscountCalculation)
    {
        $this->automaticDiscountCalculation = $automaticDiscountCalculation;

        return $this;
    }
    /**
     * Get automaticDiscountCalculation
     *
     * @return boolean
     */
    public function getAutomaticDiscountCalculation()
    {
        return $this->automaticDiscountCalculation;
    }
}
