This commit is contained in:
Bernat 2019-09-03 09:15:05 +02:00
commit 6a07740549
11 changed files with 124 additions and 50 deletions

View File

@ -30,6 +30,9 @@
}, },
"isVolumetric": { "isVolumetric": {
"type": "Boolean" "type": "Boolean"
},
"inflation": {
"type": "Number"
} }
}, },
"relations": { "relations": {

View File

@ -5,7 +5,7 @@
form="form" form="form"
save="patch"> save="patch">
</vn-watcher> </vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()"> <form name="form" ng-submit="$ctrl.onSubmit()" compact>
<vn-card pad-large> <vn-card pad-large>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-two vn-focus <vn-textfield vn-two vn-focus
@ -62,7 +62,13 @@
</vn-input-number> </vn-input-number>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-check label="Volumetric" <vn-input-number vn-one
label="Inflation"
model="$ctrl.zone.inflation"
min="0" step="0.01"
vn-acl="deliveryBoss">
</vn-input-number>
<vn-check label="Volumetric" vn-one
field="$ctrl.zone.isVolumetric" field="$ctrl.zone.isVolumetric"
vn-acl="deliveryBoss"> vn-acl="deliveryBoss">
</vn-check> </vn-check>

View File

@ -11,3 +11,4 @@ New zone: Nueva zona
Volumetric: Volumétrico Volumetric: Volumétrico
Clone: Clonar Clone: Clonar
Search zone by id or name: Buscar zonas por identificador o nombre Search zone by id or name: Buscar zonas por identificador o nombre
Inflation: Inflación

View File

@ -44,9 +44,14 @@ module.exports = Self => {
description: 'The claim state id', description: 'The claim state id',
http: {source: 'query'} http: {source: 'query'}
}, { }, {
arg: 'workerFk', arg: 'salesPersonFk',
type: 'Integer', type: 'Integer',
description: 'The worker id', description: 'The salesPerson id',
http: {source: 'query'}
}, {
arg: 'attenderFk',
type: 'Integer',
description: 'The attender worker id',
http: {source: 'query'} http: {source: 'query'}
}, { }, {
arg: 'created', arg: 'created',
@ -86,7 +91,9 @@ module.exports = Self => {
return {'c.id': value}; return {'c.id': value};
case 'claimStateFk': case 'claimStateFk':
return {'cl.claimStateFk': value}; return {'cl.claimStateFk': value};
case 'workerFk': case 'salesPersonFk':
return {'c.salesPersonFk': value};
case 'attenderFk':
return {'cl.workerFk': value}; return {'cl.workerFk': value};
case 'created': case 'created':
return {'cl.created': value}; return {'cl.created': value};

View File

@ -36,7 +36,7 @@
search-function="{firstName: $search}" search-function="{firstName: $search}"
value-field="id" value-field="id"
where="{role: 'employee'}" where="{role: 'employee'}"
label="Worker"> label="Attended by">
</vn-autocomplete> </vn-autocomplete>
<vn-autocomplete <vn-autocomplete
vn-one vn-one

View File

@ -31,6 +31,27 @@
<vn-horizontal> <vn-horizontal>
<vn-autocomplete <vn-autocomplete
vn-one vn-one
field="filter.salesPersonFk"
url="/client/api/Clients/activeWorkersWithRole"
search-function="{firstName: $search}"
value-field="id"
where="{role: 'employee'}"
label="Salesperson">
<tpl-item>{{firstName}} {{name}}</tpl-item>
</vn-autocomplete>
<vn-autocomplete
vn-one
field="filter.attenderFk"
url="/client/api/Clients/activeWorkersWithRole"
search-function="{firstName: $search}"
value-field="id"
where="{role: 'employee'}"
label="Attended by">
<tpl-item>{{firstName}} {{name}}</tpl-item>
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one
label="State" label="State"
field="filter.claimStateFk" field="filter.claimStateFk"
url="/claim/api/ClaimStates" url="/claim/api/ClaimStates"
@ -38,18 +59,6 @@
value-field="id"> value-field="id">
<tpl-item>{{description}}</tpl-item> <tpl-item>{{description}}</tpl-item>
</vn-autocomplete> </vn-autocomplete>
<vn-autocomplete
vn-one
field="filter.workerFk"
url="/client/api/Clients/activeWorkersWithRole"
search-function="{firstName: $search}"
value-field="id"
where="{role: 'employee'}"
label="Worker">
<tpl-item>{{firstName}} {{name}}</tpl-item>
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-date-picker <vn-date-picker
vn-one vn-one
label="Created" label="Created"

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.totalUnitPrice += sale.price;
salesObj.totalNewPrice += sale.component.newPrice; salesObj.totalNewPrice += sale.component.newPrice;
salesObj.totalDifference += sale.component.difference; salesObj.totalDifference += sale.component.difference;
salesObj.totalUnitPrice = Math.round(salesObj.totalUnitPrice * 100) / 100; salesObj.totalUnitPrice = Math.round(salesObj.totalUnitPrice * 100) / 100;
salesObj.totalNewPrice = Math.round(salesObj.totalNewPrice * 100) / 100; salesObj.totalNewPrice = Math.round(salesObj.totalNewPrice * 100) / 100;
}
salesObj.totalUnitPrice += sale.price;
salesObj.totalDifference = Math.round(salesObj.totalDifference * 100) / 100; salesObj.totalDifference = Math.round(salesObj.totalDifference * 100) / 100;
}); });

View File

@ -35,8 +35,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) {
@ -184,8 +186,10 @@ class Controller {
this.ticket.agencyModeFk = null; this.ticket.agencyModeFk = null;
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;
}
}); });
} }
@ -214,6 +218,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(
@ -242,6 +271,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,6 +37,7 @@ class Controller {
getTotalDifferenceOfPrice() { getTotalDifferenceOfPrice() {
let totalPriceDifference = 0; let totalPriceDifference = 0;
this.ticket.sale.items.forEach(item => { this.ticket.sale.items.forEach(item => {
if (item.component)
totalPriceDifference += item.component.difference; totalPriceDifference += item.component.difference;
}); });
this.totalPriceDifference = totalPriceDifference; this.totalPriceDifference = totalPriceDifference;

View File

@ -19,6 +19,7 @@ Available: Disponible
In which day you want to add the ticket?: ¿A que dia quieres añadir el ticket? In which day you want to add the ticket?: ¿A que dia quieres añadir el ticket?
Add claim: Crear reclamación Add claim: Crear reclamación
Claim: Reclamación Claim: Reclamación
Transfer lines: Transferir líneas
Sales to transfer: Líneas a transferir Sales to transfer: Líneas a transferir
Destination ticket: Ticket destinatario Destination ticket: Ticket destinatario
Change ticket state to 'Ok': Cambiar estado del ticket a 'Ok' Change ticket state to 'Ok': Cambiar estado del ticket a 'Ok'