refs #6842 sql mod sage
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Carlos Satorres 2024-02-19 13:30:03 +01:00
parent 7a0320270a
commit 9e3b4e8451
2 changed files with 41 additions and 6 deletions

View File

@ -17,16 +17,16 @@ BEGIN
DECLARE vRefLen INT; DECLARE vRefLen INT;
DECLARE vRefPrefix VARCHAR(255); DECLARE vRefPrefix VARCHAR(255);
DECLARE vLastRef VARCHAR(255); DECLARE vLastRef VARCHAR(255);
DECLARE vCompanyCode INT; DECLARE vSage200Company INT;
DECLARE vYearLen INT DEFAULT 2; DECLARE vYearLen INT DEFAULT 2;
DECLARE vPrefixLen INT; DECLARE vPrefixLen INT;
SELECT companyCode INTO vCompanyCode SELECT sage200Company INTO vSage200Company
FROM company FROM company
WHERE id = NEW.companyFk; WHERE id = NEW.companyFk;
IF vCompanyCode IS NULL THEN IF vSage200Company IS NULL THEN
CALL util.throw('companyCodeNotDefined'); CALL util.throw('vSage200CompanyNotDefined');
END IF; END IF;
SELECT MAX(i.ref) INTO vLastRef SELECT MAX(i.ref) INTO vLastRef
@ -36,7 +36,7 @@ BEGIN
AND i.companyFk = NEW.companyFk; AND i.companyFk = NEW.companyFk;
IF vLastRef IS NOT NULL THEN 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 vRefLen = LENGTH(vLastRef) - vPrefixLen;
SET vRefPrefix = LEFT(vLastRef, vPrefixLen); SET vRefPrefix = LEFT(vLastRef, vPrefixLen);
SET vRef = RIGHT(vLastRef, vRefLen); SET vRef = RIGHT(vLastRef, vRefLen);
@ -44,7 +44,7 @@ BEGIN
SELECT refLen INTO vRefLen FROM invoiceOutConfig; SELECT refLen INTO vRefLen FROM invoiceOutConfig;
SET vRefPrefix = CONCAT( SET vRefPrefix = CONCAT(
NEW.serial, NEW.serial,
vCompanyCode, vSage200Company,
RIGHT(YEAR(NEW.issued), vYearLen) RIGHT(YEAR(NEW.issued), vYearLen)
); );
END IF; END IF;

View File

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