|
|
|
|
|
|
|
|
return thePrice; |
|
|
return thePrice; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
isFromQuantityExceeded: function(order, idProduct, theQuantity) { |
|
|
|
|
|
var product = this.getProduct(idProduct); |
|
|
|
|
|
var pricesArray = order.productOrder[idProduct].prices; |
|
|
|
|
|
var unitCoefficient = this.getUnitCoefficient(product.unit); |
|
|
|
|
|
if (theQuantity) { |
|
|
|
|
|
theQuantity = theQuantity / unitCoefficient; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(pricesArray) { |
|
|
|
|
|
for (var i = 0; i < pricesArray.length; i++) { |
|
|
|
|
|
var fromQuantity = pricesArray[i].from_quantity; |
|
|
|
|
|
if (fromQuantity && fromQuantity <= theQuantity) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
}, |
|
|
getProduct: function (idProduct) { |
|
|
getProduct: function (idProduct) { |
|
|
for (var i = 0; i < this.products.length; i++) { |
|
|
for (var i = 0; i < this.products.length; i++) { |
|
|
if (this.products[i].id == idProduct) { |
|
|
if (this.products[i].id == idProduct) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Vue.set(this.order.productOrder[id_product], 'quantity', theQuantity); |
|
|
Vue.set(this.order.productOrder[id_product], 'quantity', theQuantity); |
|
|
Vue.set(this.order.productOrder[id_product], 'price', app.getBestProductPrice(this.order, id_product, theQuantity, false)); |
|
|
|
|
|
Vue.set(this.order.productOrder[id_product], 'price_with_tax', app.getBestProductPrice(this.order, id_product, theQuantity, true)); |
|
|
|
|
|
|
|
|
if(app.isFromQuantityExceeded(this.order, id_product, theQuantity)) { |
|
|
|
|
|
Vue.set(this.order.productOrder[id_product], 'price', app.getBestProductPrice(this.order, id_product, theQuantity, false)); |
|
|
|
|
|
Vue.set(this.order.productOrder[id_product], 'price_with_tax', app.getBestProductPrice(this.order, id_product, theQuantity, true)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.updateProductOrders(false); |
|
|
this.updateProductOrders(false); |