src/Entity/Operacion.php line 40

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\EstadoOperacionEnum;
  4. use App\Enum\EstadoRelojEnum;
  5. use App\Enum\TipoOperacionEnum;
  6. use App\Exception\ConfirmadaOperacionException;
  7. use App\Twig\NumeroALetrasExtension;
  8. use DateTime;
  9. use DateTimeInterface;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\DBAL\Types\Types;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Gedmo\Mapping\Annotation as Gedmo;
  15. use Symfony\Component\HttpFoundation\File\File;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. use App\Validator as PerseoAssert;
  18. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  19. /**
  20.  * @ORM\Entity(repositoryClass="App\Repository\OperacionRepository")
  21.  * @ORM\Table(name="operacion", schema="perseo",
  22.  *     indexes={
  23.  *         @ORM\Index(name="idx_operacion_valoracion", columns={"valoracion_id", "deleted_at"})
  24.  *     }
  25.  * )
  26.  * @ORM\EntityListeners({
  27.  *     "App\EntityListener\Operacion\CalcularIDPerseoListener",
  28.  *     "App\EntityListener\Operacion\CalcularTipoOperacionListener",
  29.  *     "App\EntityListener\Operacion\UpdateDatesListener",
  30.  *     "App\EntityListener\Operacion\ControlTipoOperacionListener"
  31.  * })
  32.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  33.  * @Vich\Uploadable
  34.  * @PerseoAssert\ContraintsValidarEntidadDetalleCompra()
  35.  * @PerseoAssert\ContraintsValidarEntidadDetalleVenta()
  36.  */
  37. class Operacion
  38. {
  39.     /**
  40.      * @ORM\Id
  41.      * @ORM\Column(type="bigint", options={"unsigned":true})
  42.      * @ORM\GeneratedValue(strategy="AUTO")
  43.      */
  44.     protected $id;
  45.     /**
  46.      * @ORM\Column(
  47.      *     type="string",
  48.      *     nullable=true,
  49.      *     options={"comment":"valores a tomar (Compra, Gestión, Permuta, Venta)"}
  50.      * )
  51.      */
  52.     protected $tipo;
  53.     /**
  54.      * @ORM\Column(type="string", nullable=true, name="id_perseo")
  55.      */
  56.     protected $IDperseo;
  57.     /**
  58.      * @ORM\Column(type="datetime", nullable=true)
  59.      */
  60.     protected $fecha;
  61.     /**
  62.      * @ORM\Column(type="boolean", nullable=true, options={"comment":"0 => particular, 1 => empresa"})
  63.      */
  64.     protected $tipoCliente;
  65.     /**
  66.      * @ORM\Column(type="boolean", nullable=true, options={"default":0})
  67.      */
  68.     protected $exportacion;
  69.     /**
  70.      * @ORM\Column(type="string", length=2, nullable=true, options={"default":"es"})
  71.      */
  72.     protected $idioma;
  73.     /**
  74.      * @ORM\Column(type="datetime", nullable=true, name="fecha_tramitacion")
  75.      */
  76.     protected $fechaTramitacion;
  77.     /**
  78.      * @ORM\Column(type="datetime", nullable=true, name="fecha_tramitada")
  79.      */
  80.     protected $fechaTramitada;
  81.     /**
  82.      * @ORM\Column(type="datetime", nullable=true, name="fecha_confirmada")
  83.      */
  84.     protected $fechaConfirmada;
  85.     /**
  86.      * @ORM\Column(type="datetime", nullable=true, name="fecha_asentada")
  87.      */
  88.     protected $fechaAsentada;
  89.     /**
  90.      * @ORM\Column(type="datetime", nullable=true, name="fecha_finalizada")
  91.      */
  92.     private $fechaFinalizada;
  93.     /**
  94.      * @ORM\Column(type="datetime", nullable=true, name="fecha_cancelada")
  95.      */
  96.     protected $fechaCancelada;
  97.     /**
  98.      * @ORM\Column(type="string", nullable=true, name="forma_pago")
  99.      */
  100.     protected $formaPago;
  101.     /**
  102.      * @ORM\Column(type="float", nullable=true, precision=2, name="precio_pagar", options={"comment":"Costes compra + Costes venta"})
  103.      */
  104.     protected $precioPagar;
  105.     /**
  106.      * @ORM\Column(type="text", nullable=true, name="comentario_contrato")
  107.      */
  108.     protected $comentarioContrato;
  109.     /**
  110.      * @ORM\Column(type="text", nullable=true)
  111.      */
  112.     protected $comentario;
  113.     /**
  114.      * @ORM\Column(type="string", nullable=true, name="contract_signed")
  115.      */
  116.     protected $contractSigned;
  117.     /**
  118.      * @Assert\File(
  119.      *     mimeTypes={
  120.      *     "application/pdf",
  121.      *     }
  122.      * )
  123.      * @Vich\UploadableField(mapping="operacion", fileNameProperty="contractSigned")
  124.      * @var File
  125.      */
  126.     protected $contractSignedFile;
  127.     /**
  128.      * @ORM\Column(type="boolean", nullable=true, name="can_deleted", options={"default":true})
  129.      */
  130.     protected $canDeleted;
  131.     /**
  132.      * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  133.      */
  134.     protected $deletedAt;
  135.     /**
  136.      * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  137.      * @Gedmo\Timestampable(on="update")
  138.      */
  139.     protected $updatedAt;
  140.     /**
  141.      * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  142.      * @Gedmo\Timestampable(on="create")
  143.      */
  144.     protected $createdAt;
  145.     /**
  146.      * @ORM\OneToOne(targetEntity="App\Entity\Compra", inversedBy="operacion", cascade={"persist"})
  147.      * @ORM\JoinColumn(name="compra_id", referencedColumnName="id", unique=true)
  148.      */
  149.     protected $compra;
  150.     /**
  151.      * @ORM\OneToOne(targetEntity="App\Entity\Venta", inversedBy="operacion", cascade={"persist"})
  152.      * @ORM\JoinColumn(name="venta_id", referencedColumnName="id", unique=true)
  153.      */
  154.     protected $venta;
  155.     /**
  156.      * @ORM\OneToOne(targetEntity="App\Entity\Valoracion", inversedBy="operacion")
  157.      * @ORM\JoinColumn(name="valoracion_id", referencedColumnName="id", unique=true)
  158.      */
  159.     protected $valoracion;
  160.     /**
  161.      * @ORM\OneToMany(targetEntity=\App\Entity\Reloj::class, mappedBy="operacionGestion")
  162.      */
  163.     private $relojesGestion;
  164.     /**
  165.      * @ORM\OneToMany(targetEntity=\App\Entity\Reloj::class, mappedBy="operacionVenta")
  166.      */
  167.     private $relojesVenta;
  168.     /**
  169.      * @ORM\OneToMany(targetEntity=\App\Entity\Reloj::class, mappedBy="operacionCompra")
  170.      */
  171.     private $relojesCompra;
  172.     /**
  173.      * @ORM\ManyToOne(targetEntity="App\Entity\Canal", inversedBy="operaciones")
  174.      * @ORM\JoinColumn(name="canal_id", referencedColumnName="id")
  175.      */
  176.     protected $canal;
  177.     /**
  178.      * @ORM\ManyToOne(targetEntity="App\Entity\Cliente", inversedBy="operaciones")
  179.      * @ORM\JoinColumn(name="cliente_id", referencedColumnName="id")
  180.      */
  181.     protected $cliente;
  182.     /**
  183.      * @ORM\ManyToOne(targetEntity="App\Entity\EstadoOperacion", inversedBy="operaciones")
  184.      * @ORM\JoinColumn(name="estado_id", referencedColumnName="id")
  185.      */
  186.     protected $estado;
  187.     /**
  188.      * @ORM\ManyToOne(targetEntity="App\Entity\Banco", inversedBy="operaciones")
  189.      * @ORM\JoinColumn(name="banco_id", referencedColumnName="id")
  190.      */
  191.     protected $banco;
  192.     /**
  193.      * @ORM\ManyToOne(targetEntity="App\Entity\Firmante", inversedBy="operaciones")
  194.      * @ORM\JoinColumn(name="firmante_id", referencedColumnName="id")
  195.      */
  196.     protected $firmante;
  197.     /**
  198.      * @ORM\ManyToOne(targetEntity="App\Entity\Intercambio", inversedBy="operaciones")
  199.      * @ORM\JoinColumn(name="intercambio_id", referencedColumnName="id")
  200.      */
  201.     protected $intercambio;
  202.     /**
  203.      * @ORM\ManyToOne(targetEntity="App\Entity\UnidadNegocio", inversedBy="operaciones")
  204.      * @ORM\JoinColumn(name="unidad_negocio_id", referencedColumnName="id")
  205.      */
  206.     protected $unidadNegocio;
  207.     /**
  208.      * @ORM\ManyToOne(targetEntity="App\Entity\Usuario", inversedBy="operaciones")
  209.      * @ORM\JoinColumn(name="usuario_id", referencedColumnName="id")
  210.      */
  211.     protected $usuario;
  212.     public function __construct()
  213.     {
  214.         $this->venta = new Venta();
  215.         $this->compra = new Compra();
  216.         $this->cliente = new Cliente();
  217.         $this->relojesGestion = new ArrayCollection();
  218.         $this->relojesVenta = new ArrayCollection();
  219.         $this->relojesCompra = new ArrayCollection();
  220.     }
  221.     public function __toString(): string
  222.     {
  223.         return $this->IDperseo??'---';
  224.     }
  225.     public function getId(): ?string
  226.     {
  227.         return $this->id;
  228.     }
  229.     public function getIDperseo(): ?string
  230.     {
  231.         return $this->IDperseo;
  232.     }
  233.     public function setIDperseo(?string $IDperseo): self
  234.     {
  235.         $this->IDperseo $IDperseo;
  236.         return $this;
  237.     }
  238.     public function getFechaTramitacion(): ?DateTimeInterface
  239.     {
  240.         return $this->fechaTramitacion;
  241.     }
  242.     public function setFechaTramitacion(?DateTimeInterface $fechaTramitacion): self
  243.     {
  244.         $this->fechaTramitacion $fechaTramitacion;
  245.         return $this;
  246.     }
  247.     public function getFechaTramitada(): ?DateTimeInterface
  248.     {
  249.         return $this->fechaTramitada;
  250.     }
  251.     public function setFechaTramitada(?DateTimeInterface $fechaTramitada): self
  252.     {
  253.         $this->fechaTramitada $fechaTramitada;
  254.         return $this;
  255.     }
  256.     public function getFechaConfirmada(): ?DateTimeInterface
  257.     {
  258.         return $this->fechaConfirmada;
  259.     }
  260.     public function setFechaConfirmada(?DateTimeInterface $fechaConfirmada): self
  261.     {
  262.         $this->fechaConfirmada $fechaConfirmada;
  263.         return $this;
  264.     }
  265.     public function getFechaAsentada(): ?DateTimeInterface
  266.     {
  267.         return $this->fechaAsentada;
  268.     }
  269.     public function setFechaAsentada(?DateTimeInterface $fechaAsentada): self
  270.     {
  271.         $this->fechaAsentada $fechaAsentada;
  272.         return $this;
  273.     }
  274.     public function getFechaCancelada(): ?DateTimeInterface
  275.     {
  276.         return $this->fechaCancelada;
  277.     }
  278.     public function setFechaCancelada(?DateTimeInterface $fechaCancelada): self
  279.     {
  280.         $this->fechaCancelada $fechaCancelada;
  281.         return $this;
  282.     }
  283.     public function getFormaPago(): ?string
  284.     {
  285.         return $this->formaPago;
  286.     }
  287.     public function setFormaPago(?string $formaPago): self
  288.     {
  289.         $this->formaPago $formaPago;
  290.         return $this;
  291.     }
  292.     public function getPrecioPagarStr(): ?string
  293.     {
  294.         $string = new NumeroALetrasExtension();
  295.         return $string->numeroALetras($this->getPrecioPagar());
  296.     }
  297.     public function getPrecioPagarAbsStr(): ?string
  298.     {
  299.         $string = new NumeroALetrasExtension();
  300.         return $string->numeroALetras(abs($this->getPrecioPagar()));
  301.     }
  302.     public function getPrecioPagar(): ?float
  303.     {
  304.         return $this->precioPagar;
  305.     }
  306.     public function setPrecioPagar(?float $precioPagar): self
  307.     {
  308.         $this->precioPagar $precioPagar;
  309.         return $this;
  310.     }
  311.     public function getDeletedAt(): ?DateTimeInterface
  312.     {
  313.         return $this->deletedAt;
  314.     }
  315.     public function setDeletedAt(?DateTimeInterface $deletedAt): self
  316.     {
  317.         $this->deletedAt $deletedAt;
  318.         return $this;
  319.     }
  320.     public function getUpdatedAt(): ?DateTimeInterface
  321.     {
  322.         return $this->updatedAt;
  323.     }
  324.     public function setUpdatedAt(DateTimeInterface $updatedAt): self
  325.     {
  326.         $this->updatedAt $updatedAt;
  327.         return $this;
  328.     }
  329.     public function getCreatedAt(): ?DateTimeInterface
  330.     {
  331.         return $this->createdAt;
  332.     }
  333.     public function setCreatedAt(DateTimeInterface $createdAt): self
  334.     {
  335.         $this->createdAt $createdAt;
  336.         return $this;
  337.     }
  338.     public function getCanal(): ?Canal
  339.     {
  340.         return $this->canal;
  341.     }
  342.     public function setCanal(?Canal $canal): self
  343.     {
  344.         $this->canal $canal;
  345.         return $this;
  346.     }
  347.     public function getCliente(): ?Cliente
  348.     {
  349.         return $this->cliente;
  350.     }
  351.     public function setCliente(?Cliente $cliente): self
  352.     {
  353.         $this->cliente $cliente;
  354.         return $this;
  355.     }
  356.     public function getVenta(): ?Venta
  357.     {
  358.         return $this->venta;
  359.     }
  360.     public function setVenta(?Venta $venta): self
  361.     {
  362.         $this->venta $venta;
  363.         return $this;
  364.     }
  365.     public function getCompra(): ?Compra
  366.     {
  367.         return $this->compra;
  368.     }
  369.     public function setCompra(?Compra $compra): self
  370.     {
  371.         $this->compra $compra;
  372.         return $this;
  373.     }
  374.     public function getTipoCliente(): ?bool
  375.     {
  376.         return $this->tipoCliente;
  377.     }
  378.     public function setTipoCliente(?bool $tipoCliente): self
  379.     {
  380.         $this->tipoCliente $tipoCliente;
  381.         return $this;
  382.     }
  383.     public function getExportacionStr():string
  384.     {
  385.         return $this->isExportacion() ? 'Exportacion' 'Europa';
  386.     }
  387.     public function getExportacion(): ?bool
  388.     {
  389.         return $this->exportacion;
  390.     }
  391.     public function setExportacion(?bool $exportacion): self
  392.     {
  393.         $this->exportacion $exportacion;
  394.         return $this;
  395.     }
  396.     public function getComentarioContrato(): ?string
  397.     {
  398.         return $this->comentarioContrato;
  399.     }
  400.     public function setComentarioContrato(?string $comentarioContrato): self
  401.     {
  402.         $this->comentarioContrato $comentarioContrato;
  403.         return $this;
  404.     }
  405.     public function getComentario(): ?string
  406.     {
  407.         return $this->comentario;
  408.     }
  409.     public function setComentario(?string $comentario): self
  410.     {
  411.         $this->comentario $comentario;
  412.         return $this;
  413.     }
  414.     public function getValoracion(): ?Valoracion
  415.     {
  416.         return $this->valoracion;
  417.     }
  418.     public function setValoracion(?Valoracion $valoracion): self
  419.     {
  420.         $this->valoracion $valoracion;
  421.         return $this;
  422.     }
  423.     public function getEstado(): ?EstadoOperacion
  424.     {
  425.         return $this->estado;
  426.     }
  427.     public function setEstado(?EstadoOperacion $estado): self
  428.     {
  429.         $this->estado $estado;
  430.         return $this;
  431.     }
  432.     public function getBanco(): ?Banco
  433.     {
  434.         return $this->banco;
  435.     }
  436.     public function setBanco(?Banco $banco): self
  437.     {
  438.         $this->banco $banco;
  439.         return $this;
  440.     }
  441.     public function getFirmante(): ?Firmante
  442.     {
  443.         return $this->firmante;
  444.     }
  445.     public function setFirmante(?Firmante $firmante): self
  446.     {
  447.         $this->firmante $firmante;
  448.         return $this;
  449.     }
  450.     public function getIntercambio(): ?Intercambio
  451.     {
  452.         return $this->intercambio;
  453.     }
  454.     public function setIntercambio(?Intercambio $intercambio): self
  455.     {
  456.         $this->intercambio $intercambio;
  457.         return $this;
  458.     }
  459.     public function getFecha(): ?DateTimeInterface
  460.     {
  461.         return $this->fecha;
  462.     }
  463.     public function setFecha(?DateTimeInterface $fecha): self
  464.     {
  465.         $this->fecha $fecha;
  466.         return $this;
  467.     }
  468.     public function getUnidadNegocio(): ?UnidadNegocio
  469.     {
  470.         return $this->unidadNegocio;
  471.     }
  472.     public function setUnidadNegocio(?UnidadNegocio $unidadNegocio): self
  473.     {
  474.         $this->unidadNegocio $unidadNegocio;
  475.         return $this;
  476.     }
  477.     public function getUsuario(): ?Usuario
  478.     {
  479.         return $this->usuario;
  480.     }
  481.     public function setUsuario(?Usuario $usuario): self
  482.     {
  483.         $this->usuario $usuario;
  484.         return $this;
  485.     }
  486.     public function getIdioma(): ?string
  487.     {
  488.         return $this->idioma;
  489.     }
  490.     public function setIdioma(?string $idioma): self
  491.     {
  492.         $this->idioma $idioma;
  493.         return $this;
  494.     }
  495.     public function isTipoCliente(): ?bool
  496.     {
  497.         return $this->tipoCliente;
  498.     }
  499.     public function isExportacion(): ?bool
  500.     {
  501.         return $this->exportacion;
  502.     }
  503.     public function getContractSigned(): ?string
  504.     {
  505.         return $this->contractSigned;
  506.     }
  507.     public function setContractSigned(?string $contractSigned): static
  508.     {
  509.         $this->contractSigned $contractSigned;
  510.         return $this;
  511.     }
  512.     public function getContractSignedFile(): ?File
  513.     {
  514.         return $this->contractSignedFile;
  515.     }
  516.     public function setContractSignedFile(?File $contractSignedFile): self
  517.     {
  518.         $this->contractSignedFile $contractSignedFile;
  519.         if ($contractSignedFile) {
  520.             // if 'updatedAt' is not defined in your entity, use another property
  521.             $this->setUpdatedAt(new DateTime('now'));
  522.         }
  523.         return $this;
  524.     }
  525.     public function getType(): ?string
  526.     {
  527.         return $this->type;
  528.     }
  529.     public function getTipo(): ?string
  530.     {
  531.         return $this->tipo;
  532.     }
  533.     public function setTipo(string $tipo): static
  534.     {
  535.         $this->tipo $tipo;
  536.         return $this;
  537.     }
  538.     /**
  539.      * @return DateTime
  540.      */
  541.     public function getEstadoFecha(): DateTime
  542.     {
  543.         switch($this->getEstado()?->getKey())
  544.         {
  545.             case EstadoOperacionEnum::ESTADO_EN_TRAMITACION:
  546.                 $fecha $this->getFechaTramitacion();
  547.                 break;
  548.             case EstadoOperacionEnum::ESTADO_TRAMITADA:
  549.                 $fecha $this->getFechaTramitada();
  550.                 break;
  551.             case EstadoOperacionEnum::ESTADO_CONFIRMADA:
  552.                 $fecha $this->getFechaConfirmada();
  553.                 break;
  554.             case EstadoOperacionEnum::ESTADO_CANCELADA:
  555.                 $fecha $this->getFechaCancelada();
  556.                 break;
  557.             case EstadoOperacionEnum::ESTADO_ASENTADA:
  558.                 $fecha $this->getFechaAsentada();
  559.                 break;
  560.             default:
  561.                 $fecha null;
  562.                 break;
  563.         }
  564.         return $fecha;
  565.     }
  566.     public function isCanDeleted(): ?bool
  567.     {
  568.         return $this->canDeleted;
  569.     }
  570.     public function setCanDeleted(?bool $canDeleted): static
  571.     {
  572.         $this->canDeleted $canDeleted;
  573.         return $this;
  574.     }
  575.     /**
  576.      * @return Collection<int, Reloj>
  577.      */
  578.     public function getRelojesGestion(): Collection
  579.     {
  580.         return $this->relojesGestion;
  581.     }
  582.     public function addRelojesGestion(Reloj $relojesGestion): static
  583.     {
  584.         if (!$this->relojesGestion->contains($relojesGestion)) {
  585.             $this->relojesGestion->add($relojesGestion);
  586.             $relojesGestion->setOperacionGestion($this);
  587.         }
  588.         return $this;
  589.     }
  590.     public function removeRelojesGestion(Reloj $relojesGestion): static
  591.     {
  592.         if ($this->relojesGestion->removeElement($relojesGestion)) {
  593.             // set the owning side to null (unless already changed)
  594.             if ($relojesGestion->getOperacionGestion() === $this) {
  595.                 $relojesGestion->setOperacionGestion(null);
  596.             }
  597.         }
  598.         return $this;
  599.     }
  600.     /**
  601.      * @return Collection<int, Reloj>
  602.      */
  603.     public function getRelojesVenta(): Collection
  604.     {
  605.         return $this->relojesVenta;
  606.     }
  607.     public function addRelojesVentum(Reloj $relojesVentum): static
  608.     {
  609.         if (!$this->relojesVenta->contains($relojesVentum)) {
  610.             $this->relojesVenta->add($relojesVentum);
  611.             $relojesVentum->setOperacionVenta($this);
  612.         }
  613.         return $this;
  614.     }
  615.     public function removeRelojesVentum(Reloj $relojesVentum): static
  616.     {
  617.         if ($this->relojesVenta->removeElement($relojesVentum)) {
  618.             // set the owning side to null (unless already changed)
  619.             if ($relojesVentum->getOperacionVenta() === $this) {
  620.                 $relojesVentum->setOperacionVenta(null);
  621.             }
  622.         }
  623.         return $this;
  624.     }
  625.     /**
  626.      * @return Collection<int, Reloj>
  627.      */
  628.     public function getRelojesCompra(): Collection
  629.     {
  630.         return $this->relojesCompra;
  631.     }
  632.     public function addRelojesCompra(Reloj $relojesCompra): static
  633.     {
  634.         if (!$this->relojesCompra->contains($relojesCompra)) {
  635.             $this->relojesCompra->add($relojesCompra);
  636.             $relojesCompra->setOperacionCompra($this);
  637.         }
  638.         return $this;
  639.     }
  640.     public function removeRelojesCompra(Reloj $relojesCompra): static
  641.     {
  642.         if ($this->relojesCompra->removeElement($relojesCompra)) {
  643.             // set the owning side to null (unless already changed)
  644.             if ($relojesCompra->getOperacionCompra() === $this) {
  645.                 $relojesCompra->setOperacionCompra(null);
  646.             }
  647.         }
  648.         return $this;
  649.     }
  650.     public function getFechaFinalizada(): ?\DateTimeInterface
  651.     {
  652.         return $this->fechaFinalizada;
  653.     }
  654.     public function setFechaFinalizada(?\DateTimeInterface $fechaFinalizada): static
  655.     {
  656.         $this->fechaFinalizada $fechaFinalizada;
  657.         return $this;
  658.     }
  659.     public function canBeProcessed(): ?bool
  660.     {
  661.         // Solo EN_TRAMITACION o CONFIRMADA
  662.         if (!in_array($this->getEstado()?->getKey(), [
  663.             EstadoOperacionEnum::ESTADO_EN_TRAMITACION,
  664.             EstadoOperacionEnum::ESTADO_CONFIRMADA
  665.         ])) {
  666.             return false;
  667.         }
  668.         // Si está CONFIRMADA y es tipo GESTION, no puede tramitarse
  669.         if ($this->getEstado()?->getKey() === EstadoOperacionEnum::ESTADO_CONFIRMADA
  670.             && $this->getTipo() === TipoOperacionEnum::OPERACION_GESTION
  671.         ) {
  672.             return false;
  673.         }
  674.         foreach ($this->getVenta()->getDetalle() as $detalle)
  675.         {
  676.             if(in_array($detalle->getReloj()->getEstado()?->getKey(), [ EstadoRelojEnum::ESTADO_GESTION_CANCELADA])) return false;
  677.         }
  678.         return $this->getFechaTramitada() ? true false;
  679.     }
  680.     public function canBeConfirmed(): ?bool
  681.     {
  682.         if ($this->isCompraGestion()) return true;
  683.         if ($this->getEstado()?->getKey() !== EstadoOperacionEnum::ESTADO_TRAMITADA) {
  684.             return false;
  685.         }
  686.         foreach ($this->getVenta()->getDetalle() as $detalle)
  687.         {
  688.             if(in_array($detalle->getReloj()->getEstado()?->getKey(), [ EstadoRelojEnum::ESTADO_GESTION_CANCELADA])) return false;
  689.         }
  690.         return $this->getFechaConfirmada() ? true false;
  691.     }
  692.     public function isCompraGestion(): ?bool
  693.     {
  694.         $detalles $this->getCompra()?->getDetalle();
  695.         if($this->getTipo() === TipoOperacionEnum::OPERACION_COMPRA &&
  696.             $detalles->count() === &&
  697.             $detalles->first()?->getReloj()?->getOperacionGestion())
  698.         {
  699.             return true;
  700.         }
  701.         return false;
  702.     }
  703. }