src/Entity/System/SubscriptionLine.php line 18

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.  * SubscriptionLine
  7.  *
  8.  * @ORM\Table(name="subscriptions_lines", indexes={
  9.  *
  10.  *     @ORM\Index(name="name", columns={"name"})
  11.  * })
  12.  *
  13.  * @ORM\Entity(repositoryClass="App\Repository\System\SubscriptionLineRepository")
  14.  */
  15. class SubscriptionLine
  16. {
  17.     public const MANUAL_CHANGE 'Cambio manual';
  18.     public const CANCEL_NAME_VALUE 'Cancel';
  19.     /**
  20.      * @var int
  21.      *
  22.      * @ORM\Id
  23.      *
  24.      * @ORM\GeneratedValue(strategy="AUTO")
  25.      *
  26.      * @ORM\Column(type="integer", name="id_subscription_lines")
  27.      */
  28.     private $id;
  29.     /**
  30.      * @var Subscription
  31.      *
  32.      * @ORM\ManyToOne(targetEntity="App\Entity\System\Subscription", inversedBy="subscriptionLines")
  33.      *
  34.      * @ORM\JoinColumn(referencedColumnName="id_subscription", name="id_subscription")
  35.      */
  36.     private $subscription;
  37.     /**
  38.      * @var SubscriptionGroup
  39.      *
  40.      * @ORM\ManyToOne(targetEntity="App\Entity\System\SubscriptionGroup", inversedBy="subscriptionLines")
  41.      *
  42.      * @ORM\JoinColumn(referencedColumnName="id_group", name="id_group")
  43.      */
  44.     private $group;
  45.     /**
  46.      * @var string|null
  47.      *
  48.      * @ORM\Column(type="string", length=100, nullable=true)
  49.      */
  50.     private $name;
  51.     /**
  52.      * @var \DateTime
  53.      *
  54.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  55.      */
  56.     private $dateCreate;
  57.     /**
  58.      * @var Customer|null
  59.      *
  60.      * @ORM\ManyToOne(targetEntity="App\Entity\System\Customer", inversedBy="subscriptionLines")
  61.      *
  62.      * @ORM\JoinColumn(referencedColumnName="id_customer", name="id_customer")
  63.      */
  64.     private $customer;
  65.     /**
  66.      * @var \DateTime
  67.      *
  68.      * @ORM\Column(type="datetime", nullable=true, options={"default": "0000-00-00 00:00:00"})
  69.      */
  70.     private $dateDue;
  71.     /**
  72.      * @var float|null
  73.      *
  74.      * @ORM\Column(type="float", nullable=true)
  75.      */
  76.     private $cost;
  77.     /**
  78.      * @var int
  79.      *
  80.      * @ORM\Column(type="integer", nullable=true)
  81.      */
  82.     private $userCreate;
  83.     /**
  84.      * @var int
  85.      *
  86.      * @ORM\Column(type="integer", nullable=true)
  87.      */
  88.     private $userMod;
  89.     /**
  90.      * @var int|null
  91.      *
  92.      * @ORM\Column(name="nintentos", type="integer", options={"default" : 0}, nullable=true)
  93.      */
  94.     private ?int $numberAttempts 0;
  95.     /**
  96.      * @var int
  97.      *
  98.      * @ORM\Column(type="integer", options={"default" : 0}, nullable=false)
  99.      */
  100.     private int $cycles 0;
  101.     /**
  102.      * @var int
  103.      *
  104.      * @ORM\Column(type="integer", nullable=false, options={"default": 0})
  105.      */
  106.     private int $numCycles 0;
  107.     /**
  108.      * @var string|null
  109.      *
  110.      * @ORM\Column(name="id_transaction", type="string", length=50, nullable=true)
  111.      */
  112.     private $transaction;
  113.     /**
  114.      * @var array|ArrayCollection<int, SubscriptionCustomer>
  115.      *
  116.      * @ORM\OneToMany(targetEntity="App\Entity\System\SubscriptionCustomer", mappedBy="subscriptionLine", cascade={"persist"})
  117.      */
  118.     private $subscriptionCustomers;
  119.     /**
  120.      * @ORM\Column(type="boolean", nullable=true, options={"default": 0})
  121.      */
  122.     private bool $migrated false;
  123.     /**
  124.      * @ORM\Column(type="string", length=64, name="internal_migration_status", nullable=true)
  125.      */
  126.     private ?string $internalMigrationStatus;
  127.     /**
  128.      * @return int
  129.      */
  130.     public function getId(): int
  131.     {
  132.         return $this->id;
  133.     }
  134.     /**
  135.      * @return Subscription
  136.      */
  137.     public function getSubscription(): Subscription
  138.     {
  139.         return $this->subscription;
  140.     }
  141.     /**
  142.      * @param Subscription $subscription
  143.      *
  144.      * @return SubscriptionLine
  145.      */
  146.     public function setSubscription(Subscription $subscription): SubscriptionLine
  147.     {
  148.         $this->subscription $subscription;
  149.         return $this;
  150.     }
  151.     /**
  152.      * @return SubscriptionGroup
  153.      */
  154.     public function getGroup(): SubscriptionGroup
  155.     {
  156.         return $this->group;
  157.     }
  158.     /**
  159.      * @param SubscriptionGroup $group
  160.      *
  161.      * @return SubscriptionLine
  162.      */
  163.     public function setGroup(SubscriptionGroup $group): SubscriptionLine
  164.     {
  165.         $this->group $group;
  166.         return $this;
  167.     }
  168.     /**
  169.      * @return string
  170.      */
  171.     public function getName(): string
  172.     {
  173.         return $this->name;
  174.     }
  175.     /**
  176.      * @param string|null $name
  177.      *
  178.      * @return SubscriptionLine
  179.      */
  180.     public function setName(?string $name): SubscriptionLine
  181.     {
  182.         $this->name $name;
  183.         return $this;
  184.     }
  185.     /**
  186.      * @return \DateTime
  187.      */
  188.     public function getDateCreate(): \DateTime
  189.     {
  190.         return $this->dateCreate;
  191.     }
  192.     /**
  193.      * @param \DateTime $dateCreate
  194.      *
  195.      * @return SubscriptionLine
  196.      */
  197.     public function setDateCreate(\DateTime $dateCreate): SubscriptionLine
  198.     {
  199.         $this->dateCreate $dateCreate;
  200.         return $this;
  201.     }
  202.     /**
  203.      * @return Customer
  204.      */
  205.     public function getCustomer(): Customer
  206.     {
  207.         return $this->customer;
  208.     }
  209.     /**
  210.      * @param Customer|null $customer
  211.      *
  212.      * @return SubscriptionLine
  213.      */
  214.     public function setCustomer(?Customer $customer): SubscriptionLine
  215.     {
  216.         $this->customer $customer;
  217.         return $this;
  218.     }
  219.     /**
  220.      * @return \DateTime
  221.      */
  222.     public function getDateDue(): ?\DateTime
  223.     {
  224.         return $this->dateDue;
  225.     }
  226.     /**
  227.      * @param \DateTime|null $dateDue
  228.      *
  229.      * @return SubscriptionLine
  230.      */
  231.     public function setDateDue(?\DateTime $dateDue): SubscriptionLine
  232.     {
  233.         $this->dateDue $dateDue;
  234.         return $this;
  235.     }
  236.     /**
  237.      * @return float
  238.      */
  239.     public function getCost(): float
  240.     {
  241.         return $this->cost;
  242.     }
  243.     /**
  244.      * @param float|null $cost
  245.      *
  246.      * @return SubscriptionLine
  247.      */
  248.     public function setCost(?float $cost): SubscriptionLine
  249.     {
  250.         $this->cost $cost;
  251.         return $this;
  252.     }
  253.     /**
  254.      * @return int
  255.      */
  256.     public function getUserCreate(): int
  257.     {
  258.         return $this->userCreate;
  259.     }
  260.     /**
  261.      * @param int $userCreate
  262.      *
  263.      * @return SubscriptionLine
  264.      */
  265.     public function setUserCreate(int $userCreate): SubscriptionLine
  266.     {
  267.         $this->userCreate $userCreate;
  268.         return $this;
  269.     }
  270.     /**
  271.      * @return int
  272.      */
  273.     public function getUserMod(): int
  274.     {
  275.         return $this->userMod;
  276.     }
  277.     /**
  278.      * @param int $userMod
  279.      *
  280.      * @return SubscriptionLine
  281.      */
  282.     public function setUserMod(int $userMod): SubscriptionLine
  283.     {
  284.         $this->userMod $userMod;
  285.         return $this;
  286.     }
  287.     /**
  288.      * @return int|null
  289.      */
  290.     public function getNumberAttempts(): ?int
  291.     {
  292.         return $this->numberAttempts;
  293.     }
  294.     /**
  295.      * @param int|null $numberAttempts
  296.      *
  297.      * @return SubscriptionLine
  298.      */
  299.     public function setNumberAttempts(?int $numberAttempts): SubscriptionLine
  300.     {
  301.         $this->numberAttempts $numberAttempts;
  302.         return $this;
  303.     }
  304.     public function getCycles(): int
  305.     {
  306.         return $this->cycles;
  307.     }
  308.     public function setCycles(int $cycles): SubscriptionLine
  309.     {
  310.         $this->cycles $cycles;
  311.         return $this;
  312.     }
  313.     /**
  314.      * @return int|null
  315.      */
  316.     public function getNumCycles(): ?int
  317.     {
  318.         return $this->numCycles;
  319.     }
  320.     /**
  321.      * @param int|null $numCycles
  322.      *
  323.      * @return SubscriptionLine
  324.      */
  325.     public function setNumCycles(?int $numCycles): SubscriptionLine
  326.     {
  327.         $this->numCycles $numCycles;
  328.         return $this;
  329.     }
  330.     /**
  331.      * @return string|null
  332.      */
  333.     public function getTransaction(): ?string
  334.     {
  335.         return $this->transaction;
  336.     }
  337.     /**
  338.      * @param string|null $transaction
  339.      *
  340.      * @return SubscriptionLine
  341.      */
  342.     public function setTransaction(?string $transaction): SubscriptionLine
  343.     {
  344.         $this->transaction $transaction;
  345.         return $this;
  346.     }
  347.     public function cancelSubscriptionLine(): void
  348.     {
  349.         $this->name 'Cancel';
  350.         $this->dateDue null;
  351.     }
  352.     public function incrementNumberAttempts(int $days): void
  353.     {
  354.         $this->numberAttempts++;
  355.         if ($this->dateDue === null) {
  356.             $this->dateDue = new \DateTime();
  357.         }
  358.         $this->dateDue->modify("+$days Days");
  359.     }
  360.     public function isMigrated(): bool
  361.     {
  362.         return $this->migrated;
  363.     }
  364.     public function setMigrated(bool $migrated): SubscriptionLine
  365.     {
  366.         $this->migrated $migrated;
  367.         return $this;
  368.     }
  369.     /**
  370.      * @return array|ArrayCollection<int, SubscriptionCustomer>
  371.      */
  372.     public function getSubscriptionCustomers()
  373.     {
  374.         return $this->subscriptionCustomers;
  375.     }
  376.     public function setSubscriptionCustomers(array $subscriptionCustomers): SubscriptionLine
  377.     {
  378.         $this->subscriptionCustomers $subscriptionCustomers;
  379.         return $this;
  380.     }
  381.     public function getInternalMigrationStatus(): ?string
  382.     {
  383.         return $this->internalMigrationStatus;
  384.     }
  385.     public function setInternalMigrationStatus(?string $internalMigrationStatus): SubscriptionLine
  386.     {
  387.         $this->internalMigrationStatus $internalMigrationStatus;
  388.         return $this;
  389.     }
  390.     public function setSubscriptionToMigrated(): self
  391.     {
  392.         $this->migrated true;
  393.         $this->internalMigrationStatus 'migrated';
  394.         return $this;
  395.     }
  396. }