diff --git a/db/routines/vn/procedures/expedition_getFromRoute.sql b/db/routines/vn/procedures/expedition_getFromRoute.sql index f95936413..8c2ab057d 100644 --- a/db/routines/vn/procedures/expedition_getFromRoute.sql +++ b/db/routines/vn/procedures/expedition_getFromRoute.sql @@ -16,7 +16,8 @@ BEGIN a.nickname, sub2.itemPackingTypeConcat, est.code, - es.isScanned + es2.isScanned, + es2.scanOrder FROM expedition e JOIN ticket t ON t.id = e.ticketFk JOIN ticketState ts ON ts.ticketFk = e.ticketFk @@ -38,6 +39,7 @@ BEGIN SELECT MAX(id) FROM expeditionState es WHERE expeditionFk = e.id) + LEFT JOIN expeditionState es2 ON es2.id = es.id WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE ORDER BY r.created, t.priority DESC; END$$ diff --git a/db/versions/11319-redEucalyptus/00-firstScript.sql b/db/versions/11319-redEucalyptus/00-firstScript.sql new file mode 100644 index 000000000..62bd64f4a --- /dev/null +++ b/db/versions/11319-redEucalyptus/00-firstScript.sql @@ -0,0 +1,3 @@ +USE vn; + +ALTER TABLE vn.expeditionState ADD scanOrder int(11) DEFAULT NULL NULL COMMENT 'Indica la posiciĆ³n al cargar la furgoneta'; diff --git a/modules/ticket/back/methods/expedition-state/addExpeditionState.js b/modules/ticket/back/methods/expedition-state/addExpeditionState.js index 80d74ee92..0ba402ff7 100644 --- a/modules/ticket/back/methods/expedition-state/addExpeditionState.js +++ b/modules/ticket/back/methods/expedition-state/addExpeditionState.js @@ -44,6 +44,7 @@ module.exports = Self => { const typeFk = expeditionStateType.id; expeditionId = expedition.expeditionFk; + expeditionPosition = expedition?.scanOrder ?? null; const isScannedExpedition = expedition.isScanned ?? false; await models.ExpeditionState.create({ @@ -51,6 +52,7 @@ module.exports = Self => { typeFk, userFk: userId, isScanned: isScannedExpedition, + scanOrder: expeditionPosition }, myOptions); } diff --git a/modules/ticket/back/models/expedition-state.json b/modules/ticket/back/models/expedition-state.json index 522327031..7d8079b33 100644 --- a/modules/ticket/back/models/expedition-state.json +++ b/modules/ticket/back/models/expedition-state.json @@ -27,6 +27,9 @@ }, "isScanned": { "type": "boolean" + }, + "scanOrder": { + "type": "number" } }, "relations": {