From 9e3b4e84515e832a454b161f7a12f8e63138012c Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 19 Feb 2024 13:30:03 +0100 Subject: [PATCH 1/7] refs #6842 sql mod sage --- .../vn/triggers/invoiceOut_beforeInsert.sql | 12 +++---- db/versions/10893-limeFern/00-sage.sql | 35 +++++++++++++++++++ 2 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 db/versions/10893-limeFern/00-sage.sql diff --git a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql index 0081c8803..f3a292edd 100644 --- a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql @@ -17,16 +17,16 @@ BEGIN DECLARE vRefLen INT; DECLARE vRefPrefix VARCHAR(255); DECLARE vLastRef VARCHAR(255); - DECLARE vCompanyCode INT; + DECLARE vSage200Company INT; DECLARE vYearLen INT DEFAULT 2; DECLARE vPrefixLen INT; - SELECT companyCode INTO vCompanyCode + SELECT sage200Company INTO vSage200Company FROM company WHERE id = NEW.companyFk; - IF vCompanyCode IS NULL THEN - CALL util.throw('companyCodeNotDefined'); + IF vSage200Company IS NULL THEN + CALL util.throw('vSage200CompanyNotDefined'); END IF; SELECT MAX(i.ref) INTO vLastRef @@ -36,7 +36,7 @@ BEGIN AND i.companyFk = NEW.companyFk; IF vLastRef IS NOT NULL THEN - SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vCompanyCode) + vYearLen; + SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vSage200Company) + vYearLen; SET vRefLen = LENGTH(vLastRef) - vPrefixLen; SET vRefPrefix = LEFT(vLastRef, vPrefixLen); SET vRef = RIGHT(vLastRef, vRefLen); @@ -44,7 +44,7 @@ BEGIN SELECT refLen INTO vRefLen FROM invoiceOutConfig; SET vRefPrefix = CONCAT( NEW.serial, - vCompanyCode, + vSage200Company, RIGHT(YEAR(NEW.issued), vYearLen) ); END IF; diff --git a/db/versions/10893-limeFern/00-sage.sql b/db/versions/10893-limeFern/00-sage.sql new file mode 100644 index 000000000..049bb2993 --- /dev/null +++ b/db/versions/10893-limeFern/00-sage.sql @@ -0,0 +1,35 @@ +-- Auto-generated SQL script #202402151810 +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=69; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=567; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=791; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=792; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=965; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=1381; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=1463; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=2142; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=2292; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=2393; +UPDATE vn.company + SET companyGroupFk=NULL + WHERE id=3869; +ALTER TABLE vn.company MODIFY COLUMN sage200Company int(2) DEFAULT NULL NULL COMMENT 'Campo para la serie InvoiceOut'; From 59a0cb3f4aa9e461f7143e7d8666afa22cd11161 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 6 Mar 2024 13:08:20 +0100 Subject: [PATCH 2/7] refs #6842 deprecated and move --- .../vn/triggers/invoiceOut_beforeInsert.sql | 12 ++-- db/versions/10893-limeFern/00-sage.sql | 57 ++++++++++++------- 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql index f3a292edd..eb5c1150f 100644 --- a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql @@ -17,16 +17,16 @@ BEGIN DECLARE vRefLen INT; DECLARE vRefPrefix VARCHAR(255); DECLARE vLastRef VARCHAR(255); - DECLARE vSage200Company INT; + DECLARE vCompanyCode INT; DECLARE vYearLen INT DEFAULT 2; DECLARE vPrefixLen INT; - SELECT sage200Company INTO vSage200Company + SELECT companyCode INTO vCompanyCode FROM company WHERE id = NEW.companyFk; - IF vSage200Company IS NULL THEN - CALL util.throw('vSage200CompanyNotDefined'); + IF vCompanyCode IS NULL THEN + CALL util.throw('vCompanyCodeNotDefined'); END IF; SELECT MAX(i.ref) INTO vLastRef @@ -36,7 +36,7 @@ BEGIN AND i.companyFk = NEW.companyFk; IF vLastRef IS NOT NULL THEN - SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vSage200Company) + vYearLen; + SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vCompanyCode) + vYearLen; SET vRefLen = LENGTH(vLastRef) - vPrefixLen; SET vRefPrefix = LEFT(vLastRef, vPrefixLen); SET vRef = RIGHT(vLastRef, vRefLen); @@ -44,7 +44,7 @@ BEGIN SELECT refLen INTO vRefLen FROM invoiceOutConfig; SET vRefPrefix = CONCAT( NEW.serial, - vSage200Company, + vCompanyCode, RIGHT(YEAR(NEW.issued), vYearLen) ); END IF; diff --git a/db/versions/10893-limeFern/00-sage.sql b/db/versions/10893-limeFern/00-sage.sql index 049bb2993..9d076050e 100644 --- a/db/versions/10893-limeFern/00-sage.sql +++ b/db/versions/10893-limeFern/00-sage.sql @@ -1,35 +1,54 @@ --- Auto-generated SQL script #202402151810 +-- Auto-generated SQL script #202403061303 UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=0 WHERE id=69; UPDATE vn.company - SET companyGroupFk=NULL - WHERE id=567; -UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=0 WHERE id=791; UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=3 WHERE id=792; UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=5 WHERE id=965; UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=7 WHERE id=1381; UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=3 WHERE id=1463; UPDATE vn.company - SET companyGroupFk=NULL - WHERE id=2142; -UPDATE vn.company - SET companyGroupFk=NULL - WHERE id=2292; -UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=6 WHERE id=2393; UPDATE vn.company - SET companyGroupFk=NULL + SET companyCode=9 WHERE id=3869; -ALTER TABLE vn.company MODIFY COLUMN sage200Company int(2) DEFAULT NULL NULL COMMENT 'Campo para la serie InvoiceOut'; + +-- Auto-generated SQL script #202403061303 +UPDATE vn.company + SET companyCode=0 + WHERE id=69; +UPDATE vn.company + SET companyCode=0 + WHERE id=791; +UPDATE vn.company + SET companyCode=3 + WHERE id=792; +UPDATE vn.company + SET companyCode=5 + WHERE id=965; +UPDATE vn.company + SET companyCode=7 + WHERE id=1381; +UPDATE vn.company + SET companyCode=3 + WHERE id=1463; +UPDATE vn.company + SET companyCode=6 + WHERE id=2393; +UPDATE vn.company + SET companyCode=9 + WHERE id=3869; + +ALTER TABLE vn.company CHANGE sage200Company sage200Company__ int(2) DEFAULT NULL NULL COMMENT '@deprecated 06/03/2024'; +ALTER TABLE vn.company MODIFY COLUMN sage200Company__ int(2) DEFAULT NULL NULL COMMENT '@deprecated 06/03/2024'; From a24445439ab389ebf8054f766d81bbd1e2b1c3af Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 6 Mar 2024 13:09:03 +0100 Subject: [PATCH 3/7] remove v --- db/routines/vn/triggers/invoiceOut_beforeInsert.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql index eb5c1150f..8eb25e710 100644 --- a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql @@ -26,7 +26,7 @@ BEGIN WHERE id = NEW.companyFk; IF vCompanyCode IS NULL THEN - CALL util.throw('vCompanyCodeNotDefined'); + CALL util.throw('CompanyCodeNotDefined'); END IF; SELECT MAX(i.ref) INTO vLastRef From 6a13a33f840b550c72b6dfd34fe4f6bd9ec12d0a Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 6 Mar 2024 13:09:41 +0100 Subject: [PATCH 4/7] min c --- db/routines/vn/triggers/invoiceOut_beforeInsert.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql index 8eb25e710..0081c8803 100644 --- a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql @@ -26,7 +26,7 @@ BEGIN WHERE id = NEW.companyFk; IF vCompanyCode IS NULL THEN - CALL util.throw('CompanyCodeNotDefined'); + CALL util.throw('companyCodeNotDefined'); END IF; SELECT MAX(i.ref) INTO vLastRef From 58a239708d1dca4dbd23af0f260ad03e801d8790 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 6 Mar 2024 13:11:41 +0100 Subject: [PATCH 5/7] refs #6842 remove sage --- db/versions/10893-limeFern/00-sage.sql | 28 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/db/versions/10893-limeFern/00-sage.sql b/db/versions/10893-limeFern/00-sage.sql index 9d076050e..01508b932 100644 --- a/db/versions/10893-limeFern/00-sage.sql +++ b/db/versions/10893-limeFern/00-sage.sql @@ -24,31 +24,41 @@ UPDATE vn.company SET companyCode=9 WHERE id=3869; --- Auto-generated SQL script #202403061303 +-- Auto-generated SQL script #202403061311 UPDATE vn.company - SET companyCode=0 + SET sage200Company=NULL WHERE id=69; UPDATE vn.company - SET companyCode=0 + SET sage200Company=NULL + WHERE id=442; +UPDATE vn.company + SET sage200Company=NULL + WHERE id=567; +UPDATE vn.company + SET sage200Company=NULL WHERE id=791; UPDATE vn.company - SET companyCode=3 + SET sage200Company=NULL WHERE id=792; UPDATE vn.company - SET companyCode=5 + SET sage200Company=NULL WHERE id=965; UPDATE vn.company - SET companyCode=7 + SET sage200Company=NULL WHERE id=1381; UPDATE vn.company - SET companyCode=3 + SET sage200Company=NULL WHERE id=1463; UPDATE vn.company - SET companyCode=6 + SET sage200Company=NULL + WHERE id=2142; +UPDATE vn.company + SET sage200Company=NULL WHERE id=2393; UPDATE vn.company - SET companyCode=9 + SET sage200Company=NULL WHERE id=3869; + ALTER TABLE vn.company CHANGE sage200Company sage200Company__ int(2) DEFAULT NULL NULL COMMENT '@deprecated 06/03/2024'; ALTER TABLE vn.company MODIFY COLUMN sage200Company__ int(2) DEFAULT NULL NULL COMMENT '@deprecated 06/03/2024'; From b051b0512fcb8abf63c2207cee732d641ce746c7 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 11 Mar 2024 09:48:29 +0100 Subject: [PATCH 6/7] refs #6842 fix fixtures --- db/dump/fixtures.before.sql | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 094b956af..05e183bfd 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -592,13 +592,13 @@ INSERT INTO `vn`.`supplierAccount`(`id`, `supplierFk`, `iban`, `bankEntityFk`) VALUES (241, 442, 'ES111122333344111122221111', 128); -INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `sage200Company`, `expired`, `companyGroupFk`, `phytosanitary` , `clientFk`) +INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `expired`, `companyGroupFk`, `phytosanitary` , `clientFk`) VALUES - (69 , 'CCs', NULL, 30, NULL, 0, NULL, 1, NULL , NULL), - (442 , 'VNL', 241, 30, 2 , 1, NULL, 2, 'VNL Company - Plant passport' , 1101), - (567 , 'VNH', NULL, 30, NULL, 4, NULL, 1, 'VNH Company - Plant passport' , NULL), - (791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30', 1, NULL , NULL), - (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport' , NULL); + (69 , 'CCs', NULL, 30, 0, NULL, 1, NULL , NULL), + (442 , 'VNL', 241, 30, 1, NULL, 2, 'VNL Company - Plant passport' , 1101), + (567 , 'VNH', NULL, 30, 4, NULL, 1, 'VNH Company - Plant passport' , NULL), + (791 , 'FTH', NULL, 30, 3, '2015-11-30', 1, NULL , NULL), + (1381, 'ORN', NULL, 30, 7, NULL, 1, 'ORN Company - Plant passport' , NULL); INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`) VALUES @@ -728,7 +728,7 @@ INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agen INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`) VALUES (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1), - (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2), + (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2), (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3), (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL), (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL), From e24eed16c1b3240cd1bbb80010c7cbb08af0768f Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 14 Mar 2024 08:26:50 +0100 Subject: [PATCH 7/7] refs #6842 fix companyCode --- db/versions/10893-limeFern/00-sage.sql | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/db/versions/10893-limeFern/00-sage.sql b/db/versions/10893-limeFern/00-sage.sql index 01508b932..d4c7e6221 100644 --- a/db/versions/10893-limeFern/00-sage.sql +++ b/db/versions/10893-limeFern/00-sage.sql @@ -3,7 +3,13 @@ UPDATE vn.company SET companyCode=0 WHERE id=69; UPDATE vn.company - SET companyCode=0 + SET companyCode=1 + WHERE id=442; +UPDATE vn.company + SET companyCode=4 + WHERE id=567; +UPDATE vn.company + SET companyCode=2 WHERE id=791; UPDATE vn.company SET companyCode=3 @@ -17,6 +23,9 @@ UPDATE vn.company UPDATE vn.company SET companyCode=3 WHERE id=1463; +UPDATE vn.company + SET companyCode=8 + WHERE id=2142; UPDATE vn.company SET companyCode=6 WHERE id=2393;