Bladeren bron

Merge branch 'develop' of https://forge.laclic.fr/Laclic/CaracoleBundle into develop

packProduct
Fabien Normand 3 jaren geleden
bovenliggende
commit
c66be5cd29
21 gewijzigde bestanden met toevoegingen van 252 en 167 verwijderingen
  1. +23
    -24
      Builder/Order/OrderShopBuilder.php
  2. +1
    -1
      Builder/User/UserMerchantBuilder.php
  3. +10
    -5
      Controller/ControllerTrait.php
  4. +1
    -1
      Controller/Order/CartController.php
  5. +22
    -22
      Controller/PointSale/PointSaleAdminController.php
  6. +17
    -17
      Controller/Product/ProductCategoryAdminController.php
  7. +3
    -3
      Controller/Section/SectionAdminController.php
  8. +51
    -46
      Controller/User/UserMerchantAdminController.php
  9. +2
    -0
      Factory/Order/OrderPaymentFactory.php
  10. +12
    -7
      Form/Ticket/TicketFormType.php
  11. +12
    -7
      Generator/OrderReferenceGenerator.php
  12. +2
    -1
      Model/Order/OrderReductionCartModel.php
  13. +1
    -4
      Model/Order/OrderShopInterface.php
  14. +1
    -6
      Model/Order/OrderShopModel.php
  15. +19
    -0
      Model/Section/SectionModel.php
  16. +9
    -0
      Repository/Order/OrderShopRepositoryQuery.php
  17. +23
    -12
      Repository/Order/OrderShopStore.php
  18. +11
    -0
      Resources/translations/admin.fr.yaml
  19. +6
    -0
      Solver/Order/OrderShopSolver.php
  20. +6
    -0
      Solver/Section/SectionSolver.php
  21. +20
    -11
      Twig/StoreTwigExtension.php

+ 23
- 24
Builder/Order/OrderShopBuilder.php Bestand weergeven

@@ -26,7 +26,6 @@ use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\Section\OpeningModel;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Model\Section\SectionModel;
use Lc\CaracoleBundle\Model\User\VisitorInterface;
@@ -35,7 +34,7 @@ use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\CaracoleBundle\Repository\Order\OrderStatusStore;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore;
use Lc\CaracoleBundle\Resolver\OpeningResolver;
use Lc\CaracoleBundle\Resolver\Price\PriceResolver;
use Lc\CaracoleBundle\Resolver\OrderShopResolver;
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\CaracoleBundle\Solver\Product\ProductSolver;
@@ -59,6 +58,7 @@ class OrderShopBuilder
protected FlashBagInterface $flashBag;
protected OpeningResolver $openingResolver;
protected ProductSolver $productSolver;
protected OrderShopResolver $orderShopResolver;

public function __construct(
EntityManagerInterface $entityManager,
@@ -73,7 +73,8 @@ class OrderShopBuilder
EventDispatcherInterface $eventDispatcher,
FlashBagInterface $flashBag,
OpeningResolver $openingResolver,
ProductSolver $productSolver
ProductSolver $productSolver,
OrderShopResolver $orderShopResolver
) {
$this->entityManager = $entityManager;
$this->orderShopStore = $orderShopStore;
@@ -88,6 +89,7 @@ class OrderShopBuilder
$this->flashBag = $flashBag;
$this->openingResolver = $openingResolver;
$this->productSolver = $productSolver;
$this->orderShopResolver = $orderShopResolver;
}

public function create(
@@ -95,7 +97,6 @@ class OrderShopBuilder
UserInterface $user = null,
VisitorInterface $visitor = null
): OrderShopInterface {

$orderShopFactory = new OrderShopFactory();
$orderShop = $orderShopFactory->create($section, $user, $visitor);

@@ -112,13 +113,9 @@ class OrderShopBuilder
UserInterface $user = null,
VisitorInterface $visitor = null
): OrderShopInterface {
$cart = $this->orderShopStore->getOneCartCurrent(
[
'section' => $section,
'user' => $user,
'visitor' => $visitor
]
);
$cart = $this->orderShopStore
->setSection($section)
->getOneCartCurrent($user, $visitor);

if (!$cart) {
$cart = $this->create($section, $user, $visitor);
@@ -132,7 +129,6 @@ class OrderShopBuilder
string $alias,
bool $forceByAdmin = false
): OrderShopInterface {

$orderStatus = $this->orderStatusStore->getOneByAlias($alias);

if ($orderStatus) {
@@ -313,14 +309,14 @@ class OrderShopBuilder

$orderShop->addOrderPayment($orderPayment);

if ($this->orderSh->isPaid($orderShop)) {
if ($this->orderShopResolver->isPaid($orderShop)) {
$nextStatus = OrderStatusModel::ALIAS_PAID;
} else {
$nextStatus = OrderStatusModel::ALIAS_PARTIAL_PAYMENT;
}

if ($orderShop->getOrderStatus()->getAlias() != $nextStatus) {
$orderShop = $this->changeOrderStatus($orderShop, $nextStatus);
$this->changeOrderStatus($orderShop, $nextStatus);
}

$this->entityManager->create($orderPayment);
@@ -360,11 +356,11 @@ class OrderShopBuilder
$cycleNumber = null;
$deliveryDate = $orderShop->getDeliveryDate();

switch ($orderShop->getSection()->getCycle()) {
case SectionModel::CYCLE_DAY:
switch ($orderShop->getSection()->getCycleType()) {
case SectionModel::CYCLE_TYPE_DAY:
$cycleNumber = $deliveryDate->format('z');
break;
case SectionModel::CYCLE_WEEK:
case SectionModel::CYCLE_TYPE_WEEK:
$cycleNumber = $deliveryDate->format('W');
break;
}
@@ -390,8 +386,8 @@ class OrderShopBuilder

$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->flush();

@@ -454,7 +450,7 @@ class OrderShopBuilder
break;
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY :

$oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited();
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($orderProduct->getProduct());
$newAvailability = $oldAvailability - $orderProduct->getQuantityOrder();

$productFamily = $orderProduct->getProduct()->getProductFamily();
@@ -465,7 +461,7 @@ class OrderShopBuilder

break;
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT :
$oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited();
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($orderProduct->getProduct());
$newAvailability = $oldAvailability - $orderProduct->getQuantityOrder();

$product = $orderProduct->getProduct();
@@ -483,7 +479,11 @@ class OrderShopBuilder
public function updatePriceByProductFamily(ProductFamilyInterface $productFamily)
{
// @TODO : faire la vérification isOpenSale depuis la méthode appelante
if (!$this->openingResolver->isOpenSale($productFamily->getSection(), null, OpeningResolver::OPENING_CONTEXT_BACKEND)) {
if (!$this->openingResolver->isOpenSale(
$productFamily->getSection(),
null,
OpeningResolver::OPENING_CONTEXT_BACKEND
)) {
$countOrderProductUpdated = 0;

foreach ($productFamily->getProducts() as $product) {
@@ -567,7 +567,7 @@ class OrderShopBuilder
}

// setDeliveryAddress
public function initDeliveryAddress(OrderShopInterface $orderShop, AddressInterface $address = null):void
public function initDeliveryAddress(OrderShopInterface $orderShop, AddressInterface $address = null): void
{
$orderShop->setDeliveryAddress($address);
$orderShop->setDeliveryInfos($address ? $address->getDeliveryInfos() : null);
@@ -595,5 +595,4 @@ class OrderShopBuilder
}



}

+ 1
- 1
Builder/User/UserMerchantBuilder.php Bestand weergeven

@@ -31,7 +31,7 @@ class UserMerchantBuilder

if (!$userMerchant) {
$userMerchantFactory = new UserMerchantFactory();
$userMerchant = $userMerchantFactory->create($user, $merchant);
$userMerchant = $userMerchantFactory->create($merchant, $user);

$this->entityManager->create($userMerchant);
$this->entityManager->flush();

+ 10
- 5
Controller/ControllerTrait.php Bestand weergeven

@@ -53,7 +53,7 @@ trait ControllerTrait
[
PriceSolver::class => PriceSolver::class,
MerchantResolver::class => MerchantResolver::class,
SectionResolver::class=> SectionResolver::class,
SectionResolver::class => SectionResolver::class,
OrderShopContainer::class => OrderShopContainer::class,
AddressContainer::class => AddressContainer::class,
TaxRateContainer::class => TaxRateContainer::class,
@@ -115,7 +115,10 @@ trait ControllerTrait

public function getUserMerchantCurrent(): UserMerchantInterface
{
return $this->getUserMerchantContainer()->getBuilder()->createIfNotExist($this->getUserCurrent(), $this->getMerchantCurrent());
return $this->getUserMerchantContainer()->getBuilder()->createIfNotExist(
$this->getUserCurrent(),
$this->getMerchantCurrent()
);
}

public function getMerchantUserCurrent(): MerchantInterface
@@ -130,9 +133,11 @@ trait ControllerTrait

public function getCartCurrent(): OrderShopInterface
{
return $this->getOrderShopContainer()->getStore()
->setSection($this->getSectionCurrent())
->getOneCartCurrent();
return $this->getOrderShopContainer()->getBuilder()->createIfNotExist(
$this->getSectionCurrent(),
$this->getUserCurrent(),
$this->getVisitorCurrent()
);
}

public function getPriceSolver(): PriceSolver

+ 1
- 1
Controller/Order/CartController.php Bestand weergeven

@@ -84,7 +84,7 @@ class CartController extends AbstractController
{
$entityManager = $this->getEntityManager();
$id = $request->get('id');
$orderReductionCart = $this->getOrderReductionCartContainer()->getStore()->getOneById((int)$id);
$orderReductionCart = $this->getOrderReductionCartContainer()->getStore()->getOneById((int) $id);
$orderShop = $this->getCartCurrent();

if ($orderReductionCart && $orderShop->getOrderReductionCarts() && $orderShop->getOrderReductionCarts(

+ 22
- 22
Controller/PointSale/PointSaleAdminController.php Bestand weergeven

@@ -3,6 +3,8 @@
namespace Lc\CaracoleBundle\Controller\PointSale;

use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer;
@@ -13,6 +15,7 @@ use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Field\ToggleField;

abstract class PointSaleAdminController extends AbstractAdminController
{
@@ -20,34 +23,31 @@ abstract class PointSaleAdminController extends AbstractAdminController

public function configureFields(string $pageName): iterable
{

return array_merge(
[
FormField::addPanel('general'),
TextField::new('title'),
NumberField::new('orderAmountMin')
->setCustomOption('appendHtml','€')
->hideOnIndex(),
NumberField::new('deliveryPrice')
->setCustomOption('appendHtml','€')
->hideOnIndex(),
BooleanField::new('isPublic'),
BooleanField::new('isDepository'),
StatusField::new('status')
->hideOnIndex(),
FormField::addPanel('address'),
AddressField::new('address')
->setRequired(true)
],
$this->getSeoPanel(),
$this->getConfPanel(),
[
FormField::addPanel('general'),
IntegerField::new('id')->onlyOnIndex()->setSortable(true),
TextField::new('title')->setSortable(true),
MoneyField::new('orderAmountMin')->setCurrency('EUR')->setSortable(true),
NumberField::new('deliveryPrice')
->setCustomOption('appendHtml', '€')
->hideOnIndex(),
StatusField::new('status')->setSortable(true),
ToggleField::new('isPublic')->setSortable(true),
ToggleField::new('isDepository')->setSortable(true),
FormField::addPanel('address'),
AddressField::new('address')
->setRequired(true)
],
$this->getSeoPanel(),
$this->getConfPanel(),
);
}

public function createEntity(string $entityFqcn)
{
return $this->get(PointSaleContainer::class)
->getFactory()
->create($this->get(MerchantResolver::class)->getCurrent());
->getFactory()
->create($this->get(MerchantResolver::class)->getCurrent());
}
}

+ 17
- 17
Controller/Product/ProductCategoryAdminController.php Bestand weergeven

@@ -2,20 +2,17 @@

namespace Lc\CaracoleBundle\Controller\Product;

//use Lc\CaracoleBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCatalogStore;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Lc\SovBundle\Field\ToggleField;

abstract class ProductCategoryAdminController extends AbstractAdminController
{
@@ -24,18 +21,21 @@ abstract class ProductCategoryAdminController extends AbstractAdminController
public function configureFields(string $pageName): iterable
{
return array_merge(
[
FormField::addPanel('general'),
TextField::new('title'),
NumberField::new('position')->hideOnForm(),
AssociationField::new('parent'),
CKEditorField::new('description'),
BooleanField::new('saleStatus'),
StatusField::new('status'),
[
FormField::addPanel('general'),
IntegerField::new('id')->onlyOnIndex()->setSortable(true),
TextField::new('title')->setSortable(true),
NumberField::new('position')->hideOnForm()->setSortable(true),
AssociationField::new('parent')->hideOnIndex(),
DateTimeField::new('createdAt')->setFormat('short')->setSortable(true),
CKEditorField::new('description')->hideOnIndex(),
StatusField::new('status')->setSortable(true),
ToggleField::new('saleStatus')->setSortable(true),
ToggleField::new('isEligibleTicketRestaurant')->setSortable(true),

],
$this->getSeoPanel(),
$this->getConfPanel()
],
$this->getSeoPanel(),
$this->getConfPanel()
);
}


+ 3
- 3
Controller/Section/SectionAdminController.php Bestand weergeven

@@ -42,14 +42,14 @@ abstract class SectionAdminController extends AbstractAdminController
]
),
TextField::new('color')
->setRequired(true)
->hideOnIndex(),
->setRequired(true),
NumberField::new('position')
->hideOnForm()
->hideOnIndex(),
CKEditorField::new('description')
->hideOnIndex(),
BooleanField::new('isDefault', 'Section par défaut'),
BooleanField::new('isDefault'),
BooleanField::new('isCommon'),
StatusField::new('status'),
],
$this->getSeoPanel(),

+ 51
- 46
Controller/User/UserMerchantAdminController.php Bestand weergeven

@@ -18,6 +18,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionExcept
use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory;
use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
@@ -50,7 +51,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController
$adminUrlGenerator = $this->get(AdminUrlGenerator::class);

$creditControllerFqcn = $context->getCrudControllers()->findCrudFqcnByEntityFqcn(
$this->get(EntityManagerInterface::class)->getEntityName(CreditHistoryInterface::class)
$this->get(EntityManagerInterface::class)->getEntityName(CreditHistoryInterface::class)
);

if ($entities) {
@@ -58,9 +59,9 @@ abstract class UserMerchantAdminController extends AbstractAdminController
foreach ($entity->getActions() as $action) {
if ($action->getName() == 'credit_history') {
$url = $adminUrlGenerator
->setController($creditControllerFqcn)
->set('userMerchantId', $entity->getInstance()->getId())
->generateUrl();
->setController($creditControllerFqcn)
->set('userMerchantId', $entity->getInstance()->getId())
->generateUrl();
$action->setLinkUrl($url);
}
}
@@ -73,14 +74,14 @@ abstract class UserMerchantAdminController extends AbstractAdminController
$actions = parent::configureActions($actions);

$creditAction = Action::new('credit_history', false, 'fa fa-cash-register')
->linkToCrudAction('credit_history')
->setHtmlAttributes(
array(
'data-toggle' => 'tooltip',
'title' => $this->get(TranslatorAdmin::class)->transAction('credit'),
)
->linkToCrudAction('credit_history')
->setHtmlAttributes(
array(
'data-toggle' => 'tooltip',
'title' => $this->get(TranslatorAdmin::class)->transAction('credit'),
)
->setCssClass('btn btn-sm btn-success');
)
->setCssClass('btn btn-sm btn-success');
$actions->add(Crud::PAGE_INDEX, $creditAction);

return $actions;
@@ -89,12 +90,13 @@ abstract class UserMerchantAdminController extends AbstractAdminController
public function configureFields(string $pageName): iterable
{
$fields = [
TextField::new('user.email'),
TextField::new('user.lastname'),
TextField::new('user.firstname'),
BooleanField::new('active'),
BooleanField::new('creditActive'),
AssociationField::new('user'),
IntegerField::new('id')->onlyOnIndex()->setSortable(true),
TextField::new('user.lastname')->setSortable(true),
TextField::new('user.firstname')->setSortable(true),
TextField::new('user.email')->setSortable(true),
BooleanField::new('active')->setSortable(true),
BooleanField::new('creditActive')->hideOnIndex(),
AssociationField::new('user'),
];

if ($this->isGranted('ROLE_SUPER_ADMIN')) {
@@ -107,7 +109,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController
public function configureFilters(Filters $filters): Filters
{
return $filters
->add(BooleanFilter::new('active'));
->add(BooleanFilter::new('active'));
}

public function new(AdminContext $context): Response
@@ -116,8 +118,8 @@ abstract class UserMerchantAdminController extends AbstractAdminController
$merchantResolver = $this->get(MerchantResolver::class);

$userMerchant = $this->get(UserMerchantContainer::class)
->getFactory()
->create($merchantResolver->getCurrent());
->getFactory()
->create($merchantResolver->getCurrent());

$form = $this->createForm(UserMerchantFormType::class, $userMerchant);

@@ -159,16 +161,19 @@ abstract class UserMerchantAdminController extends AbstractAdminController

return $this->redirect($url);
} else {
$this->addFlash('error', $this->get(TranslatorAdmin::class)->trans('form.user_merchant.already_exist'));
$this->addFlash(
'error',
$this->get(TranslatorAdmin::class)->trans('form.user_merchant.already_exist')
);
}
}
}

return $this->render(
'@LcCaracole/admin/user/new_usermerchant.html.twig',
[
'form' => $form->createView(),
]
'@LcCaracole/admin/user/new_usermerchant.html.twig',
[
'form' => $form->createView(),
]
);
}

@@ -204,10 +209,10 @@ abstract class UserMerchantAdminController extends AbstractAdminController
}

return $this->render(
'@LcCaracole/admin/user/edit_usermerchant.html.twig',
[
'form' => $form->createView(),
]
'@LcCaracole/admin/user/edit_usermerchant.html.twig',
[
'form' => $form->createView(),
]
);
}

@@ -220,8 +225,8 @@ abstract class UserMerchantAdminController extends AbstractAdminController
}

if (!$this->isGranted(
Permission::EA_EXECUTE_ACTION,
['action' => Action::DETAIL, 'entity' => $context->getEntity()]
Permission::EA_EXECUTE_ACTION,
['action' => Action::DETAIL, 'entity' => $context->getEntity()]
)) {
throw new ForbiddenActionException($context);
}
@@ -230,25 +235,25 @@ abstract class UserMerchantAdminController extends AbstractAdminController
}

$options['action'] = $adminUrlGenerator
->setController($context->getCrud()->getControllerFqcn())
->setAction('add_credit')
->setEntityId($context->getEntity()->getInstance()->getId())
->set('userMerchant', 'niche')
->generateUrl();
->setController($context->getCrud()->getControllerFqcn())
->setAction('add_credit')
->setEntityId($context->getEntity()->getInstance()->getId())
->set('userMerchant', 'niche')
->generateUrl();
$addCreditHistoryForm = $this->createForm(CreditHistoryFormType::class, null, $options)->createView();


return $this->render(
'@LcCaracole/admin/credit/credit_detail.html.twig',
[
'pageName' => Crud::PAGE_DETAIL,
'entity' => $context->getEntity(),
'batch_actions' => array(),
'entities' => array(),
'filters' => array(),
'paginator' => array(),
'add_credit_history_form' => $addCreditHistoryForm,
]
'@LcCaracole/admin/credit/credit_detail.html.twig',
[
'pageName' => Crud::PAGE_DETAIL,
'entity' => $context->getEntity(),
'batch_actions' => array(),
'entities' => array(),
'filters' => array(),
'paginator' => array(),
'add_credit_history_form' => $addCreditHistoryForm,
]
);
}


+ 2
- 0
Factory/Order/OrderPaymentFactory.php Bestand weergeven

@@ -16,6 +16,8 @@ class OrderPaymentFactory extends AbstractFactory
$orderPayment->setOrderShop($orderShop);
$orderPayment->setMeanPayment($meanPayment);
$orderPayment->setAmount($amount);
$orderPayment->setPaidAt(new \DateTime());
$orderPayment->setEditable(false);

return $orderPayment;
}

+ 12
- 7
Form/Ticket/TicketFormType.php Bestand weergeven

@@ -109,16 +109,21 @@ class TicketFormType extends AbstractType
'isValid' => true
]
),
'label' => 'field.default.order',
'label' => 'entity.default.fields.order',
'placeholder' => '-- Choisissez une commande --',
'required' => false,
'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',
]

+ 12
- 7
Generator/OrderReferenceGenerator.php Bestand weergeven

@@ -16,9 +16,9 @@ class OrderReferenceGenerator
$this->settingSolver = $settingSolver;
}

public function buildReference(OrderShopInterface $orderShop, \DateTime $distributionDate = null): string
public function buildReference(OrderShopInterface $orderShop, \DateTimeInterface $distributionDate = null): string
{
switch ($orderShop->getSection()->getCycle()) {
switch ($orderShop->getSection()->getCycleType()) {
case SectionModel::CYCLE_TYPE_DAY:
return $this->buildReferenceCycleDay($orderShop);
case SectionModel::CYCLE_TYPE_WEEK:
@@ -38,7 +38,7 @@ class OrderReferenceGenerator
'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) .
'S' . $distributionDate->format('W') .
@@ -46,15 +46,17 @@ class OrderReferenceGenerator
'A' . $distributionDate->format('y');
}

public function buildReferenceCycleMonth(OrderShopInterface $orderShop, \DateTime $distributionDate): string
{
public function buildReferenceCycleMonth(
OrderShopInterface $orderShop,
\DateTimeInterface $distributionDate
): string {
return $this->getPrefixReference($orderShop) .
'M' . $distributionDate->format('m') .
'C' . $this->numberPad($orderShop->getCycleId(), 4) .
'A' . $distributionDate->format('y');
}

public function buildReferenceCycleYear(OrderShopInterface $orderShop, \DateTime $distributionDate): string
public function buildReferenceCycleYear(OrderShopInterface $orderShop, \DateTimeInterface $distributionDate): string
{
return $this->getPrefixReference($orderShop) .
'C' . $this->numberPad($orderShop->getCycleId(), 5) .
@@ -63,7 +65,10 @@ class OrderReferenceGenerator

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

+ 2
- 1
Model/Order/OrderReductionCartModel.php Bestand weergeven

@@ -8,11 +8,12 @@ use Lc\CaracoleBundle\Doctrine\Extension\ReductionCartPropertyTrait;
use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait;
use Lc\CaracoleBundle\Doctrine\Extension\ReductionInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\SovBundle\Doctrine\EntityInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class OrderReductionCartModel implements ReductionInterface, ReductionCartPropertyInterface
abstract class OrderReductionCartModel implements EntityInterface, ReductionInterface, ReductionCartPropertyInterface
{
use ReductionTrait;
use ReductionCartPropertyTrait;

+ 1
- 4
Model/Order/OrderShopInterface.php Bestand weergeven

@@ -2,7 +2,6 @@

namespace Lc\CaracoleBundle\Model\Order;


use Doctrine\Common\Collections\Collection;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Config\TaxRateInterface;
@@ -13,9 +12,7 @@ use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\User\UserInterface;

/**
* @ORM\MappedSuperclass()
*/

interface OrderShopInterface
{
public function getValidationDate(): ?\DateTimeInterface;

+ 1
- 6
Model/Order/OrderShopModel.php Bestand weergeven

@@ -4,7 +4,6 @@ namespace Lc\CaracoleBundle\Model\Order;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
@@ -12,15 +11,11 @@ use Lc\CaracoleBundle\Model\Config\TaxRateInterface;
use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
use Lc\SovBundle\Model\User\UserInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class OrderShopModel extends AbstractLightEntity implements FilterSectionInterface, OrderShopInterface
{

@@ -68,7 +63,7 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti
protected $orderStatusHistories;

/**
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderPaymentInterface", mappedBy="orderShop", orphanRemoval=true)
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderPaymentInterface", mappedBy="orderShop", orphanRemoval=true,cascade={"persist"})
*/
protected $orderPayments;


+ 19
- 0
Model/Section/SectionModel.php Bestand weergeven

@@ -21,6 +21,8 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
*/
abstract class SectionModel extends AbstractFullEntity implements FilterMerchantInterface
{
const DEVALIAS_COMMON = 'common';

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="sections")
* @ORM\JoinColumn(nullable=false)
@@ -87,6 +89,11 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant
*/
protected $openings;

/**
* @ORM\Column(type="boolean", nullable=true)
*/
protected $isCommon;

public function __construct()
{
$this->productFamilies = new ArrayCollection();
@@ -394,4 +401,16 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant

return $this;
}

public function getIsCommon(): ?bool
{
return $this->isCommon;
}

public function setIsCommon(?bool $isCommon): self
{
$this->isCommon = $isCommon;

return $this;
}
}

+ 9
- 0
Repository/Order/OrderShopRepositoryQuery.php Bestand weergeven

@@ -7,6 +7,7 @@ use App\Entity\Delivery\DeliveryAvailabilityZone;
use App\Entity\PointSale\PointSale;
use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
@@ -49,6 +50,13 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
->select('count(r.id) as total');
}

public function filterByMerchant(MerchantInterface $merchant)
{
$this->joinMerchant();
return $this->andWhere('s.merchant = :merchant')
->setParameter('merchant', $merchant);
}

public function filterByUser(UserInterface $user): self
{
return $this
@@ -233,4 +241,5 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
}
return $this;
}

}

+ 23
- 12
Repository/Order/OrderShopStore.php Bestand weergeven

@@ -9,7 +9,9 @@ use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCartStore;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
@@ -28,6 +30,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class OrderShopStore extends AbstractStore
{
use SectionStoreTrait;
use MerchantStoreTrait;

protected OrderShopRepositoryQuery $query;
protected EntityManagerInterface $entityManager;
@@ -79,16 +82,20 @@ class OrderShopStore extends AbstractStore

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
$query->orderBy('id', 'DESC');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
if($this->section) {
if(isset($this->section) && $this->section) {
$query->filterBySection($this->section);
}

if(isset($this->merchant) && $this->merchant) {
$query->filterByMerchant($this->merchant);
}

return $query;
}

@@ -272,21 +279,22 @@ class OrderShopStore extends AbstractStore
}

// findCartCurrent
public function getOneCartCurrent(array $params = [], $query = null): ?OrderShopInterface
public function getOneCartCurrent(UserInterface $user = null, VisitorInterface $visitor = null, $query = null): ?OrderShopInterface
{
$query = $this->createDefaultQuery($query);

if (isset($params['user'])) {
$query->filterByUser($params['user']);
if (!is_null($user)) {
$query->filterByUser($user);
}

if (isset($params['visitor'])) {
$query->filterByVisitor($params['visitor']);
else {
if (!is_null($visitor)) {
$query->filterByVisitor($visitor);
}
}

$query
->selectOrderReductionCarts()
->filterByStatus(OrderStatusModel::$statusAliasAsValid);
->filterByStatus(OrderStatusModel::$statusAliasAsCart);

return $query->findOne();
}
@@ -443,7 +451,8 @@ class OrderShopStore extends AbstractStore

$reductionCreditsArray = [];
foreach ($reductionCredits as $reductionCredit) {
if (!$this->countValidWithReductionCredit($reductionCredit, $user)) {
if (!$this->countValidWithReductionCredit($reductionCredit, $user)
&& (!$this->merchant || $reductionCredit->getSection()->getMerchant() == $this->merchant)) {
$reductionCreditsArray[] = $reductionCredit;
}
}
@@ -512,8 +521,10 @@ class OrderShopStore extends AbstractStore
if ($this->reductionCartSolver->matchWithUser($reductionCart, $user)
&& $this->reductionCartSolver->matchWithGroupUser($reductionCart, $user)
&& $this->getReductionCartRemainingQuantityByUser($reductionCart, $user)
&& ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)) {
$reductionCartsArray[] = $reductionCart;
&& ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)
&& (!$this->merchant || $reductionCart->getSection()->getMerchant() == $this->merchant)) {

$reductionCartsArray[] = $reductionCart;
}
}


+ 11
- 0
Resources/translations/admin.fr.yaml Bestand weergeven

@@ -59,12 +59,15 @@ entity:
behaviorTaxRateChoices:
tax-excluded: TVA exclue
tax-included: Tva incluse
order: Commande

PointSale:
label: Point de vente
label_plurial: Points de vente
fields:
orderAmountMin: Montant minimum de commande
isPublic: Public
isDepository: Dépôt

Address:
fields:
@@ -90,6 +93,7 @@ entity:
fields:
cycle: Cycle de vente
isDefault: Section par défaut
isCommon: Section commune
TaxRate:
label: Règle de taxe
label_plurial: Règles de taxes
@@ -122,6 +126,13 @@ entity:
reference: Référence
comment: Commentaire

OrderShop:
fields:
deliveryInfos: |
Merci de nous laisser le maximum d'informations pour faciliter notre arrivée : digicode,
étage, rue non répertoriée dans les GPS, accès vers la porte d'entrée ...
useDeliveryAddressAsBillingAddress: Utiliser l'adresse de livraison

GroupUser:
label: Groupe d'utilisateur
label_plurial: Groupes d'utilisateurs

+ 6
- 0
Solver/Order/OrderShopSolver.php Bestand weergeven

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Solver\Order;

use App\Entity\Order\OrderShop;
use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\File\DocumentModel;
@@ -345,4 +346,9 @@ class OrderShopSolver
$byWeight
);
}

public function hasMakeAChoiceAboutComplementaryOrder(OrderShop $orderShop): bool
{
return $orderShop->getMainOrderShop() || $orderShop->getDeclineComplementaryOrderShop();
}
}

+ 6
- 0
Solver/Section/SectionSolver.php Bestand weergeven

@@ -3,9 +3,15 @@
namespace Lc\CaracoleBundle\Solver\Section;

use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Model\Section\SectionModel;

class SectionSolver
{
public function isSectionCommon(SectionInterface $section)
{
return $section->getDevAlias() == SectionModel::DEVALIAS_COMMON;
}

// @TODO : à voir si pertinent
public function getNewsletter(SectionInterface $section)
{

+ 20
- 11
Twig/StoreTwigExtension.php Bestand weergeven

@@ -2,25 +2,23 @@

namespace Lc\CaracoleBundle\Twig;

use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\CaracoleBundle\Repository\Config\TaxRateStore;
use Lc\CaracoleBundle\Repository\Config\UnitStore;
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore;
use Lc\CaracoleBundle\Repository\Reminder\ReminderStore;
use Lc\CaracoleBundle\Repository\Section\SectionRepository;
use Lc\CaracoleBundle\Repository\Section\SectionRepositoryInterface;
use Lc\CaracoleBundle\Repository\Section\SectionRepositoryQuery;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\ShopBundle\Context\UnitInterface;
use Lc\CaracoleBundle\Resolver\VisitorResolver;
use Lc\SovBundle\Solver\Setting\SettingSolver;
use Symfony\Component\Security\Core\Security;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

@@ -36,6 +34,9 @@ class StoreTwigExtension extends AbstractExtension
protected ProductCategoryStore $productCategoryStore;
protected OrderShopStore $orderShopStore;
protected SettingSolver $settingSolver;
protected OrderShopBuilder $orderShopBuilder;
protected Security $security;
protected VisitorResolver $visitorResolver;

public function __construct(
MerchantResolver $merchantResolver,
@@ -47,7 +48,10 @@ class StoreTwigExtension extends AbstractExtension
TaxRateStore $taxRateStore,
ProductCategoryStore $productCategoryStore,
OrderShopStore $orderShopStore,
SettingSolver $settingSolver
SettingSolver $settingSolver,
OrderShopBuilder $orderShopBuilder,
Security $security,
VisitorResolver $visitorResolver
) {
$this->merchantResolver = $merchantResolver;
$this->sectionResolver = $sectionResolver;
@@ -59,6 +63,9 @@ class StoreTwigExtension extends AbstractExtension
$this->productCategoryStore = $productCategoryStore;
$this->orderShopStore = $orderShopStore;
$this->settingSolver = $settingSolver;
$this->orderShopBuilder = $orderShopBuilder;
$this->security = $security;
$this->visitorResolver = $visitorResolver;
}

public function getFunctions()
@@ -104,9 +111,11 @@ class StoreTwigExtension extends AbstractExtension

public function getCartCurrent(): OrderShopInterface
{
return $this->orderShopStore
->setSection($this->sectionResolver->getCurrent())
->getOneCartCurrent();
return $this->orderShopBuilder->createIfNotExist(
$this->sectionResolver->getCurrent(),
$this->security->getUser(),
$this->visitorResolver->getCurrent()
);
}

public function getMerchantCurrent(): MerchantInterface
@@ -114,9 +123,9 @@ class StoreTwigExtension extends AbstractExtension
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

Laden…
Annuleren
Opslaan