<?php
namespace App\AtechNet\CoreBundle\Entity;
use App\AtechNet\CoreBundle\DTO\PriorityContext;
use App\AtechNet\CoreBundle\Entity\Statistics\OrderChangelog;
use App\AtechNet\CoreBundle\Enum\PaymentType;
use App\AtechNet\CoreBundle\Helper\Unas;
use App\AtechNet\CoreBundle\Helper\VAT;
use App\AtechNet\CoreBundle\Interface\Prioritizable;
use App\AtechNet\CoreBundle\Service\Order\OrderChangeLogService;
use App\AtechNet\CoreBundle\Translation\TranslatorInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
use Doctrine\ORM\Mapping\Index;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OrderBy;
use Doctrine\ORM\Mapping\Table as Table;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Order
*
* @Table(name="orders",
* indexes={
* @Index(name="idx_order_status", columns={"status"})
* })
* @Entity(repositoryClass="App\AtechNet\CoreBundle\Repository\OrderRepository")
* @HasLifecycleCallbacks
*/
class Order extends AbstractSignedEntity implements Prioritizable
{
public const int STATUS_OPEN = 10;
public const int STATUS_TRIAGE = 11;
public const int STATUS_RESERVED = 12;
public const int STATUS_WAITING_FOR_PAYMENT = 13;
public const int STATUS_WAITING = 20;
public const int STATUS_PRE_PROCESSING_ISSUE = 21;
public const int STATUS_WAITING_FOR_PARTNER = 22;
public const int STATUS_WAITING_FOR_PRODUCTION = 25;
public const int STATUS_WAITING_FOR_PRODUCTION_SALES = 26;
public const int STATUS_WAITING_FOR_PRODUCTION_QUARANTINE = 27;
public const int STATUS_WAITING_FOR_PRODUCTION_AIKEN = 28;
public const int STATUS_WAITING_FOR_PRODUCTION_DATA = 29;
public const int STATUS_PROCESSABLE = 30;
public const int STATUS_WAITING_FOR_ANSWER_SALES = 31;
public const int STATUS_WAITING_FOR_ANSWER_STOCK = 32;
public const int STATUS_WAITING_FOR_ANSWER_SERVICE = 33;
public const int STATUS_WAITING_FOR_ANSWER_ADMIN = 34;
public const int STATUS_WAITING_FOR_ANSWER_PARTS = 35;
public const int STATUS_WAITING_FOR_ANSWER = 37;
public const int STATUS_WAITING_FOR_ANSWER_AIKEN = 38;
public const int STATUS_WAITING_FOR_ANSWER_PARTNER = 39;
public const int STATUS_PROCESSING = 40;
public const int STATUS_WAITING_FOR_ANSWER_DATA = 41;
public const int STATUS_PROCESSING_ISSUES = 44;
public const int STATUS_READY_TO_PACK = 45;
public const int STATUS_READY_TO_SHIP = 50;
public const int STATUS_FINISHED = 60;
public const int STATUS_CANCELED = 70;
public const int STATUS_PICKUP_POINT = 80;
public const int PARCEL_STATUS_UNAVAILABLE = 0;
public const int PARCEL_STATUS_DATA_COLLECTED = 1;
public const int PARCEL_STATUS_ARRIVAL_IN_DEPOT = 3;
public const int PARCEL_STATUS_IN_DELIVERY = 4;
public const int PARCEL_STATUS_DELIVERED = 5;
public const int PARCEL_STATUS_DATA_RECEIVED = 51;
public const int PARCEL_STATUS_COD_DATA_RECEIVED = 52;
public const int PARCEL_STATUS_PACKAGE_PICKED_UP = 86;
public const string CreatedByType_Customer = 'Customer';
public const string CreatedByType_User = 'User';
public const string CreatedByType_Import = 'Import';
public const int WARRANTY_NO = 10;
public const int WARRANTY_30_DAYS = 20;
public const int WARRANTY_6_MONTHS = 25;
public const int WARRANTY_1_YEAR = 30;
public const int WARRANTY_2_YEAR = 40;
public const int WARRANTY_3_YEAR = 50;
public const int WARRANTY_4_YEAR = 60;
public const int WARRANTY_5_YEAR = 70;
public const int EXTERNAL_ORDER_SOURCE_BACKMARKET = 1;
public const int EXTERNAL_ORDER_SOURCE_REFURBED = 2;
public const int EXTERNAL_ORDER_SOURCE_AMAZON = 3;
public const int EXTERNAL_ORDER_SOURCE_EMAG = 4;
public const int EXTERNAL_ORDER_SOURCE_FNAC = 5;
public const int EXTERNAL_ORDER_SOURCE_CDISCOUNT = 6;
public const int EXTERNAL_ORDER_SOURCE_RAKUTEN = 7;
public const int EXTERNAL_ORDER_SOURCE_KAUFLAND = 8;
public const int EXTERNAL_ORDER_SOURCE_EBAY = 9;
public const int EXTERNAL_ORDER_SOURCE_ALLEGRO = 10;
public const int EXTERNAL_ORDER_SOURCE_RICONDIZIONATO = 11;
public const int EXTERNAL_ORDER_SOURCE_BACKMARKET_PRO = 12;
public const int EXTERNAL_ORDER_SOURCE_AUKRO = 13;
public const int EXTERNAL_ORDER_SOURCE_UNAS = 14;
public const int EXTERNAL_ORDER_SOURCE_MEDIAMARKT = 15;
public const int EXTERNAL_ORDER_SOURCE_PCCOMPONENTES = 16;
public const int PAYMENT_STATUS_PENDING = 0;
public const int PAYMENT_STATUS_PAID = 1;
public const int PAYMENT_STATUS_FAILED = 2;
public const int PAYMENT_STATUS_OVERPAID = 3;
public const int PAYMENT_STATUS_PARTIAL = 4;
public const int PAYMENT_STATUS_COMMISSION = 5;
public const string PUBLIC_LINK_SECRET = '4t6w9z$C&F)J@NcRfUjXn2r5u8x!A%D*';
public const array LANGUAGES_BY_COUNTRIES = [
'FR' => 'FR',
'IT' => 'IT',
'ES' => 'ES',
'US' => 'US',
'UK' => 'UK',
'DE' => 'DE',
'PT' => 'PT',
'BE' => 'FR',
'SE' => 'SWE',
'SK' => 'SK',
'NL' => 'NL',
'DK' => 'DN',
'FI' => 'FI',
'SI' => 'SI',
'RO' => 'RO',
'RE' => 'FR',
'PL' => 'PL',
'MT' => 'UK',
'MC' => 'UK',
'LV' => 'LT',
'LU' => 'DE',
'LT' => 'UK',
'IE' => 'UK',
'HR' => 'HR',
'HK' => 'UK',
'GR' => 'GR',
'GP' => 'FR',
'EE' => 'UK',
'CY' => 'GR',
'CH' => 'DE',
'BG' => 'BG',
'AT' => 'DE',
'HU' => 'HU',
'CZ' => 'CZ'
];
private ArrayCollection $orderChangelog;
/**
* @return string[]
*/
public static function getStatusChoices(): array
{
return [
self::STATUS_TRIAGE => 'Triage',
self::STATUS_RESERVED => 'Reserved',
self::STATUS_WAITING_FOR_PAYMENT => 'Waiting for payment',
self::STATUS_PRE_PROCESSING_ISSUE => 'Pre-Processing Issue',
self::STATUS_WAITING_FOR_PARTNER => 'Waiting for partner',
self::STATUS_WAITING_FOR_PRODUCTION_SALES => 'Waiting for production - Sales',
self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE => 'Waiting for production - Quarantine',
self::STATUS_WAITING_FOR_PRODUCTION_AIKEN => 'Waiting for production - Aiken',
self::STATUS_WAITING_FOR_PRODUCTION_DATA => 'Waiting for Data',
self::STATUS_PROCESSABLE => 'Processable',
self::STATUS_PROCESSING => 'Processing',
self::STATUS_PROCESSING_ISSUES => 'Processing Issues',
self::STATUS_WAITING_FOR_ANSWER_SALES => 'Waiting for answer sales',
self::STATUS_WAITING_FOR_ANSWER_STOCK => 'Waiting for answer stock',
self::STATUS_WAITING_FOR_ANSWER_SERVICE => 'Waiting for answer service',
self::STATUS_WAITING_FOR_ANSWER_ADMIN => 'Waiting for answer admin',
self::STATUS_WAITING_FOR_ANSWER_PARTS => 'Waiting for answer parts',
self::STATUS_WAITING_FOR_ANSWER_AIKEN => 'Waiting for answer aiken',
self::STATUS_WAITING_FOR_ANSWER_PARTNER => 'Waiting for answer partner',
self::STATUS_WAITING_FOR_ANSWER_DATA => 'Waiting for answer data',
self::STATUS_READY_TO_PACK => 'Ready to pack',
self::STATUS_READY_TO_SHIP => 'Ready to ship',
self::STATUS_FINISHED => 'Finished',
self::STATUS_CANCELED => 'Canceled',
];
}
public static function getStatusChoicesOldAndNew(): array
{
return [
self::STATUS_OPEN => 'Open',
self::STATUS_WAITING => 'Waiting',
self::STATUS_WAITING_FOR_PARTNER => 'Waiting for partner',
self::STATUS_WAITING_FOR_PRODUCTION => 'Waiting for production',
self::STATUS_WAITING_FOR_PRODUCTION_SALES => 'Waiting for production - Sales',
self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE => 'Waiting for production - Quarantine',
self::STATUS_WAITING_FOR_PRODUCTION_AIKEN => 'Waiting for production - Aiken',
self::STATUS_WAITING_FOR_PRODUCTION_DATA => 'Waiting for Data',
self::STATUS_WAITING_FOR_ANSWER_SALES => 'Waiting for answer sales',
self::STATUS_WAITING_FOR_ANSWER_STOCK => 'Waiting for answer stock',
self::STATUS_WAITING_FOR_ANSWER_SERVICE => 'Waiting for answer service',
self::STATUS_WAITING_FOR_ANSWER_ADMIN => 'Waiting for answer admin',
self::STATUS_WAITING_FOR_ANSWER_AIKEN => 'Waiting for answer aiken',
self::STATUS_WAITING_FOR_ANSWER_PARTS => 'Waiting for answer parts',
self::STATUS_WAITING_FOR_ANSWER_PARTNER => 'Waiting for answer partner',
self::STATUS_WAITING_FOR_ANSWER_DATA => 'Waiting for answer data',
self::STATUS_WAITING_FOR_ANSWER => 'Waiting for answer',
self::STATUS_READY_TO_PACK => 'Ready to pack',
self::STATUS_READY_TO_SHIP => 'Ready to ship',
self::STATUS_PICKUP_POINT => 'Pickup point',
self::STATUS_TRIAGE => 'Triage',
self::STATUS_RESERVED => 'Reserved',
self::STATUS_WAITING_FOR_PAYMENT => 'Waiting for payment',
self::STATUS_PRE_PROCESSING_ISSUE => 'Pre-Processing Issue',
self::STATUS_PROCESSABLE => 'Processable',
self::STATUS_PROCESSING_ISSUES => 'Processing Issues',
self::STATUS_PROCESSING => 'Processing',
self::STATUS_FINISHED => 'Finished',
self::STATUS_CANCELED => 'Canceled',
];
}
/**
* @param int $from
* @param string $userRight
* @return array|int[]
*/
public static function getAvailableNextStep(int $from, string $userRight): array
{
if ($userRight === User::PERMISSION_ORDER_STATUS_ALL) {
return [
self::STATUS_TRIAGE,
self::STATUS_RESERVED,
self::STATUS_WAITING_FOR_PAYMENT,
self::STATUS_WAITING_FOR_PARTNER,
self::STATUS_WAITING_FOR_PRODUCTION_SALES,
self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE,
self::STATUS_WAITING_FOR_PRODUCTION_AIKEN,
self::STATUS_WAITING_FOR_PRODUCTION_DATA,
self::STATUS_PROCESSABLE,
self::STATUS_PROCESSING,
self::STATUS_WAITING_FOR_ANSWER_SALES,
self::STATUS_WAITING_FOR_ANSWER_STOCK,
self::STATUS_WAITING_FOR_ANSWER_SERVICE,
self::STATUS_WAITING_FOR_ANSWER_ADMIN,
self::STATUS_WAITING_FOR_ANSWER_AIKEN,
self::STATUS_WAITING_FOR_ANSWER_PARTS,
self::STATUS_WAITING_FOR_ANSWER_PARTNER,
self::STATUS_WAITING_FOR_ANSWER_DATA,
self::STATUS_READY_TO_SHIP,
self::STATUS_READY_TO_PACK,
self::STATUS_CANCELED,
self::STATUS_FINISHED
];
}
if ($userRight === User::PERMISSION_ORDER_STATUS_SALES) {
return [
self::STATUS_TRIAGE,
self::STATUS_RESERVED,
self::STATUS_WAITING_FOR_PAYMENT,
self::STATUS_WAITING_FOR_PARTNER,
self::STATUS_WAITING_FOR_PRODUCTION_SALES,
self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE,
self::STATUS_WAITING_FOR_PRODUCTION_AIKEN,
self::STATUS_WAITING_FOR_PRODUCTION_DATA,
self::STATUS_READY_TO_PACK,
self::STATUS_WAITING_FOR_ANSWER_ADMIN,
self::STATUS_WAITING_FOR_ANSWER_AIKEN,
self::STATUS_WAITING_FOR_ANSWER_SALES,
self::STATUS_WAITING_FOR_ANSWER_PARTNER,
self::STATUS_WAITING_FOR_ANSWER_DATA,
self::STATUS_PROCESSABLE,
self::STATUS_CANCELED,
];
}
if ($userRight === User::PERMISSION_ORDER_STATUS_PRODUCTION) {
return [
self::STATUS_PROCESSABLE,
self::STATUS_PROCESSING,
self::STATUS_WAITING_FOR_ANSWER_SALES,
self::STATUS_WAITING_FOR_ANSWER_STOCK,
self::STATUS_WAITING_FOR_ANSWER_SERVICE,
self::STATUS_WAITING_FOR_ANSWER_ADMIN,
self::STATUS_WAITING_FOR_ANSWER_AIKEN,
self::STATUS_WAITING_FOR_ANSWER_PARTS,
self::STATUS_WAITING_FOR_ANSWER_PARTNER,
self::STATUS_WAITING_FOR_ANSWER_DATA,
self::STATUS_READY_TO_SHIP,
self::STATUS_READY_TO_PACK,
self::STATUS_CANCELED,
self::STATUS_FINISHED
];
}
return [];
// if ($userRight === User::PERMISSION_ORDER_STATUS_SALES &&
// !in_array($from, [
// self::STATUS_TRIAGE,
// self::STATUS_RESERVED,
// self::STATUS_WAITING_FOR_PAYMENT,
// self::STATUS_WAITING_FOR_PARTNER,
// self::STATUS_WAITING_FOR_PRODUCTION_SALES,
// self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE,
// self::STATUS_WAITING_FOR_PRODUCTION_AIKEN,
// self::STATUS_WAITING_FOR_PRODUCTION_DATA,
// self::STATUS_READY_TO_PACK,
// self::STATUS_WAITING_FOR_ANSWER_ADMIN,
// self::STATUS_WAITING_FOR_ANSWER_AIKEN,
// self::STATUS_PROCESSABLE,
// self::STATUS_CANCELED,
// ])
// ) {
// return [];
// }
//
// if ($userRight === User::PERMISSION_ORDER_STATUS_PRODUCTION &&
// !in_array($from, [
// self::STATUS_PROCESSABLE,
// self::STATUS_PROCESSING,
// self::STATUS_WAITING_FOR_ANSWER_SALES,
// self::STATUS_WAITING_FOR_ANSWER_STOCK,
// self::STATUS_WAITING_FOR_ANSWER_SERVICE,
// self::STATUS_WAITING_FOR_ANSWER_ADMIN,
// self::STATUS_WAITING_FOR_ANSWER_AIKEN,
// self::STATUS_WAITING_FOR_ANSWER_PARTS,
// self::STATUS_READY_TO_SHIP,
// self::STATUS_READY_TO_PACK,
// self::STATUS_CANCELED,
// self::STATUS_FINISHED
// ])
// ) {
// return [];
// }
//
// return match ($from) {
// self::STATUS_TRIAGE => [
// self::STATUS_TRIAGE,
// self::STATUS_RESERVED,
// self::STATUS_WAITING_FOR_PAYMENT,
// self::STATUS_PROCESSABLE,
// self::STATUS_CANCELED,
// ],
// self::STATUS_RESERVED => [
// self::STATUS_RESERVED,
// self::STATUS_WAITING_FOR_PAYMENT,
// self::STATUS_PROCESSABLE,
// self::STATUS_CANCELED,
// ],
//
// self::STATUS_WAITING_FOR_PARTNER => [
// self::STATUS_WAITING_FOR_PARTNER,
// self::STATUS_RESERVED,
// self::STATUS_WAITING_FOR_PAYMENT,
// self::STATUS_WAITING_FOR_PRODUCTION_SALES,
// self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE,
// self::STATUS_WAITING_FOR_PRODUCTION_AIKEN,
// self::STATUS_WAITING_FOR_PRODUCTION_DATA,
// self::STATUS_PROCESSABLE,
// self::STATUS_CANCELED,
// ],
// self::STATUS_WAITING_FOR_PRODUCTION_SALES => [
// self::STATUS_WAITING_FOR_PRODUCTION_SALES,
// self::STATUS_RESERVED,
// self::STATUS_WAITING_FOR_PAYMENT,
// self::STATUS_WAITING_FOR_PARTNER,
// self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE,
// self::STATUS_WAITING_FOR_PRODUCTION_AIKEN,
// self::STATUS_WAITING_FOR_PRODUCTION_DATA,
// self::STATUS_PROCESSABLE,
// self::STATUS_CANCELED,
// ],
//
// self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE => [
// self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE,
// self::STATUS_RESERVED,
// self::STATUS_WAITING_FOR_PAYMENT,
// self::STATUS_WAITING_FOR_PARTNER,
// self::STATUS_WAITING_FOR_PRODUCTION_SALES,
// self::STATUS_WAITING_FOR_PRODUCTION_AIKEN,
// self::STATUS_WAITING_FOR_PRODUCTION_DATA,
// self::STATUS_PROCESSABLE,
// self::STATUS_CANCELED,
// ],
// self::STATUS_WAITING_FOR_PRODUCTION_AIKEN => [
// self::STATUS_WAITING_FOR_PRODUCTION_AIKEN,
// self::STATUS_WAITING_FOR_PRODUCTION_DATA,
// self::STATUS_RESERVED,
// self::STATUS_WAITING_FOR_PAYMENT,
// self::STATUS_WAITING_FOR_PARTNER,
// self::STATUS_WAITING_FOR_PRODUCTION_SALES,
// self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE,
// self::STATUS_PROCESSABLE,
// self::STATUS_CANCELED,
// ],
// self::STATUS_WAITING_FOR_PRODUCTION_DATA => [
// self::STATUS_WAITING_FOR_PRODUCTION_AIKEN,
// self::STATUS_WAITING_FOR_PRODUCTION_DATA,
// self::STATUS_RESERVED,
// self::STATUS_WAITING_FOR_PAYMENT,
// self::STATUS_WAITING_FOR_PARTNER,
// self::STATUS_WAITING_FOR_PRODUCTION_SALES,
// self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE,
// self::STATUS_PROCESSABLE,
// self::STATUS_CANCELED,
// ],
// self::STATUS_WAITING_FOR_PAYMENT => [
// self::STATUS_WAITING_FOR_PAYMENT,
// self::STATUS_PROCESSABLE,
// self::STATUS_WAITING_FOR_PRODUCTION_SALES,
// self::STATUS_WAITING_FOR_PARTNER,
// self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE,
// self::STATUS_WAITING_FOR_PRODUCTION_AIKEN,
// self::STATUS_WAITING_FOR_PRODUCTION_DATA,
// self::STATUS_RESERVED,
// self::STATUS_CANCELED,
// ],
//
// self::STATUS_WAITING_FOR_ANSWER_SALES => [
// self::STATUS_WAITING_FOR_ANSWER_SALES,
// self::STATUS_PROCESSABLE,
// self::STATUS_PROCESSING,
// self::STATUS_WAITING_FOR_ANSWER_STOCK,
// self::STATUS_WAITING_FOR_ANSWER_SERVICE,
// self::STATUS_WAITING_FOR_ANSWER_ADMIN,
// self::STATUS_WAITING_FOR_ANSWER_AIKEN,
// self::STATUS_WAITING_FOR_ANSWER_PARTS,
// self::STATUS_READY_TO_PACK,
// self::STATUS_CANCELED,
// ],
// self::STATUS_WAITING_FOR_ANSWER_STOCK => [
// self::STATUS_WAITING_FOR_ANSWER_STOCK,
// self::STATUS_PROCESSABLE,
// self::STATUS_PROCESSING,
// self::STATUS_WAITING_FOR_ANSWER_SALES,
// self::STATUS_WAITING_FOR_ANSWER_SERVICE,
// self::STATUS_WAITING_FOR_ANSWER_ADMIN,
// self::STATUS_WAITING_FOR_ANSWER_AIKEN,
// self::STATUS_WAITING_FOR_ANSWER_PARTS,
// self::STATUS_READY_TO_PACK,
// self::STATUS_CANCELED,
// ],
// self::STATUS_WAITING_FOR_ANSWER_SERVICE => [
// self::STATUS_WAITING_FOR_ANSWER_SERVICE,
// self::STATUS_PROCESSABLE,
// self::STATUS_PROCESSING,
// self::STATUS_WAITING_FOR_ANSWER_SALES,
// self::STATUS_WAITING_FOR_ANSWER_STOCK,
// self::STATUS_WAITING_FOR_ANSWER_ADMIN,
// self::STATUS_WAITING_FOR_ANSWER_AIKEN,
// self::STATUS_WAITING_FOR_ANSWER_PARTS,
// self::STATUS_READY_TO_PACK,
// self::STATUS_CANCELED,
// ],
// self::STATUS_WAITING_FOR_ANSWER_ADMIN => [
// self::STATUS_PROCESSABLE,
// self::STATUS_PROCESSING,
// self::STATUS_WAITING_FOR_ANSWER_ADMIN,
// self::STATUS_WAITING_FOR_ANSWER_AIKEN,
// self::STATUS_WAITING_FOR_ANSWER_SALES,
// self::STATUS_WAITING_FOR_ANSWER_STOCK,
// self::STATUS_WAITING_FOR_ANSWER_SERVICE,
// self::STATUS_WAITING_FOR_ANSWER_PARTS,
// self::STATUS_READY_TO_PACK,
// self::STATUS_CANCELED,
// ],
// self::STATUS_WAITING_FOR_ANSWER_AIKEN => [
// self::STATUS_PROCESSABLE,
// self::STATUS_PROCESSING,
// self::STATUS_WAITING_FOR_ANSWER_ADMIN,
// self::STATUS_WAITING_FOR_ANSWER_AIKEN,
// self::STATUS_WAITING_FOR_ANSWER_SALES,
// self::STATUS_WAITING_FOR_ANSWER_STOCK,
// self::STATUS_WAITING_FOR_ANSWER_SERVICE,
// self::STATUS_WAITING_FOR_ANSWER_PARTS,
// self::STATUS_READY_TO_PACK,
// self::STATUS_CANCELED,
// ],
// self::STATUS_WAITING_FOR_ANSWER_PARTS => [
// self::STATUS_WAITING_FOR_ANSWER_PARTS,
// self::STATUS_PROCESSABLE,
// self::STATUS_PROCESSING,
// self::STATUS_WAITING_FOR_ANSWER_SALES,
// self::STATUS_WAITING_FOR_ANSWER_STOCK,
// self::STATUS_WAITING_FOR_ANSWER_SERVICE,
// self::STATUS_WAITING_FOR_ANSWER_ADMIN,
// self::STATUS_WAITING_FOR_ANSWER_AIKEN,
// self::STATUS_READY_TO_PACK,
// self::STATUS_CANCELED,
// ],
// self::STATUS_PROCESSABLE => [
// self::STATUS_PROCESSABLE,
// self::STATUS_PROCESSING,
// self::STATUS_WAITING_FOR_ANSWER_SALES,
// self::STATUS_WAITING_FOR_ANSWER_STOCK,
// self::STATUS_WAITING_FOR_ANSWER_SERVICE,
// self::STATUS_WAITING_FOR_ANSWER_ADMIN,
// self::STATUS_WAITING_FOR_ANSWER_AIKEN,
// self::STATUS_CANCELED,
// ],
// self::STATUS_PROCESSING => [
// self::STATUS_PROCESSING,
// self::STATUS_WAITING_FOR_ANSWER_SALES,
// self::STATUS_WAITING_FOR_ANSWER_STOCK,
// self::STATUS_WAITING_FOR_ANSWER_SERVICE,
// self::STATUS_WAITING_FOR_ANSWER_ADMIN,
// self::STATUS_WAITING_FOR_ANSWER_AIKEN,
// self::STATUS_WAITING_FOR_ANSWER_PARTS,
// self::STATUS_READY_TO_PACK,
// self::STATUS_CANCELED,
// ],
// self::STATUS_READY_TO_PACK => [
// self::STATUS_READY_TO_PACK,
// self::STATUS_READY_TO_SHIP,
// self::STATUS_PROCESSING,
// self::STATUS_CANCELED,
// ],
//
// self::STATUS_READY_TO_SHIP => [
// self::STATUS_READY_TO_SHIP,
// self::STATUS_READY_TO_PACK,
// self::STATUS_FINISHED,
// self::STATUS_CANCELED,
// ],
// default => [self::STATUS_CANCELED],
// };
}
public static function getWaitingForStatusIndexes(): array
{
return [
self::STATUS_WAITING_FOR_ANSWER_SALES,
self::STATUS_WAITING_FOR_ANSWER_STOCK,
self::STATUS_WAITING_FOR_ANSWER_SERVICE,
self::STATUS_WAITING_FOR_ANSWER_ADMIN,
self::STATUS_WAITING_FOR_ANSWER_AIKEN,
self::STATUS_WAITING_FOR_ANSWER_PARTS,
self::STATUS_WAITING_FOR_ANSWER_PARTNER,
self::STATUS_WAITING_FOR_ANSWER_DATA,
];
}
public static function getWaitingForStatusForFilter(): array
{
return [
self::STATUS_WAITING_FOR_ANSWER_SALES => 'Sales',
self::STATUS_WAITING_FOR_ANSWER_STOCK => 'Stock',
self::STATUS_WAITING_FOR_ANSWER_SERVICE => 'Service',
self::STATUS_WAITING_FOR_ANSWER_ADMIN => 'Admin',
self::STATUS_WAITING_FOR_ANSWER_PARTS => 'Parts',
self::STATUS_WAITING_FOR_ANSWER_AIKEN => 'Aiken',
self::STATUS_WAITING_FOR_ANSWER_PARTNER => 'Partner',
self::STATUS_WAITING_FOR_ANSWER_DATA => 'Data',
];
}
public static function getWaitingForProductionStatusIndexes(): array
{
return [
self::STATUS_WAITING_FOR_PARTNER,
self::STATUS_WAITING_FOR_PRODUCTION_SALES,
self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE,
self::STATUS_WAITING_FOR_PRODUCTION_AIKEN,
self::STATUS_WAITING_FOR_PRODUCTION_DATA
];
}
public static function getWaitingForProductionStatusForFilter(): array
{
return [
self::STATUS_WAITING_FOR_PRODUCTION_SALES => 'Sales',
self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE => 'Quarantine',
self::STATUS_WAITING_FOR_PRODUCTION_AIKEN => 'Aiken'
];
}
public static function getPreProcessingIssueStatusForFilter(): array
{
return [
self::STATUS_WAITING_FOR_PARTNER => 'Partner',
self::STATUS_WAITING_FOR_PRODUCTION_SALES => 'Sales',
self::STATUS_WAITING_FOR_PRODUCTION_QUARANTINE => 'Quarantine',
self::STATUS_WAITING_FOR_PRODUCTION_AIKEN => 'Aiken',
self::STATUS_WAITING_FOR_PRODUCTION_DATA => 'Data',
];
}
/**
* @param null $currentStatus
* @param bool $isAtechPartnerChildOrder
* @param int|null $customerId
* @return array
*/
public static function getAvailableStatusChoices(
$currentStatus = null,
$isAtechPartnerChildOrder = false,
?int $customerId = null
): array
{
$statusChoices = self::getStatusChoices();
if (is_null($currentStatus)) { // new order
$availableStatuses = [
self::STATUS_TRIAGE => $statusChoices[self::STATUS_TRIAGE],
];
} else { // edit order
if ($isAtechPartnerChildOrder) {
if ($currentStatus == Order::STATUS_PICKUP_POINT) {
$availableStatuses = [
// edit from finished
self::STATUS_WAITING => $statusChoices[self::STATUS_PICKUP_POINT],
];
} else {
$availableStatuses = [
// edit from finished
$currentStatus => $statusChoices[$currentStatus],
];
}
} else {
if ($currentStatus < self::STATUS_FINISHED) { // edit below finished
$availableStatuses = $statusChoices;
} else {
$availableStatuses = [
// edit from finished
self::STATUS_FINISHED => $statusChoices[self::STATUS_FINISHED],
];
if (!is_null($customerId) && $customerId == Customer::AMAZON_ID) {
$availableStatuses[self::STATUS_CANCELED] = $statusChoices[self::STATUS_CANCELED];
}
}
}
}
return $availableStatuses;
}
/**
* @return array
*/
public static function getParcelStatusChoices(): array
{
return [
self::PARCEL_STATUS_UNAVAILABLE => 'Unavailable',
self::PARCEL_STATUS_DATA_COLLECTED => 'Data collected',
self::PARCEL_STATUS_ARRIVAL_IN_DEPOT => 'Arrival in depot',
self::PARCEL_STATUS_IN_DELIVERY => 'In delivery',
self::PARCEL_STATUS_DELIVERED => 'Delivered',
self::PARCEL_STATUS_DATA_RECEIVED => 'Data received',
self::PARCEL_STATUS_COD_DATA_RECEIVED => 'COD data received',
self::PARCEL_STATUS_PACKAGE_PICKED_UP => 'Package picked up',
];
}
/**
* @return array
*/
public static function getCreatedByTypeChoices(): array
{
return [
self::CreatedByType_Customer,
self::CreatedByType_User,
self::CreatedByType_Import,
];
}
/**
* @return array
*/
public static function getWarrantyChoices(): array
{
return [
self::WARRANTY_NO => 'No warranty',
self::WARRANTY_30_DAYS => '30 days',
self::WARRANTY_6_MONTHS => '6 months',
self::WARRANTY_1_YEAR => '1 year',
self::WARRANTY_2_YEAR => '2 year',
self::WARRANTY_3_YEAR => '3 year',
self::WARRANTY_4_YEAR => '4 year',
self::WARRANTY_5_YEAR => '5 year',
];
}
/**
* @return array
*/
public static function getExternalOrderSourceChoices(): array
{
return [
self::EXTERNAL_ORDER_SOURCE_BACKMARKET => 'BackMarket',
self::EXTERNAL_ORDER_SOURCE_BACKMARKET_PRO => 'BackMarket PRO',
self::EXTERNAL_ORDER_SOURCE_REFURBED => 'refurbed',
self::EXTERNAL_ORDER_SOURCE_AMAZON => 'Amazon',
self::EXTERNAL_ORDER_SOURCE_EMAG => 'eMag',
self::EXTERNAL_ORDER_SOURCE_FNAC => 'Fnac',
self::EXTERNAL_ORDER_SOURCE_CDISCOUNT => 'Cdiscount',
self::EXTERNAL_ORDER_SOURCE_RAKUTEN => 'Rakuten',
self::EXTERNAL_ORDER_SOURCE_KAUFLAND => 'Kaufland',
self::EXTERNAL_ORDER_SOURCE_EBAY => 'eBay',
self::EXTERNAL_ORDER_SOURCE_ALLEGRO => 'Allegro',
self::EXTERNAL_ORDER_SOURCE_RICONDIZIONATO => 'Ricondizionato',
self::EXTERNAL_ORDER_SOURCE_AUKRO => 'Aukro',
self::EXTERNAL_ORDER_SOURCE_UNAS => 'Unas',
self::EXTERNAL_ORDER_SOURCE_MEDIAMARKT => 'MediaMarkt',
self::EXTERNAL_ORDER_SOURCE_PCCOMPONENTES => 'PcComponentes',
];
}
/**
* @return string[]
*/
public static function getMarketplaces(): array
{
return [
self::EXTERNAL_ORDER_SOURCE_BACKMARKET => 'Backmarket',
self::EXTERNAL_ORDER_SOURCE_REFURBED => 'Refurbed',
self::EXTERNAL_ORDER_SOURCE_AMAZON => 'Amazon',
self::EXTERNAL_ORDER_SOURCE_EMAG => 'Emag',
self::EXTERNAL_ORDER_SOURCE_FNAC => 'FNAC',
self::EXTERNAL_ORDER_SOURCE_CDISCOUNT => 'Cdiscount',
self::EXTERNAL_ORDER_SOURCE_RAKUTEN => 'Rakuten',
self::EXTERNAL_ORDER_SOURCE_KAUFLAND => 'Kaufland',
self::EXTERNAL_ORDER_SOURCE_EBAY => 'Ebay',
self::EXTERNAL_ORDER_SOURCE_ALLEGRO => 'Allegro',
self::EXTERNAL_ORDER_SOURCE_RICONDIZIONATO => 'Ricondizionato',
self::EXTERNAL_ORDER_SOURCE_BACKMARKET_PRO => 'Backmarket Pro',
self::EXTERNAL_ORDER_SOURCE_AUKRO => 'Aukro',
self::EXTERNAL_ORDER_SOURCE_UNAS => 'Unas',
self::EXTERNAL_ORDER_SOURCE_MEDIAMARKT => 'MediaMarkt',
self::EXTERNAL_ORDER_SOURCE_PCCOMPONENTES => 'PcComponentes',
];
}
/**
* @param string $code
* @param int $source
* @return bool
*/
public static function isExternalOrderCodeValidForSource(string $code, int $source): bool
{
$valid = true;
if ($code) {
switch ($source) {
case self::EXTERNAL_ORDER_SOURCE_BACKMARKET:
$valid = preg_match('/^\d{8}$/', $code);
break;
case self::EXTERNAL_ORDER_SOURCE_REFURBED:
$valid = preg_match('/^\d{7}$/', $code) || preg_match('/^\d{8}$/', $code);
break;
case self::EXTERNAL_ORDER_SOURCE_AMAZON:
$valid = preg_match('/^\d{3}-\d{7}-\d{7}$/', $code);
break;
case self::EXTERNAL_ORDER_SOURCE_EMAG:
case self::EXTERNAL_ORDER_SOURCE_FNAC:
case self::EXTERNAL_ORDER_SOURCE_CDISCOUNT:
case self::EXTERNAL_ORDER_SOURCE_RAKUTEN:
default:
break;
}
}
return $valid;
}
/**
* @var Domain
*
* @ManyToOne(targetEntity="Domain", inversedBy="orders")
* @JoinColumn(name="domain_id", referencedColumnName="id")
*/
private $domain;
/**
* @var Customer
*
* @ManyToOne(targetEntity="Customer", inversedBy="orders")
* @JoinColumn(name="customer_id", referencedColumnName="id")
*/
private $customer;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="status", type="string", length=16)
*/
private $status;
public const string PaymentStatus_Pending = 'Pending';
public const string PaymentStatus_Paid = 'Paid';
public const string PaymentStatus_Failed = 'Failed';
public const string PaymentStatus_OverPaid = 'Over paid';
public const string PaymentStatus_Partial = 'Partial';
public const string PaymentStatus_Commission = 'Commission';
public const int PAYMENT_STATUS_ID_PENDING = 0;
public const int PAYMENT_STATUS_ID_PAID = 1;
public const int PAYMENT_STATUS_ID_FAILED = 2;
public const int PAYMENT_STATUS_ID_OVERLOAD = 3;
public const int PAYMENT_STATUS_ID_PARTIAL = 4;
public const int PAYMENT_STATUS_ID_COMMISSION = 5;
/**
* @return string[]
*/
public static function getPaymentStatusChoices(): array
{
return [
self::PAYMENT_STATUS_ID_PENDING => self::PaymentStatus_Pending,
self::PAYMENT_STATUS_ID_PAID => self::PaymentStatus_Paid,
self::PAYMENT_STATUS_ID_FAILED => self::PaymentStatus_Failed,
self::PAYMENT_STATUS_ID_OVERLOAD => self::PaymentStatus_OverPaid,
self::PAYMENT_STATUS_ID_PARTIAL => self::PaymentStatus_Partial,
self::PAYMENT_STATUS_ID_COMMISSION => self::PaymentStatus_Commission,
];
}
/**
* @var int
*
* @Column(name="payment_status", type="integer")
*/
private $paymentStatus;
/**
* @var string
*
* @Column(name="invoice_code", type="string", length=16, nullable=true)
*/
private $invoiceCode;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="payment_type", type="string", length=16)
*/
private $paymentType;
/**
* @var int
*
* @Column(name="payment_price", type="decimal", precision=10, scale=2, nullable=true)
*/
private $paymentPrice;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="shipping_type", type="string", length=16)
*/
private $shippingType;
/**
* @var int
*
* @Column(name="shipping_price", type="decimal", precision=10, scale=2, nullable=true)
*/
private $shippingPrice;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="billing_first_name", type="string", length=64)
*/
private $billingFirstName;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="billing_last_name", type="string", length=64)
*/
private $billingLastName;
/**
* @var string
*
* @Column(name="billing_business_name", type="string", length=128, nullable=true)
*/
private $billingBusinessName = null;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="billing_street", type="string", length=128)
*/
private $billingStreet;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="billing_city", type="string", length=64)
*/
private $billingCity;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="billing_zip", type="string", length=12)
*/
private $billingZip;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="billing_country", type="string", length=32)
*/
private $billingCountry;
/**
* @var string
*
* @Column(name="billing_business_id", type="string", length=16, nullable=true)
*/
private $billingBusinessId = null;
/**
* @var string
*
* @Column(name="billing_tax_id", type="string", length=16, nullable=true)
*/
private $billingTaxId = null;
/**
* @var string
*
* @Column(name="billing_vat_id", type="string", length=16, nullable=true)
*/
private $billingVatId = null;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="billing_email", type="string", length=64)
*/
private $billingEmail;
/**
* @var string
*
* @Assert\NotNull
*
* @Column(name="billing_phone_number", type="string", length=32)
*/
private $billingPhone;
/**
* @var string
*
* @Column(name="shipping_first_name", type="string", length=64, nullable=true)
*/
private $shippingFirstName;
/**
* @var string
*
* @Column(name="shipping_last_name", type="string", length=64, nullable=true)
*/
private $shippingLastName;
/**
* @var string
*
* @Column(name="shipping_business_name", type="string", length=128, nullable=true)
*/
private $shippingBusinessName = null;
/**
* @var string
*
* @Column(name="shipping_street", type="string", length=128, nullable=true)
*/
private $shippingStreet;
/**
* @var string
*
* @Column(name="shipping_city", type="string", length=64, nullable=true)
*/
private $shippingCity;
/**
* @var string
*
* @Column(name="shipping_zip", type="string", length=12, nullable=true)
*/
private $shippingZip;
/**
* @var string
*
* @Column(name="shipping_country", type="string", length=32, nullable=true)
*/
private $shippingCountry;
/**
* @var string
*
* @Column(name="shipping_email", type="string", length=64, nullable=true)
*/
private $shippingEmail;
/**
* @var string
*
* @Column(name="shipping_phone_number", type="string", length=32, nullable=true)
*/
private $shippingPhone;
/**
* @var string
*
* @Column(name="message", type="text", nullable=true)
*/
private $message;
/**
* @var string
*
* @Column(name="coupon_code", type="string", length=255, nullable=true)
*/
private $couponCode;
/**
* @var \DateTime
*
* @Column(name="ship_date", type="datetime", nullable=true)
*/
private $shipDate;
/**
* @var \DateTime|null
*
* @Column(name="planned_ship_date", type="datetime", nullable=true)
*/
private $plannedShipDate;
/**
* @var \DateTime
*
* @Column(name="delivery_date", type="datetime", nullable=true)
*/
private $deliveryDate;
/**
* @return array
*/
public static function getBoxCountChoices(): array
{
$choices = [];
for ($x = 0; $x <= 60; $x++) {
$choices[$x] = $x;
}
return $choices;
}
/**
* @var int
*
* @Column(name="box_count", type="integer")
*/
private $boxCount = 1;
/**
* @var bool
*
* @Column(name="useBillingAddressAsShippingAddress", type="boolean")
*/
private $useBillingAddressAsShippingAddress = true;
/**
* @var float
*
* @Column(name="full_price", type="decimal", precision=10, scale=2)
*/
private $fullPrice = 0;
/**
* @var string
*
* @Column(name="presta_order_code", type="string", length=24, nullable=true)
*/
private $prestaOrderCode;
/**
* @var int|null
*
* @Column(name="external_order_source", type="integer", nullable=true)
*/
private $externalOrderSource;
/**
* @var string|null
*
* @Column(name="external_order_code", type="string", length=32, nullable=true)
*/
private $externalOrderCode;
/**
* @var bool
*
* @Column(name="message_done", type="boolean")
*/
private $messageDone = false;
/**
* @var User
*
* @ManyToOne(targetEntity="User")
* @JoinColumn(name="message_done_by", referencedColumnName="id", nullable=true)
*/
private $messageDoneBy;
/**
* @var \DateTime
*
* @Column(name="message_done_time", type="datetime", nullable=true)
*/
private $messageDoneTime;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CustomerBillingoData", mappedBy="order", orphanRemoval=true)
* @OrderBy({"created" = "DESC"})
**/
private $billingoDocuments;
/**
* @var bool
*
* @Column(name="force_free_shipping", type="boolean")
*/
private $forceFreeShipping = false;
/**
* @var int
*
* @Column(name="warranty", type="integer", nullable=true)
*/
private $warranty;
/**
* @var int
*
* @Column(name="created_by_type", type="integer")
*/
private $createdByType = 0;
/**
* @var bool
*
* @Column(name="archived", type="boolean")
*/
private $archived = false;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="OrderItem", mappedBy="order", orphanRemoval=true)
* @OrderBy({"created" = "ASC", "id" = "ASC"})
**/
private $orderItems;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="Document", mappedBy="order", orphanRemoval=true)
* @OrderBy({"created" = "DESC"})
**/
private $documents;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="StockMovement", mappedBy="order", orphanRemoval=true)
* @OrderBy({"created" = "DESC"})
**/
private $stockMovements;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="StockMovement", mappedBy="orderConfigChange", orphanRemoval=true)
* @OrderBy({"created" = "DESC"})
**/
private $configChangeStockMovements;
/**
* @var int
*
* @Column(name="discount", type="integer")
**/
private $discount = 0;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="OrderComment", mappedBy="order", orphanRemoval=true)
* @OrderBy({"type"="ASC","created" = "DESC"})
**/
private $comments;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="OrderSetting", mappedBy="order", orphanRemoval=true)
* @OrderBy({"created" = "DESC"})
**/
private $settings;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="OrderPackage", mappedBy="order", orphanRemoval=true)
* @OrderBy({"created" = "ASC"})
**/
private $packages;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="Claim", mappedBy="order", orphanRemoval=true)
* @OrderBy({"created" = "ASC"})
**/
private $claims;
/**
* @var string
*
* @Column(name="tracking_url", type="string", nullable=true)
*/
private $trackingUrl;
/**
* @var string
*
* @Column(name="parcelNumber", type="string", length=256, nullable=true)
*/
private $parcelNumber;
/**
* @var string
*
* @Column(name="dhlShipmentNumber", type="string", length=256, nullable=true)
*/
private $dhlShipmentNumber;
/**
* @var int
*
* @Column(name="parcelStatus", type="integer", nullable=true)
*/
private $parcelStatus;
/**
* @var bool
*
* @Column(name="priority", type="boolean")
*/
private $priority = false;
/**
* @var int|null
*
* @Column(name="base_order_id", type="integer", nullable=true)
*/
private $baseOrderId = null;
/**
* @var float|null
*
* @Column(name="vat", type="decimal", precision=10, scale=2, nullable=true)
*/
private $vat = null;
public function __construct()
{
parent::__construct();
$this->orderItems = new ArrayCollection();
$this->orderChangelog = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->stockMovements = new ArrayCollection();
$this->configChangeStockMovements = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->settings = new ArrayCollection();
$this->packages = new ArrayCollection();
$this->claims = new ArrayCollection();
}
/**
* @return Domain
*/
public function getDomain()
{
return $this->domain;
}
/**
* @param Domain $domain
*/
public function setDomain($domain)
{
$this->domain = $domain;
}
/**
* @return Customer
*/
public function getCustomer()
{
return $this->customer;
}
/**
* @param Customer $customer
*/
public function setCustomer($customer)
{
$this->customer = $customer;
}
/**
* @return string
*/
public function getStatus()
{
return $this->status;
}
/**
* @param string $status
*/
public function setStatus($status)
{
$this->status = $status;
}
/**
* @return int
*/
public function getPaymentStatus()
{
return $this->paymentStatus;
}
/**
* @param int $paymentStatus
*/
public function setPaymentStatus($paymentStatus)
{
$this->paymentStatus = $paymentStatus;
}
/**
* @return string
*/
public function getPaymentType()
{
return $this->paymentType;
}
/**
* @param string $paymentType
*/
public function setPaymentType($paymentType)
{
$this->paymentType = $paymentType;
}
/**
* Returns the title of current payment type, or null if not set
*
* @param TranslatorInterface|null $translator
* @return mixed
*/
public function getPaymentTypeTitle(?TranslatorInterface $translator = null)
{
if ($this->paymentType != null) {
$paymentTypes = PaymentType::getChoices();
return is_null($translator) ? $paymentTypes[$this->paymentType] : $translator->trans(
$paymentTypes[$this->paymentType]
);
} else {
return null;
}
}
/**
* @return string
*/
public function getShippingType()
{
return $this->shippingType;
}
/**
* @param string $shippingType
*/
public function setShippingType($shippingType)
{
$this->shippingType = $shippingType;
}
/**
* Returns the title of current shipping type, or null if not set
*
* @param TranslatorInterface|null $translator
* @return mixed
*/
public function getShippingTypeTitle(?TranslatorInterface $translator = null)
{
if ($this->shippingType != null) {
$shippingTypes = DomainShippingType::getShippingTypeChoices();
return is_null($translator) ? $shippingTypes[$this->shippingType] : $translator->trans(
$shippingTypes[$this->shippingType]
);
} else {
return null;
}
}
/**
* @return string
*/
public function getBillingPhone()
{
return $this->billingPhone;
}
/**
* @param string $billingPhone
*/
public function setBillingPhone($billingPhone)
{
$this->billingPhone = $billingPhone;
}
/**
* @return string
*/
public function getBillingCountry()
{
return $this->billingCountry;
}
/**
* @param string $billingCountry
*/
public function setBillingCountry($billingCountry)
{
$this->billingCountry = $billingCountry;
}
/**
* @return string
*/
public function getBillingCity()
{
return $this->billingCity;
}
/**
* @param string $billingCity
*/
public function setBillingCity($billingCity)
{
$this->billingCity = $billingCity;
}
/**
* @return string
*/
public function getShippingPhone()
{
return $this->shippingPhone;
}
/**
* @param string $shippingPhone
*/
public function setShippingPhone($shippingPhone)
{
$this->shippingPhone = $shippingPhone;
}
/**
* @return string
*/
public function getShippingEmail()
{
return $this->shippingEmail;
}
/**
* @param string $shippingEmail
*/
public function setShippingEmail($shippingEmail)
{
$this->shippingEmail = $shippingEmail;
}
/**
* @return string
*/
public function getShippingCountry()
{
return $this->shippingCountry;
}
/**
* @param string $shippingCountry
*/
public function setShippingCountry($shippingCountry)
{
$this->shippingCountry = $shippingCountry;
}
/**
* @return string
*/
public function getShippingCity()
{
return $this->shippingCity;
}
/**
* @param string $shippingCity
*/
public function setShippingCity($shippingCity)
{
$this->shippingCity = $shippingCity;
}
/**
* @return string
*/
public function getInvoiceCode()
{
return $this->invoiceCode;
}
/**
* @param string $invoiceCode
*/
public function setInvoiceCode($invoiceCode)
{
$this->invoiceCode = $invoiceCode;
}
/**
* @return string
*/
public function getBillingFirstName()
{
return $this->billingFirstName;
}
/**
* @param string $billingFirstName
*/
public function setBillingFirstName($billingFirstName)
{
$this->billingFirstName = ucfirst($billingFirstName);
}
/**
* @return string
*/
public function getBillingLastName()
{
return $this->billingLastName;
}
/**
* @param string $billingLastName
*/
public function setBillingLastName($billingLastName)
{
$this->billingLastName = ucfirst($billingLastName);
}
/**
* @return string
*/
public function getBillingBusinessName()
{
return $this->billingBusinessName;
}
/**
* @param string $billingBusinessName
*/
public function setBillingBusinessName($billingBusinessName)
{
$this->billingBusinessName = $billingBusinessName;
}
/**
* @return string
*/
public function getBillingStreet()
{
return $this->billingStreet;
}
/**
* @param string $billingStreet
*/
public function setBillingStreet($billingStreet)
{
$this->billingStreet = $billingStreet;
}
/**
* @return string
*/
public function getBillingZip()
{
return $this->billingZip;
}
/**
* @param string $billingZip
*/
public function setBillingZip($billingZip)
{
$this->billingZip = preg_replace('/^[A-Z]{2}[-,\s]+/', '', (string) $billingZip);
}
/**
* @return string
*/
public function getBillingBusinessId()
{
return $this->billingBusinessId;
}
/**
* @param string $billingBusinessId
*/
public function setBillingBusinessId($billingBusinessId)
{
$this->billingBusinessId = $billingBusinessId;
}
/**
* @return string
*/
public function getBillingTaxId()
{
return $this->billingTaxId;
}
/**
* @param string $billingTaxId
*/
public function setBillingTaxId($billingTaxId)
{
$this->billingTaxId = $billingTaxId;
}
/**
* @return string
*/
public function getBillingVatId()
{
return $this->billingVatId;
}
/**
* @param string $billingVatId
*/
public function setBillingVatId($billingVatId)
{
$this->billingVatId = $billingVatId;
}
/**
* @return string
*/
public function getBillingEmail()
{
return $this->billingEmail;
}
/**
* @param string $billingEmail
*/
public function setBillingEmail($billingEmail)
{
$this->billingEmail = $billingEmail;
}
/**
* @return string
*/
public function getShippingFirstName()
{
return $this->shippingFirstName;
}
/**
* @param string $shippingFirstName
*/
public function setShippingFirstName($shippingFirstName)
{
$this->shippingFirstName = ucfirst($shippingFirstName);
}
/**
* @return string
*/
public function getShippingLastName()
{
return $this->shippingLastName;
}
/**
* @param string $shippingLastName
*/
public function setShippingLastName($shippingLastName)
{
$this->shippingLastName = ucfirst($shippingLastName);
}
/**
* @return string
*/
public function getShippingBusinessName()
{
return $this->shippingBusinessName;
}
/**
* @param string $shippingBusinessName
*/
public function setShippingBusinessName($shippingBusinessName)
{
$this->shippingBusinessName = $shippingBusinessName;
}
/**
* @return string
*/
public function getShippingStreet()
{
return $this->shippingStreet;
}
/**
* @param string $shippingStreet
*/
public function setShippingStreet($shippingStreet)
{
$this->shippingStreet = $shippingStreet;
}
/**
* @return string
*/
public function getShippingZip()
{
return $this->shippingZip;
}
/**
* @param string $shippingZip
*/
public function setShippingZip($shippingZip)
{
$this->shippingZip = preg_replace('/^[A-Z]{2}[-,\s]+/', '', (string) $shippingZip);
}
public function hasProblematicShippingAddress(): bool
{
$fields = array_filter([
$this->shippingFirstName,
$this->shippingLastName,
$this->shippingBusinessName,
$this->shippingStreet,
$this->shippingCity,
]);
$combined = implode(' ', $fields);
if (preg_match('/[°@&#€%\(\)\[\]{}<>ר]/u', $combined)) {
return true;
}
$wordPatterns = [
'/\bajtó\b/iu',
'/\bszoba\b/iu',
'/\bGmbH\b/i',
'/\bC\.o\.?\b/i',
'/\bKft\.?/i',
'/\bs\.r\.o\.?/i',
];
foreach ($wordPatterns as $pattern) {
if (preg_match($pattern, $combined)) {
return true;
}
}
return false;
}
/**
* @return int
*/
public function getBoxCount()
{
return $this->boxCount;
}
/**
* @param int $boxCount
*/
public function setBoxCount($boxCount)
{
$this->boxCount = $boxCount;
}
/**
* @return string
*/
public function getMessage()
{
return $this->message;
}
/**
* @param string $message
*/
public function setMessage($message)
{
$this->message = $message;
}
/**
* @return string
*/
public function getCouponCode()
{
return $this->couponCode;
}
/**
* @param string $couponCode
*/
public function setCouponCode($couponCode)
{
$this->couponCode = $couponCode;
}
/**
* @return boolean
*/
public function useBillingAddressAsShippingAddress()
{
return $this->useBillingAddressAsShippingAddress;
}
/**
* @param boolean $useBillingAddressAsShippingAddress
*/
public function setUseBillingAddressAsShippingAddress($useBillingAddressAsShippingAddress)
{
$this->useBillingAddressAsShippingAddress = $useBillingAddressAsShippingAddress;
}
/**
* @return ArrayCollection
*/
public function getOrderItems()
{
return $this->orderItems;
}
/**
* @param ArrayCollection $orderItems
*/
public function setOrderItems($orderItems)
{
if ($this->orderItems === $orderItems) {
return;
}
// orderItems is a OneToMany with orphanRemoval=true: reassigning the property outright
// de-references Doctrine's tracked collection, which schedules a bulk DELETE of everything
// it held (even already-persisted, still-valid items). Mutate the existing collection instead.
$this->orderItems->clear();
foreach ($orderItems as $orderItem) {
$this->orderItems->add($orderItem);
}
}
/**
* @return ArrayCollection
*/
public function getDocuments()
{
return $this->documents;
}
/**
* @return ArrayCollection
*/
public function getStockMovements()
{
return $this->stockMovements;
}
/**
* @return void
*/
public function reMakeArrayCollectionsForOrder()
{
$this->orderItems = new ArrayCollection();
$this->orderChangelog = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->stockMovements = new ArrayCollection();
$this->configChangeStockMovements = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->settings = new ArrayCollection();
$this->packages = new ArrayCollection();
$this->claims = new ArrayCollection();
}
public function getClaims()
{
return $this->claims;
}
/**
* @return void
*/
public function emptyStockMovements()
{
$this->stockMovements = new ArrayCollection();
}
/**
* @return StockMovement|null
*/
public function getLastStockMovement()
{
return $this->getStockMovements()->count() > 0 ? $this->getStockMovements()->first() : null;
}
/**
* Get order weight in kg
*
* @return int
*/
public function getFullWeight()
{
$itemsWeight = 0;
/**
* @var OrderItem $orderItem
*/
foreach ($this->orderItems as $orderItem) {
$itemsWeight = $itemsWeight + (($orderItem->getProduct()->getWeight() * $orderItem->getQuantity()) / 1000);
}
return $itemsWeight;
}
/**
* @return mixed
*/
public function getPaymentPrice()
{
return $this->paymentPrice;
}
/**
* @param mixed $paymentPrice
*/
public function setPaymentPrice($paymentPrice)
{
$this->paymentPrice = $paymentPrice;
}
/**
* @return int
*/
public function getShippingPrice()
{
return $this->shippingPrice;
}
/**
* @param int $shippingPrice
*/
public function setShippingPrice($shippingPrice)
{
$this->shippingPrice = $shippingPrice;
}
public function getSubTotal()
{
$fullPrice = 0;
/** @var OrderItem $orderItem */
foreach ($this->getOrderItems() as $orderItem) {
if ($orderItem->getParent() == null) { // Skip container children
$fullPrice += $orderItem->getItemFullPrice();
}
}
return $fullPrice;
}
/**
* Returns the quantity of products in the whole order
*
* TODO tz update
* @return int
*/
public function getAllItemQuantity()
{
$fullQuantity = 0;
foreach ($this->orderItems as $orderItem) {
$fullQuantity += $orderItem->getQuantity();
}
return $fullQuantity;
}
/**
* Set fullPrice from subtotal, payment price and shipping price
* Triggered on every persist and update of any Order entity
*
* @internal param float $fullPrice
*/
public function setFullPrice()
{
$fullPrice = $this->getSubTotal();
$fullPrice = $fullPrice + $this->getPaymentPrice() + $this->getShippingPrice();
$this->fullPrice = round($fullPrice, 2);
}
/**
* Return the full price of order with shipping and payment price in domains currency
*
* @return float
*/
public function getFullPrice()
{
if (in_array($this->domain->getId(), [Domain::DOMAIN_ID_RT_HU, Domain::DOMAIN_ID_WS_HU])
&& $this->getVat() == 0
&& $this->fullPrice % 10 != 0) {
return ceil($this->fullPrice / 10) * 10;
}
return $this->fullPrice;
}
/**
* @return float
*/
public function getVat(): float
{
if($this->vat !== null) {
return (float) $this->vat;
}
$dateStr = $this->getCreated()->format('YmdHi');
$vatId = 'not set';
if (!is_null($this->customer) && $this->customer->getId() == Customer::MAXMEDIA_KFT_ID) {
return 27;
}
//NOTE UNASOS ORDEREKNAL ROSSZUL VOLT ERTELMEZVE, NEM TUDTUK HOGY HA A X DOMAINEN RENDEL Y ORSZAGBA AKKOR NEM X DOMAIN VATJAT SZOLJA HANEM Y ORSZAGET
if ($this->getUnasOrderDomainSetting() && $dateStr < (new \DateTime('2026-03-17 16:30'))->format('YmdHi')) {
return Unas::getVatPercentageByLanguage($this->getUnasOrderDomainSetting()->getValue()) * 100;
}
if ($this->isRefurbedCH()) {
return 8.1;
}
if ($this->getCreated()->format('Ymd') < VAT::OSS_VAT_SWITCH_DATE) {
if ($this->getBillingVatId() != null) {
$vatId = $this->getBillingVatId();
} elseif ($this->customer->getVatId() != null) {
$vatId = $this->customer->getVatId();
}
if (!is_null($this->getDomain())) {
return $this->customer->useZeroVat($vatId, $dateStr) ? 0 : $this->getDomain()->getVat($dateStr);
} else {
return $this->customer->useZeroVat($vatId, $dateStr) ? 0 : $this->getCustomer()->getDomain()->getVat(
$dateStr
);
}
} else {
$euPersonalTaxId = null;
if (!is_null($this->getEuPersonalTaxIdSetting())) {
$euPersonalTaxId = $this->getEuPersonalTaxIdSetting()->getValue();
}
if (is_null($euPersonalTaxId)) {
if (!is_null($this->getBillingTaxId())) {
$euPersonalTaxId = $this->getBillingTaxId();
}
}
return VAT::getVatByCustomerData(
$this->getCustomer()->useZeroVat($this->getBillingVatId(), $dateStr),
$this->getBillingCountry(),
$this->getBillingBusinessId(),
$this->getShippingCountry(),
$this->getCreated(),
$euPersonalTaxId
);
}
}
/**
* Returns the amount of money tax, from the full price of order
*
* @return float
*/
public function getTaxOutOfFullPrice()
{
$fullPrice = $this->getFullPrice();
$taxPercentage = $this->getVat();
return ($fullPrice / (100 + $taxPercentage)) * $taxPercentage;
}
/**
* Returns title of current payment type
*
* @return mixed
*/
public function getPaymentTitle()
{
return PaymentType::from($this->paymentType)->getDisplayName();
}
/**
* Returns title of current payment status type
*
* @return mixed
*/
public function getPaymentStatusTitle()
{
$choices = $this->getPaymentStatusChoices();
return $choices[$this->paymentStatus];
}
/**
* Returns title of current shipping type
*
* @return mixed
*/
public function getShippingTitle()
{
$choices = DomainShippingType::getShippingTypeChoices();
return $choices[$this->shippingType] ?? '';
}
/**
* @param $parcel
* @return void
*/
public function setShippingTypeByCarrier($parcel): void
{
switch ($parcel) {
case OrderPackage::CARRIER_FEDEX_AIR:
case OrderPackage::CARRIER_DHL_AIR:
$this->shippingType = DomainShippingType::SHIPPING_TYPE_CARRIER_EXPRESS_ID;
break;
case OrderPackage::CARRIER_GLS:
case OrderPackage::CARRIER_PBH:
case OrderPackage::CARRIER_DHL_AT:
case OrderPackage::CARRIER_FEDEX_ROAD:
case OrderPackage::CARRIER_DHL_ROAD:
$this->shippingType = DomainShippingType::ShippingType_Carrier_Id;
break;
case OrderPackage::CARRIER_PACKETA:
$this->shippingType = DomainShippingType::SHIPPING_TYPE_PACKETA_PICKUP_POINT_ID;
break;
}
}
/**
* Returns title of current status
*
* @param TranslatorInterface|null $translator
* @return mixed
*/
public function getStatusTitle(?TranslatorInterface $translator = null)
{
return Order::statusToTitle($this->status, $translator);
}
public static function statusToTitle($status, ?TranslatorInterface $translator = null)
{
$choices = Order::getStatusChoicesOldAndNew();
if ($translator != null) {
return $translator->trans($choices[$status]);
}
return $choices[$status];
}
/**
* @return boolean
*/
public function isMessageDone()
{
return $this->messageDone;
}
/**
* @param boolean $messageDone
*/
public function setMessageDone($messageDone)
{
$this->messageDone = $messageDone;
}
/**
* @return int
*/
public function getCreatedByType()
{
return $this->createdByType;
}
/**
* @param int $createdByType
*/
public function setCreatedByType($createdByType)
{
$this->createdByType = $createdByType;
}
/**
* @return boolean
*/
public function isArchived()
{
return $this->archived;
}
/**
* @param boolean $archived
*/
public function setArchived($archived)
{
$this->archived = $archived;
}
/**
* @return \DateTime
*/
public function getShipDate()
{
return $this->shipDate;
}
/**
* @param \DateTime $shipDate
*/
public function setShipDate($shipDate)
{
if (is_null($this->shipDate)) {
$this->shipDate = $shipDate;
}
}
/**
* Returns all stock items of this order
* @return ArrayCollection
*/
public function getStockItems()
{
$stockItems = new ArrayCollection();
if (!is_null($this->getLastStockMovement())) {
$stockItems = $this->getLastStockMovement()->getStockItems();
}
return $stockItems;
}
/**
* 1 = less, 2 = OK, 3 = more
*
* @return int|null
*/
public function isAllStockItemsAdded()
{
return !is_null($this->getLastStockMovement()) ? $this->getLastStockMovement()->isAllStockItemsAdded() : 1;
}
public function isShippableToday()
{
return (new \DateTime()) > $this->plannedShipDate;
}
public function isUsingPlannedShipDate()
{
return $this->shippingType == DomainShippingType::getShippingTypeId(DomainShippingType::ShippingType_Carrier)
|| $this->shippingType == DomainShippingType::getShippingTypeId(DomainShippingType::ShippingType_EU_BY_US)
|| $this->shippingType == DomainShippingType::getShippingTypeId(
DomainShippingType::ShippingType_EU_BY_CUSTOMER
);
}
/**
* @return int
*/
public function getDiscount()
{
return $this->discount;
}
/**
* @param $discount
*/
public function setDiscount($discount)
{
$this->discount = $discount;
}
/**
* @return ArrayCollection
*/
public function getBillingoDocuments()
{
return $this->billingoDocuments;
}
/**
* @return string
*/
public function getPrestaOrderCode()
{
return $this->prestaOrderCode;
}
/**
* @param string $prestaOrderCode
*/
public function setPrestaOrderCode($prestaOrderCode)
{
$this->prestaOrderCode = $prestaOrderCode;
}
/**
* @return \Doctrine\Common\Collections\ArrayCollection
*/
public function getComments()
{
return $this->comments;
}
/**
* @param \Doctrine\Common\Collections\ArrayCollection $comments
*/
public function setComments($comments)
{
$this->comments = $comments;
}
// public function getOrderChangelog(): array
// {
// $em = $this->registry->getManager('statistics');
// return $em->getRepository(OrderChangelog::class)
// ->findBy(
// [
// 'orderId' => $this->getId()
// ]
// );
// }
// /**
// * @param int $orderStatus
// * @param bool $showFirst
// * @return mixed
// */
// public function getOrderChangelogByStatus(int $orderStatus, bool $showFirst = false): mixed
// {
// $em = $this->registry->getManager('statistics');
// $changeLogs = $em->getRepository(OrderChangelog::class)
// ->findBy(
// [
// 'orderId' => $this->getId(),
// 'status' => $this->getStatus()
// ], [
// 'created' => $showFirst ? 'ASC' : 'DESC'
// ]
// );
//
// return $changeLogs[0];
// }
/**
* @param \Doctrine\Common\Collections\ArrayCollection $orderChangelog
*/
public function setOrderChangelog($orderChangelog)
{
$this->orderChangelog = $orderChangelog;
}
/**
* @return \DateTime
*/
public function getPlannedShipDate()
{
return $this->plannedShipDate;
}
/**
* @param \DateTime|null $plannedShipDate
*/
public function setPlannedShipDate(?\DateTime $plannedShipDate)
{
$this->plannedShipDate = $plannedShipDate;
}
/**
* @return \DateTime
*/
public function getDeliveryDate()
{
return $this->deliveryDate;
}
/**
* @param \DateTime $deliveryDate
*/
public function setDeliveryDate($deliveryDate)
{
$this->deliveryDate = $deliveryDate;
}
/**
* @return string
*/
public function getTrackingUrl()
{
return $this->trackingUrl;
}
/**
* @param string $trackingUrl
*/
public function setTrackingUrl($trackingUrl)
{
$this->trackingUrl = $trackingUrl;
}
/**
* @return string
*/
public function getParcelNumber()
{
return $this->parcelNumber;
}
/**
* @param string $parcelNumber
*/
public function setParcelNumber($parcelNumber)
{
$this->parcelNumber = $parcelNumber;
}
/**
* @return string
*/
public function getParcelStatus()
{
return $this->parcelStatus;
}
/**
* @param string $parcelStatus
*/
public function setParcelStatus($parcelStatus)
{
$this->parcelStatus = $parcelStatus;
}
/**
* @return boolean
*/
public function isForceFreeShipping()
{
return $this->forceFreeShipping;
}
/**
* @param boolean $forceFreeShipping
*/
public function setForceFreeShipping($forceFreeShipping)
{
$this->forceFreeShipping = $forceFreeShipping;
}
/**
* @return int
*/
public function getWarranty()
{
return $this->warranty;
}
/**
* @param int $warranty
*/
public function setWarranty($warranty)
{
return $this->warranty = $warranty;
}
/**
* Get end of warranty
*
* @param \DateTime|null $warrantyStart
* @return \DateTime
*/
public function getWarrantyEnd(?\DateTime $warrantyStart = null): \DateTime
{
if (is_null($warrantyStart)) {
$warrantyStart = $this->getCreated();
}
if (is_null($this->warranty)) {
return (clone $warrantyStart)->add(new \DateInterval('P2Y'));
}
switch ($this->warranty) {
case self::WARRANTY_NO:
return (clone $warrantyStart);
case self::WARRANTY_30_DAYS:
return (clone $warrantyStart)->add(new \DateInterval('P30D'));
case self::WARRANTY_1_YEAR:
return (clone $warrantyStart)->add(new \DateInterval('P1Y'));
case self::WARRANTY_2_YEAR:
return (clone $warrantyStart)->add(new \DateInterval('P2Y'));
case self::WARRANTY_3_YEAR:
return (clone $warrantyStart)->add(new \DateInterval('P3Y'));
case self::WARRANTY_4_YEAR:
return (clone $warrantyStart)->add(new \DateInterval('P4Y'));
case self::WARRANTY_5_YEAR:
return (clone $warrantyStart)->add(new \DateInterval('P5Y'));
}
}
/**
* @return OrderSetting|null
*/
public function getKlarnaOrderIdSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_KLARNA_ORDER_ID);
}
/**
* @return OrderSetting|null
*/
public function getCnCountSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_CN_COUNT);
}
/**
* @return string|null
*/
public function getFedexTrackingNumber(): ?string
{
return $this->getMultipleSettings(OrderSetting::TYPE_FEDEX_TRACKING_NUMBER);
}
/**
* @return string|null
*/
public function getClaimFedexShipmentNumber(): ?string
{
return $this->getSetting(OrderSetting::TYPE_CLAIM_FEDEX_TRACKING_NUMBER)?->getValue();
}
/**
* @return string|null
*/
public function getClaimImportFedexShipmentNumber(): ?string
{
return $this->getSetting(OrderSetting::TYPE_CLAIM_IMPORT_FEDEX_TRACKING_NUMBER)?->getValue();
}
public function isFedexAddressVerified(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_FEDEX_ADDRESS_VERIFIED);
}
/**
* @return ArrayCollection
*/
public function getSettings()
{
return $this->settings;
}
public function getCetelemCodeSetting()
{
return $this->getSetting(OrderSetting::TYPE_CETELEM_CODE);
}
public function getDepositSetting()
{
return $this->getSetting(OrderSetting::TYPE_DEPOSIT);
}
public function getLabelPrintedSetting()
{
return $this->getSetting(OrderSetting::TYPE_LABEL_PRINTED);
}
public function getPickupPointSetting()
{
return $this->getSetting(OrderSetting::TYPE_PICKUP_POINT_ID);
}
public function getParentOrderIdSetting()
{
return $this->getSetting(OrderSetting::TYPE_PARENT_ORDER_ID);
}
public function getChildOrderIdSetting()
{
return $this->getSetting(OrderSetting::TYPE_CHILD_ORDER_ID);
}
public function getPickupPointPartnerNotifiedSetting()
{
return $this->getSetting(OrderSetting::TYPE_PICKUP_POINT_PARTNER_NOTIFIED);
}
public function getSimplePayTransactionIdSetting()
{
return $this->getSetting(OrderSetting::TYPE_SIMPLEPAY_PAYMENT_ID);
}
public function getSimplePayOrderRefSetting()
{
return $this->getSetting(OrderSetting::TYPE_SIMPLEPAY_PAYMENT_ORDER_REF);
}
public function getGoPayTransactionIdSetting()
{
return $this->getSetting(OrderSetting::TYPE_GOPAY_PAYMENT_ID);
}
public function getCouponCodeSetting()
{
return $this->getSetting(OrderSetting::TYPE_COUPON_CODE);
}
public function getUpsellStatSetting()
{
return $this->getSetting(OrderSetting::TYPE_UPSELL_STATS);
}
public function getShippingNotificationSetting()
{
return $this->getSetting(OrderSetting::TYPE_SHIPPING_NOTIFICATION);
}
public function getPaidPriceByCardSetting()
{
return $this->getSetting(OrderSetting::TYPE_PAID_PRICE_BY_CARD);
}
public function getChosenCarrierSetting()
{
return $this->getSetting(OrderSetting::TYPE_CHOSEN_CARRIER_ID);
}
public function getDoneSetting()
{
return $this->getSetting(OrderSetting::TYPE_DONE);
}
public function getOrderConfirmedSetting()
{
return $this->getSetting(OrderSetting::TYPE_ORDER_CONFIRMED);
}
public function getBillingoInvoiceNoteSetting()
{
return $this->getSetting(OrderSetting::TYPE_BILLINGO_NOTE);
}
public function getPacketaBranchIdSetting()
{
return $this->getSetting(OrderSetting::TYPE_PACKETA_BRANCH_ID);
}
public function getPacketaBranchNameSetting()
{
return $this->getSetting(OrderSetting::TYPE_PACKETA_BRANCH_NAME);
}
public function getPacketaCarrierIdSetting()
{
return $this->getSetting(OrderSetting::TYPE_PACKETA_CARRIER_ID);
}
/**
* @return OrderSetting|null
*/
public function getEuPersonalTaxIdSetting(): ?OrderSetting
{
$orderSetting = $this->getSetting(OrderSetting::TYPE_EU_PERSONAL_TAX_ID);
if ($orderSetting) {
if (trim($orderSetting->getValue()) == 'NIF') {
return null;
}
}
return $orderSetting;
}
/**
* @return OrderSetting|null
*/
public function getClonedOrderSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_CLONED_ORDER);
}
/**
* @return OrderSetting|null
*/
public function getFinishedByMarketplaceAPISetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_FINISHED_BY_MARKETPLACE_API);
}
/**
* @return OrderSetting|null
*/
public function getInstacashApplicationIdSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_INSTACASH_APPLICATION_ID);
}
/**
* @return OrderSetting|null
*/
public function getInstacashApplicationStatusSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_INSTACASH_APPLICATION_STATUS);
}
/**
* @return array
*/
public function getInstacashPaymentSettings(): array
{
return $this->getOrderSettings(OrderSetting::TYPE_INSTACASH_PAYMENT);
}
/**
* @return OrderSetting|null
*/
public function getMilpayApplicationIdSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_MILPAY_APPLICATION_ID);
}
/**
* @return OrderSetting|null
*/
public function getMilpayApplicationStatusSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_MILPAY_APPLICATION_STATUS);
}
/**
* @return array
*/
public function getMilpayPaymentSettings(): array
{
return $this->getOrderSettings(OrderSetting::TYPE_MILPAY_PAYMENT);;
}
/**
* @return array
*/
public function getPastPayPaymentSettings(): array
{
return $this->getOrderSettings(OrderSetting::TYPE_PAST_PAY_RESERVE);
}
/**
* @return array
*/
public function getPastPayFinalizedSettings(): array
{
return $this->getOrderSettings(OrderSetting::TYPE_PAST_PAY_FINALIZED);
}
/**
* @return array
*/
public function getPastPayCanceledSettings(): array
{
return $this->getOrderSettings(OrderSetting::TYPE_PAST_PAY_RESERVATION_CANCELED);
}
/**
* @return OrderSetting|null
*/
public function getDisableInvoiceCreationSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_DISABLE_INVOICE_CREATION);
}
/**
* @return OrderSetting|null
*/
public function getPBHTrackingNumberSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_TRACKING_NUMBER_FROM_PBH);
}
/**
* @return OrderSetting|null
*/
public function getIsCanceledAtMarketplaceSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_CANCELED_ORDER);
}
/**
* @return OrderSetting|null
*/
public function getPriceByMarketplaceApiSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_PRICE_BY_MARKETPLACE_API);
}
/**
* @return OrderSetting|null
*/
public function getSaveAnywayInfoSettings(): ?array
{
return $this->getOrderSettings(OrderSetting::TYPE_FORCE_SAVING_USER);
}
/**
* @return OrderSetting|null
*/
public function getPaypalTransactionIdSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_PAYPAL_TRANSACTION_ID);
}
/**
* @return OrderSetting|null
*/
public function getKlarnaPaymentSessionIdSetting(bool $getOriginal = true): ?OrderSetting
{
$settings = [];
foreach ($this->settings as $setting) {
if ($setting->getType() == OrderSetting::TYPE_KLARNA_PAYMENT_SESSION_ID) {
$settings[] = $setting;
}
}
usort($settings, function ($a, $b) {
return $a->getCreated() > $b->getCreated();
});
return $settings[$getOriginal ? 0 : count($settings) - 1] ?? null;
}
public function getAllKlarnaPaymentSessionIdSettings(): array
{
$settings = [];
foreach ($this->settings as $setting) {
if ($setting->getType() == OrderSetting::TYPE_KLARNA_PAYMENT_SESSION_ID) {
$settings[] = $setting;
}
}
return $settings;
}
/**
* @return OrderSetting|null
*
*/
public function getRequiredQualityCheckSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_REQUIRED_QUALITY_CHECK);
}
public function getSalesRiskSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_SALES_RISK);
}
public function getQualityMayVarySetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_QUALITY_MAY_VARY);
}
public function getUnasOrderDomainSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_UNAS_ORDER_DOMAIN);
}
public function getUnasCustomerIsRegisteredSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_UNAS_USER_IS_REGISTERED);
}
public function getStripeIdSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_STRIPE_ID);
}
public function getAlternativeV2ProductSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_ALTERNATIVE_V2_PRODUCT);
}
public function getLaseredProductsSetting(): ?OrderSetting
{
return $this->getSetting(OrderSetting::TYPE_LASERED_PRODUCTS);
}
private function getSetting($settingCode)
{
foreach ($this->settings as $setting) {
if ($setting->getType() == $settingCode) {
return $setting;
}
}
return null;
}
private function getMultipleSettings($settingCode)
{
$result = [];
foreach ($this->settings as $setting) {
if ($setting->getType() == $settingCode) {
$result[] = $setting->getValue();
}
}
if (count($result)) {
return join(', ', $result);
}
return null;
}
/**
* @param int $settingCode
* @return array
*/
private function getOrderSettings(int $settingCode): array
{
$settings = [];
foreach ($this->settings as $setting) {
if ($setting->getType() == $settingCode) {
$settings[] = $setting;
}
}
return $settings;
}
public function isClonedOrder()
{
return !is_null($this->getSetting(OrderSetting::TYPE_CLONED_ORDER));
}
/**
* @return User
*/
public function getMessageDoneBy()
{
return $this->messageDoneBy;
}
/**
* @param User $messageDoneBy
*/
public function setMessageDoneBy($messageDoneBy)
{
$this->messageDoneBy = $messageDoneBy;
}
/**
* @return \DateTime
*/
public function getMessageDoneTime()
{
return $this->messageDoneTime;
}
/**
* @param \DateTime $messageDoneTime
*/
public function setMessageDoneTime($messageDoneTime)
{
$this->messageDoneTime = $messageDoneTime;
}
/**
* @return bool
*/
public function hasTimedSale()
{
$hasTimedSale = false;
foreach ($this->getOrderItems() as $item) {
if ($hasTimedSale) {
continue;
}
$hasTimedSale = $item->isFromTimedSale();
}
return $hasTimedSale;
}
/**
* @return int
*/
public function getExternalOrderSource(): ?int
{
return $this->externalOrderSource;
}
/**
* @param int $externalOrderSource
*/
public function setExternalOrderSource($externalOrderSource): Order
{
$this->externalOrderSource = $externalOrderSource;
return $this;
}
/**
* @return string
*/
public function getExternalOrderCode()
{
return $this->externalOrderCode;
}
/**
* @param string $externalOrderCode
*/
public function setExternalOrderCode($externalOrderCode)
{
$this->externalOrderCode = $externalOrderCode;
}
/**
* @return ArrayCollection
*/
public function getPackages()
{
return $this->packages;
}
public function removeAllPackages()
{
$this->packages = new ArrayCollection();
}
/**
* @return ArrayCollection
*/
public function setPackages($packages)
{
$this->packages = $packages;
}
public function hasPackageLabels(): bool
{
$parcelIds = array_map(fn(OrderPackage $p) => $p->getParcelId(), $this->packages->toArray());
return array_filter($parcelIds) !== [];
}
/**
* @return string
*/
public function getDhlShipmentNumber()
{
return $this->dhlShipmentNumber;
}
/**
* @param string $dhlShipmentNumber
*/
public function setDhlShipmentNumber($dhlShipmentNumber)
{
$this->dhlShipmentNumber = $dhlShipmentNumber;
}
/**
* @return bool
*/
public function hasStockItemsForWorkbench(): bool
{
$availableProductTypes = [44, 52, 60, 90, 116]; // Monitor, Notebook, PC, Tablet, All in one
foreach ($this->getOrderItems() as $orderItem) {
if (in_array($orderItem->getProduct()->getType()->getId(), $availableProductTypes)) {
if ($orderItem->getStockMovementItem() && $orderItem->getStockMovementItem()->getItems()->count() > 0) {
return true;
}
}
}
return false;
}
/**
* @return string|null
*/
public function getShippingTime(): ?string
{
$settings = $this->settings;
if (count($settings) > 0) {
foreach ($settings as $key => $setting) {
if ($setting->getType() == OrderSetting::TYPE_SHIPPING_DATETIME) {
return $setting->getValue();
}
}
}
return null;
}
/**
* @return bool
*/
public function isPriority(): bool
{
return $this->priority;
}
/**
* @param bool $priority
*/
public function setPriority(bool $priority)
{
$this->priority = $priority;
}
/**
* @return bool
*/
public function isConfirmed(): bool
{
$orderSetting = $this->getOrderConfirmedSetting();
if (!is_null($orderSetting)) {
return true;
}
return false;
}
/**
* @return int
*/
public function getChosenCarrierId(): int
{
if ($this->getChosenCarrierSetting()) {
return $this->getChosenCarrierSetting()->getValue();
}
if (!in_array($this->getShippingType(), [
DomainShippingType::ShippingType_Carrier_Id,
DomainShippingType::SHIPPING_TYPE_CARRIER_EXPRESS_ID,
DomainShippingType::SHIPPING_TYPE_PACKETA_PICKUP_POINT_ID,
DomainShippingType::SHIPPING_TYPE_PACKETA_PICKUP_POINT_ID,
])) {
return 0;
}
if (in_array($this->getShippingType(), [
DomainShippingType::SHIPPING_TYPE_PACKETA_PICKUP_POINT_ID, DomainShippingType::SHIPPING_TYPE_PACKETA_PICKUP_POINT_ID
])) {
return OrderPackage::CARRIER_PACKETA;
} else {
if ($this->getDomain()->getId() == Domain::DOMAIN_ID_B2C_EU) {
return OrderPackage::CARRIER_DHL_AIR;
} else {
return OrderPackage::CARRIER_GLS;
}
}
}
/**
* @return string
*/
public function getChosenCarrierTitle(): string
{
$carrierId = $this->getChosenCarrierId();
if ( $carrierId == 0 || !isset(OrderPackage::getCarrierChoices()[$carrierId]) ) {
return '';
}
return OrderPackage::getCarrierChoices()[$carrierId];
}
/**
* @return string
*/
public function getChosenCarrierNormalizedName(): string
{
$carrierId = $this->getChosenCarrierId();
if ($carrierId == 0) {
return '';
}
return OrderPackage::getFinalizingFormatCarrierName()[$carrierId];
}
/**
* @return bool
*/
public function isB2B(): bool
{
return $this->getCustomer()->isB2B();
}
public function getOrderConfigChangeMovementOut()
{
foreach ($this->getConfigChangeStockMovements() as $stockMovement) {
if ($stockMovement->getSubType() == StockMovement::SUB_TYPE_OUT_ORDER_CONFIG_CHANGE) {
return $stockMovement;
}
}
return null;
}
public function getOrderConfigChangeMovementIn()
{
foreach ($this->getConfigChangeStockMovements() as $stockMovement) {
if ($stockMovement->getSubType() == StockMovement::SUB_TYPE_IN_ORDER_CONFIG_CHANGE) {
return $stockMovement;
}
}
return null;
}
public function getOrderNeutralMovement()
{
foreach ($this->getStockMovements() as $stockMovement) {
if ($stockMovement->getType() == StockMovement::TYPE_NEUTRAL) {
return $stockMovement;
}
}
return null;
}
/**
* @return ArrayCollection
*/
public function getConfigChangeStockMovements()
{
return $this->configChangeStockMovements;
}
public function getPriorityContext(ManagerRegistry $registry): PriorityContext
{
$orderChangeLogService = new OrderChangeLogService();
$orderChangeLogService->setDoctrine($registry);
$firstProcessableStatus = $orderChangeLogService->getOrderChangelogByStatus($this, self::STATUS_PROCESSABLE, true);
$processableDate = $firstProcessableStatus ? $firstProcessableStatus->getCreated() : null;
return new PriorityContext(
$this->getDomain()->getId(),
$this->getCreated(),
$processableDate
);
}
/**
* @return int|null
*/
public function getBaseOrderId(): ?int
{
return $this->baseOrderId;
}
/**
* @param int $baseOrderId
*/
public function setBaseOrderId($baseOrderId)
{
$this->baseOrderId = $baseOrderId;
}
public function setVat(?float $vat): void
{
$this->vat = $vat;
}
/**
* @return string
*/
public function getMarketplace(): string
{
return self::getMarketplaces()[$this->externalOrderSource] ?? '';
}
public function isRefurbedCH()
{
return !is_null($this->getExternalOrderSource()) && $this->getExternalOrderSource() == self::EXTERNAL_ORDER_SOURCE_REFURBED && $this->getBillingCountry() == 'CH';
}
}