diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index 2393018cf..0e7c9fe20 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -33,54 +33,54 @@ module.exports = Self => { const stmt = new ParameterizedSQL( `SELECT - t.id, - t.packages, - t.warehouseFk, - t.nickname, - t.clientFk, - t.priority, - t.addressFk, - st.code ticketStateCode, - st.name ticketStateName, - wh.name warehouseName, - tob.description observationDelivery, - tob2.description observationDropOff, - tob2.id, - a.street, - a.postalCode, - a.city, - am.name agencyModeName, - u.nickname userNickname, - vn.ticketTotalVolume(t.id) volume, - GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, - c.phone clientPhone, - c.mobile clientMobile, - a.phone addressPhone, - a.mobile addressMobile, - a.longitude, - a.latitude, - wm.mediaValue salePersonPhone, - t.cmrFk, - t.isSigned signed - FROM vn.route r - JOIN ticket t ON t.routeFk = r.id - JOIN client c ON t.clientFk = c.id - LEFT JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.id = ts.stateFk - LEFT JOIN warehouse wh ON wh.id = t.warehouseFk - LEFT JOIN observationType ot ON ot.code = 'delivery' - LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id - AND tob.observationTypeFk = ot.id - LEFT JOIN observationType ot2 ON ot2.code = 'dropOff' - LEFT JOIN ticketObservation tob2 ON tob2.ticketFk = t.id - AND tob2.observationTypeFk = ot2.id - LEFT JOIN address a ON a.id = t.addressFk - LEFT JOIN agencyMode am ON am.id = t.agencyModeFk - LEFT JOIN account.user u ON u.id = r.workerFk - LEFT JOIN vehicle v ON v.id = r.vehicleFk - LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk` + t.id, + t.packages, + t.warehouseFk, + t.nickname, + t.clientFk, + t.priority, + t.addressFk, + st.code ticketStateCode, + st.name ticketStateName, + wh.name warehouseName, + tob.description observationDelivery, + tob2.description observationDropOff, + tob2.id observationId, + a.street, + a.postalCode, + a.city, + am.name agencyModeName, + u.nickname userNickname, + vn.ticketTotalVolume(t.id) volume, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, + c.phone clientPhone, + c.mobile clientMobile, + a.phone addressPhone, + a.mobile addressMobile, + a.longitude, + a.latitude, + wm.mediaValue salePersonPhone, + t.cmrFk, + t.isSigned signed + FROM vn.route r + JOIN ticket t ON t.routeFk = r.id + JOIN client c ON t.clientFk = c.id + LEFT JOIN vn.sale s ON s.ticketFk = t.id + LEFT JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + LEFT JOIN state st ON st.id = ts.stateFk + LEFT JOIN warehouse wh ON wh.id = t.warehouseFk + LEFT JOIN observationType ot ON ot.code = 'delivery' + LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id + AND tob.observationTypeFk = ot.id + LEFT JOIN observationType ot2 ON ot2.code = 'dropOff' + LEFT JOIN ticketObservation tob2 ON tob2.ticketFk = t.id + AND tob2.observationTypeFk = ot2.id + LEFT JOIN address a ON a.id = t.addressFk + LEFT JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN account.user u ON u.id = r.workerFk + LEFT JOIN vehicle v ON v.id = r.vehicleFk + LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk` ); if (!filter.where) filter.where = {};