diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 592ed11e6..d22fa0804 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -96,9 +96,18 @@ module.exports = Self => { teamMembersId.push(userId); } - if (args && args.myTeam) + if (args?.myTeam) args.teamIds = teamIds; + if (args?.to) + args.to.setHours(23, 59, 0, 0); + + if (!args.from) { + const yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + args.from = yesterday.toISOString().split('T')[0]; + } + const where = buildFilter(args, (param, value) => { switch (param) { case 'search': @@ -194,7 +203,7 @@ module.exports = Self => { `); stmt.merge(conn.makeWhere(filter.where)); - stmt.merge(`GROUP BY id`); + stmt.merge(`GROUP BY o.id`); stmt.merge(conn.makePagination(filter)); stmts.push(stmt); stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`);