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