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';