src/Entity/ProjectOrderExpenses.php line 34

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProjectOrderExpensesRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Serializer\Annotation\MaxDepth;
  10. /**
  11.  * TODO Replace Entity Name with Expenses (Too Props)
  12.  * ORM\Entity(repositoryClass=ProjectOrderExpensesRepository::class)
  13.  * @UniqueEntity(
  14.  *     fields={"supplier", "invoice_nr"},
  15.  *     message="This invoice already created, please try another one|This invoice with combination %s %s already created, please try another one"
  16.  * )
  17.  * FULL TEXT SEARCH INDEX SUPPORT
  18.  * @ORM\Entity(repositoryClass=ProjectOrderExpensesRepository::class)
  19.  * @ORM\Table(
  20.  *      name="project_order_expenses",
  21.  *      indexes={
  22.  *          @ORM\Index(name="search_indx", columns={"invoice_nr", "expense_nr"}, flags={"fulltext"})
  23.  *      },
  24.  *     options={"comment": "Replace this table name to expenses"}
  25.  * )
  26.  *
  27.  */
  28. // README annotation info
  29. //
  30. class ProjectOrderExpenses
  31. {
  32.     /**
  33.      * @ORM\Id
  34.      * @ORM\GeneratedValue
  35.      * @ORM\Column(type="integer")
  36.      * 👉project.orders.expense.minify.base.for.position  Expense Position Project ordar'a related oldugu icin bu Positionnun bagli oldugu expense mini bilgileri veriyori, yoksa circular reference olusuyor
  37.      * @Groups({
  38.      *     "project.orders.expense.base",
  39.      *     "project.orders.expense.minify.version",
  40.      *
  41.      *     "expense.core",
  42.      *     "expense:core",
  43.      *
  44.      *     "expense@base",
  45.      *     "expense@core"
  46.      * })
  47.      */
  48.     private $id;
  49.     /**
  50.      * @ORM\ManyToOne(targetEntity=Suppliers::class, inversedBy="projectOrderExpenses")
  51.      * @ORM\JoinColumn(nullable=false)
  52.      * @Groups({
  53.      *      "supplier.base",
  54.      *      "project.orders.expense.minify.version",
  55.      *
  56.      *     "expense.supplier",
  57.      *
  58.      *     "expense@supplier"
  59.      * })
  60.      */
  61.     private $supplier;
  62. //    /**
  63. //     * ❌❌❌❌❌❌ use in positions
  64. //     * @deprecated will remove completelly
  65. //     * ORM\ManyToOne(targetEntity=ProjectOrders::class, inversedBy="projectOrderExpenses")
  66. //     * Groups({
  67. //     *         "project.orders.expense.assigned.order",
  68. //     *
  69. //     *        })
  70. //     */
  71. //    private $project_order;
  72.     /**
  73.      * Tedarikçinin gönderdiği faturanın üzerindeki numara (dışarıdan gelir).
  74.      * supplier + invoice_nr kombinasyonu unique — aynı tedarikçinin aynı faturası sisteme iki kez işlenemez.
  75.      * @ORM\Column(type="string", length=64, nullable=true, unique=true )
  76.      * @ORM\JoinColumn(nullable=true)
  77.      * @Groups({
  78.      *     "project.orders.expense.base",
  79.      *     "expense.core",
  80.      *     "expense:core",
  81.      *
  82.      *     "expense@base",
  83.      *     "expense@core"
  84.      * })
  85.      */
  86.     private $invoice_nr;
  87.     /**
  88.      * @ORM\Column(type="datetime_immutable")
  89.      * @Groups({
  90.      *      "project.orders.expense.base",
  91.      *      "expense.core",
  92.      *      "expense:core",
  93.      *
  94.      *     "expense@base",
  95.      *     "expense@core"
  96.      *  })
  97.      */
  98.     private $created_at;
  99.     /**
  100.      * @MaxDepth(1)
  101.      * "project.orders.expense.minify.version" for count
  102.      * @ORM\OneToMany(targetEntity=ProjectOrderExpensePositions::class, mappedBy="project_order_expense", cascade={"persist", "remove"})
  103.      * @Groups({
  104.      *     "@deprecated_.project.orders.expense.positions",
  105.      *     "expense.positions",
  106.      *     "project.orders.expense.minify.version",
  107.      *     "expense.positions",
  108.      *
  109.      *     "expense@positions"
  110.      * })
  111.      * @ORM\OrderBy({"id": "DESC"})
  112.      */
  113.     private $project_order_expense_positions;
  114.     /**
  115.      * @deprecated ❌❌❌❌❌❌❌ Amount use for older vers. with new use positions amount
  116.      *
  117.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  118.      * @Groups({
  119.      *     "project.orders.expense.base"
  120.      * })
  121.      */
  122.     private $amount;
  123.     /**
  124.      * Persisted canonical total of all positions, written on every upsert
  125.      * (ExpenseService::computeExpenseTotal). The list reads this directly —
  126.      * no client-side math. Formula mirrors FE calcPositionLineTotal:
  127.      * per position buying_price>0 ? (unit / PE) * buying_price : amount, plus delivery_amount.
  128.      *
  129.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  130.      * @Groups({
  131.      *     "expense@core"
  132.      * })
  133.      */
  134.     private $total;
  135.     /**
  136.      * @ORM\Column(type="datetime_immutable", nullable=true)
  137.      * @Groups({
  138.      *     "project.orders.expense.base",
  139.      *     "project.orders.expense.minify.version",
  140.      *     "project.orders.expense.position.expense",
  141.      *
  142.      *     "expense.core", "expense:core",
  143.      *
  144.      *
  145.      *     "expense@base",
  146.      *     "expense@core"
  147.      * })
  148.      */
  149.     private $expensed_at;
  150.     /**
  151.      * @ORM\Column(type="string", length=64, nullable=true, unique=true, options={"comment": "Bu bir siparis numarasi bir Proje>Orderlar icin yapilan siparislerin geneli"})
  152.      * @Groups({
  153.      *     "project.orders.expense.base",
  154.      *     "project.orders.expense.minify.version",
  155.      *     "expense.core", "expense:core",
  156.      *     "expense@base",
  157.      *     "expense@core"
  158.      * })
  159.      */
  160.     private $expense_nr;
  161.     /**
  162.      * @ORM\Column(type="string", length=64, nullable=true)
  163.      * @Groups({"expense@core"})
  164.      */
  165.     private $offer_nr;
  166.     /**
  167.      * @ORM\Column(type="datetime_immutable", nullable=true)
  168.      * @Groups({"expense@core"})
  169.      */
  170.     private $offer_at;
  171.     /**
  172.      * @ORM\Column(type="datetime_immutable", nullable=true)
  173.      * @Groups({"expense@core"})
  174.      */
  175.     private $delivery_due_at;
  176.     /**
  177.      * @ORM\ManyToOne(targetEntity=Locations::class)
  178.      * @ORM\JoinColumn(nullable=true)
  179.      * @Groups({"expense@deliver_location"})
  180.      */
  181.     private $deliver_location;
  182.     /**
  183.      * @ORM\Column(type="text", nullable=true)
  184.      * @Groups({
  185.      *     "project.orders.expense.base",
  186.      *
  187.      *     "expense.core", "expense:core",
  188.      *
  189.      *     "expense@base",
  190.      *     "expense@core"
  191.      * })
  192.      */
  193.     private $comment;
  194.     /**
  195.      * @deprecated use documents as json
  196.      * TODO Replace with json and the name Documents!!!
  197.      * @ORM\Column(type="text", nullable=true)
  198.      * @Groups({
  199.      *     "project.orders.expense.base",
  200.      *     "project.orders.expense.minify.version",
  201.      *
  202.      *     "expense.core", "expense:core",
  203.      *
  204.      *     "expense@core"
  205.      * })
  206.      */
  207.     private $document;
  208.     /**
  209.      * TODO Replace with json and the name Documents!!!
  210.      * @ORM\Column(type="json", nullable=true)
  211.      * @Groups({
  212.      *     "expense@core"
  213.      * })
  214.      */
  215.     private $documents;
  216.     /**
  217.      * ORM\OneToOne(targetEntity=PurchaseRequest::class, mappedBy="expense", cascade={"persist", "remove"})
  218.      * @ORM\ManyToOne(targetEntity=PurchaseRequest::class, inversedBy="expense", cascade={"persist", "remove"})
  219.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  220.      * @Groups({
  221.      *      "expense:purchse_request",
  222.      *
  223.      *
  224.      *      "expense@purchse_request"
  225.      *  })
  226.      */
  227.     private $purchase_request;
  228.     public function __construct()
  229.     {
  230.         $this->project_order_expense_positions = new ArrayCollection();
  231.     }
  232.     public function getId(): ?int
  233.     {
  234.         return $this->id;
  235.     }
  236.     public function getSupplier(): ?Suppliers
  237.     {
  238.         return $this->supplier;
  239.     }
  240.     public function setSupplier(?Suppliers $supplier): self
  241.     {
  242.         $this->supplier $supplier;
  243.         return $this;
  244.     }
  245. //    public function getProjectOrder(): ?ProjectOrders
  246. //    {
  247. //        return $this->project_order;
  248. //    }
  249. //
  250. //    public function setProjectOrder(?ProjectOrders $project_order): self
  251. //    {
  252. //        $this->project_order = $project_order;
  253. //
  254. //        return $this;
  255. //    }
  256.     public function getInvoiceNr(): ?string
  257.     {
  258.         return $this->invoice_nr;
  259.     }
  260.     public function setInvoiceNr(?string $invoice_nr): self
  261.     {
  262.         $this->invoice_nr $invoice_nr;
  263.         return $this;
  264.     }
  265.     public function getCreatedAt(): ?\DateTimeImmutable
  266.     {
  267.         return $this->created_at;
  268.     }
  269.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  270.     {
  271.         $this->created_at $created_at;
  272.         return $this;
  273.     }
  274.     /**
  275.      * @return Collection<int, ProjectOrderExpensePositions>
  276.      */
  277.     public function getProjectOrderExpensePositions(): Collection
  278.     {
  279.         return $this->project_order_expense_positions;
  280.     }
  281.     public function addProjectOrderExpensePosition(ProjectOrderExpensePositions $projectOrderExpensePosition): self
  282.     {
  283.         if (!$this->project_order_expense_positions->contains($projectOrderExpensePosition)) {
  284.             $this->project_order_expense_positions[] = $projectOrderExpensePosition;
  285.             $projectOrderExpensePosition->setProjectOrderExpense($this);
  286.         }
  287.         return $this;
  288.     }
  289.     public function removeProjectOrderExpensePosition(ProjectOrderExpensePositions $projectOrderExpensePosition): self
  290.     {
  291.         if ($this->project_order_expense_positions->removeElement($projectOrderExpensePosition)) {
  292.             // set the owning side to null (unless already changed)
  293.             if ($projectOrderExpensePosition->getProjectOrderExpense() === $this) {
  294.                 $projectOrderExpensePosition->setProjectOrderExpense(null);
  295.             }
  296.         }
  297.         return $this;
  298.     }
  299.     public function getAmount(): ?string
  300.     {
  301.         return $this->amount;
  302.     }
  303.     public function setAmount(?string $amount): self
  304.     {
  305.         $this->amount $amount;
  306.         return $this;
  307.     }
  308.     public function getTotal(): ?string
  309.     {
  310.         return $this->total;
  311.     }
  312.     public function setTotal(?string $total): self
  313.     {
  314.         $this->total $total;
  315.         return $this;
  316.     }
  317.     public function getExpensedAt(): ?\DateTimeImmutable
  318.     {
  319.         return $this->expensed_at;
  320.     }
  321.     public function setExpensedAt(?\DateTimeImmutable $expensed_at): self
  322.     {
  323.         $this->expensed_at $expensed_at;
  324.         return $this;
  325.     }
  326.     public function getExpenseNr(): ?string
  327.     {
  328.         return $this->expense_nr;
  329.     }
  330.     public function setExpenseNr(?string $expense_nr): self
  331.     {
  332.         $this->expense_nr $expense_nr;
  333.         return $this;
  334.     }
  335.     public function getOfferNr(): ?string
  336.     {
  337.         return $this->offer_nr;
  338.     }
  339.     public function setOfferNr(?string $offer_nr): self
  340.     {
  341.         $this->offer_nr $offer_nr;
  342.         return $this;
  343.     }
  344.     public function getOfferAt(): ?\DateTimeImmutable
  345.     {
  346.         return $this->offer_at;
  347.     }
  348.     public function setOfferAt(?\DateTimeImmutable $offer_at): self
  349.     {
  350.         $this->offer_at $offer_at;
  351.         return $this;
  352.     }
  353.     public function getComment(): ?string
  354.     {
  355.         return $this->comment;
  356.     }
  357.     public function setComment(?string $comment): self
  358.     {
  359.         $this->comment $comment;
  360.         return $this;
  361.     }
  362.     /**
  363.      * TODO remove this forever
  364.      * @deprecated use documents as json
  365.      */
  366.     public function getDocument(): ?string
  367.     {
  368.         return $this->document;
  369.     }
  370.     /**
  371.      * TODO remove this forever
  372.      * @deprecated use documents as json
  373.      */
  374.     public function setDocument(?string $document): self
  375.     {
  376.         $this->document $document;
  377.         return $this;
  378.     }
  379.     public function getDocuments(): ?array { return $this->documents; }
  380.     public function setDocuments(?array $documents): self $this->documents $documents; return $this;}
  381.     public function getDeliveryDueAt(): ?\DateTimeImmutable
  382.     {
  383.         return $this->delivery_due_at;
  384.     }
  385.     public function setDeliveryDueAt(?\DateTimeImmutable $delivery_due_at): self
  386.     {
  387.         $this->delivery_due_at $delivery_due_at;
  388.         return $this;
  389.     }
  390.     public function getDeliverLocation(): ?Locations
  391.     {
  392.         return $this->deliver_location;
  393.     }
  394.     public function setDeliverLocation(?Locations $deliver_location): self
  395.     {
  396.         $this->deliver_location $deliver_location;
  397.         return $this;
  398.     }
  399.     public function getPurchaseRequest(): ?PurchaseRequest
  400.     {
  401.         return $this->purchase_request;
  402.     }
  403.     public function setPurchaseRequest(?PurchaseRequest $purchase_request): self
  404.     {
  405.         $this->purchase_request $purchase_request;
  406.         return $this;
  407.     }
  408. }