소스 검색

Gestion des accessoires

feature/rotating_product
Guillaume Bourgeois 5 달 전
부모
커밋
a191eae5b0
3개의 변경된 파일20개의 추가작업 그리고 18개의 파일을 삭제
  1. +4
    -0
      backend/views/distribution/index.php
  2. +0
    -5
      backend/web/js/vuejs/distribution-index.js
  3. +16
    -13
      domain/Order/Order/OrderResolver.php

+ 4
- 0
backend/views/distribution/index.php 파일 보기

@@ -151,6 +151,10 @@ $this->setPageTitle('Distributions') ;
<input type="text" class="form-control quantity-max" placeholder="&infin;" :data-id-product="product.id" v-model="getProductDistribution(product).quantity_max" @keyup="productQuantityMaxChange" />
<span class="input-group-addon">{{ (product.unit == 'piece') ? 'p.' : ' '+((product.unit == 'g' || product.unit == 'kg') ? 'kg' : 'litre(s)') }}</span>
</div>
<div v-if=" false && getProductDistribution(product).quantity_max != product.quantity_max">
Limitation accessoires : <br />
{{ product.quantity_max }}
</div>
</td>
</tr>
</tbody>

+ 0
- 5
backend/web/js/vuejs/distribution-index.js 파일 보기

@@ -1235,11 +1235,6 @@ if($(selector).length) {
}
},
getProductQuantityMax: function(product) {
//var quantityMax = this.getProductDistribution(product).quantity_max;

// Gestion quantité max accessoires
// ...

return product.quantity_max;
},
getProductQuantityOrder: function(product) {

+ 16
- 13
domain/Order/Order/OrderResolver.php 파일 보기

@@ -36,12 +36,10 @@ class OrderResolver extends AbstractResolver
{
$smallestQuantity = null;

if($this->featureChecker->isEnabled(Feature::ALIAS_PRODUCT_ACCESSORY)) {
foreach ($product->getProductAccessories() as $productAccessory) {
$quantityAccessory = $productAccessory->getAccessory()->getQuantity();
$smallestQuantity = is_null($smallestQuantity) ? $quantityAccessory
: min($smallestQuantity, $quantityAccessory);
}
foreach ($product->getProductAccessories() as $productAccessory) {
$quantityAccessory = $productAccessory->getAccessory()->getQuantity();
$smallestQuantity = is_null($smallestQuantity) ? $quantityAccessory
: min($smallestQuantity, $quantityAccessory);
}

return $smallestQuantity;
@@ -50,15 +48,18 @@ class OrderResolver extends AbstractResolver
public function getProductQuantityMax(Product $product, Distribution $distribution): ?float
{
$productDistribution = $this->productDistributionRepository->findOneProductDistribution($distribution, $product);
// @TODO : gérer via une exception
if(!$productDistribution) {
return null;
}

$quantityMax = $productDistribution->quantity_max;
$smallestQuantityAccessory = $this->getSmallestQuantityAccessory($product);

if(!is_null($smallestQuantityAccessory)) {
$quantityMax = is_null($quantityMax) ? $smallestQuantityAccessory : min($quantityMax, $smallestQuantityAccessory);
if($this->featureChecker->isEnabled(Feature::ALIAS_PRODUCT_ACCESSORY)) {
$smallestQuantityAccessory = $this->getSmallestQuantityAccessory($product);
if (!is_null($smallestQuantityAccessory)) {
$quantityMax = is_null($quantityMax) ? $smallestQuantityAccessory : min($quantityMax, $smallestQuantityAccessory);
}
}

return $quantityMax;
@@ -105,10 +106,12 @@ class OrderResolver extends AbstractResolver
: ($productDistribution->quantity_max - $quantityOrder);

// Limitation par nombre d'accessoires disponibles
$smallestQuantityAccessoryAvailable = $this->getSmallestQuantityAccessoryAvailable($product, $distribution);
if(!is_null($smallestQuantityAccessoryAvailable)) {
$quantityRemaining = is_null($quantityRemaining) ? $smallestQuantityAccessoryAvailable
: min($quantityRemaining, $smallestQuantityAccessoryAvailable);
if($this->featureChecker->isEnabled(Feature::ALIAS_PRODUCT_ACCESSORY)) {
$smallestQuantityAccessoryAvailable = $this->getSmallestQuantityAccessoryAvailable($product, $distribution);
if (!is_null($smallestQuantityAccessoryAvailable)) {
$quantityRemaining = is_null($quantityRemaining) ? $smallestQuantityAccessoryAvailable
: min($quantityRemaining, $smallestQuantityAccessoryAvailable);
}
}

return $quantityRemaining;

Loading…
취소
저장