<?php
namespace App\Entity;
use App\Repository\DocumentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\CancelReason ;
use App\Entity\ExchangeReason;
use App\Entity\ReturnReason ;
use App\Entity\RefundReason ;
use App\Entity\PosSession;
use App\Entity\Warehouse;
use JsonSerializable;
/**
* @ORM\Entity(repositoryClass=DocumentRepository::class)
*/
class Document implements JsonSerializable
{
public const MESSENGER_ORIGIN_CRM = 'crm';
public const MESSENGER_ORIGIN_META_INBOX = 'meta_inbox';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $type;
/**
* @ORM\Column(type="string", length=255)
*/
private $status;
/**
* @ORM\Column(type="text")
*/
private ?string $conditionDocument = null;
/**
* @ORM\Column(type="string", length=255)
*/
private $internalNbr;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $externalNbr;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $object;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $note;
/**
* @ORM\Column(type="decimal", precision=12, scale=3, options={"default":"0.000", "comment": "Total HT brut (avant remise document)"})
*/
private $totalAmountHt;
/**
* @ORM\Column(type="decimal", precision=12, scale=3, options={"default":"0.000"})
*/
private $totalTva;
/**
* @ORM\Column( name="items_amount_ttc", type="decimal", precision=12, scale=3, options={"default":"0.000","comment":"Total TTC articles (hors livraison)"} )
*/
// Total TTC des articles uniquement (sans frais de livraison). Le champ total_amount_ttc reste = montant à payer (inclut livraison).
private $itemsAmountTtc = "0.000";
/**
* @ORM\Column(name="total_amount_ttc", type="decimal", precision=12, scale=3, options={"default":"0.000","comment":"Total TTC net (après remise document)"})
*/
private $totalAmountTtc;
/**
* @ORM\Column(type="string", length=255)
*/
private $paymentMethod;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $paymentDeadline;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $paymentRef;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $discount;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $discountType;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $advancePayment;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $advancePaymentType;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $parcelTrackingNbr;
/**
* @ORM\OneToMany(targetEntity=DocumentProduit::class, mappedBy="document" ,cascade={"persist"})
*/
private $documentProduits;
/**
* @ORM\OneToMany(targetEntity=DocumentDeclinationProduit::class, mappedBy="document" ,cascade={"persist"})
*/
private $documentDeclinationProduits;
/**
* @ORM\Column(type="string", length=255)
*/
private $category;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="documents")
*/
private $client;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="userDocuments")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(name="reseller_user_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
private ?User $resellerUser = null;
/**
* @ORM\ManyToOne(targetEntity=Document::class, inversedBy="documents")
*/
private $document;
/**
* @ORM\OneToMany(targetEntity=Document::class, mappedBy="document")
*/
private $documents;
/**
* @ORM\ManyToOne(targetEntity=Delivery::class, inversedBy="documents")
*/
private $delivery;
/**
* @ORM\ManyToOne(targetEntity=Warehouse::class)
* @ORM\JoinColumn(name="warehouse_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
private ?Warehouse $warehouse = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $urlPdf;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $deliveryDiscount;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $deliveryDiscountType;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $deliveryPrice;
/**
* @ORM\ManyToOne(targetEntity=Tva::class)
*/
private $deliveryTva;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $deliveryTotal;
/**
* @ORM\Column(name="delivery_company_total", type="decimal", precision=12, scale=2, nullable=true)
*/
private $deliveryCompanyTotal;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $adress;
/**
* @ORM\Column(name="temporary_stock_holder", type="string", length=255, nullable=true)
*/
private ?string $temporaryStockHolder = null;
/**
* @ORM\Column(name="temporary_stock_holder_type", type="string", length=20, nullable=true, options={"default":"other"})
*/
private ?string $temporaryStockHolderType = 'other';
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(name="temporary_stock_holder_user_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
private ?User $temporaryStockHolderUser = null;
/**
* @ORM\ManyToOne(targetEntity=TemporaryStockOutReason::class)
* @ORM\JoinColumn(name="temporary_stock_out_reason_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
private ?TemporaryStockOutReason $temporaryStockOutReason = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $deliveryCustomerFullName = null;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private ?string $deliveryCustomerPhone = null;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private ?string $deliveryCustomerPhone2 = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $deliveryCustomerAddress = null;
/**
* @ORM\Column(type="string", length=150, nullable=true)
*/
private ?string $deliveryCustomerCity = null;
/**
* @ORM\Column(type="string", length=150, nullable=true)
*/
private ?string $deliveryCustomerRegion = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $deliveryCustomerNote = null;
/**
* @ORM\Column(type="string", length=30, nullable=true)
*/
private ?string $sourceSocialPlatform = null;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $sourceSocialConversationId = null;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $sourceSocialContactId = null;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private ?string $messengerOrigin = null;
/**
* @ORM\OneToMany(targetEntity=Comment::class, mappedBy="document")
* @ORM\OrderBy({"createAt" = "DESC"})
*/
private $comments;
/**
* @ORM\ManyToOne(targetEntity=Supplier::class, inversedBy="documents")
*/
private $supplier;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $urlTracking;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $packagesNbr;
/**
* @ORM\OneToMany(targetEntity=Comment::class, mappedBy="documentComment")
*/
private $documentComments;
/**
* @ORM\Column(name="promised_at", type="datetime", nullable=true, options={"comment":"Date promise client/fournisseur"})
*/
private ?\DateTimeInterface $promisedAt = null;
/**
* @ORM\Column(name="shipped_at", type="datetime", nullable=true)
*/
private ?\DateTimeInterface $shippedAt = null;
/**
* @ORM\Column(name="delivered_at", type="datetime", nullable=true)
*/
private ?\DateTimeInterface $deliveredAt = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $returnedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $bonrecuAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $aPayerLe;
/**
* @ORM\ManyToOne(targetEntity=Source::class, inversedBy="documents")
*/
private $source;
/**
* @ORM\Column(type="boolean")
*/
private $isFreeDelivery;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private $updatedBy;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\OneToMany(targetEntity=Activity::class, mappedBy="document")
*/
private $activities;
/**
* @ORM\ManyToOne(targetEntity=Promotion::class)
*/
private $promotion;
/**
* @ORM\Column(name="payment_status", type="string", length=32, options={"default":"non-paye"})
*/
private $paymentStatus = 'non-paye';
/**
* @ORM\Column(name="paid_at", type="datetime", nullable=true)
*/
private $paidAt;
/**
* @ORM\Column(type="decimal", precision=12, scale=3, options={"default": "0.000", "comment": "Total des encaissements TTC"})
*/
private $totalPaid;
/**
* @ORM\Column(name="refund_amount", type="decimal", precision=12, scale=3, nullable=true)
*/
private $refundAmount;
/**
* @ORM\Column(name="refunded_at", type="datetime", nullable=true)
*/
private $refundedAt;
/**
* @ORM\Column( type="text", nullable=true, options={ "comment"="Données saisies lors d’une commande site web (nom, adresse, email) à vérifier par un commercial. Champ vidé après validation." })
*/
private ?string $webCheckPayload = null;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\CancelReason")
* @ORM\JoinColumn(name="cancel_reason_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $cancelReason;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\RefundReason")
* @ORM\JoinColumn(name="refund_reason_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $refundReason;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\ReturnReason")
* @ORM\JoinColumn(name="return_reason_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
*/
private $returnReason;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\ExchangeReason")
* @ORM\JoinColumn(name="exchange_reason_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
*/
private $exchangeReason;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $exchangeReasonNote = null;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $region;
/**
* @ORM\Column(type="integer")
*/
private int $publicNumber;
/**
* @ORM\Column(type="integer")
*/
private int $publicYear;
/**
* @ORM\ManyToOne(targetEntity=PosSession::class, inversedBy="documents")
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
private ?PosSession $posSession = null;
/**
* @ORM\OneToMany(targetEntity=PosPayment::class, mappedBy="document")
*/
private $posPayments;
public function __construct()
{
$this->documentProduits = new ArrayCollection();
$this->documentDeclinationProduits = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->documentComments = new ArrayCollection();
$this->activities = new ArrayCollection();
$this->posPayments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getConditionDocument(): ?string
{
return $this->conditionDocument;
}
public function setConditionDocument(string $conditionDocument): self
{
$this->conditionDocument = $conditionDocument;
return $this;
}
public function getInternalNbr(): ?string
{
return $this->internalNbr;
}
public function setInternalNbr(string $internalNbr): self
{
$this->internalNbr = $internalNbr;
return $this;
}
public function getExternalNbr(): ?string
{
return $this->externalNbr;
}
public function setExternalNbr(?string $externalNbr): self
{
$this->externalNbr = $externalNbr;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getObject(): ?string
{
return $this->object;
}
public function setObject(?string $object): self
{
$this->object = $object;
return $this;
}
public function getNote(): ?string
{
return $this->note;
}
public function setNote(?string $note): self
{
$this->note = $note;
return $this;
}
public function getTotalAmountHt(): ?float
{
return $this->totalAmountHt;
}
public function setTotalAmountHt(float $totalAmountHt): self
{
$this->totalAmountHt = $totalAmountHt;
return $this;
}
public function getTotalTva(): ?float
{
return $this->totalTva;
}
public function setTotalTva(float $totalTva): self
{
$this->totalTva = $totalTva;
return $this;
}
public function getItemsAmountTtc(): ?string
{
return $this->itemsAmountTtc;
}
public function setItemsAmountTtc($itemsAmountTtc): self
{
// Valeur TTC hors livraison (decimal string recommandé avec Doctrine)
$this->itemsAmountTtc = $itemsAmountTtc;
return $this;
}
public function getTotalAmountTtc(): ?string
{
return $this->totalAmountTtc;
}
public function getTotalToPay(): ?float
{
return $this->totalAmountTtc;
}
public function setTotalToPay(float $totalAmountTtc): self
{
$this->totalAmountTtc = $totalAmountTtc;
return $this;
}
public function getPaymentMethod(): ?string
{
return $this->paymentMethod;
}
public function setPaymentMethod(string $paymentMethod): self
{
$this->paymentMethod = $paymentMethod;
return $this;
}
public function getPaymentDeadline(): ?string
{
return $this->paymentDeadline;
}
public function setPaymentDeadline(?string $paymentDeadline): self
{
$this->paymentDeadline = $paymentDeadline;
return $this;
}
public function getPaymentRef(): ?string
{
return $this->paymentRef;
}
public function setPaymentRef(?string $paymentRef): self
{
$this->paymentRef = $paymentRef;
return $this;
}
public function getDiscount(): ?float
{
return $this->discount;
}
public function setDiscount(?float $discount): self
{
$this->discount = $discount;
return $this;
}
public function getDiscountType(): ?string
{
return $this->discountType;
}
public function setDiscountType(?string $discountType): self
{
$this->discountType = $discountType;
return $this;
}
public function getAdvancePayment(): ?float
{
return $this->advancePayment;
}
public function setAdvancePayment(?float $advancePayment): self
{
$this->advancePayment = $advancePayment;
return $this;
}
public function getAdvancePaymentType(): ?string
{
return $this->advancePaymentType;
}
public function setAdvancePaymentType(?string $advancePaymentType): self
{
$this->advancePaymentType = $advancePaymentType;
return $this;
}
public function getParcelTrackingNbr(): ?string
{
return $this->parcelTrackingNbr;
}
public function setParcelTrackingNbr(?string $parcelTrackingNbr): self
{
$this->parcelTrackingNbr = $parcelTrackingNbr;
return $this;
}
/**
* @return Collection|DocumentProduit[]
*/
public function getDocumentProduits(): Collection
{
return $this->documentProduits;
}
public function addDocumentProduit(DocumentProduit $documentProduit): self
{
if( !$this->documentProduits->contains($documentProduit)) {
$this->documentProduits[] = $documentProduit;
$documentProduit->setDocument($this);
}
return $this;
}
public function removeDocumentProduit(DocumentProduit $documentProduit): self
{
if( $this->documentProduits->removeElement($documentProduit)) {
// set the owning side to null (unless already changed)
if( $documentProduit->getDocument() === $this) {
$documentProduit->setDocument(null);
}
}
return $this;
}
/**
* @return Collection|DocumentDeclinationProduit[]
*/
public function getDocumentDeclinationProduits(): Collection
{
return $this->documentDeclinationProduits;
}
public function addDocumentDeclinationProduit(DocumentDeclinationProduit $documentDeclinationProduit): self
{
if( !$this->documentDeclinationProduits->contains($documentDeclinationProduit)) {
$this->documentDeclinationProduits[] = $documentDeclinationProduit;
$documentDeclinationProduit->setDocument($this);
}
return $this;
}
public function removeDocumentDeclinationProduit(DocumentDeclinationProduit $documentDeclinationProduit): self
{
if( $this->documentDeclinationProduits->removeElement($documentDeclinationProduit)) {
// set the owning side to null (unless already changed)
if( $documentDeclinationProduit->getDocument() === $this) {
$documentDeclinationProduit->setDocument(null);
}
}
return $this;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(string $category): self
{
$this->category = $category;
return $this;
}
public function getClient(): ?User
{
return $this->client;
}
public function setClient(?User $client): self
{
$this->client = $client;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getResellerUser(): ?User
{
return $this->resellerUser;
}
public function setResellerUser(?User $resellerUser): self
{
$this->resellerUser = $resellerUser;
return $this;
}
public function getDocument(): ?self
{
return $this->document;
}
public function setDocument(?self $document): self
{
$this->document = $document;
return $this;
}
/**
* @return Collection|self[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(self $document): self
{
if( !$this->documents->contains($document)) {
$this->documents[] = $document;
$document->setDocument($this);
}
return $this;
}
public function removeDocument(self $document): self
{
if( $this->documents->removeElement($document)) {
// set the owning side to null (unless already changed)
if( $document->getDocument() === $this) {
$document->setDocument(null);
}
}
return $this;
}
public function getDelivery(): ?Delivery
{
return $this->delivery;
}
public function setDelivery(?Delivery $delivery): self
{
$this->delivery = $delivery;
return $this;
}
public function getUrlPdf(): ?string
{
return $this->urlPdf;
}
public function setUrlPdf(?string $urlPdf): self
{
$this->urlPdf = $urlPdf;
return $this;
}
public function getDeliveryDiscount(): ?float
{
return $this->deliveryDiscount;
}
public function setDeliveryDiscount(?float $deliveryDiscount): self
{
$this->deliveryDiscount = $deliveryDiscount;
return $this;
}
public function getDeliveryDiscountType(): ?string
{
return $this->deliveryDiscountType;
}
public function setDeliveryDiscountType(?string $deliveryDiscountType): self
{
$this->deliveryDiscountType = $deliveryDiscountType;
return $this;
}
public function getDeliveryPrice(): ?float
{
return $this->deliveryPrice;
}
public function setDeliveryPrice(?float $deliveryPrice): self
{
$this->deliveryPrice = $deliveryPrice;
return $this;
}
public function getDeliveryTva(): ?Tva
{
return $this->deliveryTva;
}
public function setDeliveryTva(?Tva $deliveryTva): self
{
$this->deliveryTva = $deliveryTva;
return $this;
}
public function getDeliveryTotal(): ?float
{
return $this->deliveryTotal;
}
public function setDeliveryTotal(?float $deliveryTotal): self
{
$this->deliveryTotal = $deliveryTotal;
return $this;
}
public function getDeliveryCompanyTotal(): ?string
{
return $this->deliveryCompanyTotal;
}
public function setDeliveryCompanyTotal(?string $deliveryCompanyTotal): self
{
$this->deliveryCompanyTotal = $deliveryCompanyTotal;
return $this;
}
public function getAdress(): ?string
{
return $this->adress;
}
public function setAdress(?string $adress): self
{
$this->adress = $adress;
return $this;
}
public function getDeliveryCustomerFullName(): ?string
{
return $this->deliveryCustomerFullName;
}
public function setDeliveryCustomerFullName(?string $deliveryCustomerFullName): self
{
$deliveryCustomerFullName = trim((string) $deliveryCustomerFullName);
$this->deliveryCustomerFullName = $deliveryCustomerFullName !== '' ? $deliveryCustomerFullName : null;
return $this;
}
public function getDeliveryCustomerPhone(): ?string
{
return $this->deliveryCustomerPhone;
}
public function setDeliveryCustomerPhone(?string $deliveryCustomerPhone): self
{
$deliveryCustomerPhone = trim((string) $deliveryCustomerPhone);
$this->deliveryCustomerPhone = $deliveryCustomerPhone !== '' ? $deliveryCustomerPhone : null;
return $this;
}
public function getDeliveryCustomerPhone2(): ?string
{
return $this->deliveryCustomerPhone2;
}
public function setDeliveryCustomerPhone2(?string $deliveryCustomerPhone2): self
{
$deliveryCustomerPhone2 = trim((string) $deliveryCustomerPhone2);
$this->deliveryCustomerPhone2 = $deliveryCustomerPhone2 !== '' ? $deliveryCustomerPhone2 : null;
return $this;
}
public function getDeliveryCustomerAddress(): ?string
{
return $this->deliveryCustomerAddress;
}
public function setDeliveryCustomerAddress(?string $deliveryCustomerAddress): self
{
$deliveryCustomerAddress = trim((string) $deliveryCustomerAddress);
$this->deliveryCustomerAddress = $deliveryCustomerAddress !== '' ? $deliveryCustomerAddress : null;
return $this;
}
public function getDeliveryCustomerCity(): ?string
{
return $this->deliveryCustomerCity;
}
public function setDeliveryCustomerCity(?string $deliveryCustomerCity): self
{
$deliveryCustomerCity = trim((string) $deliveryCustomerCity);
$this->deliveryCustomerCity = $deliveryCustomerCity !== '' ? $deliveryCustomerCity : null;
return $this;
}
public function getDeliveryCustomerRegion(): ?string
{
return $this->deliveryCustomerRegion;
}
public function setDeliveryCustomerRegion(?string $deliveryCustomerRegion): self
{
$deliveryCustomerRegion = trim((string) $deliveryCustomerRegion);
$this->deliveryCustomerRegion = $deliveryCustomerRegion !== '' ? $deliveryCustomerRegion : null;
return $this;
}
public function getDeliveryCustomerNote(): ?string
{
return $this->deliveryCustomerNote;
}
public function setDeliveryCustomerNote(?string $deliveryCustomerNote): self
{
$deliveryCustomerNote = trim((string) $deliveryCustomerNote);
$this->deliveryCustomerNote = $deliveryCustomerNote !== '' ? $deliveryCustomerNote : null;
return $this;
}
public function getSourceSocialPlatform(): ?string
{
return $this->sourceSocialPlatform;
}
public function setSourceSocialPlatform(?string $sourceSocialPlatform): self
{
$this->sourceSocialPlatform = $sourceSocialPlatform;
return $this;
}
public function getSourceSocialConversationId(): ?int
{
return $this->sourceSocialConversationId;
}
public function setSourceSocialConversationId(?int $sourceSocialConversationId): self
{
$this->sourceSocialConversationId = $sourceSocialConversationId;
return $this;
}
public function getSourceSocialContactId(): ?int
{
return $this->sourceSocialContactId;
}
public function setSourceSocialContactId(?int $sourceSocialContactId): self
{
$this->sourceSocialContactId = $sourceSocialContactId;
return $this;
}
public function getMessengerOrigin(): ?string
{
return $this->messengerOrigin;
}
public function setMessengerOrigin(?string $messengerOrigin): self
{
$this->messengerOrigin = $messengerOrigin;
return $this;
}
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if( !$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setDocument($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if( $this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if( $comment->getDocument() === $this) {
$comment->setDocument(null);
}
}
return $this;
}
public function getSupplier(): ?Supplier
{
return $this->supplier;
}
public function setSupplier(?Supplier $supplier): self
{
$this->supplier = $supplier;
return $this;
}
public function getUrlTracking(): ?string
{
return $this->urlTracking;
}
public function setUrlTracking(?string $urlTracking): self
{
$this->urlTracking = $urlTracking;
return $this;
}
public function getPackagesNbr(): ?int
{
return $this->packagesNbr;
}
public function setPackagesNbr(?int $packagesNbr): self
{
$this->packagesNbr = $packagesNbr;
return $this;
}
/**
* @return Collection|Comment[]
*/
public function getDocumentComments(): Collection
{
return $this->documentComments;
}
public function addDocumentComment(Comment $documentComment): self
{
if( !$this->documentComments->contains($documentComment)) {
$this->documentComments[] = $documentComment;
$documentComment->setDocumentComment($this);
}
return $this;
}
public function removeDocumentComment(Comment $documentComment): self
{
if( $this->documentComments->removeElement($documentComment)) {
// set the owning side to null (unless already changed)
if( $documentComment->getDocumentComment() === $this) {
$documentComment->setDocumentComment(null);
}
}
return $this;
}
public function getPromisedAt(): ?\DateTimeInterface
{
return $this->promisedAt;
}
public function setPromisedAt(?\DateTimeInterface $promisedAt): self
{
$this->promisedAt = $promisedAt;
return $this;
}
public function getWarehouse(): ?Warehouse
{
return $this->warehouse;
}
public function setWarehouse(?Warehouse $warehouse): self
{
$this->warehouse = $warehouse;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getShippedAt(): ?\DateTimeInterface
{
return $this->shippedAt;
}
public function setShippedAt(?\DateTimeInterface $shippedAt): self
{
$this->shippedAt = $shippedAt;
return $this;
}
public function getDeliveredAt(): ?\DateTimeInterface
{
return $this->deliveredAt;
}
public function setDeliveredAt(?\DateTimeInterface $dt): self
{
$this->deliveredAt = $dt; return $this;
}
public function getReturnedAt(): ?\DateTimeInterface
{
return $this->returnedAt;
}
public function setReturnedAt(?\DateTimeInterface $returnedAt): self
{
$this->returnedAt = $returnedAt;
return $this;
}
public function getTemporaryStockHolder(): ?string
{
return $this->temporaryStockHolder;
}
public function setTemporaryStockHolder(?string $temporaryStockHolder): self
{
$this->temporaryStockHolder = $temporaryStockHolder !== null ? trim($temporaryStockHolder) : null;
return $this;
}
public function getTemporaryStockHolderType(): ?string
{
return $this->temporaryStockHolderType ?: 'other';
}
public function setTemporaryStockHolderType(?string $temporaryStockHolderType): self
{
$temporaryStockHolderType = trim((string) $temporaryStockHolderType);
if (!in_array($temporaryStockHolderType, ['user', 'other'], true)) {
$temporaryStockHolderType = 'other';
}
$this->temporaryStockHolderType = $temporaryStockHolderType;
return $this;
}
public function getTemporaryStockHolderUser(): ?User
{
return $this->temporaryStockHolderUser;
}
public function setTemporaryStockHolderUser(?User $temporaryStockHolderUser): self
{
$this->temporaryStockHolderUser = $temporaryStockHolderUser;
return $this;
}
public function getTemporaryStockOutReason(): ?TemporaryStockOutReason
{
return $this->temporaryStockOutReason;
}
public function setTemporaryStockOutReason(?TemporaryStockOutReason $temporaryStockOutReason): self
{
$this->temporaryStockOutReason = $temporaryStockOutReason;
return $this;
}
public function getBonrecuAt(): ?\DateTimeInterface
{
return $this->bonrecuAt;
}
public function setBonrecuAt(?\DateTimeInterface $bonrecuAt): self
{
$this->bonrecuAt = $bonrecuAt;
return $this;
}
public function getAPayerLe(): ?\DateTimeInterface
{
return $this->aPayerLe;
}
public function setAPayerLe(?\DateTimeInterface $aPayerLe): self
{
$this->aPayerLe = $aPayerLe;
return $this;
}
public function getSource(): ?Source
{
return $this->source;
}
public function setSource(?Source $source): self
{
$this->source = $source;
return $this;
}
public function getIsFreeDelivery(): ?bool
{
return $this->isFreeDelivery;
}
public function setIsFreeDelivery(bool $isFreeDelivery): self
{
$this->isFreeDelivery = $isFreeDelivery;
return $this;
}
public function getWebCheckPayload(): ?string
{
return $this->webCheckPayload;
}
public function setWebCheckPayload(?string $value): self
{
$this->webCheckPayload = $value;
return $this;
}
/**
* @return Collection|Activity[]
*/
public function getActivities(): Collection
{
return $this->activities;
}
public function addActivity(Activity $activity): self
{
if( !$this->activities->contains($activity)) {
$this->activities[] = $activity;
$activity->setDocument($this);
}
return $this;
}
public function removeActivity(Activity $activity): self
{
if( $this->activities->removeElement($activity)) {
// set the owning side to null (unless already changed)
if( $activity->getDocument() === $this) {
$activity->setDocument(null);
}
}
return $this;
}
public function getUpdatedBy(): ?User
{
return $this->user;
}
public function setUpdatedBy(?User $user): self
{
$this->updatedBy = $user;
return $this;
}
public function getPromotion(): ?Promotion
{
return $this->promotion;
}
public function setPromotion(?Promotion $promotion): self
{
$this->promotion = $promotion;
return $this;
}
public function getCancelReason(): ?CancelReason
{
return $this->cancelReason;
}
public function setCancelReason(?CancelReason $cancelReason): self
{
$this->cancelReason = $cancelReason;
return $this;
}
public function getRefundReason(): ?RefundReason
{
return $this->refundReason;
}
public function setRefundReason(?RefundReason $refundReason): self
{
$this->refundReason = $refundReason;
return $this;
}
public function getReturnReason(): ?ReturnReason
{
return $this->returnReason;
}
public function setReturnReason(?ReturnReason $returnReason): self
{
$this->returnReason = $returnReason;
return $this;
}
public function getExchangeReason(): ?ExchangeReason
{
return $this->exchangeReason;
}
public function setExchangeReason(?ExchangeReason $exchangeReason): self
{
$this->exchangeReason = $exchangeReason;
return $this;
}
public function getExchangeReasonNote(): ?string
{
return $this->exchangeReasonNote;
}
public function setExchangeReasonNote(?string $exchangeReasonNote): self
{
$this->exchangeReasonNote = $exchangeReasonNote;
return $this;
}
public function getPublicNumber(): int
{
return $this->publicNumber;
}
public function setPublicNumber(int $publicNumber): self
{
$this->publicNumber = $publicNumber;
return $this;
}
public function getPublicYear(): int
{
return $this->publicYear;
}
public function setPublicYear(int $publicYear): self
{
$this->publicYear = $publicYear;
return $this;
}
public function getPosSession(): ?PosSession
{
return $this->posSession;
}
public function setPosSession(?PosSession $posSession): self
{
$this->posSession = $posSession;
return $this;
}
/**
* @return Collection|PosPayment[]
*/
public function getPosPayments(): Collection
{
return $this->posPayments;
}
public function addPosPayment(PosPayment $posPayment): self
{
if (!$this->posPayments->contains($posPayment)) {
$this->posPayments[] = $posPayment;
$posPayment->setDocument($this);
}
return $this;
}
public function removePosPayment(PosPayment $posPayment): self
{
if ($this->posPayments->removeElement($posPayment)) {
if ($posPayment->getDocument() === $this) {
$posPayment->setDocument(null);
}
}
return $this;
}
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'totalToPay' => $this->getTotalToPayTtc() + $this->getDeliveryPrice(),
'createdAt' => $this->getCreatedAt()->format('d/m/Y h:i'),
'status' => $this->getStatus()
];
}
/* ---------- Getters/Setters paiement ---------- */
public function getPaymentStatus(): ?string
{
return $this->paymentStatus;
}
public function setPaymentStatus(string $paymentStatus): self
{
$this->paymentStatus = $paymentStatus;
return $this;
}
public function getPaidAt(): ?\DateTimeInterface
{
return $this->paidAt;
}
public function setPaidAt(?\DateTimeInterface $paidAt): self
{
$this->paidAt = $paidAt;
return $this;
}
/**
* Attention: Doctrine renvoie DECIMAL en string.
* On garde string pour éviter les surprises d’arrondi.
*/
public function getTotalPaid(): ?string
{
return $this->totalPaid;
}
public function setTotalPaid($totalPaid): self
{
// accepte float|string, on normalise à 3 décimales
$this->totalPaid = number_format((float)$totalPaid, 3, '.', '');
return $this;
}
/** @ORM\PrePersist */
public function ensureTotalPaid(): void
{
if ($this->totalPaid === null || $this->totalPaid === '') {
$this->totalPaid = '0.000';
}
}
public function getRefundAmount(): ?string
{
return $this->refundAmount;
}
public function setRefundAmount($refundAmount): self
{
$this->refundAmount = $refundAmount !== null
? number_format((float)$refundAmount, 3, '.', '')
: null;
return $this;
}
public function getRefundedAt(): ?\DateTimeInterface
{
return $this->refundedAt;
}
public function setRefundedAt(?\DateTimeInterface $refundedAt): self
{
$this->refundedAt = $refundedAt;
return $this;
}
public function getRegion(): ?string
{
return $this->region;
}
public function setRegion(?string $region): self
{
$this->region = $region ?? '';
return $this;
}
/* ---------- Helper historique ---------- */
/** Ajoute proprement une étape dans condition_document */
public function addConditionStep(string $label): self
{
$current = trim((string)$this->getConditionDocument());
$this->setConditionDocument($current !== '' ? $current.' -> '.$label : $label);
return $this;
}
}