fix: refs #6389 saleMonitor filter #3130

Open
carlossa wants to merge 12 commits from 6389-changesMonitor into dev
1 changed files with 20 additions and 1 deletions

View File

@ -88,6 +88,11 @@ module.exports = Self => {
arg: 'alertLevel', arg: 'alertLevel',
type: 'number', type: 'number',
description: `The alert level of the tickets` description: `The alert level of the tickets`
},
{
arg: 'packing',
type: 'string',
description: `The packing of the items`
} }
], ],
returns: { returns: {
@ -155,6 +160,9 @@ module.exports = Self => {
case 'clientFk': case 'clientFk':
param = `t.${param}`; param = `t.${param}`;
return {[param]: value}; return {[param]: value};
case 'packing':
param = `i.${param}`;
return {[param]: value};
} }
}); });
@ -169,7 +177,7 @@ module.exports = Self => {
stmt = new ParameterizedSQL(` stmt = new ParameterizedSQL(`
CREATE OR REPLACE TEMPORARY TABLE tmp.filter CREATE OR REPLACE TEMPORARY TABLE tmp.filter
(PRIMARY KEY (id)) (PRIMARY KEY (id))
ENGINE = MEMORY ENGINE = InnoDB
SELECT t.id, SELECT t.id,
t.shipped, t.shipped,
CAST(DATE(t.shipped) AS CHAR) shippedDate, CAST(DATE(t.shipped) AS CHAR) shippedDate,
@ -194,10 +202,18 @@ module.exports = Self => {
u.name userName, u.name userName,
c.salesPersonFk, c.salesPersonFk,
c.credit, c.credit,
pm.name payMethod,
z.hour zoneLanding, z.hour zoneLanding,
z.name zoneName, z.name zoneName,
z.id zoneFk, z.id zoneFk,
st.classColor, 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(t.shipped, '%H:%i') preparationHour,
TIME_FORMAT(z.hour, '%H:%i') theoreticalhour, TIME_FORMAT(z.hour, '%H:%i') theoreticalhour,
TIME_FORMAT(zed.etc, '%H:%i') practicalHour 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 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 client c ON c.id = t.clientFk 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 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 account.user u ON u.id = wk.id
LEFT JOIN ( LEFT JOIN (
SELECT zoneFk, SELECT zoneFk,