src/Flexy/ShopBundle/Entity/Order/Order.php line 44
<?php
namespace App\Flexy\ShopBundle\Entity\Order;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use App\Entity\LogHistory;
use App\Entity\User;
use App\Flexy\ShopBundle\Entity\Accounting\Invoice;
use App\Flexy\ShopBundle\Entity\Customer\Customer;
use App\Flexy\ShopBundle\Entity\Product\ProductSubscription;
use App\Flexy\ShopBundle\Entity\Shipping\Shipment;
use App\Flexy\ShopBundle\Entity\Customer\CustomerWalletPoint;
use App\Flexy\ShopBundle\Entity\Payment\PaymentMethod;
use App\Flexy\ShopBundle\Entity\Promotion\Coupon;
use App\Flexy\ShopBundle\Entity\Shipping\CityRegion;
use App\Flexy\ShopBundle\Entity\Resource\Agent;
use App\Flexy\ShopBundle\Entity\Shipping\ShippingMethod;
use App\Flexy\ShopBundle\Entity\Store\Store;
use App\Flexy\ShopBundle\Entity\Vendor\Vendor;
use App\Flexy\ShopBundle\Repository\Order\OrderRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\InheritanceType;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource(
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
)]
#[ApiFilter(SearchFilter::class, properties: ['status' => 'exact','customer'=>'exact','statusShipping' => 'exact'])]
#[ORM\Table(name: '`order`')]
#[ORM\Entity(repositoryClass: OrderRepository::class)]
#[InheritanceType('JOINED')]
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]
#[Gedmo\Loggable(logEntryClass:LogHistory::class)]
class Order implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(['read'])]
private $id;
#[Groups(['read'])]
#[ORM\Column(type: 'datetime', nullable: true)]
private ?\DateTime $createdAt = null;
#[Groups(['read','write'])]
#[ORM\Column(type: 'text', nullable: true)]
#[Gedmo\Versioned]
private ?string $description = null;
#[Groups(['read','write'])]
#[ORM\ManyToOne(targetEntity: Customer::class, inversedBy: 'orders', cascade: ['persist'])]
#[Assert\Valid]
#[Gedmo\Versioned]
private ?\App\Flexy\ShopBundle\Entity\Customer\Customer $customer = null;
/**
*
* @example OrderItems that contain products,quantities,partial reductions, and details of the order
*/
#[Groups(['read','write'])]
#[ORM\OneToMany(targetEntity: OrderItem::class, mappedBy: 'parentOrder', cascade: ['persist', 'remove'])]
#[Assert\Valid]
private \Doctrine\Common\Collections\Collection|array $orderItems;
#[ORM\OneToMany(targetEntity: Adjustment::class, mappedBy: 'parentOrder')]
private \Doctrine\Common\Collections\Collection|array $adjustments;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $firstName = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $lastName = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $companyName = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $address = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $city = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $country = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $department = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $postcode = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $email = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $tel = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $comment = null;
#[ORM\ManyToOne(targetEntity: DemandeFund::class, inversedBy: 'orders')]
private ?\App\Flexy\ShopBundle\Entity\Order\DemandeFund $demandeFund = null;
#[Groups(['read','write'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Gedmo\Versioned]
private ?string $status = "draft";
#[Groups(['read','write'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Gedmo\Versioned]
private ?string $statusShipping = "draft";
#[Groups(['read','write'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $source = null;
#[ORM\Column(type: 'text', nullable: true)]
private $deliveryAt;
#[ORM\Column(type: 'text', nullable: true)]
private $recoveryAt;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $oldOrderNumber = null;
#[Groups(['read','write'])]
#[ORM\Column(type: 'float', nullable: true)]
private ?float $reduction = null;
#[ORM\Column(type: 'float', nullable: true)]
private $distance = 0;
#[ORM\ManyToOne(targetEntity: ShippingMethod::class, inversedBy: 'orders', cascade: ['persist'])]
#[Groups(['read','write'])]
#[Gedmo\Versioned]
private ?\App\Flexy\ShopBundle\Entity\Shipping\ShippingMethod $shippingMethod = null;
#[ORM\ManyToOne(targetEntity: Agent::class, inversedBy: 'orders')]
#[Groups(['read','write'])]
#[Gedmo\Versioned]
private ?\App\Flexy\ShopBundle\Entity\Resource\Agent $agent = null;
#[Groups(['read','write'])]
#[ORM\ManyToOne(targetEntity: paymentMethod::class, inversedBy: 'orders', cascade: ['persist'])]
#[ORM\JoinColumn(nullable: true, onDelete: 'CASCADE')]
private ?\App\Flexy\ShopBundle\Entity\Payment\PaymentMethod $paymentMethod = null;
#[ORM\Column(type: 'float', nullable: true)]
#[Groups(['read','write'])]
#[Gedmo\Versioned]
private ?float $payedAmount = null;
#[ORM\Column(type: 'datetime', nullable: true)]
#[Groups(['read','write'])]
#[Gedmo\Versioned]
private ?\DateTimeInterface $startProcessingAt = null;
#[Groups(['read','write'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $deliveryType = null;
#[ORM\Column(type: 'datetime', nullable: true)]
#[Groups(['read','write'])]
#[Gedmo\Versioned]
private ?\DateTimeInterface $startDeliveryAt = null;
#[ORM\OneToMany(targetEntity: CustomerWalletPoint::class, mappedBy: 'originOrder')]
private \Doctrine\Common\Collections\Collection|array $customerWalletPoints;
#[ORM\ManyToOne(targetEntity: Coupon::class, inversedBy: 'orders')]
#[Groups(['read','write'])]
private ?\App\Flexy\ShopBundle\Entity\Promotion\Coupon $coupon = null;
#[ORM\ManyToOne(targetEntity: Agent::class, inversedBy: 'ordersToDolist')]
private ?\App\Flexy\ShopBundle\Entity\Resource\Agent $agentToDo = null;
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isToDo = false;
#[ORM\ManyToOne(targetEntity: CityRegion::class, inversedBy: 'orders')]
private ?\App\Flexy\ShopBundle\Entity\Shipping\CityRegion $cityRegionShipping = null;
#[ORM\ManyToOne(targetEntity: CityRegion::class, inversedBy: 'collectedOrders')]
private $cityRegionCollect;
#[ORM\ManyToOne(targetEntity: Vendor::class, inversedBy: 'orders')]
private ?\App\Flexy\ShopBundle\Entity\Vendor\Vendor $vendor = null;
#[ORM\Column(type: 'text', nullable: true)]
#[Groups(['read','write'])]
private ?string $collectAddress = null;
#[ORM\Column(type: 'text', nullable: true)]
#[Groups(['read','write'])]
private ?string $shippingAddress = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $collectTel = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $collectLng = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $collectLat = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $shippingLng = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $shippingLat = null;
#[ORM\Column(type: 'boolean', nullable: true)]
#[Groups(['read','write'])]
private ?bool $isHeavy = null;
#[Groups(['read','write'])]
#[ORM\Column(type: 'float', nullable: true)]
private $shippingTips = 0;
#[Groups(['read','write'])]
#[ORM\Column(type: 'float', nullable: true)]
private $walletPaymentAmount = 0;
#[ORM\Column(type: 'boolean', nullable: true)]
private $isChecked;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $tokenStripe;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['read','write'])]
private ?string $orderType = "order";
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $deletedAt = null;
#[ORM\ManyToOne(inversedBy: 'orders')]
private ?Store $store = null;
#[ORM\OneToOne(inversedBy: 'relatedOrder', cascade: ['persist', 'remove'])]
#[Groups(['read','write'])]
private ?Shipment $shipment = null;
// Undefined array key \"invoice\"" To be fixed for #[Groups(['read','write'])]
#[ORM\ManyToOne(inversedBy: 'orders')]
private ?Invoice $invoice = null;
#[ORM\Column(type: Types::STRING,nullable: true)]
#[Gedmo\Blameable(on: 'create')]
private $createdBy;
#[ORM\OneToOne(mappedBy: 'relatedOrder', cascade: ['persist', 'remove'])]
private ?ProductSubscription $productSubscription = null;
#[Groups(['read','write'])]
#[ORM\Column(nullable: true)]
private ?array $metaData = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $defaultCurrency = null;
#[ORM\Column(nullable: true)]
private ?float $extraShippingFees = 0;
#[ORM\Column(length: 255, nullable: true)]
private ?string $extraShippingMethodName = "";
#[ORM\Column(length: 255, nullable: true)]
private ?string $extraShippingInfos = "";
public function __construct()
{
$this->orderItems = new ArrayCollection();
$this->adjustments = new ArrayCollection();
$this->createdAt = new \DateTime();
$this->customerWalletPoints = new ArrayCollection();
}
public function __toString(): string
{
return (string)$this->getOrderNumber();
}
public function getId(): ?int
{
return $this->id;
}
#[Groups(['read'])]
public function getOrderNumber($secondaryPrefix=null)
{
$prefix = "CMD-";
if($this->getOrderType()=="invoice"){
$prefix = "FA-";
}
$orderNumber = $prefix.$this->createdAt->format("ym").str_pad((string) $this->id, 5, "0", STR_PAD_LEFT);
if($secondaryPrefix){
$orderNumber = $prefix.$this->createdAt->format("ym").str_pad((string) $this->id, 5, "0", STR_PAD_LEFT)."-".$secondaryPrefix;
}
return $orderNumber;
}
#[Groups(['read'])]
public function getIdPrefixed()
{
return $this->getOrderNumber();
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTime $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): self
{
$this->customer = $customer;
return $this;
}
public function getCategoriesProduct(){
$categories = [];
foreach($this->getOrderItems() as $singleOrderItem){
if($singleOrderItem->getProduct()){
if($singleOrderItem->getProduct()->getParentCategory()){
$categories[] = $singleOrderItem->getProduct()->getParentCategory()->getName();
}
}
}
return $categories;
}
public function getSubCategoriesProduct(){
$categories = [];
foreach($this->getOrderItems() as $singleOrderItem){
if($singleOrderItem->getProduct()){
foreach($singleOrderItem->getProduct()->getCategoriesProduct() as $singleCategory){
if(!in_array($singleCategory->getName(),$categories)){
$categories[] = $singleCategory->getName();
}
}
}
}
return $categories;
}
/**
* @return Collection|OrderItem[]
*/
public function getOrderItems(): Collection
{
return $this->orderItems;
}
public function addOrderItem(OrderItem $orderItem): self
{
if (!$this->orderItems->contains($orderItem)) {
$this->orderItems[] = $orderItem;
$orderItem->setParentOrder($this);
}
return $this;
}
public function removeOrderItem(OrderItem $orderItem): self
{
if ($this->orderItems->removeElement($orderItem)) {
// set the owning side to null (unless already changed)
if ($orderItem->getParentOrder() === $this) {
$orderItem->setParentOrder(null);
}
}
return $this;
}
/**
* @return Collection|Adjustment[]
*/
public function getAdjustments(): Collection
{
return $this->adjustments;
}
public function addAdjustment(Adjustment $adjustment): self
{
if (!$this->adjustments->contains($adjustment)) {
$this->adjustments[] = $adjustment;
$adjustment->setParentOrder($this);
}
return $this;
}
public function removeAdjustment(Adjustment $adjustment): self
{
if ($this->adjustments->removeElement($adjustment)) {
// set the owning side to null (unless already changed)
if ($adjustment->getParentOrder() === $this) {
$adjustment->setParentOrder(null);
}
}
return $this;
}
#[Groups(['read'])]
public function getReductionOnCoupon(){
$reductionCoupon=0;
if($this->getCoupon()){
if($this->getCoupon()->getTypeReduction()=="percent"){
$reductionCoupon = ($this->getTotalAmount()/100)*$this->getCoupon()->getValueReduction();
}else{
$reductionCoupon = $this->getCoupon()->getValueReduction();
}
}
return $reductionCoupon;
}
public function getCompanyName(): ?string
{
return $this->companyName;
}
public function setCompanyName(?string $companyName): self
{
$this->companyName = $companyName;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
public function getDepartment(): ?string
{
return $this->department;
}
public function setDepartment(?string $department): self
{
$this->department = $department;
return $this;
}
public function getPostcode(): ?string
{
return $this->postcode;
}
public function setPostcode(?string $postcode): self
{
$this->postcode = $postcode;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getTel(): ?string
{
return $this->tel;
}
public function setTel(string $tel): self
{
$this->tel = $tel;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
#[Groups(['read'])]
public function getTotalAmount(){
$total=0;
foreach($this->orderItems as $singleOrderItem){
$total = $total + ($singleOrderItem->getTotalAmount());
}
return $total;
}
#[Groups(['read'])]
public function getFullTotalAmount(){
$total =
((float)$this->getTotalAmount() +
(float)$this->getShippingFees()
+ (float)$this->getShippingTips()) -
((float)$this->getTotalReduction()) ;
return $total;
}
#[Groups(['read'])]
public function getFullRestAmount(){
$payedAmount = $this->getPayedAmount();
$walletPayedAmount = $this->getWalletPaymentAmount();
$paymentMethodCode = null;
if($this->getPaymentMethod()){
$paymentMethodCode = $this->getPaymentMethod()->getCode();
}
if( ( $this->statusShipping == "cancelled")){
// ToReview
//return 0;
$payedAmount = 0;
}
$total = ($this->getTotalAmount() + $this->getShippingTips() + $this->getShippingFees()) - ($payedAmount + $walletPayedAmount + $this->getTotalReduction());
;
return $total;
}
//needs optimisation
#[Groups(['read'])]
public function getShippingFees(){
$fees = 0;
foreach($this->getOrderItems() as $singleOrderItem){
$fees += $singleOrderItem->getShippingFees();
}
$fees += $this->getExtraShippingFees();
if($fees>0) {return $fees;}
if($this->getShippingMethod()){
// Condition IlaveU / Classic 19 DH
if($this->getShippingMethod()->getCode() == "CLASSIQUE GRATUIT" and $this->getDeliveryType() == "on-store"){
return 0;
}
if($this->getShippingMethod()->isIsSeparatelyCalculated()){
$fees = $this->getShippingMethod()->getPrice();
foreach($this->getShippingMethod()->getShippingRules() as $shippingRule){
if($shippingRule->getTypeCalculation() == "distance"){
if( $shippingRule->getMin() < $this->getDistance() and $shippingRule->getMax() >= $this->getDistance() ){
$fees = $this->getDistance() * $shippingRule->getValueCalculation();
/*Condition for TLCS may be it works for all people*/
if ($fees < $this->getShippingMethod()->getPrice()){
$fees = $this->getShippingMethod()->getPrice();
}
/*Condition for TLCS may be it works for all people*/
}
}
else{
if(
$shippingRule->getMin() < $this->getTotalAmount() and $shippingRule->getMax() >= $this->getTotalAmount()
){
if($shippingRule->getTypeCalculation() == "percent"){
$fees = ($this->getTotalAmount() / 100 ) * $shippingRule->getValueCalculation();
}
else{
$fees = $shippingRule->getValueCalculation();
}
}
}
}
}
}
return $fees;
}
#[Groups(['read'])]
public function getTotalReduction(){
$total=0;
$total = $total + $this->getReduction() + $this->getReductionOnCoupon();
return $total;
}
public function getReductionOnTotal(){
$reductionAmount = 0;
if($this->getReduction() and $this->getReduction()>0){
$reductionAmount = ($this->getTotalAmount() / 100) * $this->getReduction();
}
return $reductionAmount;
}
#[Groups(['read'])]
public function getAmountPayedByCredit(){
$total=0;
foreach($this->getCustomerWalletPoints() as $singleWalletPoints){
if($singleWalletPoints->getPoints()<0){
$total = $total + ($singleWalletPoints->getPoints());
}
}
return $total;
}
#[Groups(['read'])]
public function getAmountEarnedAsCredit(){
$total=0;
foreach($this->getCustomerWalletPoints() as $singleWalletPoints){
if($singleWalletPoints->getPoints()>0){
$total = $total + ($singleWalletPoints->getPoints());
}
}
return $total;
}
public function getDemandeFund(): ?DemandeFund
{
return $this->demandeFund;
}
public function setDemandeFund(?DemandeFund $demandeFund): self
{
$this->demandeFund = $demandeFund;
return $this;
}
public function getStatus(): ?string
{
$status = "draft";
$shippingMethodCode = $this->getPaymentMethod() ? $this->getPaymentMethod()->getCode() : "";
$cashTranslations = [
"CASH",
"ESPECES"
];
if(
($this->statusShipping == "cancelled") or
($this->getPayedAmount() == 0 and $this->status == "paid") or
($this->status == "waiting" and $this->source == "mobile" and $this->payedAmount == $this->getFullTotalAmount() and in_array($shippingMethodCode,$cashTranslations) )
){
return "waiting";
}
if( ($this->getFullRestAmount() >= 0 and $this->getFullRestAmount() < $this->getFullTotalAmount())){
return "partially-paid";
}
// BySamir : ToReview : $this->status != "waiting" and $this->source != "mobile" and $this->source
if( $this->getFullRestAmount() == 0 and $this->getFullTotalAmount() > 0){
return "paid";
}
if($this->status)
{
$status = $this->status;
}
return $status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
// BySamir : TO CLEAN
public function getSource(): ?string
{
return $this->source;
}
public function setSource(?string $source): self
{
$this->source = $source;
return $this;
}
public function getDeliveryAt()
{
return $this->deliveryAt;
}
public function setDeliveryAt($deliveryAt)
{
$this->deliveryAt = $deliveryAt;
return $this;
}
public function getRecoveryAt()
{
return $this->recoveryAt;
}
public function setRecoveryAt($recoveryAt)
{
$this->recoveryAt = $recoveryAt;
return $this;
}
public function getReduction(): ?float
{
return $this->reduction;
}
public function setReduction(?float $reduction): self
{
$this->reduction = $reduction;
return $this;
}
#[Groups(['read'])]
public function getReductionInPercent(): ?float
{
return $this->reduction / (($this->reduction + $this->getFullTotalAmount()) / 100);
}
public function getShippingMethod(): ?ShippingMethod
{
return $this->shippingMethod;
}
public function setShippingMethod(?ShippingMethod $shippingMethod): self
{
$this->shippingMethod = $shippingMethod;
return $this;
}
public function getAgent(): ?Agent
{
return $this->agent;
}
public function setAgent(?Agent $agent): self
{
$this->agent = $agent;
return $this;
}
public function getPaymentMethod(): ?paymentMethod
{
return $this->paymentMethod;
}
public function setPaymentMethod(?paymentMethod $paymentMethod): self
{
$this->paymentMethod = $paymentMethod;
return $this;
}
public function getPayedAmount(): ?float
{
return $this->payedAmount;
}
public function setPayedAmount(?float $payedAmount): self
{
$this->payedAmount = $payedAmount;
return $this;
}
public function getStartProcessingAt(): ?\DateTimeInterface
{
return $this->startProcessingAt;
}
public function setStartProcessingAt(?\DateTimeInterface $startProcessingAt): self
{
$this->startProcessingAt = $startProcessingAt;
return $this;
}
public function getDeliveryType(): ?string
{
return $this->deliveryType;
}
public function setDeliveryType(?string $deliveryType): self
{
$this->deliveryType = $deliveryType;
return $this;
}
public function getStartDeliveryAt(): ?\DateTimeInterface
{
return $this->startDeliveryAt;
}
public function setStartDeliveryAt(?\DateTimeInterface $startDeliveryAt): self
{
$this->startDeliveryAt = $startDeliveryAt;
return $this;
}
/**
* @return Collection<int, CustomerWalletPoint>
*/
public function getCustomerWalletPoints(): Collection
{
return $this->customerWalletPoints;
}
public function addCustomerWalletPoint(CustomerWalletPoint $customerWalletPoint): self
{
if (!$this->customerWalletPoints->contains($customerWalletPoint)) {
$this->customerWalletPoints[] = $customerWalletPoint;
$customerWalletPoint->setOriginOrder($this);
}
return $this;
}
public function removeCustomerWalletPoint(CustomerWalletPoint $customerWalletPoint): self
{
if ($this->customerWalletPoints->removeElement($customerWalletPoint)) {
// set the owning side to null (unless already changed)
if ($customerWalletPoint->getOriginOrder() === $this) {
$customerWalletPoint->setOriginOrder(null);
}
}
return $this;
}
public function getCoupon(): ?Coupon
{
return $this->coupon;
}
public function setCoupon(?Coupon $coupon): self
{
$this->coupon = $coupon;
return $this;
}
public function getAgentToDo(): ?Agent
{
return $this->agentToDo;
}
public function setAgentToDo(?Agent $agentToDo): self
{
$this->agentToDo = $agentToDo;
return $this;
}
public function getIsToDo(): ?bool
{
return $this->isToDo;
}
public function setIsToDo(?bool $isToDo): self
{
$this->isToDo = $isToDo;
return $this;
}
public function getCityRegionShipping(): ?CityRegion
{
return $this->cityRegionShipping;
}
public function setCityRegionShipping(?CityRegion $cityRegionShipping): self
{
$this->cityRegionShipping = $cityRegionShipping;
return $this;
}
public function getVendor(): ?Vendor
{
return $this->vendor;
}
public function setVendor(?Vendor $vendor): self
{
$this->vendor = $vendor;
return $this;
}
public function getCollectAddress(): ?string
{
return $this->collectAddress;
}
public function setCollectAddress(?string $collectAddress): self
{
$this->collectAddress = $collectAddress;
return $this;
}
public function getCollectTel(): ?string
{
return $this->collectTel;
}
public function setCollectTel(?string $collectTel): self
{
$this->collectTel = $collectTel;
return $this;
}
public function getIsHeavy(): ?bool
{
return $this->isHeavy;
}
public function setIsHeavy(?bool $isHeavy): self
{
$this->isHeavy = $isHeavy;
return $this;
}
#[Groups(['read'])]
public function getShippingTips(): ?float
{
return $this->shippingTips;
}
public function setShippingTips(?float $shippingTips): self
{
$this->shippingTips = $shippingTips;
return $this;
}
/**
* Get the value of isChecked
*/
public function getIsChecked()
{
return $this->isChecked;
}
/**
* Set the value of isChecked
*
* @return self
*/
public function setIsChecked($isChecked)
{
$this->isChecked = $isChecked;
return $this;
}
/**
* Get the value of walletPaymentAmount
*/
public function getWalletPaymentAmount()
{
return $this->walletPaymentAmount;
}
/**
* Set the value of walletPaymentAmount
*
* @return self
*/
public function setWalletPaymentAmount($walletPaymentAmount)
{
$this->walletPaymentAmount = $walletPaymentAmount;
return $this;
}
/**
* Get the value of cityRegionCollect
*/
public function getCityRegionCollect()
{
return $this->cityRegionCollect;
}
/**
* Set the value of cityRegionCollect
*
* @return self
*/
public function setCityRegionCollect($cityRegionCollect)
{
$this->cityRegionCollect = $cityRegionCollect;
return $this;
}
/**
* Get the value of distance
*/
public function getDistance()
{
return $this->distance;
}
/**
* Set the value of distance
*
* @return self
*/
public function setDistance($distance)
{
$this->distance = $distance;
return $this;
}
/**
* Get the value of tokenStripe
*/
public function getTokenStripe()
{
return $this->tokenStripe;
}
/**
* Set the value of tokenStripe
*
* @return self
*/
public function setTokenStripe($tokenStripe)
{
$this->tokenStripe = $tokenStripe;
return $this;
}
public function getOrderType(): ?string
{
return $this->orderType;
}
public function setOrderType(?string $orderType): self
{
$this->orderType = $orderType;
return $this;
}
/**
* Get the value of deletedAt
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Set the value of deletedAt
*
* @return self
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getStore(): ?Store
{
return $this->store;
}
public function setStore(?Store $store): self
{
$this->store = $store;
return $this;
}
public function getShipment(): ?Shipment
{
return $this->shipment;
}
public function setShipment(?Shipment $shipment): self
{
$this->shipment = $shipment;
return $this;
}
public function getInvoice(): ?Invoice
{
return $this->invoice;
}
public function setInvoice(?Invoice $invoice): self
{
$this->invoice = $invoice;
return $this;
}
/**
* Get the value of shippingAddress
*/
public function getShippingAddress()
{
return $this->shippingAddress;
}
/**
* Set the value of shippingAddress
*
* @return self
*/
public function setShippingAddress($shippingAddress)
{
$this->shippingAddress = $shippingAddress;
return $this;
}
public function getCreatedBy()
{
return $this->createdBy;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
#[Groups(['read'])]
public function getStartProcessingAtText()
{
$value = null;
if($this->startDeliveryAt and $this->getShippingMethod()){
$intervalDate = clone $this->startProcessingAt;
$intervalInMinutes = $this->shippingMethod->getShippingDuration() * 60;
$intervalDate->modify(" + ".$intervalInMinutes." minutes");
$value = $this->startProcessingAt->format("d/m/Y H:i") ." - ".$intervalDate->format("H:i");
}
return $value;
}
#[Groups(['read'])]
public function getCreatedAtText()
{
$value = null;
if($this->createdAt){
$value = $this->createdAt->format("d/m/Y H:i");
}
return $value;
}
#[Groups(['read'])]
public function getStartDeliveryAtText()
{
$value = null;
if($this->startDeliveryAt and $this->getShippingMethod()){
$intervalDate = clone $this->startDeliveryAt;
$intervalInMinutes = $this->shippingMethod->getShippingDuration() * 60;
$intervalDate->modify(" + ".$intervalInMinutes." minutes");
$value = $this->startDeliveryAt->format("d/m/Y H:i") ." - ".$intervalDate->format("H:i");
}
return $value;
}
#[Groups(['read'])]
public function getShippingMethodText()
{
$value = null;
if($this->shippingMethod){
$value = $this->shippingMethod->getName();
}
return $value;
}
#[Groups(['read'])]
public function getPaymentMethodText()
{
$value = null;
if($this->paymentMethod){
$value = $this->paymentMethod->getName();
}
return $value;
}
#[Groups(['read'])]
public function getStatusText()
{
//$translated = $this->translator->trans($this->getSatus());
$translatedStatusArray = [
"paid"=>"Réglé",
"canceled"=>"annulé",
"waiting"=>"Non réglé",
"partially-paid"=>"Réglé partiellement",
];
if(array_key_exists($this->getStatus(),$translatedStatusArray)){
return $translatedStatusArray[$this->getStatus()];
}
return "Non réglé";
}
#[Groups(['read'])]
public function getTotalProducts()
{
$value = 0;
foreach($this->getOrderItems() as $singleOrderItem){
$defaultQuantityProduct = 1;
if($singleOrderItem->getProduct()){
if($singleOrderItem->getProduct()->getDefaultQuantity() > 0){
$defaultQuantityProduct = $singleOrderItem->getProduct()->getDefaultQuantity();
}
}
$value = $value + ($singleOrderItem->getQuantity() * $defaultQuantityProduct );
}
return $value;
}
public function getProductSubscription(): ?ProductSubscription
{
return $this->productSubscription;
}
public function setProductSubscription(?ProductSubscription $productSubscription): self
{
// unset the owning side of the relation if necessary
if ($productSubscription === null && $this->productSubscription !== null) {
$this->productSubscription->setRelatedOrder(null);
}
// set the owning side of the relation if necessary
if ($productSubscription !== null && $productSubscription->getRelatedOrder() !== $this) {
$productSubscription->setRelatedOrder($this);
}
$this->productSubscription = $productSubscription;
return $this;
}
/**
* Get the value of statusShipping
*/
public function getStatusShipping()
{
return $this->statusShipping;
}
/**
* Set the value of statusShipping
*
* @return self
*/
public function setStatusShipping($statusShipping)
{
$this->statusShipping = $statusShipping;
return $this;
}
public function getCollectLng()
{
return $this->collectLng;
}
public function getCollectLat()
{
return $this->collectLat;
}
public function setCollectLng($collectLng)
{
$this->collectLng = $collectLng;
return $this;
}
public function setCollectLat($collectLat)
{
$this->collectLat = $collectLat;
return $this;
}
public function getShippingLng()
{
return $this->shippingLng;
}
public function getShippingLat()
{
return $this->shippingLat;
}
public function setShippingLng($shippingLng)
{
$this->shippingLng = $shippingLng;
return $this;
}
public function setShippingLat($shippingLat)
{
$this->shippingLat = $shippingLat;
return $this;
}
public function getMetaData(): ?array
{
return $this->metaData;
}
public function setMetaData(?array $metaData): static
{
$this->metaData = $metaData;
return $this;
}
public function getDefaultCurrency(): ?string
{
return $this->defaultCurrency;
}
public function setDefaultCurrency(?string $defaultCurrency): static
{
$this->defaultCurrency = $defaultCurrency;
return $this;
}
public function getExtraShippingFees(): ?float
{
return $this->extraShippingFees;
}
public function setExtraShippingFees(?float $extraShippingFees): static
{
$this->extraShippingFees = $extraShippingFees;
return $this;
}
public function getExtraShippingMethodName(): ?string
{
return $this->extraShippingMethodName;
}
public function setExtraShippingMethodName(?string $extraShippingMethodName): static
{
$this->extraShippingMethodName = $extraShippingMethodName;
return $this;
}
public function getExtraShippingInfos(): ?string
{
return $this->extraShippingInfos;
}
public function setExtraShippingInfos(?string $extraShippingInfos): static
{
$this->extraShippingInfos = $extraShippingInfos;
return $this;
}
public function getShippingMonth(){
$result = "";
if($this->getStartDeliveryAt()){
$result = $this->getStartDeliveryAt()->format('M');
}
return $result;
}
}