From 862a583e3017b5a00aa0a8921cd2cb0f8261d0b1 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 14 Oct 2024 13:01:32 +0200 Subject: [PATCH 1/3] feat: refs #8077 defaulter filter --- .../client/back/methods/defaulter/filter.js | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index 9f19dee0a..1fcfde51b 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -18,6 +18,11 @@ module.exports = Self => { arg: 'search', type: 'string', description: `If it's and integer searchs by id, otherwise it searchs by name` + }, + { + arg: 'sumAmount', + type: 'boolean', + description: `` } ], returns: { @@ -28,6 +33,7 @@ module.exports = Self => { path: `/filter`, verb: 'GET' } + }); Self.filter = async(ctx, filter, options) => { @@ -50,14 +56,7 @@ module.exports = Self => { filter = mergeFilters(ctx.args.filter, {where}); const stmts = []; - - const date = Date.vnNew(); - date.setHours(0, 0, 0, 0); - const stmt = new ParameterizedSQL( - `SELECT * - FROM ( - SELECT - DISTINCT c.id clientFk, + const fields = ctx.args.sumAmount ? 'sum(d.amount) sumAmount' : ` DISTINCT c.id clientFk, c.name clientName, c.salesPersonFk, c.businessTypeFk = 'worker' isWorker, @@ -74,7 +73,14 @@ module.exports = Self => { pm.name payMethod, r.finished IS NULL hasRecovery, dp.id departmentFk, - dp.name departmentName + dp.name departmentName`; + const date = Date.vnNew(); + date.setHours(0, 0, 0, 0); + const stmt = new ParameterizedSQL( + `SELECT * + FROM ( + SELECT + ${fields} FROM defaulter d JOIN client c ON c.id = d.clientFk JOIN country cn ON cn.id = c.countryFk @@ -101,7 +107,7 @@ module.exports = Self => { , [date]); stmt.merge(conn.makeWhere(filter.where)); - stmt.merge(`GROUP BY d.clientFk`); + !ctx.args.sumAmount && stmt.merge(`GROUP BY d.clientFk`); stmt.merge(conn.makeOrderBy(filter.order)); stmt.merge(conn.makeLimit(filter)); -- 2.40.1 From 34df4aed54a8583e8efe93b4bf2b622e02840bb4 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 24 Oct 2024 08:04:55 +0200 Subject: [PATCH 2/3] feat: refs #8077 resolve conflict --- modules/client/back/methods/defaulter/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index 98a1f7621..c38926db0 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -73,7 +73,7 @@ module.exports = Self => { pm.name payMethod, r.finished IS NULL hasRecovery, dp.id departmentFk, - dp.name departmentName + dp.name departmentName, dp.notificationEmail departmentEmail`; const date = Date.vnNew(); date.setHours(0, 0, 0, 0); -- 2.40.1 From 76b32e1d2551603dbd79f474a208bf3a38776fe3 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 18 Nov 2024 13:19:25 +0100 Subject: [PATCH 3/3] feat: refs #8077 add description to sumAmount --- modules/client/back/methods/defaulter/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index c38926db0..14b55f9b9 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -22,7 +22,7 @@ module.exports = Self => { { arg: 'sumAmount', type: 'boolean', - description: `` + description: `Indicates whether to calculate the total sum of amounts or to return detailed records` } ], returns: { -- 2.40.1