src/Entity/Suministro.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SuministroRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. /**
  9.  * @ORM\Entity(repositoryClass=SuministroRepository::class)
  10.  * @UniqueEntity("cups")
  11.  */
  12. class Suministro
  13. {
  14.     /**
  15.      * @ORM\Id()
  16.      * @ORM\GeneratedValue()
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $cups;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=TipoVia::class)
  26.      * @ORM\JoinColumn(nullable=false)
  27.      */
  28.     private $tipoVia;
  29.     /**
  30.      * @ORM\Column(type="string", length=255)
  31.      */
  32.     private $nombreVia;
  33.     /**
  34.      * @ORM\Column(type="string", length=255)
  35.      */
  36.     private $numeroDireccion;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      */
  40.     private $escalera;
  41.     /**
  42.      * @ORM\Column(type="string", length=255, nullable=true)
  43.      */
  44.     private $piso;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      */
  48.     private $puerta;
  49.     /**
  50.      * @ORM\Column(type="string", length=255)
  51.      */
  52.     private $cp;
  53.     /**
  54.      * @ORM\Column(type="string", length=255)
  55.      */
  56.     private $poblacion;
  57.     /**
  58.      * @ORM\Column(type="string", length=255)
  59.      */
  60.     private $provincia;
  61.     /**
  62.      * @ORM\Column(type="decimal", precision=10, scale=5, nullable=true)
  63.      */
  64.     private $potenciaP1;
  65.     /**
  66.      * @ORM\Column(type="decimal", precision=10, scale=5, nullable=true)
  67.      */
  68.     private $potenciaP2;
  69.     /**
  70.      * @ORM\Column(type="decimal", precision=10, scale=5, nullable=true)
  71.      */
  72.     private $potenciaP3;
  73.     /**
  74.      * @ORM\Column(type="decimal", precision=10, scale=5, nullable=true)
  75.      */
  76.     private $potenciaP4;
  77.     /**
  78.      * @ORM\Column(type="decimal", precision=10, scale=5, nullable=true)
  79.      */
  80.     private $potenciaP5;
  81.     /**
  82.      * @ORM\Column(type="decimal", precision=10, scale=5, nullable=true)
  83.      */
  84.     private $potenciaP6;
  85.     /**
  86.      * @ORM\Column(type="decimal", precision=10, scale=5, nullable=true)
  87.      */
  88.     private $alquilerContador;
  89.     /**
  90.      * @ORM\Column(type="integer")
  91.      */
  92.     private $consumoAnual;
  93.     /**
  94.      * @ORM\OneToMany(targetEntity=Contrato::class, mappedBy="suministro")
  95.      */
  96.     private $contratos;
  97.     /**
  98.      * @ORM\Column(type="string", length=255, nullable=true)
  99.      */
  100.     private $observaciones;
  101.     /**
  102.      * @ORM\Column(type="boolean", nullable=true)
  103.      */
  104.     private $maximetro;
  105.     /**
  106.      * @ORM\Column(type="string", length=255, nullable=true)
  107.      */
  108.     private $codigoContable;
  109.     /**
  110.      * @ORM\Column(type="decimal", precision=10, scale=5, nullable=true)
  111.      */
  112.     private $alquilerContadorReal;
  113.     /**
  114.      * @ORM\Column(type="string", length=255, nullable=true)
  115.      */
  116.     private $direccionCompleta;
  117.     public function __construct()
  118.     {
  119.         $this->contratos = new ArrayCollection();
  120.         $this->updateDireccion();
  121.     }
  122.     public function getId(): ?int
  123.     {
  124.         return $this->id;
  125.     }
  126.     public function getCups(): ?string
  127.     {
  128.         return $this->cups;
  129.     }
  130.     public function setCups(string $cups): self
  131.     {
  132.         $this->cups $cups;
  133.         return $this;
  134.     }
  135.     public function getTipoVia(): ?TipoVia
  136.     {
  137.         return $this->tipoVia;
  138.     }
  139.     public function setTipoVia(?TipoVia $tipoVia): self
  140.     {
  141.         $this->tipoVia $tipoVia;
  142.         $this->updateDireccion();
  143.         return $this;
  144.     }
  145.     public function getNombreVia(): ?string
  146.     {
  147.         return $this->nombreVia;
  148.     }
  149.     public function setNombreVia(string $nombreVia): self
  150.     {
  151.         $this->nombreVia $nombreVia;
  152.         $this->updateDireccion();
  153.         return $this;
  154.     }
  155.     public function getNumeroDireccion(): ?string
  156.     {
  157.         return $this->numeroDireccion;
  158.     }
  159.     public function setNumeroDireccion(string $numeroDireccion): self
  160.     {
  161.         $this->numeroDireccion $numeroDireccion;
  162.         $this->updateDireccion();
  163.         return $this;
  164.     }
  165.     public function getEscalera(): ?string
  166.     {
  167.         return $this->escalera;
  168.     }
  169.     public function setEscalera(?string $escalera): self
  170.     {
  171.         $this->escalera $escalera;
  172.         $this->updateDireccion();
  173.         return $this;
  174.     }
  175.     public function getPiso(): ?string
  176.     {
  177.         return $this->piso;
  178.     }
  179.     public function setPiso(?string $piso): self
  180.     {
  181.         $this->piso $piso;
  182.         $this->updateDireccion();
  183.         return $this;
  184.     }
  185.     public function getPuerta(): ?string
  186.     {
  187.         return $this->puerta;
  188.     }
  189.     public function setPuerta(?string $puerta): self
  190.     {
  191.         $this->puerta $puerta;
  192.         $this->updateDireccion();
  193.         return $this;
  194.     }
  195.     public function getCp(): ?string
  196.     {
  197.         return $this->cp;
  198.     }
  199.     public function setCp(string $cp): self
  200.     {
  201.         $this->cp $cp;
  202.         return $this;
  203.     }
  204.     public function getPoblacion(): ?string
  205.     {
  206.         return $this->poblacion;
  207.     }
  208.     public function setPoblacion(string $poblacion): self
  209.     {
  210.         $this->poblacion $poblacion;
  211.         $this->updateDireccion();
  212.         return $this;
  213.     }
  214.     public function getProvincia(): ?string
  215.     {
  216.         return $this->provincia;
  217.     }
  218.     public function setProvincia(string $provincia): self
  219.     {
  220.         $this->provincia $provincia;
  221.         return $this;
  222.     }
  223.     public function getPotenciaP1(): ?string
  224.     {
  225.         return $this->potenciaP1;
  226.     }
  227.     public function setPotenciaP1(?string $potenciaP1): self
  228.     {
  229.         $this->potenciaP1 $potenciaP1;
  230.         return $this;
  231.     }
  232.     public function getPotenciaP2(): ?string
  233.     {
  234.         return $this->potenciaP2;
  235.     }
  236.     public function setPotenciaP2(?string $potenciaP2): self
  237.     {
  238.         $this->potenciaP2 $potenciaP2;
  239.         return $this;
  240.     }
  241.     public function getPotenciaP3(): ?string
  242.     {
  243.         return $this->potenciaP3;
  244.     }
  245.     public function setPotenciaP3(?string $potenciaP3): self
  246.     {
  247.         $this->potenciaP3 $potenciaP3;
  248.         return $this;
  249.     }
  250.     public function getPotenciaP4(): ?string
  251.     {
  252.         return $this->potenciaP4;
  253.     }
  254.     public function setPotenciaP4(?string $potenciaP4): self
  255.     {
  256.         $this->potenciaP4 $potenciaP4;
  257.         return $this;
  258.     }
  259.     public function getPotenciaP5(): ?string
  260.     {
  261.         return $this->potenciaP5;
  262.     }
  263.     public function setPotenciaP5(?string $potenciaP5): self
  264.     {
  265.         $this->potenciaP5 $potenciaP5;
  266.         return $this;
  267.     }
  268.     public function getPotenciaP6(): ?string
  269.     {
  270.         return $this->potenciaP6;
  271.     }
  272.     public function setPotenciaP6(?string $potenciaP6): self
  273.     {
  274.         $this->potenciaP6 $potenciaP6;
  275.         return $this;
  276.     }
  277.     public function getAlquilerContador(): ?string
  278.     {
  279.         return $this->alquilerContador;
  280.     }
  281.     public function setAlquilerContador(string $alquilerContador): self
  282.     {
  283.         $this->alquilerContador $alquilerContador;
  284.         return $this;
  285.     }
  286.     public function getConsumoAnual(): ?int
  287.     {
  288.         return $this->consumoAnual;
  289.     }
  290.     public function setConsumoAnual(int $consumoAnual): self
  291.     {
  292.         $this->consumoAnual $consumoAnual;
  293.         return $this;
  294.     }
  295.     /**
  296.      * @return Collection|Contrato[]
  297.      */
  298.     public function getContratos(): Collection
  299.     {
  300.         return $this->contratos;
  301.     }
  302.     public function getContrato(): ?Contrato
  303.     {
  304.         $contratos=array_filter(
  305.             $this->contratos->toArray(),
  306.             function ($e) {
  307.                 return $e->getEstado()->getId() == ;
  308.             }
  309.         );
  310.         $contrato=end($contratos);
  311.         if(!$contrato){
  312.             return null;
  313.         }else{
  314.             return $contrato;
  315.         }
  316.     }
  317.     public function addContrato(Contrato $contrato): self
  318.     {
  319.         if (!$this->contratos->contains($contrato)) {
  320.             $this->contratos[] = $contrato;
  321.             $contrato->setSuministro($this);
  322.         }
  323.         return $this;
  324.     }
  325.     public function removeContrato(Contrato $contrato): self
  326.     {
  327.         if ($this->contratos->contains($contrato)) {
  328.             $this->contratos->removeElement($contrato);
  329.             // set the owning side to null (unless already changed)
  330.             if ($contrato->getSuministro() === $this) {
  331.                 $contrato->setSuministro(null);
  332.             }
  333.         }
  334.         return $this;
  335.     }
  336.     public function __toString():?string
  337.     {
  338.         return $this->cups;
  339.     }
  340.     public function getDireccion():?string
  341.     {
  342.         $direccion=($this->tipoVia??new TipoVia())->getNombre().' '.$this->nombreVia.' '.$this->numeroDireccion;
  343.         if(!empty($this->escalera)){
  344.             $direccion.=', '.$this->escalera;
  345.         }
  346.         if(!empty($this->piso)){
  347.             $direccion.=', '.$this->piso;
  348.         }
  349.         if(!empty($this->puerta)){
  350.             $direccion.=', '.$this->puerta;
  351.         }
  352.         return $direccion;
  353.     }
  354.     public function getObservaciones(): ?string
  355.     {
  356.         return $this->observaciones;
  357.     }
  358.     public function setObservaciones(?string $observaciones): self
  359.     {
  360.         $this->observaciones $observaciones;
  361.         return $this;
  362.     }
  363.     public function getMaximetro(): ?bool
  364.     {
  365.         return $this->maximetro;
  366.     }
  367.     public function setMaximetro(?bool $maximetro): self
  368.     {
  369.         $this->maximetro $maximetro;
  370.         return $this;
  371.     }
  372.     public function getCodigoContable(): ?string
  373.     {
  374.         return $this->codigoContable;
  375.     }
  376.     public function setCodigoContable(?string $codigoContable): self
  377.     {
  378.         $this->codigoContable $codigoContable;
  379.         return $this;
  380.     }
  381.     public function getAlquilerContadorReal(): ?string
  382.     {
  383.         return $this->alquilerContadorReal;
  384.     }
  385.     public function setAlquilerContadorReal(?string $alquilerContadorReal): self
  386.     {
  387.         $this->alquilerContadorReal $alquilerContadorReal;
  388.         return $this;
  389.     }
  390.     public function getDireccionCompleta(): ?string
  391.     {
  392.         return $this->direccionCompleta;
  393.     }
  394.     public function updateDireccion(): self
  395.     {
  396.         $this->direccionCompleta $this->getDireccion();
  397.         return $this;
  398.     }
  399. }