From 9af3c17a1ffccbf60a1f2ce1736a5ccda31f78fe Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 29 Apr 2024 09:58:58 +0200 Subject: [PATCH 1/5] feat: refs #7291 sale_getProblems --- db/routines/vn/procedures/sale_getProblems.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index bf02e2401..c17eefbf9 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -34,7 +34,7 @@ BEGIN ticketFk INT(11), saleFk INT(11), isFreezed INTEGER(1) DEFAULT 0, - risk DECIMAL(10,2) DEFAULT 0, + risk DECIMAL(10,1) DEFAULT 0, hasHighRisk TINYINT(1) DEFAULT 0, hasTicketRequest INTEGER(1) DEFAULT 0, itemShortage VARCHAR(255), From 6c6ae412bd5fdfa48bbf6ae8324274b61e053399 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 7 May 2024 14:19:11 +0200 Subject: [PATCH 2/5] feat: refs #182001 packaging --- db/routines/vn/procedures/fv_pca.sql | 101 ------------------ .../11034-purpleHydrangea/00-firstScript.sql | 5 + 2 files changed, 5 insertions(+), 101 deletions(-) delete mode 100644 db/routines/vn/procedures/fv_pca.sql create mode 100644 db/versions/11034-purpleHydrangea/00-firstScript.sql diff --git a/db/routines/vn/procedures/fv_pca.sql b/db/routines/vn/procedures/fv_pca.sql deleted file mode 100644 index b8e7343ef..000000000 --- a/db/routines/vn/procedures/fv_pca.sql +++ /dev/null @@ -1,101 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`fv_pca`() -BEGIN - -DECLARE done INT DEFAULT FALSE; - -DECLARE vTicketFk INT; -DECLARE vSaleFk INT; -DECLARE vClonTicket INT DEFAULT 0; - -DECLARE cur1 CURSOR FOR -SELECT s.ticketFk, s.id - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - WHERE t.shipped BETWEEN '2020-10-18' AND '2020-10-31' - AND it.code IN ('ANT','ANS','ORQ','TRO') - and t.warehouseFk = 1; - -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - -OPEN cur1; - -FETCH cur1 INTO vTicketFk, vSaleFk; - - WHILE done = 0 DO - - SELECT t.id INTO vClonTicket - FROM vn.ticket t - JOIN (SELECT addressFk, shipped FROM vn.ticket WHERE id = vTicketFk) sub USING(addressFk, shipped) - WHERE t.warehouseFk = 44 - LIMIT 1; - - SELECT vTicketFk, vClonTicket; - - IF vClonTicket = 0 THEN - - INSERT INTO ticket ( - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - warehouseFk, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus, - routeFk - ) - SELECT - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - 44, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus, - routeFk - - FROM ticket - WHERE id = vTicketFk; - - SET vClonTicket = LAST_INSERT_ID(); - - SELECT 'lstID', vClonTicket; - /* - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vTicketFk, ao.observationTypeFk, ao.description - FROM addressObservation ao - JOIN ticket t ON t.addressFk = ao.addressFk - WHERE t.id = vClonTicket; -*/ - INSERT INTO ticketLog - SET originFk = vTicketFk, userFk = account.myUser_getId(), `action` = 'insert', - description = CONCAT('Ha creado el ticket:', ' ', vClonTicket, ' clonando el ', vTicketFk); - - END IF; - - UPDATE vn.sale - SET ticketFk = vClonTicket - WHERE id = vSaleFk; - - SET vClonTicket = 0; - - SET done = 0; - FETCH cur1 INTO vTicketFk, vSaleFk; - - END WHILE; - - CLOSE cur1; - - -END$$ -DELIMITER ; diff --git a/db/versions/11034-purpleHydrangea/00-firstScript.sql b/db/versions/11034-purpleHydrangea/00-firstScript.sql new file mode 100644 index 000000000..c8c2cc7f9 --- /dev/null +++ b/db/versions/11034-purpleHydrangea/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Place your SQL code here +ALTER TABLE vn.packaging +MODIFY COLUMN height decimal(10,2) DEFAULT NULL NULL, +MODIFY COLUMN `depth` decimal(10,2) DEFAULT NULL NULL, +MODIFY COLUMN width decimal(10,2) DEFAULT NULL NULL; From f529a7f5b42f136c795a351212b0ea9355b352a0 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 7 May 2024 14:25:26 +0200 Subject: [PATCH 3/5] feat : refs #182001 --- db/routines/vn/procedures/fv_pca.sql | 101 +++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 db/routines/vn/procedures/fv_pca.sql diff --git a/db/routines/vn/procedures/fv_pca.sql b/db/routines/vn/procedures/fv_pca.sql new file mode 100644 index 000000000..d0c37acd1 --- /dev/null +++ b/db/routines/vn/procedures/fv_pca.sql @@ -0,0 +1,101 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`fv_pca`() +BEGIN + +DECLARE done INT DEFAULT FALSE; + +DECLARE vTicketFk INT; +DECLARE vSaleFk INT; +DECLARE vClonTicket INT DEFAULT 0; + +DECLARE cur1 CURSOR FOR +SELECT s.ticketFk, s.id + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + WHERE t.shipped BETWEEN '2020-10-18' AND '2020-10-31' + AND it.code IN ('ANT','ANS','ORQ','TRO') + and t.warehouseFk = 1; + +DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + +OPEN cur1; + +FETCH cur1 INTO vTicketFk, vSaleFk; + + WHILE done = 0 DO + + SELECT t.id INTO vClonTicket + FROM vn.ticket t + JOIN (SELECT addressFk, shipped FROM vn.ticket WHERE id = vTicketFk) sub USING(addressFk, shipped) + WHERE t.warehouseFk = 44 + LIMIT 1; + + SELECT vTicketFk, vClonTicket; + + IF vClonTicket = 0 THEN + + INSERT INTO ticket ( + clientFk, + shipped, + addressFk, + agencyModeFk, + nickname, + warehouseFk, + companyFk, + landed, + zoneFk, + zonePrice, + zoneBonus, + routeFk + ) + SELECT + clientFk, + shipped, + addressFk, + agencyModeFk, + nickname, + 44, + companyFk, + landed, + zoneFk, + zonePrice, + zoneBonus, + routeFk + + FROM ticket + WHERE id = vTicketFk; + + SET vClonTicket = LAST_INSERT_ID(); + + SELECT 'lstID', vClonTicket; + /* + INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) + SELECT vTicketFk, ao.observationTypeFk, ao.description + FROM addressObservation ao + JOIN ticket t ON t.addressFk = ao.addressFk + WHERE t.id = vClonTicket; +*/ + INSERT INTO ticketLog + SET originFk = vTicketFk, userFk = account.myUser_getId(), `action` = 'insert', + description = CONCAT('Ha creado el ticket:', ' ', vClonTicket, ' clonando el ', vTicketFk); + + END IF; + + UPDATE vn.sale + SET ticketFk = vClonTicket + WHERE id = vSaleFk; + + SET vClonTicket = 0; + + SET done = 0; + FETCH cur1 INTO vTicketFk, vSaleFk; + + END WHILE; + + CLOSE cur1; + + +END$$ +DELIMITER ; \ No newline at end of file From f70f2949ec8882247ce1e5c3aba2377c96662205 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 7 May 2024 14:30:38 +0200 Subject: [PATCH 4/5] feat: refs #182001 --- db/routines/vn/procedures/fv_pca.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/fv_pca.sql b/db/routines/vn/procedures/fv_pca.sql index d0c37acd1..b8e7343ef 100644 --- a/db/routines/vn/procedures/fv_pca.sql +++ b/db/routines/vn/procedures/fv_pca.sql @@ -98,4 +98,4 @@ FETCH cur1 INTO vTicketFk, vSaleFk; END$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; From 393d57f078c27a553773581acab1a25987b4507b Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 8 May 2024 10:51:35 +0200 Subject: [PATCH 5/5] fix: #7344 getSupplierDebt agrupa por pago --- db/routines/vn/procedures/company_getSuppliersDebt.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/company_getSuppliersDebt.sql b/db/routines/vn/procedures/company_getSuppliersDebt.sql index 6335ccbe3..83043f337 100644 --- a/db/routines/vn/procedures/company_getSuppliersDebt.sql +++ b/db/routines/vn/procedures/company_getSuppliersDebt.sql @@ -188,11 +188,12 @@ BEGIN FROM tPendingDuedates vp LEFT JOIN supplier s ON s.id = vp.supplierFk LEFT JOIN client c ON c.fi = s.nif - LEFT JOIN clientRisk cr ON cr.clientFk = c.id + LEFT JOIN clientRisk cr ON cr.clientFk = c.id AND cr.companyFk = vp.companyFk LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk - LEFT JOIN country co ON co.id = be.countryFk; + LEFT JOIN country co ON co.id = be.countryFk + GROUP BY vp.id; DROP TEMPORARY TABLE tOpeningBalances; DROP TEMPORARY TABLE tPendingDuedates;