<?php
namespace App\Entity;
use App\Core\Model\Orderable;
use App\Repository\EstimateRepository;
use DateInterval;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
/**
* @ORM\Entity(repositoryClass=EstimateRepository::class)
* @ORM\Table(
* name="`estimate`"
* )
*/
class Estimate extends Orderable implements JsonSerializable
{
const DELIVERY_MODE_BY_HAND = 1;
const DELIVERY_MODE_EMAIL = 3;
const DELIVERY_MODE_POSTAL_REGISTERED = 2;
const INSTRUCTION_ACCEPTED = 2;
const INSTRUCTION_PENDING = 1;
const INSTRUCTION_REFUSED = 3;
const PAYMENT_MODE_CASH = 1;
const PAYMENT_MODE_CHECK = 2;
const PAYMENT_MODE_CREDIT = 3;
const STATUS_CANCELLED = 3;
const STATUS_PENDING = 0;
const STATUS_VALID = 1;
const STATUS_VERIFIED = 2;
const YOUSIGN_STATUS_ACTIVE = "active";
const YOUSIGN_STATUS_DONE = "done";
const YOUSIGN_STATUS_DRAFT = 'draft';
const YOUSIGN_STATUS_EXPIRED = 'expired';
const YOUSIGN_STATUS_FINISHED = 'finished';
const YOUSIGN_STATUS_PENDING = 'pending';
const YOUSIGN_STATUS_PROCESSING = "processing";
const YOUSIGN_STATUS_REFUSED = 'refused';
/**
* @var EstimateBuilding | null
* @ORM\OneToOne(targetEntity="App\Entity\EstimateBuilding", mappedBy="estimate", cascade={"persist", "remove"})
*/
private $building;
/**
* @var boolean | null
* @ORM\Column(name="canceled", type="boolean", nullable=true)
*/
private $canceled;
/**
* @var string | null
* @ORM\Column(name="cerfa_document", type="string", length=255, nullable=true)
*/
private $cerfaDocument;
/**
* @var string | null
* @ORM\Column(name="cerfa_signature", type="text", nullable=true)
*/
private $cerfaSignature;
/**
* @var string | null
* @ORM\Column(name="comment", type="text", nullable=true)
*/
private $comment;
/**
* @var Collection|User[]
* @ORM\ManyToMany(targetEntity="App\Entity\User")
*/
private $commercials;
/**
* @var float | null
* @ORM\Column(name="contribution_amount", type="float", nullable=true)
*/
private $contributionAmount;
/**
* @var DateTime
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
private $createdAt;
/**
* @var float | null
* @ORM\Column(name="credit_amount", type="float", nullable=true)
*/
private $creditAmount;
/**
* @var float | null
* @ORM\Column(name="credit_amount_with_insurance", type="float", nullable=true)
*/
private $creditAmountWithInsurance;
/**
* @var float | null
* @ORM\Column(name="credit_amount_without_insurance", type="float", nullable=true)
*/
private $creditAmountWithoutInsurance;
/**
* @var float | null
* @ORM\Column(name="credit_cost_wihout_insurance", type="float", nullable=true)
*/
private $creditCostWihoutInsurance;
/**
* @var float | null
* @ORM\Column(name="credit_cost_with_insurance", type="float", nullable=true)
*/
private $creditCostWithInsurance;
/**
* @var float | null
* @ORM\Column(name="credit_debit_rate", type="float", nullable=true)
*/
private $creditDebitRate;
/**
* @var int | null
* @ORM\Column(name="credit_duration", type="integer", nullable=true)
*/
private $creditDuration;
/**
* @var string | null
* @ORM\Column(name="credit_etablishment", type="string", length=255, nullable=true)
*/
private $creditEtablishment;
/**
* @var int | null
* @ORM\Column(name="credit_mensuality_number", type="integer", nullable=true)
*/
private $creditMensualityNumber;
/**
* @var float | null
* @ORM\Column(name="credit_mensuality_wihout_insurance", type="float", nullable=true)
*/
private $creditMensualityWihoutInsurance;
/**
* @var float | null
* @ORM\Column(name="credit_mensuality_with_insurance", type="float", nullable=true)
*/
private $creditMensualityWithInsurance;
/**
* @var float | null
* @ORM\Column(name="credit_rate", type="float", nullable=true)
*/
private $creditRate;
/**
* @var float | null
* @ORM\Column(name="credit_report", type="float", nullable=true)
*/
private $creditReport;
/**
* @var float | null
* @ORM\Column(name="credit_taeg", type="float", nullable=true)
*/
private $creditTAEG;
/**
* @var float | null
* @ORM\Column(name="credit_without_insurance", type="float", nullable=true)
*/
private $creditWihoutInsurance;
/**
* @var EstimateCustomer | null
* @ORM\OneToOne(targetEntity="App\Entity\EstimateCustomer", mappedBy="estimate", cascade={"persist", "remove"})
*/
private $customer;
/**
* @var DateTime | null
* @ORM\Column(name="date_email", type="datetime", nullable=true)
*/
private $dateEmail;
/**
* @var DateTime
* @ORM\Column(name="date_previsionnelle", type="date")
*/
private $datePrevisionnelle;
/**
* @var DateTime
* @ORM\Column(name="date_visite", type="date")
*/
private $dateVisite;
/**
* @var int|null
* @ORM\Column(name="delivery_mode", type="integer", nullable=true, options={"default": 3})
*/
private $deliveryMode = self::DELIVERY_MODE_EMAIL;
/**
* @var string | null
* @ORM\Column(name="document", type="string", length=255, nullable=true)
*/
private $document;
/**
* @var string | null
* @ORM\Column(name="document_bon_de_commande", type="string", length=255, nullable=true)
*/
private $documentBonDeCommande;
/**
* @var string | null
* @ORM\Column(name="document_devis", type="string", length=255, nullable=true)
*/
private $documentDevis;
/**
* @var int | null
* @ORM\Column(name="extrabat_devis_id", type="integer", nullable=true)
*/
private $extrabatDevisId;
/**
* @var int | null
* @ORM\Column(name="instruction", type="integer", nullable=true)
*/
private $instruction = null;
/**
* @var boolean
* @ORM\Column(name="new_version", type="boolean", nullable=true)
*/
private $newVersion = false;
/**
* @var boolean | null
* @ORM\Column(name="nouveau_client", type="boolean", nullable=true)
*/
private $nouveauClient = true;
/**
* @var string | null
* @ORM\Column(name="organism", type="text", length=255, nullable=true)
*/
private $organism;
/**
* @var string | null
* @ORM\Column(name="programmated", type="boolean", nullable=true)
*/
private $programmated;
/**
* @var PurchaseOrder | null
* @ORM\OneToOne(targetEntity=PurchaseOrder::class, mappedBy="estimate", cascade={"persist", "remove"})
*/
private $purchaseOrder;
/**
* @var string | null
* @ORM\Column(name="signed_document", type="string", length=255, nullable=true)
*/
private $signedDocument;
/**
* @var int | null
* @ORM\Column(name="status", type="integer", nullable=true)
*/
private $status;
/**
* @var boolean
* @ORM\Column(name="step_bonus_complete", type="boolean", nullable=true)
*/
private $stepBonusComplete = false;
/**
* @var boolean
* @ORM\Column(name="step_building_complete", type="boolean", nullable=true)
*/
private $stepBuildingComplete = false;
/**
* @var boolean
* @ORM\Column(name="step_customer_complete", type="boolean", nullable=true)
*/
private $stepCustomerComplete = false;
/**
* @var boolean
* @ORM\Column(name="step_paiment_complete", type="boolean", nullable=true)
*/
private $stepPaimentComplete = false;
/**
* @var boolean
* @ORM\Column(name="step_signature_complete", type="boolean", nullable=true)
*/
private $stepSignatureComplete = false;
/**
* @var boolean
* @ORM\Column(name="step_waste_complete", type="boolean", nullable=true)
*/
private $stepWasteComplete = false;
/**
* @var boolean
* @ORM\Column(name="step_work_complete", type="boolean", nullable=true)
*/
private $stepWorkComplete = false;
/**
* @var Agency|null
* @ORM\ManyToOne(targetEntity="App\Entity\Agency")
* @ORM\JoinColumn(name="subcontractor", referencedColumnName="id", onDelete="SET NULL")
*/
private $subcontractor;
/**
* @var User|null
*
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="estimates")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $user;
/**
* @var boolean | null
* @ORM\Column(name="is_valid", type="boolean", nullable=true)
*/
private $valid;
/**
* @var string | null
* @ORM\Column(name="view_collab", type="boolean", nullable=true)
*/
private $viewByCOLLAB;
/**
* @var string | null
* @ORM\Column(name="view_da", type="boolean", nullable=true)
*/
private $viewByDA;
/**
* @var EstimateWork | null
* @ORM\OneToOne(targetEntity="App\Entity\EstimateWork", mappedBy="estimate", cascade={"persist", "remove"})
*/
private $work;
/**
* @var string | null
* @ORM\Column(name="yousign", type="string", length=255, nullable=true)
*/
private $yousign;
/**
* @var string | null
* @ORM\Column(name="yousign_file", type="string", length=255, nullable=true)
*/
private $yousignFile;
/**
* @var string | null
* @ORM\Column(name="yougign_status", type="string", length=255, nullable=true)
*/
private $yousignStatus;
public function __construct ()
{
$this->dateVisite = new DateTime();
$this->datePrevisionnelle = (new DateTime())->add(new DateInterval('P15D'));
$this->commercials = new ArrayCollection();
$this->createdAt = new DateTime();
$this->wasteTypes = [];
$this->viewByDA = false;
$this->viewByCOLLAB = false;
$this->programmated = false;
$this->canceled = false;
$this->newVersion = false;
$this->stepCustomerComplete = false;
$this->status = null;
}
public function __clone ()
{
$this->createdAt = new DateTime();
$this->dateVisite = new DateTime();
$this->datePrevisionnelle = (new DateTime())->add(new DateInterval('P15D'));
$this->dateEmail = null;
$this->number = null;
$this->yousignFile = null;
$this->yousignStatus = null;
$this->cerfaSignature = null;
$this->cerfaDocument = null;
$this->yousign = null;
$this->documentDevis = null;
$this->documentBonDeCommande = null;
$this->viewByDA = false;
$this->viewByCOLLAB = false;
$this->programmated = false;
$this->canceled = false;
$this->newVersion = true;
$this->status = null;
$this->purchaseOrder = null;
// $this->stepCustomerComplete = false;
}
/**
* @param User $user
*
* @return $this
*/
public function addCommercial (User $user): self
{
if (!$this->commercials->contains($user)) {
$this->commercials[] = $user;
}
return $this;
}
/**
* Get the value of advise
*/
public function getAdvise (): string
{
return ($this->getUser()) ? $this->getUser()->getFirstname() . ' ' . $this->getUser()->getLastname() : "";
}
/**
* Get Building.
*
* @return EstimateBuilding|null The Building.
*/
public function getBuilding (): ?EstimateBuilding
{
return $this->building;
}
/**
* Set the Building.
*
* @param EstimateBuilding|null $building
*
* @return Estimate return this class.
*/
public function setBuilding (?EstimateBuilding $building): Estimate
{
$this->building = $building;
// set the owning side of the relation if necessary
if ($building !== null && $building->getEstimate() !== $this) {
$building->setEstimate($this);
}
return $this;
}
/**
* @return bool|null
*/
public function getCanceled (): ?bool
{
return $this->canceled;
}
/**
* @param bool|null $canceled
* @return $this
*/
public function setCanceled (?bool $canceled): self
{
$this->canceled = $canceled;
return $this;
}
/**
* @return string|null
*/
public function getCerfaDocument (): ?string
{
return $this->cerfaDocument;
}
/**
* @param string|null $cerfaDocument
* @return Estimate
*/
public function setCerfaDocument (?string $cerfaDocument): Estimate
{
$this->cerfaDocument = $cerfaDocument;
return $this;
}
/**
* @return string|null
*/
public function getCerfaSignature (): ?string
{
return $this->cerfaSignature;
}
/**
* @param string|null $cerfaSignature
* @return Estimate
*/
public function setCerfaSignature (?string $cerfaSignature): Estimate
{
$this->cerfaSignature = $cerfaSignature;
return $this;
}
/**
* @return string|null
*/
public function getComment (): ?string
{
return $this->comment;
}
/**
* Set the value of comment
*/
public function setComment ($comment): self
{
$this->comment = $comment;
return $this;
}
/**
* Get Commercials.
*
* @return User[]|Collection The Commercials.
*/
public function getCommercials ()
{
return $this->commercials;
}
/**
* @return float|null
*/
public function getContributionAmount (): ?float
{
return $this->contributionAmount;
}
/**
* Set the value of contributionAmount
*/
public function setContributionAmount ($contributionAmount): self
{
$this->contributionAmount = $contributionAmount;
return $this;
}
/**
* Get CreatedAt.
*
* @return DateTime The CreatedAt.
*/
public function getCreatedAt (): DateTime
{
return $this->createdAt;
}
/**
* Set the CreatedAt.
*
* @param DateTime $createdAt
*
* @return Estimate return this class.
*/
public function setCreatedAt (DateTime $createdAt): Estimate
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return float|null
*/
public function getCreditAmount (): ?float
{
return $this->creditAmount;
}
/**
* @param float|null $creditAmount
* @return Estimate
*/
public function setCreditAmount (?float $creditAmount): Estimate
{
$this->creditAmount = $creditAmount;
return $this;
}
/**
* @return float|null
*/
public function getCreditAmountWithInsurance (): ?float
{
return $this->creditAmountWithInsurance;
}
/**
* @param float|null $creditAmountWithInsurance
* @return Estimate
*/
public function setCreditAmountWithInsurance (?float $creditAmountWithInsurance): Estimate
{
$this->creditAmountWithInsurance = $creditAmountWithInsurance;
return $this;
}
/**
* @return float|null
*/
public function getCreditAmountWithoutInsurance (): ?float
{
return $this->creditAmountWithoutInsurance;
}
/**
* @param float|null $creditAmountWithoutInsurance
* @return Estimate
*/
public function setCreditAmountWithoutInsurance (?float $creditAmountWithoutInsurance): Estimate
{
$this->creditAmountWithoutInsurance = $creditAmountWithoutInsurance;
return $this;
}
/**
* @return float|null
*/
public function getCreditCostWihoutInsurance (): ?float
{
return $this->creditCostWihoutInsurance;
}
/**
* @param float|null $creditCostWihoutInsurance
* @return Estimate
*/
public function setCreditCostWihoutInsurance (?float $creditCostWihoutInsurance): Estimate
{
$this->creditCostWihoutInsurance = $creditCostWihoutInsurance;
return $this;
}
/**
* @return float|null
*/
public function getCreditCostWithInsurance (): ?float
{
return $this->creditCostWithInsurance;
}
/**
* @param float|null $creditCostWithInsurance
* @return Estimate
*/
public function setCreditCostWithInsurance (?float $creditCostWithInsurance): Estimate
{
$this->creditCostWithInsurance = $creditCostWithInsurance;
return $this;
}
/**
* @return string|null
*/
public function getCreditDebitRate (): ?string
{
return $this->creditDebitRate;
}
/**
* @param string|null $creditDebitRate
* @return Estimate
*/
public function setCreditDebitRate (?string $creditDebitRate): Estimate
{
$this->creditDebitRate = $creditDebitRate;
return $this;
}
/**
* @return int|null
*/
public function getCreditDuration (): ?int
{
return $this->creditDuration;
}
/**
* @param int|null $creditDuration
* @return Estimate
*/
public function setCreditDuration (?int $creditDuration): Estimate
{
$this->creditDuration = $creditDuration;
return $this;
}
/**
* @return string|null
*/
public function getCreditEtablishment (): ?string
{
return $this->creditEtablishment;
}
/**
* @param string|null $creditEtablishment
* @return Estimate
*/
public function setCreditEtablishment (?string $creditEtablishment): Estimate
{
$this->creditEtablishment = $creditEtablishment;
return $this;
}
/**
* @return string|null
*/
public function getCreditMensualityNumber (): ?string
{
return $this->creditMensualityNumber;
}
/**
* @param string|null $creditMensualityNumber
* @return Estimate
*/
public function setCreditMensualityNumber (?string $creditMensualityNumber): Estimate
{
$this->creditMensualityNumber = $creditMensualityNumber;
return $this;
}
/**
* @return string|null
*/
public function getCreditMensualityWihoutInsurance (): ?string
{
return $this->creditMensualityWihoutInsurance;
}
/**
* @param string|null $creditMensualityWihoutInsurance
* @return Estimate
*/
public function setCreditMensualityWihoutInsurance (?string $creditMensualityWihoutInsurance): Estimate
{
$this->creditMensualityWihoutInsurance = $creditMensualityWihoutInsurance;
return $this;
}
/**
* @return string|null
*/
public function getCreditMensualityWithInsurance (): ?string
{
return $this->creditMensualityWithInsurance;
}
/**
* @param string|null $creditMensualityWithInsurance
* @return Estimate
*/
public function setCreditMensualityWithInsurance (?string $creditMensualityWithInsurance): Estimate
{
$this->creditMensualityWithInsurance = $creditMensualityWithInsurance;
return $this;
}
/**
* @return string|null
*/
public function getCreditRate (): ?string
{
return $this->creditRate;
}
/**
* @param string|null $creditRate
* @return Estimate
*/
public function setCreditRate (?string $creditRate): Estimate
{
$this->creditRate = $creditRate;
return $this;
}
/**
* @return string|null
*/
public function getCreditReport (): ?string
{
return $this->creditReport;
}
/**
* @param string|null $creditReport
* @return Estimate
*/
public function setCreditReport (?string $creditReport): Estimate
{
$this->creditReport = $creditReport;
return $this;
}
/**
* @return string|null
*/
public function getCreditTAEG (): ?string
{
return $this->creditTAEG;
}
/**
* @param string|null $creditTAEG
* @return Estimate
*/
public function setCreditTAEG (?string $creditTAEG): Estimate
{
$this->creditTAEG = $creditTAEG;
return $this;
}
/**
* @return string|null
*/
public function getCreditWihoutInsurance (): ?string
{
return $this->creditWihoutInsurance;
}
/**
* @param string|null $creditWihoutInsurance
* @return Estimate
*/
public function setCreditWihoutInsurance (?string $creditWihoutInsurance): Estimate
{
$this->creditWihoutInsurance = $creditWihoutInsurance;
return $this;
}
/**
* Get Customer.
*
* @return EstimateCustomer|null The Customer.
*/
public function getCustomer (): ?EstimateCustomer
{
return $this->customer;
}
/**
* Set the Customer.
*
* @param EstimateCustomer|null $customer
*
* @return Estimate return this class.
*/
public function setCustomer (?EstimateCustomer $customer): Estimate
{
$this->customer = $customer;
if ($customer) $customer->setEstimate($this);
return $this;
}
/**
* Get DateEmail.
*
* @return DateTime|null The DateEmail.
*/
public function getDateEmail (): ?DateTime
{
return $this->dateEmail;
}
/**
* Set the DateEmail.
*
* @param DateTime|null $dateEmail
* @return $this return this class.
*/
public function setDateEmail (?DateTime $dateEmail): self
{
$this->dateEmail = $dateEmail;
return $this;
}
/**
* Get DatePrevisionnelle.
*
* @return DateTime The DatePrevisionnelle.
*/
public function getDatePrevisionnelle (): DateTime
{
return $this->datePrevisionnelle;
}
/**
* Set the DatePrevisionnelle.
*
* @param DateTime|null $datePrevisionnelle
*
* @return Estimate return this class.
*/
public function setDatePrevisionnelle (?DateTime $datePrevisionnelle): Estimate
{
$this->datePrevisionnelle = $datePrevisionnelle ?? new DateTime();
return $this;
}
/**
* Get DateVisite.
*
* @return DateTime The DateVisite.
*/
public function getDateVisite (): DateTime
{
return $this->dateVisite;
}
/**
* Set the DateVisite.
*
* @param DateTime|null $dateVisite
*
* @return Estimate return this class.
*/
public function setDateVisite (?DateTime $dateVisite): Estimate
{
$this->dateVisite = $dateVisite ?? new DateTime();
return $this;
}
/**
* Get DeliveryMode.
*
* @return int|null The DeliveryMode.
*/
public function getDeliveryMode (): ?int
{
return $this->deliveryMode;
}
/**
* Set the DeliveryMode.
*
* @param int|null $deliveryMode
* @return $this
*/
public function setDeliveryMode (?int $deliveryMode): self
{
$this->deliveryMode = $deliveryMode;
return $this;
}
/**
* @return string[]
*/
public static function getDeliveryModesList (): array
{
return [
self::DELIVERY_MODE_BY_HAND => 'En main propre',
self::DELIVERY_MODE_EMAIL => 'Par email',
self::DELIVERY_MODE_POSTAL_REGISTERED => 'Par courrier recommandé',
];
}
/**
* Get Document.
*
* @return string|null The Document.
*/
public function getDocument (): ?string
{
return $this->document;
}
/**
* Set the Document.
*
* @param string|null $document
*
* @return Estimate return this class.
*/
public function setDocument (?string $document): Estimate
{
$this->document = $document;
return $this;
}
/**
* Get DocumentBonDeCommande.
*
* @return string|null The DocumentBonDeCommande.
*/
public function getDocumentBonDeCommande (): ?string
{
return $this->documentBonDeCommande;
}
/**
* Set the DocumentBonDeCommande.
*
* @param string|null $documentBonDeCommande
* @return $this return this class.
*/
public function setDocumentBonDeCommande (?string $documentBonDeCommande): self
{
$this->documentBonDeCommande = $documentBonDeCommande;
return $this;
}
/**
* Get DocumentDevis.
*
* @return string|null The DocumentDevis.
*/
public function getDocumentDevis (): ?string
{
return $this->documentDevis;
}
/**
* Set the DocumentDevis.
*
* @param string|null $documentDevis
* @return $this return this class.
*/
public function setDocumentDevis (?string $documentDevis): self
{
$this->documentDevis = $documentDevis;
return $this;
}
/**
* Get ExtrabatDevisId.
*
* @return int|null The ExtrabatDevisId.
*/
public function getExtrabatDevisId (): ?int
{
return $this->extrabatDevisId;
}
/**
* Set the ExtrabatDevisId.
*
* @param int|null $extrabatDevisId
*
* @return Estimate return this class.
*/
public function setExtrabatDevisId (?int $extrabatDevisId): Estimate
{
$this->extrabatDevisId = $extrabatDevisId;
return $this;
}
/**
* Get Instruction.
*
* @return int|null The Instruction.
*/
public function getInstruction (): ?int
{
return $this->instruction;
}
/**
* Set the Instruction.
*
* @param int|null $instruction
* @return $this return this class.
*/
public function setInstruction (?int $instruction): self
{
$this->instruction = $instruction;
return $this;
}
/**
* @return string[]
*/
public static function getInstructionChoices (): array
{
return [
self::INSTRUCTION_PENDING => "En attente",
self::INSTRUCTION_ACCEPTED => "Accepté",
self::INSTRUCTION_REFUSED => "Refusé",
];
}
public function getNouveauClient (): bool
{
return $this->nouveauClient ?? false;
}
public function setNouveauClient (?bool $nouveauClient): self
{
$this->nouveauClient = $nouveauClient;
return $this;
}
/**
* Get Organism.
*
* @return string|null The Organism.
*/
public function getOrganism (): ?string
{
return $this->organism;
}
/**
* Set the Organism.
*
* @param string|null $organism
*
* @return Estimate return this class.
*/
public function setOrganism (?string $organism): Estimate
{
$this->organism = $organism;
return $this;
}
/**
* @return string[]
*/
public static function getPaimentModeChoices (): array
{
return [
self::PAYMENT_MODE_CASH => "Espèces",
self::PAYMENT_MODE_CHECK => "Chèque",
self::PAYMENT_MODE_CREDIT => "Crédit",
];
}
/**
* Get the value of programmated
*/
public function getProgrammated ()
{
return $this->programmated;
}
/**
* Set the value of programmated
*/
public function setProgrammated ($programmated): self
{
$this->programmated = $programmated;
return $this;
}
/**
* @return PurchaseOrder|null
*/
public function getPurchaseOrder (): ?PurchaseOrder
{
return $this->purchaseOrder;
}
/**
* @param PurchaseOrder|null $purchaseOrder
*
* @return $this
*/
public function setPurchaseOrder (?PurchaseOrder $purchaseOrder): self
{
// unset the owning side of the relation if necessary
if ($purchaseOrder === null && $this->purchaseOrder !== null) {
$this->purchaseOrder->setEstimate(null);
}
// set the owning side of the relation if necessary
if ($purchaseOrder !== null && $purchaseOrder->getEstimate() !== $this) {
$purchaseOrder->setEstimate($this);
}
$this->purchaseOrder = $purchaseOrder;
return $this;
}
/**
* Get SignedDocument.
*
* @return string|null The SignedDocument.
*/
public function getSignedDocument (): ?string
{
return $this->signedDocument;
}
/**
* Set the SignedDocument.
*
* @param string|null $signedDocument
*
* @return Estimate return this class.
*/
public function setSignedDocument (?string $signedDocument): Estimate
{
$this->signedDocument = $signedDocument;
return $this;
}
/**
* Get Status.
*
* @return int|null The Status.
*/
public function getStatus (): ?int
{
return $this->status;
}
/**
* Set the Status.
*
* @param int|null $status
* @return $this return this class.
*/
public function setStatus (?int $status): self
{
$this->status = $status;
if ($status === self::STATUS_VALID) $this->valid = true;
return $this;
}
/**
* @return string[]
*/
public static function getStatusChoices (): array
{
return [
self::STATUS_PENDING => "En étude",
self::STATUS_VALID => "Validé DA",
self::STATUS_VERIFIED => "Vérifié Collab.",
self::STATUS_CANCELLED => "Annulé",
];
}
/**
* Get Subcontractor.
*
* @return Agency|null The Subcontractor.
*/
public function getSubcontractor (): ?Agency
{
return $this->subcontractor;
}
/**
* Set the Subcontractor.
*
* @param Agency|null $subcontractor
*
* @return Estimate return this class.
*/
public function setSubcontractor (?Agency $subcontractor): Estimate
{
$this->subcontractor = $subcontractor;
return $this;
}
public function getTotalExcludingVatDiscountedPrice ()
{
return array_sum(($this->getWork() ? $this->getWork()->getOrders() : new ArrayCollection([]))->map(function (EstimateWorkOrder $order) {
return $order->getTotalExcludingVatDiscountedPrice();
})->toArray());
}
/**
* Get User.
*
* @return User|null The User.
*/
public function getUser (): ?User
{
return $this->user;
}
/**
* Set the User.
*
* @param User|null $user
*
* @return Estimate return this class.
*/
public function setUser (?User $user): Estimate
{
$this->user = $user;
return $this;
}
/**
* Get the value of viewByCOLLAB
*/
public function getViewByCOLLAB ()
{
return $this->viewByCOLLAB;
}
/**
* Set the value of viewByCOLLAB
*/
public function setViewByCOLLAB ($viewByCOLLAB): self
{
$this->viewByCOLLAB = $viewByCOLLAB;
return $this;
}
// Credit
/**
* Get the value of viewByDA
*/
public function getViewByDA ()
{
return $this->viewByDA;
}
/**
* Set the value of viewByDA
*/
public function setViewByDA ($viewByDA): self
{
$this->viewByDA = $viewByDA;
return $this;
}
/**
* Get Work.
*
* @return EstimateWork|null The Work.
*/
public function getWork (): ?EstimateWork
{
return $this->work;
}
/**
* Set the Work.
*
* @param EstimateWork|null $work
*
* @return Estimate return this class.
*/
public function setWork (?EstimateWork $work): Estimate
{
$this->work = $work;
// set the owning side of the relation if necessary
if ($work !== null && $work->getEstimate() !== $this) {
$work->setEstimate($this);
}
return $this;
}
/**
* Get YousignId.
*
* @return string|null The YousignId.
*/
public function getYousign (): ?string
{
return $this->yousign;
}
/**
* Set the YousignId.
*
* @param string|null $yousign
*
* @return Estimate return this class.
*/
public function setYousign (?string $yousign): Estimate
{
$this->yousign = $yousign;
return $this;
}
/**
* Get Link.
*
* @return string|null The Link.
*/
public function getYousignFile (): ?string
{
return $this->yousignFile;
}
/**
* Set the Link.
*
* @param string|null $yousignFile
*
* @return $this return this class.
*/
public function setYousignFile (?string $yousignFile): self
{
$this->yousignFile = $yousignFile;
return $this;
}
/**
* Get YougignStatus.
*
* @return string|null The YougignStatus.
*/
public function getYousignStatus (): ?string
{
return $this->yousignStatus;
}
/**
* Set the YougignStatus.
*
* @param string|null $yousignStatus
* @return $this return this class.
*/
public function setYousignStatus (?string $yousignStatus): self
{
$this->yousignStatus = $yousignStatus;
return $this;
}
/**
* @return bool
*/
public function isAllStepsComplete (): bool
{
return $this->isStepCustomerComplete()
&& $this->isStepBonusComplete()
&& $this->isStepBuildingComplete()
&& $this->isStepPaimentComplete()
&& $this->isStepSignatureComplete()
&& $this->isStepWasteComplete()
&& $this->isStepWorkComplete();
}
/**
* Get NewVersion.
*
* @return bool The NewVersion.
*/
public function isNewVersion (): bool
{
return $this->newVersion === true;
}
/**
* Set the NewVersion.
*
* @param bool $newVersion
* @return $this return this class.
*/
public function setNewVersion (bool $newVersion): self
{
$this->newVersion = $newVersion;
return $this;
}
/**
* Get StepBonusComplete.
*
* @return bool The StepBonusComplete.
*/
public function isStepBonusComplete (): bool
{
return $this->stepBonusComplete === true;
}
/**
* Set the StepBonusComplete.
*
* @param bool $stepBonusComplete
* @return $this return this class.
*/
public function setStepBonusComplete (bool $stepBonusComplete): self
{
$this->stepBonusComplete = $stepBonusComplete;
return $this;
}
/**
* Get StepBuildingComplete.
*
* @return bool The StepBuildingComplete.
*/
public function isStepBuildingComplete (): bool
{
return $this->stepBuildingComplete === true;
}
/**
* Set the StepBuildingComplete.
*
* @param bool $stepBuildingComplete
* @return $this return this class.
*/
public function setStepBuildingComplete (bool $stepBuildingComplete): self
{
$this->stepBuildingComplete = $stepBuildingComplete;
return $this;
}
/**
* Get StepCustomerComplete.
*
* @return bool The StepCustomerComplete.
*/
public function isStepCustomerComplete (): bool
{
return $this->stepCustomerComplete === true;
}
/**
* Set the StepCustomerComplete.
*
* @param bool $stepCustomerComplete
* @return $this return this class.
*/
public function setStepCustomerComplete (bool $stepCustomerComplete): self
{
$this->stepCustomerComplete = $stepCustomerComplete;
return $this;
}
/**
* Get StepPaimentComplete.
*
* @return bool The StepPaimentComplete.
*/
public function isStepPaimentComplete (): bool
{
return $this->stepPaimentComplete === true;
}
/**
* Set the StepPaimentComplete.
*
* @param bool $stepPaimentComplete
* @return $this return this class.
*/
public function setStepPaimentComplete (bool $stepPaimentComplete): self
{
$this->stepPaimentComplete = $stepPaimentComplete;
return $this;
}
/**
* Get StepSignatureComplete.
*
* @return bool The StepSignatureComplete.
*/
public function isStepSignatureComplete (): bool
{
return $this->stepSignatureComplete === true;
}
/**
* Set the StepSignatureComplete.
*
* @param bool $stepSignatureComplete
* @return $this return this class.
*/
public function setStepSignatureComplete (bool $stepSignatureComplete): self
{
$this->stepSignatureComplete = $stepSignatureComplete;
return $this;
}
/**
* Get StepWasteComplete.
*
* @return bool The StepWasteComplete.
*/
public function isStepWasteComplete (): bool
{
return $this->stepWasteComplete === true;
}
/**
* Set the StepWasteComplete.
*
* @param bool $stepWasteComplete
* @return $this return this class.
*/
public function setStepWasteComplete (bool $stepWasteComplete): self
{
$this->stepWasteComplete = $stepWasteComplete;
return $this;
}
/**
* Get StepWorkComplete.
*
* @return bool The StepWorkComplete.
*/
public function isStepWorkComplete (): bool
{
return $this->stepWorkComplete === true;
}
/**
* Set the StepWorkComplete.
*
* @param bool $stepWorkComplete
* @return $this return this class.
*/
public function setStepWorkComplete (bool $stepWorkComplete): self
{
$this->stepWorkComplete = $stepWorkComplete;
return $this;
}
/**
* Get Valid.
*
* @return bool The Valid.
*/
public function isValid (): bool
{
return $this->valid === true;
}
public function jsonFormAdminSerialize (): array
{
return [
'paymentMode' => $this->getPaymentMode(),
'paymentType' => $this->getPaymentType(),
'modePayment' => $this->getModePayment() ? $this->getModePayment()->jsonSerialize() : null,
'deposit' => $this->getDeposit(),
'customer' => $this->getCustomer() ? $this->getCustomer()->jsonFormSerialize() : null,
'work' => $this->getWork() ? $this->getWork()->jsonFormSerialize() : null,
'building' => $this->getBuilding() ? $this->getBuilding()->jsonSerialiseForm() : null,
'user' => $this->getUser() ? ['id' => $this->getUser()->getId()] : ['id' => null],
'agency' => $this->getAgency() ? ['id' => $this->getAgency()->getId(), 'label' => $this->getAgency()->getLabel()] : null,
'datePrevisionnelle' => $this->getDatePrevisionnelle()->format('Y-m-d'),
'dateVisite' => $this->getDateVisite()->format('Y-m-d'),
'maPrimeRenove' => $this->getMaPrimeRenove(),
'energySavingCertificate' => $this->getEnergySavingCertificate(),
'wasteTypes' => $this->getWasteTypes(),
'wasteAddress' => $this->getWasteAddress(),
'wastePostalCode' => $this->getWastePostalCode(),
'wasteCity' => $this->getWasteCity(),
'wasteQuantity' => $this->getWasteQuantity(),
'commercials' => $this->getCommercials()->map(function (User $user) {
return $user->getId();
})->toArray(),
'creditEtablishment' => $this->getCreditEtablishment(),
'creditAmount' => $this->getCreditAmount(),
'contributionAmount' => $this->getContributionAmount(),
'creditMensualityWihoutInsurance' => $this->getCreditMensualityWihoutInsurance(),
'creditMensualityWithInsurance' => $this->getCreditMensualityWithInsurance(),
'creditDuration' => $this->getCreditDuration(),
'creditMensualityNumber' => $this->getCreditMensualityNumber(),
'creditAmountWithoutInsurance' => $this->getCreditAmountWithoutInsurance(),
'creditAmountWithInsurance' => $this->getCreditAmountWithInsurance(),
'creditCostWihoutInsurance' => $this->getCreditCostWihoutInsurance(),
'creditCostWithInsurance' => $this->getCreditCostWithInsurance(),
'creditRate' => $this->getCreditRate(),
'creditTAEG' => $this->getCreditTAEG(),
'creditDebitRate' => $this->getCreditDebitRate(),
'creditReport' => $this->getCreditReport(),
// 'comment' => $this->getComment(),
'subcontractor' => $this->getSubcontractor() ? $this->getSubcontractor()->getId() : null,
"deliveryMode" => $this->getDeliveryMode(),
"nouveauClient" => $this->getNouveauClient()
];
}
/**
* @inheritDoc
*/
public function jsonSerialize (): array
{
return [
'id' => $this->getId(),
'createdAt' => $this->getCreatedAt() ? $this->getCreatedAt()->format('Y-m-d H:i:s') : null,
'number' => $this->getNumber(),
'paymentMode' => $this->getPaymentMode(),
'paymentType' => $this->getPaymentType(),
'modePayment' => $this->getModePayment() ? $this->getModePayment()->jsonSerialize() : null,
'deposit' => $this->getDeposit(),
'customer' => $this->getCustomer() ? $this->getCustomer()->jsonSerialize() : null,
'work' => $this->getWork() ? $this->getWork()->jsonSerialize() : null,
'building' => $this->getBuilding() ? $this->getBuilding()->jsonSerialize() : null,
'purchaseOrder' => $this->getPurchaseOrder() ? $this->getPurchaseOrder()->jsonSerialize() : null,
'yousignId' => $this->getYousign(),
'yousignFile' => $this->getYousignFile(),
'yousignStatus' => $this->getYousignStatus(),
'user' => $this->getUser()->jsonSerializeInfos(),
'agency' => $this->getAgency() ? $this->getAgency()->jsonSerializeInfos() : null,
'datePrevisionnelle' => $this->getDatePrevisionnelle()->format('Y-m-d'),
'dateVisite' => $this->getDateVisite()->format('Y-m-d'),
'dateEmail' => $this->getDateEmail() ? $this->getDateEmail()->format('Y-m-d') : null,
'maPrimeRenov' => $this->getMaPrimeRenove(),
'maPrimeRenove' => $this->getMaPrimeRenove(),
'energySavingCertificate' => $this->getEnergySavingCertificate(),
'wasteTypes' => $this->getWasteTypes(),
'wasteAddress' => $this->getWasteAddress(),
'wastePostalCode' => $this->getWastePostalCode(),
'wasteCity' => $this->getWasteCity(),
'wasteQuantity' => $this->getWasteQuantity(),
'document' => $this->getDocument(),
'documentDevis' => $this->getDocumentDevis(),
'documentBonDeCommande' => $this->getDocumentBonDeCommande(),
'signedDocument' => $this->getSignedDocument(),
'cerfaDocument' => $this->getCerfaDocument(),
'commercials' => $this->getCommercials()->map(function (User $user) {
return $user->jsonSerializeInfos();
})->toArray(),
'creditEtablishment' => $this->getCreditEtablishment(),
'creditAmount' => $this->getCreditAmount(),
'contributionAmount' => $this->getContributionAmount(),
'creditMensualityWihoutInsurance' => $this->getCreditMensualityWihoutInsurance(),
'creditMensualityWithInsurance' => $this->getCreditMensualityWithInsurance(),
'creditDuration' => $this->getCreditDuration(),
'creditMensualityNumber' => $this->getCreditMensualityNumber(),
'creditAmountWithoutInsurance' => $this->getCreditAmountWithoutInsurance(),
'creditAmountWithInsurance' => $this->getCreditAmountWithInsurance(),
'creditCostWihoutInsurance' => $this->getCreditCostWihoutInsurance(),
'creditCostWithInsurance' => $this->getCreditCostWithInsurance(),
'creditRate' => $this->getCreditRate(),
'creditTAEG' => $this->getCreditTAEG(),
'creditDebitRate' => $this->getCreditDebitRate(),
'creditReport' => $this->getCreditReport(),
'comment' => $this->getComment(),
'advise' => $this->getAdvise() ?: "",
'subcontractor' => $this->getSubcontractor() ? $this->getSubcontractor()->jsonSerializeInfos() : null,
'viewByDA' => $this->getViewByDA(),
'viewByCOLLAB' => $this->getViewByCOLLAB(),
'programmated' => $this->getProgrammated(),
'canceled' => $this->getCanceled(),
'cerfaSignature' => $this->getCerfaSignature(),
'newVersion' => $this->isNewVersion(),
'stepCustomerComplete' => $this->isStepCustomerComplete(),
'stepBonusComplete' => $this->isStepBonusComplete(),
'stepBuildingComplete' => $this->isStepBuildingComplete(),
'stepPaimentComplete' => $this->isStepPaimentComplete(),
'stepSignatureComplete' => $this->isStepSignatureComplete(),
'stepWasteComplete' => $this->isStepWasteComplete(),
'stepWorkComplete' => $this->isStepWorkComplete(),
'allStepsComplete' => $this->isAllStepsComplete(),
"deliveryMode" => $this->getDeliveryMode(),
"status" => $this->getStatus(),
"nouveauClient" => $this->getNouveauClient()
];
}
/**
* @param User $user
*
* @return $this
*/
public function removeCommercial (User $user): self
{
$this->commercials->removeElement($user);
return $this;
}
/**
* @return $this
*/
public function setAllStepsComplete (): self
{
$this->setStepCustomerComplete(true)
->setStepBonusComplete(true)
->setStepBuildingComplete(true)
->setStepPaimentComplete(true)
->setStepSignatureComplete(true)
->setStepWasteComplete(true)
->setStepWorkComplete(true);
return $this;
}
/**
* Set the Valid.
*
* @param bool|null $valid
* @return $this return this class.
*/
public function setValid (?bool $valid): self
{
$this->valid = $valid;
return $this;
}
}