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