} | } | ||||
if ($orderShop->getOrderStatus()->getAlias() != $nextStatus) { | if ($orderShop->getOrderStatus()->getAlias() != $nextStatus) { | ||||
$orderShop = $this->changeOrderStatus($orderShop, $nextStatus); | |||||
$this->changeOrderStatus($orderShop, $nextStatus); | |||||
} | } | ||||
$this->entityManager->create($orderPayment); | $this->entityManager->create($orderPayment); | ||||
$orderShop->addOrderReductionCart($orderReductionCart); | $orderShop->addOrderReductionCart($orderReductionCart); | ||||
if ($this->orderShopStore->isPositiveAmount($orderShop) | |||||
&& $this->isPositiveAmountRemainingToBePaid($orderShop)) { | |||||
if ($this->orderShopResolver->isPositiveAmount($orderShop) | |||||
&& $this->orderShopResolver->isPositiveAmountRemainingToBePaid($orderShop)) { | |||||
$this->entityManager->create($orderReductionCart); | $this->entityManager->create($orderReductionCart); | ||||
$this->entityManager->flush(); | $this->entityManager->flush(); | ||||
if (!$userMerchant) { | if (!$userMerchant) { | ||||
$userMerchantFactory = new UserMerchantFactory(); | $userMerchantFactory = new UserMerchantFactory(); | ||||
$userMerchant = $userMerchantFactory->create($user, $merchant); | |||||
$userMerchant = $userMerchantFactory->create($merchant, $user); | |||||
$this->entityManager->create($userMerchant); | $this->entityManager->create($userMerchant); | ||||
$this->entityManager->flush(); | $this->entityManager->flush(); |
'isValid' => true | 'isValid' => true | ||||
] | ] | ||||
), | ), | ||||
'label' => 'field.default.order', | |||||
'label' => 'entity.default.fields.order', | |||||
'placeholder' => '-- Choisissez une commande --', | 'placeholder' => '-- Choisissez une commande --', | ||||
'required' => false, | 'required' => false, | ||||
'choice_label' => function ($orderShop, $key, $value) { | 'choice_label' => function ($orderShop, $key, $value) { | ||||
return 'Commande du ' . $orderShop->getValidationDate()->format( | |||||
'd/m/Y' | |||||
) . ' (' . number_format( | |||||
$this->priceSolver->getTotalWithTax($orderShop), | |||||
2 | |||||
) . ' €)'; | |||||
$dateString = '' ; | |||||
$dateObject = $orderShop->getValidationDate() ? $orderShop->getValidationDate() : $orderShop->getCreatedAt(); | |||||
if($orderShop->getValidationDate()) { | |||||
$dateString .= 'du '.$dateObject->format('d/m/Y').' ' ; | |||||
} | |||||
return 'Commande ' . $dateString . | |||||
'(' . number_format($this->priceSolver->getTotalWithTax($orderShop), 2) . | |||||
' €)'; | |||||
}, | }, | ||||
'translation_domain' => 'admin', | 'translation_domain' => 'admin', | ||||
] | ] |
$this->settingSolver = $settingSolver; | $this->settingSolver = $settingSolver; | ||||
} | } | ||||
public function buildReference(OrderShopInterface $orderShop, \DateTime $distributionDate = null): string | |||||
public function buildReference(OrderShopInterface $orderShop, \DateTimeInterface $distributionDate = null): string | |||||
{ | { | ||||
switch ($orderShop->getSection()->getCycleType()) { | switch ($orderShop->getSection()->getCycleType()) { | ||||
case SectionModel::CYCLE_TYPE_DAY: | case SectionModel::CYCLE_TYPE_DAY: | ||||
'C' . $this->numberPad($orderShop->getCycleId(), 3); | 'C' . $this->numberPad($orderShop->getCycleId(), 3); | ||||
} | } | ||||
public function buildReferenceCycleWeek(OrderShopInterface $orderShop, \DateTime $distributionDate): string | |||||
public function buildReferenceCycleWeek(OrderShopInterface $orderShop, \DateTimeInterface $distributionDate): string | |||||
{ | { | ||||
return $this->getPrefixReference($orderShop) . | return $this->getPrefixReference($orderShop) . | ||||
'S' . $distributionDate->format('W') . | 'S' . $distributionDate->format('W') . | ||||
'A' . $distributionDate->format('y'); | 'A' . $distributionDate->format('y'); | ||||
} | } | ||||
public function buildReferenceCycleMonth(OrderShopInterface $orderShop, \DateTime $distributionDate): string | |||||
{ | |||||
public function buildReferenceCycleMonth( | |||||
OrderShopInterface $orderShop, | |||||
\DateTimeInterface $distributionDate | |||||
): string { | |||||
return $this->getPrefixReference($orderShop) . | return $this->getPrefixReference($orderShop) . | ||||
'M' . $distributionDate->format('m') . | 'M' . $distributionDate->format('m') . | ||||
'C' . $this->numberPad($orderShop->getCycleId(), 4) . | 'C' . $this->numberPad($orderShop->getCycleId(), 4) . | ||||
'A' . $distributionDate->format('y'); | 'A' . $distributionDate->format('y'); | ||||
} | } | ||||
public function buildReferenceCycleYear(OrderShopInterface $orderShop, \DateTime $distributionDate): string | |||||
public function buildReferenceCycleYear(OrderShopInterface $orderShop, \DateTimeInterface $distributionDate): string | |||||
{ | { | ||||
return $this->getPrefixReference($orderShop) . | return $this->getPrefixReference($orderShop) . | ||||
'C' . $this->numberPad($orderShop->getCycleId(), 5) . | 'C' . $this->numberPad($orderShop->getCycleId(), 5) . | ||||
public function getPrefixReference(OrderShopInterface $orderShop): string | public function getPrefixReference(OrderShopInterface $orderShop): string | ||||
{ | { | ||||
return $this->settingSolver->getSettingValue($orderShop->getSection(), SectionSettingDefinition::SETTING_REFERENCE_PREFIX); | |||||
return ''.$this->settingSolver->getSettingValue( | |||||
$orderShop->getSection(), | |||||
SectionSettingDefinition::SETTING_REFERENCE_PREFIX | |||||
); | |||||
} | } | ||||
public function numberPad($number, $length): string | public function numberPad($number, $length): string |
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->orderBy('id'); | |||||
$query->orderBy('id', 'DESC'); | |||||
return $query; | return $query; | ||||
} | } | ||||
behaviorTaxRateChoices: | behaviorTaxRateChoices: | ||||
tax-excluded: TVA exclue | tax-excluded: TVA exclue | ||||
tax-included: Tva incluse | tax-included: Tva incluse | ||||
order: Commande | |||||
PointSale: | PointSale: | ||||
label: Point de vente | label: Point de vente |
return $this->merchantResolver->getCurrent(); | return $this->merchantResolver->getCurrent(); | ||||
} | } | ||||
public function getUserMerchantCurrent(): UserMerchantInterface | |||||
public function getUserMerchantCurrent(): ?UserMerchantInterface | |||||
{ | { | ||||
$this->merchantResolver->getUserMerchant(); | |||||
return $this->merchantResolver->getUserMerchant(); | |||||
} | } | ||||
public function getMerchantSetting(MerchantInterface $merchant, string $settingName): string | public function getMerchantSetting(MerchantInterface $merchant, string $settingName): string |