<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\Collection;
use App\Entity\Reglement;
/**
* Company
*
* @ORM\Table(name="company")
* @ORM\Entity
*/
class Company
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false, options={"default" : "SILVER BEAUTÉ"})
*/
private $name;
/**
* @var string|null
*
* @ORM\Column(name="tva_number", type="string", length=255, nullable=true)
*/
private $tvaNumber;
/**
* @var string|null
*
* @ORM\Column(name="capital", type="string", length=255, nullable=true)
*/
private $capital;
/**
* @var string|null
*
* @ORM\Column(name="siret", type="string", length=255, nullable=true)
*/
private $siret;
/**
* @var string|null
*
* @ORM\Column(name="forme", type="string", length=255, nullable=true)
*/
private $forme;
/**
* @var string|null
*
* @ORM\Column(name="urssaf_number", type="string", length=255, nullable=true)
*/
private $urssafNumber;
/**
* @var string|null
*
* @ORM\Column(name="fiscalite_number", type="string", length=255, nullable=true)
*/
private $fiscaliteNumber;
/**
* @var string|null
*
* @ORM\Column(name="ceo_name", nullable=true)
*/
private $ceoName;
/**
* @var string|null
*
* @ORM\Column(name="ceo_job", nullable=true)
*/
private $ceoJob;
/**
* @var bool
*
* @ORM\Column(name="status", type="boolean", nullable=false)
*/
private $status;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $logo;
/**
*
* @ORM\Column(name="endDate", type="string", nullable=true)
*/
private $endDate;
/**
*
* @ORM\Column(name="textMail", type="text", nullable=true)
*/
private $textMail;
/**
*
* @ORM\Column(name="mail", type="string", nullable=true)
*/
private $mail;
/**
* @var string|null
*
* @ORM\Column(name="convention", type="string", length=255, nullable=true)
*/
private $convention;
/**
* @var string
*
* @ORM\Column(name="telephoneStandard", type="string", nullable=false)
*/
private $telephoneStandard;
/**
* @var Address
*
* @ORM\ManyToOne(targetEntity="Address", cascade={"persist"})
* @ORM\JoinColumn(name="address_id", referencedColumnName="id")
*/
private $address;
/**
* @var BankAccount ArrayCollection
* @ORM\OneToMany(targetEntity="BankAccount", mappedBy="company", cascade={"persist"})
*/
protected $bankAccounts;
/**
* @var PaymentType ArrayCollection
* @ORM\OneToMany(targetEntity="PaymentType", mappedBy="company", cascade={"persist"})
*/
protected $payments;
/**
* @var PaymentType ArrayCollection
* @ORM\OneToMany(targetEntity=Reglement::class, mappedBy="company", cascade={"persist"})
*/
protected $reglements;
public function __construct()
{
$this->bankAccounts = new ArrayCollection();
$this->payments = new ArrayCollection();
$this->reglements = new ArrayCollection();
}
public function __toString()
{
return $this->getName();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getTvaNumber(): ?string
{
return $this->tvaNumber;
}
public function setTvaNumber(?string $tvaNumber): self
{
$this->tvaNumber = $tvaNumber;
return $this;
}
public function getCapital(): ?string
{
return $this->capital;
}
public function setCapital(?string $capital): self
{
$this->capital = $capital;
return $this;
}
public function getSiret(): ?string
{
return $this->siret;
}
public function setSiret(?string $siret): self
{
$this->siret = $siret;
return $this;
}
public function getForme(): ?string
{
return $this->forme;
}
public function setForme(?string $forme): self
{
$this->forme = $forme;
return $this;
}
public function getUrssafNumber(): ?string
{
return $this->urssafNumber;
}
public function setUrssafNumber(?string $urssafNumber): self
{
$this->urssafNumber = $urssafNumber;
return $this;
}
public function getFiscaliteNumber(): ?string
{
return $this->fiscaliteNumber;
}
public function setFiscaliteNumber(?string $fiscaliteNumber): self
{
$this->fiscaliteNumber = $fiscaliteNumber;
return $this;
}
public function getStatus(): ?bool
{
return $this->status;
}
public function setStatus(bool $status): self
{
$this->status = $status;
return $this;
}
public function getConvention(): ?string
{
return $this->convention;
}
public function setConvention(?string $convention): self
{
$this->convention = $convention;
return $this;
}
public function getAddress(): ?Address
{
return $this->address;
}
public function setAddress(?Address $address): self
{
$this->address = $address;
return $this;
}
/**
* @return BankAccount
*/
public function getBankAccounts()
{
return $this->bankAccounts;
}
/**
* @param BankAccount $bankAccounts
*/
public function setBankAccounts($bankAccounts): void
{
$this->bankAccounts = $bankAccounts;
}
/**
* @return string|null
*/
public function getCeoName(): ?string
{
return $this->ceoName;
}
/**
* @param string|null $ceoName
*/
public function setCeoName(?string $ceoName): void
{
$this->ceoName = $ceoName;
}
/**
* @return string|null
*/
public function getCeoJob(): ?string
{
return $this->ceoJob;
}
/**
* @param string|null $ceoJob
*/
public function setCeoJob(?string $ceoJob): void
{
$this->ceoJob = $ceoJob;
}
/**
* @return bool
*/
public function isEndDate()
{
return $this->endDate;
}
/**
* @param $endDate
*/
public function setEndDate($endDate)
{
$this->endDate = $endDate;
}
/**
* @return mixed
*/
public function getLogo()
{
return $this->logo;
}
/**
* @return BankAccount
*/
public function getPayments()
{
return $this->payments;
}
/**
* @param BankAccount $payments
*/
public function setPayments($payments): void
{
$this->payments = $payments;
}
/**
* @param mixed $logo
*/
public function setLogo($logo): void
{
$this->logo = $logo;
}
public function getPrefix() {
$prefix = 'FR';
if(strtoupper($this->name) === 'FREESIA') {
$prefix = 'FR';
}
elseif(strtoupper($this->name) === 'FREESIA SERVICE') {
$prefix = 'FRS';
}
elseif(strtoupper($this->name) === 'SILVER BEAUTÉ') {
$prefix = 'SB';
}
return $prefix;
}
/*********/
/* ADD */
/********/
public function addBankAccount(BankAccount $bankAccount)
{
$this->bankAccounts->add($bankAccount);
$bankAccount->setCompany($this);
}
public function addPayment(PaymentType $paymentType)
{
$this->payments->add($paymentType);
$paymentType->setCompany($this);
}
public function removePayment(PaymentType $paymentType)
{
$this->payments->remove($paymentType);
}
public function removeBankAccount(BankAccount $bankAccount)
{
$this->bankAccounts->remove($bankAccount);
}
/**
* @return PaymentType
*/
public function getSepaBankAccount() {
$criteria = Criteria::create()->where(Criteria::expr()->contains('name', PaymentType::NAME_SEPA));
return $this->payments->matching($criteria)->first();
}
/**
* @return PaymentType
*/
public function getCBPayment() {
$criteria = Criteria::create()->where(Criteria::expr()->contains('name', PaymentType::NAME_CB));
return $this->payments->matching($criteria)->first();
}
/**
* @return PaymentType
*/
public function getEspecePayment() {
$criteria = Criteria::create()->where(Criteria::expr()->contains('name', PaymentType::NAME_ESPECES));
return $this->payments->matching($criteria)->first();
}
/**
* @return PaymentType
*/
public function getChequePayment() {
$criteria = Criteria::create()->where(Criteria::expr()->contains('name', PaymentType::NAME_CHEQUE));
return $this->payments->matching($criteria)->first();
}
/**
* @return string
*/
public function getTelephoneStandard(): ?string
{
return $this->telephoneStandard;
}
/**
* @param string $telephoneStandard
*/
public function setTelephoneStandard(string $telephoneStandard): void
{
$this->telephoneStandard = $telephoneStandard;
}
/**
* @return mixed
*/
public function getTextMail()
{
return $this->textMail;
}
/**
* @param mixed $textMail
*/
public function setTextMail($textMail): void
{
$this->textMail = $textMail;
}
/**
* @return PaymentType
*/
public function getReglements()
{
return $this->reglements;
}
/**
* @param PaymentType $reglements
*/
public function setReglements($reglements): void
{
$this->reglements = $reglements;
}
/**
* @return mixed
*/
public function getMail()
{
return $this->mail;
}
/**
* @param mixed $mail
*/
public function setMail($mail): void
{
$this->mail = $mail;
}
}