ticket.basicData Update zone on changes + fixes #1668
gitea/salix/master This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-09-02 14:36:54 +02:00
parent 8726aa70c5
commit 7b40fe2942
4 changed files with 78 additions and 31 deletions

View File

@ -94,14 +94,16 @@ module.exports = Self => {
salesObj.items.forEach(sale => { salesObj.items.forEach(sale => {
const difComponent = map.get(sale.id); const difComponent = map.get(sale.id);
if (difComponent) if (difComponent) {
sale.component = difComponent; sale.component = difComponent;
salesObj.totalNewPrice += sale.component.newPrice;
salesObj.totalDifference += sale.component.difference;
salesObj.totalUnitPrice = Math.round(salesObj.totalUnitPrice * 100) / 100;
salesObj.totalNewPrice = Math.round(salesObj.totalNewPrice * 100) / 100;
}
salesObj.totalUnitPrice += sale.price; salesObj.totalUnitPrice += sale.price;
salesObj.totalNewPrice += sale.component.newPrice;
salesObj.totalDifference += sale.component.difference;
salesObj.totalUnitPrice = Math.round(salesObj.totalUnitPrice * 100) / 100;
salesObj.totalNewPrice = Math.round(salesObj.totalNewPrice * 100) / 100;
salesObj.totalDifference = Math.round(salesObj.totalDifference * 100) / 100; salesObj.totalDifference = Math.round(salesObj.totalDifference * 100) / 100;
}); });

View File

@ -36,8 +36,7 @@
label="Warehouse" label="Warehouse"
show-field="name" show-field="name"
value-field="id" value-field="id"
field="$ctrl.ticket.warehouseFk" field="$ctrl.warehouseId">
initial-data="$ctrl.ticket.warehouseFk">
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>

View File

@ -39,11 +39,21 @@ class Controller {
this.onChangeClient(value); this.onChangeClient(value);
} }
set shipped(value) { get warehouseId() {
this.ticket.shipped = value; if (this.ticket)
this.onChangeShipped(value); return this.ticket.warehouseFk;
return null;
} }
set warehouseId(id) {
if (id != this.ticket.warehouseFk) {
this.ticket.warehouseFk = id;
this.onChangeWarehouse(id);
}
}
get shipped() { get shipped() {
if (this.ticket) if (this.ticket)
return this.ticket.shipped; return this.ticket.shipped;
@ -51,6 +61,11 @@ class Controller {
return null; return null;
} }
set shipped(value) {
this.ticket.shipped = value;
this.onChangeShipped(value);
}
get landed() { get landed() {
if (this.ticket) if (this.ticket)
return this.ticket.landed; return this.ticket.landed;
@ -120,23 +135,6 @@ class Controller {
}); });
} }
/*
* Returns a landing date
*/
getLanded(params) {
let query = `/api/Agencies/getLanded`;
return this.$http.get(query, {params});
}
/*
* Returns a shipment date
*/
getShipped(params) {
let query = `/api/Agencies/getShipped`;
return this.$http.get(query, {params});
}
onChangeShipped(shipped) { onChangeShipped(shipped) {
let params = { let params = {
shipped: shipped, shipped: shipped,
@ -144,6 +142,8 @@ class Controller {
agencyModeFk: this.ticket.agencyModeFk, agencyModeFk: this.ticket.agencyModeFk,
warehouseFk: this.ticket.warehouseFk warehouseFk: this.ticket.warehouseFk
}; };
this.ticket.zoneFk = null;
let query = `/api/Agencies/getLanded`; let query = `/api/Agencies/getLanded`;
this.$http.get(query, {params}).then(res => { this.$http.get(query, {params}).then(res => {
if (res.data && res.data.landed) { if (res.data && res.data.landed) {
@ -164,6 +164,8 @@ class Controller {
agencyModeFk: this.ticket.agencyModeFk, agencyModeFk: this.ticket.agencyModeFk,
warehouseFk: this.ticket.warehouseFk warehouseFk: this.ticket.warehouseFk
}; };
this.ticket.zoneFk = null;
let query = `/api/Agencies/getShipped`; let query = `/api/Agencies/getShipped`;
this.$http.get(query, {params}).then(res => { this.$http.get(query, {params}).then(res => {
if (res.data) { if (res.data) {
@ -183,8 +185,10 @@ class Controller {
onChangeZone(zoneId) { onChangeZone(zoneId) {
const query = `/api/Zones/${zoneId}`; const query = `/api/Zones/${zoneId}`;
this.$http.get(query).then(res => { this.$http.get(query).then(res => {
if (res.data) if (res.data) {
this.ticket.agencyModeFk = res.data.agencyModeFk; this.ticket.agencyModeFk = res.data.agencyModeFk;
this.ticket.warehouseFk = res.data.warehouseFk;
}
}); });
} }
@ -212,6 +216,31 @@ class Controller {
}); });
} }
/*
* Gets a zone from an agency
*/
onChangeWarehouse(warehouseId) {
let params = {
landed: this.ticket.landed,
addressFk: this.ticket.addressFk,
agencyModeFk: this.ticket.agencyModeFk,
warehouseFk: warehouseId
};
this.ticket.zoneFk = null;
let query = `/api/Agencies/getShipped`;
this.$http.get(query, {params}).then(res => {
if (res.data)
this.ticket.zoneFk = res.data.id;
if (!res.data) {
this.vnApp.showMessage(
this.$translate.instant('No delivery zone available for this parameters')
);
}
});
}
async onStepChange() { async onStepChange() {
if (this.isFormInvalid()) { if (this.isFormInvalid()) {
return this.vnApp.showError( return this.vnApp.showError(
@ -240,6 +269,22 @@ class Controller {
}); });
} }
/*
* Returns a landing date
*/
getLanded(params) {
let query = `/api/Agencies/getLanded`;
return this.$http.get(query, {params});
}
/*
* Returns a shipment date
*/
getShipped(params) {
let query = `/api/Agencies/getShipped`;
return this.$http.get(query, {params});
}
isFormInvalid() { isFormInvalid() {
return !this.ticket.clientFk || !this.ticket.addressFk || !this.ticket.agencyModeFk return !this.ticket.clientFk || !this.ticket.addressFk || !this.ticket.agencyModeFk
|| !this.ticket.companyFk || !this.ticket.shipped || !this.ticket.landed || !this.ticket.companyFk || !this.ticket.shipped || !this.ticket.landed

View File

@ -28,8 +28,8 @@ class Controller {
getTotalNewPrice() { getTotalNewPrice() {
let totalNewPrice = 0; let totalNewPrice = 0;
this.ticket.sale.items.forEach(item => { this.ticket.sale.items.forEach(item => {
let itemTotalNewPrice = item.quantity * item.component.newPrice; if (item.component)
totalNewPrice += itemTotalNewPrice; totalNewPrice += item.quantity * item.component.newPrice;
}); });
this.totalNewPrice = totalNewPrice; this.totalNewPrice = totalNewPrice;
} }
@ -37,7 +37,8 @@ class Controller {
getTotalDifferenceOfPrice() { getTotalDifferenceOfPrice() {
let totalPriceDifference = 0; let totalPriceDifference = 0;
this.ticket.sale.items.forEach(item => { this.ticket.sale.items.forEach(item => {
totalPriceDifference += item.component.difference; if (item.component)
totalPriceDifference += item.component.difference;
}); });
this.totalPriceDifference = totalPriceDifference; this.totalPriceDifference = totalPriceDifference;
} }