test: refs #7173 fix sql, adding alias
gitea/salix/pipeline/pr-test This commit looks good Details

This commit is contained in:
Alex Moreno 2024-04-23 08:47:52 +02:00
parent 85491613b0
commit 60d5b9e4aa
1 changed files with 48 additions and 48 deletions

View File

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