diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index c17eefbf9..98926b28b 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..521e4cf2f 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;