src/Entity/System/OrderReturnLine.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * OrderReturn
  7.  *
  8.  * @ORM\Table(name="ps_returns_lines")
  9.  *
  10.  * @ORM\Entity(repositoryClass="App\Repository\System\OrderReturnLineRepository")
  11.  */
  12. class OrderReturnLine
  13. {
  14.     /**
  15.      * @ORM\Id()
  16.      *
  17.      * @ORM\GeneratedValue()
  18.      *
  19.      * @ORM\Column(type="integer", name="id_returns_lines")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @var OrderReturn
  24.      *
  25.      * @ORM\ManyToOne(targetEntity="App\Entity\System\OrderReturn", inversedBy="lines")
  26.      *
  27.      * @ORM\JoinColumn(name="id_returns", referencedColumnName="id_returns")
  28.      */
  29.     private $rma;
  30.     /**
  31.      * @var OrderDetail
  32.      *
  33.      * @ORM\ManyToOne(targetEntity="App\Entity\System\OrderDetail")
  34.      *
  35.      * @ORM\JoinColumn(name="order_detail_id", referencedColumnName="id_order_detail")
  36.      */
  37.     private $orderDetail;
  38.     /**
  39.      * @var OrderReturnLineStatus
  40.      *
  41.      * @ORM\ManyToOne(targetEntity="App\Entity\System\OrderReturnLineStatus")
  42.      *
  43.      * @ORM\JoinColumn(name="status_id", referencedColumnName="id")
  44.      */
  45.     private $status;
  46.     /**
  47.      * @var int
  48.      *
  49.      * @ORM\Column(type="integer", name="product_qty", length=10)
  50.      */
  51.     private $productQuantity;
  52.     /**
  53.      * @var float
  54.      *
  55.      * @ORM\Column(type="float", options={"default" : 0.00})
  56.      */
  57.     private $price;
  58.     /**
  59.      * @var float
  60.      *
  61.      * @ORM\Column(type="float", options={"default" : 0.00})
  62.      */
  63.     private $tax;
  64.     /**
  65.      * @var \DateTime
  66.      *
  67.      * @ORM\Column(type="datetime")
  68.      */
  69.     private $dateAdd;
  70.     /**
  71.      * @var \DateTime
  72.      *
  73.      * @ORM\Column(type="datetime")
  74.      */
  75.     private $dateUpd;
  76.     /**
  77.      * @var string
  78.      *
  79.      * @ORM\Column(type="string", nullable=true)
  80.      */
  81.     private $noteSat;
  82.     /**
  83.      * @var string
  84.      *
  85.      * @ORM\Column(type="text", nullable=true)
  86.      */
  87.     private $satDescription;
  88.     /**
  89.      * @var string
  90.      *
  91.      * @ORM\Column(type="text", nullable=true, name="sat_comments")
  92.      */
  93.     private $satComments;
  94.     /**
  95.      * @var string
  96.      *
  97.      * @ORM\Column(type="text", nullable=true)
  98.      */
  99.     private $adminComments;
  100.     /**
  101.      * @var bool
  102.      *
  103.      * @ORM\Column(type="boolean", options={"default" : 0})
  104.      */
  105.     private $productOk;
  106.     /**
  107.      * @var bool
  108.      *
  109.      * @ORM\Column(type="boolean", options={"default" : 0})
  110.      */
  111.     private $validate;
  112.     /**
  113.      * @var bool
  114.      *
  115.      * @ORM\Column(type="boolean", options={"default" : 0}, nullable=true)
  116.      */
  117.     private $refused;
  118.     /**
  119.      * @var bool
  120.      *
  121.      * @ORM\Column(type="boolean", options={"default" : 0}, nullable=true)
  122.      */
  123.     private $confirmed;
  124.     /**
  125.      * @var bool
  126.      *
  127.      * @ORM\Column(type="boolean", name="revisar", options={"default" : 0}, nullable=true)
  128.      */
  129.     private $revised;
  130.     /**
  131.      * @var int
  132.      *
  133.      * @ORM\Column(type="integer", length=2)
  134.      */
  135.     private $taxRate;
  136.     /**
  137.      * @var string
  138.      *
  139.      * @ORM\Column(type="text")
  140.      */
  141.     private $returnReason;
  142.     /**
  143.      * @var OrderReturnLineComment[]|ArrayCollection
  144.      *
  145.      * @ORM\OneToMany(targetEntity="OrderReturnLineComment", mappedBy="returnsLine")
  146.      */
  147.     private $comments;
  148.     /**
  149.      * @var float
  150.      *
  151.      * @ORM\Column(type="float", options={"default" : 0})
  152.      */
  153.     private $total;
  154.     /**
  155.      * @var float
  156.      *
  157.      * @ORM\Column(type="float", options={"default" : 0})
  158.      */
  159.     private $totalPaid;
  160.     /**
  161.      * @var bool
  162.      *
  163.      * @ORM\Column(name="product_50", type="boolean", options={"default" : 0})
  164.      */
  165.     private $product50;
  166.     /**
  167.      * @var bool
  168.      *
  169.      * @ORM\Column(name="product_100", type="boolean", options={"default" : 0})
  170.      */
  171.     private $product100;
  172.     /**
  173.      * @var int
  174.      *
  175.      * @ORM\Column(type="integer")
  176.      */
  177.     private $receivedQuantity;
  178.     /**
  179.      * @var int
  180.      *
  181.      * @ORM\Column(type="integer")
  182.      */
  183.     private $acceptedQuantity;
  184.     public static function createRmaLine(
  185.         OrderReturn $rma,
  186.         OrderDetail $orderDetail,
  187.         \DateTime $creationDate,
  188.         OrderReturnLineStatus $status,
  189.         int $quantity,
  190.         float $price,
  191.         float $tax,
  192.         string $returnReason
  193.     ): OrderReturnLine {
  194.         $rmaLine = new self();
  195.         $rmaLine->dateAdd $creationDate;
  196.         $rmaLine->dateUpd $creationDate;
  197.         $rmaLine->status $status;
  198.         $rmaLine->rma $rma;
  199.         $rmaLine->orderDetail $orderDetail;
  200.         $rmaLine->productQuantity $quantity;
  201.         $rmaLine->price $price;
  202.         $rmaLine->tax $tax;
  203.         $rmaLine->validate 0;
  204.         $rmaLine->returnReason $returnReason;
  205.         $rmaLine->total $price $quantity;
  206.         $rmaLine->totalPaid $price $quantity;
  207.         $rmaLine->productOk false;
  208.         $rmaLine->product50 false;
  209.         $rmaLine->product100 false;
  210.         $rmaLine->receivedQuantity 0;
  211.         $rmaLine->acceptedQuantity 0;
  212.         $rmaLine->taxRate $orderDetail->getTaxRate();
  213.         return $rmaLine;
  214.     }
  215.     /**
  216.      * @return mixed
  217.      */
  218.     public function getId()
  219.     {
  220.         return $this->id;
  221.     }
  222.     /**
  223.      * @param mixed $id
  224.      *
  225.      * @return OrderReturnLine
  226.      */
  227.     public function setId($id): OrderReturnLine
  228.     {
  229.         $this->id $id;
  230.         return $this;
  231.     }
  232.     /**
  233.      * @return OrderReturn
  234.      */
  235.     public function getRma(): OrderReturn
  236.     {
  237.         return $this->rma;
  238.     }
  239.     /**
  240.      * @param OrderReturn $rma
  241.      *
  242.      * @return OrderReturnLine
  243.      */
  244.     public function setRma(OrderReturn $rma): OrderReturnLine
  245.     {
  246.         $this->rma $rma;
  247.         return $this;
  248.     }
  249.     /**
  250.      * @return int
  251.      */
  252.     public function getProductQuantity(): int
  253.     {
  254.         return $this->productQuantity;
  255.     }
  256.     /**
  257.      * @param int $productQuantity
  258.      *
  259.      * @return OrderReturnLine
  260.      */
  261.     public function setProductQuantity(int $productQuantity): OrderReturnLine
  262.     {
  263.         $this->productQuantity $productQuantity;
  264.         return $this;
  265.     }
  266.     /**
  267.      * @return float
  268.      */
  269.     public function getPrice(): float
  270.     {
  271.         return $this->price;
  272.     }
  273.     /**
  274.      * @param float $price
  275.      *
  276.      * @return OrderReturnLine
  277.      */
  278.     public function setPrice(float $price): OrderReturnLine
  279.     {
  280.         $this->price $price;
  281.         return $this;
  282.     }
  283.     /**
  284.      * @return int
  285.      */
  286.     public function getTaxRate(): int
  287.     {
  288.         return $this->taxRate;
  289.     }
  290.     /**
  291.      * @param int $taxRate
  292.      *
  293.      * @return OrderReturnLine
  294.      */
  295.     public function setTaxRate(int $taxRate): OrderReturnLine
  296.     {
  297.         $this->taxRate $taxRate;
  298.         return $this;
  299.     }
  300.     /**
  301.      * @return OrderDetail
  302.      */
  303.     public function getOrderDetail(): OrderDetail
  304.     {
  305.         return $this->orderDetail;
  306.     }
  307.     /**
  308.      * @return string
  309.      */
  310.     public function getReturnReason(): ?string
  311.     {
  312.         return $this->returnReason;
  313.     }
  314.     /**
  315.      * @param string $returnReason
  316.      */
  317.     public function setReturnReason(string $returnReason): void
  318.     {
  319.         $this->returnReason $returnReason;
  320.     }
  321.     /**
  322.      * @return OrderReturnLineStatus
  323.      */
  324.     public function getStatus(): OrderReturnLineStatus
  325.     {
  326.         return $this->status;
  327.     }
  328.     /**
  329.      * @param OrderReturnLineStatus $status
  330.      */
  331.     public function setStatus(OrderReturnLineStatus $status): void
  332.     {
  333.         $this->status $status;
  334.     }
  335.     /**
  336.      * @return OrderReturnLineComment[]|ArrayCollection
  337.      */
  338.     public function getComments()
  339.     {
  340.         return $this->comments;
  341.     }
  342.     /**
  343.      * @return float
  344.      */
  345.     public function getTotal(): float
  346.     {
  347.         return $this->total;
  348.     }
  349.     /**
  350.      * @return float
  351.      */
  352.     public function getTotalPaid(): float
  353.     {
  354.         return $this->totalPaid;
  355.     }
  356.     /**
  357.      * @param float $total
  358.      *
  359.      * @return OrderReturnLine
  360.      */
  361.     public function setTotal(float $total): OrderReturnLine
  362.     {
  363.         $this->total $total;
  364.         return $this;
  365.     }
  366.     /**
  367.      * @param float $totalPaid
  368.      *
  369.      * @return OrderReturnLine
  370.      */
  371.     public function setTotalPaid(float $totalPaid): OrderReturnLine
  372.     {
  373.         $this->totalPaid $totalPaid;
  374.         return $this;
  375.     }
  376.     /**
  377.      * @return bool
  378.      */
  379.     public function getProduct50(): bool
  380.     {
  381.         return $this->product50;
  382.     }
  383.     /**
  384.      * @return bool
  385.      */
  386.     public function getProduct100(): bool
  387.     {
  388.         return $this->product100;
  389.     }
  390.     /**
  391.      * @return bool
  392.      */
  393.     public function isRefused(): bool
  394.     {
  395.         return $this->refused;
  396.     }
  397.     /**
  398.      * @param bool $refused
  399.      */
  400.     public function setRefused(bool $refused): void
  401.     {
  402.         $this->refused $refused;
  403.     }
  404.     /**
  405.      * @return bool
  406.      */
  407.     public function isConfirmed(): bool
  408.     {
  409.         return $this->confirmed;
  410.     }
  411.     /**
  412.      * @param bool $confirmed
  413.      */
  414.     public function setConfirmed(bool $confirmed): void
  415.     {
  416.         $this->confirmed $confirmed;
  417.     }
  418.     public function getNoteSat(): ?string
  419.     {
  420.         return $this->noteSat;
  421.     }
  422.     public function setNoteSat(?string $noteSat): OrderReturnLine
  423.     {
  424.         $this->noteSat $noteSat;
  425.         return $this;
  426.     }
  427.     public function getTax(): float
  428.     {
  429.         return $this->tax;
  430.     }
  431.     public function setTax(float $tax): OrderReturnLine
  432.     {
  433.         $this->tax $tax;
  434.         return $this;
  435.     }
  436.     public function getReceivedQuantity(): int
  437.     {
  438.         return $this->receivedQuantity;
  439.     }
  440.     public function setReceivedQuantity(int $receivedQuantity): OrderReturnLine
  441.     {
  442.         $this->receivedQuantity $receivedQuantity;
  443.         return $this;
  444.     }
  445.     public function getAcceptedQuantity(): int
  446.     {
  447.         return $this->acceptedQuantity;
  448.     }
  449.     public function setAcceptedQuantity(int $acceptedQuantity): OrderReturnLine
  450.     {
  451.         $this->acceptedQuantity $acceptedQuantity;
  452.         return $this;
  453.     }
  454.     public function setProductOk(bool $productOk): OrderReturnLine
  455.     {
  456.         $this->productOk $productOk;
  457.         return $this;
  458.     }
  459.     public function setProduct50(bool $product50): OrderReturnLine
  460.     {
  461.         $this->product50 $product50;
  462.         return $this;
  463.     }
  464.     public function setProduct100(bool $product100): OrderReturnLine
  465.     {
  466.         $this->product100 $product100;
  467.         return $this;
  468.     }
  469.     public function isProductOk(): bool
  470.     {
  471.         return $this->productOk;
  472.     }
  473.     public function isProductReview(): bool
  474.     {
  475.         return $this->getProduct50() || $this->getProduct100() || $this->isProductOk();
  476.     }
  477.     public function getDamagedGoodsFee(): int
  478.     {
  479.         if ($this->getProduct50()) {
  480.             return 50;
  481.         }
  482.         if ($this->getProduct100()) {
  483.             return 100;
  484.         }
  485.         return 0;
  486.     }
  487.     public function getSatComments(): ?string
  488.     {
  489.         return $this->satComments;
  490.     }
  491.     public function setSatComments(?string $satComments): OrderReturnLine
  492.     {
  493.         $this->satComments $satComments;
  494.         return $this;
  495.     }
  496.     /**
  497.      * @return string[]
  498.      */
  499.     public function getCommentDetails(): array
  500.     {
  501.         return array_map(static function (OrderReturnLineComment $comment) {
  502.             return $comment->getComments();
  503.         }, $this->comments->toArray());
  504.     }
  505.     public function updateTax(): OrderReturnLine
  506.     {
  507.         $this->tax = ($this->totalPaid $this->taxRate) / 100;
  508.         return $this;
  509.     }
  510.     public function getAdminComments(): ?string
  511.     {
  512.         return $this->adminComments;
  513.     }
  514.     public function setAdminComments(?string $adminComments): OrderReturnLine
  515.     {
  516.         $this->adminComments $adminComments;
  517.         return $this;
  518.     }
  519. }