Browse Source

Reduction Cart : gestion des quantités disponibles

feature/export_comptable
Guillaume 4 years ago
parent
commit
31e74facbd
4 changed files with 7 additions and 5 deletions
  1. +1
    -1
      ShopBundle/Controller/Backend/OrderController.php
  2. +1
    -1
      ShopBundle/Model/AbstractEntity.php
  3. +2
    -2
      ShopBundle/Repository/OrderShopRepository.php
  4. +3
    -1
      ShopBundle/Repository/ReductionCartRepository.php

+ 1
- 1
ShopBundle/Controller/Backend/OrderController.php View File

@@ -290,7 +290,7 @@ class OrderController extends AdminController
if ($formOrderReductionCart->isSubmitted() && $formOrderReductionCart->isValid()) {
$reductionCart = $formOrderReductionCart->get('reductionCart')->getData();
$orderShop->reductionError = array();
if ($this->orderUtils->isReductionCartAllowToBeAddToOrder($orderShop, $reductionCart)) {
if ($this->orderUtils->isReductionCartAllowAddToOrder($orderShop, $reductionCart)) {
$orderReductionCart = $this->orderUtils->createOrderReductionCart($orderShop, $reductionCart);
$this->em->persist($orderReductionCart);
$this->em->flush();

+ 1
- 1
ShopBundle/Model/AbstractEntity.php View File

@@ -40,7 +40,7 @@ abstract class AbstractEntity
protected $updatedBy;


public function addError($message, $domain = 'lcshop', $params){
public function addError($message, $domain = 'lcshop', $params = []){
$this->errors[] = array(
'message'=> $message,
'domain'=> $domain,

+ 2
- 2
ShopBundle/Repository/OrderShopRepository.php View File

@@ -43,7 +43,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
$query = $this->findByMerchantQuery();
$query = $this->filterOrderValid($query);
$query->select('count(e.id)');
$query->join('e.orderReductionCart', 'orc');
$query->join('e.orderReductionCarts', 'orc');
$query->andWhere('orc.reductionCart = :reductionCart');
$query->setParameter('reductionCart', $reductionCart);
return $query->getQuery()->getSingleScalarResult();
@@ -55,7 +55,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
$query = $this->filterOrderValid($query);
$query->select('count(e.id)');
$query->andWhere('e.user = :user');
$query->join('e.orderReductionCart', 'orc');
$query->join('e.orderReductionCarts', 'orc');
$query->andWhere('orc.reductionCart = :reductionCart');
$query->setParameter('reductionCart', $reductionCart);
$query->setParameter('user', $user);

+ 3
- 1
ShopBundle/Repository/ReductionCartRepository.php View File

@@ -69,7 +69,9 @@ class ReductionCartRepository extends BaseRepository implements DefaultRepositor
$reductionCartsArray = [] ;
foreach($reductionCarts as $reductionCart) {
if($this->orderUtils->isReductionCartMatchWithUser($reductionCart, $user)
&& $this->orderUtils->isReductionCartMatchWithGroupUser($reductionCart, $user)) {
&& $this->orderUtils->isReductionCartMatchWithGroupUser($reductionCart, $user)
&& $this->orderUtils->countReductionCartAvailableForUser($reductionCart, $user)) {

$reductionCartsArray[] = $reductionCart ;
}
}

Loading…
Cancel
Save