Kaynağa Gözat

[Administration] Distributions : correctif bug changement de prix

develop
Guillaume Bourgeois 4 ay önce
ebeveyn
işleme
c1218219c3
1 değiştirilmiş dosya ile 54 ekleme ve 43 silme
  1. +54
    -43
      backend/web/js/vuejs/distribution-index.js

+ 54
- 43
backend/web/js/vuejs/distribution-index.js Dosyayı Görüntüle

@@ -83,6 +83,8 @@ if($(selector).length) {
messageGenerateDeliveryNoteDisplayed: false,
missingSubscriptions: false,
loadingUpdateProductOrder: false,
timerAjaxUpdateProductOrder: null,
xhr: null,
units: [],
calendar: {
mode: 'single',
@@ -858,7 +860,7 @@ if($(selector).length) {
}
return JSON.stringify(productOrderArrayRequest);
},
updateProductOrders: function (updatePricesOnUpdateOrder) {
updateProductOrders: function (updatePrices) {
var app = this;
app.loadingUpdateProductOrder = true;
var order = null;
@@ -876,57 +878,66 @@ if($(selector).length) {
}

if (order) {
axios.get(UrlManager.getBaseUrlAbsolute() + "distribution/ajax-update-product-order", {
params: {
idDistribution: app.distribution.id,
idUser: order.id_user,
idPointSale: order.id_point_sale,
idOrder: order.id,
productOrderFormArray: app.getProductOrderArrayRequest(order)
if (app.timerAjaxUpdateProductOrder) {
clearTimeout(app.timerAjaxUpdateProductOrder);
}
app.timerAjaxUpdateProductOrder = setTimeout(function(app) {
if(app.xhr) {
app.xhr.abort();
}
})
.then(function (response) {
if (response.data) {
for (idProduct in response.data) {

if (app.showModalFormOrderCreate) {
Vue.set(app.orderCreate.productOrder[idProduct], 'quantity_remaining', response.data[idProduct].quantity_remaining);
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], '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));
}
app.xhr = $.get(UrlManager.getBaseUrlAbsolute() + "distribution/ajax-update-product-order", {
idDistribution: app.distribution.id,
idUser: order.id_user,
idPointSale: order.id_point_sale,
idOrder: order.id,
productOrderFormArray: app.getProductOrderArrayRequest(order)
}, function (response) {
if (response) {
for (idProduct in response) {

if (app.showModalFormOrderCreate) {
Vue.set(app.orderCreate.productOrder[idProduct], 'quantity_remaining', response[idProduct].quantity_remaining);
Vue.set(app.orderCreate.productOrder[idProduct], 'prices', response[idProduct].prices);
Vue.set(app.orderCreate.productOrder[idProduct], 'active', response[idProduct].active);

if(updatePrices) {
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));
}
}

if (app.showModalFormOrderUpdate && app.idOrderUpdate) {
for (keyOrderUpdate in app.ordersUpdate) {
if (order.id == app.idOrderUpdate) {
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'quantity_remaining', response.data[idProduct].quantity_remaining);
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], 'invoice_price', response.data[idProduct].invoice_price);

if (updatePricesOnUpdateOrder) {
Vue.set(
app.ordersUpdate[keyOrderUpdate].productOrder[idProduct],
'price',
app.getBestProductPrice(app.ordersUpdate[keyOrderUpdate], idProduct, app.ordersUpdate[keyOrderUpdate].productOrder[idProduct].quantity, false));
Vue.set(
app.ordersUpdate[keyOrderUpdate].productOrder[idProduct],
'price_with_tax',
app.getBestProductPrice(app.ordersUpdate[keyOrderUpdate], idProduct, app.ordersUpdate[keyOrderUpdate].productOrder[idProduct].quantity, true));
if (app.showModalFormOrderUpdate && app.idOrderUpdate) {
for (keyOrderUpdate in app.ordersUpdate) {
if (order.id == app.idOrderUpdate) {
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'quantity_remaining', response[idProduct].quantity_remaining);
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'prices', response[idProduct].prices);
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'active', response[idProduct].active);
Vue.set(app.ordersUpdate[keyOrderUpdate].productOrder[idProduct], 'invoice_price', response[idProduct].invoice_price);

if (updatePrices) {
Vue.set(
app.ordersUpdate[keyOrderUpdate].productOrder[idProduct],
'price',
app.getBestProductPrice(app.ordersUpdate[keyOrderUpdate], idProduct, app.ordersUpdate[keyOrderUpdate].productOrder[idProduct].quantity, false));
Vue.set(
app.ordersUpdate[keyOrderUpdate].productOrder[idProduct],
'price_with_tax',
app.getBestProductPrice(app.ordersUpdate[keyOrderUpdate], idProduct, app.ordersUpdate[keyOrderUpdate].productOrder[idProduct].quantity, true));
}
}
}
}
}
}

if (updatePricesOnUpdateOrder) {
appAlerts.alert('info', 'Prix rechargés');
if (updatePrices) {
appAlerts.alert('info', 'Prix rechargés');
}
}
}

app.loadingUpdateProductOrder = false;
});
app.loadingUpdateProductOrder = false;
}, 'json');
}.bind(this, app), 500);
}
},
updateInvoicePrices: function () {

Yükleniyor…
İptal
Kaydet