Browse Source

Merge branch 'develop'

master
Guillaume 2 years ago
parent
commit
32124e725d
4 changed files with 28 additions and 19 deletions
  1. +5
    -8
      Builder/Order/OrderShopBuilder.php
  2. +15
    -9
      Definition/Field/Product/ProductCategoryFieldDefinition.php
  3. +5
    -1
      Solver/Product/ProductFamilySolver.php
  4. +3
    -1
      Solver/Product/ProductSolver.php

+ 5
- 8
Builder/Order/OrderShopBuilder.php View File

use Lc\CaracoleBundle\Builder\File\DocumentBuilder; use Lc\CaracoleBundle\Builder\File\DocumentBuilder;
use Lc\CaracoleBundle\Event\Order\CartChangeEvent; use Lc\CaracoleBundle\Event\Order\CartChangeEvent;
use Lc\CaracoleBundle\Event\Order\OrderShopChangeStatusEvent; use Lc\CaracoleBundle\Event\Order\OrderShopChangeStatusEvent;
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory;
use Lc\CaracoleBundle\Factory\File\DocumentFactory; use Lc\CaracoleBundle\Factory\File\DocumentFactory;
use Lc\CaracoleBundle\Factory\Order\OrderPaymentFactory; use Lc\CaracoleBundle\Factory\Order\OrderPaymentFactory;
use Lc\CaracoleBundle\Factory\Order\OrderProductFactory; use Lc\CaracoleBundle\Factory\Order\OrderProductFactory;
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\SectionInterface; use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Model\Section\SectionModel;
use Lc\CaracoleBundle\Model\User\VisitorInterface; use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\CaracoleBundle\Repository\Order\OrderProductStore; use Lc\CaracoleBundle\Repository\Order\OrderProductStore;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\SovBundle\Translation\FlashBagTranslator; use Lc\SovBundle\Translation\FlashBagTranslator;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
use Symfony\Contracts\Cache\TagAwareCacheInterface;


class OrderShopBuilder class OrderShopBuilder
{ {
protected MerchantResolver $merchantResolver; protected MerchantResolver $merchantResolver;
protected CreditHistoryBuilder $creditHistoryBuilder; protected CreditHistoryBuilder $creditHistoryBuilder;
protected FlashBagTranslator $flashBagTranslator; protected FlashBagTranslator $flashBagTranslator;
protected OrderShopFactory $orderShopFactory;


public function __construct( public function __construct(
EntityManagerInterface $entityManager, EntityManagerInterface $entityManager,
DistributionBuilder $distributionBuilder, DistributionBuilder $distributionBuilder,
MerchantResolver $merchantResolver, MerchantResolver $merchantResolver,
CreditHistoryBuilder $creditHistoryBuilder, CreditHistoryBuilder $creditHistoryBuilder,
FlashBagTranslator $flashBagTranslator
FlashBagTranslator $flashBagTranslator,
OrderShopFactory $orderShopFactory
) { ) {
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
$this->orderShopStore = $orderShopStore; $this->orderShopStore = $orderShopStore;
$this->merchantResolver = $merchantResolver; $this->merchantResolver = $merchantResolver;
$this->creditHistoryBuilder = $creditHistoryBuilder; $this->creditHistoryBuilder = $creditHistoryBuilder;
$this->flashBagTranslator = $flashBagTranslator; $this->flashBagTranslator = $flashBagTranslator;
$this->orderShopFactory = $orderShopFactory;
} }


public function create( public function create(
UserInterface $user = null, UserInterface $user = null,
VisitorInterface $visitor = null VisitorInterface $visitor = null
): OrderShopInterface { ): OrderShopInterface {
$orderShopFactory = new OrderShopFactory();
$orderShop = $orderShopFactory->create($section, $user, $visitor);
$orderShop = $this->orderShopFactory->create($section, $user, $visitor);


$this->setOrderStatus($orderShop, OrderStatusModel::ALIAS_CART); $this->setOrderStatus($orderShop, OrderStatusModel::ALIAS_CART);



+ 15
- 9
Definition/Field/Product/ProductCategoryFieldDefinition.php View File

public function configurePanelMain(): array public function configurePanelMain(): array
{ {
return [ return [
'section',
'parent',
'title',
'description',
'image',
'status',
'saleStatus',
'isEligibleTicketRestaurant',
'section',
'parent',
'title',
'description',
'image',
'status',
'saleStatus',
'isEligibleTicketRestaurant',
]; ];
} }


'title' => TextField::new('title')->setSortable(true), 'title' => TextField::new('title')->setSortable(true),
'position' => NumberField::new('position')->setSortable(true), 'position' => NumberField::new('position')->setSortable(true),
'parent' => AssociationField::new('parent') 'parent' => AssociationField::new('parent')
->setFormTypeOption('choices', $productCategoryArray),
->setFormTypeOption('choices', $productCategoryArray)
->setFormTypeOption(
'choice_label',
function ($productCategory) {
return $productCategory->getTitle() . ' (' . $productCategory->getSection() . ')';
}
),
'image' => ImageManagerField::new('image'), 'image' => ImageManagerField::new('image'),
'description' => CKEditorField::new('description'), 'description' => CKEditorField::new('description'),
'saleStatus' => ToggleField::new('saleStatus')->setSortable(true), 'saleStatus' => ToggleField::new('saleStatus')->setSortable(true),

+ 5
- 1
Solver/Product/ProductFamilySolver.php View File



public function getQuantityInherited(ProductFamilyInterface $productFamily): ?float public function getQuantityInherited(ProductFamilyInterface $productFamily): ?float
{ {
return $productFamily->getQuantity();
if($productFamily->getQuantity()){
return $productFamily->getQuantity();
}else{
return 1;
}
} }


public function getUnitInherited(ProductFamilyInterface $productFamily) public function getUnitInherited(ProductFamilyInterface $productFamily)

+ 3
- 1
Solver/Product/ProductSolver.php View File

{ {
if ($product->getQuantity()) { if ($product->getQuantity()) {
return $product->getQuantity(); return $product->getQuantity();
} else {
} else if($product->getProductFamily()->getQuantity()){
return $product->getProductFamily()->getQuantity(); return $product->getProductFamily()->getQuantity();
}else{
return 1;
} }
} }



Loading…
Cancel
Save