From 28c94b5f324fd40ce60a23677cb274cf8b3c4aa3 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 27 Aug 2024 12:58:48 +0200 Subject: [PATCH] feat: refs #7686 Changes in procs --- .../bs/procedures/inventoryDiscrepancyDetail_replace.sql | 5 ++--- db/routines/hedera/procedures/order_confirmWithUser.sql | 2 +- db/routines/vn/procedures/itemShelvingRadar.sql | 2 +- db/routines/vn/procedures/productionControl.sql | 2 +- db/routines/vn/procedures/ticketDown_PrintableSelection.sql | 2 +- db/routines/vn/procedures/ticketGetVisibleAvailable.sql | 2 +- db/routines/vn/procedures/ticket_DelayTruck.sql | 2 +- db/routines/vn/procedures/ticket_canMerge.sql | 4 ++-- db/routines/vn/procedures/ticket_canbePostponed.sql | 2 +- modules/monitor/back/methods/sales-monitor/salesFilter.js | 2 +- modules/ticket/back/methods/ticket/filter.js | 2 +- modules/ticket/back/methods/ticket/getTicketsFuture.js | 2 +- 12 files changed, 14 insertions(+), 15 deletions(-) diff --git a/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql b/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql index 863005373..481082766 100644 --- a/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql +++ b/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql @@ -65,15 +65,14 @@ BEGIN JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN vn.alertLevel al ON al.id = ts.alertLevel WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - AND s.isPicked = FALSE - AND al.code = 'FREE' + AND NOT s.isPicked + AND al.code IN ('FREE', 'APPROVED') AND t.warehouseFk = vWarehouseFk GROUP BY s.itemFk HAVING notPicked ) s ON s.itemFk = v.item_id WHERE v.calc_id = vCalc AND NOT v.visible <=> tv.totalVisible; - END LOOP; CLOSE cWarehouses; diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 2b033b704..e293427e8 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -134,7 +134,7 @@ BEGIN ) SELECT t.id INTO vTicketFk FROM vn.ticket t - JOIN vn.alertLevel al ON al.code = 'FREE' + JOIN vn.alertLevel al ON al.code IN ('FREE', 'APPROVED') LEFT JOIN tPrevia tp ON tp.ticketFk = t.id LEFT JOIN vn.ticketState tls ON tls.ticketFk = t.id JOIN hedera.`order` o ON o.address_id = t.addressFk diff --git a/db/routines/vn/procedures/itemShelvingRadar.sql b/db/routines/vn/procedures/itemShelvingRadar.sql index aa95d0503..3c7ba577b 100644 --- a/db/routines/vn/procedures/itemShelvingRadar.sql +++ b/db/routines/vn/procedures/itemShelvingRadar.sql @@ -106,7 +106,7 @@ BEGIN JOIN alertLevel al ON al.id = tst.alertLevel JOIN sale s ON s.ticketFk = t.id WHERE t.warehouseFk = vWarehouseFk - AND al.code = 'FREE' + AND al.code IN ('FREE', 'APPROVED') GROUP BY s.itemFk ) sub ON sub.itemFk = ishr.itemFk ORDER BY i.typeFk, i.longName; diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index 84717a19a..16a2ada93 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -82,7 +82,7 @@ proc: BEGIN rm.bufferFk FROM tmp.productionTicket tt JOIN ticket t ON tt.ticketFk = t.id - JOIN alertLevel al ON al.code = 'FREE' + JOIN alertLevel al ON al.code = 'APPROVED' LEFT JOIN ticketStateToday tst ON tst.ticketFk = t.id LEFT JOIN `state` st ON st.id = tst.state LEFT JOIN client c ON c.id = t.clientFk diff --git a/db/routines/vn/procedures/ticketDown_PrintableSelection.sql b/db/routines/vn/procedures/ticketDown_PrintableSelection.sql index 45002dd1f..22de6573a 100644 --- a/db/routines/vn/procedures/ticketDown_PrintableSelection.sql +++ b/db/routines/vn/procedures/ticketDown_PrintableSelection.sql @@ -13,7 +13,7 @@ BEGIN JOIN vn.parking p ON p.id = sh.parkingFk WHERE p.sectorFk = vSectorFk ) sub ON sub.id = td.ticketFk - JOIN vn.ticketDown_SelectionType tdst ON tdst.description = 'FREE' + JOIN vn.ticketDown_SelectionType tdst ON tdst.description IN ('FREE', 'APPROVED') JOIN vn.ticketDown_SelectionType tdst2 ON tdst2.description = 'SELECTED' SET td.selected = tdst2.id WHERE td.selected = tdst.id; diff --git a/db/routines/vn/procedures/ticketGetVisibleAvailable.sql b/db/routines/vn/procedures/ticketGetVisibleAvailable.sql index 3717d57e3..7589e2702 100644 --- a/db/routines/vn/procedures/ticketGetVisibleAvailable.sql +++ b/db/routines/vn/procedures/ticketGetVisibleAvailable.sql @@ -12,7 +12,7 @@ BEGIN SELECT t.warehouseFk, t.shipped, ts.alertLevel, al.id INTO vWarehouse, vShipped, vAlertLevel, vAlertLevelFree FROM ticket t - JOIN alertLevel al ON al.code = 'FREE' + JOIN alertLevel al ON al.code IN ('FREE', 'APPROVED') LEFT JOIN ticketState ts ON ts.ticketFk = vTicket WHERE t.id = vTicket; diff --git a/db/routines/vn/procedures/ticket_DelayTruck.sql b/db/routines/vn/procedures/ticket_DelayTruck.sql index 81896dd8e..64598646c 100644 --- a/db/routines/vn/procedures/ticket_DelayTruck.sql +++ b/db/routines/vn/procedures/ticket_DelayTruck.sql @@ -13,7 +13,7 @@ BEGIN CREATE TEMPORARY TABLE tTicket SELECT ticketFk FROM tmp.productionBuffer - JOIN alertLevel al ON al.code = 'FREE' + JOIN alertLevel al ON al.code IN ('FREE', 'APPROVED') WHERE shipped = util.VN_CURDATE() AND problem LIKE '%I:%' AND (HH <= vHour OR HH = vHour AND mm < vMinute) diff --git a/db/routines/vn/procedures/ticket_canMerge.sql b/db/routines/vn/procedures/ticket_canMerge.sql index c3f211027..91b77296c 100644 --- a/db/routines/vn/procedures/ticket_canMerge.sql +++ b/db/routines/vn/procedures/ticket_canMerge.sql @@ -48,14 +48,14 @@ BEGIN WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, vScopeDays,vDated) AND util.dayend(TIMESTAMPADD(DAY, vScopeDays,vDated)) AND t.warehouseFk = vWarehouseFk - AND al.code = 'FREE' + AND al.code IN ('FREE', 'APPROVED') GROUP BY t.id ) sub GROUP BY sub.addressFk ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id WHERE t.shipped BETWEEN vDated AND util.dayend(vDated) AND t.warehouseFk = vWarehouseFk - AND al.code = 'FREE' + AND al.code IN ('FREE', 'APPROVED') AND tp.ticketFk IS NULL GROUP BY sv.ticketFk HAVING liters <= vLitersMax diff --git a/db/routines/vn/procedures/ticket_canbePostponed.sql b/db/routines/vn/procedures/ticket_canbePostponed.sql index 442059b99..f5065746b 100644 --- a/db/routines/vn/procedures/ticket_canbePostponed.sql +++ b/db/routines/vn/procedures/ticket_canbePostponed.sql @@ -65,7 +65,7 @@ BEGIN ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id WHERE t.shipped BETWEEN vOriginDated AND util.dayend(vOriginDated) AND t.warehouseFk = vWarehouseFk - AND al.code = 'FREE' + AND al.code IN ('FREE', 'APPROVED') AND tp.ticketFk IS NULL GROUP BY sv.ticketFk HAVING futureId; diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 33b37d8a4..513efc412 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -288,7 +288,7 @@ module.exports = Self => { SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped FROM tmp.filter f LEFT JOIN alertLevel al ON al.id = f.alertLevel - WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) + WHERE (al.code IN ('FREE', 'APPROVED') OR f.alertLevel IS NULL) AND f.shipped >= ?`, [date]); stmts.push(stmt); diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 3e8b732af..5ac72539a 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -299,7 +299,7 @@ module.exports = Self => { SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped FROM tmp.filter f LEFT JOIN alertLevel al ON al.id = f.alertLevel - WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) + WHERE (al.code IN ('FREE', 'APPROVED') OR f.alertLevel IS NULL) AND f.shipped >= ? `, [date]); diff --git a/modules/ticket/back/methods/ticket/getTicketsFuture.js b/modules/ticket/back/methods/ticket/getTicketsFuture.js index 0fd21ea74..41497062f 100644 --- a/modules/ticket/back/methods/ticket/getTicketsFuture.js +++ b/modules/ticket/back/methods/ticket/getTicketsFuture.js @@ -152,7 +152,7 @@ module.exports = Self => { SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped, f.lines, f.liters FROM tmp.filter f LEFT JOIN alertLevel al ON al.id = f.alertLevel - WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) + WHERE (al.code IN ('FREE', 'APPROVED') OR f.alertLevel IS NULL) `); stmts.push(stmt);