<?php
namespace App\Entity\System;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="order_cancellation_request")
*
* @ORM\Entity(repositoryClass="App\Repository\System\OrderCancellationRequestRepository")
*/
class OrderCancellationRequest
{
public const WRONG_EAN_MARKETPLACE_CANCELLATION_REASON_ID = 8;
public const MIP_BY_API_CANCELLATION_REASON_ID = 11;
public const WORKHUMAN_CANCELLATION_REASON_ID = 12;
public const CANCELLATION_REASONS = [
0 => 'controlpanel.orders.modal_delete.cancellation_reason.other_reason',
1 => 'controlpanel.orders.modal_delete.cancellation_reason.quantity_or_sku_modification',
2 => 'controlpanel.orders.modal_delete.cancellation_reason.duplicated_order',
3 => 'controlpanel.orders.modal_delete.cancellation_reason.wrong_order',
4 => 'controlpanel.orders.modal_delete.cancellation_reason.end_customer_cancellation',
5 => 'controlpanel.orders.modal_delete.cancellation_reason.change_delivery_address',
6 => 'controlpanel.orders.modal_delete.cancellation_reason.negative_margin',
7 => 'controlpanel.orders.modal_delete.cancellation_reason.carrier_high_cost',
self::WRONG_EAN_MARKETPLACE_CANCELLATION_REASON_ID => 'controlpanel.orders.modal_delete.cancellation_reason.wrong_ean_marketplace',
9 => 'controlpanel.orders.modal_delete.cancellation_reason.end_customer_fraud',
10 => 'controlpanel.orders.modal_delete.cancellation_reason.test_order',
self::MIP_BY_API_CANCELLATION_REASON_ID => 'controlpanel.orders.cancellation_reason.mip_by_api',
self::WORKHUMAN_CANCELLATION_REASON_ID => 'controlpanel.orders.cancellation_reason.workhuman',
];
/**
* @var int
*
* @ORM\Id
*
* @ORM\GeneratedValue(strategy="AUTO")
*
* @ORM\Column(type="integer", name="id")
*/
private $id;
/**
* @var Order
*
* @ORM\OneToOne(targetEntity="App\Entity\System\Order", inversedBy="cancellationRequest")
*
* @ORM\JoinColumn(name="order_id", referencedColumnName="id_order")
*/
private $order;
/**
* @var int
*
* @ORM\Column(type="integer", length=10, name="order_previous_state")
*/
private $orderPreviousState;
/**
* @var \DateTime|null
*
* @ORM\Column(type="datetime", nullable=true)
*/
private $date;
/**
* @var int
*
* @ORM\Column(type="integer")
*/
private int $reason;
/**
* @var string
*
* @ORM\Column(type="string")
*/
private string $specificReason;
public function __construct()
{
}
public static function fromPrimitives(Order $order, int $orderPreviousState, int $reason, ?string $specificReason): self
{
$self = new self();
$self->order = $order;
$self->orderPreviousState = $orderPreviousState;
$self->reason = $reason;
$self->specificReason = $specificReason !== null ? $specificReason : '';
$self->date = new \DateTime();
return $self;
}
public function getId(): int
{
return $this->id;
}
public function getOrder(): Order
{
return $this->order;
}
public function setOrder(Order $order): void
{
$this->order = $order;
}
public function getOrderPreviousState(): int
{
return $this->orderPreviousState;
}
public function setOrderPreviousState(int $orderPreviousState): void
{
$this->orderPreviousState = $orderPreviousState;
}
public function getReason(): int
{
return $this->reason;
}
public function setReason(int $reason): void
{
$this->reason = $reason;
}
public function getSpecificReason(): string
{
return $this->specificReason;
}
public function setSpecificReason(string $specificReason): void
{
$this->specificReason = $specificReason;
}
public function getDate(): ?\DateTime
{
if (null === $this->date) {
return null;
}
if ((int)$this->date->format('Y') <= 0) {
// 0000-00-00 00:00:00 dates
return null;
}
return $this->date;
}
}