src/Entity/AccountingStudentRegistrationFee.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 Doctrine\Common\Collections\Collection;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use App\Repository\AccountingStudentRegistrationFeeRepository;
  8. /**
  9.  * @ORM\Entity(repositoryClass=AccountingStudentRegistrationFeeRepository::class)
  10.  * Frais d'inscription
  11.  */
  12. class AccountingStudentRegistrationFee
  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="accountingStudentRegistrationFees")
  22.      * @ORM\JoinColumn(nullable=false)
  23.      */
  24.     private $establishment;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity=RegistrationStudentRegistration::class, inversedBy="accountingStudentRegistrationFees")
  27.      * @ORM\JoinColumn(nullable=false)
  28.      */
  29.     private $studentRegistration;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=SettingFee::class, inversedBy="accountingStudentRegistrationFees")
  32.      * @ORM\JoinColumn(nullable=false)
  33.      */
  34.     private $fee;
  35.     /**
  36.      * @ORM\Column(type="string", length=60)
  37.      */
  38.     private $code;
  39.     /**
  40.      * @ORM\Column(type="string", length=128)
  41.      */
  42.     private $label;
  43.     /**
  44.      * @ORM\Column(type="float")
  45.      */
  46.     private $amount;
  47.     /**
  48.      * @ORM\Column(type="float", nullable=true)
  49.     */
  50.     private $last_amount_paid;
  51.     /**
  52.      * @ORM\Column(type="integer", nullable=true)
  53.     */
  54.     private $last_payment_id;
  55.     /**
  56.      * @ORM\Column(type="datetime_immutable", nullable=true)
  57.     */
  58.     private $last_payment_at;
  59.     /**
  60.      * @ORM\Column(type="datetime_immutable")
  61.     */
  62.     private $created_at;
  63.     /**
  64.      * @ORM\Column(type="datetime_immutable")
  65.      */
  66.     private $updated_at;
  67.     /**
  68.      * @ORM\Column(type="integer")
  69.      */
  70.     private $created_by;
  71.     /**
  72.      * @ORM\Column(type="integer")
  73.      */
  74.     private $updated_by;
  75.     /**
  76.      * @ORM\OneToMany(targetEntity=AccountingStudentRegistrationFeeShedul::class, mappedBy="studentRegistrationFee")
  77.      * @ORM\OrderBy({"date_due" = "ASC"})
  78.      */
  79.     private $accountingStudentRegistrationFeeSheduls;
  80.     /**
  81.      * @ORM\OneToMany(targetEntity=AccountingStudentRegistrationFeeShedulPayment::class, mappedBy="studentRegistrationFee")
  82.      */
  83.     private $accountingStudentRegistrationFeeShedulPayments;
  84.     /**
  85.      * @ORM\OneToMany(targetEntity=RegistrationStudentDowngradeLine::class, mappedBy="accountingStudentRegistrationFee")
  86.      */
  87.     private $registrationStudentDowngradeLines;
  88.     /**
  89.      * @ORM\OneToMany(targetEntity=RegistrationStudentAbandonmentLine::class, mappedBy="accountingStudentRegistrationFee")
  90.      */
  91.     private $registrationStudentAbandonmentLines;
  92.     /**
  93.      * @ORM\Column(type="float", nullable=true)
  94.     */
  95.     private $amount_cancel;
  96.     /**
  97.      * @ORM\Column(type="float", nullable=true)
  98.     */
  99.     private $amount_reported;
  100.     /**
  101.      * @ORM\Column(type="boolean")
  102.     */
  103.     private $is_reported;
  104.     /**
  105.      * @ORM\Column(type="boolean")
  106.     */
  107.     private $is_cancel;
  108.     /**
  109.      * @ORM\OneToMany(targetEntity=AccountingCredit::class, mappedBy="feeToDelete")
  110.      */
  111.     private $accountingCredits;
  112.     /**
  113.      * @ORM\Column(type="boolean")
  114.     */
  115.     private $is_archived;
  116.     /**
  117.      * @ORM\Column(type="string", length=60, nullable=true)
  118.     */
  119.     private $duration;
  120.     /**
  121.      * @ORM\Column(type="date_immutable", nullable=true)
  122.     */
  123.     private $start_at;
  124.     /**
  125.      * @ORM\Column(type="date_immutable", nullable=true)
  126.     */
  127.     private $end_at;
  128.     /**
  129.      * @ORM\OneToMany(targetEntity=StockKitOut::class, mappedBy="accountingStudentRegistrationFee")
  130.      */
  131.     private $stockKitOuts;
  132.     public function __construct()
  133.     {
  134.         $this->accountingStudentRegistrationFeeSheduls = new ArrayCollection();
  135.         $this->accountingStudentRegistrationFeeShedulPayments = new ArrayCollection();
  136.         $this->registrationStudentDowngradeLines = new ArrayCollection();
  137.         $this->registrationStudentAbandonmentLines = new ArrayCollection();
  138.         $this->amount_cancel 0;
  139.         $this->is_cancel false;
  140.         $this->is_archived false;
  141.         $this->is_reported false;
  142.         $this->accountingCredits = new ArrayCollection();
  143.         $this->stockKitOuts = new ArrayCollection();
  144.     }
  145.     public function __toString()
  146.     {
  147.         return $this->label;
  148.     }
  149.     public function getId(): ?int
  150.     {
  151.         return $this->id;
  152.     }
  153.     public function getEstablishment(): ?Establishment
  154.     {
  155.         return $this->establishment;
  156.     }
  157.     public function setEstablishment(?Establishment $establishment): self
  158.     {
  159.         $this->establishment $establishment;
  160.         return $this;
  161.     }
  162.     public function getStudentRegistration(): ?RegistrationStudentRegistration
  163.     {
  164.         return $this->studentRegistration;
  165.     }
  166.     public function setStudentRegistration(?RegistrationStudentRegistration $studentRegistration): self
  167.     {
  168.         $this->studentRegistration $studentRegistration;
  169.         return $this;
  170.     }
  171.     public function getFee(): ?SettingFee
  172.     {
  173.         return $this->fee;
  174.     }
  175.     public function setFee(?SettingFee $fee): self
  176.     {
  177.         $this->fee $fee;
  178.         return $this;
  179.     }
  180.     public function getCode(): ?string
  181.     {
  182.         return $this->code;
  183.     }
  184.     public function setCode(string $code): self
  185.     {
  186.         $this->code $code;
  187.         return $this;
  188.     }
  189.     public function getLabel(): ?string
  190.     {
  191.         return $this->label;
  192.     }
  193.     public function setLabel(string $label): self
  194.     {
  195.         $this->label $label;
  196.         return $this;
  197.     }
  198.     public function getAmount(): ?float
  199.     {
  200.         /* if ($this->amount <= 0) {
  201.             return $this->getAmountRest() + $this->getAmountPaid();
  202.         } */
  203.         return $this->amount;
  204.     }
  205.     public function setAmount(float $amount): self
  206.     {
  207.         $this->amount $amount;
  208.         return $this;
  209.     }
  210.     /**
  211.      * @return Collection|AccountingStudentRegistrationFeeShedul[]
  212.      */
  213.     public function getAccountingStudentRegistrationFeeSheduls(): Collection
  214.     {
  215.         return $this->accountingStudentRegistrationFeeSheduls;
  216.     }
  217.     public function addAccountingStudentRegistrationFeeShedul(AccountingStudentRegistrationFeeShedul $accountingStudentRegistrationFeeShedul): self
  218.     {
  219.         if (!$this->accountingStudentRegistrationFeeSheduls->contains($accountingStudentRegistrationFeeShedul)) {
  220.             $this->accountingStudentRegistrationFeeSheduls[] = $accountingStudentRegistrationFeeShedul;
  221.             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($this);
  222.         }
  223.         return $this;
  224.     }
  225.     public function removeAccountingStudentRegistrationFeeShedul(AccountingStudentRegistrationFeeShedul $accountingStudentRegistrationFeeShedul): self
  226.     {
  227.         if ($this->accountingStudentRegistrationFeeSheduls->removeElement($accountingStudentRegistrationFeeShedul)) {
  228.             // set the owning side to null (unless already changed)
  229.             if ($accountingStudentRegistrationFeeShedul->getStudentRegistrationFee() === $this) {
  230.                 $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee(null);
  231.             }
  232.         }
  233.         return $this;
  234.     }
  235.     /**
  236.      * @return Collection|AccountingStudentRegistrationFeeShedulPayment[]
  237.      */
  238.     public function getAccountingStudentRegistrationFeeShedulPayments(): Collection
  239.     {
  240.         return $this->accountingStudentRegistrationFeeShedulPayments;
  241.     }
  242.     public function addAccountingStudentRegistrationFeeShedulPayment(AccountingStudentRegistrationFeeShedulPayment $accountingStudentRegistrationFeeShedulPayment): self
  243.     {
  244.         if (!$this->accountingStudentRegistrationFeeShedulPayments->contains($accountingStudentRegistrationFeeShedulPayment)) {
  245.             $this->accountingStudentRegistrationFeeShedulPayments[] = $accountingStudentRegistrationFeeShedulPayment;
  246.             $accountingStudentRegistrationFeeShedulPayment->setStudentRegistrationFee($this);
  247.         }
  248.         return $this;
  249.     }
  250.     public function removeAccountingStudentRegistrationFeeShedulPayment(AccountingStudentRegistrationFeeShedulPayment $accountingStudentRegistrationFeeShedulPayment): self
  251.     {
  252.         if ($this->accountingStudentRegistrationFeeShedulPayments->removeElement($accountingStudentRegistrationFeeShedulPayment)) {
  253.             // set the owning side to null (unless already changed)
  254.             if ($accountingStudentRegistrationFeeShedulPayment->getStudentRegistrationFee() === $this) {
  255.                 $accountingStudentRegistrationFeeShedulPayment->setStudentRegistrationFee(null);
  256.             }
  257.         }
  258.         return $this;
  259.     }
  260.     public function getAmountPaid(): ?float
  261.     {
  262.         $amount_paid 0;
  263.         foreach ($this->getAccountingStudentRegistrationFeeShedulPayments() as $key => $value) {
  264.             if (!$value->getStudentRegistrationFee()->getIsArchived()) {
  265.                 $amount_paid $amount_paid $value->getAmount();
  266.             }
  267.         }
  268.         return $amount_paid;
  269.     }
  270.     public function getAmountRest(): ?float
  271.     {
  272.         $amountRest 0;
  273.         foreach ($this->getAccountingStudentRegistrationFeeSheduls() as $key => $accountingStudentRegistrationFeeShedul) {
  274.             //if (!$this->getIsArchived()) {
  275.                 $amountRest $amountRest $accountingStudentRegistrationFeeShedul->getAmountRest();
  276.             //}
  277.         }
  278.         return $amountRest;
  279.     }
  280.     public function getCreatedAt(): ?\DateTimeImmutable
  281.     {
  282.         return $this->created_at;
  283.     }
  284.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  285.     {
  286.         $this->created_at $created_at;
  287.         return $this;
  288.     }
  289.     public function getUpdatedAt(): ?\DateTimeImmutable
  290.     {
  291.         return $this->updated_at;
  292.     }
  293.     public function setUpdatedAt(\DateTimeImmutable $updated_at): self
  294.     {
  295.         $this->updated_at $updated_at;
  296.         return $this;
  297.     }
  298.     public function getCreatedBy(): ?int
  299.     {
  300.         return $this->created_by;
  301.     }
  302.     public function setCreatedBy(int $created_by): self
  303.     {
  304.         $this->created_by $created_by;
  305.         return $this;
  306.     }
  307.     public function getUpdatedBy(): ?int
  308.     {
  309.         return $this->updated_by;
  310.     }
  311.     public function setUpdatedBy(int $updated_by): self
  312.     {
  313.         $this->updated_by $updated_by;
  314.         return $this;
  315.     }
  316.     public function getDueDate(){
  317.         $due_date null;
  318.         foreach ($this->getAccountingStudentRegistrationFeeSheduls() as $key => $shedul) {
  319.             if ($shedul->getAmountRest() > 0) {
  320.                 $due_date $shedul->getDateDue();
  321.                 break;
  322.             }
  323.         }
  324.         return $due_date;
  325.     }
  326.     public function getDueAmount(){
  327.         $amount 0;
  328.         foreach ($this->getAccountingStudentRegistrationFeeSheduls() as $key => $shedul) {
  329.             if ($shedul->getAmountRest() > 0) {
  330.                 $amount $amount $shedul->getAmountRest();
  331.                 break;
  332.             }
  333.         }
  334.         return $amount;
  335.     }
  336.     public function getLastAmountPaid(): ?float
  337.     {
  338.         return $this->last_amount_paid;
  339.     }
  340.     public function setLastAmountPaid(?float $last_amount_paid): self
  341.     {
  342.         $this->last_amount_paid $last_amount_paid;
  343.         return $this;
  344.     }
  345.     public function getLastPaymentId(): ?int
  346.     {
  347.         return $this->last_payment_id;
  348.     }
  349.     public function setLastPaymentId(?int $last_payment_id): self
  350.     {
  351.         $this->last_payment_id $last_payment_id;
  352.         return $this;
  353.     }
  354.     public function getLastPaymentAt(): ?\DateTimeImmutable
  355.     {
  356.         return $this->last_payment_at;
  357.     }
  358.     public function setLastPaymentAt(\DateTimeImmutable $last_payment_at): self
  359.     {
  360.         $this->last_payment_at $last_payment_at;
  361.         return $this;
  362.     }
  363.     /**
  364.      * @return Collection|RegistrationStudentDowngradeLine[]
  365.      */
  366.     public function getRegistrationStudentDowngradeLines(): Collection
  367.     {
  368.         return $this->registrationStudentDowngradeLines;
  369.     }
  370.     public function addRegistrationStudentDowngradeLine(RegistrationStudentDowngradeLine $registrationStudentDowngradeLine): self
  371.     {
  372.         if (!$this->registrationStudentDowngradeLines->contains($registrationStudentDowngradeLine)) {
  373.             $this->registrationStudentDowngradeLines[] = $registrationStudentDowngradeLine;
  374.             $registrationStudentDowngradeLine->setAccountingStudentRegistrationFee($this);
  375.         }
  376.         return $this;
  377.     }
  378.     public function removeRegistrationStudentDowngradeLine(RegistrationStudentDowngradeLine $registrationStudentDowngradeLine): self
  379.     {
  380.         if ($this->registrationStudentDowngradeLines->removeElement($registrationStudentDowngradeLine)) {
  381.             // set the owning side to null (unless already changed)
  382.             if ($registrationStudentDowngradeLine->getAccountingStudentRegistrationFee() === $this) {
  383.                 $registrationStudentDowngradeLine->setAccountingStudentRegistrationFee(null);
  384.             }
  385.         }
  386.         return $this;
  387.     }
  388.     /**
  389.      * @return Collection|RegistrationStudentAbandonmentLine[]
  390.      */
  391.     public function getRegistrationStudentAbandonmentLines(): Collection
  392.     {
  393.         return $this->registrationStudentAbandonmentLines;
  394.     }
  395.     public function addRegistrationStudentAbandonmentLine(RegistrationStudentAbandonmentLine $registrationStudentAbandonmentLine): self
  396.     {
  397.         if (!$this->registrationStudentAbandonmentLines->contains($registrationStudentAbandonmentLine)) {
  398.             $this->registrationStudentAbandonmentLines[] = $registrationStudentAbandonmentLine;
  399.             $registrationStudentAbandonmentLine->setAccountingStudentRegistrationFee($this);
  400.         }
  401.         return $this;
  402.     }
  403.     public function removeRegistrationStudentAbandonmentLine(RegistrationStudentAbandonmentLine $registrationStudentAbandonmentLine): self
  404.     {
  405.         if ($this->registrationStudentAbandonmentLines->removeElement($registrationStudentAbandonmentLine)) {
  406.             // set the owning side to null (unless already changed)
  407.             if ($registrationStudentAbandonmentLine->getAccountingStudentRegistrationFee() === $this) {
  408.                 $registrationStudentAbandonmentLine->setAccountingStudentRegistrationFee(null);
  409.             }
  410.         }
  411.         return $this;
  412.     }
  413.     public function getAmountCancel(): ?float
  414.     {
  415.         $amountCancel 0;
  416.         
  417.         foreach ($this->getAccountingStudentRegistrationFeeSheduls() as $key => $accountingStudentRegistrationFeeShedul) {
  418.             $amountCancel $amountCancel $accountingStudentRegistrationFeeShedul->getAmountCancel();
  419.         }
  420.         
  421.         return $amountCancel;
  422.     }
  423.     public function setAmountCancel(?float $amount_cancel): self
  424.     {
  425.         $this->amount_cancel $amount_cancel;
  426.         return $this;
  427.     }
  428.     public function getIsCancel(): ?bool
  429.     {
  430.         return $this->is_cancel;
  431.     }
  432.     public function setIsCancel(bool $is_cancel): self
  433.     {
  434.         $this->is_cancel $is_cancel;
  435.         return $this;
  436.     }
  437.     public function getSheduledAmount(){
  438.         $amount 0;
  439.         foreach ($this->getAccountingStudentRegistrationFeeSheduls() as $key => $shedul) {
  440.             $amount $amount $shedul->getAmount();
  441.         }
  442.         return $amount;
  443.     }
  444.     /**
  445.      * @return Collection|AccountingCredit[]
  446.      */
  447.     public function getAccountingCredits(): Collection
  448.     {
  449.         return $this->accountingCredits;
  450.     }
  451.     public function addAccountingCredit(AccountingCredit $accountingCredit): self
  452.     {
  453.         if (!$this->accountingCredits->contains($accountingCredit)) {
  454.             $this->accountingCredits[] = $accountingCredit;
  455.             $accountingCredit->setFeeToDelete($this);
  456.         }
  457.         return $this;
  458.     }
  459.     public function removeAccountingCredit(AccountingCredit $accountingCredit): self
  460.     {
  461.         if ($this->accountingCredits->removeElement($accountingCredit)) {
  462.             // set the owning side to null (unless already changed)
  463.             if ($accountingCredit->getFeeToDelete() === $this) {
  464.                 $accountingCredit->setFeeToDelete(null);
  465.             }
  466.         }
  467.         return $this;
  468.     }
  469.     public function getIsArchived(): ?bool
  470.     {
  471.         return $this->is_archived;
  472.     }
  473.     public function setIsArchived(bool $is_archived): self
  474.     {
  475.         $this->is_archived $is_archived;
  476.         return $this;
  477.     }
  478.     public function getDuration(): ?string
  479.     {
  480.         return $this->duration;
  481.     }
  482.     public function setDuration(?string $duration): self
  483.     {
  484.         $this->duration $duration;
  485.         return $this;
  486.     }
  487.     public function getStartAt(): ?\DateTimeImmutable
  488.     {
  489.         return $this->start_at;
  490.     }
  491.     public function setStartAt(?\DateTimeImmutable $start_at): self
  492.     {
  493.         $this->start_at $start_at;
  494.         return $this;
  495.     }
  496.     public function getEndAt(): ?\DateTimeImmutable
  497.     {
  498.         return $this->end_at;
  499.     }
  500.     public function setEndAt(?\DateTimeImmutable $end_at): self
  501.     {
  502.         $this->end_at $end_at;
  503.         return $this;
  504.     }
  505.     public function getAmountDueAt(DateTimeImmutable $dueDate$amountMax 0){
  506.         $amountDue 0;
  507.         
  508.         foreach ($this->getAccountingStudentRegistrationFeeSheduls() as $key => $accountingStudentRegistrationFeeShedul) {
  509.             if ($accountingStudentRegistrationFeeShedul->getDateDue() <= $dueDate && $accountingStudentRegistrationFeeShedul->getAmountRest() > 0) {
  510.                 $amountDue $amountDue $accountingStudentRegistrationFeeShedul->getAmountRest();
  511.             }
  512.         }
  513.         
  514.         return $amountDue;
  515.     }
  516.     public function getAmountReported(): ?float
  517.     {
  518.         return $this->amount_reported;
  519.     }
  520.     public function setAmountReported(?float $amount_reported): self
  521.     {
  522.         $this->amount_reported $amount_reported;
  523.         return $this;
  524.     }
  525.     public function getIsReported(): ?bool
  526.     {
  527.         return $this->is_reported;
  528.     }
  529.     public function setIsReported(bool $is_reported): self
  530.     {
  531.         $this->is_reported $is_reported;
  532.         return $this;
  533.     }
  534.     /**
  535.      * @return Collection|StockKitOut[]
  536.      */
  537.     public function getStockKitOuts(): Collection
  538.     {
  539.         return $this->stockKitOuts;
  540.     }
  541.     public function addStockKitOut(StockKitOut $stockKitOut): self
  542.     {
  543.         if (!$this->stockKitOuts->contains($stockKitOut)) {
  544.             $this->stockKitOuts[] = $stockKitOut;
  545.             $stockKitOut->setAccountingStudentRegistrationFee($this);
  546.         }
  547.         return $this;
  548.     }
  549.     public function removeStockKitOut(StockKitOut $stockKitOut): self
  550.     {
  551.         if ($this->stockKitOuts->removeElement($stockKitOut)) {
  552.             // set the owning side to null (unless already changed)
  553.             if ($stockKitOut->getAccountingStudentRegistrationFee() === $this) {
  554.                 $stockKitOut->setAccountingStudentRegistrationFee(null);
  555.             }
  556.         }
  557.         return $this;
  558.     }
  559. }