src/Entity/System/SubscriptionLine.php line 19

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