src/Entity/CommissionRule.php line 18

  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\CommissionHoldPeriod;
  4. use App\Enum\CommissionResultRateType;
  5. use App\Enum\CommissionType;
  6. use App\Enum\QuotaPeriod;
  7. use App\Repository\CommissionRuleRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\DBAL\Types\Types;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Gedmo\Timestampable\Traits\TimestampableEntity;
  13. #[ORM\Entity(repositoryClassCommissionRuleRepository::class)]
  14. class CommissionRule
  15. {
  16.     use TimestampableEntity;
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column]
  20.     private ?int $id null;
  21.     #[ORM\Column(length255)]
  22.     private ?string $name null;
  23.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  24.     private ?string $description null;
  25.     #[ORM\Column(nullabletrue)]
  26.     private ?CommissionType $ruleType null;
  27.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  28.     private ?\DateTimeInterface $activeStartDate null;
  29.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  30.     private ?\DateTimeInterface $activeEndDate null;
  31.     #[ORM\OneToMany(mappedBy'commissionRule'targetEntityRuleConditionOld::class, cascade: ['persist'], fetch"EAGER")]
  32.     private Collection $ruleConditionsOld;
  33.     #[ORM\ManyToOne]
  34.     private ?AttainmentMeasure $attainmentMeasure null;
  35.     #[ORM\ManyToOne]
  36.     private ?RateTable $rateTable null;
  37.     #[ORM\ManyToOne]
  38.     private ?Quota $quota null;
  39.     #[ORM\Column(length255nullabletrue)]
  40.     private ?QuotaPeriod $quotaPeriod null;
  41.     #[ORM\Column(length255nullabletrue)]
  42.     private ?CommissionResultRateType $resultRateType null;
  43.     #[ORM\Column(nullabletrue)]
  44.     private ?int $rate null;
  45.     #[ORM\Column(length255nullabletrue)]
  46.     private ?CommissionHoldPeriod $holdPeriod CommissionHoldPeriod::DATE;
  47.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  48.     private ?\DateTimeInterface $hold null;
  49.     #[ORM\ManyToOne(inversedBy'commissionRules')]
  50.     #[ORM\JoinColumn(nullablefalse)]
  51.     private ?Year $year null;
  52.     public function __construct()
  53.     {
  54.         $this->ruleConditionsOld = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getName(): ?string
  61.     {
  62.         return $this->name;
  63.     }
  64.     public function setName(string $name): self
  65.     {
  66.         $this->name $name;
  67.         return $this;
  68.     }
  69.     public function getDescription(): ?string
  70.     {
  71.         return $this->description;
  72.     }
  73.     public function setDescription(?string $description): self
  74.     {
  75.         $this->description $description;
  76.         return $this;
  77.     }
  78.     public function getRuleType(): ?CommissionType
  79.     {
  80.         return $this->ruleType;
  81.     }
  82.     public function setRuleType(?CommissionType $ruleType): self
  83.     {
  84.         $this->ruleType $ruleType;
  85.         return $this;
  86.     }
  87.     public function getActiveStartDate(): ?\DateTimeInterface
  88.     {
  89.         return $this->activeStartDate;
  90.     }
  91.     public function setActiveStartDate(?\DateTimeInterface $activeStartDate): self
  92.     {
  93.         $this->activeStartDate $activeStartDate;
  94.         return $this;
  95.     }
  96.     public function getActiveEndDate(): ?\DateTimeInterface
  97.     {
  98.         return $this->activeEndDate;
  99.     }
  100.     public function setActiveEndDate(?\DateTimeInterface $activeEndDate): self
  101.     {
  102.         $this->activeEndDate $activeEndDate;
  103.         return $this;
  104.     }
  105.     /**
  106.      * @return Collection<int, RuleConditionOld>
  107.      */
  108.     public function getRuleConditions(): Collection
  109.     {
  110.         return $this->ruleConditionsOld;
  111.     }
  112.     public function addRuleCondition(RuleConditionOld $ruleCondition): self
  113.     {
  114.         if (!$this->ruleConditionsOld->contains($ruleCondition)) {
  115.             $this->ruleConditionsOld->add($ruleCondition);
  116.             $ruleCondition->setCommissionRule($this);
  117.         }
  118.         return $this;
  119.     }
  120.     public function removeRuleCondition(RuleConditionOld $ruleCondition): self
  121.     {
  122.         if ($this->ruleConditionsOld->removeElement($ruleCondition)) {
  123.             // set the owning side to null (unless already changed)
  124.             if ($ruleCondition->getCommissionRule() === $this) {
  125.                 $ruleCondition->setCommissionRule(null);
  126.             }
  127.         }
  128.         return $this;
  129.     }
  130.     public function getAttainmentMeasure(): ?AttainmentMeasure
  131.     {
  132.         return $this->attainmentMeasure;
  133.     }
  134.     public function setAttainmentMeasure(?AttainmentMeasure $attainmentMeasure): self
  135.     {
  136.         $this->attainmentMeasure $attainmentMeasure;
  137.         return $this;
  138.     }
  139.     public function getRateTable(): ?RateTable
  140.     {
  141.         return $this->rateTable;
  142.     }
  143.     public function setRateTable(?RateTable $rateTable): self
  144.     {
  145.         $this->rateTable $rateTable;
  146.         return $this;
  147.     }
  148.     public function getQuota(): ?Quota
  149.     {
  150.         return $this->quota;
  151.     }
  152.     public function setQuota(?Quota $quota): self
  153.     {
  154.         $this->quota $quota;
  155.         return $this;
  156.     }
  157.     public function getQuotaPeriod(): ?QuotaPeriod
  158.     {
  159.         return $this->quotaPeriod;
  160.     }
  161.     public function setQuotaPeriod(?QuotaPeriod $quotaPeriod): self
  162.     {
  163.         $this->quotaPeriod $quotaPeriod;
  164.         return $this;
  165.     }
  166.     public function __toString()
  167.     {
  168.         return $this->name;
  169.     }
  170.     public function getResultRateType(): ?CommissionResultRateType
  171.     {
  172.         return $this->resultRateType;
  173.     }
  174.     public function setResultRateType(?CommissionResultRateType $resultRateType): self
  175.     {
  176.         $this->resultRateType $resultRateType;
  177.         return $this;
  178.     }
  179.     public function getRate(): ?int
  180.     {
  181.         return $this->rate;
  182.     }
  183.     public function setRate(?int $rate): self
  184.     {
  185.         $this->rate $rate;
  186.         return $this;
  187.     }
  188.     public function getHoldPeriod(): ?CommissionHoldPeriod
  189.     {
  190.         return $this->holdPeriod;
  191.     }
  192.     public function setHoldPeriod(?CommissionHoldPeriod $holdPeriod): self
  193.     {
  194.         $this->holdPeriod $holdPeriod;
  195.         return $this;
  196.     }
  197.     public function getHold(): ?\DateTimeInterface
  198.     {
  199.         return $this->hold;
  200.     }
  201.     public function setHold(?\DateTimeInterface $hold): self
  202.     {
  203.         $this->hold $hold;
  204.         return $this;
  205.     }
  206.     public function getYear(): ?Year
  207.     {
  208.         return $this->year;
  209.     }
  210.     public function setYear(?Year $year): self
  211.     {
  212.         $this->year $year;
  213.         return $this;
  214.     }
  215. }