|
|
@@ -80,6 +80,7 @@ var app = new Vue({ |
|
|
|
messageGenerateDeliveryNoteDisplayed: false, |
|
|
|
missingSubscriptions: false, |
|
|
|
loadingUpdateProductOrder: false, |
|
|
|
units: [], |
|
|
|
calendar: { |
|
|
|
mode: 'single', |
|
|
|
attrs: [], |
|
|
@@ -156,6 +157,7 @@ var app = new Vue({ |
|
|
|
axios.get("ajax-infos", {params: {date: this.getDate()}}) |
|
|
|
.then(function (response) { |
|
|
|
app.calendar.attrs = []; |
|
|
|
app.units = response.data.units; |
|
|
|
app.distribution = response.data.distribution; |
|
|
|
app.producer = response.data.producer; |
|
|
|
app.products = response.data.products; |
|
|
@@ -565,6 +567,16 @@ var app = new Vue({ |
|
|
|
this.showModalProducts = false; |
|
|
|
this.init(this.idActivePointSale); |
|
|
|
}, |
|
|
|
closeModalOrderForm: function(create) { |
|
|
|
if(create) { |
|
|
|
this.showModalFormOrderCreate = false |
|
|
|
} |
|
|
|
else { |
|
|
|
this.showModalFormOrderUpdate = false |
|
|
|
} |
|
|
|
|
|
|
|
this.init(this.idActivePointSale); |
|
|
|
}, |
|
|
|
cloneOrder: function (order) { |
|
|
|
var clone = Object.assign({}, order); |
|
|
|
|
|
|
@@ -788,7 +800,6 @@ var app = new Vue({ |
|
|
|
if (app.showModalFormOrderCreate) { |
|
|
|
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, false)); |
|
|
|
Vue.set(app.orderCreate.productOrder[idProduct], 'price_with_tax', app.getBestProductPrice(app.orderCreate, idProduct, app.orderCreate.productOrder[idProduct].quantity, true)); |
|
|
|
} |
|
|
@@ -798,7 +809,6 @@ var app = new Vue({ |
|
|
|
if (order.id == app.idOrderUpdate) { |
|
|
|
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'prices', response.data[idProduct].prices); |
|
|
|
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'active', response.data[idProduct].active); |
|
|
|
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'unit_coefficient', response.data[idProduct].unit_coefficient); |
|
|
|
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'invoice_price', response.data[idProduct].invoice_price); |
|
|
|
|
|
|
|
if (updatePricesOnUpdateOrder) { |
|
|
@@ -849,9 +859,11 @@ var app = new Vue({ |
|
|
|
} |
|
|
|
}, |
|
|
|
getBestProductPrice: function (order, idProduct, theQuantity, withTax) { |
|
|
|
var product = this.getProduct(idProduct); |
|
|
|
var thePrice = 9999; |
|
|
|
var pricesArray = order.productOrder[idProduct].prices; |
|
|
|
var unitCoefficient = order.productOrder[idProduct].unit_coefficient; |
|
|
|
|
|
|
|
var unitCoefficient = this.getUnitCoefficient(product.unit); |
|
|
|
if (theQuantity) { |
|
|
|
theQuantity = theQuantity / unitCoefficient; |
|
|
|
} |
|
|
@@ -870,7 +882,6 @@ var app = new Vue({ |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
var product = this.getProduct(idProduct); |
|
|
|
if (withTax) { |
|
|
|
thePrice = getPriceWithTax(product.price, product.taxRate.value); |
|
|
|
} else { |
|
|
@@ -909,6 +920,9 @@ var app = new Vue({ |
|
|
|
} |
|
|
|
|
|
|
|
return count; |
|
|
|
}, |
|
|
|
getUnitCoefficient: function(unit) { |
|
|
|
return this.units[unit].coefficient; |
|
|
|
} |
|
|
|
}, |
|
|
|
}); |
|
|
@@ -923,7 +937,7 @@ Vue.component('modal', { |
|
|
|
}); |
|
|
|
|
|
|
|
Vue.component('order-form', { |
|
|
|
props: ['date', 'dateFormat', 'pointsSale', 'idActivePointSale', 'meansPayment', 'users', 'products', 'order', 'orders', 'producer', 'loadingUpdateProductOrder', 'create'], |
|
|
|
props: ['date', 'dateFormat', 'pointsSale', 'idActivePointSale', 'meansPayment', 'users', 'products', 'order', 'orders', 'producer', 'loadingUpdateProductOrder', 'create', 'units'], |
|
|
|
emits: ['updateProductPrice', 'updateInvoicePrices'], |
|
|
|
data: function () { |
|
|
|
return { |
|
|
@@ -1132,23 +1146,32 @@ Vue.component('order-form', { |
|
|
|
} |
|
|
|
}, |
|
|
|
getProductQuantityRemaining: function(product) { |
|
|
|
var order = null; |
|
|
|
var app = this; |
|
|
|
var quantityRemaining = 0; |
|
|
|
var productQuantityOrder = 0; |
|
|
|
var unitCoefficient = 1; |
|
|
|
var unit = product.unit; |
|
|
|
|
|
|
|
for(key in app.orders) { |
|
|
|
order = app.orders[key]; |
|
|
|
unitCoefficient = order.productOrder[product.id].unit_coefficient; |
|
|
|
productQuantityOrder += order.productOrder[product.id].quantity / unitCoefficient; |
|
|
|
for(key in this.orders) { |
|
|
|
productQuantityOrder += this.getProductQuantityProductOrder(this.orders[key], product); |
|
|
|
} |
|
|
|
if(this.create == 1) { |
|
|
|
productQuantityOrder += this.getProductQuantityProductOrder(this.order, product); |
|
|
|
} |
|
|
|
|
|
|
|
if(app.create == 1) { |
|
|
|
unitCoefficient = app.order.productOrder[product.id].unit_coefficient; |
|
|
|
productQuantityOrder += app.order.productOrder[product.id].quantity / unitCoefficient; |
|
|
|
quantityRemaining = product.productDistribution[0].quantity_max - productQuantityOrder; |
|
|
|
if(unit != 'piece') { |
|
|
|
quantityRemaining = quantityRemaining.toFixed(2); |
|
|
|
} |
|
|
|
|
|
|
|
return product.productDistribution[0].quantity_max - productQuantityOrder; |
|
|
|
return quantityRemaining; |
|
|
|
}, |
|
|
|
getProductQuantityProductOrder: function(order, product) { |
|
|
|
var productOrder = order.productOrder[product.id]; |
|
|
|
var unit = productOrder.unit; |
|
|
|
var unitCoefficient = this.getUnitCoefficient(unit); |
|
|
|
return parseFloat(productOrder.quantity / unitCoefficient); |
|
|
|
}, |
|
|
|
getUnitCoefficient: function(unit) { |
|
|
|
return this.units[unit].coefficient; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |