src/Entity/PaymentCredit.php line 21

  1. <?php
  2. /*
  3.  *  @author Guerby Duval <info@tranzaksyon.com>
  4.  *  @link https://tranzaksyon.com
  5.  *  @copyright You are not allowed to remove this author "Guerby Duval <info@tranzaksyon.com>", the link "https://tranzaksyon.com" neither this copyright.
  6.  */
  7. namespace App\Entity;
  8. use App\Repository\PaymentCreditRepository;
  9. use App\Utils\Sri\SriData;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. use Symfony\Component\Validator\Constraints\NotBlank;
  15. use Symfony\Component\Validator\Constraints\Valid;
  16. use Symfony\Component\Validator\Constraints\When;
  17. #[ORM\Entity(repositoryClassPaymentCreditRepository::class)]
  18. class PaymentCredit
  19. {
  20.     #[ORM\Id]
  21.     #[ORM\GeneratedValue]
  22.     #[ORM\Column]
  23.     #[Groups(['payment_credit_out'])]
  24.     private ?int $id null;
  25.     #[ORM\Column]
  26.     #[NotBlank(message"Ingrese condición de la operación")]
  27.     #[Groups(['payment_credit_out''payment_credit_in'])]
  28.     private ?int $condicionOperacion null;
  29.     #[ORM\Column(length20)]
  30.     #[Groups(['payment_credit_out''payment_credit_in'])]
  31.     private ?string $descripcionCondicionOperacion null;
  32.     #[ORM\Column(length15nullabletrue)]
  33.     #[When('this.getCondicionOperacion() === 1', [
  34.         new NotBlank(),
  35.     ])]
  36.     #[Groups(['payment_credit_out''payment_credit_in'])]
  37.     private ?string $plazo null;
  38.     #[ORM\Column(nullabletrue)]
  39.     #[When('this.getCondicionOperacion() === 2', [
  40.         new NotBlank(),
  41.     ])]
  42.     #[Groups(['payment_credit_out''payment_credit_in'])]
  43.     private ?int $quoteAmount null;
  44.     #[ORM\ManyToOne(inversedBy'paymentCredits')]
  45.     #[ORM\JoinColumn(nullablefalse)]
  46.     private ?SriInfo $company null;
  47.     #[ORM\OneToOne(mappedBy'paymentCredit'cascade: ['persist''remove'])]
  48.     private ?Invoice $invoice null;
  49.     #[ORM\ManyToOne(inversedBy'paymentCredits')]
  50.     private ?Sucursal $sucursal null;
  51.     #[ORM\Column(length15nullabletrue)]
  52.     #[When('this.getCondicionOperacion() === 1', [
  53.         new NotBlank(),
  54.     ])]
  55.     #[Groups(['payment_credit_out''payment_credit_in'])]
  56.     private ?string $periodPlazo null;
  57.     #[ORM\OneToMany(mappedBy'credit'targetEntityPaymentCreditQuote::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  58.     #[Valid]
  59.     #[Groups(['payment_credit_out''payment_credit_in'])]
  60.     private Collection $quotes;
  61.     #[ORM\ManyToOne(targetEntitySriPayment::class, cascade: ['persist''remove'], inversedBy'paymentCredits')]
  62.     #[Valid]
  63.     #[Groups(['payment_credit_out''payment_credit_in'])]
  64.     private ?SriPayment $sriPayment null;
  65.     public function __construct()
  66.     {
  67.         $this->quotes = new ArrayCollection();
  68.     }
  69.     public function getId(): ?int
  70.     {
  71.         return $this->id;
  72.     }
  73.     public function getCondicionOperacion(): ?int
  74.     {
  75.         return $this->condicionOperacion;
  76.     }
  77.     public function setCondicionOperacion(?int $condicionOperacion): static
  78.     {
  79.         $this->condicionOperacion $condicionOperacion;
  80.         return $this;
  81.     }
  82.     public function getDescripcionCondicionOperacion(): ?string
  83.     {
  84.         return $this->descripcionCondicionOperacion;
  85.     }
  86.     public function setDescripcionCondicionOperacion(?string $descripcionCondicionOperacion): static
  87.     {
  88.         $this->descripcionCondicionOperacion $descripcionCondicionOperacion;
  89.         return $this;
  90.     }
  91.     public function getPlazo(): ?string
  92.     {
  93.         return $this->plazo;
  94.     }
  95.     public function setPlazo(?string $plazo): static
  96.     {
  97.         $this->plazo $plazo;
  98.         return $this;
  99.     }
  100.     public function getQuoteAmount(): ?int
  101.     {
  102.         return $this->quoteAmount;
  103.     }
  104.     public function setQuoteAmount(?int $quoteAmount): static
  105.     {
  106.         $this->quoteAmount $quoteAmount;
  107.         return $this;
  108.     }
  109.     public function getCompany(): ?SriInfo
  110.     {
  111.         return $this->company;
  112.     }
  113.     public function setCompany(?SriInfo $company): static
  114.     {
  115.         $this->company $company;
  116.         return $this;
  117.     }
  118.     public function getInvoice(): ?Invoice
  119.     {
  120.         return $this->invoice;
  121.     }
  122.     public function setInvoice(?Invoice $invoice): static
  123.     {
  124.         // unset the owning side of the relation if necessary
  125.         if ($invoice === null && $this->invoice !== null) {
  126.             $this->invoice->setPaymentCredit(null);
  127.         }
  128.         // set the owning side of the relation if necessary
  129.         if ($invoice !== null && $invoice->getPaymentCredit() !== $this) {
  130.             $invoice->setPaymentCredit($this);
  131.         }
  132.         $this->invoice $invoice;
  133.         return $this;
  134.     }
  135.     public function getSucursal(): ?Sucursal
  136.     {
  137.         return $this->sucursal;
  138.     }
  139.     public function setSucursal(?Sucursal $sucursal): static
  140.     {
  141.         $this->sucursal $sucursal;
  142.         return $this;
  143.     }
  144.     public function getPeriodPlazo(): ?string
  145.     {
  146.         return $this->periodPlazo;
  147.     }
  148.     public function getPeriodPlazoDescription(): ?string
  149.     {
  150.         return array_flip(SriData::PLAZO_PERIODS)[$this->periodPlazo];
  151.     }
  152.     public function setPeriodPlazo(?string $periodPlazo): static
  153.     {
  154.         $this->periodPlazo $periodPlazo;
  155.         return $this;
  156.     }
  157.     /**
  158.      * @return Collection<int, PaymentCreditQuote>
  159.      */
  160.     public function getQuotes(): Collection
  161.     {
  162.         return $this->quotes;
  163.     }
  164.     public function addQuote(PaymentCreditQuote $quote): static
  165.     {
  166.         if (!$this->quotes->contains($quote)) {
  167.             $this->quotes->add($quote);
  168.             $quote->setCredit($this);
  169.         }
  170.         return $this;
  171.     }
  172.     public function removeQuote(PaymentCreditQuote $quote): static
  173.     {
  174.         if ($this->quotes->removeElement($quote)) {
  175.             // set the owning side to null (unless already changed)
  176.             if ($quote->getCredit() === $this) {
  177.                 $quote->setCredit(null);
  178.             }
  179.         }
  180.         return $this;
  181.     }
  182.     public function getSriPayment(): ?SriPayment
  183.     {
  184.         return $this->sriPayment;
  185.     }
  186.     public function setSriPayment(?SriPayment $sriPayment): static
  187.     {
  188.         $this->sriPayment $sriPayment;
  189.         return $this;
  190.     }
  191. }