src/Entity/Venta.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Validator as PerseoAssert;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use JMS\Serializer\Annotation as JMS;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12.  * @ORM\Table(name="venta")
  13.  * @ORM\EntityListeners({"App\EntityListener\Venta\CalcularPrecioTotalRelojListener"})
  14.  * @ORM\Entity(repositoryClass="App\Repository\VentaRepository")
  15.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  16.  * @PerseoAssert\ContraintsValidarEntidadCp()
  17.  */
  18. class Venta
  19. {
  20.     /**
  21.      * @ORM\Id
  22.      * @ORM\Column(type="bigint", options={"unsigned":true})
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      */
  25.     protected $id;
  26.     /**
  27.      * @ORM\Column(type="string", length=4, nullable=true, options={"comment":"REBU รณ IVA"})
  28.      */
  29.     protected $regimen;
  30.     /**
  31.      * @ORM\Column(type="string", nullable=true)
  32.      */
  33.     protected $iban;
  34.     /**
  35.      * @ORM\Column(type="string", nullable=true)
  36.      */
  37.     private $swift;
  38.     /**
  39.      * @ORM\Column(type="datetime", nullable=true, name="fecha_confirmacion_venta")
  40.      */
  41.     protected $fechaConfirmacionVenta;
  42.     /**
  43.      * @ORM\Column(type="datetime", nullable=true, name="fecha_envio_prevista")
  44.      */
  45.     protected $fechaEnvioPrevista;
  46.     /**
  47.      * @ORM\Column(type="string", nullable=true, name="direccion_facturacion_direccion")
  48.      */
  49.     protected $direccionFacturacionDireccion;
  50.     /**
  51.      * @ORM\Column(type="string", length=12, nullable=true, name="direccion_facturacion_cp")
  52.      * @Assert\Length(min = 5, max = 12)
  53.      */
  54.     protected $direccionFacturacionCp;
  55.     /**
  56.      * @ORM\Column(type="string", nullable=true, name="direccion_facturacion_region")
  57.      */
  58.     protected $direccionFacturacionRegion;
  59.     /**
  60.      * @ORM\Column(type="string", nullable=true, name="direccion_facturacion_ciudad")
  61.      */
  62.     protected $direccionFacturacionCiudad;
  63.     /**
  64.      * @ORM\Column(type="string", nullable=true)
  65.      * @JMS\Groups({
  66.      *      "api_v1_operacion_show_serialize"
  67.      *  })
  68.      */
  69.     protected $destinatario;
  70.     /**
  71.      * @ORM\Column(type="string", nullable=true, name="destinatario_empresa")
  72.      * @JMS\Groups({
  73.      *      "api_v1_operacion_show_serialize"
  74.      *  })
  75.      */
  76.     protected $destinatarioEmpresa;
  77.     /**
  78.      * @ORM\Column(type="string", nullable=true, name="direccion_envio_direccion_1")
  79.      * @JMS\Groups({
  80.      *      "api_v1_operacion_show_serialize"
  81.      *  })
  82.      */
  83.     protected $direccionEnvioDireccion1;
  84.     /**
  85.      * @ORM\Column(type="string", nullable=true, name="direccion_envio_direccion_2")
  86.      * @JMS\Groups({
  87.      *      "api_v1_operacion_show_serialize"
  88.      *  })
  89.      */
  90.     protected $direccionEnvioDireccion2;
  91.     /**
  92.      * @ORM\Column(type="string", length=12, nullable=true, name="direccion_envio_cp")
  93.      * @Assert\Length(min = 5, max = 12)
  94.      * @JMS\Groups({
  95.      *      "api_v1_operacion_show_serialize"
  96.      *  })
  97.      */
  98.     protected $direccionEnvioCp;
  99.     /**
  100.      * @ORM\Column(type="string", nullable=true, name="direccion_envio_region")
  101.      * @JMS\Groups({
  102.      *      "api_v1_operacion_show_serialize"
  103.      *  })
  104.      */
  105.     protected $direccionEnvioRegion;
  106.     /**
  107.      * @ORM\Column(type="string", nullable=true, name="direccion_envio_ciudad")
  108.      * @JMS\Groups({
  109.      *      "api_v1_operacion_show_serialize"
  110.      *  })
  111.      */
  112.     protected $direccionEnvioCiudad;
  113.     /**
  114.      * @ORM\Column(type="text", nullable=true, name="direccion_envio_comentario")
  115.      */
  116.     protected $direccionEnvioComentario;
  117.     /**
  118.      * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  119.      */
  120.     protected $deletedAt;
  121.     /**
  122.      * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  123.      * @Gedmo\Timestampable(on="update")
  124.      */
  125.     protected $updatedAt;
  126.     /**
  127.      * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  128.      * @Gedmo\Timestampable(on="create")
  129.      */
  130.     protected $createdAt;
  131.     /**
  132.      * @ORM\Column(type="string", length=2, nullable=true, name="direccion_facturacion_pais")
  133.      */
  134.     protected $direccionFacturacionPais;
  135.     /**
  136.      * @ORM\Column(type="string", length=2, nullable=true, name="direccion_envio_pais")
  137.      * @JMS\Groups({
  138.      *      "api_v1_operacion_show_serialize"
  139.      *  })
  140.      */
  141.     protected $direccionEnvioPais;
  142.     /**
  143.      * @ORM\OneToOne(targetEntity="App\Entity\Operacion", mappedBy="venta")
  144.      */
  145.     protected $operacion;
  146.     /**
  147.      * @ORM\OneToMany(targetEntity="App\Entity\CosteVenta", mappedBy="venta")
  148.      */
  149.     protected $costesVenta;
  150.     /**
  151.      * @ORM\OneToMany(
  152.      *     targetEntity="App\Entity\DetalleVenta",
  153.      *     mappedBy="venta",
  154.      *     orphanRemoval=true,
  155.      *     cascade={"persist","remove"}
  156.      * )
  157.      * @JMS\Type("ArrayCollection<App\Entity\DetalleVenta>")
  158.      * @JMS\Groups({
  159.      *       "api_v1_operacion_show_serialize"
  160.      *   })
  161.      */
  162.     protected $detalle;
  163.     /*
  164.      * @ORM\ManyToOne(targetEntity="App\Entity\Ciudad", inversedBy="direccionFacturacionCiudadVentas")
  165.      * @ORM\JoinColumn(name="direccion_facturacion_ciudad_id", referencedColumnName="id")
  166.      */
  167.     //protected $direccionFacturacionCiudad;
  168.     /**
  169.      * @ORM\ManyToOne(targetEntity="App\Entity\Provincia", inversedBy="direccionFacturacionProvinciaVentas")
  170.      * @ORM\JoinColumn(name="direccion_facturacion_provincia_id", referencedColumnName="id")
  171.      */
  172.     protected $direccionFacturacionProvincia;
  173.     /**
  174.      * @ORM\ManyToOne(targetEntity="App\Entity\CCAA", inversedBy="direccionFacturacionCcaaVentas")
  175.      * @ORM\JoinColumn(name="direccion_facturacion_ccaa_id", referencedColumnName="id")
  176.      */
  177.     protected $direccionFacturacionCcaa;
  178.     /*
  179.      * @ORM\ManyToOne(targetEntity="App\Entity\Ciudad", inversedBy="direccionEnvioCiudadVentas")
  180.      * @ORM\JoinColumn(name="direccion_envio_ciudad_id", referencedColumnName="id")
  181.      */
  182.     //protected $direccionEnvioCiudad;
  183.     /**
  184.      * @ORM\ManyToOne(targetEntity="App\Entity\Provincia", inversedBy="direccionEnvioProvinciaVentas")
  185.      * @ORM\JoinColumn(name="direccion_envio_provincia_id", referencedColumnName="id")
  186.      */
  187.     protected $direccionEnvioProvincia;
  188.     /**
  189.      * @ORM\ManyToOne(targetEntity="App\Entity\CCAA", inversedBy="direccionEnvioCcaaVentas")
  190.      * @ORM\JoinColumn(name="direccion_envio_ccaa_id", referencedColumnName="id")
  191.      */
  192.     protected $direccionEnvioCcaa;
  193.     public function __construct()
  194.     {
  195.         $this->costesVenta = new ArrayCollection();
  196.         $this->detalle = new ArrayCollection();
  197.     }
  198.     public function __toString(): string
  199.     {
  200.         return $this->getOperacion()?->getIDperseo() ?? '---';
  201.     }
  202.     public function getId(): ?string
  203.     {
  204.         return $this->id;
  205.     }
  206.     public function getRegimen(): ?string
  207.     {
  208.         return $this->regimen;
  209.     }
  210.     public function setRegimen(?string $regimen): self
  211.     {
  212.         $this->regimen $regimen;
  213.         return $this;
  214.     }
  215.     public function getIban(): ?string
  216.     {
  217.         return $this->iban;
  218.     }
  219.     public function setIban(?string $iban): self
  220.     {
  221.         $this->iban $iban;
  222.         return $this;
  223.     }
  224.     public function getFechaConfirmacionVenta(): ?\DateTimeInterface
  225.     {
  226.         return $this->fechaConfirmacionVenta;
  227.     }
  228.     public function setFechaConfirmacionVenta(?\DateTimeInterface $fechaConfirmacionVenta): self
  229.     {
  230.         $this->fechaConfirmacionVenta $fechaConfirmacionVenta;
  231.         return $this;
  232.     }
  233.     public function getFechaEnvioPrevista(): ?\DateTimeInterface
  234.     {
  235.         return $this->fechaEnvioPrevista;
  236.     }
  237.     public function setFechaEnvioPrevista(?\DateTimeInterface $fechaEnvioPrevista): self
  238.     {
  239.         $this->fechaEnvioPrevista $fechaEnvioPrevista;
  240.         return $this;
  241.     }
  242.     public function getDireccionFacturacionDireccion(): ?string
  243.     {
  244.         return $this->direccionFacturacionDireccion;
  245.     }
  246.     public function setDireccionFacturacionDireccion(?string $direccionFacturacionDireccion): self
  247.     {
  248.         $this->direccionFacturacionDireccion $direccionFacturacionDireccion;
  249.         return $this;
  250.     }
  251.     public function getDireccionEnvioDireccion1(): ?string
  252.     {
  253.         return $this->direccionEnvioDireccion1;
  254.     }
  255.     public function setDireccionEnvioDireccion1(?string $direccionEnvioDireccion1): self
  256.     {
  257.         $this->direccionEnvioDireccion1 $direccionEnvioDireccion1;
  258.         return $this;
  259.     }
  260.     public function getDireccionEnvioDireccion2(): ?string
  261.     {
  262.         return $this->direccionEnvioDireccion2;
  263.     }
  264.     public function setDireccionEnvioDireccion2(?string $direccionEnvioDireccion2): self
  265.     {
  266.         $this->direccionEnvioDireccion2 $direccionEnvioDireccion2;
  267.         return $this;
  268.     }
  269.     public function getDeletedAt(): ?\DateTimeInterface
  270.     {
  271.         return $this->deletedAt;
  272.     }
  273.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  274.     {
  275.         $this->deletedAt $deletedAt;
  276.         return $this;
  277.     }
  278.     public function getUpdatedAt(): ?\DateTimeInterface
  279.     {
  280.         return $this->updatedAt;
  281.     }
  282.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  283.     {
  284.         $this->updatedAt $updatedAt;
  285.         return $this;
  286.     }
  287.     public function getCreatedAt(): ?\DateTimeInterface
  288.     {
  289.         return $this->createdAt;
  290.     }
  291.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  292.     {
  293.         $this->createdAt $createdAt;
  294.         return $this;
  295.     }
  296.     public function getOperacion(): ?Operacion
  297.     {
  298.         return $this->operacion;
  299.     }
  300.     public function setOperacion(?Operacion $operacion): self
  301.     {
  302.         // unset the owning side of the relation if necessary
  303.         if ($operacion === null && $this->operacion !== null) {
  304.             $this->operacion->setVenta(null);
  305.         }
  306.         // set the owning side of the relation if necessary
  307.         if ($operacion !== null && $operacion->getVenta() !== $this) {
  308.             $operacion->setVenta($this);
  309.         }
  310.         $this->operacion $operacion;
  311.         return $this;
  312.     }
  313.     /**
  314.      * @return Collection|CosteVenta[]
  315.      */
  316.     public function getCostesVenta(): Collection
  317.     {
  318.         return $this->costesVenta;
  319.     }
  320.     public function addCostesVentum(CosteVenta $costesVentum): self
  321.     {
  322.         if (!$this->costesVenta->contains($costesVentum)) {
  323.             $this->costesVenta[] = $costesVentum;
  324.             $costesVentum->setVenta($this);
  325.         }
  326.         return $this;
  327.     }
  328.     public function removeCostesVentum(CosteVenta $costesVentum): self
  329.     {
  330.         if ($this->costesVenta->removeElement($costesVentum)) {
  331.             // set the owning side to null (unless already changed)
  332.             if ($costesVentum->getVenta() === $this) {
  333.                 $costesVentum->setVenta(null);
  334.             }
  335.         }
  336.         return $this;
  337.     }
  338.     public function getDireccionFacturacionCiudad(): ?string
  339.     {
  340.         return $this->direccionFacturacionCiudad;
  341.     }
  342.     public function setDireccionFacturacionCiudad(?string $direccionFacturacionCiudad): self
  343.     {
  344.         $this->direccionFacturacionCiudad $direccionFacturacionCiudad;
  345.         return $this;
  346.     }
  347.     public function getDireccionFacturacionProvincia(): ?Provincia
  348.     {
  349.         return $this->direccionFacturacionProvincia;
  350.     }
  351.     public function setDireccionFacturacionProvincia(?Provincia $direccionFacturacionProvincia): self
  352.     {
  353.         $this->direccionFacturacionProvincia $direccionFacturacionProvincia;
  354.         return $this;
  355.     }
  356.     public function getDireccionFacturacionCcaa(): ?CCAA
  357.     {
  358.         return $this->direccionFacturacionCcaa;
  359.     }
  360.     public function setDireccionFacturacionCcaa(?CCAA $direccionFacturacionCcaa): self
  361.     {
  362.         $this->direccionFacturacionCcaa $direccionFacturacionCcaa;
  363.         return $this;
  364.     }
  365.     public function getDireccionFacturacionPais(): ?string
  366.     {
  367.         return $this->direccionFacturacionPais;
  368.     }
  369.     public function setDireccionFacturacionPais(?string $direccionFacturacionPais): self
  370.     {
  371.         $this->direccionFacturacionPais $direccionFacturacionPais;
  372.         return $this;
  373.     }
  374.     public function getDireccionEnvioCiudad(): ?string
  375.     {
  376.         return $this->direccionEnvioCiudad;
  377.     }
  378.     public function setDireccionEnvioCiudad(?string $direccionEnvioCiudad): self
  379.     {
  380.         $this->direccionEnvioCiudad $direccionEnvioCiudad;
  381.         return $this;
  382.     }
  383.     public function getDireccionEnvioProvincia(): ?Provincia
  384.     {
  385.         return $this->direccionEnvioProvincia;
  386.     }
  387.     public function setDireccionEnvioProvincia(?Provincia $direccionEnvioProvincia): self
  388.     {
  389.         $this->direccionEnvioProvincia $direccionEnvioProvincia;
  390.         return $this;
  391.     }
  392.     public function getDireccionEnvioCcaa(): ?CCAA
  393.     {
  394.         return $this->direccionEnvioCcaa;
  395.     }
  396.     public function setDireccionEnvioCcaa(?CCAA $direccionEnvioCcaa): self
  397.     {
  398.         $this->direccionEnvioCcaa $direccionEnvioCcaa;
  399.         return $this;
  400.     }
  401.     public function getDireccionEnvioPais(): ?string
  402.     {
  403.         return $this->direccionEnvioPais;
  404.     }
  405.     public function setDireccionEnvioPais(?string $direccionEnvioPais): self
  406.     {
  407.         $this->direccionEnvioPais $direccionEnvioPais;
  408.         return $this;
  409.     }
  410.     public function getDireccionEnvioComentario(): ?string
  411.     {
  412.         return $this->direccionEnvioComentario;
  413.     }
  414.     public function setDireccionEnvioComentario(?string $direccionEnvioComentario): self
  415.     {
  416.         $this->direccionEnvioComentario $direccionEnvioComentario;
  417.         return $this;
  418.     }
  419.     /**
  420.      * @return Collection|DetalleVenta[]
  421.      */
  422.     public function getDetalle(): Collection
  423.     {
  424.         return $this->detalle;
  425.     }
  426.     public function addDetalle(DetalleVenta $detalle): self
  427.     {
  428.         if (!$this->detalle->contains($detalle)) {
  429.             $this->detalle[] = $detalle;
  430.             $detalle->setVenta($this);
  431.         }
  432.         return $this;
  433.     }
  434.     public function removeDetalle(DetalleVenta $detalle): self
  435.     {
  436.         if ($this->detalle->removeElement($detalle)) {
  437.             // set the owning side to null (unless already changed)
  438.             if ($detalle->getVenta() === $this) {
  439.                 $detalle->setVenta(null);
  440.             }
  441.         }
  442.         return $this;
  443.     }
  444.     public function getDireccionFacturacionCp(): ?string
  445.     {
  446.         return $this->direccionFacturacionCp;
  447.     }
  448.     public function setDireccionFacturacionCp(?string $direccionFacturacionCp): self
  449.     {
  450.         $this->direccionFacturacionCp $direccionFacturacionCp;
  451.         return $this;
  452.     }
  453.     public function getDireccionEnvioCp(): ?string
  454.     {
  455.         return $this->direccionEnvioCp;
  456.     }
  457.     public function setDireccionEnvioCp(?string $direccionEnvioCp): self
  458.     {
  459.         $this->direccionEnvioCp $direccionEnvioCp;
  460.         return $this;
  461.     }
  462.     public function getDestinatario(): ?string
  463.     {
  464.         return $this->destinatario;
  465.     }
  466.     public function setDestinatario(?string $destinatario): static
  467.     {
  468.         $this->destinatario $destinatario;
  469.         return $this;
  470.     }
  471.     public function getDestinatarioEmpresa(): ?string
  472.     {
  473.         return $this->destinatarioEmpresa;
  474.     }
  475.     public function setDestinatarioEmpresa(?string $destinatarioEmpresa): static
  476.     {
  477.         $this->destinatarioEmpresa $destinatarioEmpresa;
  478.         return $this;
  479.     }
  480.     public function getDireccionEnvioRegion(): ?string
  481.     {
  482.         return $this->direccionEnvioRegion;
  483.     }
  484.     public function setDireccionEnvioRegion(?string $direccionEnvioRegion): static
  485.     {
  486.         $this->direccionEnvioRegion $direccionEnvioRegion;
  487.         return $this;
  488.     }
  489.     public function getDireccionFacturacionRegion(): ?string
  490.     {
  491.         return $this->direccionFacturacionRegion;
  492.     }
  493.     public function setDireccionFacturacionRegion(?string $direccionFacturacionRegion): static
  494.     {
  495.         $this->direccionFacturacionRegion $direccionFacturacionRegion;
  496.         return $this;
  497.     }
  498.     public function getDireccionEnvio(): ?string
  499.     {
  500.         return implode(' / 'array_filter([$this->getDireccionEnvioDireccion1(), $this->getDireccionEnvioDireccion2()])) . ' ' .
  501.             $this->getDireccionEnvioCp() . ' ' $this->getDireccionEnvioCiudad() . ' ' .
  502.             $this->getDireccionEnvioRegion() . ' ' $this->getDireccionEnvioPais()
  503.         ;
  504.     }
  505.     public function getDestinatarioEnvio(): ?string
  506.     {
  507.         return implode(' / 'array_filter([$this->getDestinatario(), $this->getDestinatarioEmpresa()]));
  508.     }
  509.     public function getSwift(): ?string
  510.     {
  511.         return $this->swift;
  512.     }
  513.     public function setSwift(?string $swift): static
  514.     {
  515.         $this->swift $swift;
  516.         return $this;
  517.     }
  518. }