diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index 82578c397..42dbe3078 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -148,24 +148,19 @@ module.exports = Self => { s.name AS supplierName, s.nickname AS supplierAlias, co.code AS companyCode, - cu.code AS currencyCode, - IF(b.buyingValue, SUM(b.quantity * b.buyingValue), 0) AS totalEntry + cu.code AS currencyCode FROM vn.entry e JOIN vn.supplier s ON s.id = e.supplierFk JOIN vn.travel t ON t.id = e.travelFk JOIN vn.company co ON co.id = e.companyFk - JOIN vn.currency cu ON cu.id = e.currencyFk - LEFT JOIN vn.buy b ON b.entryFk = e.id` + JOIN vn.currency cu ON cu.id = e.currencyFk` ); - stmt.merge(conn.makeWhere(filter.where)); - stmt.merge(conn.makeGroupBy('b.entryFk')); - stmt.merge(conn.makeLimit(filter)); + stmt.merge(conn.makeSuffix(filter)); let itemsIndex = stmts.push(stmt) - 1; let sql = ParameterizedSQL.join(stmts, ';'); let result = await conn.executeStmt(sql); - return itemsIndex === 0 ? result : result[itemsIndex]; }; };