From 1f6f7b99758617ece9ce722c346127ddec69078c Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Feb 2025 00:34:08 +0100 Subject: [PATCH] feat: refs #6321 updates requested --- db/routines/vn/procedures/item_getLack.sql | 4 ++-- loopback/locale/en.json | 2 +- modules/item/back/methods/item/getSimilar.js | 6 ++--- .../methods/supplier/getItemsPackaging.js | 2 +- .../back/methods/ticket/itemLackDetail.js | 24 ++++++++++++------- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/db/routines/vn/procedures/item_getLack.sql b/db/routines/vn/procedures/item_getLack.sql index f70705fa35..1a54f03962 100644 --- a/db/routines/vn/procedures/item_getLack.sql +++ b/db/routines/vn/procedures/item_getLack.sql @@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getLack`( vForce BOOLEAN, vDays INT, vLongname VARCHAR(255), - vSupplierFk VARCHAR(255), + vProducerName VARCHAR(255), vColor VARCHAR(255), vSize INT, vOrigen INT, @@ -60,7 +60,7 @@ BEGIN AND it.code != 'GEN' AND (vSelf IS NULL OR i.id = vSelf) AND (vLongname IS NULL OR i.name = vLongname) - AND (vSupplierFk IS NULL OR p.`name` LIKE CONCAT('%', vSupplierFk, '%')) + AND (vProducerName IS NULL OR p.`name` LIKE CONCAT('%', vProducerName, '%')) AND (vColor IS NULL OR vColor = i.inkFk) AND (vSize IS NULL OR vSize = i.`size`) AND (vOrigen IS NULL OR vOrigen = w.id) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 3f27859576..27c6ac2161 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -256,5 +256,5 @@ "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", "Ticket has been delivered out of order": "The ticket {{ticket}} of route {{{fullUrl}}} has been delivered out of order.", "negativeReplaced": "(Negativos) Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})", - "The tag or priority can't be repeated for an item": "The tag or priority can't be repeated for an item" + "The tag and priority can't be repeated": "The tag and priority can't be repeated" } diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js index 51d61c61c8..2479d08b52 100644 --- a/modules/item/back/methods/item/getSimilar.js +++ b/modules/item/back/methods/item/getSimilar.js @@ -32,9 +32,9 @@ module.exports = Self => { const query = [ filter.itemFk, where.warehouseFk, - where.date ?? Date.vnNew(), - where.showType ?? true, - where.scopeDays ?? 2 + where.date, + where.showType, + where.scopeDays ]; const [results] = await Self.rawSql('CALL vn.item_getSimilar(?, ?, ?, ?, ?)', query, myOptions); diff --git a/modules/supplier/back/methods/supplier/getItemsPackaging.js b/modules/supplier/back/methods/supplier/getItemsPackaging.js index 8a27c89c4b..8231e9936f 100644 --- a/modules/supplier/back/methods/supplier/getItemsPackaging.js +++ b/modules/supplier/back/methods/supplier/getItemsPackaging.js @@ -44,7 +44,7 @@ module.exports = Self => { JOIN hedera.imageConfig ic WHERE e.supplierFk = ? AND i.family IN ('EMB', 'CONT') - AND b.created > (util.VN_CURDATE() - INTERVAL bc.monthsAgo MONTH) + AND b.created > util.VN_CURDATE() - INTERVAL bc.monthsAgo MONTH) GROUP BY b.itemFk ORDER BY et.quantity DESC, quantityTotal DESC`, [entry, id, id]); }; diff --git a/modules/ticket/back/methods/ticket/itemLackDetail.js b/modules/ticket/back/methods/ticket/itemLackDetail.js index 3ab22d9e58..10d6c8fa91 100644 --- a/modules/ticket/back/methods/ticket/itemLackDetail.js +++ b/modules/ticket/back/methods/ticket/itemLackDetail.js @@ -62,7 +62,7 @@ module.exports = Self => { IF(ISNULL(tr.saleFk),0,1) peticionCompra, DATE_FORMAT(IF(HOUR(t.shipped), t.shipped, IF(zc.hour, zc.hour, z.hour)),'%H:%i') minTimed, FALSE isBasket, - substitution.hasSubstitution, + substitution.hasObservation, IF(d.code = 'spainTeamVip', 1, 0) hasToIgnore FROM sale s LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id @@ -81,7 +81,7 @@ module.exports = Self => { LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk LEFT JOIN department d ON d.id = wd.departmentFk LEFT JOIN ( - SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasSubstitution + SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasObservation FROM clientObservation co INNER JOIN observationType ot ON ot.id = co.observationTypeFk WHERE ot.code = 'substitution' @@ -92,7 +92,7 @@ module.exports = Self => { AND s.quantity <> 0 AND t.shipped BETWEEN util.VN_CURDATE() AND DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) AND sgd.saleFk IS NULL - AND (al.id = ? OR al.id IS NULL) + AND (al.code IN (?) OR al.id IS NULL) UNION ALL SELECT r.id, NULL, @@ -117,7 +117,7 @@ module.exports = Self => { NULL, NULL, TRUE, - substitution.hasSubstitution, + substitution.hasObservation, IF(d.code = 'spainTeamVip', 1, 0) FROM hedera.orderRow r INNER JOIN hedera.order o ON o.id = r.orderFk @@ -127,7 +127,7 @@ module.exports = Self => { LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk LEFT JOIN department d ON d.id = wd.departmentFk LEFT JOIN ( - SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasSubstitution + SELECT co.clientFk, IF(COUNT(*) > 0, FALSE, TRUE) hasObservation FROM clientObservation co INNER JOIN observationType ot ON ot.id = co.observationTypeFk WHERE ot.code = 'substitution' @@ -135,12 +135,20 @@ module.exports = Self => { ) substitution ON substitution.clientFk = c.id WHERE r.shipment BETWEEN util.VN_CURDATE() AND DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY) AND r.warehouseFk = ? - AND r.created >= STR_TO_DATE(util.VN_CURDATE(), '%Y-%m-%d %H:%i:%s') + AND r.created >= util.VN_CURDATE() AND NOT o.confirmed AND r.itemFk = ? - AND r.amount <> 0 + AND r.amount ORDER BY hasToIgnore, isBasket;`, - [filter.where.warehouseFk, itemFk, 2, filter.where.stateFk ?? 0, 2, filter.where.warehouseFk, itemFk]); + [ + filter.where.warehouseFk, + itemFk, + 2, + filter.where.alertLevelCode, + 2, + filter.where.warehouseFk, + itemFk + ]); const sql = ParameterizedSQL.join([stmt], ';'); const result = await conn.executeStmt(sql, myOptions);