Merge pull request '2622-route_tickets_refactor' (#486) from 2622-route_tickets_refactor into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #486 Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
commit
564ca3a511
|
@ -161,6 +161,7 @@
|
||||||
"The nif cannot be empty": "El NIF no puede quedar en blanco",
|
"The nif cannot be empty": "El NIF no puede quedar en blanco",
|
||||||
"You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados",
|
"You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados",
|
||||||
"ASSIGN_ZONE_FIRST": "Asigna una zona primero",
|
"ASSIGN_ZONE_FIRST": "Asigna una zona primero",
|
||||||
|
"You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria",
|
||||||
"You can't upload images on the test environment": "No puedes subir imágenes en el entorno de pruebas",
|
"You can't upload images on the test environment": "No puedes subir imágenes en el entorno de pruebas",
|
||||||
"You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria"
|
"Sorts whole route": "Reordena ruta entera"
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('guessPriority', {
|
Self.remoteMethodCtx('guessPriority', {
|
||||||
description: 'Changes automatically the priority of the tickets in a route',
|
description: 'Changes automatically the priority of the tickets in a route',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
|
@ -19,10 +19,32 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.guessPriority = async id => {
|
Self.guessPriority = async(ctx, id) => {
|
||||||
let query = `CALL vn.routeGuessPriority(?)`;
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
const $t = ctx.req.__; // $translate
|
||||||
|
const query = `CALL vn.routeGuessPriority(?)`;
|
||||||
|
const tx = await Self.beginTransaction({});
|
||||||
|
|
||||||
let options = [id];
|
try {
|
||||||
return await Self.rawSql(query, options);
|
let options = {transaction: tx};
|
||||||
|
|
||||||
|
const priority = await Self.rawSql(query, [id], options);
|
||||||
|
|
||||||
|
let logRecord = {
|
||||||
|
originFk: id,
|
||||||
|
userFk: userId,
|
||||||
|
action: 'update',
|
||||||
|
changedModel: 'Route',
|
||||||
|
description: $t('Sorts whole route')
|
||||||
|
};
|
||||||
|
|
||||||
|
await Self.app.models.RouteLog.create(logRecord, options);
|
||||||
|
|
||||||
|
await tx.commit();
|
||||||
|
return priority;
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,9 +15,15 @@ describe('route guessPriority()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call guessPriority() and then check the tickets in the target route now have their priorities defined', async() => {
|
it('should call guessPriority() and then check the tickets in the target route now have their priorities defined', async() => {
|
||||||
|
const ctx = {
|
||||||
|
req: {
|
||||||
|
accessToken: {userId: 9},
|
||||||
|
__: () => {}
|
||||||
|
},
|
||||||
|
};
|
||||||
routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}});
|
routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}});
|
||||||
|
|
||||||
await app.models.Route.guessPriority(targetRouteId);
|
await app.models.Route.guessPriority(ctx, targetRouteId);
|
||||||
let routeTickets = await app.models.Ticket.find({where: {routeFk: targetRouteId}, fields: ['id', 'priority']});
|
let routeTickets = await app.models.Ticket.find({where: {routeFk: targetRouteId}, fields: ['id', 'priority']});
|
||||||
|
|
||||||
expect(routeTickets.length).toEqual(2);
|
expect(routeTickets.length).toEqual(2);
|
||||||
|
|
|
@ -31,13 +31,13 @@
|
||||||
model="model">
|
model="model">
|
||||||
</vn-multi-check>
|
</vn-multi-check>
|
||||||
</vn-th>
|
</vn-th>
|
||||||
<vn-th shrink>Order</vn-th>
|
<vn-th class="order-field">Order</vn-th>
|
||||||
<vn-th number>Ticket</vn-th>
|
<vn-th number>Ticket</vn-th>
|
||||||
<vn-th expand>Client</vn-th>
|
<vn-th expand>Client</vn-th>
|
||||||
<vn-th shrink>Packages</vn-th>
|
<vn-th shrink>Packages</vn-th>
|
||||||
<vn-th number>m³</vn-th>
|
<vn-th shrink>m³</vn-th>
|
||||||
<vn-th>Warehouse</vn-th>
|
<vn-th>Warehouse</vn-th>
|
||||||
<vn-th>Postcode</vn-th>
|
<vn-th translate-attr="{title: 'Postcode'}" shrink>PC</vn-th>
|
||||||
<vn-th expand>Street</vn-th>
|
<vn-th expand>Street</vn-th>
|
||||||
<vn-th shrink></vn-th>
|
<vn-th shrink></vn-th>
|
||||||
<vn-th shrink></vn-th>
|
<vn-th shrink></vn-th>
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
ng-model="ticket.checked">
|
ng-model="ticket.checked">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td shrink>
|
<vn-td class="order-field">
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
on-change="$ctrl.setPriority(ticket.id, ticket.priority)"
|
on-change="$ctrl.setPriority(ticket.id, ticket.priority)"
|
||||||
ng-model="ticket.priority"
|
ng-model="ticket.priority"
|
||||||
|
@ -73,9 +73,9 @@
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td shrink>{{ticket.packages}}</vn-td>
|
<vn-td shrink>{{ticket.packages}}</vn-td>
|
||||||
<vn-td number>{{::ticket.volume | number:1}}</vn-td>
|
<vn-td shrink>{{::ticket.volume | number:1}}</vn-td>
|
||||||
<vn-td expand>{{ticket.warehouse.name}}</vn-td>
|
<vn-td expand>{{ticket.warehouse.name}}</vn-td>
|
||||||
<vn-td>{{ticket.address.postalCode}}</vn-td>
|
<vn-td shrink>{{ticket.address.postalCode}}</vn-td>
|
||||||
<vn-td expand title="{{ticket.address.street}}">{{ticket.address.street}}</vn-td>
|
<vn-td expand title="{{ticket.address.street}}">{{ticket.address.street}}</vn-td>
|
||||||
<vn-td shrink>
|
<vn-td shrink>
|
||||||
<vn-icon
|
<vn-icon
|
||||||
|
|
|
@ -8,3 +8,4 @@ Add ticket: Añadir ticket
|
||||||
Tickets to add: Tickets a añadir
|
Tickets to add: Tickets a añadir
|
||||||
Ticket not found: No se ha encontrado el ticket
|
Ticket not found: No se ha encontrado el ticket
|
||||||
The selected ticket is not suitable for this route: El ticket seleccionado no es apto para esta ruta
|
The selected ticket is not suitable for this route: El ticket seleccionado no es apto para esta ruta
|
||||||
|
PC: CP
|
|
@ -3,4 +3,8 @@
|
||||||
vn-route-tickets form{
|
vn-route-tickets form{
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
max-width: $width-lg;
|
max-width: $width-lg;
|
||||||
|
|
||||||
|
.order-field {
|
||||||
|
max-width: 30px;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -72,7 +72,7 @@ Notes: Notas
|
||||||
Volume: Volumen
|
Volume: Volumen
|
||||||
Expedition: Expedición
|
Expedition: Expedición
|
||||||
New state: Nuevo estado
|
New state: Nuevo estado
|
||||||
Packages: Embalajes
|
Packages: Bultos
|
||||||
Tracking: Estados
|
Tracking: Estados
|
||||||
Sale checked: Control clientes
|
Sale checked: Control clientes
|
||||||
Components: Componentes
|
Components: Componentes
|
||||||
|
|
Loading…
Reference in New Issue