Browse Source

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

packProduct
Fabien Normand 3 years ago
parent
commit
c66be5cd29
21 changed files with 252 additions and 167 deletions
  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 View File

use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\Section\OpeningModel;
use Lc\CaracoleBundle\Model\Section\SectionInterface; use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Model\Section\SectionModel; use Lc\CaracoleBundle\Model\Section\SectionModel;
use Lc\CaracoleBundle\Model\User\VisitorInterface; use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\CaracoleBundle\Repository\Order\OrderStatusStore; use Lc\CaracoleBundle\Repository\Order\OrderStatusStore;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore; use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore;
use Lc\CaracoleBundle\Resolver\OpeningResolver; 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\Order\OrderShopSolver;
use Lc\CaracoleBundle\Solver\Price\PriceSolver; use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\CaracoleBundle\Solver\Product\ProductSolver; use Lc\CaracoleBundle\Solver\Product\ProductSolver;
protected FlashBagInterface $flashBag; protected FlashBagInterface $flashBag;
protected OpeningResolver $openingResolver; protected OpeningResolver $openingResolver;
protected ProductSolver $productSolver; protected ProductSolver $productSolver;
protected OrderShopResolver $orderShopResolver;


public function __construct( public function __construct(
EntityManagerInterface $entityManager, EntityManagerInterface $entityManager,
EventDispatcherInterface $eventDispatcher, EventDispatcherInterface $eventDispatcher,
FlashBagInterface $flashBag, FlashBagInterface $flashBag,
OpeningResolver $openingResolver, OpeningResolver $openingResolver,
ProductSolver $productSolver
ProductSolver $productSolver,
OrderShopResolver $orderShopResolver
) { ) {
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
$this->orderShopStore = $orderShopStore; $this->orderShopStore = $orderShopStore;
$this->flashBag = $flashBag; $this->flashBag = $flashBag;
$this->openingResolver = $openingResolver; $this->openingResolver = $openingResolver;
$this->productSolver = $productSolver; $this->productSolver = $productSolver;
$this->orderShopResolver = $orderShopResolver;
} }


public function create( public function create(
UserInterface $user = null, UserInterface $user = null,
VisitorInterface $visitor = null VisitorInterface $visitor = null
): OrderShopInterface { ): OrderShopInterface {

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


UserInterface $user = null, UserInterface $user = null,
VisitorInterface $visitor = null VisitorInterface $visitor = null
): OrderShopInterface { ): OrderShopInterface {
$cart = $this->orderShopStore->getOneCartCurrent(
[
'section' => $section,
'user' => $user,
'visitor' => $visitor
]
);
$cart = $this->orderShopStore
->setSection($section)
->getOneCartCurrent($user, $visitor);


if (!$cart) { if (!$cart) {
$cart = $this->create($section, $user, $visitor); $cart = $this->create($section, $user, $visitor);
string $alias, string $alias,
bool $forceByAdmin = false bool $forceByAdmin = false
): OrderShopInterface { ): OrderShopInterface {

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


if ($orderStatus) { if ($orderStatus) {


$orderShop->addOrderPayment($orderPayment); $orderShop->addOrderPayment($orderPayment);


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


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);
$cycleNumber = null; $cycleNumber = null;
$deliveryDate = $orderShop->getDeliveryDate(); $deliveryDate = $orderShop->getDeliveryDate();


switch ($orderShop->getSection()->getCycle()) {
case SectionModel::CYCLE_DAY:
switch ($orderShop->getSection()->getCycleType()) {
case SectionModel::CYCLE_TYPE_DAY:
$cycleNumber = $deliveryDate->format('z'); $cycleNumber = $deliveryDate->format('z');
break; break;
case SectionModel::CYCLE_WEEK:
case SectionModel::CYCLE_TYPE_WEEK:
$cycleNumber = $deliveryDate->format('W'); $cycleNumber = $deliveryDate->format('W');
break; break;
} }


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


break; break;
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY : case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY :


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


$productFamily = $orderProduct->getProduct()->getProductFamily(); $productFamily = $orderProduct->getProduct()->getProductFamily();


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


$product = $orderProduct->getProduct(); $product = $orderProduct->getProduct();
public function updatePriceByProductFamily(ProductFamilyInterface $productFamily) public function updatePriceByProductFamily(ProductFamilyInterface $productFamily)
{ {
// @TODO : faire la vérification isOpenSale depuis la méthode appelante // @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; $countOrderProductUpdated = 0;


foreach ($productFamily->getProducts() as $product) { foreach ($productFamily->getProducts() as $product) {
} }


// setDeliveryAddress // setDeliveryAddress
public function initDeliveryAddress(OrderShopInterface $orderShop, AddressInterface $address = null):void
public function initDeliveryAddress(OrderShopInterface $orderShop, AddressInterface $address = null): void
{ {
$orderShop->setDeliveryAddress($address); $orderShop->setDeliveryAddress($address);
$orderShop->setDeliveryInfos($address ? $address->getDeliveryInfos() : null); $orderShop->setDeliveryInfos($address ? $address->getDeliveryInfos() : null);
} }





} }

+ 1
- 1
Builder/User/UserMerchantBuilder.php View File



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

+ 10
- 5
Controller/ControllerTrait.php View File

[ [
PriceSolver::class => PriceSolver::class, PriceSolver::class => PriceSolver::class,
MerchantResolver::class => MerchantResolver::class, MerchantResolver::class => MerchantResolver::class,
SectionResolver::class=> SectionResolver::class,
SectionResolver::class => SectionResolver::class,
OrderShopContainer::class => OrderShopContainer::class, OrderShopContainer::class => OrderShopContainer::class,
AddressContainer::class => AddressContainer::class, AddressContainer::class => AddressContainer::class,
TaxRateContainer::class => TaxRateContainer::class, TaxRateContainer::class => TaxRateContainer::class,


public function getUserMerchantCurrent(): UserMerchantInterface 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 public function getMerchantUserCurrent(): MerchantInterface


public function getCartCurrent(): OrderShopInterface 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 public function getPriceSolver(): PriceSolver

+ 1
- 1
Controller/Order/CartController.php View File

{ {
$entityManager = $this->getEntityManager(); $entityManager = $this->getEntityManager();
$id = $request->get('id'); $id = $request->get('id');
$orderReductionCart = $this->getOrderReductionCartContainer()->getStore()->getOneById((int)$id);
$orderReductionCart = $this->getOrderReductionCartContainer()->getStore()->getOneById((int) $id);
$orderShop = $this->getCartCurrent(); $orderShop = $this->getCartCurrent();


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

+ 22
- 22
Controller/PointSale/PointSaleAdminController.php View File

namespace Lc\CaracoleBundle\Controller\PointSale; namespace Lc\CaracoleBundle\Controller\PointSale;


use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; 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\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer; use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField; use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\StatusField; use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Field\ToggleField;


abstract class PointSaleAdminController extends AbstractAdminController abstract class PointSaleAdminController extends AbstractAdminController
{ {


public function configureFields(string $pageName): iterable public function configureFields(string $pageName): iterable
{ {

return array_merge( 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) public function createEntity(string $entityFqcn)
{ {
return $this->get(PointSaleContainer::class) 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 View File



namespace Lc\CaracoleBundle\Controller\Product; namespace Lc\CaracoleBundle\Controller\Product;


//use Lc\CaracoleBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; 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\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCatalogStore;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\CKEditorField; use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField; use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Lc\SovBundle\Field\ToggleField;


abstract class ProductCategoryAdminController extends AbstractAdminController abstract class ProductCategoryAdminController extends AbstractAdminController
{ {
public function configureFields(string $pageName): iterable public function configureFields(string $pageName): iterable
{ {
return array_merge( 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 View File

] ]
), ),
TextField::new('color') TextField::new('color')
->setRequired(true)
->hideOnIndex(),
->setRequired(true),
NumberField::new('position') NumberField::new('position')
->hideOnForm() ->hideOnForm()
->hideOnIndex(), ->hideOnIndex(),
CKEditorField::new('description') CKEditorField::new('description')
->hideOnIndex(), ->hideOnIndex(),
BooleanField::new('isDefault', 'Section par défaut'),
BooleanField::new('isDefault'),
BooleanField::new('isCommon'),
StatusField::new('status'), StatusField::new('status'),
], ],
$this->getSeoPanel(), $this->getSeoPanel(),

+ 51
- 46
Controller/User/UserMerchantAdminController.php View File

use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory;
use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField; use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter; use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
$adminUrlGenerator = $this->get(AdminUrlGenerator::class); $adminUrlGenerator = $this->get(AdminUrlGenerator::class);


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


if ($entities) { if ($entities) {
foreach ($entity->getActions() as $action) { foreach ($entity->getActions() as $action) {
if ($action->getName() == 'credit_history') { if ($action->getName() == 'credit_history') {
$url = $adminUrlGenerator $url = $adminUrlGenerator
->setController($creditControllerFqcn)
->set('userMerchantId', $entity->getInstance()->getId())
->generateUrl();
->setController($creditControllerFqcn)
->set('userMerchantId', $entity->getInstance()->getId())
->generateUrl();
$action->setLinkUrl($url); $action->setLinkUrl($url);
} }
} }
$actions = parent::configureActions($actions); $actions = parent::configureActions($actions);


$creditAction = Action::new('credit_history', false, 'fa fa-cash-register') $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); $actions->add(Crud::PAGE_INDEX, $creditAction);


return $actions; return $actions;
public function configureFields(string $pageName): iterable public function configureFields(string $pageName): iterable
{ {
$fields = [ $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')) { if ($this->isGranted('ROLE_SUPER_ADMIN')) {
public function configureFilters(Filters $filters): Filters public function configureFilters(Filters $filters): Filters
{ {
return $filters return $filters
->add(BooleanFilter::new('active'));
->add(BooleanFilter::new('active'));
} }


public function new(AdminContext $context): Response public function new(AdminContext $context): Response
$merchantResolver = $this->get(MerchantResolver::class); $merchantResolver = $this->get(MerchantResolver::class);


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


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




return $this->redirect($url); return $this->redirect($url);
} else { } 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( return $this->render(
'@LcCaracole/admin/user/new_usermerchant.html.twig',
[
'form' => $form->createView(),
]
'@LcCaracole/admin/user/new_usermerchant.html.twig',
[
'form' => $form->createView(),
]
); );
} }


} }


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


} }


if (!$this->isGranted( 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); throw new ForbiddenActionException($context);
} }
} }


$options['action'] = $adminUrlGenerator $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(); $addCreditHistoryForm = $this->createForm(CreditHistoryFormType::class, null, $options)->createView();




return $this->render( 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 View File

$orderPayment->setOrderShop($orderShop); $orderPayment->setOrderShop($orderShop);
$orderPayment->setMeanPayment($meanPayment); $orderPayment->setMeanPayment($meanPayment);
$orderPayment->setAmount($amount); $orderPayment->setAmount($amount);
$orderPayment->setPaidAt(new \DateTime());
$orderPayment->setEditable(false);


return $orderPayment; return $orderPayment;
} }

+ 12
- 7
Form/Ticket/TicketFormType.php View File

'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',
] ]

+ 12
- 7
Generator/OrderReferenceGenerator.php View File

$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()->getCycle()) {
switch ($orderShop->getSection()->getCycleType()) {
case SectionModel::CYCLE_TYPE_DAY: case SectionModel::CYCLE_TYPE_DAY:
return $this->buildReferenceCycleDay($orderShop); return $this->buildReferenceCycleDay($orderShop);
case SectionModel::CYCLE_TYPE_WEEK: case SectionModel::CYCLE_TYPE_WEEK:
'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

+ 2
- 1
Model/Order/OrderReductionCartModel.php View File

use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait;
use Lc\CaracoleBundle\Doctrine\Extension\ReductionInterface; use Lc\CaracoleBundle\Doctrine\Extension\ReductionInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\SovBundle\Doctrine\EntityInterface;


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

+ 1
- 4
Model/Order/OrderShopInterface.php View File



namespace Lc\CaracoleBundle\Model\Order; namespace Lc\CaracoleBundle\Model\Order;



use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Lc\CaracoleBundle\Model\Address\AddressInterface; use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Config\TaxRateInterface; use Lc\CaracoleBundle\Model\Config\TaxRateInterface;
use Lc\SovBundle\Model\Ticket\TicketInterface; use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\User\UserInterface; use Lc\SovBundle\Model\User\UserInterface;


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

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

+ 1
- 6
Model/Order/OrderShopModel.php View File



use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface; use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\File\DocumentInterface; use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface; use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait;
use Lc\SovBundle\Model\Ticket\TicketInterface; use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\CaracoleBundle\Model\User\VisitorInterface; use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
use Lc\SovBundle\Model\User\UserInterface; use Lc\SovBundle\Model\User\UserInterface;


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


protected $orderStatusHistories; 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; protected $orderPayments;



+ 19
- 0
Model/Section/SectionModel.php View File

*/ */
abstract class SectionModel extends AbstractFullEntity implements FilterMerchantInterface abstract class SectionModel extends AbstractFullEntity implements FilterMerchantInterface
{ {
const DEVALIAS_COMMON = 'common';

/** /**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="sections") * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="sections")
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
*/ */
protected $openings; protected $openings;


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

public function __construct() public function __construct()
{ {
$this->productFamilies = new ArrayCollection(); $this->productFamilies = new ArrayCollection();


return $this; 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 View File

use App\Entity\PointSale\PointSale; use App\Entity\PointSale\PointSale;
use Knp\Component\Pager\PaginatorInterface; use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface; use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface; use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface; use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
->select('count(r.id) as total'); ->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 public function filterByUser(UserInterface $user): self
{ {
return $this return $this
} }
return $this; return $this;
} }

} }

+ 23
- 12
Repository/Order/OrderShopStore.php View File

use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel; use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore; use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCartStore; use Lc\CaracoleBundle\Repository\Reduction\ReductionCartStore;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore; use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore;
use Lc\CaracoleBundle\Repository\Section\SectionStore; use Lc\CaracoleBundle\Repository\Section\SectionStore;
class OrderShopStore extends AbstractStore class OrderShopStore extends AbstractStore
{ {
use SectionStoreTrait; use SectionStoreTrait;
use MerchantStoreTrait;


protected OrderShopRepositoryQuery $query; protected OrderShopRepositoryQuery $query;
protected EntityManagerInterface $entityManager; protected EntityManagerInterface $entityManager;


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


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


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

return $query; return $query;
} }


} }


// findCartCurrent // 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); $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 $query
->selectOrderReductionCarts() ->selectOrderReductionCarts()
->filterByStatus(OrderStatusModel::$statusAliasAsValid);
->filterByStatus(OrderStatusModel::$statusAliasAsCart);


return $query->findOne(); return $query->findOne();
} }


$reductionCreditsArray = []; $reductionCreditsArray = [];
foreach ($reductionCredits as $reductionCredit) { foreach ($reductionCredits as $reductionCredit) {
if (!$this->countValidWithReductionCredit($reductionCredit, $user)) {
if (!$this->countValidWithReductionCredit($reductionCredit, $user)
&& (!$this->merchant || $reductionCredit->getSection()->getMerchant() == $this->merchant)) {
$reductionCreditsArray[] = $reductionCredit; $reductionCreditsArray[] = $reductionCredit;
} }
} }
if ($this->reductionCartSolver->matchWithUser($reductionCart, $user) if ($this->reductionCartSolver->matchWithUser($reductionCart, $user)
&& $this->reductionCartSolver->matchWithGroupUser($reductionCart, $user) && $this->reductionCartSolver->matchWithGroupUser($reductionCart, $user)
&& $this->getReductionCartRemainingQuantityByUser($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 View File

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
label_plurial: Points de vente label_plurial: Points de vente
fields: fields:
orderAmountMin: Montant minimum de commande orderAmountMin: Montant minimum de commande
isPublic: Public
isDepository: Dépôt


Address: Address:
fields: fields:
fields: fields:
cycle: Cycle de vente cycle: Cycle de vente
isDefault: Section par défaut isDefault: Section par défaut
isCommon: Section commune
TaxRate: TaxRate:
label: Règle de taxe label: Règle de taxe
label_plurial: Règles de taxes label_plurial: Règles de taxes
reference: Référence reference: Référence
comment: Commentaire 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: GroupUser:
label: Groupe d'utilisateur label: Groupe d'utilisateur
label_plurial: Groupes d'utilisateurs label_plurial: Groupes d'utilisateurs

+ 6
- 0
Solver/Order/OrderShopSolver.php View File



namespace Lc\CaracoleBundle\Solver\Order; namespace Lc\CaracoleBundle\Solver\Order;


use App\Entity\Order\OrderShop;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Model\File\DocumentInterface; use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\File\DocumentModel; use Lc\CaracoleBundle\Model\File\DocumentModel;
$byWeight $byWeight
); );
} }

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

+ 6
- 0
Solver/Section/SectionSolver.php View File

namespace Lc\CaracoleBundle\Solver\Section; namespace Lc\CaracoleBundle\Solver\Section;


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


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

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

+ 20
- 11
Twig/StoreTwigExtension.php View File



namespace Lc\CaracoleBundle\Twig; namespace Lc\CaracoleBundle\Twig;


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


protected ProductCategoryStore $productCategoryStore; protected ProductCategoryStore $productCategoryStore;
protected OrderShopStore $orderShopStore; protected OrderShopStore $orderShopStore;
protected SettingSolver $settingSolver; protected SettingSolver $settingSolver;
protected OrderShopBuilder $orderShopBuilder;
protected Security $security;
protected VisitorResolver $visitorResolver;


public function __construct( public function __construct(
MerchantResolver $merchantResolver, MerchantResolver $merchantResolver,
TaxRateStore $taxRateStore, TaxRateStore $taxRateStore,
ProductCategoryStore $productCategoryStore, ProductCategoryStore $productCategoryStore,
OrderShopStore $orderShopStore, OrderShopStore $orderShopStore,
SettingSolver $settingSolver
SettingSolver $settingSolver,
OrderShopBuilder $orderShopBuilder,
Security $security,
VisitorResolver $visitorResolver
) { ) {
$this->merchantResolver = $merchantResolver; $this->merchantResolver = $merchantResolver;
$this->sectionResolver = $sectionResolver; $this->sectionResolver = $sectionResolver;
$this->productCategoryStore = $productCategoryStore; $this->productCategoryStore = $productCategoryStore;
$this->orderShopStore = $orderShopStore; $this->orderShopStore = $orderShopStore;
$this->settingSolver = $settingSolver; $this->settingSolver = $settingSolver;
$this->orderShopBuilder = $orderShopBuilder;
$this->security = $security;
$this->visitorResolver = $visitorResolver;
} }


public function getFunctions() public function getFunctions()


public function getCartCurrent(): OrderShopInterface 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 public function getMerchantCurrent(): MerchantInterface
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

Loading…
Cancel
Save