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.         $this->setDescripcionCondicionOperacion((array_flip(SriData::condicionOperacionCredit())[$condicionOperacion]));
  81.         return $this;
  82.     }
  83.     public function getDescripcionCondicionOperacion(): ?string
  84.     {
  85.         return $this->descripcionCondicionOperacion;
  86.     }
  87.     public function setDescripcionCondicionOperacion(?string $descripcionCondicionOperacion): static
  88.     {
  89.         $this->descripcionCondicionOperacion $descripcionCondicionOperacion;
  90.         return $this;
  91.     }
  92.     public function getPlazo(): ?string
  93.     {
  94.         return $this->plazo;
  95.     }
  96.     public function setPlazo(?string $plazo): static
  97.     {
  98.         $this->plazo $plazo;
  99.         return $this;
  100.     }
  101.     public function getQuoteAmount(): ?int
  102.     {
  103.         return $this->quoteAmount;
  104.     }
  105.     public function setQuoteAmount(?int $quoteAmount): static
  106.     {
  107.         $this->quoteAmount $quoteAmount;
  108.         return $this;
  109.     }
  110.     public function getCompany(): ?SriInfo
  111.     {
  112.         return $this->company;
  113.     }
  114.     public function setCompany(?SriInfo $company): static
  115.     {
  116.         $this->company $company;
  117.         return $this;
  118.     }
  119.     public function getInvoice(): ?Invoice
  120.     {
  121.         return $this->invoice;
  122.     }
  123.     public function setInvoice(?Invoice $invoice): static
  124.     {
  125.         // unset the owning side of the relation if necessary
  126.         if ($invoice === null && $this->invoice !== null) {
  127.             $this->invoice->setPaymentCredit(null);
  128.         }
  129.         // set the owning side of the relation if necessary
  130.         if ($invoice !== null && $invoice->getPaymentCredit() !== $this) {
  131.             $invoice->setPaymentCredit($this);
  132.         }
  133.         $this->invoice $invoice;
  134.         return $this;
  135.     }
  136.     public function getSucursal(): ?Sucursal
  137.     {
  138.         return $this->sucursal;
  139.     }
  140.     public function setSucursal(?Sucursal $sucursal): static
  141.     {
  142.         $this->sucursal $sucursal;
  143.         return $this;
  144.     }
  145.     public function getPeriodPlazo(): ?string
  146.     {
  147.         return $this->periodPlazo;
  148.     }
  149.     public function getPeriodPlazoDescription(): ?string
  150.     {
  151.         return array_flip(SriData::PLAZO_PERIODS)[$this->periodPlazo];
  152.     }
  153.     public function setPeriodPlazo(?string $periodPlazo): static
  154.     {
  155.         $this->periodPlazo $periodPlazo;
  156.         return $this;
  157.     }
  158.     /**
  159.      * @return Collection<int, PaymentCreditQuote>
  160.      */
  161.     public function getQuotes(): Collection
  162.     {
  163.         return $this->quotes;
  164.     }
  165.     public function addQuote(PaymentCreditQuote $quote): static
  166.     {
  167.         if (!$this->quotes->contains($quote)) {
  168.             $this->quotes->add($quote);
  169.             $quote->setCredit($this);
  170.         }
  171.         return $this;
  172.     }
  173.     public function removeQuote(PaymentCreditQuote $quote): static
  174.     {
  175.         if ($this->quotes->removeElement($quote)) {
  176.             // set the owning side to null (unless already changed)
  177.             if ($quote->getCredit() === $this) {
  178.                 $quote->setCredit(null);
  179.             }
  180.         }
  181.         return $this;
  182.     }
  183.     public function getSriPayment(): ?SriPayment
  184.     {
  185.         return $this->sriPayment;
  186.     }
  187.     public function setSriPayment(?SriPayment $sriPayment): static
  188.     {
  189.         $this->sriPayment $sriPayment;
  190.         return $this;
  191.     }
  192. }