src/Entity/AccountingStudentRegistrationPayment.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTimeImmutable;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\UserRepository;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use App\Repository\AccountingStudentRegistrationPaymentRepository;
  9. /**
  10.  * @ORM\Entity(repositoryClass=AccountingStudentRegistrationPaymentRepository::class)
  11.  */
  12. class AccountingStudentRegistrationPayment
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\ManyToOne(targetEntity=Establishment::class, inversedBy="accountingStudentRegistrationPayments")
  22.      * @ORM\JoinColumn(nullable=false)
  23.      */
  24.     private $establishment;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity=RegistrationStudentRegistration::class, inversedBy="accountingStudentRegistrationPayments")
  27.      * @ORM\JoinColumn(nullable=false)
  28.      */
  29.     private $studentRegistration;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=TreasuryCashRegister::class, inversedBy="accountingStudentRegistrationPayments")
  32.      * @ORM\JoinColumn(nullable=false)
  33.      */
  34.     private $cashRegister;
  35.     /**
  36.      * @ORM\Column(type="string", length=255)
  37.      */
  38.     private $code;
  39.     /**
  40.      * @ORM\Column(type="string", length=60, nullable=true)
  41.      */
  42.     private $method;
  43.     /**
  44.      * @ORM\Column(type="string", length=128, nullable=true)
  45.      */
  46.     private $memo;
  47.     /**
  48.      * @ORM\Column(type="float")
  49.      */
  50.     private $amount;
  51.     /**
  52.      * @ORM\Column(type="date_immutable")
  53.     */
  54.     private $create_at;
  55.     /**
  56.      * @ORM\Column(type="datetime_immutable")
  57.     */
  58.     private $created_at;
  59.     /**
  60.      * @ORM\Column(type="datetime_immutable")
  61.      */
  62.     private $updated_at;
  63.     /**
  64.      * @ORM\Column(type="integer")
  65.      */
  66.     private $created_by;
  67.     /**
  68.      * @ORM\Column(type="integer")
  69.      */
  70.     private $updated_by;
  71.     /**
  72.      * @ORM\OneToMany(targetEntity=AccountingStudentRegistrationFeeShedulPayment::class, mappedBy="studentRegistrationPayment")
  73.      */
  74.     private $accountingStudentRegistrationFeeShedulPayments;
  75.     /**
  76.      * @ORM\ManyToOne(targetEntity=SchoolYear::class, inversedBy="accountingStudentRegistrationPayments")
  77.      * @ORM\JoinColumn(nullable=false)
  78.      */
  79.     private $schoolYear;
  80.     public function __construct()
  81.     {
  82.         $this->accountingStudentRegistrationFeeShedulPayments = new ArrayCollection();
  83.         $this->create_at = new DateTimeImmutable();
  84.     }
  85.     public function getId(): ?int
  86.     {
  87.         return $this->id;
  88.     }
  89.     public function getEstablishment(): ?Establishment
  90.     {
  91.         return $this->establishment;
  92.     }
  93.     public function setEstablishment(?Establishment $establishment): self
  94.     {
  95.         $this->establishment $establishment;
  96.         return $this;
  97.     }
  98.     public function getStudentRegistration(): ?RegistrationStudentRegistration
  99.     {
  100.         return $this->studentRegistration;
  101.     }
  102.     public function setStudentRegistration(?RegistrationStudentRegistration $studentRegistration): self
  103.     {
  104.         $this->studentRegistration $studentRegistration;
  105.         return $this;
  106.     }
  107.     public function getCashRegister(): ?TreasuryCashRegister
  108.     {
  109.         return $this->cashRegister;
  110.     }
  111.     public function setCashRegister(?TreasuryCashRegister $cashRegister): self
  112.     {
  113.         $this->cashRegister $cashRegister;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return Collection|AccountingStudentRegistrationFeeShedulPayment[]
  118.      */
  119.     public function getAccountingStudentRegistrationFeeShedulPayments(): Collection
  120.     {
  121.         return $this->accountingStudentRegistrationFeeShedulPayments;
  122.     }
  123.     public function addAccountingStudentRegistrationFeeShedulPayment(AccountingStudentRegistrationFeeShedulPayment $accountingStudentRegistrationFeeShedulPayment): self
  124.     {
  125.         if (!$this->accountingStudentRegistrationFeeShedulPayments->contains($accountingStudentRegistrationFeeShedulPayment)) {
  126.             $this->accountingStudentRegistrationFeeShedulPayments[] = $accountingStudentRegistrationFeeShedulPayment;
  127.             $accountingStudentRegistrationFeeShedulPayment->setStudentRegistrationPayment($this);
  128.         }
  129.         return $this;
  130.     }
  131.     public function removeAccountingStudentRegistrationFeeShedulPayment(AccountingStudentRegistrationFeeShedulPayment $accountingStudentRegistrationFeeShedulPayment): self
  132.     {
  133.         if ($this->accountingStudentRegistrationFeeShedulPayments->removeElement($accountingStudentRegistrationFeeShedulPayment)) {
  134.             // set the owning side to null (unless already changed)
  135.             if ($accountingStudentRegistrationFeeShedulPayment->getStudentRegistrationPayment() === $this) {
  136.                 $accountingStudentRegistrationFeeShedulPayment->setStudentRegistrationPayment(null);
  137.             }
  138.         }
  139.         return $this;
  140.     }
  141.     public function getCode(): ?string
  142.     {
  143.         return $this->code;
  144.     }
  145.     public function setCode(string $code): self
  146.     {
  147.         $this->code $code;
  148.         return $this;
  149.     }
  150.     public function getCreatedAt(): ?\DateTimeImmutable
  151.     {
  152.         return $this->created_at;
  153.     }
  154.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  155.     {
  156.         $this->created_at $created_at;
  157.         return $this;
  158.     }
  159.     public function getUpdatedAt(): ?\DateTimeImmutable
  160.     {
  161.         return $this->updated_at;
  162.     }
  163.     public function setUpdatedAt(\DateTimeImmutable $updated_at): self
  164.     {
  165.         $this->updated_at $updated_at;
  166.         return $this;
  167.     }
  168.     public function getCreatedBy(): ?int
  169.     {
  170.         return $this->created_by;
  171.     }
  172.     public function setCreatedBy(int $created_by): self
  173.     {
  174.         $this->created_by $created_by;
  175.         return $this;
  176.     }
  177.     public function getUpdatedBy(): ?int
  178.     {
  179.         return $this->updated_by;
  180.     }
  181.     public function setUpdatedBy(int $updated_by): self
  182.     {
  183.         $this->updated_by $updated_by;
  184.         return $this;
  185.     }
  186.     public function getAmount(): ?float
  187.     {
  188.         return $this->amount;
  189.     }
  190.     public function setAmount(float $amount): self
  191.     {
  192.         $this->amount $amount;
  193.         return $this;
  194.     }
  195.     public function getSchoolYear(): ?SchoolYear
  196.     {
  197.         return $this->schoolYear;
  198.     }
  199.     public function setSchoolYear(?SchoolYear $schoolYear): self
  200.     {
  201.         $this->schoolYear $schoolYear;
  202.         return $this;
  203.     }
  204.     public function getCreateAt(): ?\DateTimeImmutable
  205.     {
  206.         return $this->create_at;
  207.     }
  208.     public function setCreateAt(\DateTimeImmutable $create_at): self
  209.     {
  210.         $this->create_at $create_at;
  211.         return $this;
  212.     }
  213.     public function getMethod(): ?string
  214.     {
  215.         return $this->method;
  216.     }
  217.     public function setMethod(?string $method): self
  218.     {
  219.         $this->method $method;
  220.         return $this;
  221.     }
  222.     public function getMemo(): ?string
  223.     {
  224.         return $this->memo;
  225.     }
  226.     public function setMemo(?string $memo): self
  227.     {
  228.         $this->memo $memo;
  229.         return $this;
  230.     }
  231.     public function getShedulAmount(){
  232.         $amount 0;
  233.         foreach ($this->getAccountingStudentRegistrationFeeShedulPayments() as $key => $payment) {
  234.             $amount $amount $payment->getAmount();
  235.         }
  236.         return $amount;
  237.     }
  238.     public function isLastOfThisStudent(){
  239.         return $this->getId() == $this->getStudentRegistration()->getLastPaymentId();
  240.     }
  241.     public function isCanBeShow(){
  242.         return $this->getShedulAmount() < $this->getAmount();
  243.     }
  244.     public function isCanBePrint(){
  245.         return $this->getShedulAmount() == $this->getAmount() && $this->isLastOfThisStudent();
  246.     }
  247.     public function isPrintable(){
  248.         return $this->getShedulAmount() == $this->getAmount();
  249.     }
  250.     public function isCanBeSaftlyRemove(){
  251.         return $this->getShedulAmount() == || $this->isLastOfThisStudent();
  252.     }
  253.     public function getUsername(UserRepository $userRepository){
  254.         return $userRepository->findOneBy(['id' => $this->created_by], []) ? $userRepository->findOneBy(['id' => $this->created_by], [])->getUserIdentifier() : null;
  255.     }
  256.     public function isFee(AccountingStudentRegistrationFee $accountingStudentRegistrationFee){
  257.         foreach ($this->getAccountingStudentRegistrationFeeShedulPayments() as $key => $accountingStudentRegistrationFeeShedulPayment) {
  258.             if ($accountingStudentRegistrationFeeShedulPayment->getStudentRegistrationFee() == $accountingStudentRegistrationFee) {
  259.                 return true;
  260.             }
  261.         }
  262.         return false;
  263.     }
  264.     public function getFeeproviders(){
  265.         $feeProviders = new ArrayCollection();
  266.         foreach ($this->getAccountingStudentRegistrationFeeShedulPayments() as $key => $accountingStudentRegistrationFeeShedulPayment) {
  267.             foreach ($accountingStudentRegistrationFeeShedulPayment->getStudentRegistrationFee()->getFee()->getSettingFeeProviderDistributions() as $key => $settingFeeProviderDistribution) {
  268.                 if (!$feeProviders->contains($settingFeeProviderDistribution->getSettingFeeProvider())) {
  269.                     $feeProviders->add($settingFeeProviderDistribution->getSettingFeeProvider());
  270.                 }
  271.             }
  272.         }
  273.         return $feeProviders;
  274.     }
  275.     public function getFeeEts(){
  276.         $count 0;
  277.         foreach ($this->getAccountingStudentRegistrationFeeShedulPayments() as $key => $accountingStudentRegistrationFeeShedulPayment) {
  278.             if (<= count($accountingStudentRegistrationFeeShedulPayment->getStudentRegistrationFee()->getFee()->getSettingFeeProviderDistributions())) {
  279.                 $count += 1;
  280.             }
  281.         }
  282.         return $count;
  283.     }
  284. }