From 42d17aa7f5b17b15f5c419eaa137f1c2d4a16657 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 9 May 2024 11:52:25 +0200 Subject: [PATCH 1/2] done --- db/routines/vn/procedures/sale_getProblems.sql | 9 +++++++++ db/routines/vn/procedures/ticket_getProblems.sql | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index c17eefbf9..bc1583177 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -44,6 +44,7 @@ BEGIN hasComponentLack INTEGER(1), hasRounding VARCHAR(255), isTooLittle BOOL DEFAULT FALSE, + isVIP BOOL DEFAULT FALSE, PRIMARY KEY (ticketFk, saleFk) ) ENGINE = MEMORY; @@ -79,6 +80,14 @@ BEGIN JOIN volumeConfig vc WHERE sub.litros < vc.minTicketVolume AND sub.totalWithoutVat < vc.minTicketValue; + + -- VIP + INSERT INTO tmp.sale_problems(ticketFk, isVIP) + SELECT DISTINCT tl.ticketFk, TRUE + FROM tmp.ticket_list tl + JOIN client c ON c.id = tl.clientFk + WHERE c.businessTypeFk = 'VIP' + ON DUPLICATE KEY UPDATE isVIP = TRUE; -- Faltan componentes INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) diff --git a/db/routines/vn/procedures/ticket_getProblems.sql b/db/routines/vn/procedures/ticket_getProblems.sql index 7c57492b4..996366352 100644 --- a/db/routines/vn/procedures/ticket_getProblems.sql +++ b/db/routines/vn/procedures/ticket_getProblems.sql @@ -25,6 +25,7 @@ BEGIN MAX(itemDelay) itemDelay, MAX(hasRounding) hasRounding, MAX(itemLost) itemLost, + MAX(isVIP) isVIP, 0 totalProblems FROM tmp.sale_problems GROUP BY ticketFk; @@ -40,7 +41,8 @@ BEGIN (tp.isTooLittle) + (tp.itemLost) + (tp.hasRounding) + - (tp.itemShortage) + (tp.itemShortage) + + (tp.isVIP) ); DROP TEMPORARY TABLE tmp.sale_problems; -- 2.40.1 From 53f49531b71e46207cbfa640d08c8616e9731452 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 14 May 2024 09:07:43 +0200 Subject: [PATCH 2/2] VIP now is Vip --- db/routines/vn/procedures/sale_getProblems.sql | 6 +++--- db/routines/vn/procedures/ticket_getProblems.sql | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index bc1583177..98926b28b 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -44,7 +44,7 @@ BEGIN hasComponentLack INTEGER(1), hasRounding VARCHAR(255), isTooLittle BOOL DEFAULT FALSE, - isVIP BOOL DEFAULT FALSE, + isVip BOOL DEFAULT FALSE, PRIMARY KEY (ticketFk, saleFk) ) ENGINE = MEMORY; @@ -82,12 +82,12 @@ BEGIN AND sub.totalWithoutVat < vc.minTicketValue; -- VIP - INSERT INTO tmp.sale_problems(ticketFk, isVIP) + INSERT INTO tmp.sale_problems(ticketFk, isVip) SELECT DISTINCT tl.ticketFk, TRUE FROM tmp.ticket_list tl JOIN client c ON c.id = tl.clientFk WHERE c.businessTypeFk = 'VIP' - ON DUPLICATE KEY UPDATE isVIP = TRUE; + ON DUPLICATE KEY UPDATE isVip = TRUE; -- Faltan componentes INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) diff --git a/db/routines/vn/procedures/ticket_getProblems.sql b/db/routines/vn/procedures/ticket_getProblems.sql index 996366352..521e4cf2f 100644 --- a/db/routines/vn/procedures/ticket_getProblems.sql +++ b/db/routines/vn/procedures/ticket_getProblems.sql @@ -25,7 +25,7 @@ BEGIN MAX(itemDelay) itemDelay, MAX(hasRounding) hasRounding, MAX(itemLost) itemLost, - MAX(isVIP) isVIP, + MAX(isVip) isVip, 0 totalProblems FROM tmp.sale_problems GROUP BY ticketFk; @@ -42,7 +42,7 @@ BEGIN (tp.itemLost) + (tp.hasRounding) + (tp.itemShortage) + - (tp.isVIP) + (tp.isVip) ); DROP TEMPORARY TABLE tmp.sale_problems; -- 2.40.1