<?php
namespace App\Application\Internit\IntegracaoBundle\Sienge\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Application\Internit\IntegracaoBundle\Sienge\Repository\EmpreendimentoRepository;
/**
* Empreendimento - Cache local de empreendimentos sincronizados do Sienge
*/
#[ORM\Table(name: 'integracao_sienge_empreendimento')]
#[ORM\Entity(repositoryClass: EmpreendimentoRepository::class)]
class Empreendimento
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(name: 'id', type: 'integer', unique: true, nullable: false)]
private ?int $id = null;
/**
* ID do contrato do Sienge
*/
#[ORM\Column(name: 'sienge_contract_id', type: 'string', length: 255, nullable: false, unique: true)]
private string $siengeContractId;
/**
* ID da empresa do Sienge
*/
#[ORM\Column(name: 'sienge_company_id', type: 'string', length: 255, nullable: true)]
private ?string $siengeCompanyId = null;
/**
* ID da obra/edifício do Sienge
*/
#[ORM\Column(name: 'sienge_building_id', type: 'string', length: 255, nullable: true)]
private ?string $siengeBuildingId = null;
/**
* Nome do empreendimento
*/
#[ORM\Column(name: 'nome', type: 'string', length: 255, nullable: true)]
private ?string $nome = null;
/**
* Descrição da obra
*/
#[ORM\Column(name: 'descricao', type: 'text', nullable: true)]
private ?string $descricao = null;
/**
* Endereço
*/
#[ORM\Column(name: 'endereco', type: 'string', length: 255, nullable: true)]
private ?string $endereco = null;
/**
* Cidade
*/
#[ORM\Column(name: 'cidade', type: 'string', length: 100, nullable: true)]
private ?string $cidade = null;
/**
* Estado
*/
#[ORM\Column(name: 'estado', type: 'string', length: 2, nullable: true)]
private ?string $estado = null;
/**
* CEP
*/
#[ORM\Column(name: 'cep', type: 'string', length: 10, nullable: true)]
private ?string $cep = null;
/**
* Data de sincronização
*/
#[ORM\Column(name: 'data_sincronizacao', type: 'datetime', nullable: false)]
private \DateTimeInterface $dataSincronizacao;
/**
* Relacionamento com unidades
*
* @var Collection<int, Unidade>
*/
#[ORM\OneToMany(targetEntity: Unidade::class, mappedBy: 'empreendimento', cascade: ['persist', 'remove'])]
private Collection $unidades;
public function __construct()
{
$this->unidades = new ArrayCollection();
$this->dataSincronizacao = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getSiengeContractId(): string
{
return $this->siengeContractId;
}
public function setSiengeContractId(string $siengeContractId): self
{
$this->siengeContractId = $siengeContractId;
return $this;
}
public function getSiengeCompanyId(): ?string
{
return $this->siengeCompanyId;
}
public function setSiengeCompanyId(?string $siengeCompanyId): self
{
$this->siengeCompanyId = $siengeCompanyId;
return $this;
}
/**
* Alias semântico para getSiengeCompanyId() - usado em requisições de Imposto de Renda
* Retorna o ID da empresa do Sienge que pode ser usada como 'companyId' em APIs externas
*/
public function getCompanyId(): ?string
{
return $this->siengeCompanyId;
}
public function getSiengeBuildingId(): ?string
{
return $this->siengeBuildingId;
}
public function setSiengeBuildingId(?string $siengeBuildingId): self
{
$this->siengeBuildingId = $siengeBuildingId;
return $this;
}
public function getNome(): ?string
{
return $this->nome;
}
public function setNome(?string $nome): self
{
$this->nome = $nome;
return $this;
}
public function getDescricao(): ?string
{
return $this->descricao;
}
public function setDescricao(?string $descricao): self
{
$this->descricao = $descricao;
return $this;
}
public function getEndereco(): ?string
{
return $this->endereco;
}
public function setEndereco(?string $endereco): self
{
$this->endereco = $endereco;
return $this;
}
public function getCidade(): ?string
{
return $this->cidade;
}
public function setCidade(?string $cidade): self
{
$this->cidade = $cidade;
return $this;
}
public function getEstado(): ?string
{
return $this->estado;
}
public function setEstado(?string $estado): self
{
$this->estado = $estado;
return $this;
}
public function getCep(): ?string
{
return $this->cep;
}
public function setCep(?string $cep): self
{
$this->cep = $cep;
return $this;
}
public function getDataSincronizacao(): \DateTimeInterface
{
return $this->dataSincronizacao;
}
public function setDataSincronizacao(\DateTimeInterface $dataSincronizacao): self
{
$this->dataSincronizacao = $dataSincronizacao;
return $this;
}
/**
* @return Collection<int, Unidade>
*/
public function getUnidades(): Collection
{
return $this->unidades;
}
public function addUnidade(Unidade $unidade): self
{
if (!$this->unidades->contains($unidade)) {
$this->unidades->add($unidade);
$unidade->setEmpreendimento($this);
}
return $this;
}
public function removeUnidade(Unidade $unidade): self
{
if ($this->unidades->removeElement($unidade)) {
if ($unidade->getEmpreendimento() === $this) {
$unidade->setEmpreendimento(null);
}
}
return $this;
}
}