src/Entity/ProjectOrderExpensePositions.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProjectOrderExpensePositionsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Symfony\Component\Serializer\Annotation\MaxDepth;
  9. /**
  10.  * TODO Replace Entity Name with ExpensePositions (Too Props)
  11.  * @ORM\Entity(repositoryClass=ProjectOrderExpensePositionsRepository::class)
  12.  */
  13. class ProjectOrderExpensePositions
  14. {
  15.     /**
  16.      * ðŸ’¡ðŸ’¡ðŸ’¡ðŸ’¡
  17.      *  project.orders.expense.positions.countable.version
  18.      *  countable sadece exoense list Ã¼zerinde expense ait kac tane position oldugunu anlamak icin lazim!!!
  19.      *  ðŸ’¡ðŸ’¡ðŸ’¡ðŸ’¡
  20.     */
  21.     /**
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue
  24.      * @ORM\Column(type="integer")
  25.      * @Groups({
  26.      *     "project.orders.expense.position.base",
  27.      *     "project.orders.expense.positions.countable.version",
  28.      *
  29.      *     "project.orders.expense.minify.version",
  30.      *
  31.      *     "expense.position.core",
  32.      *
  33.      *     "expense_position@core",
  34.      *     "expense_position@base"
  35.      * })
  36.      */
  37.     private $id;
  38.     /**
  39.      * @Groups({
  40.      *      "project.orders.expense.position.base",
  41.      *  })
  42.     */
  43.     private $test;
  44.     /**
  45.      * @return mixed
  46.      */
  47.     public function getTest()
  48.     {
  49.         return $this->test;
  50.     }
  51.     /**
  52.      *     "project.orders.expense.position.base",
  53.      * @ORM\ManyToOne(targetEntity=ProjectOrderExpenses::class, inversedBy="projectOrderExpensePositions")
  54.      * @ORM\JoinColumn(onDelete="CASCADE")
  55.      * @Groups({
  56.      *     "project.orders.expense.minify.version",
  57.      *
  58.      *     "expense.position.expense",
  59.      *
  60.      *     "expense_position@expense"
  61.      * })
  62.      */
  63.     private $project_order_expense;
  64.     /**
  65.      * @ORM\ManyToOne(targetEntity=Material::class, inversedBy="projectOrderExpensePositions")
  66.      * @ORM\JoinColumn(nullable=true)
  67.      * @Groups({
  68.      *     "material.base",
  69.      *     "expense.position.material",
  70.      *
  71.      *     "expense_position@material"
  72.      * })
  73.      */
  74.     private $material;
  75.     /**
  76.      * Pozisyon miktarı (belgedeki "Menge"). Float â€” kg gibi kesirli miktarlar için
  77.      * (ör. 31.62 KG). PE ile: total = (unit / price_unit) Ã— unit_price.
  78.      * @ORM\Column(type="float")
  79.      * @Groups({
  80.      *      "project.orders.expense.position.base",
  81.      *      "project.orders.expense.minify.version",
  82.      *      "project.orders.expense.positions.countable.version",
  83.      *      "expense.position.core",
  84.      *
  85.      *     "expense_position@core",
  86.      *     "expense_position@base"
  87.      * })
  88.      */
  89.     private $unit;
  90.     /**
  91.      * @ORM\Column(type="datetime_immutable")
  92.      * @Groups({
  93.      *     "project.orders.expense.position.base",
  94.      *     "expense.position.core", "expense_position@core"
  95.      * })
  96.      */
  97.     private $created_at;
  98.     /**
  99.      * @ORM\Column(type="datetime_immutable", nullable=true)
  100.      * @Groups({
  101.      *     "project.orders.expense.position.base",
  102.      *     "project.orders.expense.minify.version",
  103.      *     "project.orders.expense.positions.countable.version",
  104.      *
  105.      *     "expense.position.core", "expense_position@core"
  106.      * })
  107.      */
  108.     private $delivered_at;
  109.     /**
  110.      * FAZ G â€” per-position override of the expense header's delivery_due_at
  111.      * ("supplier'a bildirdiÄŸimiz teslim vadesi"). Null â†’ falls back to the
  112.      * expense-level value at read time; write-time cascade in
  113.      * ExpenseService::syncExpensePositions fills nulls with the expense
  114.      * value on save (safety net). PE pattern.
  115.      *
  116.      * @ORM\Column(type="datetime_immutable", nullable=true)
  117.      * @Groups({
  118.      *     "expense_position@core"
  119.      * })
  120.      */
  121.     private $delivery_due_at;
  122.     /**
  123.      * TODO not created yet!
  124.      * @deprecated use buying price instead
  125.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  126.      * @Groups({
  127.      *     "project.orders.expense.position.base",
  128.      *     "project.orders.expense.minify.version",
  129.      *     "project.orders.expense.positions.countable.version",
  130.      *     "expense.position.core", "expense_position@core",
  131.      *
  132.      *     "expense_position@base"
  133.      * })
  134.      */
  135.     private $amount;
  136.     /**
  137.      * @ORM\Column(type="integer", nullable=true)
  138.      * @Groups({
  139.      *     "project.orders.expense.position.base",
  140.      *     "expense.position.core", "expense_position@core"
  141.      * })
  142.      */
  143.     private $delivered_unit;
  144.     /**
  145.      * @ORM\Column(type="text", nullable=true)
  146.      * @Groups({
  147.      *     "project.orders.expense.position.base",
  148.      *     "project.orders.expense.minify.version",
  149.      *     "expense.position.core", "expense_position@core"
  150.      * })
  151.      *
  152.      */
  153.     private $content;
  154.     /**
  155.      * @ORM\Column(type="boolean", nullable=true)
  156.      * @Groups({
  157.      *     "project.orders.expense.position.base",
  158.      *     "expense.position.core", "expense_position@core"
  159.      * })
  160.      */
  161.     private $completed;
  162.     /**
  163.      * @ORM\Column(type="text", nullable=true)
  164.      * @Groups({
  165.      *     "project.orders.expense.position.base",
  166.      *     "expense.position.core", "expense_position@core"
  167.      * })
  168.      */
  169.     private $comment;
  170.     /**
  171.      * @ORM\Column(type="string", length=255, nullable=true)
  172.      * @Groups({
  173.      *     "project.orders.expense.position.base",
  174.      *     "expense.position.core", "expense_position@core"
  175.      * })
  176.      */
  177.     private $delivered_to;
  178.     /**
  179.      * @MaxDepth(1)
  180.      * @ORM\ManyToOne(targetEntity=ProjectOrders::class, inversedBy="projectOrderExpensePositions")
  181.      * @ORM\JoinColumn(onDelete="CASCADE")
  182.      * @Groups({
  183.      *     "project.orders.expense.position.base",
  184.      *     "project.order.expense.position.order",
  185.      *
  186.      *     "expense.position.order",
  187.      *
  188.      *     "expense_position@project_order"
  189.      * })
  190.      */
  191.     private $project_order;
  192.     /**
  193.      * A manipulated or simulated column is used to prevent circular references.
  194.      * It is used for retrieving the necessary information related to an order in order to generate
  195.      * a list of minified expenses for the associated spending
  196.      * @Groups({
  197.      *     "project.orders.expense.minify.version",
  198.      *     })
  199.      */
  200.     private $required_order_details_for_expense_history;
  201.     /**
  202.      * @return mixed
  203.      */
  204.     public function getRequiredOrderDetailsForExpenseHistory(): array
  205.     {
  206.         if($this->getProjectOrder()){
  207.             return [
  208.                 "id" => $this->getProjectOrder()->getId(),
  209.                 "order_nr" => $this->getProjectOrder()->getOrderNr()
  210.             ];
  211.         }
  212.         return [];
  213.     }
  214.     /**
  215.      * @ORM\Column(type="string", length=64, nullable=true)
  216.      * @Groups({
  217.      *     "project.orders.expense.position.base",
  218.      *     "expense.position.core", "expense_position@core"
  219.      * })
  220.      */
  221.     private $an_supplier;
  222.     /**
  223.      * @ORM\ManyToOne(targetEntity=ProjectOrderExpensePositions::class, inversedBy="decomposed_positions", cascade={"persist"})
  224.      * @Groups({
  225.      *     "project.orders.expense.position.base",
  226.      *     "expense.position.core", "expense_position@core"
  227.      * })
  228.      * @ORM\JoinColumn(onDelete="SET NULL")
  229.      */
  230.     private $parent_pos;
  231.     /**
  232.      * @ORM\OneToMany(targetEntity=ProjectOrderExpensePositions::class, mappedBy="parent_pos")
  233.      * @Groups({
  234.      *     "project.orders.expense.position.base",
  235.      *     "expense.position.decomposed"
  236.      * })
  237.      */
  238.     private $decomposed_positions;
  239.     /**
  240.      * TODO remove this forever
  241.      * @deprecated use documents as json
  242.      * @ORM\Column(type="string", length=255, nullable=true)
  243.      * @Groups({
  244.      *     "project.orders.expense.position.base",
  245.      *     "project.orders.expense.minify.version",
  246.      *     "expense.position.core", "expense_position@core"
  247.      * })
  248.      */
  249.     private $document;
  250.     /**
  251.      * @ORM\Column(type="json", nullable=true)
  252.      * @Groups({
  253.      *     "expense_position@core"
  254.      * })
  255.      */
  256.     private $documents;
  257.     /**
  258.      * @ORM\ManyToOne(targetEntity=Stocks::class, inversedBy="projectOrderExpensePositions")
  259.      * @Groups({
  260.      *      "project_orders_expense_position@stock"
  261.      *  })
  262.      */
  263.     private $stock;
  264.     /**
  265.      * @ORM\Column(type="float", nullable=true)
  266.      * @Groups({
  267.      *      "project.orders.expense.position.base",
  268.      *      "project.orders.expense.minify.version",
  269.      *      "project.orders.expense.positions.countable.version",
  270.      *      "expense.position.core", "expense_position@core"
  271.      *  })
  272.      */
  273.     private $buying_price;
  274.     /**
  275.      * Position-level override of supplier_products.price_unit (Preiseinheit / PE).
  276.      * NULL means inherit from supplier_product, or default to per single unit.
  277.      *
  278.      * @ORM\Column(type="float", nullable=true)
  279.      * @Groups({
  280.      *      "project.orders.expense.position.base",
  281.      *      "project.orders.expense.minify.version",
  282.      *      "project.orders.expense.positions.countable.version",
  283.      *      "expense.position.core", "expense_position@core"
  284.      *  })
  285.      */
  286.     private $price_unit;
  287.     /**
  288.      * @ORM\Column(type="float", nullable=true)
  289.      * @Groups({
  290.      *      "project.orders.expense.position.base",
  291.      *      "project.orders.expense.minify.version",
  292.      *      "project.orders.expense.positions.countable.version",
  293.      *      "expense.position.core", "expense_position@core"
  294.      *  })
  295.      */
  296.     private $sales_price;
  297.     /**
  298.      * @ORM\Column(type="float", nullable=true)
  299.      * @Groups({
  300.      *      "project.orders.expense.position.base",
  301.      *      "project.orders.expense.minify.version",
  302.      *      "project.orders.expense.positions.countable.version",
  303.      *      "expense.position.core", "expense_position@core"
  304.      *  })
  305.      */
  306.     private $sales_margin;
  307.     /**
  308.      * @ORM\OneToOne(targetEntity=PurchaseRequestPositions::class, inversedBy="expense_position", cascade={"persist", "remove"})
  309.      * @ORM\JoinColumn(onDelete="CASCADE")
  310.      * @Groups({
  311.      *        "expense_position@purchse_request_position"
  312.      *    })
  313.      */
  314.     private $purchase_request_position;
  315.     /**
  316.      * @ORM\Column(type="float", nullable=true)
  317.      * @Groups({
  318.      *       "project.orders.expense.position.base",
  319.      *       "project.orders.expense.minify.version",
  320.      *       "project.orders.expense.positions.countable.version",
  321.      *       "expense.position.core", "expense_position@core"
  322.      *   })
  323.      */
  324.     private $delivery_amount;
  325.     /**
  326.      * @ORM\Column(type="string", length=255, nullable=true)
  327.      * @Groups({"expense_position@core", "expense_position@base"})
  328.      */
  329.     private $offer_nr;
  330.     /**
  331.      * @ORM\Column(type="string", nullable=true, columnDefinition="ENUM('item','service','delivery')")
  332.      * @Groups({"expense_position@core"})
  333.      */
  334.     private $position_type;
  335.     /**
  336.      * @ORM\Column(type="string", nullable=true, columnDefinition="ENUM('pending','sent','delivered')")
  337.      * @Groups({"expense_position@core"})
  338.      */
  339.     private $delivery_status;
  340.     /**
  341.      * @deprecated use supplier_product instead
  342.      * @ORM\Column(type="string", length=255, nullable=true)
  343.      * @Groups({"expense_position@core", "expense_position@base"})
  344.      */
  345.     private $size;
  346.     /**
  347.      * @ORM\ManyToOne(targetEntity=SupplierProducts::class, inversedBy="project_order_expense_positions")
  348.      * @ORM\JoinColumn(onDelete="CASCADE")
  349.      * @Groups({
  350.      *     "expense_position@supplier_product"
  351.      * })
  352.      */
  353.     private $supplier_product;
  354.     public function __construct()
  355.     {
  356.         $this->decomposed_positions = new ArrayCollection();
  357.     }
  358.     public function getId(): ?int
  359.     {
  360.         return $this->id;
  361.     }
  362.     public function getProjectOrderExpense(): ?ProjectOrderExpenses
  363.     {
  364.         return $this->project_order_expense;
  365.     }
  366.     public function setProjectOrderExpense(?ProjectOrderExpenses $project_order_expense): self
  367.     {
  368.         $this->project_order_expense $project_order_expense;
  369.         return $this;
  370.     }
  371.     public function getMaterial(): ?Material
  372.     {
  373.         return $this->material;
  374.     }
  375.     public function setMaterial(?Material $material): self
  376.     {
  377.         $this->material $material;
  378.         return $this;
  379.     }
  380.     public function getUnit(): ?float
  381.     {
  382.         return $this->unit;
  383.     }
  384.     public function setUnit(float $unit): self
  385.     {
  386.         $this->unit $unit;
  387.         return $this;
  388.     }
  389.     public function getCreatedAt(): ?\DateTimeImmutable
  390.     {
  391.         return $this->created_at;
  392.     }
  393.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  394.     {
  395.         $this->created_at $created_at;
  396.         return $this;
  397.     }
  398.     public function getDeliveredAt(): ?\DateTimeImmutable
  399.     {
  400.         return $this->delivered_at;
  401.     }
  402.     public function setDeliveredAt(?\DateTimeImmutable $delivered_at): self
  403.     {
  404.         $this->delivered_at $delivered_at;
  405.         return $this;
  406.     }
  407.     public function getDeliveryDueAt(): ?\DateTimeImmutable
  408.     {
  409.         return $this->delivery_due_at;
  410.     }
  411.     public function setDeliveryDueAt(?\DateTimeImmutable $delivery_due_at): self
  412.     {
  413.         $this->delivery_due_at $delivery_due_at;
  414.         return $this;
  415.     }
  416.     /**
  417.      * @deprecated use buying price instead
  418.      */
  419.     public function getAmount(): ?string
  420.     {
  421.         return $this->amount;
  422.     }
  423.     /**
  424.      * @deprecated use buying price instead
  425.      */
  426.     public function setAmount(?string $amount): self
  427.     {
  428.         $this->amount $amount;
  429.         return $this;
  430.     }
  431.     public function getDeliveredUnit(): ?int
  432.     {
  433.         return $this->delivered_unit;
  434.     }
  435.     public function setDeliveredUnit(?int $delivered_unit): self
  436.     {
  437.         $this->delivered_unit $delivered_unit;
  438.         return $this;
  439.     }
  440.     public function getContent(): ?string
  441.     {
  442.         return $this->content;
  443.     }
  444.     public function setContent(?string $content): self
  445.     {
  446.         $this->content $content;
  447.         return $this;
  448.     }
  449.     public function getCompleted(): ?bool
  450.     {
  451.         return $this->completed;
  452.     }
  453.     public function setCompleted(?bool $completed): self
  454.     {
  455.         $this->completed $completed;
  456.         return $this;
  457.     }
  458.     public function getComment(): ?string
  459.     {
  460.         return $this->comment;
  461.     }
  462.     public function setComment(?string $comment): self
  463.     {
  464.         $this->comment $comment;
  465.         return $this;
  466.     }
  467.     public function getDeliveredTo(): ?string
  468.     {
  469.         return $this->delivered_to;
  470.     }
  471.     public function setDeliveredTo(?string $delivered_to): self
  472.     {
  473.         $this->delivered_to $delivered_to;
  474.         return $this;
  475.     }
  476.     public function getProjectOrder(): ?ProjectOrders
  477.     {
  478.         return $this->project_order;
  479.     }
  480.     public function setProjectOrder(?ProjectOrders $project_order): self
  481.     {
  482.         $this->project_order $project_order;
  483.         return $this;
  484.     }
  485.     public function getAnSupplier(): ?string
  486.     {
  487.         return $this->an_supplier;
  488.     }
  489.     public function setAnSupplier(?string $an_supplier): self
  490.     {
  491.         $this->an_supplier $an_supplier;
  492.         return $this;
  493.     }
  494.     public function getParentPos():? self
  495.     {
  496.         return $this->parent_pos;
  497.     }
  498.     public function setParentPos(?self $parent_pos): self
  499.     {
  500.         $this->parent_pos $parent_pos;
  501.         return $this;
  502.     }
  503.     /**
  504.      * @return Collection<int, self>
  505.      */
  506.     public function getDecomposedPositions(): Collection
  507.     {
  508.         return $this->decomposed_positions;
  509.     }
  510.     public function addDecomposedPosition(self $decomposedPosition): self
  511.     {
  512.         if (!$this->decomposed_positions->contains($decomposedPosition)) {
  513.             $this->decomposed_positions[] = $decomposedPosition;
  514.             $decomposedPosition->setParentPos($this);
  515.         }
  516.         return $this;
  517.     }
  518.     public function removeDecomposedPosition(self $decomposedPosition): self
  519.     {
  520.         if ($this->decomposed_positions->removeElement($decomposedPosition)) {
  521.             // set the owning side to null (unless already changed)
  522.             if ($decomposedPosition->getParentPos() === $this) {
  523.                 $decomposedPosition->setParentPos(null);
  524.             }
  525.         }
  526.         return $this;
  527.     }
  528.     /**
  529.      * TODO remove this forever
  530.      * @deprecated use documents as json
  531.      */
  532.     public function getDocument(): ?string
  533.     {
  534.         return $this->document;
  535.     }
  536.     /**
  537.      * TODO remove this forever
  538.      * @deprecated use documents as json
  539.      */
  540.     public function setDocument(?string $document): self
  541.     {
  542.         $this->document $document;
  543.         return $this;
  544.     }
  545.     public function getDocuments(): ?array { return $this->documents; }
  546.     public function setDocuments(?array $documents): self $this->documents $documents; return $this;}
  547.     public function getStock(): ?Stocks
  548.     {
  549.         return $this->stock;
  550.     }
  551.     public function setStock(?Stocks $stock): self
  552.     {
  553.         $this->stock $stock;
  554.         return $this;
  555.     }
  556.     public function getBuyingPrice(): ?float
  557.     {
  558.         return $this->buying_price;
  559.     }
  560.     public function setBuyingPrice(?float $buying_price): self
  561.     {
  562.         $this->buying_price $buying_price;
  563.         return $this;
  564.     }
  565.     public function getPriceUnit(): ?float
  566.     {
  567.         return $this->price_unit;
  568.     }
  569.     public function setPriceUnit(?float $price_unit): self
  570.     {
  571.         $this->price_unit $price_unit;
  572.         return $this;
  573.     }
  574.     public function getSalesPrice(): ?float
  575.     {
  576.         return $this->sales_price;
  577.     }
  578.     public function setSalesPrice(?float $sales_price): self
  579.     {
  580.         $this->sales_price $sales_price;
  581.         return $this;
  582.     }
  583.     public function getSalesMargin(): ?float
  584.     {
  585.         return $this->sales_margin;
  586.     }
  587.     public function setSalesMargin(?float $sales_margin): self
  588.     {
  589.         $this->sales_margin $sales_margin;
  590.         return $this;
  591.     }
  592.     public function getPurchaseRequestPosition(): ?PurchaseRequestPositions
  593.     {
  594.         return $this->purchase_request_position;
  595.     }
  596.     public function setPurchaseRequestPosition(?PurchaseRequestPositions $purchase_request_position): self
  597.     {
  598.         $this->purchase_request_position $purchase_request_position;
  599.         return $this;
  600.     }
  601.     public function getDeliveryAmount(): ?float
  602.     {
  603.         return $this->delivery_amount;
  604.     }
  605.     public function setDeliveryAmount(?float $delivery_amount): self
  606.     {
  607.         $this->delivery_amount $delivery_amount;
  608.         return $this;
  609.     }
  610.     public function getOfferNr(): ?string { return $this->offer_nr; }
  611.     public function setOfferNr(?string $offer_nr): self $this->offer_nr $offer_nr; return $this; }
  612.     public function getPositionType(): ?string { return $this->position_type; }
  613.     public function setPositionType(?string $position_type): self $this->position_type $position_type; return $this; }
  614.     public function getDeliveryStatus(): ?string { return $this->delivery_status; }
  615.     public function setDeliveryStatus(?string $delivery_status): self $this->delivery_status $delivery_status; return $this; }
  616.     public function getSize(): ?string { return $this->size; }
  617.     public function setSize(?string $size): self $this->size $size; return $this; }
  618.     public function getSupplierProduct(): ?SupplierProducts
  619.     {
  620.         return $this->supplier_product;
  621.     }
  622.     public function setSupplierProduct(?SupplierProducts $supplier_product): self
  623.     {
  624.         $this->supplier_product $supplier_product;
  625.         return $this;
  626.     }
  627. }