From 6b7a529b5587266e7ca0fae68df1d06a1790e724 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 10 May 2024 11:39:14 +0200 Subject: [PATCH 1/6] refactor: refs #7345 Renamed column of invoiceInConfig --- db/dump/fixtures.before.sql | 2 +- db/versions/11044-blueOrchid/00-firstScript.sql | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 db/versions/11044-blueOrchid/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 06e94c99e..348c1fd06 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2562,7 +2562,7 @@ REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issu (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1), (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1); -INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo`) +INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`) VALUES (1, -2, '2% retention', 2, 45); diff --git a/db/versions/11044-blueOrchid/00-firstScript.sql b/db/versions/11044-blueOrchid/00-firstScript.sql new file mode 100644 index 000000000..d2212bc55 --- /dev/null +++ b/db/versions/11044-blueOrchid/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceInConfig CHANGE sageWithholdingFk sageFarmerWithholdingFk smallint(6) NOT NULL; From cb9cacc1ea7cd1fa1be52cf23e1d033f36f661aa Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 10 May 2024 11:51:54 +0200 Subject: [PATCH 2/6] feat: refs #7363 item_getBalance saleTracking no mostrar duplicados --- db/routines/vn/procedures/item_getBalance.sql | 259 ++++++++++-------- 1 file changed, 149 insertions(+), 110 deletions(-) diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index 88583cf00..dae53bf29 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -40,117 +40,156 @@ BEGIN inventorySupplierFk INT(10) ); - INSERT INTO tItemDiary - SELECT tr.landed shipped, - b.quantity `in`, - NULL `out`, - st.alertLevel , - st.name stateName, - s.name `name`, - e.invoiceNumber reference, - e.id origin, - s.id clientFk, - IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked, - FALSE isTicket, - b.id lineFk, - NULL `order`, - NULL clientType, - NULL claimFk, - ec.inventorySupplierFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - JOIN supplier s ON s.id = e.supplierFk - JOIN state st ON st.`code` = IF( tr.landed < util.VN_CURDATE() - OR (util.VN_CURDATE() AND tr.isReceived), - 'DELIVERED', - 'FREE') - JOIN entryConfig ec - WHERE tr.landed >= vDateInventory - AND vWarehouseFk = tr.warehouseInFk - AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) - AND b.itemFk = vItemFk - AND e.isExcludedFromAvailable = FALSE - AND e.isRaid = FALSE - UNION ALL - SELECT tr.shipped, - NULL, - b.quantity, - st.alertLevel, - st.name, - s.name, - e.invoiceNumber, - e.id, - s.id, - IF(st.`code` = 'DELIVERED' , TRUE, FALSE), - FALSE, - b.id, - NULL, - NULL, - NULL, - ec.inventorySupplierFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - JOIN warehouse w ON w.id = tr.warehouseOutFk - JOIN supplier s ON s.id = e.supplierFk - JOIN state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE() - OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived), - 'DELIVERED', - 'FREE') - JOIN entryConfig ec - WHERE tr.shipped >= vDateInventory - AND vWarehouseFk = tr.warehouseOutFk - AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) - AND b.itemFk = vItemFk - AND e.isExcludedFromAvailable = FALSE - AND w.isFeedStock = FALSE - AND e.isRaid = FALSE - UNION ALL - SELECT DATE(t.shipped), - NULL, - s.quantity, - st2.alertLevel, - st2.name, - t.nickname, - t.refFk, - t.id, - t.clientFk, - stk.id, - TRUE, - s.id, - st.`order`, - c.typeFk, - cb.claimFk, - NULL - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.`code` = ts.`code` - JOIN client c ON c.id = t.clientFk - JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), - 'DELIVERED', - IF (t.shipped > util.dayEnd(util.VN_CURDATE()), - 'FREE', - IFNULL(ts.code, 'FREE'))) - LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' - LEFT JOIN saleTracking stk ON stk.saleFk = s.id - AND stk.stateFk = stPrep.id - LEFT JOIN claimBeginning cb ON s.id = cb.saleFk - WHERE t.shipped >= vDateInventory - AND s.itemFk = vItemFk - AND vWarehouseFk =t.warehouseFk - ORDER BY shipped, - (inventorySupplierFk = clientFk) DESC, - alertLevel DESC, - isTicket, - `order` DESC, - isPicked DESC, - `in` DESC, - `out` DESC; + INSERT INTO tItemDiary + WITH entries AS ( + SELECT tr.landed shipped, + b.quantity `in`, + NULL `out`, + st.alertLevel , + st.name stateName, + s.name `name`, + e.invoiceNumber reference, + e.id origin, + s.id clientFk, + IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked, + FALSE isTicket, + b.id lineFk, + NULL `order`, + NULL clientType, + NULL claimFk, + ec.inventorySupplierFk + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN supplier s ON s.id = e.supplierFk + JOIN state st ON st.`code` = IF( tr.landed < util.VN_CURDATE() + OR (util.VN_CURDATE() AND tr.isReceived), + 'DELIVERED', + 'FREE') + JOIN entryConfig ec + WHERE tr.landed >= vDateInventory + AND vWarehouseFk = tr.warehouseInFk + AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) + AND b.itemFk = vItemFk + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid + ), + deliveried AS ( + SELECT tr.shipped, + NULL, + b.quantity, + st.alertLevel, + st.name stateName, + s.name , + e.invoiceNumber, + e.id entryFk, + s.id supplierFk, + IF(st.`code` = 'DELIVERED' , TRUE, FALSE), + FALSE isTicket, + b.id, + NULL `order`, + NULL clientType, + NULL claimFk, + ec.inventorySupplierFk + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN warehouse w ON w.id = tr.warehouseOutFk + JOIN supplier s ON s.id = e.supplierFk + JOIN state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE() + OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived), + 'DELIVERED', + 'FREE') + JOIN entryConfig ec + WHERE tr.shipped >= vDateInventory + AND vWarehouseFk = tr.warehouseOutFk + AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) + AND b.itemFk = vItemFk + AND NOT e.isExcludedFromAvailable + AND NOT w.isFeedStock + AND NOT e.isRaid + ), + sales AS ( + SELECT DATE(t.shipped) shipped, + s.quantity, + st2.alertLevel, + st2.name, + t.nickname, + t.refFk, + t.id ticketFk, + t.clientFk, + s.id saleFk, + st.`order`, + c.typeFk, + cb.claimFk + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + LEFT JOIN state st ON st.`code` = ts.`code` + JOIN client c ON c.id = t.clientFk + JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), + 'DELIVERED', + IF (t.shipped > util.dayEnd(util.VN_CURDATE()), + 'FREE', + IFNULL(ts.code, 'FREE'))) + LEFT JOIN claimBeginning cb ON s.id = cb.saleFk + WHERE t.shipped >= vDateInventory + AND s.itemFk = vItemFk + AND vWarehouseFk = t.warehouseFk + ),sale AS ( + SELECT s.shipped, + NULL `in`, + s.quantity, + s.alertLevel, + s.name, + s.nickname, + s.refFk, + s.ticketFk, + s.clientFk, + IF(stk.saleFk, TRUE, NULL), + TRUE, + s.saleFk, + s.`order`, + s.typeFk, + s.claimFk, + NULL + FROM sales s + LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' + LEFT JOIN saleTracking stk ON stk.saleFk = s.saleFk + AND stk.stateFk = stPrep.id + GROUP BY s.saleFk + ) SELECT shipped, + `in`, + `out`, + alertLevel, + stateName, + `name`, + reference, + origin, + clientFk, + isPicked, + isTicket, + lineFk, + `order`, + clientType, + claimFk, + inventorySupplierFk + FROM entries + UNION ALL + SELECT * FROM deliveried + UNION ALL + SELECT * FROM sale + ORDER BY shipped, + (inventorySupplierFk = clientFk) DESC, + alertLevel DESC, + isTicket, + `order` DESC, + isPicked DESC, + `in` DESC, + `out` DESC; IF vDate IS NULL THEN - + SET @a := 0; SET @currentLineFk := 0; SET @shipped := ''; @@ -220,7 +259,7 @@ BEGIN FROM tItemDiary WHERE shipped >= vDate; END IF; - + DROP TEMPORARY TABLE tItemDiary; END$$ DELIMITER ; From ba72408e8484a79bb9cfa83f5bab2fdd71c7bb15 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 10 May 2024 12:45:53 +0200 Subject: [PATCH 3/6] refactor: refs #7345 Deprecated isFarmer__ --- db/routines/vn2008/views/Proveedores.sql | 1 - db/versions/11044-blueOrchid/00-firstScript.sql | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn2008/views/Proveedores.sql b/db/routines/vn2008/views/Proveedores.sql index b5d3d3684..203d4295f 100644 --- a/db/routines/vn2008/views/Proveedores.sql +++ b/db/routines/vn2008/views/Proveedores.sql @@ -6,7 +6,6 @@ AS SELECT `s`.`id` AS `Id_Proveedor`, `s`.`account` AS `cuenta`, `s`.`countryFk` AS `pais_id`, `s`.`nif` AS `NIF`, - `s`.`isFarmer` AS `Agricola`, `s`.`phone` AS `Telefono`, `s`.`retAccount` AS `cuentaret`, `s`.`commission` AS `ComisionProveedor`, diff --git a/db/versions/11044-blueOrchid/00-firstScript.sql b/db/versions/11044-blueOrchid/00-firstScript.sql index d2212bc55..29162820c 100644 --- a/db/versions/11044-blueOrchid/00-firstScript.sql +++ b/db/versions/11044-blueOrchid/00-firstScript.sql @@ -1 +1,3 @@ ALTER TABLE vn.invoiceInConfig CHANGE sageWithholdingFk sageFarmerWithholdingFk smallint(6) NOT NULL; +ALTER TABLE vn.supplier CHANGE isFarmer isFarmer__ tinyint(1) DEFAULT 0 NOT NULL COMMENT 'refs #7345 @deprecated 2024-05-10 - Utilizar withholdingSageFk'; +ALTER TABLE vn.supplier MODIFY COLUMN isFarmer__ tinyint(1) DEFAULT 0 NOT NULL COMMENT 'refs #7345 @deprecated 2024-05-10 - Utilizar withholdingSageFk'; From 9163d3db74ff8d4f6013dfcd37740a3acc09f6eb Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 10 May 2024 13:05:44 +0200 Subject: [PATCH 4/6] feat: refs #7363 changes --- db/routines/vn/procedures/item_getBalance.sql | 210 +++++++++--------- 1 file changed, 104 insertions(+), 106 deletions(-) diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index dae53bf29..5e21047b4 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -41,7 +41,7 @@ BEGIN ); INSERT INTO tItemDiary - WITH entries AS ( + WITH entriesIn AS ( SELECT tr.landed shipped, b.quantity `in`, NULL `out`, @@ -58,86 +58,84 @@ BEGIN NULL clientType, NULL claimFk, ec.inventorySupplierFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - JOIN supplier s ON s.id = e.supplierFk - JOIN state st ON st.`code` = IF( tr.landed < util.VN_CURDATE() + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.supplier s ON s.id = e.supplierFk + JOIN vn.state st ON st.`code` = IF( tr.landed < util.VN_CURDATE() OR (util.VN_CURDATE() AND tr.isReceived), - 'DELIVERED', + 'DELIVERED', 'FREE') - JOIN entryConfig ec + JOIN vn.entryConfig ec WHERE tr.landed >= vDateInventory AND vWarehouseFk = tr.warehouseInFk AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT e.isRaid - ), - deliveried AS ( - SELECT tr.shipped, - NULL, - b.quantity, - st.alertLevel, - st.name stateName, - s.name , - e.invoiceNumber, - e.id entryFk, - s.id supplierFk, - IF(st.`code` = 'DELIVERED' , TRUE, FALSE), - FALSE isTicket, - b.id, - NULL `order`, - NULL clientType, - NULL claimFk, - ec.inventorySupplierFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - JOIN warehouse w ON w.id = tr.warehouseOutFk - JOIN supplier s ON s.id = e.supplierFk - JOIN state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE() - OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived), - 'DELIVERED', + ), entriesOut AS ( + SELECT tr.shipped, + NULL, + b.quantity, + st.alertLevel, + st.name stateName, + s.name , + e.invoiceNumber, + e.id entryFk, + s.id supplierFk, + IF(st.`code` = 'DELIVERED' , TRUE, FALSE), + FALSE isTicket, + b.id, + NULL `order`, + NULL clientType, + NULL claimFk, + ec.inventorySupplierFk + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.warehouse w ON w.id = tr.warehouseOutFk + JOIN vn.supplier s ON s.id = e.supplierFk + JOIN vn.state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE() + OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived), + 'DELIVERED', 'FREE') - JOIN entryConfig ec - WHERE tr.shipped >= vDateInventory - AND vWarehouseFk = tr.warehouseOutFk - AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) - AND b.itemFk = vItemFk - AND NOT e.isExcludedFromAvailable - AND NOT w.isFeedStock - AND NOT e.isRaid - ), - sales AS ( - SELECT DATE(t.shipped) shipped, - s.quantity, - st2.alertLevel, - st2.name, - t.nickname, - t.refFk, - t.id ticketFk, - t.clientFk, - s.id saleFk, - st.`order`, - c.typeFk, - cb.claimFk - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.`code` = ts.`code` - JOIN client c ON c.id = t.clientFk - JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), - 'DELIVERED', - IF (t.shipped > util.dayEnd(util.VN_CURDATE()), - 'FREE', - IFNULL(ts.code, 'FREE'))) - LEFT JOIN claimBeginning cb ON s.id = cb.saleFk - WHERE t.shipped >= vDateInventory - AND s.itemFk = vItemFk - AND vWarehouseFk = t.warehouseFk - ),sale AS ( - SELECT s.shipped, + JOIN vn.entryConfig ec + WHERE tr.shipped >= vDateInventory + AND vWarehouseFk = tr.warehouseOutFk + AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) + AND b.itemFk = vItemFk + AND NOT e.isExcludedFromAvailable + AND NOT w.isFeedStock + AND NOT e.isRaid + ), sales AS ( + SELECT DATE(t.shipped) shipped, + s.quantity, + st2.alertLevel, + st2.name, + t.nickname, + t.refFk, + t.id ticketFk, + t.clientFk, + s.id saleFk, + st.`order`, + c.typeFk, + cb.claimFk + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id + LEFT JOIN vn.state st ON st.`code` = ts.`code` + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), + 'DELIVERED', + IF (t.shipped > util.dayEnd(util.VN_CURDATE()), + 'FREE', + IFNULL(ts.code, 'FREE'))) + LEFT JOIN vn.claimBeginning cb ON s.id = cb.saleFk + WHERE t.shipped >= vDateInventory + AND s.itemFk = vItemFk + AND vWarehouseFk = t.warehouseFk + ),sale AS ( + SELECT s.shipped, NULL `in`, s.quantity, s.alertLevel, @@ -153,40 +151,40 @@ BEGIN s.typeFk, s.claimFk, NULL - FROM sales s - LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' - LEFT JOIN saleTracking stk ON stk.saleFk = s.saleFk - AND stk.stateFk = stPrep.id - GROUP BY s.saleFk - ) SELECT shipped, - `in`, - `out`, - alertLevel, - stateName, - `name`, - reference, - origin, - clientFk, - isPicked, - isTicket, - lineFk, - `order`, - clientType, - claimFk, - inventorySupplierFk - FROM entries - UNION ALL - SELECT * FROM deliveried - UNION ALL - SELECT * FROM sale - ORDER BY shipped, - (inventorySupplierFk = clientFk) DESC, - alertLevel DESC, - isTicket, - `order` DESC, - isPicked DESC, - `in` DESC, - `out` DESC; + FROM vn.sales s + LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED' + LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk + AND stk.stateFk = stPrep.id + GROUP BY s.saleFk + ) SELECT shipped, + `in`, + `out`, + alertLevel, + stateName, + `name`, + reference, + origin, + clientFk, + isPicked, + isTicket, + lineFk, + `order`, + clientType, + claimFk, + inventorySupplierFk + FROM entriesIn + UNION ALL + SELECT * FROM entriesOut + UNION ALL + SELECT * FROM sale + ORDER BY shipped, + (inventorySupplierFk = clientFk) DESC, + alertLevel DESC, + isTicket, + `order` DESC, + isPicked DESC, + `in` DESC, + `out` DESC; IF vDate IS NULL THEN From e7df3fefc6a1d7d4d62e22f81a8cbb56c9fcecee Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 10 May 2024 13:11:41 +0200 Subject: [PATCH 5/6] feat: refs #7363 --- db/routines/vn/procedures/item_getBalance.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index 5e21047b4..a4942af6f 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -9,7 +9,7 @@ BEGIN * @vItemFk item a buscar * @vWarehouseFk almacen donde buscar * @vDate Si la fecha es null, muestra el histórico desde el inventario. - * Si la fecha no es null, muestra histórico desde la fecha pasada. + * Si la fecha no es null, muestra histórico desde la fecha de vDate. */ DECLARE vDateInventory DATETIME; @@ -151,7 +151,7 @@ BEGIN s.typeFk, s.claimFk, NULL - FROM vn.sales s + FROM sales s LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED' LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk AND stk.stateFk = stPrep.id From 473f261cf169fca52d56f6372354967ea478a2b3 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 10 May 2024 14:11:29 +0200 Subject: [PATCH 6/6] refs #7342 Modify decimal item plastic --- db/versions/11046-maroonCamellia/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/11046-maroonCamellia/00-firstScript.sql diff --git a/db/versions/11046-maroonCamellia/00-firstScript.sql b/db/versions/11046-maroonCamellia/00-firstScript.sql new file mode 100644 index 000000000..5e7faad35 --- /dev/null +++ b/db/versions/11046-maroonCamellia/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.item +MODIFY nonRecycledPlastic DECIMAL(10,2) DEFAULT NULL NULL, +MODIFY recycledPlastic DECIMAL(10,2) DEFAULT NULL NULL;