diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 927f49999..30df9c0cc 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -88,6 +88,11 @@ module.exports = Self => { arg: 'alertLevel', type: 'number', description: `The alert level of the tickets` + }, + { + arg: 'packing', + type: 'string', + description: `The packing of the items` } ], returns: { @@ -155,6 +160,9 @@ module.exports = Self => { case 'clientFk': param = `t.${param}`; return {[param]: value}; + case 'packing': + param = `i.${param}`; + return {[param]: value}; } }); @@ -169,7 +177,7 @@ module.exports = Self => { stmt = new ParameterizedSQL(` CREATE OR REPLACE TEMPORARY TABLE tmp.filter (PRIMARY KEY (id)) - ENGINE = MEMORY + ENGINE = InnoDB SELECT t.id, t.shipped, CAST(DATE(t.shipped) AS CHAR) shippedDate, @@ -194,10 +202,18 @@ module.exports = Self => { u.name userName, c.salesPersonFk, c.credit, + pm.name payMethod, z.hour zoneLanding, z.name zoneName, z.id zoneFk, st.classColor, + d.id departmentFk, + d.name department, + (SELECT GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk SEPARATOR ',') + FROM sale s + JOIN item i ON i.id = s.itemFk + WHERE s.ticketFk = t.id + ) AS packing, TIME_FORMAT(t.shipped, '%H:%i') preparationHour, TIME_FORMAT(z.hour, '%H:%i') theoreticalhour, TIME_FORMAT(zed.etc, '%H:%i') practicalHour @@ -211,7 +227,10 @@ module.exports = Self => { LEFT JOIN ticketState ts ON ts.ticketFk = t.id LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN payMethod pm ON pm.id = c.payMethodFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk + LEFT JOIN workerDepartment wd ON wd.workerFk = wk.id + LEFT JOIN department d ON d.id = wd.departmentFk LEFT JOIN account.user u ON u.id = wk.id LEFT JOIN ( SELECT zoneFk,