src/Entity/Credit.php line 17

  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\CreditStatus;
  4. use App\Repository\CreditRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Timestampable\Traits\TimestampableEntity;
  10. #[ORM\Entity(repositoryClassCreditRepository::class)]
  11. #[ORM\Index(columns: ['incentive_date'], name'cred_incentive_date')]
  12. #[ORM\Index(columns: ['user_id'], name'cred_user_id')]
  13. class Credit
  14. {
  15.     use TimestampableEntity;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\ManyToOne(fetch"EAGER"inversedBy'credits')]
  21.     private ?User $user null;
  22.     #[ORM\ManyToOne(fetch"EAGER"inversedBy'credits')]
  23.     private ?Position $position null;
  24.     #[ORM\Column]
  25.     private ?float $amount null;
  26.     #[ORM\ManyToOne(inversedBy'credits'fetch"EAGER")]
  27.     private ?Order $orderItem null;
  28.     #[ORM\ManyToOne(inversedBy'credits')]
  29.     private ?Period $period null;
  30.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  31.     private ?\DateTimeInterface $incentiveDate null;
  32.     #[ORM\ManyToOne(inversedBy'credits')]
  33.     private ?ReasonCode $reasonCode null;
  34.     #[ORM\Column]
  35.     private ?bool $held false;
  36.     #[ORM\ManyToOne(inversedBy'credits'fetch"EAGER")]
  37.     private ?CreditType $creditType null;
  38.     #[ORM\ManyToOne(inversedBy'credits'fetch"EAGER")]
  39.     private ?RuleResult $ruleResult null;
  40.     #[ORM\Column(length255nullabletrue)]
  41.     private ?string $geographyName null;
  42.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  43.     private ?\DateTimeInterface $establishedReleaseDate null;
  44.     #[ORM\Column(length255nullabletrue)]
  45.     private ?string $product null;
  46.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  47.     private ?\DateTimeInterface $actualReleaseDate null;
  48.     #[ORM\Column]
  49.     private ?bool $l6 false;
  50.     #[ORM\Column(length255)]
  51.     private ?CreditStatus $status CreditStatus::NEW;
  52.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'credits')]
  53.     private ?self $directCredit null;
  54.     #[ORM\OneToMany(mappedBy'directCredit'targetEntityself::class)]
  55.     private Collection $credits;
  56.     #[ORM\OneToMany(mappedBy'credit'targetEntityCommission::class, orphanRemovaltrue)]
  57.     private Collection $commissions;
  58.     public function __construct()
  59.     {
  60.         $this->credits = new ArrayCollection();
  61.         $this->commissions = new ArrayCollection();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getUser(): ?User
  68.     {
  69.         return $this->user;
  70.     }
  71.     public function setUser(?User $user): static
  72.     {
  73.         $this->user $user;
  74.         return $this;
  75.     }
  76.     public function getPosition(): ?Position
  77.     {
  78.         return $this->position;
  79.     }
  80.     public function setPosition(?Position $position): static
  81.     {
  82.         $this->position $position;
  83.         return $this;
  84.     }
  85.     public function getAmount(): ?float
  86.     {
  87.         return $this->amount;
  88.     }
  89.     public function setAmount(float $amount): static
  90.     {
  91.         $this->amount $amount;
  92.         return $this;
  93.     }
  94.     public function getOrderItem(): ?Order
  95.     {
  96.         return $this->orderItem;
  97.     }
  98.     public function setOrderItem(?Order $orderItem): static
  99.     {
  100.         $this->orderItem $orderItem;
  101.         return $this;
  102.     }
  103.     public function getPeriod(): ?Period
  104.     {
  105.         return $this->period;
  106.     }
  107.     public function setPeriod(?Period $period): static
  108.     {
  109.         $this->period $period;
  110.         return $this;
  111.     }
  112.     public function getIncentiveDate(): ?\DateTimeInterface
  113.     {
  114.         return $this->incentiveDate;
  115.     }
  116.     public function setIncentiveDate(?\DateTimeInterface $incentiveDate): static
  117.     {
  118.         $this->incentiveDate $incentiveDate;
  119.         return $this;
  120.     }
  121.     public function getReasonCode(): ?ReasonCode
  122.     {
  123.         return $this->reasonCode;
  124.     }
  125.     public function setReasonCode(?ReasonCode $reasonCode): static
  126.     {
  127.         $this->reasonCode $reasonCode;
  128.         return $this;
  129.     }
  130.     public function isHeld(): ?bool
  131.     {
  132.         return $this->held;
  133.     }
  134.     public function setHeld(bool $held): static
  135.     {
  136.         $this->held $held;
  137.         return $this;
  138.     }
  139.     public function getCreditType(): ?CreditType
  140.     {
  141.         return $this->creditType;
  142.     }
  143.     public function setCreditType(?CreditType $creditType): static
  144.     {
  145.         $this->creditType $creditType;
  146.         return $this;
  147.     }
  148.     public function getRuleResult(): ?RuleResult
  149.     {
  150.         return $this->ruleResult;
  151.     }
  152.     public function setRuleResult(?RuleResult $ruleResult): static
  153.     {
  154.         $this->ruleResult $ruleResult;
  155.         return $this;
  156.     }
  157.     public function getGeographyName(): ?string
  158.     {
  159.         return $this->geographyName;
  160.     }
  161.     public function setGeographyName(?string $geographyName): static
  162.     {
  163.         $this->geographyName $geographyName;
  164.         return $this;
  165.     }
  166.     public function getEstablishedReleaseDate(): ?\DateTimeInterface
  167.     {
  168.         return $this->establishedReleaseDate;
  169.     }
  170.     public function setEstablishedReleaseDate(?\DateTimeInterface $establishedReleaseDate): static
  171.     {
  172.         $this->establishedReleaseDate $establishedReleaseDate;
  173.         return $this;
  174.     }
  175.     public function getProduct(): ?string
  176.     {
  177.         return $this->product;
  178.     }
  179.     public function setProduct(?string $product): static
  180.     {
  181.         $this->product $product;
  182.         return $this;
  183.     }
  184.     public function getActualReleaseDate(): ?\DateTimeInterface
  185.     {
  186.         return $this->actualReleaseDate;
  187.     }
  188.     public function setActualReleaseDate(?\DateTimeInterface $actualReleaseDate): static
  189.     {
  190.         $this->actualReleaseDate $actualReleaseDate;
  191.         return $this;
  192.     }
  193.     public function isL6(): ?bool
  194.     {
  195.         return $this->l6;
  196.     }
  197.     public function setL6(bool $l6): static
  198.     {
  199.         $this->l6 $l6;
  200.         return $this;
  201.     }
  202.     public function getStatus(): ?CreditStatus
  203.     {
  204.         return $this->status;
  205.     }
  206.     public function setStatus(CreditStatus $status): static
  207.     {
  208.         $this->status $status;
  209.         return $this;
  210.     }
  211.     public function getDirectCredit(): ?self
  212.     {
  213.         return $this->directCredit;
  214.     }
  215.     public function setDirectCredit(?self $directCredit): static
  216.     {
  217.         $this->directCredit $directCredit;
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection<int, self>
  222.      */
  223.     public function getCredits(): Collection
  224.     {
  225.         return $this->credits;
  226.     }
  227.     public function addCredit(self $credit): static
  228.     {
  229.         if (!$this->credits->contains($credit)) {
  230.             $this->credits->add($credit);
  231.             $credit->setDirectCredit($this);
  232.         }
  233.         return $this;
  234.     }
  235.     public function removeCredit(self $credit): static
  236.     {
  237.         if ($this->credits->removeElement($credit)) {
  238.             // set the owning side to null (unless already changed)
  239.             if ($credit->getDirectCredit() === $this) {
  240.                 $credit->setDirectCredit(null);
  241.             }
  242.         }
  243.         return $this;
  244.     }
  245.     /**
  246.      * @return Collection<int, Commission>
  247.      */
  248.     public function getCommissions(): Collection
  249.     {
  250.         return $this->commissions;
  251.     }
  252.     public function addCommission(Commission $commission): static
  253.     {
  254.         if (!$this->commissions->contains($commission)) {
  255.             $this->commissions->add($commission);
  256.             $commission->setCredit($this);
  257.         }
  258.         return $this;
  259.     }
  260.     public function removeCommission(Commission $commission): static
  261.     {
  262.         if ($this->commissions->removeElement($commission)) {
  263.             // set the owning side to null (unless already changed)
  264.             if ($commission->getCredit() === $this) {
  265.                 $commission->setCredit(null);
  266.             }
  267.         }
  268.         return $this;
  269.     }
  270.     public function __toString()
  271.     {
  272.         return sprintf('%s - $%s'$this->getUser(), $this->getAmount());
  273.     }
  274. }