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.      * TODO not created yet!
  111.      * @deprecated use buying price instead
  112.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  113.      * @Groups({
  114.      *     "project.orders.expense.position.base",
  115.      *     "project.orders.expense.minify.version",
  116.      *     "project.orders.expense.positions.countable.version",
  117.      *     "expense.position.core", "expense_position@core",
  118.      *
  119.      *     "expense_position@base"
  120.      * })
  121.      */
  122.     private $amount;
  123.     /**
  124.      * @ORM\Column(type="integer", nullable=true)
  125.      * @Groups({
  126.      *     "project.orders.expense.position.base",
  127.      *     "expense.position.core", "expense_position@core"
  128.      * })
  129.      */
  130.     private $delivered_unit;
  131.     /**
  132.      * @ORM\Column(type="text", nullable=true)
  133.      * @Groups({
  134.      *     "project.orders.expense.position.base",
  135.      *     "project.orders.expense.minify.version",
  136.      *     "expense.position.core", "expense_position@core"
  137.      * })
  138.      *
  139.      */
  140.     private $content;
  141.     /**
  142.      * @ORM\Column(type="boolean", nullable=true)
  143.      * @Groups({
  144.      *     "project.orders.expense.position.base",
  145.      *     "expense.position.core", "expense_position@core"
  146.      * })
  147.      */
  148.     private $completed;
  149.     /**
  150.      * @ORM\Column(type="text", nullable=true)
  151.      * @Groups({
  152.      *     "project.orders.expense.position.base",
  153.      *     "expense.position.core", "expense_position@core"
  154.      * })
  155.      */
  156.     private $comment;
  157.     /**
  158.      * @ORM\Column(type="string", length=255, nullable=true)
  159.      * @Groups({
  160.      *     "project.orders.expense.position.base",
  161.      *     "expense.position.core", "expense_position@core"
  162.      * })
  163.      */
  164.     private $delivered_to;
  165.     /**
  166.      * @MaxDepth(1)
  167.      * @ORM\ManyToOne(targetEntity=ProjectOrders::class, inversedBy="projectOrderExpensePositions")
  168.      * @ORM\JoinColumn(onDelete="CASCADE")
  169.      * @Groups({
  170.      *     "project.orders.expense.position.base",
  171.      *     "project.order.expense.position.order",
  172.      *
  173.      *     "expense.position.order",
  174.      *
  175.      *     "expense_position@project_order"
  176.      * })
  177.      */
  178.     private $project_order;
  179.     /**
  180.      * A manipulated or simulated column is used to prevent circular references.
  181.      * It is used for retrieving the necessary information related to an order in order to generate
  182.      * a list of minified expenses for the associated spending
  183.      * @Groups({
  184.      *     "project.orders.expense.minify.version",
  185.      *     })
  186.      */
  187.     private $required_order_details_for_expense_history;
  188.     /**
  189.      * @return mixed
  190.      */
  191.     public function getRequiredOrderDetailsForExpenseHistory(): array
  192.     {
  193.         if($this->getProjectOrder()){
  194.             return [
  195.                 "id" => $this->getProjectOrder()->getId(),
  196.                 "order_nr" => $this->getProjectOrder()->getOrderNr()
  197.             ];
  198.         }
  199.         return [];
  200.     }
  201.     /**
  202.      * @ORM\Column(type="string", length=64, nullable=true)
  203.      * @Groups({
  204.      *     "project.orders.expense.position.base",
  205.      *     "expense.position.core", "expense_position@core"
  206.      * })
  207.      */
  208.     private $an_supplier;
  209.     /**
  210.      * @ORM\ManyToOne(targetEntity=ProjectOrderExpensePositions::class, inversedBy="decomposed_positions", cascade={"persist"})
  211.      * @Groups({
  212.      *     "project.orders.expense.position.base",
  213.      *     "expense.position.core", "expense_position@core"
  214.      * })
  215.      * @ORM\JoinColumn(onDelete="SET NULL")
  216.      */
  217.     private $parent_pos;
  218.     /**
  219.      * @ORM\OneToMany(targetEntity=ProjectOrderExpensePositions::class, mappedBy="parent_pos")
  220.      * @Groups({
  221.      *     "project.orders.expense.position.base",
  222.      *     "expense.position.decomposed"
  223.      * })
  224.      */
  225.     private $decomposed_positions;
  226.     /**
  227.      * TODO remove this forever
  228.      * @deprecated use documents as json
  229.      * @ORM\Column(type="string", length=255, nullable=true)
  230.      * @Groups({
  231.      *     "project.orders.expense.position.base",
  232.      *     "project.orders.expense.minify.version",
  233.      *     "expense.position.core", "expense_position@core"
  234.      * })
  235.      */
  236.     private $document;
  237.     /**
  238.      * @ORM\Column(type="json", nullable=true)
  239.      * @Groups({
  240.      *     "expense_position@core"
  241.      * })
  242.      */
  243.     private $documents;
  244.     /**
  245.      * @ORM\ManyToOne(targetEntity=Stocks::class, inversedBy="projectOrderExpensePositions")
  246.      * @Groups({
  247.      *      "project_orders_expense_position@stock"
  248.      *  })
  249.      */
  250.     private $stock;
  251.     /**
  252.      * @ORM\Column(type="float", nullable=true)
  253.      * @Groups({
  254.      *      "project.orders.expense.position.base",
  255.      *      "project.orders.expense.minify.version",
  256.      *      "project.orders.expense.positions.countable.version",
  257.      *      "expense.position.core", "expense_position@core"
  258.      *  })
  259.      */
  260.     private $buying_price;
  261.     /**
  262.      * Position-level override of supplier_products.price_unit (Preiseinheit / PE).
  263.      * NULL means inherit from supplier_product, or default to per single unit.
  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 $price_unit;
  274.     /**
  275.      * @ORM\Column(type="float", nullable=true)
  276.      * @Groups({
  277.      *      "project.orders.expense.position.base",
  278.      *      "project.orders.expense.minify.version",
  279.      *      "project.orders.expense.positions.countable.version",
  280.      *      "expense.position.core", "expense_position@core"
  281.      *  })
  282.      */
  283.     private $sales_price;
  284.     /**
  285.      * @ORM\Column(type="float", nullable=true)
  286.      * @Groups({
  287.      *      "project.orders.expense.position.base",
  288.      *      "project.orders.expense.minify.version",
  289.      *      "project.orders.expense.positions.countable.version",
  290.      *      "expense.position.core", "expense_position@core"
  291.      *  })
  292.      */
  293.     private $sales_margin;
  294.     /**
  295.      * @ORM\OneToOne(targetEntity=PurchaseRequestPositions::class, inversedBy="expense_position", cascade={"persist", "remove"})
  296.      * @ORM\JoinColumn(onDelete="CASCADE")
  297.      * @Groups({
  298.      *        "expense_position@purchse_request_position"
  299.      *    })
  300.      */
  301.     private $purchase_request_position;
  302.     /**
  303.      * @ORM\Column(type="float", nullable=true)
  304.      * @Groups({
  305.      *       "project.orders.expense.position.base",
  306.      *       "project.orders.expense.minify.version",
  307.      *       "project.orders.expense.positions.countable.version",
  308.      *       "expense.position.core", "expense_position@core"
  309.      *   })
  310.      */
  311.     private $delivery_amount;
  312.     /**
  313.      * @ORM\Column(type="string", length=255, nullable=true)
  314.      * @Groups({"expense_position@core", "expense_position@base"})
  315.      */
  316.     private $offer_nr;
  317.     /**
  318.      * @ORM\Column(type="string", nullable=true, columnDefinition="ENUM('item','service','delivery')")
  319.      * @Groups({"expense_position@core"})
  320.      */
  321.     private $position_type;
  322.     /**
  323.      * @ORM\Column(type="string", nullable=true, columnDefinition="ENUM('pending','sent','delivered')")
  324.      * @Groups({"expense_position@core"})
  325.      */
  326.     private $delivery_status;
  327.     /**
  328.      * @deprecated use supplier_product instead
  329.      * @ORM\Column(type="string", length=255, nullable=true)
  330.      * @Groups({"expense_position@core", "expense_position@base"})
  331.      */
  332.     private $size;
  333.     /**
  334.      * @ORM\ManyToOne(targetEntity=SupplierProducts::class, inversedBy="project_order_expense_positions")
  335.      * @ORM\JoinColumn(onDelete="CASCADE")
  336.      * @Groups({
  337.      *     "expense_position@supplier_product"
  338.      * })
  339.      */
  340.     private $supplier_product;
  341.     public function __construct()
  342.     {
  343.         $this->decomposed_positions = new ArrayCollection();
  344.     }
  345.     public function getId(): ?int
  346.     {
  347.         return $this->id;
  348.     }
  349.     public function getProjectOrderExpense(): ?ProjectOrderExpenses
  350.     {
  351.         return $this->project_order_expense;
  352.     }
  353.     public function setProjectOrderExpense(?ProjectOrderExpenses $project_order_expense): self
  354.     {
  355.         $this->project_order_expense $project_order_expense;
  356.         return $this;
  357.     }
  358.     public function getMaterial(): ?Material
  359.     {
  360.         return $this->material;
  361.     }
  362.     public function setMaterial(?Material $material): self
  363.     {
  364.         $this->material $material;
  365.         return $this;
  366.     }
  367.     public function getUnit(): ?float
  368.     {
  369.         return $this->unit;
  370.     }
  371.     public function setUnit(float $unit): self
  372.     {
  373.         $this->unit $unit;
  374.         return $this;
  375.     }
  376.     public function getCreatedAt(): ?\DateTimeImmutable
  377.     {
  378.         return $this->created_at;
  379.     }
  380.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  381.     {
  382.         $this->created_at $created_at;
  383.         return $this;
  384.     }
  385.     public function getDeliveredAt(): ?\DateTimeImmutable
  386.     {
  387.         return $this->delivered_at;
  388.     }
  389.     public function setDeliveredAt(?\DateTimeImmutable $delivered_at): self
  390.     {
  391.         $this->delivered_at $delivered_at;
  392.         return $this;
  393.     }
  394.     /**
  395.      * @deprecated use buying price instead
  396.      */
  397.     public function getAmount(): ?string
  398.     {
  399.         return $this->amount;
  400.     }
  401.     /**
  402.      * @deprecated use buying price instead
  403.      */
  404.     public function setAmount(?string $amount): self
  405.     {
  406.         $this->amount $amount;
  407.         return $this;
  408.     }
  409.     public function getDeliveredUnit(): ?int
  410.     {
  411.         return $this->delivered_unit;
  412.     }
  413.     public function setDeliveredUnit(?int $delivered_unit): self
  414.     {
  415.         $this->delivered_unit $delivered_unit;
  416.         return $this;
  417.     }
  418.     public function getContent(): ?string
  419.     {
  420.         return $this->content;
  421.     }
  422.     public function setContent(?string $content): self
  423.     {
  424.         $this->content $content;
  425.         return $this;
  426.     }
  427.     public function getCompleted(): ?bool
  428.     {
  429.         return $this->completed;
  430.     }
  431.     public function setCompleted(?bool $completed): self
  432.     {
  433.         $this->completed $completed;
  434.         return $this;
  435.     }
  436.     public function getComment(): ?string
  437.     {
  438.         return $this->comment;
  439.     }
  440.     public function setComment(?string $comment): self
  441.     {
  442.         $this->comment $comment;
  443.         return $this;
  444.     }
  445.     public function getDeliveredTo(): ?string
  446.     {
  447.         return $this->delivered_to;
  448.     }
  449.     public function setDeliveredTo(?string $delivered_to): self
  450.     {
  451.         $this->delivered_to $delivered_to;
  452.         return $this;
  453.     }
  454.     public function getProjectOrder(): ?ProjectOrders
  455.     {
  456.         return $this->project_order;
  457.     }
  458.     public function setProjectOrder(?ProjectOrders $project_order): self
  459.     {
  460.         $this->project_order $project_order;
  461.         return $this;
  462.     }
  463.     public function getAnSupplier(): ?string
  464.     {
  465.         return $this->an_supplier;
  466.     }
  467.     public function setAnSupplier(?string $an_supplier): self
  468.     {
  469.         $this->an_supplier $an_supplier;
  470.         return $this;
  471.     }
  472.     public function getParentPos():? self
  473.     {
  474.         return $this->parent_pos;
  475.     }
  476.     public function setParentPos(?self $parent_pos): self
  477.     {
  478.         $this->parent_pos $parent_pos;
  479.         return $this;
  480.     }
  481.     /**
  482.      * @return Collection<int, self>
  483.      */
  484.     public function getDecomposedPositions(): Collection
  485.     {
  486.         return $this->decomposed_positions;
  487.     }
  488.     public function addDecomposedPosition(self $decomposedPosition): self
  489.     {
  490.         if (!$this->decomposed_positions->contains($decomposedPosition)) {
  491.             $this->decomposed_positions[] = $decomposedPosition;
  492.             $decomposedPosition->setParentPos($this);
  493.         }
  494.         return $this;
  495.     }
  496.     public function removeDecomposedPosition(self $decomposedPosition): self
  497.     {
  498.         if ($this->decomposed_positions->removeElement($decomposedPosition)) {
  499.             // set the owning side to null (unless already changed)
  500.             if ($decomposedPosition->getParentPos() === $this) {
  501.                 $decomposedPosition->setParentPos(null);
  502.             }
  503.         }
  504.         return $this;
  505.     }
  506.     /**
  507.      * TODO remove this forever
  508.      * @deprecated use documents as json
  509.      */
  510.     public function getDocument(): ?string
  511.     {
  512.         return $this->document;
  513.     }
  514.     /**
  515.      * TODO remove this forever
  516.      * @deprecated use documents as json
  517.      */
  518.     public function setDocument(?string $document): self
  519.     {
  520.         $this->document $document;
  521.         return $this;
  522.     }
  523.     public function getDocuments(): ?array { return $this->documents; }
  524.     public function setDocuments(?array $documents): self $this->documents $documents; return $this;}
  525.     public function getStock(): ?Stocks
  526.     {
  527.         return $this->stock;
  528.     }
  529.     public function setStock(?Stocks $stock): self
  530.     {
  531.         $this->stock $stock;
  532.         return $this;
  533.     }
  534.     public function getBuyingPrice(): ?float
  535.     {
  536.         return $this->buying_price;
  537.     }
  538.     public function setBuyingPrice(?float $buying_price): self
  539.     {
  540.         $this->buying_price $buying_price;
  541.         return $this;
  542.     }
  543.     public function getPriceUnit(): ?float
  544.     {
  545.         return $this->price_unit;
  546.     }
  547.     public function setPriceUnit(?float $price_unit): self
  548.     {
  549.         $this->price_unit $price_unit;
  550.         return $this;
  551.     }
  552.     public function getSalesPrice(): ?float
  553.     {
  554.         return $this->sales_price;
  555.     }
  556.     public function setSalesPrice(?float $sales_price): self
  557.     {
  558.         $this->sales_price $sales_price;
  559.         return $this;
  560.     }
  561.     public function getSalesMargin(): ?float
  562.     {
  563.         return $this->sales_margin;
  564.     }
  565.     public function setSalesMargin(?float $sales_margin): self
  566.     {
  567.         $this->sales_margin $sales_margin;
  568.         return $this;
  569.     }
  570.     public function getPurchaseRequestPosition(): ?PurchaseRequestPositions
  571.     {
  572.         return $this->purchase_request_position;
  573.     }
  574.     public function setPurchaseRequestPosition(?PurchaseRequestPositions $purchase_request_position): self
  575.     {
  576.         $this->purchase_request_position $purchase_request_position;
  577.         return $this;
  578.     }
  579.     public function getDeliveryAmount(): ?float
  580.     {
  581.         return $this->delivery_amount;
  582.     }
  583.     public function setDeliveryAmount(?float $delivery_amount): self
  584.     {
  585.         $this->delivery_amount $delivery_amount;
  586.         return $this;
  587.     }
  588.     public function getOfferNr(): ?string { return $this->offer_nr; }
  589.     public function setOfferNr(?string $offer_nr): self $this->offer_nr $offer_nr; return $this; }
  590.     public function getPositionType(): ?string { return $this->position_type; }
  591.     public function setPositionType(?string $position_type): self $this->position_type $position_type; return $this; }
  592.     public function getDeliveryStatus(): ?string { return $this->delivery_status; }
  593.     public function setDeliveryStatus(?string $delivery_status): self $this->delivery_status $delivery_status; return $this; }
  594.     public function getSize(): ?string { return $this->size; }
  595.     public function setSize(?string $size): self $this->size $size; return $this; }
  596.     public function getSupplierProduct(): ?SupplierProducts
  597.     {
  598.         return $this->supplier_product;
  599.     }
  600.     public function setSupplierProduct(?SupplierProducts $supplier_product): self
  601.     {
  602.         $this->supplier_product $supplier_product;
  603.         return $this;
  604.     }
  605. }