@@ -10,7 +10,6 @@ use domain\Feature\Feature\FeatureChecker; | |||
use domain\Product\Accessory\Accessory; | |||
use domain\Product\Product\Product; | |||
use domain\Product\Product\ProductSolver; | |||
use yii\base\ErrorException; | |||
class OrderResolver extends AbstractResolver | |||
{ | |||
@@ -93,8 +92,14 @@ class OrderResolver extends AbstractResolver | |||
public function getProductQuantityMaxOrderable(Product $product, Distribution $distribution, Order $orderCurrent = null): ?float | |||
{ | |||
return $this->orderSolver->getProductQuantity($product, $orderCurrent ? [$orderCurrent] : []) | |||
+ $this->getProductQuantityRemaining($product, $distribution, $orderCurrent); | |||
$productQuantity = $this->orderSolver->getProductQuantity($product, $orderCurrent ? [$orderCurrent] : []); | |||
$productQuantityRemaining = $this->getProductQuantityRemaining($product, $distribution, $orderCurrent); | |||
if(is_null($productQuantityRemaining)) { | |||
return null; | |||
} | |||
return $productQuantity + $productQuantityRemaining; | |||
} | |||
public function getQuantityOfAccessoryAvailableInDistribution( |
@@ -354,7 +354,7 @@ $this->setMeta('description', $producerModule->getSeoGenerator()->generateMetaDe | |||
<span v-if="product.weight">({{ product.weight }} g)</span> | |||
</span> | |||
<div> | |||
<span v-if="product.quantity_max > 0 && (product.quantity_remaining <= 0 || product.quantity_remaining * product.coefficient_unit < product.step)" | |||
<span v-if="product.quantity_max != null && (product.quantity_remaining <= 0 || product.quantity_remaining * product.coefficient_unit < product.step)" | |||
class="badge bg-danger">Épuisé</span> | |||
</div> | |||
<div class="description" v-if="product.description.length"> | |||
@@ -412,7 +412,7 @@ $this->setMeta('description', $producerModule->getSeoGenerator()->generateMetaDe | |||
<button class="btn btn-secondary btn-plus" | |||
type="button" | |||
@click="productQuantityClick(product, product.unit == 'piece' ? 1 : parseFloat(product.step))" | |||
:disabled="loadingProducts || product.quantity_remaining <= 0 || product.quantity_form >= product.quantity_max * product.coefficient_unit"> | |||
:disabled="loadingProducts || (product.quantity_remaining != null && product.quantity_remaining <= 0) || (product.quantity_max != null && product.quantity_form >= product.quantity_max * product.coefficient_unit)"> | |||
<i class="bi bi-plus-lg"></i></button> | |||
</span> | |||
</div> |
@@ -524,9 +524,10 @@ var app = new Vue({ | |||
}, | |||
productQuantityClick: function(product, quantity) { | |||
if(this.products[product.index].quantity_form + quantity >= 0 | |||
&& this.products[product.index].quantity_form + quantity <= this.products[product.index].quantity_max * this.products[product.index].coefficient_unit | |||
&& (quantity <= (this.products[product.index].quantity_remaining * this.products[product.index].coefficient_unit) | |||
|| this.products[product.index].quantity_remaining == null) | |||
&& (this.products[product.index].quantity_max == null | |||
|| this.products[product.index].quantity_form + quantity <= this.products[product.index].quantity_max * this.products[product.index].coefficient_unit) | |||
&& (this.products[product.index].quantity_remaining == null | |||
|| (quantity <= (this.products[product.index].quantity_remaining * this.products[product.index].coefficient_unit))) | |||
) { | |||
var theQuantity = parseFloat(this.products[product.index].quantity_form) + parseFloat(quantity); | |||
this.products[product.index].quantity_form = parseFloat(theQuantity.toFixed(2)) ; |