src/Entity/SubscriptionOrder.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\Common\Collections\Criteria;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  9. /**
  10. * @ORM\Entity(repositoryClass="App\Repository\SubscriptionOrderRepository")
  11. * @ORM\HasLifecycleCallbacks()
  12. */
  13. class SubscriptionOrder
  14. {
  15. /**
  16. * @ORM\Id()
  17. * @ORM\GeneratedValue()
  18. * @ORM\Column(type="integer")
  19. */
  20. private $id;
  21. /**
  22. * @ORM\ManyToOne(targetEntity="App\Entity\Child", inversedBy="subscriptionOrders")
  23. */
  24. private $participant;
  25. /**
  26. * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="subscriptionOrders")
  27. * @ORM\JoinColumn(nullable=false)
  28. */
  29. private $user;
  30. /**
  31. * @ORM\Column(type="string", length=255)
  32. */
  33. private $customerId;
  34. /**
  35. * @ORM\Column(type="datetime")
  36. */
  37. private $purchaseDate;
  38. /**
  39. * @ORM\Column(type="datetime", nullable=true)
  40. * use for track schedules change and limit the changes for 30 days
  41. */
  42. private $updateAt;
  43. /**
  44. * @ORM\Column(type="boolean")
  45. */
  46. private $isActif;
  47. /**
  48. * @ORM\OneToMany(targetEntity="App\Entity\TeacherSchedule", mappedBy="subscriptionOrder")
  49. */
  50. private $schedules;
  51. /**
  52. * @ORM\ManyToOne(targetEntity="App\Entity\Plan", inversedBy="subscriptionOrders")
  53. * @ORM\JoinColumn(nullable=false)
  54. */
  55. private $plan;
  56. /**
  57. * @ORM\ManyToOne(targetEntity="App\Entity\Teacher", inversedBy="subscriptionOrders")
  58. * @ORM\JoinColumn(nullable=false)
  59. */
  60. private $teacher;
  61. /**
  62. * @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="subscriptionOrders")
  63. * @ORM\JoinColumn(nullable=false)
  64. */
  65. private $category;
  66. /**
  67. * @ORM\Column(type="datetime")
  68. */
  69. private $coursesStartAt;
  70. /**
  71. * @ORM\ManyToOne(targetEntity="App\Entity\Subject", inversedBy="subscriptionOrders")
  72. */
  73. private $subject;
  74. /**
  75. * @ORM\Column(type="integer")
  76. */
  77. private $catchUpRight;
  78. /**
  79. * @ORM\Column(type="datetime", nullable=true)
  80. */
  81. private $nextPaymentDate;
  82. /**
  83. * @ORM\OneToMany(targetEntity="App\Entity\PaidCourseList", mappedBy="subscriptionOrder")
  84. */
  85. private $coursesList;
  86. /**
  87. * @ORM\Column(type="string", length=100, nullable=true)
  88. */
  89. private $cardBrand;
  90. /**
  91. * @ORM\Column(type="string", length=50, nullable=true)
  92. */
  93. private $cardLast4;
  94. /**
  95. * @ORM\Column(type="string", length=255, nullable=true)
  96. */
  97. private $stripeSubscriptionId;
  98. /**
  99. * @ORM\Column(type="datetime", nullable=true)
  100. */
  101. private $renewBefore;
  102. /**
  103. * @ORM\Column(type="boolean", nullable=true)
  104. */
  105. private $isCancelled;
  106. /**
  107. * @ORM\Column(type="integer")
  108. */
  109. private $nbOfScheduleChoose = 1;
  110. /**
  111. * @ORM\Column(type="boolean", nullable=true)
  112. */
  113. private $isDue;
  114. /**
  115. * @ORM\Column(type="string", length=255, nullable=true)
  116. */
  117. private $nextPaymentTimeStamp;
  118. /**
  119. * @ORM\Column(type="datetime", nullable=true)
  120. */
  121. private $lastPaidCourse;
  122. /**
  123. * @ORM\Column(type="datetime", nullable=true)
  124. */
  125. private $lastScheduleChangeAt;
  126. /**
  127. * @ORM\OneToMany(targetEntity="App\Entity\PlanUpdateLog", mappedBy="subscription")
  128. */
  129. private $planUpdateLogs;
  130. /**
  131. * @ORM\OneToMany(targetEntity="App\Entity\AbsenceLog", mappedBy="subscription")
  132. */
  133. private $absenceLogs;
  134. /**
  135. * @ORM\OneToMany(targetEntity="App\Entity\SubscriptionLessonReport", mappedBy="subscription", orphanRemoval=true)
  136. */
  137. private $subscriptionLessonReports;
  138. /**
  139. * @ORM\Column(type="datetime", nullable=true)
  140. */
  141. private $cancellationDate;
  142. /**
  143. * @ORM\ManyToOne(targetEntity="App\Entity\SubjectLevel", inversedBy="subscriptionOrder")
  144. */
  145. private $subjectLevel;
  146. /**
  147. * @ORM\Column(type="decimal", precision=25, scale=15)
  148. */
  149. private $paidAmount;
  150. /**
  151. * @ORM\Column(type="integer", nullable=true)
  152. */
  153. private $TotalLostMinutes;
  154. /**
  155. * @ORM\OneToMany(targetEntity="App\Entity\Homework", mappedBy="RelatedToSubscription")
  156. */
  157. private $homeworks;
  158. /**
  159. * @ORM\Column(type="boolean", nullable=true)
  160. */
  161. private $haveRamadanCredit;
  162. /**
  163. * @ORM\Column(type="decimal", precision=25, scale=15, nullable=true)
  164. */
  165. private $ramadanCreditAmount;
  166. /**
  167. * @ORM\OneToMany(targetEntity="App\Entity\EmailListSubscribeLostLog", mappedBy="subscriptionOrder")
  168. */
  169. private $subscribeLostLogs;
  170. /**
  171. * @ORM\OneToMany(targetEntity="App\Entity\EmailListUnsubscribeLog", mappedBy="subscriptionOrder")
  172. */
  173. private $unsubscribeLogs;
  174. /**
  175. * @ORM\OneToMany(targetEntity=Exam::class, mappedBy="relatedToSubscription")
  176. */
  177. private $exams;
  178. /**
  179. * @ORM\OneToMany(targetEntity=TrainingReport::class, mappedBy="relatedToSubscription")
  180. */
  181. private $trainingReports;
  182. /**
  183. * @ORM\Column(type="string", length=3, nullable=true)
  184. */
  185. private $paymentCurrency;
  186. /**
  187. * @ORM\Column(type="decimal", precision=25, scale=15, nullable=true)
  188. */
  189. private $amountPaidLocalCurrency;
  190. /**
  191. * @ORM\Column(type="decimal", precision=25, scale=15, nullable=true)
  192. */
  193. private $amountReceivedUsd;
  194. /**
  195. * @ORM\Column(type="decimal", precision=25, scale=15, nullable=true)
  196. */
  197. private $stripeFees;
  198. public function __construct()
  199. {
  200. $this->schedules = new ArrayCollection();
  201. $this->coursesList = new ArrayCollection();
  202. $this->planUpdateLogs = new ArrayCollection();
  203. $this->absenceLogs = new ArrayCollection();
  204. $this->subscriptionLessonReports = new ArrayCollection();
  205. $this->homeworks = new ArrayCollection();
  206. $this->subscribeLostLogs = new ArrayCollection();
  207. $this->unsubscribeLogs = new ArrayCollection();
  208. $this->exams = new ArrayCollection();
  209. $this->trainingReports = new ArrayCollection();
  210. }
  211. public function getId(): ?int
  212. {
  213. return $this->id;
  214. }
  215. public function getPurchaseDate(): ?\DateTimeInterface
  216. {
  217. return $this->purchaseDate;
  218. }
  219. public function setPurchaseDate(\DateTimeInterface $purchaseDate): self
  220. {
  221. $this->purchaseDate = $purchaseDate;
  222. return $this;
  223. }
  224. public function getCustomerId(): ?string
  225. {
  226. return $this->customerId;
  227. }
  228. public function setCustomerId(string $customerId): self
  229. {
  230. $this->customerId = $customerId;
  231. return $this;
  232. }
  233. public function getUpdateAt(): ?\DateTimeInterface
  234. {
  235. return $this->updateAt;
  236. }
  237. public function setUpdateAt(?\DateTimeInterface $updateAt): self
  238. {
  239. $this->updateAt = $updateAt;
  240. return $this;
  241. }
  242. public function getIsActif(): ?bool
  243. {
  244. return $this->isActif;
  245. }
  246. public function setIsActif(bool $isActif): self
  247. {
  248. $this->isActif = $isActif;
  249. return $this;
  250. }
  251. public function getParticipant(): ?Child
  252. {
  253. return $this->participant;
  254. }
  255. public function setParticipant(?Child $participant): self
  256. {
  257. $this->participant = $participant;
  258. return $this;
  259. }
  260. public function getUser(): ?User
  261. {
  262. return $this->user;
  263. }
  264. public function setUser(?User $user): self
  265. {
  266. $this->user = $user;
  267. return $this;
  268. }
  269. /**
  270. * @return Collection|TeacherSchedule[]
  271. */
  272. public function getSchedules(): Collection
  273. {
  274. return $this->schedules;
  275. }
  276. public function addSchedule(TeacherSchedule $schedule): self
  277. {
  278. if (!$this->schedules->contains($schedule)) {
  279. $this->schedules[] = $schedule;
  280. $schedule->setSubscriptionOrder($this);
  281. }
  282. return $this;
  283. }
  284. public function removeSchedule(TeacherSchedule $schedule): self
  285. {
  286. if ($this->schedules->contains($schedule)) {
  287. $this->schedules->removeElement($schedule);
  288. // set the owning side to null (unless already changed)
  289. if ($schedule->getSubscriptionOrder() === $this) {
  290. $schedule->setSubscriptionOrder(null);
  291. }
  292. }
  293. return $this;
  294. }
  295. public function getPlan(): ?Plan
  296. {
  297. return $this->plan;
  298. }
  299. public function setPlan(?Plan $plan): self
  300. {
  301. $this->plan = $plan;
  302. return $this;
  303. }
  304. public function getTeacher(): ?Teacher
  305. {
  306. return $this->teacher;
  307. }
  308. public function setTeacher(?Teacher $teacher): self
  309. {
  310. $this->teacher = $teacher;
  311. return $this;
  312. }
  313. public function getCategory(): ?Category
  314. {
  315. return $this->category;
  316. }
  317. public function setCategory(?Category $category): self
  318. {
  319. $this->category = $category;
  320. return $this;
  321. }
  322. public function getCoursesStartAt(): ?\DateTimeInterface
  323. {
  324. return $this->coursesStartAt;
  325. }
  326. public function setCoursesStartAt(\DateTimeInterface $coursesStartAt): self
  327. {
  328. $this->coursesStartAt = $coursesStartAt;
  329. return $this;
  330. }
  331. public function getSubject(): ?Subject
  332. {
  333. return $this->subject;
  334. }
  335. public function setSubject(?Subject $subject): self
  336. {
  337. $this->subject = $subject;
  338. return $this;
  339. }
  340. public function getCatchUpRight(): ?int
  341. {
  342. return $this->catchUpRight;
  343. }
  344. public function setCatchUpRight(int $catchUpRight): self
  345. {
  346. $this->catchUpRight = $catchUpRight;
  347. return $this;
  348. }
  349. public function getNextPaymentDate(): ?\DateTimeInterface
  350. {
  351. return $this->nextPaymentDate;
  352. }
  353. public function setNextPaymentDate(?\DateTimeInterface $nextPaymentDate): self
  354. {
  355. $this->nextPaymentDate = $nextPaymentDate;
  356. return $this;
  357. }
  358. /**
  359. * @return Collection|PaidCourseList[]
  360. */
  361. public function getCoursesList(): Collection
  362. {
  363. return $this->coursesList;
  364. }
  365. public function addCoursesList(PaidCourseList $coursesList): self
  366. {
  367. if (!$this->coursesList->contains($coursesList)) {
  368. $this->coursesList[] = $coursesList;
  369. $coursesList->setSubscriptionOrder($this);
  370. }
  371. return $this;
  372. }
  373. public function removeCoursesList(PaidCourseList $coursesList): self
  374. {
  375. if ($this->coursesList->contains($coursesList)) {
  376. $this->coursesList->removeElement($coursesList);
  377. // set the owning side to null (unless already changed)
  378. if ($coursesList->getSubscriptionOrder() === $this) {
  379. $coursesList->setSubscriptionOrder(null);
  380. }
  381. }
  382. return $this;
  383. }
  384. public function getCardBrand(): ?string
  385. {
  386. return $this->cardBrand;
  387. }
  388. public function setCardBrand(?string $cardBrand): self
  389. {
  390. $this->cardBrand = $cardBrand;
  391. return $this;
  392. }
  393. public function getCardLast4(): ?string
  394. {
  395. return $this->cardLast4;
  396. }
  397. public function setCardLast4(?string $cardLast4): self
  398. {
  399. $this->cardLast4 = $cardLast4;
  400. return $this;
  401. }
  402. public function getStripeSubscriptionId(): ?string
  403. {
  404. return $this->stripeSubscriptionId;
  405. }
  406. public function setStripeSubscriptionId(?string $stripeSubscriptionId): self
  407. {
  408. $this->stripeSubscriptionId = $stripeSubscriptionId;
  409. return $this;
  410. }
  411. public function getRenewBefore(): ?\DateTimeInterface
  412. {
  413. return $this->renewBefore;
  414. }
  415. public function setRenewBefore(?\DateTimeInterface $renewBefore): self
  416. {
  417. $this->renewBefore = $renewBefore;
  418. return $this;
  419. }
  420. public function cancel()
  421. {
  422. $this->isActif = false;
  423. }
  424. public function makeDue()
  425. {
  426. $this->isDue = true;
  427. }
  428. public function fullyCancel()
  429. {
  430. $this->isActif = false;
  431. $this->isCancelled = true;
  432. $this->isDue = false;
  433. $this->cancellationDate = new \DateTimeImmutable();
  434. }
  435. public function reactivate()
  436. {
  437. $this->isActif = true;
  438. }
  439. public function getIsCancelled(): ?bool
  440. {
  441. return $this->isCancelled;
  442. }
  443. public function setIsCancelled(?bool $isCancelled): self
  444. {
  445. $this->isCancelled = $isCancelled;
  446. return $this;
  447. }
  448. public function getNbOfScheduleChoose(): int
  449. {
  450. return $this->nbOfScheduleChoose;
  451. }
  452. public function setNbOfScheduleChoose(int $nbOfScheduleChoose): self
  453. {
  454. $this->nbOfScheduleChoose = $nbOfScheduleChoose;
  455. return $this;
  456. }
  457. public function getIsDue(): ?bool
  458. {
  459. return $this->isDue;
  460. }
  461. public function setIsDue(?bool $isDue): self
  462. {
  463. $this->isDue = $isDue;
  464. return $this;
  465. }
  466. public function getNextPaymentTimeStamp(): ?string
  467. {
  468. return $this->nextPaymentTimeStamp;
  469. }
  470. public function setNextPaymentTimeStamp(?string $nextPaymentTimeStamp): self
  471. {
  472. $this->nextPaymentTimeStamp = $nextPaymentTimeStamp;
  473. return $this;
  474. }
  475. public function getLastPaidCourse(): ?\DateTimeInterface
  476. {
  477. return $this->lastPaidCourse;
  478. }
  479. public function setLastPaidCourse(?\DateTimeInterface $lastPaidCourse): self
  480. {
  481. $this->lastPaidCourse = $lastPaidCourse;
  482. return $this;
  483. }
  484. public function getLastScheduleChangeAt(): ?\DateTimeInterface
  485. {
  486. return $this->lastScheduleChangeAt;
  487. }
  488. public function setLastScheduleChangeAt(?\DateTimeInterface $lastScheduleChangeAt): self
  489. {
  490. $this->lastScheduleChangeAt = $lastScheduleChangeAt;
  491. return $this;
  492. }
  493. /**
  494. * @return Collection|PlanUpdateLog[]
  495. */
  496. public function getPlanUpdateLogs(): Collection
  497. {
  498. return $this->planUpdateLogs;
  499. }
  500. public function addPlanUpdateLog(PlanUpdateLog $planUpdateLog): self
  501. {
  502. if (!$this->planUpdateLogs->contains($planUpdateLog)) {
  503. $this->planUpdateLogs[] = $planUpdateLog;
  504. $planUpdateLog->setSubscription($this);
  505. }
  506. return $this;
  507. }
  508. public function removePlanUpdateLog(PlanUpdateLog $planUpdateLog): self
  509. {
  510. if ($this->planUpdateLogs->contains($planUpdateLog)) {
  511. $this->planUpdateLogs->removeElement($planUpdateLog);
  512. // set the owning side to null (unless already changed)
  513. if ($planUpdateLog->getSubscription() === $this) {
  514. $planUpdateLog->setSubscription(null);
  515. }
  516. }
  517. return $this;
  518. }
  519. /**
  520. * @return Collection|AbsenceLog[]
  521. */
  522. public function getAbsenceLogs(): Collection
  523. {
  524. return $this->absenceLogs;
  525. }
  526. public function addAbsenceLog(AbsenceLog $absenceLog): self
  527. {
  528. if (!$this->absenceLogs->contains($absenceLog)) {
  529. $this->absenceLogs[] = $absenceLog;
  530. $absenceLog->setSubscription($this);
  531. }
  532. return $this;
  533. }
  534. public function removeAbsenceLog(AbsenceLog $absenceLog): self
  535. {
  536. if ($this->absenceLogs->contains($absenceLog)) {
  537. $this->absenceLogs->removeElement($absenceLog);
  538. // set the owning side to null (unless already changed)
  539. if ($absenceLog->getSubscription() === $this) {
  540. $absenceLog->setSubscription(null);
  541. }
  542. }
  543. return $this;
  544. }
  545. /**
  546. * @return Collection|SubscriptionLessonReport[]
  547. */
  548. public function getSubscriptionLessonReports(): Collection
  549. {
  550. return $this->subscriptionLessonReports;
  551. }
  552. public function addSubscriptionLessonReport(SubscriptionLessonReport $subscriptionLessonReport): self
  553. {
  554. if (!$this->subscriptionLessonReports->contains($subscriptionLessonReport)) {
  555. $this->subscriptionLessonReports[] = $subscriptionLessonReport;
  556. $subscriptionLessonReport->setSubscription($this);
  557. }
  558. return $this;
  559. }
  560. public function removeSubscriptionLessonReport(SubscriptionLessonReport $subscriptionLessonReport): self
  561. {
  562. if ($this->subscriptionLessonReports->contains($subscriptionLessonReport)) {
  563. $this->subscriptionLessonReports->removeElement($subscriptionLessonReport);
  564. // set the owning side to null (unless already changed)
  565. if ($subscriptionLessonReport->getSubscription() === $this) {
  566. $subscriptionLessonReport->setSubscription(null);
  567. }
  568. }
  569. return $this;
  570. }
  571. public function getCancellationDate(): ?\DateTimeInterface
  572. {
  573. return $this->cancellationDate;
  574. }
  575. public function setCancellationDate(?\DateTimeInterface $cancellationDate): self
  576. {
  577. $this->cancellationDate = $cancellationDate;
  578. return $this;
  579. }
  580. public function __toString()
  581. {
  582. return $this->getCustomerId();
  583. }
  584. public function getSubjectLevel(): ?SubjectLevel
  585. {
  586. return $this->subjectLevel;
  587. }
  588. public function setSubjectLevel(?SubjectLevel $subjectLevel): self
  589. {
  590. $this->subjectLevel = $subjectLevel;
  591. return $this;
  592. }
  593. public function getPaidAmount(): ?float
  594. {
  595. return $this->paidAmount;
  596. }
  597. public function setPaidAmount(float $paidAmount): self
  598. {
  599. $this->paidAmount = round($paidAmount, 2);
  600. return $this;
  601. }
  602. public function getTotalLostMinutes(): ?int
  603. {
  604. return $this->TotalLostMinutes;
  605. }
  606. public function setTotalLostMinutes(?int $TotalLostMinutes): self
  607. {
  608. $this->TotalLostMinutes = $TotalLostMinutes;
  609. return $this;
  610. }
  611. /**
  612. * Quand des minutes de cours sont perdues, j'augmente le total avec les minutes perdues
  613. * @param $lostMinutes
  614. * @return mixed
  615. */
  616. public function incrementTotalListMinutes($lostMinutes)
  617. {
  618. $newTotal = $this->TotalLostMinutes + $lostMinutes;
  619. return $newTotal;
  620. }
  621. /**
  622. * Quand des minutes sont rattrapées, je les déduit de ce total
  623. * @param $minutesCaughtUp
  624. * @return mixed
  625. */
  626. public function decrementTotalListMinutes($minutesCaughtUp)
  627. {
  628. $newTotal = $this->TotalLostMinutes - $minutesCaughtUp;
  629. return $newTotal;
  630. }
  631. /**
  632. * @return Collection|Homework[]
  633. */
  634. public function getHomeworks(): Collection
  635. {
  636. return $this->homeworks;
  637. }
  638. public function addHomework(Homework $homework): self
  639. {
  640. if (!$this->homeworks->contains($homework)) {
  641. $this->homeworks[] = $homework;
  642. $homework->setRelatedToSubscription($this);
  643. }
  644. return $this;
  645. }
  646. public function removeHomework(Homework $homework): self
  647. {
  648. if ($this->homeworks->contains($homework)) {
  649. $this->homeworks->removeElement($homework);
  650. // set the owning side to null (unless already changed)
  651. if ($homework->getRelatedToSubscription() === $this) {
  652. $homework->setRelatedToSubscription(null);
  653. }
  654. }
  655. return $this;
  656. }
  657. public function getHaveRamadanCredit(): ?bool
  658. {
  659. return $this->haveRamadanCredit;
  660. }
  661. public function setHaveRamadanCredit(?bool $haveRamadanCredit): self
  662. {
  663. $this->haveRamadanCredit = $haveRamadanCredit;
  664. return $this;
  665. }
  666. public function getRamadanCreditAmount(): ?float
  667. {
  668. return $this->ramadanCreditAmount;
  669. }
  670. public function setRamadanCreditAmount(?float $ramadanCreditAmount): self
  671. {
  672. $this->ramadanCreditAmount = round($ramadanCreditAmount, 2);
  673. return $this;
  674. }
  675. /*
  676. /**
  677. * @Assert\Callback()
  678. */
  679. /*
  680. public function validate(ExecutionContextInterface $context, $payload) {
  681. if($this->getSubject()->getHasLevel() === true) {
  682. if( $this->getSubjectLevel() === null || $this->getSubjectLevel()->getSubject()->getId() != $this->getSubject()->getId() ) {
  683. $context->buildViolation('form.subjectlevel.error')
  684. ->setTranslationDomain('subscription')
  685. ->atPath('subjectLevel')
  686. ->addViolation();
  687. }
  688. }
  689. }*/
  690. /**
  691. * @return Collection|EmailListSubscribeLostLog[]
  692. */
  693. public function getSubscribeLostLogs(): Collection
  694. {
  695. return $this->subscribeLostLogs;
  696. }
  697. public function addSubscribeLostLog(EmailListSubscribeLostLog $subscribeLostLog): self
  698. {
  699. if (!$this->subscribeLostLogs->contains($subscribeLostLog)) {
  700. $this->subscribeLostLogs[] = $subscribeLostLog;
  701. $subscribeLostLog->setSubscriptionOrder($this);
  702. }
  703. return $this;
  704. }
  705. public function removeSubscribeLostLog(EmailListSubscribeLostLog $subscribeLostLog): self
  706. {
  707. if ($this->subscribeLostLogs->removeElement($subscribeLostLog)) {
  708. if ($subscribeLostLog->getSubscriptionOrder() === $this) {
  709. $subscribeLostLog->setSubscriptionOrder(null);
  710. }
  711. }
  712. return $this;
  713. }
  714. /**
  715. * @return Collection|EmailListUnsubscribeLog[]
  716. */
  717. public function getUnsubscribeLogs(): Collection
  718. {
  719. return $this->unsubscribeLogs;
  720. }
  721. public function addUnsubscribeLog(EmailListUnsubscribeLog $unsubscribeLog): self
  722. {
  723. if (!$this->unsubscribeLogs->contains($unsubscribeLog)) {
  724. $this->unsubscribeLogs[] = $unsubscribeLog;
  725. $unsubscribeLog->setSubscriptionOrder($this);
  726. }
  727. return $this;
  728. }
  729. public function removeUnsubscribeLog(EmailListUnsubscribeLog $unsubscribeLog): self
  730. {
  731. if ($this->unsubscribeLogs->removeElement($unsubscribeLog)) {
  732. if ($unsubscribeLog->getSubscriptionOrder() === $this) {
  733. $unsubscribeLog->setSubscriptionOrder(null);
  734. }
  735. }
  736. return $this;
  737. }
  738. /**
  739. * @return Collection|Exam[]
  740. */
  741. public function getExams(): Collection
  742. {
  743. return $this->exams;
  744. }
  745. public function addExam(Exam $exam): self
  746. {
  747. if (!$this->exams->contains($exam)) {
  748. $this->exams[] = $exam;
  749. $exam->setRelatedToSubscription($this);
  750. }
  751. return $this;
  752. }
  753. public function removeExam(Exam $exam): self
  754. {
  755. if ($this->exams->removeElement($exam)) {
  756. // set the owning side to null (unless already changed)
  757. if ($exam->getRelatedToSubscription() === $this) {
  758. $exam->setRelatedToSubscription(null);
  759. }
  760. }
  761. return $this;
  762. }
  763. /**
  764. * @return Collection|TrainingReport[]
  765. */
  766. public function getTrainingReports(): Collection
  767. {
  768. return $this->trainingReports;
  769. }
  770. public function addTrainingReport(TrainingReport $trainingReport): self
  771. {
  772. if (!$this->trainingReports->contains($trainingReport)) {
  773. $this->trainingReports[] = $trainingReport;
  774. $trainingReport->setRelatedToSubscription($this);
  775. }
  776. return $this;
  777. }
  778. public function removeTrainingReport(TrainingReport $trainingReport): self
  779. {
  780. if ($this->trainingReports->removeElement($trainingReport)) {
  781. // set the owning side to null (unless already changed)
  782. if ($trainingReport->getRelatedToSubscription() === $this) {
  783. $trainingReport->setRelatedToSubscription(null);
  784. }
  785. }
  786. return $this;
  787. }
  788. public function getPaymentCurrency(): ?string
  789. {
  790. return $this->paymentCurrency;
  791. }
  792. public function setPaymentCurrency(?string $paymentCurrency): self
  793. {
  794. $this->paymentCurrency = $paymentCurrency ? mb_strtoupper(trim($paymentCurrency)) : null;
  795. return $this;
  796. }
  797. public function getAmountPaidLocalCurrency(): ?float
  798. {
  799. return $this->amountPaidLocalCurrency;
  800. }
  801. public function setAmountPaidLocalCurrency(?float $amountPaidLocalCurrency): self
  802. {
  803. $this->amountPaidLocalCurrency = $amountPaidLocalCurrency ? round($amountPaidLocalCurrency, 2) : null;
  804. return $this;
  805. }
  806. public function getAmountReceivedUsd(): ?float
  807. {
  808. return $this->amountReceivedUsd;
  809. }
  810. public function setAmountReceivedUsd(?float $amountReceivedUsd): self
  811. {
  812. $this->amountReceivedUsd = $amountReceivedUsd ? round($amountReceivedUsd, 2) : null;
  813. return $this;
  814. }
  815. public function getStripeFees(): ?float
  816. {
  817. return $this->stripeFees;
  818. }
  819. public function setStripeFees(?float $stripeFees): self
  820. {
  821. $this->stripeFees = $stripeFees ? round($stripeFees, 2) : null;
  822. return $this;
  823. }
  824. }