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\Column(type="string", nullable=true, name="numero_seguimiento")
  144.      * @JMS\Groups({
  145.      *       "api_v1_operacion_show_serialize"
  146.      *   })
  147.      */
  148.     protected $numeroSeguimiento;
  149.     /**
  150.      * @ORM\OneToOne(targetEntity="App\Entity\Operacion", mappedBy="venta")
  151.      */
  152.     protected $operacion;
  153.     /**
  154.      * @ORM\OneToMany(targetEntity="App\Entity\CosteVenta", mappedBy="venta")
  155.      */
  156.     protected $costesVenta;
  157.     /**
  158.      * @ORM\OneToMany(
  159.      *     targetEntity="App\Entity\DetalleVenta",
  160.      *     mappedBy="venta",
  161.      *     orphanRemoval=true,
  162.      *     cascade={"persist","remove"}
  163.      * )
  164.      * @JMS\Type("ArrayCollection<App\Entity\DetalleVenta>")
  165.      * @JMS\Groups({
  166.      *       "api_v1_operacion_show_serialize"
  167.      *   })
  168.      */
  169.     protected $detalle;
  170.     /*
  171.      * @ORM\ManyToOne(targetEntity="App\Entity\Ciudad", inversedBy="direccionFacturacionCiudadVentas")
  172.      * @ORM\JoinColumn(name="direccion_facturacion_ciudad_id", referencedColumnName="id")
  173.      */
  174.     //protected $direccionFacturacionCiudad;
  175.     /**
  176.      * @ORM\ManyToOne(targetEntity="App\Entity\Provincia", inversedBy="direccionFacturacionProvinciaVentas")
  177.      * @ORM\JoinColumn(name="direccion_facturacion_provincia_id", referencedColumnName="id")
  178.      */
  179.     protected $direccionFacturacionProvincia;
  180.     /**
  181.      * @ORM\ManyToOne(targetEntity="App\Entity\CCAA", inversedBy="direccionFacturacionCcaaVentas")
  182.      * @ORM\JoinColumn(name="direccion_facturacion_ccaa_id", referencedColumnName="id")
  183.      */
  184.     protected $direccionFacturacionCcaa;
  185.     /*
  186.      * @ORM\ManyToOne(targetEntity="App\Entity\Ciudad", inversedBy="direccionEnvioCiudadVentas")
  187.      * @ORM\JoinColumn(name="direccion_envio_ciudad_id", referencedColumnName="id")
  188.      */
  189.     //protected $direccionEnvioCiudad;
  190.     /**
  191.      * @ORM\ManyToOne(targetEntity="App\Entity\Provincia", inversedBy="direccionEnvioProvinciaVentas")
  192.      * @ORM\JoinColumn(name="direccion_envio_provincia_id", referencedColumnName="id")
  193.      */
  194.     protected $direccionEnvioProvincia;
  195.     /**
  196.      * @ORM\ManyToOne(targetEntity="App\Entity\CCAA", inversedBy="direccionEnvioCcaaVentas")
  197.      * @ORM\JoinColumn(name="direccion_envio_ccaa_id", referencedColumnName="id")
  198.      */
  199.     protected $direccionEnvioCcaa;
  200.     /**
  201.      * @ORM\ManyToOne(targetEntity=\App\Entity\MetodoEntrega::class, inversedBy="ventas")
  202.      * @ORM\JoinColumn(name="metodo_entrega_id", referencedColumnName="id")
  203.      * @JMS\Groups({
  204.      *       "api_v1_operacion_show_serialize"
  205.      *   })
  206.      * @JMS\Type(MetodoEntrega::class)
  207.      */
  208.     private $metodoEntrega;
  209.     public function __construct()
  210.     {
  211.         $this->costesVenta = new ArrayCollection();
  212.         $this->detalle = new ArrayCollection();
  213.     }
  214.     public function __toString(): string
  215.     {
  216.         return $this->getOperacion()?->getIDperseo() ?? '---';
  217.     }
  218.     public function getId(): ?string
  219.     {
  220.         return $this->id;
  221.     }
  222.     public function getRegimen(): ?string
  223.     {
  224.         return $this->regimen;
  225.     }
  226.     public function setRegimen(?string $regimen): self
  227.     {
  228.         $this->regimen $regimen;
  229.         return $this;
  230.     }
  231.     public function getIban(): ?string
  232.     {
  233.         return $this->iban;
  234.     }
  235.     public function setIban(?string $iban): self
  236.     {
  237.         $this->iban $iban;
  238.         return $this;
  239.     }
  240.     public function getFechaConfirmacionVenta(): ?\DateTimeInterface
  241.     {
  242.         return $this->fechaConfirmacionVenta;
  243.     }
  244.     public function setFechaConfirmacionVenta(?\DateTimeInterface $fechaConfirmacionVenta): self
  245.     {
  246.         $this->fechaConfirmacionVenta $fechaConfirmacionVenta;
  247.         return $this;
  248.     }
  249.     public function getFechaEnvioPrevista(): ?\DateTimeInterface
  250.     {
  251.         return $this->fechaEnvioPrevista;
  252.     }
  253.     public function setFechaEnvioPrevista(?\DateTimeInterface $fechaEnvioPrevista): self
  254.     {
  255.         $this->fechaEnvioPrevista $fechaEnvioPrevista;
  256.         return $this;
  257.     }
  258.     public function getDireccionFacturacionDireccion(): ?string
  259.     {
  260.         return $this->direccionFacturacionDireccion;
  261.     }
  262.     public function setDireccionFacturacionDireccion(?string $direccionFacturacionDireccion): self
  263.     {
  264.         $this->direccionFacturacionDireccion $direccionFacturacionDireccion;
  265.         return $this;
  266.     }
  267.     public function getDireccionEnvioDireccion1(): ?string
  268.     {
  269.         return $this->direccionEnvioDireccion1;
  270.     }
  271.     public function setDireccionEnvioDireccion1(?string $direccionEnvioDireccion1): self
  272.     {
  273.         $this->direccionEnvioDireccion1 $direccionEnvioDireccion1;
  274.         return $this;
  275.     }
  276.     public function getDireccionEnvioDireccion2(): ?string
  277.     {
  278.         return $this->direccionEnvioDireccion2;
  279.     }
  280.     public function setDireccionEnvioDireccion2(?string $direccionEnvioDireccion2): self
  281.     {
  282.         $this->direccionEnvioDireccion2 $direccionEnvioDireccion2;
  283.         return $this;
  284.     }
  285.     public function getDeletedAt(): ?\DateTimeInterface
  286.     {
  287.         return $this->deletedAt;
  288.     }
  289.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  290.     {
  291.         $this->deletedAt $deletedAt;
  292.         return $this;
  293.     }
  294.     public function getUpdatedAt(): ?\DateTimeInterface
  295.     {
  296.         return $this->updatedAt;
  297.     }
  298.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  299.     {
  300.         $this->updatedAt $updatedAt;
  301.         return $this;
  302.     }
  303.     public function getCreatedAt(): ?\DateTimeInterface
  304.     {
  305.         return $this->createdAt;
  306.     }
  307.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  308.     {
  309.         $this->createdAt $createdAt;
  310.         return $this;
  311.     }
  312.     public function getOperacion(): ?Operacion
  313.     {
  314.         return $this->operacion;
  315.     }
  316.     public function setOperacion(?Operacion $operacion): self
  317.     {
  318.         // unset the owning side of the relation if necessary
  319.         if ($operacion === null && $this->operacion !== null) {
  320.             $this->operacion->setVenta(null);
  321.         }
  322.         // set the owning side of the relation if necessary
  323.         if ($operacion !== null && $operacion->getVenta() !== $this) {
  324.             $operacion->setVenta($this);
  325.         }
  326.         $this->operacion $operacion;
  327.         return $this;
  328.     }
  329.     /**
  330.      * @return Collection|CosteVenta[]
  331.      */
  332.     public function getCostesVenta(): Collection
  333.     {
  334.         return $this->costesVenta;
  335.     }
  336.     public function addCostesVentum(CosteVenta $costesVentum): self
  337.     {
  338.         if (!$this->costesVenta->contains($costesVentum)) {
  339.             $this->costesVenta[] = $costesVentum;
  340.             $costesVentum->setVenta($this);
  341.         }
  342.         return $this;
  343.     }
  344.     public function removeCostesVentum(CosteVenta $costesVentum): self
  345.     {
  346.         if ($this->costesVenta->removeElement($costesVentum)) {
  347.             // set the owning side to null (unless already changed)
  348.             if ($costesVentum->getVenta() === $this) {
  349.                 $costesVentum->setVenta(null);
  350.             }
  351.         }
  352.         return $this;
  353.     }
  354.     public function getDireccionFacturacionCiudad(): ?string
  355.     {
  356.         return $this->direccionFacturacionCiudad;
  357.     }
  358.     public function setDireccionFacturacionCiudad(?string $direccionFacturacionCiudad): self
  359.     {
  360.         $this->direccionFacturacionCiudad $direccionFacturacionCiudad;
  361.         return $this;
  362.     }
  363.     public function getDireccionFacturacionProvincia(): ?Provincia
  364.     {
  365.         return $this->direccionFacturacionProvincia;
  366.     }
  367.     public function setDireccionFacturacionProvincia(?Provincia $direccionFacturacionProvincia): self
  368.     {
  369.         $this->direccionFacturacionProvincia $direccionFacturacionProvincia;
  370.         return $this;
  371.     }
  372.     public function getDireccionFacturacionCcaa(): ?CCAA
  373.     {
  374.         return $this->direccionFacturacionCcaa;
  375.     }
  376.     public function setDireccionFacturacionCcaa(?CCAA $direccionFacturacionCcaa): self
  377.     {
  378.         $this->direccionFacturacionCcaa $direccionFacturacionCcaa;
  379.         return $this;
  380.     }
  381.     public function getDireccionFacturacionPais(): ?string
  382.     {
  383.         return $this->direccionFacturacionPais;
  384.     }
  385.     public function setDireccionFacturacionPais(?string $direccionFacturacionPais): self
  386.     {
  387.         $this->direccionFacturacionPais $direccionFacturacionPais;
  388.         return $this;
  389.     }
  390.     public function getDireccionEnvioCiudad(): ?string
  391.     {
  392.         return $this->direccionEnvioCiudad;
  393.     }
  394.     public function setDireccionEnvioCiudad(?string $direccionEnvioCiudad): self
  395.     {
  396.         $this->direccionEnvioCiudad $direccionEnvioCiudad;
  397.         return $this;
  398.     }
  399.     public function getDireccionEnvioProvincia(): ?Provincia
  400.     {
  401.         return $this->direccionEnvioProvincia;
  402.     }
  403.     public function setDireccionEnvioProvincia(?Provincia $direccionEnvioProvincia): self
  404.     {
  405.         $this->direccionEnvioProvincia $direccionEnvioProvincia;
  406.         return $this;
  407.     }
  408.     public function getDireccionEnvioCcaa(): ?CCAA
  409.     {
  410.         return $this->direccionEnvioCcaa;
  411.     }
  412.     public function setDireccionEnvioCcaa(?CCAA $direccionEnvioCcaa): self
  413.     {
  414.         $this->direccionEnvioCcaa $direccionEnvioCcaa;
  415.         return $this;
  416.     }
  417.     public function getDireccionEnvioPais(): ?string
  418.     {
  419.         return $this->direccionEnvioPais;
  420.     }
  421.     public function setDireccionEnvioPais(?string $direccionEnvioPais): self
  422.     {
  423.         $this->direccionEnvioPais $direccionEnvioPais;
  424.         return $this;
  425.     }
  426.     public function getDireccionEnvioComentario(): ?string
  427.     {
  428.         return $this->direccionEnvioComentario;
  429.     }
  430.     public function setDireccionEnvioComentario(?string $direccionEnvioComentario): self
  431.     {
  432.         $this->direccionEnvioComentario $direccionEnvioComentario;
  433.         return $this;
  434.     }
  435.     /**
  436.      * @return Collection|DetalleVenta[]
  437.      */
  438.     public function getDetalle(): Collection
  439.     {
  440.         return $this->detalle;
  441.     }
  442.     public function addDetalle(DetalleVenta $detalle): self
  443.     {
  444.         if (!$this->detalle->contains($detalle)) {
  445.             $this->detalle[] = $detalle;
  446.             $detalle->setVenta($this);
  447.         }
  448.         return $this;
  449.     }
  450.     public function removeDetalle(DetalleVenta $detalle): self
  451.     {
  452.         if ($this->detalle->removeElement($detalle)) {
  453.             // set the owning side to null (unless already changed)
  454.             if ($detalle->getVenta() === $this) {
  455.                 $detalle->setVenta(null);
  456.             }
  457.         }
  458.         return $this;
  459.     }
  460.     public function getDireccionFacturacionCp(): ?string
  461.     {
  462.         return $this->direccionFacturacionCp;
  463.     }
  464.     public function setDireccionFacturacionCp(?string $direccionFacturacionCp): self
  465.     {
  466.         $this->direccionFacturacionCp $direccionFacturacionCp;
  467.         return $this;
  468.     }
  469.     public function getDireccionEnvioCp(): ?string
  470.     {
  471.         return $this->direccionEnvioCp;
  472.     }
  473.     public function setDireccionEnvioCp(?string $direccionEnvioCp): self
  474.     {
  475.         $this->direccionEnvioCp $direccionEnvioCp;
  476.         return $this;
  477.     }
  478.     public function getDestinatario(): ?string
  479.     {
  480.         return $this->destinatario;
  481.     }
  482.     public function setDestinatario(?string $destinatario): static
  483.     {
  484.         $this->destinatario $destinatario;
  485.         return $this;
  486.     }
  487.     public function getDestinatarioEmpresa(): ?string
  488.     {
  489.         return $this->destinatarioEmpresa;
  490.     }
  491.     public function setDestinatarioEmpresa(?string $destinatarioEmpresa): static
  492.     {
  493.         $this->destinatarioEmpresa $destinatarioEmpresa;
  494.         return $this;
  495.     }
  496.     public function getDireccionEnvioRegion(): ?string
  497.     {
  498.         return $this->direccionEnvioRegion;
  499.     }
  500.     public function setDireccionEnvioRegion(?string $direccionEnvioRegion): static
  501.     {
  502.         $this->direccionEnvioRegion $direccionEnvioRegion;
  503.         return $this;
  504.     }
  505.     public function getDireccionFacturacionRegion(): ?string
  506.     {
  507.         return $this->direccionFacturacionRegion;
  508.     }
  509.     public function setDireccionFacturacionRegion(?string $direccionFacturacionRegion): static
  510.     {
  511.         $this->direccionFacturacionRegion $direccionFacturacionRegion;
  512.         return $this;
  513.     }
  514.     public function getDireccionEnvio(): ?string
  515.     {
  516.         return implode(' / 'array_filter([$this->getDireccionEnvioDireccion1(), $this->getDireccionEnvioDireccion2()])) . ' ' .
  517.             $this->getDireccionEnvioCp() . ' ' $this->getDireccionEnvioCiudad() . ' ' .
  518.             $this->getDireccionEnvioRegion() . ' ' $this->getDireccionEnvioPais()
  519.         ;
  520.     }
  521.     public function getDestinatarioEnvio(): ?string
  522.     {
  523.         return implode(' / 'array_filter([$this->getDestinatario(), $this->getDestinatarioEmpresa()]));
  524.     }
  525.     public function getSwift(): ?string
  526.     {
  527.         return $this->swift;
  528.     }
  529.     public function setSwift(?string $swift): static
  530.     {
  531.         $this->swift $swift;
  532.         return $this;
  533.     }
  534.     public function getNumeroSeguimiento(): ?string
  535.     {
  536.         return $this->numeroSeguimiento;
  537.     }
  538.     public function setNumeroSeguimiento(?string $numeroSeguimiento): static
  539.     {
  540.         $this->numeroSeguimiento $numeroSeguimiento;
  541.         return $this;
  542.     }
  543.     public function getMetodoEntrega(): ?MetodoEntrega
  544.     {
  545.         return $this->metodoEntrega;
  546.     }
  547.     public function setMetodoEntrega(?MetodoEntrega $metodoEntrega): static
  548.     {
  549.         $this->metodoEntrega $metodoEntrega;
  550.         return $this;
  551.     }
  552. }