|
|
@@ -602,6 +602,7 @@ var app = new Vue({ |
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'prices', response.data[idProduct].prices); |
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'active', response.data[idProduct].active); |
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'unit_coefficient', response.data[idProduct].unit_coefficient); |
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'price', app.getBestProductPrice(app.orderCreate, idProduct, app.orderCreate.productOrder[idProduct].quantity)); |
|
|
|
} |
|
|
|
|
|
|
|
if (app.showModalFormOrderUpdate && app.idOrderUpdate) { |
|
|
@@ -619,7 +620,31 @@ var app = new Vue({ |
|
|
|
app.loadingUpdateProductOrder = false; |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
getBestProductPrice: function(order, idProduct, theQuantity) { |
|
|
|
var thePriceWithTax = 9999; |
|
|
|
var pricesArray = order.productOrder[idProduct].prices; |
|
|
|
var unitCoefficient = order.productOrder[idProduct].unit_coefficient; |
|
|
|
if(theQuantity) { |
|
|
|
theQuantity = theQuantity / unitCoefficient; |
|
|
|
} |
|
|
|
|
|
|
|
for(var i = 0; i < pricesArray.length ; i++) { |
|
|
|
var priceWithTax = pricesArray[i].price_with_tax; |
|
|
|
var fromQuantity = pricesArray[i].from_quantity; |
|
|
|
|
|
|
|
if(priceWithTax < thePriceWithTax && fromQuantity <= theQuantity) { |
|
|
|
thePriceWithTax = priceWithTax; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(thePriceWithTax == 9999) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
else { |
|
|
|
return thePriceWithTax; |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
@@ -629,6 +654,7 @@ Vue.component('modal', { |
|
|
|
|
|
|
|
Vue.component('order-form',{ |
|
|
|
props: ['date', 'pointsSale','meansPayment', 'users', 'products', 'order', 'producer', 'loadingUpdateProductOrder'], |
|
|
|
emits: ['updateProductPrice'], |
|
|
|
data: function() { |
|
|
|
return { |
|
|
|
errors: [], |
|
|
@@ -736,37 +762,8 @@ Vue.component('order-form',{ |
|
|
|
theQuantity = parseInt(theQuantity); |
|
|
|
} |
|
|
|
|
|
|
|
Vue.set(this.order.productOrder, id_product, { |
|
|
|
quantity: theQuantity, |
|
|
|
unit: this.order.productOrder[id_product].unit, |
|
|
|
unit_coefficient: this.order.productOrder[id_product].unit_coefficient, |
|
|
|
prices: this.order.productOrder[id_product].prices, |
|
|
|
price: this.getBestProductPrice(id_product, theQuantity), |
|
|
|
active: this.order.productOrder[id_product].active |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
getBestProductPrice: function(id_product, theQuantity) { |
|
|
|
var thePriceWithTax = 9999; |
|
|
|
var pricesArray = this.order.productOrder[id_product].prices; |
|
|
|
var unitCoefficient = this.order.productOrder[id_product].unit_coefficient; |
|
|
|
if(theQuantity) { |
|
|
|
theQuantity = theQuantity / unitCoefficient; |
|
|
|
} |
|
|
|
|
|
|
|
for(var i = 0; i < pricesArray.length ; i++) { |
|
|
|
var priceWithTax = pricesArray[i].price_with_tax; |
|
|
|
var fromQuantity = pricesArray[i].from_quantity; |
|
|
|
|
|
|
|
if(priceWithTax < thePriceWithTax && fromQuantity <= theQuantity) { |
|
|
|
thePriceWithTax = priceWithTax; |
|
|
|
} |
|
|
|
} |
|
|
|
if(thePriceWithTax == 9999) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
else { |
|
|
|
return thePriceWithTax; |
|
|
|
Vue.set(this.order.productOrder[id_product], 'quantity', theQuantity); |
|
|
|
Vue.set(this.order.productOrder[id_product], 'price', app.getBestProductPrice(this.order, id_product, theQuantity)); |
|
|
|
} |
|
|
|
}, |
|
|
|
productPriceChange: function(event) { |