Kaynağa Gözat

Amélioration gestion du stock

feature/export_comptable
Guillaume 4 yıl önce
ebeveyn
işleme
18d6532d18
3 değiştirilmiş dosya ile 20 ekleme ve 4 silme
  1. +4
    -2
      ShopBundle/Controller/Frontend/CartController.php
  2. +6
    -2
      ShopBundle/Services/Order/OrderUtils.php
  3. +10
    -0
      ShopBundle/Services/Order/OrderUtilsStockTrait.php

+ 4
- 2
ShopBundle/Controller/Frontend/CartController.php Dosyayı Görüntüle

@@ -74,8 +74,10 @@ class CartController extends BaseController
$data = $form->getData() ;
foreach($data as $orderProduct) {
if($orderProduct instanceof OrderProductInterface) {
$addOrderProduct = $this->orderUtils->addOrderProduct($orderShop, $orderProduct) ;
if($addOrderProduct && $orderProduct->getQuantityOrder() > 0) {
if($orderProduct->getQuantityOrder() > 0) {
$addOrderProduct = $this->orderUtils->addOrderProduct($orderShop, $orderProduct) ;
}
if(isset($addOrderProduct) && $addOrderProduct && $orderProduct->getQuantityOrder() > 0) {
$this->orderProducts[] = $orderProduct ;
}
}

+ 6
- 2
ShopBundle/Services/Order/OrderUtils.php Dosyayı Görüntüle

@@ -182,10 +182,14 @@ class OrderUtils
if($availableQuantity !== false && $availableQuantity > 0) {
$unit = '' ;
if($orderProductAdd->getProduct()->getProductFamily()->getBehaviorCountStock() == ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE) {
$unit = $orderProductAdd->getProduct()->getUnitInherited()->getUnit() ;
$unit = $orderProductAdd->getProduct()->getUnitInherited()->getUnitReference()->getUnit() ;
}
$textError .= ' dans cette quantité ' ;
$textError .= '<br />'.$availableQuantity.$unit.' disponible(s) dont '.$this->getQuantityOrderByProduct($orderShop, $orderProductAdd->getProduct()).$unit.' déjà dans votre panier.' ;

$user = $this->security->getUser() ;
if($user && $user->hasRole('ROLE_USER')) {
$textError .= '<br />'.$availableQuantity.$unit.' disponible(s) dont '.$this->getQuantityOrderByProduct($orderShop, $orderProductAdd->getProduct()).$unit.' déjà dans votre panier.' ;
}
}
$this->utils->addFlash('error', $textError);
}

+ 10
- 0
ShopBundle/Services/Order/OrderUtilsStockTrait.php Dosyayı Görüntüle

@@ -159,5 +159,15 @@ trait OrderUtilsStockTrait
return $product->getAvailableQuantityInherited() - $this->getQuantityOrderByProduct($orderShop, $product, $byWeight) ;
}

public function getProductQuantity($product) {

$productFamily = $product->getProductFamily() ;

if($productFamily->getBehaviorCountStock() == ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE) {
return $product->getQuantityInherited() / $product->getUnitInherited()->getCoefficient() ;
}
else {
return 1 ;
}
}
}

Yükleniyor…
İptal
Kaydet