From 4c529da620871d1c78f824aad3a781f7ea1fd0e8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 24 Oct 2024 07:31:26 +0200 Subject: [PATCH] feat: refs #7266 Requested changes and query optimization --- db/routines/vn/functions/buy_getUltimate.sql | 2 +- db/routines/vn/procedures/buy_getUltimate.sql | 2 +- .../item-label-barcode.html | 8 ++- .../item-label-barcode/sql/company.sql | 3 +- .../reports/item-label-barcode/sql/item.sql | 60 ++++++++----------- .../reports/item-label-qr/item-label-qr.html | 8 ++- .../reports/item-label-qr/sql/company.sql | 3 +- .../reports/item-label-qr/sql/item.sql | 60 ++++++++----------- 8 files changed, 68 insertions(+), 78 deletions(-) diff --git a/db/routines/vn/functions/buy_getUltimate.sql b/db/routines/vn/functions/buy_getUltimate.sql index 173e6e01f..8f5e9ce59 100644 --- a/db/routines/vn/functions/buy_getUltimate.sql +++ b/db/routines/vn/functions/buy_getUltimate.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getUltimate`( vItemFk INT, - vWarehouseFk SMALLINT, + vWarehouseFk INT, vDated DATE ) RETURNS int(11) diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql index 1532222ad..77e2029fc 100644 --- a/db/routines/vn/procedures/buy_getUltimate.sql +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimate`( vItemFk INT, - vWarehouseFk SMALLINT, + vWarehouseFk INT, vDated DATE ) BEGIN diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.html b/print/templates/reports/item-label-barcode/item-label-barcode.html index 224338c2f..929ce5fe2 100644 --- a/print/templates/reports/item-label-barcode/item-label-barcode.html +++ b/print/templates/reports/item-label-barcode/item-label-barcode.html @@ -17,12 +17,16 @@
- {{item.comment}} + {{ + (item.longName && item.size && item.subName) + ? `${item.longName} ${item.size} ${item.subName}` + : item.comment + }}
- {{item.producer}} + {{item.producerName || item.producerFk}}
diff --git a/print/templates/reports/item-label-barcode/sql/company.sql b/print/templates/reports/item-label-barcode/sql/company.sql index e130b4033..4047786a9 100644 --- a/print/templates/reports/item-label-barcode/sql/company.sql +++ b/print/templates/reports/item-label-barcode/sql/company.sql @@ -1,6 +1,5 @@ SELECT co.code FROM warehouse w JOIN address a ON a.id = w.addressFk - JOIN client c ON c.id = a.clientFk - JOIN company co ON co.clientFk = c.id + JOIN company co ON co.clientFk = a.clientFk WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/sql/item.sql b/print/templates/reports/item-label-barcode/sql/item.sql index 11ee60d1a..3cb42d139 100644 --- a/print/templates/reports/item-label-barcode/sql/item.sql +++ b/print/templates/reports/item-label-barcode/sql/item.sql @@ -6,37 +6,29 @@ WITH RECURSIVE numbers AS ( WHERE n < ? ) SELECT ROW_NUMBER() OVER() labelNum, - b.id buyFk, - b.itemFk, - b.quantity, - b.packing, - b.isPickedOff, - b.entryFk, - e.sub, - o.code origin, - COALESCE(p.`name`, p.id, '') producer, - i.name item, - i.`size`, - i.category, - i.stems, - i.inkFk, - IFNULL(CONCAT(ig.longName, ' ', ig.`size`, ' ', ig.subName), i.comment) comment, - i.typeFk, - i.isLaid, - w.code buyerName, - w.code, - s.company_name companyName, - t.shipped - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk - LEFT JOIN edi.ekt e ON e.id = b.ektFk - JOIN vn.origin o ON o.id = i.originFk - LEFT JOIN vn.producer p ON p.id = i.producerFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.worker w ON w.id = it.workerFk - LEFT JOIN edi.supplier s ON s.supplier_id = e.pro - JOIN vn.entry e2 ON e2.id = b.entryFk - JOIN vn.travel t ON t.id = e2.travelFk - JOIN numbers num - WHERE b.id = ? \ No newline at end of file + b.itemFk, + i.name item, + b.id buyFk, + b.quantity, + b.packing, + b.entryFk, + o.code origin, + p.`name` producerName, + p.id producerFk, + i.`size`, + i.category, + i.stems, + i.inkFk, + ig.longName, + ig.subName, + i.comment, + w.code buyerName + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk + JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.producer p ON p.id = i.producerFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.worker w ON w.id = it.workerFk + JOIN numbers num + WHERE b.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/item-label-qr/item-label-qr.html index 231c94818..712bd6c7d 100644 --- a/print/templates/reports/item-label-qr/item-label-qr.html +++ b/print/templates/reports/item-label-qr/item-label-qr.html @@ -71,7 +71,7 @@
- Productor: {{item.producer}} + Productor: {{item.producerName || item.producerFk}}
@@ -103,7 +103,11 @@
- {{item.comment}} + {{ + (item.longName && item.size && item.subName) + ? `${item.longName} ${item.size} ${item.subName}` + : item.comment + }}
diff --git a/print/templates/reports/item-label-qr/sql/company.sql b/print/templates/reports/item-label-qr/sql/company.sql index e130b4033..4047786a9 100644 --- a/print/templates/reports/item-label-qr/sql/company.sql +++ b/print/templates/reports/item-label-qr/sql/company.sql @@ -1,6 +1,5 @@ SELECT co.code FROM warehouse w JOIN address a ON a.id = w.addressFk - JOIN client c ON c.id = a.clientFk - JOIN company co ON co.clientFk = c.id + JOIN company co ON co.clientFk = a.clientFk WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/sql/item.sql b/print/templates/reports/item-label-qr/sql/item.sql index 11ee60d1a..3cb42d139 100644 --- a/print/templates/reports/item-label-qr/sql/item.sql +++ b/print/templates/reports/item-label-qr/sql/item.sql @@ -6,37 +6,29 @@ WITH RECURSIVE numbers AS ( WHERE n < ? ) SELECT ROW_NUMBER() OVER() labelNum, - b.id buyFk, - b.itemFk, - b.quantity, - b.packing, - b.isPickedOff, - b.entryFk, - e.sub, - o.code origin, - COALESCE(p.`name`, p.id, '') producer, - i.name item, - i.`size`, - i.category, - i.stems, - i.inkFk, - IFNULL(CONCAT(ig.longName, ' ', ig.`size`, ' ', ig.subName), i.comment) comment, - i.typeFk, - i.isLaid, - w.code buyerName, - w.code, - s.company_name companyName, - t.shipped - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk - LEFT JOIN edi.ekt e ON e.id = b.ektFk - JOIN vn.origin o ON o.id = i.originFk - LEFT JOIN vn.producer p ON p.id = i.producerFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.worker w ON w.id = it.workerFk - LEFT JOIN edi.supplier s ON s.supplier_id = e.pro - JOIN vn.entry e2 ON e2.id = b.entryFk - JOIN vn.travel t ON t.id = e2.travelFk - JOIN numbers num - WHERE b.id = ? \ No newline at end of file + b.itemFk, + i.name item, + b.id buyFk, + b.quantity, + b.packing, + b.entryFk, + o.code origin, + p.`name` producerName, + p.id producerFk, + i.`size`, + i.category, + i.stems, + i.inkFk, + ig.longName, + ig.subName, + i.comment, + w.code buyerName + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk + JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.producer p ON p.id = i.producerFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.worker w ON w.id = it.workerFk + JOIN numbers num + WHERE b.id = ? \ No newline at end of file