<?php
namespace App\V4\Model\QuoteLine;
use ApiPlatform\Core\Annotation\ApiProperty;
use App\Model\IriNormalizableInterface;
use App\Model\NormalizeAsIRITrait;
use App\Model\Traits\BlamableTrait;
use App\Model\Traits\ImportableObjectTrait;
use App\Model\Traits\TimestampableTrait;
use App\V4\Model\FormatNumberTrait;
use App\V4\Model\Quote\Quote;
use App\V4\Model\QuoteLineInfo\QuoteLineInfo;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
class QuoteLine implements IriNormalizableInterface
{
public const DEFAULT_VAT_RATE_VALUE = '20.00';
public const DISCOUNT_TYPE_PERCENTAGE = 'percentage';
public const DISCOUNT_TYPE_AMOUNT = 'amount';
use TimestampableTrait;
use BlamableTrait;
use ImportableObjectTrait;
use NormalizeAsIRITrait;
use FormatNumberTrait;
/**
* @ApiProperty(identifier=true)
*
* @var string|null
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update", "quote:regenerate"})
*/
private $id;
/**
* @var Quote|null
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $quote;
/**
* @var QuoteLineInfo|null
*
* @Groups({"list", "new", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $quoteLineInfo;
/**
* @var string|null
*
* @Assert\NotBlank(
* message="validation_required"
* )
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $name;
/**
* @var string|null
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $reference;
/**
* @var string|null
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $comment;
/**
* @var string
*
* @Assert\GreaterThanOrEqual(0)
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update", "quote:regenerate"})
*/
private $unitPriceExclVat = '0.00';
/**
* @var int
*
* @Assert\GreaterThan(0)
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $quantity = 0;
/**
* @var string|null
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $discountType;
/**
* @var string
*
* @Assert\GreaterThanOrEqual(0)
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $discountValue = '0.00';
/**
* @var string
*/
private $discountAmount = '0.00';
/**
* @var string
*
* @Groups({"list", "new", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $vatRate = self::DEFAULT_VAT_RATE_VALUE;
/**
* @var string
*
* @Groups({"list", "new", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $vatAmount = '0.00';
/**
* @var string
*
* @Groups({"quote:regenerate"})
*/
private $totalExclDiscountAndVat = '0.00';
/**
* @var string
*
* @Groups({"quote:regenerate"})
*/
private $totalExclDiscount = '0.00';
/**
* @var string
*
* @Groups({"quote:regenerate"})
*/
private $totalExclVat = '0.00';
/**
* @var string
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $vatAmountExclDiscount = '0.00';
/**
* @var string
*
* @Groups({"quote:regenerate"})
*/
private $total = '0.00';
/**
* @var bool
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $isOptional = false;
/**
* @var string|null
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $sectionName;
/**
* @var int|null
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $position;
/**
* @var string|null
*
* @Groups({"list", "write_post_quote", "quote:write", "quote:read", "quote:update"})
*/
private $description;
/**
* @return string
*/
public function __toString(): string
{
return $this->id ?? '';
}
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
/**
* @param string|null $id
*
* @return self
*/
public function setId(?string $id): self
{
$this->id = $id;
return $this;
}
/**
* @return Quote|null
*/
public function getQuote(): ?Quote
{
return $this->quote;
}
/**
* @param Quote|null $quote
*
* @return self
*/
public function setQuote(?Quote $quote): self
{
$this->quote = $quote;
return $this;
}
/**
* @return QuoteLineInfo|null
*/
public function getQuoteLineInfo(): ?QuoteLineInfo
{
return $this->quoteLineInfo;
}
/**
* @param QuoteLineInfo|null $quoteLineInfo
*
* @return self
*/
public function setQuoteLineInfo(?QuoteLineInfo $quoteLineInfo): self
{
$this->quoteLineInfo = $quoteLineInfo;
return $this;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string|null $name
*
* @return self
*/
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return string|null
*/
public function getReference(): ?string
{
return $this->reference;
}
/**
* @param string|null $reference
*
* @return self
*/
public function setReference(?string $reference): self
{
$this->reference = $reference;
return $this;
}
/**
* @return string|null
*/
public function getComment(): ?string
{
return $this->comment;
}
/**
* @param string|null $comment
*
* @return self
*/
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
/**
* @return string
*/
public function getUnitPriceExclVat(): string
{
return $this->formatNumber($this->unitPriceExclVat, 2);
}
/**
* @param string $unitPriceExclVat
*
* @return self
*/
public function setUnitPriceExclVat(string $unitPriceExclVat): self
{
$this->unitPriceExclVat = $unitPriceExclVat;
return $this;
}
/**
* @return int
*/
public function getQuantity(): int
{
return $this->quantity;
}
/**
* @param int $quantity
*
* @return self
*/
public function setQuantity(int $quantity): self
{
$this->quantity = $quantity;
return $this;
}
/**
* @return string|null
*/
public function getDiscountType(): ?string
{
return $this->discountType;
}
/**
* @param string|null $discountType
*
* @return self
*/
public function setDiscountType(?string $discountType): self
{
$this->discountType = $discountType;
return $this;
}
/**
* @return string
*/
public function getDiscountValue(): string
{
return $this->formatNumber($this->discountValue, 2);
}
/**
* @param string $discountValue
*
* @return self
*/
public function setDiscountValue(string $discountValue): self
{
$this->discountValue = $discountValue;
return $this;
}
/**
* @return string
*/
public function getDiscountAmount(): string
{
return $this->formatNumber($this->discountAmount, 2);
}
/**
* @param string $discountAmount
*
* @return self
*/
public function setDiscountAmount(string $discountAmount): self
{
$this->discountAmount = $discountAmount;
return $this;
}
public function getVatRate(): string
{
return $this->vatRate;
}
public function setVatRate(string $vatRate): self
{
$this->vatRate = $vatRate;
return $this;
}
public function getVatAmount(): string
{
return $this->formatNumber($this->vatAmount, 2);
}
public function setVatAmount(string $vatAmount): self
{
$this->vatAmount = $vatAmount;
return $this;
}
/**
* @return string
*/
public function getTotalExclDiscountAndVat(): string
{
return $this->formatNumber($this->totalExclDiscountAndVat, 2);
}
/**
* @param string $totalExclDiscountAndVat
*
* @return self
*/
public function setTotalExclDiscountAndVat(string $totalExclDiscountAndVat): self
{
$this->totalExclDiscountAndVat = $totalExclDiscountAndVat;
return $this;
}
/**
* @return string
*/
public function getTotalExclDiscount(): string
{
return $this->formatNumber($this->totalExclDiscount, 2);
}
/**
* @param string $totalExclDiscount
*
* @return self
*/
public function setTotalExclDiscount(string $totalExclDiscount): self
{
$this->totalExclDiscount = $totalExclDiscount;
return $this;
}
/**
* @return string
*/
public function getTotalExclVat(): string
{
return $this->formatNumber($this->totalExclVat, 2);
}
/**
* @param string $totalExclVat
*
* @return self
*/
public function setTotalExclVat(string $totalExclVat): self
{
$this->totalExclVat = $totalExclVat;
return $this;
}
/**
* @return string
*/
public function getVatAmountExclDiscount(): string
{
return $this->formatNumber($this->vatAmountExclDiscount, 2);
}
/**
* @param string $vatAmountExclDiscount
*
* @return $this
*/
public function setVatAmountExclDiscount(string $vatAmountExclDiscount): self
{
$this->vatAmountExclDiscount = $vatAmountExclDiscount;
return $this;
}
/**
* @return string
*/
public function getTotal(): string
{
return $this->formatNumber($this->total, 2);
}
/**
* @param string $total
*
* @return self
*/
public function setTotal(string $total): self
{
$this->total = $total;
return $this;
}
/**
* @return bool
*/
public function getIsOptional(): bool
{
return $this->isOptional;
}
/**
* @param bool $isOptional
*
* @return self
*/
public function setIsOptional(bool $isOptional): self
{
$this->isOptional = $isOptional;
return $this;
}
/**
* @return string|null
*/
public function getSectionName(): ?string
{
return $this->sectionName;
}
/**
* @param string|null $sectionName
*
* @return QuoteLine
*/
public function setSectionName(?string $sectionName): self
{
$this->sectionName = $sectionName;
return $this;
}
/**
* @return string|null
*/
public function getDescription(): ?string
{
return $this->description;
}
/**
* @param string|null $description
*
* @return $this
*/
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(int $position): self
{
$this->position = $position;
return $this;
}
}