src/Entity/InvoiceAutomation.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InvoiceAutomationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=InvoiceAutomationRepository::class)
  9.  */
  10. class InvoiceAutomation
  11. {
  12.     const STATE_INICIALIZED 'init';
  13.     const STATE_APPROVED 'approved';
  14.     const STATE_COMPLAINE 'complain';
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $invoiceNumber;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="invoices")
  27.      * @ORM\JoinColumn(nullable=false)
  28.      */
  29.     private $merchant;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private $merchantEmail;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      */
  37.     private $merchantPhone;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="invoices")
  40.      * @ORM\JoinColumn(nullable=false)
  41.      */
  42.     private $subscriber;
  43.     /**
  44.      * @ORM\Column(type="float")
  45.      */
  46.     private $amount;
  47.     /**
  48.      * @ORM\Column(type="datetime")
  49.      */
  50.     private $created;
  51.     /**
  52.      * @ORM\Column(type="datetime", nullable=true)
  53.      */
  54.     private $approved;
  55.     /**
  56.      * @ORM\Column(type="string", length=255)
  57.      */
  58.     private $status;
  59.     /**
  60.      * @ORM\Column(type="text", nullable=true)
  61.      */
  62.     private $approverMessage;
  63.     /**
  64.      * @ORM\OneToMany(targetEntity=InvoiceAutomationItem::class, mappedBy="invoice", orphanRemoval=true, cascade={"persist"})
  65.      */
  66.     private $invoiceAutomationItems;
  67.     /**
  68.      * @ORM\Column(type="boolean")
  69.      */
  70.     private $paid false;
  71.     /**
  72.      * @ORM\Column(type="string", length=12, nullable=true)
  73.      */
  74.     private $currency 'CZK';
  75.     /**
  76.      * @ORM\Column(type="float", nullable=true)
  77.      */
  78.     private $expand1Value;
  79.     /**
  80.      * @ORM\Column(type="float", nullable=true)
  81.      */
  82.     private $expand2Value;
  83.     /**
  84.      * @ORM\Column(type="float", nullable=true)
  85.      */
  86.     private $expand3Value;
  87.     /**
  88.      * @ORM\Column(type="float", nullable=true)
  89.      */
  90.     private $expand4Value;
  91.     /**
  92.      * @ORM\Column(type="float", nullable=true)
  93.      */
  94.     private $residue;
  95.     /**
  96.      * @ORM\Column(type="boolean")
  97.      */
  98.     private $isExpanded false;
  99.     public function __construct()
  100.     {
  101.         $this->invoiceAutomationItems = new ArrayCollection();
  102.     }
  103.     public function getId(): ?int
  104.     {
  105.         return $this->id;
  106.     }
  107.     public function getInvoiceNumber(): ?string
  108.     {
  109.         return $this->invoiceNumber;
  110.     }
  111.     public function setInvoiceNumber(string $invoiceNumber): self
  112.     {
  113.         $this->invoiceNumber $invoiceNumber;
  114.         return $this;
  115.     }
  116.     public function getSubject(): ?string
  117.     {
  118.         return $this->subject;
  119.     }
  120.     public function setSubject(?string $subject): self
  121.     {
  122.         $this->subject $subject;
  123.         return $this;
  124.     }
  125.     public function getMerchant(): ?User
  126.     {
  127.         return $this->merchant;
  128.     }
  129.     public function setMerchant(?User $merchant): self
  130.     {
  131.         $this->merchant $merchant;
  132.         return $this;
  133.     }
  134.     public function getMerchantEmail(): ?string
  135.     {
  136.         return $this->merchantEmail;
  137.     }
  138.     public function setMerchantEmail(?string $merchantEmail): self
  139.     {
  140.         $this->merchantEmail $merchantEmail;
  141.         return $this;
  142.     }
  143.     public function getMerchantPhone(): ?string
  144.     {
  145.         return $this->merchantPhone;
  146.     }
  147.     public function setMerchantPhone(?string $merchantPhone): self
  148.     {
  149.         $this->merchantPhone $merchantPhone;
  150.         return $this;
  151.     }
  152.     public function getSubscriber(): ?Company
  153.     {
  154.         return $this->subscriber;
  155.     }
  156.     public function setSubscriber(?Company $subscriber): self
  157.     {
  158.         $this->subscriber $subscriber;
  159.         return $this;
  160.     }
  161.     public function getAmount(): ?float
  162.     {
  163.         $total 0;
  164.         /** @var InvoiceAutomationItem $invoiceAutomationItem */
  165.         foreach ($this->invoiceAutomationItems as $invoiceAutomationItem) {
  166.             if($invoiceAutomationItem->isHideOnInvoice() == false) {
  167.                 $total $total $invoiceAutomationItem->getPriceTotal();
  168.             }
  169.         }
  170.         return $total;
  171.     }
  172.     public function setAmount(float $amount): self
  173.     {
  174.         $this->amount $amount;
  175.         return $this;
  176.     }
  177.     public function getDueDate(): ?\DateTimeInterface
  178.     {
  179.         $dueDate = clone $this->created;
  180.         $dueDate->modify('+10 days');
  181.         return $dueDate;
  182.     }
  183.     public function getCreated(): ?\DateTimeInterface
  184.     {
  185.         return $this->created;
  186.     }
  187.     public function setCreated(\DateTimeInterface $created): self
  188.     {
  189.         $this->created $created;
  190.         return $this;
  191.     }
  192.     public function getApproved(): ?\DateTimeInterface
  193.     {
  194.         return $this->approved;
  195.     }
  196.     public function setApproved(?\DateTimeInterface $approved): self
  197.     {
  198.         $this->approved $approved;
  199.         return $this;
  200.     }
  201.     public function getStatus(): ?string
  202.     {
  203.         return $this->status;
  204.     }
  205.     public function setStatus(string $status): self
  206.     {
  207.         $this->status $status;
  208.         return $this;
  209.     }
  210.     public function getApproverMessage(): ?string
  211.     {
  212.         return $this->approverMessage;
  213.     }
  214.     public function setApproverMessage(?string $approverMessage): self
  215.     {
  216.         $this->approverMessage $approverMessage;
  217.         return $this;
  218.     }
  219.     /**
  220.      * @return Collection<int, InvoiceAutomationItem>
  221.      */
  222.     public function getItems(): Collection
  223.     {
  224.         return $this->invoiceAutomationItems;
  225.     }
  226.     public function addItem(InvoiceAutomationItem $invoiceAutomationItem): self
  227.     {
  228.         if (!$this->invoiceAutomationItems->contains($invoiceAutomationItem)) {
  229.             $this->invoiceAutomationItems[] = $invoiceAutomationItem;
  230.             $invoiceAutomationItem->setInvoice($this);
  231.         }
  232.         return $this;
  233.     }
  234.     public function removeItem(InvoiceAutomationItem $invoiceAutomationItem): self
  235.     {
  236.         if ($this->invoiceAutomationItems->removeElement($invoiceAutomationItem)) {
  237.             // set the owning side to null (unless already changed)
  238.             if ($invoiceAutomationItem->getInvoice() === $this) {
  239.                 $invoiceAutomationItem->setInvoice(null);
  240.             }
  241.         }
  242.         return $this;
  243.     }
  244.     public function isPaid(): ?bool
  245.     {
  246.         return $this->paid;
  247.     }
  248.     public function setPaid(bool $paid): self
  249.     {
  250.         $this->paid $paid;
  251.         return $this;
  252.     }
  253.     public function getCurrency(): ?string
  254.     {
  255.         return $this->currency;
  256.     }
  257.     public function setCurrency(string $currency): self
  258.     {
  259.         $this->currency $currency;
  260.         return $this;
  261.     }
  262.     public function getExpand1Value(): ?float
  263.     {
  264.         return $this->expand1Value;
  265.     }
  266.     public function setExpand1Value(?float $expand1Value): self
  267.     {
  268.         $this->expand1Value $expand1Value;
  269.         return $this;
  270.     }
  271.     public function getExpand2Value(): ?float
  272.     {
  273.         return $this->expand2Value;
  274.     }
  275.     public function setExpand2Value(?float $expand2Value): self
  276.     {
  277.         $this->expand2Value $expand2Value;
  278.         return $this;
  279.     }
  280.     public function getExpand3Value(): ?float
  281.     {
  282.         return $this->expand3Value;
  283.     }
  284.     public function setExpand3Value(?float $expand3Value): self
  285.     {
  286.         $this->expand3Value $expand3Value;
  287.         return $this;
  288.     }
  289.     public function getExpand4Value(): ?float
  290.     {
  291.         return $this->expand4Value;
  292.     }
  293.     public function setExpand4Value(?float $expand4Value): self
  294.     {
  295.         $this->expand4Value $expand4Value;
  296.         return $this;
  297.     }
  298.     public function getResidue(): ?float
  299.     {
  300.         return $this->residue;
  301.     }
  302.     public function setResidue(?float $residue): self
  303.     {
  304.         $this->residue $residue;
  305.         return $this;
  306.     }
  307.     public function isIsExpanded(): ?bool
  308.     {
  309.         return $this->isExpanded;
  310.     }
  311.     public function setIsExpanded(bool $isExpanded): self
  312.     {
  313.         $this->isExpanded $isExpanded;
  314.         return $this;
  315.     }
  316. }