From 4ebda1a06ffe0bdaf67bf4b1e5ea99a6383775e2 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 26 Sep 2024 14:06:45 +0200 Subject: [PATCH 01/42] feat: refs #7010 added filter fields to show packing type field in ticket list --- modules/ticket/back/methods/ticket/filter.js | 96 +++++++++++--------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 06781c3c8..b72f224bf 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -228,52 +228,55 @@ module.exports = Self => { stmt = new ParameterizedSQL(` CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) - ENGINE = MEMORY + ENGINE = InnoDB SELECT t.id, - t.shipped, - CAST(DATE(t.shipped) AS CHAR) shippedDate, - HOUR(t.shipped) shippedHour, - t.nickname, - t.refFk, - t.routeFk, - t.warehouseFk, - t.clientFk, - t.totalWithoutVat, - t.totalWithVat, - io.id invoiceOutId, - a.provinceFk, - p.name province, - w.name warehouse, - am.name agencyMode, - am.id agencyModeFk, - st.name state, - st.classColor, - wk.lastName salesPerson, - ts.stateFk stateFk, - ts.alertLevel alertLevel, - ts.code alertLevelCode, - u.name userName, - c.salesPersonFk, - z.hour zoneLanding, - HOUR(z.hour) zoneHour, - MINUTE(z.hour) zoneMinute, - z.name zoneName, - z.id zoneFk, - CAST(z.hour AS CHAR) hour, - a.nickname addressNickname - FROM ticket t - LEFT JOIN invoiceOut io ON t.refFk = io.ref - LEFT JOIN zone z ON z.id = t.zoneFk - LEFT JOIN address a ON a.id = t.addressFk - LEFT JOIN province p ON p.id = a.provinceFk - LEFT JOIN warehouse w ON w.id = t.warehouseFk - LEFT JOIN agencyMode am ON am.id = t.agencyModeFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.id = ts.stateFk - LEFT JOIN client c ON c.id = t.clientFk - LEFT JOIN worker wk ON wk.id = c.salesPersonFk - LEFT JOIN account.user u ON u.id = wk.id - LEFT JOIN route r ON r.id = t.routeFk + t.shipped, + CAST(DATE(t.shipped) AS CHAR) shippedDate, + HOUR(t.shipped) shippedHour, + t.nickname, + t.refFk, + t.routeFk, + t.warehouseFk, + t.clientFk, + t.totalWithoutVat, + t.totalWithVat, + io.id invoiceOutId, + a.provinceFk, + p.name province, + w.name warehouse, + am.name agencyMode, + am.id agencyModeFk, + st.name state, + st.classColor, + wk.lastName salesPerson, + ts.stateFk stateFk, + ts.alertLevel alertLevel, + ts.code alertLevelCode, + u.name userName, + c.salesPersonFk, + z.hour zoneLanding, + HOUR(z.hour) zoneHour, + MINUTE(z.hour) zoneMinute, + z.name zoneName, + z.id zoneFk, + CAST(z.hour AS CHAR) hour, + a.nickname addressNickname, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk SEPARATOR ', ') packing + FROM ticket t + LEFT JOIN invoiceOut io ON t.refFk = io.ref + LEFT JOIN zone z ON z.id = t.zoneFk + LEFT JOIN address a ON a.id = t.addressFk + LEFT JOIN province p ON p.id = a.provinceFk + LEFT JOIN warehouse w ON w.id = t.warehouseFk + LEFT JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + LEFT JOIN state st ON st.id = ts.stateFk + LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN worker wk ON wk.id = c.salesPersonFk + LEFT JOIN account.user u ON u.id = wk.id + LEFT JOIN route r ON r.id = t.routeFk + LEFT JOIN sale s ON t.id = s.ticketFk + LEFT JOIN item i ON i.id = s.itemFk `); if (args.orderFk) { @@ -292,6 +295,9 @@ module.exports = Self => { } stmt.merge(conn.makeWhere(filter.where)); + stmt.merge({ + sql: `GROUP BY t.id` + }); stmts.push(stmt); stmt = new ParameterizedSQL(` From b547858820d4e42de35105611a64557f3ee678e3 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 27 Sep 2024 08:28:12 +0200 Subject: [PATCH 02/42] perf: refs #7010 showing field correctly --- modules/ticket/back/methods/ticket/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index b72f224bf..37150e6e9 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -261,7 +261,7 @@ module.exports = Self => { z.id zoneFk, CAST(z.hour AS CHAR) hour, a.nickname addressNickname, - GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk SEPARATOR ', ') packing + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk SEPARATOR ',') packing FROM ticket t LEFT JOIN invoiceOut io ON t.refFk = io.ref LEFT JOIN zone z ON z.id = t.zoneFk From b55db4bdc00f0ab0e6e20604e268c7d3a0e4e73f Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 30 Sep 2024 14:09:57 +0200 Subject: [PATCH 03/42] feat: refs #7010 added subquery to avoid using group by in sql --- modules/ticket/back/methods/ticket/filter.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 37150e6e9..d7e77603b 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -229,7 +229,7 @@ module.exports = Self => { CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) ENGINE = InnoDB - SELECT t.id, + SELECT DISTINCT t.id, t.shipped, CAST(DATE(t.shipped) AS CHAR) shippedDate, HOUR(t.shipped) shippedHour, @@ -261,7 +261,11 @@ module.exports = Self => { z.id zoneFk, CAST(z.hour AS CHAR) hour, a.nickname addressNickname, - GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk SEPARATOR ',') packing + (SELECT GROUP_CONCAT(DISTINCT i2.itemPackingTypeFk ORDER BY i2.itemPackingTypeFk SEPARATOR ',') + FROM sale s2 + JOIN item i2 ON i2.id = s2.itemFk + WHERE s2.ticketFk = t.id + ) AS packing FROM ticket t LEFT JOIN invoiceOut io ON t.refFk = io.ref LEFT JOIN zone z ON z.id = t.zoneFk @@ -275,8 +279,6 @@ module.exports = Self => { LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN account.user u ON u.id = wk.id LEFT JOIN route r ON r.id = t.routeFk - LEFT JOIN sale s ON t.id = s.ticketFk - LEFT JOIN item i ON i.id = s.itemFk `); if (args.orderFk) { @@ -295,9 +297,7 @@ module.exports = Self => { } stmt.merge(conn.makeWhere(filter.where)); - stmt.merge({ - sql: `GROUP BY t.id` - }); + stmts.push(stmt); stmt = new ParameterizedSQL(` From 952f8f3dfcb6976b98d33ba3ab5da5286f8de632 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 7 Oct 2024 15:14:03 +0200 Subject: [PATCH 04/42] feat(Docuware): refs #8066 use oath --- back/methods/docuware/core.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 74d922236..760909aa3 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -8,12 +8,22 @@ module.exports = Self => { * @return {object} - The headers */ Self.getOptions = async() => { - const docuwareConfig = await Self.app.models.DocuwareConfig.findOne(); + const {url, username, password} = await Self.app.models.DocuwareConfig.findOne(); + const {IdentityServiceUrl} = await axios.get(`${url}/Home/IdentityServiceInfo`); + const {token_endpoint} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`); + const {access_token} = await axios.post(token_endpoint, { + grant_type: 'password', + scope: 'docuware.platform', + client_id: 'docuware.platform.net.client', + username, // falta añadirlos + password // falta añadirlos + }); + const headers = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', - 'Cookie': docuwareConfig.cookie + 'access_token': access_token } }; From b4dc5276ddf9f16678cbdc4664b890d563d6e263 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 8 Oct 2024 08:36:17 +0200 Subject: [PATCH 05/42] fix: refs #7986 create fk --- db/versions/11290-blackOrchid/00-firstScript.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 db/versions/11290-blackOrchid/00-firstScript.sql diff --git a/db/versions/11290-blackOrchid/00-firstScript.sql b/db/versions/11290-blackOrchid/00-firstScript.sql new file mode 100644 index 000000000..e573e9e32 --- /dev/null +++ b/db/versions/11290-blackOrchid/00-firstScript.sql @@ -0,0 +1,6 @@ + +ALTER TABLE `vn`.`worker` +ADD COLUMN `motoFk` INT(11) UNSIGNED DEFAULT NULL; + +ALTER TABLE `vn`.`worker` +ADD CONSTRAINT `worker_machineFk` FOREIGN KEY (`motoFk`) REFERENCES `machine` (`id`) ON UPDATE CASCADE ON DELETE SET NULL; From 9695fea48f30207dffe9897993af2446acb23b9a Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 8 Oct 2024 12:05:19 +0200 Subject: [PATCH 06/42] feat(Docuware): refs #8066 add username and password --- back/methods/docuware/core.js | 25 ++++++++++--------- back/models/docuware-config.json | 17 ++++++------- .../11291-purpleChico/00-firstScript.sql | 2 ++ 3 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 db/versions/11291-purpleChico/00-firstScript.sql diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 760909aa3..9545cd878 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -9,15 +9,16 @@ module.exports = Self => { */ Self.getOptions = async() => { const {url, username, password} = await Self.app.models.DocuwareConfig.findOne(); - const {IdentityServiceUrl} = await axios.get(`${url}/Home/IdentityServiceInfo`); - const {token_endpoint} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`); - const {access_token} = await axios.post(token_endpoint, { + const {data: {IdentityServiceUrl}} = await axios.get(`${url}/Home/IdentityServiceInfo`); + const {data: {token_endpoint}} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`); + const data = await axios.post(token_endpoint, JSON.stringify({ grant_type: 'password', scope: 'docuware.platform', client_id: 'docuware.platform.net.client', - username, // falta añadirlos - password // falta añadirlos - }); + username, + password + })); + console.log('data: ', data); const headers = { headers: { @@ -42,8 +43,8 @@ module.exports = Self => { * @return {number} - The fileCabinet id */ Self.getDialog = async(code, action, fileCabinetId) => { - if (!process.env.NODE_ENV) - return Math.floor(Math.random() + 100); + // if (!process.env.NODE_ENV) + // return Math.floor(Math.random() + 100); const docuwareInfo = await Self.app.models.Docuware.findOne({ where: { @@ -69,8 +70,8 @@ module.exports = Self => { * @return {number} - The fileCabinet id */ Self.getFileCabinet = async code => { - if (!process.env.NODE_ENV) - return Math.floor(Math.random() + 100); + // if (!process.env.NODE_ENV) + // return Math.floor(Math.random() + 100); const options = await Self.getOptions(); const docuwareInfo = await Self.app.models.Docuware.findOne({ @@ -95,7 +96,7 @@ module.exports = Self => { * @return {object} - The data */ Self.get = async(code, filter, parse) => { - if (!process.env.NODE_ENV) return; + // if (!process.env.NODE_ENV) return; const options = await Self.getOptions(); const fileCabinetId = await Self.getFileCabinet(code); @@ -118,7 +119,7 @@ module.exports = Self => { * @return {object} - The data */ Self.getById = async(code, id, parse) => { - if (!process.env.NODE_ENV) return; + // if (!process.env.NODE_ENV) return; const docuwareInfo = await Self.app.models.Docuware.findOne({ fields: ['findById'], diff --git a/back/models/docuware-config.json b/back/models/docuware-config.json index 9d06c4874..244ae2790 100644 --- a/back/models/docuware-config.json +++ b/back/models/docuware-config.json @@ -18,15 +18,12 @@ }, "cookie": { "type": "string" + }, + "username": { + "type": "string" + }, + "password": { + "type": "string" } - }, - "acls": [ - { - "property": "*", - "accessType": "*", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] + } } diff --git a/db/versions/11291-purpleChico/00-firstScript.sql b/db/versions/11291-purpleChico/00-firstScript.sql new file mode 100644 index 000000000..db66c4c98 --- /dev/null +++ b/db/versions/11291-purpleChico/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS username varchar(100) NULL; +ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS password varchar(100) NULL; From 39e808bca764d2283994b18758413a6882e44283 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 8 Oct 2024 16:06:38 +0200 Subject: [PATCH 07/42] fix: refs #7986 fix model --- db/versions/11290-blackOrchid/00-firstScript.sql | 9 +++------ modules/worker/back/models/operator.json | 14 +++++++++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/db/versions/11290-blackOrchid/00-firstScript.sql b/db/versions/11290-blackOrchid/00-firstScript.sql index e573e9e32..e0c0e391c 100644 --- a/db/versions/11290-blackOrchid/00-firstScript.sql +++ b/db/versions/11290-blackOrchid/00-firstScript.sql @@ -1,6 +1,3 @@ - -ALTER TABLE `vn`.`worker` -ADD COLUMN `motoFk` INT(11) UNSIGNED DEFAULT NULL; - -ALTER TABLE `vn`.`worker` -ADD CONSTRAINT `worker_machineFk` FOREIGN KEY (`motoFk`) REFERENCES `machine` (`id`) ON UPDATE CASCADE ON DELETE SET NULL; +ALTER TABLE `vn`.`operator` +ADD COLUMN `machineFk` int(11) DEFAULT NULL, +ADD CONSTRAINT `operator_machine_FK` FOREIGN KEY (`machineFk`) REFERENCES `vn`.`machine` (`id`) ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/modules/worker/back/models/operator.json b/modules/worker/back/models/operator.json index d4832bccf..9933babc6 100644 --- a/modules/worker/back/models/operator.json +++ b/modules/worker/back/models/operator.json @@ -30,7 +30,10 @@ "isOnReservationMode": { "type": "boolean", "required": true - } + }, + "machineFk": { + "type": "number" + } }, "relations": { "sector": { @@ -53,6 +56,11 @@ "model": "ItemPackingType", "foreignKey": "itemPackingTypeFk", "primaryKey": "code" - } + }, + "machine": { + "type": "belongsTo", + "model": "Machine", + "foreignKey": "machineFk" + } } -} \ No newline at end of file +} From 3c881d5e483b904dfcb0be489e313345099c755a Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 15 Oct 2024 08:00:19 +0200 Subject: [PATCH 08/42] refactor(docuware): refs #8066 use Authorization --- back/methods/docuware/core.js | 42 ++++++++++++------- back/methods/docuware/upload.js | 2 +- back/models/docuware-config.json | 5 ++- .../11291-purpleChico/00-firstScript.sql | 2 + 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 9545cd878..6d3bb58ed 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -4,32 +4,45 @@ module.exports = Self => { /** * Returns basic headers * - * @param {string} cookie - The docuware cookie * @return {object} - The headers */ Self.getOptions = async() => { - const {url, username, password} = await Self.app.models.DocuwareConfig.findOne(); - const {data: {IdentityServiceUrl}} = await axios.get(`${url}/Home/IdentityServiceInfo`); - const {data: {token_endpoint}} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`); - const data = await axios.post(token_endpoint, JSON.stringify({ - grant_type: 'password', - scope: 'docuware.platform', - client_id: 'docuware.platform.net.client', - username, - password - })); - console.log('data: ', data); + const docuwareConfig = await Self.app.models.DocuwareConfig.findOne(); + const now = new Date().getTime(); + let {url, username, password, token, expired} = docuwareConfig; + + if (!expired || expired < now + 60) { + const {data: {IdentityServiceUrl}} = await axios.get(`${url}/Home/IdentityServiceInfo`); + const {data: {token_endpoint}} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`); + const {data} = await axios.post(token_endpoint, { + grant_type: 'password', + scope: 'docuware.platform', + client_id: 'docuware.platform.net.client', + username, + password + }, {headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/x-www-form-urlencoded' + }}); + + const newToken = data.access_token; + token = data.token_type + ' ' + newToken; + await docuwareConfig.updateAttributes({ + token, + expired: now + data.expires_in + }); + } const headers = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', - 'access_token': access_token + 'Authorization': token } }; return { - url: docuwareConfig.url, + url, headers }; }; @@ -80,6 +93,7 @@ module.exports = Self => { } }); + console.log('options.headers: ', options.headers); const fileCabinetResponse = await axios.get(`${options.url}/FileCabinets`, options.headers); const fileCabinets = fileCabinetResponse.data.FileCabinet; const fileCabinetId = fileCabinets.find(fileCabinet => fileCabinet.Name === docuwareInfo.fileCabinetName).Id; diff --git a/back/methods/docuware/upload.js b/back/methods/docuware/upload.js index 0102911e0..5b35b7598 100644 --- a/back/methods/docuware/upload.js +++ b/back/methods/docuware/upload.js @@ -143,7 +143,7 @@ module.exports = Self => { headers: { 'Content-Type': 'multipart/form-data', 'X-File-ModifiedDate': Date.vnNew(), - 'Cookie': docuwareOptions.headers.headers.Cookie, + 'Authorization': docuwareOptions.headers.headers.Authorization, ...data.getHeaders() }, }; diff --git a/back/models/docuware-config.json b/back/models/docuware-config.json index 244ae2790..b15cb4c03 100644 --- a/back/models/docuware-config.json +++ b/back/models/docuware-config.json @@ -16,7 +16,7 @@ "url": { "type": "string" }, - "cookie": { + "token": { "type": "string" }, "username": { @@ -24,6 +24,9 @@ }, "password": { "type": "string" + }, + "expired":{ + "type": "number" } } } diff --git a/db/versions/11291-purpleChico/00-firstScript.sql b/db/versions/11291-purpleChico/00-firstScript.sql index db66c4c98..e60b90376 100644 --- a/db/versions/11291-purpleChico/00-firstScript.sql +++ b/db/versions/11291-purpleChico/00-firstScript.sql @@ -1,2 +1,4 @@ ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS username varchar(100) NULL; ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS password varchar(100) NULL; +ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS token text NULL; +ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS expired int(11) NULL; From 52e573501ad4d5fa120291b24f1ba9cf53dfaea0 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 15 Oct 2024 08:46:43 +0200 Subject: [PATCH 09/42] feat: refs #8108 create tables itemTag --- .../11300-limeMedeola/00-firstScript.sql | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 db/versions/11300-limeMedeola/00-firstScript.sql diff --git a/db/versions/11300-limeMedeola/00-firstScript.sql b/db/versions/11300-limeMedeola/00-firstScript.sql new file mode 100644 index 000000000..21920b692 --- /dev/null +++ b/db/versions/11300-limeMedeola/00-firstScript.sql @@ -0,0 +1,85 @@ +CREATE TABLE IF NOT EXISTS `vn`.`itemFarmingTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemFarmingTag` (`name`) VALUES ('Enraizado'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemFarmingTag' + WHERE name= 'cultivo'; + + + +CREATE TABLE IF NOT EXISTS `vn`.`itemWrappingTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Bolsa'); +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Caja cartón'); +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Caja decorativa'); +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Celofán'); +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Papel kraft'); +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Plástico'); +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Variable'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemWrappingTag' + WHERE name= 'Envoltorio'; + + + +CREATE TABLE IF NOT EXISTS `vn`.`itemLanguageTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Castellano'); +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Catalán'); +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Euskera'); +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Francés'); +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Gallego'); +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Inglés'); +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Portugués'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemLanguageTag' + WHERE name= 'Idioma'; + + + +CREATE TABLE IF NOT EXISTS `vn`.`itemStemTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemStemTag` (`name`) VALUES ('Natural'); +INSERT IGNORE INTO `vn`.`itemStemTag` (`name`) VALUES ('Seminatural'); +INSERT IGNORE INTO `vn`.`itemStemTag` (`name`) VALUES ('Sintético'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemStemTag' + WHERE name= 'Tronco'; + + +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemWrappingTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemLanguageTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemStemTag TO logisticAssist; \ No newline at end of file From c73fd51a9ca6ff5a5cf1d7490a2ba83b1f566d85 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 15 Oct 2024 09:45:14 +0200 Subject: [PATCH 10/42] fix: refs #7986 add acl --- db/versions/11290-blackOrchid/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/versions/11290-blackOrchid/00-firstScript.sql b/db/versions/11290-blackOrchid/00-firstScript.sql index e0c0e391c..fe568ed6e 100644 --- a/db/versions/11290-blackOrchid/00-firstScript.sql +++ b/db/versions/11290-blackOrchid/00-firstScript.sql @@ -1,3 +1,6 @@ ALTER TABLE `vn`.`operator` ADD COLUMN `machineFk` int(11) DEFAULT NULL, ADD CONSTRAINT `operator_machine_FK` FOREIGN KEY (`machineFk`) REFERENCES `vn`.`machine` (`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Machine','*','*','ALLOW','ROLE','productionBoss'); From b1b36a33a0eb7fb2215305ef56bb3e12c650ca8b Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 15 Oct 2024 09:47:39 +0200 Subject: [PATCH 11/42] chore(docuware_core): refs #8066 add returns --- back/methods/docuware/core.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 6d3bb58ed..391a8b4ab 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -56,8 +56,8 @@ module.exports = Self => { * @return {number} - The fileCabinet id */ Self.getDialog = async(code, action, fileCabinetId) => { - // if (!process.env.NODE_ENV) - // return Math.floor(Math.random() + 100); + if (!process.env.NODE_ENV) + return Math.floor(Math.random() + 100); const docuwareInfo = await Self.app.models.Docuware.findOne({ where: { @@ -83,8 +83,8 @@ module.exports = Self => { * @return {number} - The fileCabinet id */ Self.getFileCabinet = async code => { - // if (!process.env.NODE_ENV) - // return Math.floor(Math.random() + 100); + if (!process.env.NODE_ENV) + return Math.floor(Math.random() + 100); const options = await Self.getOptions(); const docuwareInfo = await Self.app.models.Docuware.findOne({ @@ -93,7 +93,6 @@ module.exports = Self => { } }); - console.log('options.headers: ', options.headers); const fileCabinetResponse = await axios.get(`${options.url}/FileCabinets`, options.headers); const fileCabinets = fileCabinetResponse.data.FileCabinet; const fileCabinetId = fileCabinets.find(fileCabinet => fileCabinet.Name === docuwareInfo.fileCabinetName).Id; @@ -110,7 +109,7 @@ module.exports = Self => { * @return {object} - The data */ Self.get = async(code, filter, parse) => { - // if (!process.env.NODE_ENV) return; + if (!process.env.NODE_ENV) return; const options = await Self.getOptions(); const fileCabinetId = await Self.getFileCabinet(code); @@ -133,7 +132,7 @@ module.exports = Self => { * @return {object} - The data */ Self.getById = async(code, id, parse) => { - // if (!process.env.NODE_ENV) return; + if (!process.env.NODE_ENV) return; const docuwareInfo = await Self.app.models.Docuware.findOne({ fields: ['findById'], From da55fffef02385c03945fb5ca30b0f42a8961161 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 15 Oct 2024 11:18:04 +0200 Subject: [PATCH 12/42] feat: refs #8108 addMoreTablesTag --- db/routines/vn/procedures/entry_transfer.sql | 121 ++++++++++++++++++ .../11300-limeMedeola/00-firstScript.sql | 72 ++++++++++- 2 files changed, 189 insertions(+), 4 deletions(-) create mode 100644 db/routines/vn/procedures/entry_transfer.sql diff --git a/db/routines/vn/procedures/entry_transfer.sql b/db/routines/vn/procedures/entry_transfer.sql new file mode 100644 index 000000000..6d7da2b37 --- /dev/null +++ b/db/routines/vn/procedures/entry_transfer.sql @@ -0,0 +1,121 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_transfer`(vOriginalEntry INT, OUT vNewEntry INT) +BEGIN +/** +* Adelanta a mañana la mercancia de una entrada a partir de lo que hay ubicado en el almacén +* +* @param vOriginalEntry entrada que se quiera adelantar +*/ + + DECLARE vNewEntryFk INT; + DECLARE vTravelFk INT; + DECLARE vWarehouseFk INT; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + -- Clonar la entrada + CALL entry_clone(vOriginalEntry,vNewEntryFk); + + START TRANSACTION; + + -- Hay que crear un nuevo travel, con salida hoy y llegada mañana y asignar la entrada nueva al nuevo travel. + INSERT INTO travel( + shipped, + landed, + warehouseInFk, + warehouseOutFk, + `ref`, + isReceived, + agencyModeFk) + SELECT util.VN_CURDATE(), + util.VN_CURDATE() + INTERVAL 1 DAY, + t.warehouseInFk, + t.warehouseInFk, + t.`ref`, + t.isReceived, + t.agencyModeFk + FROM travel t + JOIN entry e ON e.travelFk = t.id + WHERE e.id = vOriginalEntry; + + SET vTravelFk = LAST_INSERT_ID(); + + UPDATE entry + SET travelFk = vTravelFk + WHERE id = vNewEntryFk; + + -- Poner a 0 las cantidades + UPDATE buy b + SET b.quantity = 0, b.stickers = 0 + WHERE b.entryFk = vNewEntryFk; + + -- Eliminar duplicados + DELETE b.* + FROM buy b + LEFT JOIN (SELECT b.id, b.itemFk + FROM buy b + WHERE b.entryFk = vNewEntryFk + GROUP BY b.itemFk) tBuy ON tBuy.id = b.id + WHERE b.entryFk = vNewEntryFk + AND tBuy.id IS NULL; + + SELECT t.warehouseInFk INTO vWarehouseFk + FROM travel t + JOIN entry e ON e.travelFk = t.id + WHERE e.id = vOriginalEntry; + + -- Actualizar la nueva entrada con lo que no está ubicado HOY, descontando lo vendido HOY de esas ubicaciones + CREATE OR REPLACE TEMPORARY TABLE tBuy + ENGINE = MEMORY + SELECT tBuy.itemFk, IFNULL(iss.visible,0) visible, tBuy.totalQuantity, IFNULL(sales.sold,0) sold + FROM (SELECT b.itemFk, SUM(b.quantity) totalQuantity + FROM buy b + WHERE b.entryFk = vOriginalEntry + GROUP BY b.itemFk + ) tBuy + LEFT JOIN ( + SELECT ish.itemFk, SUM(visible) visible + FROM itemShelving ish + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON p.id = sh.parkingFk + JOIN sector s ON s.id = p.sectorFk + WHERE s.warehouseFk = vWarehouseFk + AND sh.parked = util.VN_CURDATE() + GROUP BY ish.itemFk) iss ON tBuy.itemFk = iss.itemFk + LEFT JOIN ( + SELECT s.itemFk, SUM(s.quantity) sold + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN itemShelvingSale iss ON iss.saleFk = s.id + JOIN itemShelving is2 ON is2.id = iss.itemShelvingFk + JOIN shelving s2 ON s2.code = is2.shelvingFk + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) + AND s2.parked = util.VN_CURDATE() + GROUP BY s.itemFk) sales ON sales.itemFk = tBuy.itemFk + WHERE visible = tBuy.totalQuantity + OR iss.itemFk IS NULL; + + UPDATE buy b + JOIN (SELECT * FROM tBuy) sub ON sub.itemFk = b.itemFk + SET b.quantity = sub.totalQuantity - sub.visible - sub.sold + WHERE b.entryFk = vNewEntryFk; + + -- Limpia la nueva entrada + DELETE b.* + FROM buy b + WHERE b.entryFk = vNewEntryFk + AND b.quantity = 0; + + COMMIT; + + SET vNewEntry = vNewEntryFk; + + CALL cache.visible_refresh(@c,TRUE,7); + CALL cache.available_refresh(@c, TRUE, 7, util.VN_CURDATE()); + +END$$ +DELIMITER ; diff --git a/db/versions/11300-limeMedeola/00-firstScript.sql b/db/versions/11300-limeMedeola/00-firstScript.sql index 21920b692..313a65e81 100644 --- a/db/versions/11300-limeMedeola/00-firstScript.sql +++ b/db/versions/11300-limeMedeola/00-firstScript.sql @@ -79,7 +79,71 @@ UPDATE vn.tag WHERE name= 'Tronco'; -GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; -GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemWrappingTag TO logisticAssist; -GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemLanguageTag TO logisticAssist; -GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemStemTag TO logisticAssist; \ No newline at end of file +CREATE TABLE IF NOT EXISTS `vn`.`itemBreederTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemBreederTag` (`name`) VALUES ('David Austin'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemBreederTag' + WHERE name= 'Obtentor'; + + + +CREATE TABLE IF NOT EXISTS `vn`.`itemBaseTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Biodegradable'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Caballete'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Cerámica'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Cristal'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Plástico por inyección'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Madera'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Plástico'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Rígido'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Ruedas'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Sin soporte rígido'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemBaseTag' + WHERE name= 'Soporte'; + + + +CREATE TABLE IF NOT EXISTS `vn`.`itemVatRateTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemVatRateTag` (`name`) VALUES ('General'); +INSERT IGNORE INTO `vn`.`itemVatRateTag` (`name`) VALUES ('Reducido'); + + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemVatRateTag' + WHERE name= 'Tipo de IVA'; + + +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemWrappingTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemLanguageTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemStemTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemWrappingTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemBaseTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemBreederTag TO logisticAssist; \ No newline at end of file From 8da005f08ab1c0775c1cfee83bbdbadff3ca0cfa Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 15 Oct 2024 11:19:08 +0200 Subject: [PATCH 13/42] feat: refs #8108 refs #9108 --- db/routines/vn/procedures/entry_transfer.sql | 121 ------------------- 1 file changed, 121 deletions(-) delete mode 100644 db/routines/vn/procedures/entry_transfer.sql diff --git a/db/routines/vn/procedures/entry_transfer.sql b/db/routines/vn/procedures/entry_transfer.sql deleted file mode 100644 index 6d7da2b37..000000000 --- a/db/routines/vn/procedures/entry_transfer.sql +++ /dev/null @@ -1,121 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_transfer`(vOriginalEntry INT, OUT vNewEntry INT) -BEGIN -/** -* Adelanta a mañana la mercancia de una entrada a partir de lo que hay ubicado en el almacén -* -* @param vOriginalEntry entrada que se quiera adelantar -*/ - - DECLARE vNewEntryFk INT; - DECLARE vTravelFk INT; - DECLARE vWarehouseFk INT; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - -- Clonar la entrada - CALL entry_clone(vOriginalEntry,vNewEntryFk); - - START TRANSACTION; - - -- Hay que crear un nuevo travel, con salida hoy y llegada mañana y asignar la entrada nueva al nuevo travel. - INSERT INTO travel( - shipped, - landed, - warehouseInFk, - warehouseOutFk, - `ref`, - isReceived, - agencyModeFk) - SELECT util.VN_CURDATE(), - util.VN_CURDATE() + INTERVAL 1 DAY, - t.warehouseInFk, - t.warehouseInFk, - t.`ref`, - t.isReceived, - t.agencyModeFk - FROM travel t - JOIN entry e ON e.travelFk = t.id - WHERE e.id = vOriginalEntry; - - SET vTravelFk = LAST_INSERT_ID(); - - UPDATE entry - SET travelFk = vTravelFk - WHERE id = vNewEntryFk; - - -- Poner a 0 las cantidades - UPDATE buy b - SET b.quantity = 0, b.stickers = 0 - WHERE b.entryFk = vNewEntryFk; - - -- Eliminar duplicados - DELETE b.* - FROM buy b - LEFT JOIN (SELECT b.id, b.itemFk - FROM buy b - WHERE b.entryFk = vNewEntryFk - GROUP BY b.itemFk) tBuy ON tBuy.id = b.id - WHERE b.entryFk = vNewEntryFk - AND tBuy.id IS NULL; - - SELECT t.warehouseInFk INTO vWarehouseFk - FROM travel t - JOIN entry e ON e.travelFk = t.id - WHERE e.id = vOriginalEntry; - - -- Actualizar la nueva entrada con lo que no está ubicado HOY, descontando lo vendido HOY de esas ubicaciones - CREATE OR REPLACE TEMPORARY TABLE tBuy - ENGINE = MEMORY - SELECT tBuy.itemFk, IFNULL(iss.visible,0) visible, tBuy.totalQuantity, IFNULL(sales.sold,0) sold - FROM (SELECT b.itemFk, SUM(b.quantity) totalQuantity - FROM buy b - WHERE b.entryFk = vOriginalEntry - GROUP BY b.itemFk - ) tBuy - LEFT JOIN ( - SELECT ish.itemFk, SUM(visible) visible - FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk - JOIN parking p ON p.id = sh.parkingFk - JOIN sector s ON s.id = p.sectorFk - WHERE s.warehouseFk = vWarehouseFk - AND sh.parked = util.VN_CURDATE() - GROUP BY ish.itemFk) iss ON tBuy.itemFk = iss.itemFk - LEFT JOIN ( - SELECT s.itemFk, SUM(s.quantity) sold - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN itemShelvingSale iss ON iss.saleFk = s.id - JOIN itemShelving is2 ON is2.id = iss.itemShelvingFk - JOIN shelving s2 ON s2.code = is2.shelvingFk - WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - AND s2.parked = util.VN_CURDATE() - GROUP BY s.itemFk) sales ON sales.itemFk = tBuy.itemFk - WHERE visible = tBuy.totalQuantity - OR iss.itemFk IS NULL; - - UPDATE buy b - JOIN (SELECT * FROM tBuy) sub ON sub.itemFk = b.itemFk - SET b.quantity = sub.totalQuantity - sub.visible - sub.sold - WHERE b.entryFk = vNewEntryFk; - - -- Limpia la nueva entrada - DELETE b.* - FROM buy b - WHERE b.entryFk = vNewEntryFk - AND b.quantity = 0; - - COMMIT; - - SET vNewEntry = vNewEntryFk; - - CALL cache.visible_refresh(@c,TRUE,7); - CALL cache.available_refresh(@c, TRUE, 7, util.VN_CURDATE()); - -END$$ -DELIMITER ; From 099fe8f9502164570079c8a718249b03b9761a95 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 15 Oct 2024 14:42:35 +0200 Subject: [PATCH 14/42] fix: refs #7986 fix model --- modules/worker/back/models/operator.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/worker/back/models/operator.json b/modules/worker/back/models/operator.json index 9933babc6..b75bf6732 100644 --- a/modules/worker/back/models/operator.json +++ b/modules/worker/back/models/operator.json @@ -24,6 +24,9 @@ "warehouseFk": { "type": "number" }, + "sectorFk": { + "type": "number" + }, "labelerFk": { "type": "number" }, @@ -33,6 +36,15 @@ }, "machineFk": { "type": "number" + }, + "linesLimit": { + "type": "number" + }, + "volumeLimit": { + "type": "number" + }, + "sizeLimit": { + "type": "number" } }, "relations": { From 4a88ba5078132adee8e7f24657ee29da0445f873 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 15 Oct 2024 15:43:12 +0200 Subject: [PATCH 15/42] feat: refs #7744 closeAll Test --- db/dump/fixtures.before.sql | 24 ++++-- loopback/locale/es.json | 1 + loopback/locale/fr.json | 1 + loopback/locale/pt.json | 1 + modules/invoiceOut/back/models/invoice-out.js | 2 + modules/ticket/back/methods/sale/usesMana.js | 2 +- .../ticket/back/methods/ticket/closeAll.js | 44 +++++----- modules/ticket/back/methods/ticket/closure.js | 10 ++- .../methods/ticket/specs/closeAll.spec.js | 80 +++++++++++++++++++ 9 files changed, 136 insertions(+), 29 deletions(-) create mode 100644 modules/ticket/back/methods/ticket/specs/closeAll.spec.js diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 7f7e50dd3..6007b73e0 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -632,14 +632,21 @@ INSERT INTO vn.invoiceOutConfig SET id = 1, parallelism = 8; -INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`) +INSERT INTO `vn`.`invoiceOutSerial` + (`code`,`description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`) VALUES - ('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'), - ('T', 'Española rapida', 1, 'NATIONAL', 0, 'quick'), - ('V', 'Intracomunitaria global', 0, 'CEE', 1, 'global'), - ('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'multiple'), - ('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL), - ('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick'); + ('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'), + ('T', 'Española rapida', 1, 'NATIONAL', 0, 'quick'), + ('V', 'Intracomunitaria global', 0, 'CEE', 1, 'global'), + ('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'multiple'), + ('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL), + ('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick'), + ('H', 'Intracomunitaria rápida', 0, 'CEE', 1, 'quick'), + ('P', 'Factura simplificada', 1, 'NATIONAL', 0, NULL), + ('PE', 'COOPERATIE FLORAHOLLAND UA', 0, 'CEE', 1, NULL), + ('S', 'Simplificada', 1, 'NATIONAL', 0, NULL), + ('X', 'Exportación global', 0, 'WORLD', 0, 'global'), + ('N', 'Múltiple Intracomunitaria', 0, 'CEE', 1, 'multiple'); INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) VALUES @@ -2911,7 +2918,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) (6, 'book-entry-deleted', 'accounting entries deleted'), (7, 'zone-included','An email to notify zoneCollisions'), (8, 'backup-printer-selected','A backup printer has been selected'), - (9, 'mrw-deadline','The MRW deadline has passed'); + (9, 'mrw-deadline','The MRW deadline has passed'), + (10,'invoice-ticket-closure','Tickets not invoiced during the nightly closure ticket process'); TRUNCATE `util`.`notificationAcl`; INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9308fd4ec..0349fa8fb 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -350,6 +350,7 @@ "Cmr file does not exist": "El archivo del cmr no existe", "You are not allowed to modify the alias": "No estás autorizado a modificar el alias", "The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas", + "No invoice series found for these parameters": "No se encontró una serie para estos parámetros", "The line could not be marked": "La linea no puede ser marcada", "Through this procedure, it is not possible to modify the password of users with verified email": "Mediante este procedimiento, no es posible modificar la contraseña de usuarios con correo verificado", "They're not your subordinate": "No es tu subordinado/a.", diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index a6648b186..23bd5cc04 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -350,6 +350,7 @@ "Cmr file does not exist": "Le fichier cmr n'existe pas", "You are not allowed to modify the alias": "Vous n'êtes pas autorisé à modifier l'alias", "The address of the customer must have information about Incoterms and Customs Agent": "L'adresse du client doit contenir des informations sur les Incoterms et l'agent des douanes", + "No invoice series found for these parameters": "Aucune série de facture trouvée pour ces paramètres", "The line could not be marked": "La ligne ne peut pas être marquée", "This password can only be changed by the user themselves": "Ce mot de passe ne peut être modifié que par l'utilisateur lui-même", "They're not your subordinate": "Ce n'est pas votre subordonné.", diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index a43f0e780..f85afd607 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -350,6 +350,7 @@ "Cmr file does not exist": "O arquivo CMR não existe", "You are not allowed to modify the alias": "Você não tem permissão para modificar o alias", "The address of the customer must have information about Incoterms and Customs Agent": "O endereço do cliente deve ter informações sobre Incoterms e Agente Aduaneiro", + "No invoice series found for these parameters": "Nenhuma série de fatura encontrada para esses parâmetros", "The line could not be marked": "A linha não pôde ser marcada", "This password can only be changed by the user themselves": "Esta senha só pode ser alterada pelo próprio usuário", "They're not your subordinate": "Eles não são seus subordinados.", diff --git a/modules/invoiceOut/back/models/invoice-out.js b/modules/invoiceOut/back/models/invoice-out.js index bab1fa375..f8fc8cdbf 100644 --- a/modules/invoiceOut/back/models/invoice-out.js +++ b/modules/invoiceOut/back/models/invoice-out.js @@ -79,6 +79,8 @@ module.exports = Self => { type ], myOptions); + if (!serial) + throw new UserError('No invoice series found for these parameters'); const invoiceOutSerial = await Self.app.models.InvoiceOutSerial.findById(serial); if (invoiceOutSerial?.taxAreaFk == 'WORLD') { diff --git a/modules/ticket/back/methods/sale/usesMana.js b/modules/ticket/back/methods/sale/usesMana.js index 31beb3a4c..b4768d80a 100644 --- a/modules/ticket/back/methods/sale/usesMana.js +++ b/modules/ticket/back/methods/sale/usesMana.js @@ -31,6 +31,6 @@ module.exports = Self => { const usesMana = departments.find(department => department.id == workerDepartment.departmentFk); - return usesMana ? true : false; + return !!usesMana; }; }; diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 4fd72d454..1b3f84295 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -1,11 +1,17 @@ -const UserError = require('vn-loopback/util/user-error'); const closure = require('./closure'); module.exports = Self => { Self.remoteMethodCtx('closeAll', { description: 'Makes the closure process from all warehouses', accessType: 'WRITE', - accepts: [], + accepts: [ + { + arg: 'options', + type: 'object', + http: {source: 'body'}, + description: 'Optional parameters, including transaction.' + } + ], returns: { type: 'object', root: true @@ -16,21 +22,20 @@ module.exports = Self => { } }); - Self.closeAll = async ctx => { + Self.closeAll = async(ctx, options) => { + const userId = ctx.req.accessToken.userId; + const myOptions = {userId}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + let tx; + // IMPORTANT: Due to its high cost in production, wrapping this process in a transaction may cause timeouts. + const toDate = Date.vnNew(); toDate.setHours(0, 0, 0, 0); toDate.setDate(toDate.getDate() - 1); - const todayMinDate = Date.vnNew(); - todayMinDate.setHours(0, 0, 0, 0); - - const todayMaxDate = Date.vnNew(); - todayMaxDate.setHours(23, 59, 59, 59); - - // Prevent closure for current day - if (toDate >= todayMinDate && toDate <= todayMaxDate) - throw new UserError('You cannot close tickets for today'); - const tickets = await Self.rawSql(` SELECT t.id, t.clientFk, @@ -58,12 +63,12 @@ module.exports = Self => { AND t.shipped BETWEEN ? - INTERVAL tc.closureDaysAgo DAY AND util.dayEnd(?) AND t.refFk IS NULL GROUP BY t.id - `, [toDate, toDate]); + `, [toDate, toDate], myOptions); const ticketIds = tickets.map(ticket => ticket.id); await Self.rawSql(` INSERT INTO util.debug (variable, value) VALUES ('nightInvoicing', ?) - `, [ticketIds.join(',')]); + `, [ticketIds.join(',')], myOptions); await Self.rawSql(` WITH ticketNotInvoiceable AS( @@ -133,9 +138,9 @@ module.exports = Self => { ) SELECT IF(errors = '{"tickets": null}', 'No errors', util.notification_send('invoice-ticket-closure', errors, NULL)) - FROM ticketNotInvoiceable`, [toDate, toDate]); + FROM ticketNotInvoiceable`, [toDate, toDate], myOptions); - await closure(ctx, Self, tickets); + await closure(ctx, Self, tickets, myOptions); await Self.rawSql(` UPDATE ticket t @@ -150,7 +155,10 @@ module.exports = Self => { AND al.code NOT IN ('DELIVERED', 'PACKED') AND NOT t.packages AND tob.id IS NULL - AND t.routeFk`, [toDate, toDate], {userId: ctx.req.accessToken.userId}); + AND t.routeFk`, [toDate, toDate], myOptions); + + if (tx) + await tx.commit(); return { message: 'Success' diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index 56bd6eccd..64f198834 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -19,9 +19,15 @@ module.exports = async function(ctx, Self, tickets, options) { const failedtickets = []; for (const ticket of tickets) { try { - await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId}); + await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId}, + myOptions); - await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'quick'); + await Self.app.models.InvoiceOut.getSerial( + ticket.clientFk, + ticket.companyFk, + ticket.addressFk, + 'quick', + myOptions); await Self.rawSql( `CALL vn.ticket_closeByTicket(?)`, [ticket.id], diff --git a/modules/ticket/back/methods/ticket/specs/closeAll.spec.js b/modules/ticket/back/methods/ticket/specs/closeAll.spec.js new file mode 100644 index 000000000..4b067ce7e --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/closeAll.spec.js @@ -0,0 +1,80 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); + +fdescribe('Ticket Closure - closeAll function', () => { + let ctx = { + req: { + getLocale: () => 'es', + accessToken: {userId: 1106}, + headers: {origin: 'http://localhost'}, + __: value => value, + }, + args: {} + }; + let options; + let tx; + let originalVnNew; + + beforeEach(async() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req}); + tx = await models.Ticket.beginTransaction({}); + options = {transaction: tx}; + originalVnNew = Date.vnNew; + spyOn(Date, 'vnNew').and.callFake(() => { + const mockDate = originalVnNew(); + mockDate.setDate(mockDate.getDate() + 1); + return mockDate; + }); + }); + + afterEach(async() => { + if (tx) + await tx.rollback(); + }); + + xit('should successfully close all tickets when conditions are met', async() => { + const ticketsBefore = await models.Ticket.find({ + where: { + packages: {neq: 0} + } + }, options); + const packedTicketsIds = ticketsBefore.map(ticket => ticket.id); + + const packedTicketsBefore = await models.TicketLastState.find({ + where: { + ticketFk: {inq: packedTicketsIds}, + lastState: 'Encajado' + } + }, options); + + await models.Ticket.closeAll(ctx, options); + + const packedTicketsAfter = await models.TicketLastState.find({ + where: { + ticketFk: {inq: packedTicketsIds}, + lastState: 'Encajado' + } + }, options); + + expect(packedTicketsBefore.length).toBeGreaterThan(packedTicketsAfter.length); + }); + + fit('should set routeFk to NULL when conditions are met', async() => { + const ticketsBefore = await models.Ticket.find({ + where: { + routeFk: {neq: null} + } + }, options); + + await models.Ticket.closeAll(ctx, options); + + const ticketsAfter = await models.Ticket.find({ + where: { + id: {inq: ticketsBefore.map(ticket => ticket.id)}, + routeFk: {neq: null} + } + }, options); + + expect(ticketsBefore.length).toBeGreaterThan(ticketsAfter.length); + }); +}); From b592ccc1624542e0f9efc1c9dedca4d12566f3bd Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 15 Oct 2024 17:01:09 +0200 Subject: [PATCH 16/42] fix: refs #6861 getTickets --- back/methods/collection/getTickets.js | 6 ++++-- db/routines/vn/triggers/itemShelvingSale_afterInsert.sql | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js index 2a2b67524..48301a366 100644 --- a/back/methods/collection/getTickets.js +++ b/back/methods/collection/getTickets.js @@ -62,7 +62,8 @@ module.exports = Self => { p.code parkingCodePrevia, p.pickingOrder pickingOrderPrevia, iss.id itemShelvingSaleFk, - iss.isPicked + iss.isPicked, + iss.itemShelvingFk FROM ticketCollection tc LEFT JOIN collection c ON c.id = tc.collectionFk JOIN sale s ON s.ticketFk = tc.ticketFk @@ -102,7 +103,8 @@ module.exports = Self => { p.code, p.pickingOrder, iss.id itemShelvingSaleFk, - iss.isPicked + iss.isPicked, + iss.itemShelvingFk FROM sectorCollection sc JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id JOIN saleGroup sg ON sg.id = ss.saleGroupFk diff --git a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql index 3531b094c..5ad83d289 100644 --- a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql @@ -3,10 +3,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterI AFTER INSERT ON `itemShelvingSale` FOR EACH ROW BEGIN - UPDATE sale s JOIN operator o ON o.workerFk = account.myUser_getId() - SET s.isPicked = IF(o.isOnReservationMode, s.isPicked, TRUE) + JOIN sector se ON s.id = o.sectorFk + SET s.isPicked = IF((se.isOnReservationMode IS NULL AND o.isOnReservationMode) OR se.isOnReservationMode, s.isPicked, TRUE) WHERE id = NEW.saleFk; END$$ DELIMITER ; \ No newline at end of file From 2adc424ccb3814a51a87e3b1cdfba0ca86b4da5e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 15 Oct 2024 17:07:35 +0200 Subject: [PATCH 17/42] fix: refs #6861 getTickets --- db/routines/vn/triggers/itemShelvingSale_afterInsert.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql index 5ad83d289..1980691b5 100644 --- a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterI BEGIN UPDATE sale s JOIN operator o ON o.workerFk = account.myUser_getId() - JOIN sector se ON s.id = o.sectorFk + JOIN sector se ON se.id = o.sectorFk SET s.isPicked = IF((se.isOnReservationMode IS NULL AND o.isOnReservationMode) OR se.isOnReservationMode, s.isPicked, TRUE) WHERE id = NEW.saleFk; END$$ From 12abca0a2d2819e559e4d64a8ee147a89c278c00 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 15 Oct 2024 18:12:07 +0200 Subject: [PATCH 18/42] fix: refs #6861 getTickets --- db/routines/vn/triggers/itemShelvingSale_afterInsert.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql index 1980691b5..ad4a6f670 100644 --- a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql @@ -6,7 +6,7 @@ BEGIN UPDATE sale s JOIN operator o ON o.workerFk = account.myUser_getId() JOIN sector se ON se.id = o.sectorFk - SET s.isPicked = IF((se.isOnReservationMode IS NULL AND o.isOnReservationMode) OR se.isOnReservationMode, s.isPicked, TRUE) - WHERE id = NEW.saleFk; + SET s.isPicked = IF(IFNULL(se.isOnReservationMode, o.isOnReservationMode), s.isPicked, TRUE) + WHERE s.id = NEW.saleFk; END$$ DELIMITER ; \ No newline at end of file From 46e657675b1ce8ae70c1742c41d17746892978e9 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 16 Oct 2024 08:26:39 +0200 Subject: [PATCH 19/42] fix: refs #7906 remake method --- loopback/locale/en.json | 3 ++- loopback/locale/es.json | 5 +++-- modules/zone/back/methods/zone/deleteZone.js | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ea84cb6eb..a7e21960b 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -240,5 +240,6 @@ "There is already a tray with the same height": "There is already a tray with the same height", "The height must be greater than 50cm": "The height must be greater than 50cm", "The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm", - "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line" + "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", + "There are tickets for this area, delete them first": "There are tickets for this area, delete them first" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9308fd4ec..6d50f634e 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -382,5 +382,6 @@ "This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha", "No valid travel thermograph found": "No se encontró un termógrafo válido", "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", - "type cannot be blank": "Se debe rellenar el tipo" -} \ No newline at end of file + "type cannot be blank": "Se debe rellenar el tipo", + "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero" +} diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index a75302703..34ab177ac 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -1,3 +1,4 @@ +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('deleteZone', { description: 'Delete a zone', @@ -57,7 +58,8 @@ module.exports = Self => { where: {id: userId} }, myOptions); - await models.Ticket.rawSql('UPDATE ticket SET zoneFk = NULL WHERE zoneFk = ?', [id], myOptions); + if (ticketList.length > 0) + throw new UserError('There are tickets for this area, delete them first'); for (ticket of ticketList) { if (ticket.ticketState().alertLevel == 0) { From c6e764b478b9481376f187c32c9c73b5b26cb23d Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 16 Oct 2024 08:32:10 +0200 Subject: [PATCH 20/42] feat: refs #7348 hasDailyInvoice from client --- back/models/autonomy.json | 6 +- back/models/country.json | 4 + back/models/province.json | 5 +- db/routines/vn/procedures/client_create.sql | 10 +- db/routines/vn/procedures/ticket_close.sql | 7 +- .../11302-limeTulip/00-firstScript.sql | 13 ++ .../back/methods/client/createWithUser.js | 20 ++- .../client/specs/createWithUser.spec.js | 143 +++++++++++------- .../ticket/back/methods/ticket/closeAll.js | 4 +- .../back/methods/ticket/closeByTicket.js | 4 +- 10 files changed, 145 insertions(+), 71 deletions(-) create mode 100644 db/versions/11302-limeTulip/00-firstScript.sql diff --git a/back/models/autonomy.json b/back/models/autonomy.json index 8c9d82936..214061cf5 100644 --- a/back/models/autonomy.json +++ b/back/models/autonomy.json @@ -16,6 +16,10 @@ "name": { "type": "string", "required": true + }, + "hasDailyInvoice": { + "type": "boolean", + "description": "Indicates if the autonomy has daily invoice enabled" } }, "relations": { @@ -40,4 +44,4 @@ "permission": "ALLOW" } ] -} \ No newline at end of file +} diff --git a/back/models/country.json b/back/models/country.json index 5b9d842a8..80d456702 100644 --- a/back/models/country.json +++ b/back/models/country.json @@ -28,6 +28,10 @@ }, "continentFk": { "type": "number" + }, + "hasDailyInvoice": { + "type": "boolean", + "description": "Indicates if the autonomy has daily invoice enabled" } }, "relations": { diff --git a/back/models/province.json b/back/models/province.json index 77e0b24a6..61a1574d7 100644 --- a/back/models/province.json +++ b/back/models/province.json @@ -16,6 +16,9 @@ "name": { "type": "string", "required": true + }, + "autonomyFk": { + "type": "number" } }, "relations": { @@ -55,4 +58,4 @@ "permission": "ALLOW" } ] -} \ No newline at end of file +} diff --git a/db/routines/vn/procedures/client_create.sql b/db/routines/vn/procedures/client_create.sql index 3df3df905..fad01c107 100644 --- a/db/routines/vn/procedures/client_create.sql +++ b/db/routines/vn/procedures/client_create.sql @@ -34,22 +34,19 @@ BEGIN DECLARE vIsTaxDataChecked TINYINT(1); DECLARE vHasCoreVnl BOOLEAN; DECLARE vMandateTypeFk INT; - DECLARE vHasDailyInvoice BOOLEAN; SELECT cc.defaultPayMethodFk, cc.defaultDueDay, cc.defaultCredit, cc.defaultIsTaxDataChecked, cc.defaultHasCoreVnl, - cc.defaultMandateTypeFk, - c.hasDailyInvoice + cc.defaultMandateTypeFk INTO vPayMethodFk, vDueDay, vDefaultCredit, vIsTaxDataChecked, vHasCoreVnl, - vMandateTypeFk, - vHasDailyInvoice + vMandateTypeFk FROM clientConfig cc LEFT JOIN province p ON p.id = vProvinceFk LEFT JOIN country c ON c.id = p.countryFk; @@ -70,8 +67,7 @@ BEGIN credit = vDefaultCredit, isTaxDataChecked = vIsTaxDataChecked, hasCoreVnl = vHasCoreVnl, - isEqualizated = FALSE, - hasDailyInvoice = vHasDailyInvoice + isEqualizated = FALSE ON duplicate KEY UPDATE payMethodFk = vPayMethodFk, dueDay = vDueDay, diff --git a/db/routines/vn/procedures/ticket_close.sql b/db/routines/vn/procedures/ticket_close.sql index 0da001ffa..e2dcef9a5 100644 --- a/db/routines/vn/procedures/ticket_close.sql +++ b/db/routines/vn/procedures/ticket_close.sql @@ -43,7 +43,7 @@ BEGIN c.isTaxDataChecked, t.companyFk, t.shipped, - IFNULL(a.hasDailyInvoice, co.hasDailyInvoice), + c.hasDailyInvoice, w.isManaged, c.hasToInvoice INTO vClientFk, @@ -55,9 +55,6 @@ BEGIN vHasToInvoice FROM ticket t JOIN `client` c ON c.id = t.clientFk - JOIN province p ON p.id = c.provinceFk - LEFT JOIN autonomy a ON a.id = p.autonomyFk - JOIN country co ON co.id = p.countryFk JOIN warehouse w ON w.id = t.warehouseFk WHERE t.id = vCurTicketFk; @@ -85,7 +82,7 @@ BEGIN IF(vHasDailyInvoice) AND vHasToInvoice THEN SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial; - IF vSerial IS NULL THEN + IF vSerial IS NULL THEN CALL util.throw('Cannot booking without a serial'); END IF; diff --git a/db/versions/11302-limeTulip/00-firstScript.sql b/db/versions/11302-limeTulip/00-firstScript.sql new file mode 100644 index 000000000..7bda31b64 --- /dev/null +++ b/db/versions/11302-limeTulip/00-firstScript.sql @@ -0,0 +1,13 @@ + +UPDATE `vn`.`client` c + JOIN `vn`.`country` co ON co.id=c.countryFk +SET c.hasDailyInvoice = co.hasDailyInvoice +WHERE co.hasDailyInvoice IS NOT NULL + AND c.hasDailyInvoice = FALSE; + +UPDATE `vn`.`client` c + JOIN `vn`.`province` p ON p.id=c.provinceFk + JOIN `vn`.`autonomy` a ON a.id = p.autonomyFk +SET c.hasDailyInvoice = a.hasDailyInvoice +WHERE a.hasDailyInvoice IS NOT NULL + AND c.hasDailyInvoice = FALSE; diff --git a/modules/client/back/methods/client/createWithUser.js b/modules/client/back/methods/client/createWithUser.js index 06b885ab8..c8cd282e1 100644 --- a/modules/client/back/methods/client/createWithUser.js +++ b/modules/client/back/methods/client/createWithUser.js @@ -43,6 +43,23 @@ module.exports = function(Self) { }; try { + const province = await models.Province.findOne({ + where: {id: data.provinceFk}, + fields: ['autonomyFk'] + }); + + const autonomy = province ? await models.Autonomy.findOne({ + where: {id: province.autonomyFk}, + fields: ['hasDailyInvoice'] + }) : null; + + const country = await models.Country.findOne({ + where: {id: data.countryFk}, + fields: ['hasDailyInvoice'] + }); + + const hasDailyInvoice = (autonomy?.hasDailyInvoice ?? country?.hasDailyInvoice) || false; + const account = await models.VnUser.create(user, myOptions); const client = await Self.create({ id: account.id, @@ -57,7 +74,8 @@ module.exports = function(Self) { provinceFk: data.provinceFk, countryFk: data.countryFk, isEqualizated: data.isEqualizated, - businessTypeFk: data.businessTypeFk + businessTypeFk: data.businessTypeFk, + hasDailyInvoice: hasDailyInvoice }, myOptions); const address = await models.Address.create({ diff --git a/modules/client/back/methods/client/specs/createWithUser.spec.js b/modules/client/back/methods/client/specs/createWithUser.spec.js index 5b1ff5da9..f47c24087 100644 --- a/modules/client/back/methods/client/specs/createWithUser.spec.js +++ b/modules/client/back/methods/client/specs/createWithUser.spec.js @@ -1,67 +1,79 @@ const models = require('vn-loopback/server/server').models; + describe('Client Create', () => { - const newAccount = { - userName: 'deadpool', - email: 'deadpool@marvel.com', - fi: '16195279J', - name: 'Wade', - socialName: 'DEADPOOL MARVEL', - street: 'WALL STREET', - city: 'New York', - businessTypeFk: 'florist', - provinceFk: 1 - }; - const newAccountWithoutEmail = JSON.parse(JSON.stringify(newAccount)); - delete newAccountWithoutEmail.email; + let options; + let tx; beforeAll.mockLoopBackContext(); - it(`should not find deadpool as he's not created yet`, async() => { - const tx = await models.Client.beginTransaction({}); + beforeEach(async() => { + tx = await models.Client.beginTransaction({}); + options = {transaction: tx}; + }); + afterEach(async() => await tx.rollback()); + + it('should not find deadpool as he is not created yet', async() => { try { - const options = {transaction: tx}; + const account = await models.VnUser.findOne({where: {name: 'deadpool'}}, options); + const client = await models.Client.findOne({where: {name: 'Wade'}}, options); - const account = await models.VnUser.findOne({where: {name: newAccount.userName}}, options); - const client = await models.Client.findOne({where: {name: newAccount.name}}, options); - - expect(account).toEqual(null); - expect(client).toEqual(null); - - await tx.rollback(); + expect(account).toBeNull(); + expect(client).toBeNull(); } catch (e) { await tx.rollback(); throw e; } }); - it('should not create a new account', async() => { - const tx = await models.Client.beginTransaction({}); - + it('should throw an error when creating a new account without email', async() => { let error; + const newAccountWithoutEmail = { + userName: 'deadpool', + fi: '16195279J', + name: 'Wade', + socialName: 'DEADPOOL MARVEL', + street: 'WALL STREET', + city: 'New York', + businessTypeFk: 'florist', + provinceFk: 1 + }; + try { - const options = {transaction: tx}; await models.Client.createWithUser(newAccountWithoutEmail, options); - - await tx.rollback(); + fail('shapoifaspodifa spdofij'); } catch (e) { - error = e.message; - - await tx.rollback(); + error = e; } - expect(error).toEqual(`An email is necessary`); + expect(error.message).toEqual('An email is necessary'); }); - it('should create a new account', async() => { - const tx = await models.Client.beginTransaction({}); + it('should create a new account with dailyInvoice', async() => { + const newAccount = { + userName: 'deadpool', + email: 'deadpool@marvel.com', + fi: '16195279J', + name: 'Wade', + socialName: 'DEADPOOL MARVEL', + street: 'WALL STREET', + city: 'New York', + businessTypeFk: 'florist', + provinceFk: 1 + }; try { - const options = {transaction: tx}; + const province = await models.Province.findById(newAccount.provinceFk, { + fields: ['id', 'name', 'autonomyFk'], + include: { + relation: 'autonomy' + } + }, options); const client = await models.Client.createWithUser(newAccount, options); const account = await models.VnUser.findOne({where: {name: newAccount.userName}}, options); + expect(province.autonomy().hasDailyInvoice).toBeTruthy(); expect(account.name).toEqual(newAccount.userName); expect(client.id).toEqual(account.id); expect(client.name).toEqual(newAccount.name); @@ -69,8 +81,38 @@ describe('Client Create', () => { expect(client.fi).toEqual(newAccount.fi); expect(client.socialName).toEqual(newAccount.socialName); expect(client.businessTypeFk).toEqual(newAccount.businessTypeFk); - + expect(client.hasDailyInvoice).toBeTruthy(); + } catch (e) { await tx.rollback(); + throw e; + } + }); + + it('should create a new account without dailyInvoice', async() => { + const newAccount = { + userName: 'deadpool', + email: 'deadpool@marvel.com', + fi: '16195279J', + name: 'Wade', + socialName: 'DEADPOOL MARVEL', + street: 'WALL STREET', + city: 'New York', + businessTypeFk: 'florist', + provinceFk: 3 + }; + + try { + const province = await models.Province.findById(newAccount.provinceFk, { + fields: ['id', 'name', 'autonomyFk'], + include: { + relation: 'autonomy' + } + }, options); + + const client = await models.Client.createWithUser(newAccount, options); + + expect(province.autonomy.hasDailyInvoice).toBeFalsy(); + expect(client.hasDailyInvoice).toBeFalsy(); } catch (e) { await tx.rollback(); throw e; @@ -78,26 +120,25 @@ describe('Client Create', () => { }); it('should not be able to create a user if exists', async() => { - const tx = await models.Client.beginTransaction({}); - let error; - + const newAccount = { + userName: 'deadpool', + email: 'deadpool@marvel.com', + fi: '16195279J', + name: 'Wade', + socialName: 'DEADPOOL MARVEL', + street: 'WALL STREET', + city: 'New York', + businessTypeFk: 'florist', + provinceFk: 1 + }; try { - const options = {transaction: tx}; - await models.Client.createWithUser(newAccount, options); - const client = await models.Client.createWithUser(newAccount, options); - - expect(client).toBeNull(); - - await tx.rollback(); + await models.Client.createWithUser(newAccount, options); } catch (e) { - await tx.rollback(); error = e; } - const errorName = error.details.codes.name[0]; - - expect(errorName).toEqual('uniqueness'); + expect(error.message).toContain('already exists'); }); }); diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 4fd72d454..b9060d2f2 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -41,7 +41,7 @@ module.exports = Self => { c.salesPersonFk, c.isToBeMailed, c.hasToInvoice, - co.hasDailyInvoice, + c.hasDailyInvoice, eu.email salesPersonEmail, t.addressFk FROM ticket t @@ -120,7 +120,7 @@ module.exports = Self => { WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code <> 'delivered')) AND t.shipped BETWEEN ? - INTERVAL tc.closureDaysAgo DAY AND util.dayEnd(?) AND t.refFk IS NULL - AND IFNULL(a.hasDailyInvoice, co.hasDailyInvoice) + AND c.hasDailyInvoice GROUP BY ticketFk HAVING hasErrorToInvoice OR hasErrorTaxDataChecked diff --git a/modules/ticket/back/methods/ticket/closeByTicket.js b/modules/ticket/back/methods/ticket/closeByTicket.js index 40fe048a5..8a21267b6 100644 --- a/modules/ticket/back/methods/ticket/closeByTicket.js +++ b/modules/ticket/back/methods/ticket/closeByTicket.js @@ -50,7 +50,7 @@ module.exports = Self => { c.salesPersonFk, c.isToBeMailed, c.hasToInvoice, - co.hasDailyInvoice, + c.hasDailyInvoice, eu.email salesPersonEmail, t.addressFk FROM expedition e @@ -58,8 +58,6 @@ module.exports = Self => { JOIN ticketState ts ON ts.ticketFk = t.id JOIN alertLevel al ON al.id = ts.alertLevel JOIN client c ON c.id = t.clientFk - JOIN province p ON p.id = c.provinceFk - JOIN country co ON co.id = p.countryFk LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk WHERE al.code = 'PACKED' AND t.id = ? From aac4dd0a6d1719ccc9937faa67871b5dd205bc78 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 16 Oct 2024 08:52:27 +0200 Subject: [PATCH 21/42] feat: refs #7348 minor bug --- modules/client/back/methods/client/specs/createWithUser.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/client/back/methods/client/specs/createWithUser.spec.js b/modules/client/back/methods/client/specs/createWithUser.spec.js index f47c24087..8cff96ac5 100644 --- a/modules/client/back/methods/client/specs/createWithUser.spec.js +++ b/modules/client/back/methods/client/specs/createWithUser.spec.js @@ -41,7 +41,6 @@ describe('Client Create', () => { try { await models.Client.createWithUser(newAccountWithoutEmail, options); - fail('shapoifaspodifa spdofij'); } catch (e) { error = e; } From c355fcfece4c201ae7ab183d4c1237530f26f755 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 16 Oct 2024 09:03:47 +0200 Subject: [PATCH 22/42] test(docuware_core): refs #8066 adapt --- back/methods/docuware/core.js | 4 +- back/methods/docuware/specs/core.spec.js | 164 ++++++++++++----------- 2 files changed, 86 insertions(+), 82 deletions(-) diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 391a8b4ab..3de33b786 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -8,10 +8,10 @@ module.exports = Self => { */ Self.getOptions = async() => { const docuwareConfig = await Self.app.models.DocuwareConfig.findOne(); - const now = new Date().getTime(); + const now = Date.vnNow(); let {url, username, password, token, expired} = docuwareConfig; - if (!expired || expired < now + 60) { + if (process.env.NODE_ENV && (!expired || expired < now + 60)) { const {data: {IdentityServiceUrl}} = await axios.get(`${url}/Home/IdentityServiceInfo`); const {data: {token_endpoint}} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`); const {data} = await axios.post(token_endpoint, { diff --git a/back/methods/docuware/specs/core.spec.js b/back/methods/docuware/specs/core.spec.js index cdf8a3b62..47580483d 100644 --- a/back/methods/docuware/specs/core.spec.js +++ b/back/methods/docuware/specs/core.spec.js @@ -2,87 +2,54 @@ const axios = require('axios'); const models = require('vn-loopback/server/server').models; describe('Docuware core', () => { - beforeAll(() => { + const fileCabinetCode = 'deliveryNote'; + beforeAll(async() => { process.env.NODE_ENV = 'testing'; - }); - afterAll(() => { - delete process.env.NODE_ENV; - }); - - describe('getOptions()', () => { - it('should return url and headers', async() => { - const result = await models.Docuware.getOptions(); - - expect(result.url).toBeDefined(); - expect(result.headers).toBeDefined(); + const docuwareInfo = await models.Docuware.findOne({ + where: { + code: fileCabinetCode + } }); - }); - describe('getDialog()', () => { - it('should return dialogId', async() => { - const dialogs = { - data: { - Dialog: [ - { - DisplayName: 'find', - Id: 'getDialogTest' - } - ] - } - }; - spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(dialogs))); - const result = await models.Docuware.getDialog('deliveryNote', 'find', 'randomFileCabinetId'); + spyOn(axios, 'get').and.callFake(url => { + if (url.includes('IdentityServiceInfo')) return {data: {IdentityServiceUrl: 'IdentityServiceUrl'}}; + if (url.includes('IdentityServiceUrl')) return {data: {token_endpoint: 'token_endpoint'}}; + if (url.includes('dialogs')) { + return { + data: { + Dialog: [ + { + DisplayName: 'find', + Id: 'getDialogTest' + } + ] + } + }; + } - expect(result).toEqual('getDialogTest'); - }); - }); - - describe('getFileCabinet()', () => { - it('should return fileCabinetId', async() => { - const code = 'deliveryNote'; - const docuwareInfo = await models.Docuware.findOne({ - where: { - code - } - }); - const dialogs = { - data: { + if (url.includes('FileCabinets')) { + return {data: { FileCabinet: [ { Name: docuwareInfo.fileCabinetName, Id: 'getFileCabinetTest' } ] - } - }; - spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(dialogs))); - const result = await models.Docuware.getFileCabinet(code); - - expect(result).toEqual('getFileCabinetTest'); - }); - }); - - describe('get()', () => { - it('should return data without parse', async() => { - spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random())))); - spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random())))); - const data = { - data: { - id: 1 - } - }; - spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data))); - const result = await models.Docuware.get('deliveryNote'); - - expect(result.id).toEqual(1); + }}; + } }); - it('should return data with parse', async() => { - spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random())))); - spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random())))); - const data = { - data: { + spyOn(axios, 'post').and.callFake(url => { + if (url.includes('token_endpoint')) { + return {data: { + access_token: 'access_token', + token_type: 'bearer', + expires_in: 10000 + }}; + } + if (url.includes('DialogExpression')) { + return {data: { Items: [{ Fields: [ { @@ -103,12 +70,52 @@ describe('Docuware core', () => { ] }] } - }; + }; + } + }); + }); + + afterAll(() => { + delete process.env.NODE_ENV; + }); + + describe('getOptions()', () => { + it('should return url and headers', async() => { + const result = await models.Docuware.getOptions(); + + expect(result.url).toBeDefined(); + expect(result.headers).toBeDefined(); + }); + }); + + describe('Dialog()', () => { + it('should return dialogId', async() => { + const result = await models.Docuware.getDialog('deliveryNote', 'find', 'randomFileCabinetId'); + + expect(result).toEqual('getDialogTest'); + }); + }); + + describe('getFileCabinet()', () => { + it('should return fileCabinetId', async() => { + const result = await models.Docuware.getFileCabinet(fileCabinetCode); + + expect(result).toEqual('getFileCabinetTest'); + }); + }); + + describe('get()', () => { + it('should return data without parse', async() => { + const [result] = await models.Docuware.get('deliveryNote'); + + expect(result.firstRequiredField).toEqual(1); + }); + + it('should return data with parse', async() => { const parse = { 'firstRequiredField': 'id', 'secondRequiredField': 'name', }; - spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data))); const [result] = await models.Docuware.get('deliveryNote', null, parse); expect(result.id).toEqual(1); @@ -119,17 +126,14 @@ describe('Docuware core', () => { describe('getById()', () => { it('should return data', async() => { - spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random())))); - spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random())))); - const data = { - data: { - id: 1 - } - }; - spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data))); - const result = await models.Docuware.getById('deliveryNote', 1); + spyOn(models.Docuware, 'get'); + await models.Docuware.getById('deliveryNote', 1); - expect(result.id).toEqual(1); + expect(models.Docuware.get).toHaveBeenCalledWith( + 'deliveryNote', + {condition: [Object({DBName: 'N__ALBAR_N', Value: [1]})]}, + undefined + ); }); }); }); From c5aa7dc44e4bac9148b226420e9a687054c037fa Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 16 Oct 2024 09:30:37 +0200 Subject: [PATCH 23/42] fix: refs #7906 edit test --- .../zone/back/methods/zone/specs/deleteZone.spec.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index 08dafd181..60e704161 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -8,7 +8,7 @@ describe('zone deletezone()', () => { __: value => value }; const ctx = {req: activeCtx}; - const zoneId = 9; + const zoneId = 4; let ticketIDs; let originalTicketStates; @@ -35,18 +35,8 @@ describe('zone deletezone()', () => { await models.Zone.deleteZone(ctx, zoneId, options); const updatedZone = await models.Zone.findById(zoneId, null, options); - const anUpdatedTicket = await models.Ticket.findById(ticketIDs[0], null, options); - - const updatedTicketStates = await models.TicketState.find({ - where: { - ticketFk: {inq: ticketIDs}, - code: 'FIXING' - } - }, options); expect(updatedZone).toBeNull(); - expect(anUpdatedTicket.zoneFk).toBeNull(); - expect(updatedTicketStates.length).toBeGreaterThan(originalTicketStates.length); await tx.rollback(); } catch (e) { From 8f01e4d110ad040c33674bb5b51664d0e3dd93be Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 16 Oct 2024 09:32:15 +0200 Subject: [PATCH 24/42] fix: refs #7353 redirect to lilium --- modules/monitor/front/locale/es.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 modules/monitor/front/locale/es.yml diff --git a/modules/monitor/front/locale/es.yml b/modules/monitor/front/locale/es.yml new file mode 100644 index 000000000..01b26b70c --- /dev/null +++ b/modules/monitor/front/locale/es.yml @@ -0,0 +1,16 @@ +Tickets monitor: Monitor de tickets +Clients on website: Clientes activos en la web +Recent order actions: Acciones recientes en pedidos +Search tickets: Buscar tickets +Delete selected elements: Eliminar los elementos seleccionados +All the selected elements will be deleted. Are you sure you want to continue?: Todos los elementos seleccionados serán eliminados. ¿Seguro que quieres continuar? +Component lack: Faltan componentes +Ticket too little: Ticket demasiado pequeño +Minimize/Maximize: Minimizar/Maximizar +Problems: Problemas +Theoretical: Teórica +Practical: Práctica +Preparation: Preparación +Auto-refresh: Auto-refresco +Toggle auto-refresh every 2 minutes: Conmuta el refresco automático cada 2 minutos +Is fragile: Es frágil \ No newline at end of file From a28217001642d8a44c25ebce4c64f7cc85a2e10d Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 16 Oct 2024 11:36:48 +0200 Subject: [PATCH 25/42] fix: refs #7906 fix method --- modules/zone/back/methods/zone/deleteZone.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index 34ab177ac..5b0fe11f4 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -53,23 +53,10 @@ module.exports = Self => { const promises = []; const ticketList = await models.Ticket.find(filter, myOptions); - const fixingState = await models.State.findOne({where: {code: 'FIXING'}}, myOptions); - const worker = await models.Worker.findOne({ - where: {id: userId} - }, myOptions); if (ticketList.length > 0) throw new UserError('There are tickets for this area, delete them first'); - for (ticket of ticketList) { - if (ticket.ticketState().alertLevel == 0) { - promises.push(models.Ticket.state(ctx, { - ticketFk: ticket.id, - stateFk: fixingState.id, - userFk: worker.id - }, myOptions)); - } - } await Promise.all(promises); await models.Zone.destroyById(id, myOptions); From 3e443ad5ced8090ee005bfa79add11e60c30a654 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 16 Oct 2024 12:22:57 +0200 Subject: [PATCH 26/42] fix: refs #7230 producer fix --- print/templates/reports/delivery-note/delivery-note.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html index c1701e084..ccf2fbfb4 100644 --- a/print/templates/reports/delivery-note/delivery-note.html +++ b/print/templates/reports/delivery-note/delivery-note.html @@ -58,6 +58,7 @@ {{$t('reference')}} {{$t('quantity')}} {{$t('concept')}} + {{$t('producer')}} {{$t('price')}} {{$t('discount')}} {{$t('vat')}} @@ -69,7 +70,7 @@ {{sale.itemFk}} {{sale.quantity}} {{sale.concept}} - {{sale.price | currency('EUR', $i18n.locale)}} + {{sale.subName}} {{(sale.discount / 100) | percentage}} {{sale.vatType}} @@ -81,7 +82,6 @@ {{sale.tag5}} {{sale.value5}} {{sale.tag6}} {{sale.value6}} {{sale.tag7}} {{sale.value7}} - {{$t('producer')}} {{ sale.subName }} From 5de4a11e8b2a236bb4055253fa1c19dd9ae04e80 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 16 Oct 2024 13:53:20 +0200 Subject: [PATCH 27/42] fix: refs #7230 fix line --- print/templates/reports/delivery-note/delivery-note.html | 1 + 1 file changed, 1 insertion(+) diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html index ccf2fbfb4..89bc07488 100644 --- a/print/templates/reports/delivery-note/delivery-note.html +++ b/print/templates/reports/delivery-note/delivery-note.html @@ -71,6 +71,7 @@ {{sale.quantity}} {{sale.concept}} {{sale.subName}} + {{sale.price | currency('EUR', $i18n.locale)}} {{(sale.discount / 100) | percentage}} {{sale.vatType}} From 3f3b93625583f6366a9cd6b4f9d6008b81016645 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 16 Oct 2024 13:56:42 +0200 Subject: [PATCH 28/42] fix: refs #7906 remove code --- modules/zone/back/methods/zone/deleteZone.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index 5b0fe11f4..ffe23c9b9 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -50,14 +50,12 @@ module.exports = Self => { } } }; - const promises = []; const ticketList = await models.Ticket.find(filter, myOptions); if (ticketList.length > 0) throw new UserError('There are tickets for this area, delete them first'); - await Promise.all(promises); await models.Zone.destroyById(id, myOptions); if (tx) await tx.commit(); From 681f82a3ae934f7834d1122ef2821241242f1771 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 16 Oct 2024 16:09:53 +0200 Subject: [PATCH 29/42] feat: refs #7744 test back ok --- .../back/methods/invoiceOut/delete.js | 8 ++--- modules/ticket/back/methods/ticket/closure.js | 3 +- .../methods/ticket/specs/closeAll.spec.js | 32 ++----------------- 3 files changed, 8 insertions(+), 35 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/delete.js b/modules/invoiceOut/back/methods/invoiceOut/delete.js index d6efd9961..1ab9a582b 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/delete.js +++ b/modules/invoiceOut/back/methods/invoiceOut/delete.js @@ -37,7 +37,7 @@ module.exports = Self => { const tickets = await models.Ticket.find({ where: {refFk: invoiceOut.ref} }, myOptions); - + const [bookEntry] = await models.Xdiario.find({ where: { SERIE: invoiceOut.ref[0], @@ -55,13 +55,13 @@ module.exports = Self => { if (bookEntry) { if (bookEntry.enlazadoSage) { const params = { - bookEntry: bookEntry.ASIEN, + bookEntry: bookEntry.ASIEN, invoiceOutRef: invoiceOut.ref - } + }; await Self.rawSql(`SELECT util.notification_send('book-entry-deleted', ?, NULL)`, [JSON.stringify(params)], myOptions); - }; + } await models.Xdiario.destroyAll({ ASIEN: bookEntry.ASIEN diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index 64f198834..e4cb49007 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -19,8 +19,7 @@ module.exports = async function(ctx, Self, tickets, options) { const failedtickets = []; for (const ticket of tickets) { try { - await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId}, - myOptions); + await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], myOptions); await Self.app.models.InvoiceOut.getSerial( ticket.clientFk, diff --git a/modules/ticket/back/methods/ticket/specs/closeAll.spec.js b/modules/ticket/back/methods/ticket/specs/closeAll.spec.js index 4b067ce7e..f01541eec 100644 --- a/modules/ticket/back/methods/ticket/specs/closeAll.spec.js +++ b/modules/ticket/back/methods/ticket/specs/closeAll.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); -fdescribe('Ticket Closure - closeAll function', () => { +describe('Ticket Closure - closeAll function', () => { let ctx = { req: { getLocale: () => 'es', @@ -17,6 +17,7 @@ fdescribe('Ticket Closure - closeAll function', () => { beforeEach(async() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req}); + tx = await models.Ticket.beginTransaction({}); options = {transaction: tx}; originalVnNew = Date.vnNew; @@ -32,34 +33,7 @@ fdescribe('Ticket Closure - closeAll function', () => { await tx.rollback(); }); - xit('should successfully close all tickets when conditions are met', async() => { - const ticketsBefore = await models.Ticket.find({ - where: { - packages: {neq: 0} - } - }, options); - const packedTicketsIds = ticketsBefore.map(ticket => ticket.id); - - const packedTicketsBefore = await models.TicketLastState.find({ - where: { - ticketFk: {inq: packedTicketsIds}, - lastState: 'Encajado' - } - }, options); - - await models.Ticket.closeAll(ctx, options); - - const packedTicketsAfter = await models.TicketLastState.find({ - where: { - ticketFk: {inq: packedTicketsIds}, - lastState: 'Encajado' - } - }, options); - - expect(packedTicketsBefore.length).toBeGreaterThan(packedTicketsAfter.length); - }); - - fit('should set routeFk to NULL when conditions are met', async() => { + it('should set routeFk to NULL when conditions are met', async() => { const ticketsBefore = await models.Ticket.find({ where: { routeFk: {neq: null} From a188efb1e33d24e5a70f6301f6b739b3d93de12b Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 11:45:13 +0200 Subject: [PATCH 30/42] refactor: refs #7930 Deleted HEALTHCHECK of back dockerfile --- back/Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/back/Dockerfile b/back/Dockerfile index 363192a0b..3e2a90c58 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -55,7 +55,4 @@ COPY \ README.md \ ./ -CMD ["pm2-runtime", "./back/process.yml"] - -HEALTHCHECK --interval=15s --timeout=10s \ - CMD curl -f http://localhost:3000/api/Applications/status || exit 1 +CMD ["pm2-runtime", "./back/process.yml"] \ No newline at end of file From faecbbb3735034876e7544891fc63702e089b0ad Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 17 Oct 2024 13:08:58 +0200 Subject: [PATCH 31/42] feat: refs #8108 saltos de linea --- db/versions/11300-limeMedeola/00-firstScript.sql | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/db/versions/11300-limeMedeola/00-firstScript.sql b/db/versions/11300-limeMedeola/00-firstScript.sql index 313a65e81..28b033b4a 100644 --- a/db/versions/11300-limeMedeola/00-firstScript.sql +++ b/db/versions/11300-limeMedeola/00-firstScript.sql @@ -13,8 +13,6 @@ UPDATE vn.tag sourceTable='itemFarmingTag' WHERE name= 'cultivo'; - - CREATE TABLE IF NOT EXISTS `vn`.`itemWrappingTag` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, @@ -36,8 +34,6 @@ UPDATE vn.tag sourceTable='itemWrappingTag' WHERE name= 'Envoltorio'; - - CREATE TABLE IF NOT EXISTS `vn`.`itemLanguageTag` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, @@ -59,8 +55,6 @@ UPDATE vn.tag sourceTable='itemLanguageTag' WHERE name= 'Idioma'; - - CREATE TABLE IF NOT EXISTS `vn`.`itemStemTag` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, @@ -94,8 +88,6 @@ UPDATE vn.tag sourceTable='itemBreederTag' WHERE name= 'Obtentor'; - - CREATE TABLE IF NOT EXISTS `vn`.`itemBaseTag` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, @@ -120,8 +112,6 @@ UPDATE vn.tag sourceTable='itemBaseTag' WHERE name= 'Soporte'; - - CREATE TABLE IF NOT EXISTS `vn`.`itemVatRateTag` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, @@ -133,13 +123,11 @@ CREATE TABLE IF NOT EXISTS `vn`.`itemVatRateTag` ( INSERT IGNORE INTO `vn`.`itemVatRateTag` (`name`) VALUES ('General'); INSERT IGNORE INTO `vn`.`itemVatRateTag` (`name`) VALUES ('Reducido'); - UPDATE vn.tag SET isFree=0, sourceTable='itemVatRateTag' WHERE name= 'Tipo de IVA'; - GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemWrappingTag TO logisticAssist; GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemLanguageTag TO logisticAssist; From cb539624056c6d88d182b27745daec7334c40eb9 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 17 Oct 2024 13:58:21 +0200 Subject: [PATCH 32/42] fix: refs #6861 saleTrackingAdd --- ...saleTracking_sectorCollectionAddPrevOK.sql | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql diff --git a/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql new file mode 100644 index 000000000..3ac31752a --- /dev/null +++ b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql @@ -0,0 +1,26 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_sectorCollectionAddPrevOK`(vSectorCollectionFk INT) +BEGIN +/** + * Inserta los registros de sectorCollection con el estado PREVIA OK si la reserva está picked + * + * @param vSectorCollectionFk Identificador de vn.sectorCollection + */ + REPLACE saleTracking( + saleFk, + isChecked, + workerFk, + stateFk + ) + SELECT sgd.saleFk, + TRUE, + sc.userFk, + s.id + FROM vn.sectorCollection sc + JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk + JOIN state s ON s.code = 'OK PREVIOUS' + JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk + WHERE sc.id = vSectorCollectionFk AND iss.isPicked; +END$$ +DELIMITER ; From 28e957fecd9ba5e5c71088d00cdcdf7d47032232 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 14:46:19 +0200 Subject: [PATCH 33/42] refactor: refs #8106 refs #1406 Optimized ticket_getTax --- db/routines/vn/procedures/ticket_getTax.sql | 56 ++++++++++++------- .../back/methods/invoiceOut/negativeBases.js | 18 +++--- 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/db/routines/vn/procedures/ticket_getTax.sql b/db/routines/vn/procedures/ticket_getTax.sql index 947c45806..fc266f978 100644 --- a/db/routines/vn/procedures/ticket_getTax.sql +++ b/db/routines/vn/procedures/ticket_getTax.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getTax`(IN vTaxArea VARCHAR(25)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getTax`( + vTaxArea VARCHAR(25) +) BEGIN /** * Calcula la base imponible, el IVA y el recargo de equivalencia para @@ -33,30 +35,44 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.ticketTax (PRIMARY KEY (ticketFk, code, rate)) ENGINE = MEMORY - SELECT * FROM ( - SELECT tmpTicket.ticketFk, + WITH sales AS ( + SELECT s.id, + s.ticketFk, + s.itemFk, + s.quantity * s.price * (100 - s.discount) / 100 total, + t.companyFk, + t.addressFk, + su.countryFk, + ata.areaFk, + itc.taxClassFk + FROM vn.sale s + JOIN tmp.ticket tmp ON tmp.ticketFk = s.ticketFk + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.supplier su ON su.id = t.companyFk + JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk + AND ata.companyFk = t.companyFk + JOIN vn.itemTaxCountry itc ON itc.itemFk = s.itemFk + AND itc.countryFk = su.countryFk + HAVING total + ), + ticketTax AS ( + SELECT s.ticketFk, bp.pgcFk, - SUM(s.quantity * s.price * (100 - s.discount) / 100 ) taxableBase, + SUM(s.total) taxableBase, pgc.rate, tc.code, bp.priority - FROM tmp.ticket tmpTicket - JOIN sale s ON s.ticketFk = tmpTicket.ticketFk - JOIN item i ON i.id = s.itemFk - JOIN ticket t ON t.id = tmpTicket.ticketFk - JOIN supplier su ON su.id = t.companyFk - JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk - AND ata.companyFk = t.companyFk - JOIN itemTaxCountry itc ON itc.itemFk = i.id - AND itc.countryFk = su.countryFk - JOIN bookingPlanner bp ON bp.countryFk = su.countryFk - AND bp.taxAreaFk = ata.areaFk - AND bp.taxClassFk = itc.taxClassFk - JOIN pgc ON pgc.code = bp.pgcFk - JOIN taxClass tc ON tc.id = bp.taxClassFk - GROUP BY tmpTicket.ticketFk, pgc.code, pgc.rate + FROM sales s + JOIN vn.bookingPlanner bp ON bp.countryFk = s.countryFk + AND bp.taxAreaFk = s.areaFk + AND bp.taxClassFk = s.taxClassFk + JOIN vn.pgc ON pgc.code = bp.pgcFk + JOIN vn.taxClass tc ON tc.id = bp.taxClassFk + GROUP BY s.ticketFk, pgc.code, pgc.rate HAVING taxableBase - ) t3 + ) + SELECT * + FROM ticketTax ORDER BY priority; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js index 76ef29604..9e491b35c 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js @@ -48,13 +48,13 @@ module.exports = Self => { let stmt; stmts.push(new ParameterizedSQL( `CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (KEY (ticketFk)) + (INDEX (ticketFk)) ENGINE = MEMORY SELECT id ticketFk - FROM ticket t + FROM ticket WHERE shipped BETWEEN ? AND util.dayEnd(?) AND refFk IS NULL`, [args.from, args.to])); - stmts.push(`CALL vn.ticket_getTax(NULL)`); + stmts.push(`CALL ticket_getTax(NULL)`); stmts.push(new ParameterizedSQL( `CREATE OR REPLACE TEMPORARY TABLE tmp.filter ENGINE = MEMORY @@ -71,12 +71,12 @@ module.exports = Self => { c.isTaxDataChecked, w.id comercialId, u.name workerName - FROM vn.ticket t - JOIN vn.company co ON co.id = t.companyFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.client c ON c.id = t.clientFk - JOIN vn.country cou ON cou.id = c.countryFk - LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + FROM ticket t + JOIN company co ON co.id = t.companyFk + JOIN sale s ON s.ticketFk = t.id + JOIN client c ON c.id = t.clientFk + JOIN country cou ON cou.id = c.countryFk + LEFT JOIN worker w ON w.id = c.salesPersonFk JOIN account.user u ON u.id = w.id LEFT JOIN ( SELECT ticketFk, taxableBase From 63c0ec308f3231fbc276c7e3ee365cdc2464d5c7 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 17 Oct 2024 17:01:44 +0200 Subject: [PATCH 34/42] fix: refs #6861 saleTrackingAdd --- ...saleTracking_sectorCollectionAddPrevOK.sql | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql index 3ac31752a..a5d34c2d6 100644 --- a/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql +++ b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_sectorCollectionAddPrevOK`(vSectorCollectionFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_sectorCollectionAddPrevOK`( + vSectorCollectionFk INT + ) BEGIN /** * Inserta los registros de sectorCollection con el estado PREVIA OK si la reserva está picked @@ -12,15 +14,15 @@ BEGIN workerFk, stateFk ) - SELECT sgd.saleFk, - TRUE, - sc.userFk, - s.id - FROM vn.sectorCollection sc - JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id - JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk - JOIN state s ON s.code = 'OK PREVIOUS' - JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk - WHERE sc.id = vSectorCollectionFk AND iss.isPicked; + SELECT sgd.saleFk, + TRUE, + sc.userFk, + s.id + FROM sectorCollection sc + JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk + JOIN state s ON s.code = 'OK PREVIOUS' + JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk + WHERE sc.id = vSectorCollectionFk AND iss.isPicked; END$$ DELIMITER ; From 7dc35458e8973188cf4b968f335c438b378e85e5 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 17 Oct 2024 17:05:08 +0200 Subject: [PATCH 35/42] refactor: refs #7865 delete client.gestdocFk from TPV --- db/dump/fixtures.before.sql | 30 +++++++++---------- db/routines/vn2008/views/Clientes.sql | 1 - db/versions/11311-tealFern/00-firstScript.sql | 1 + 3 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 db/versions/11311-tealFern/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 7f7e50dd3..a6852be7e 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -388,23 +388,23 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`) (4, 'GCN Channel'), (5, 'The Newspaper'); -INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`businessTypeFk`,`typeFk`) +INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`businessTypeFk`,`typeFk`) VALUES - (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), - (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), - (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), - (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), - (1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 18, 0, 'florist','normal'), - (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 19, 0, 'florist','normal'), - (1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 19, 0, 'florist','normal'), - (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 'florist','normal'), - (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, 0, 'florist','normal'), - (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, NULL, 1, 'florist','normal'), - (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'), - (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'); + (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), + (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), + (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), + (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), + (1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 18, 0, 'florist','normal'), + (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 19, 0, 'florist','normal'), + (1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 19, 0, 'florist','normal'), + (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 'florist','normal'), + (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, 0, 'florist','normal'), + (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, NULL, 1, 'florist','normal'), + (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'), + (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'); -INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) - SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1 +INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) + SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1 FROM `account`.`role` `r` WHERE `r`.`hasLogin` = 1; diff --git a/db/routines/vn2008/views/Clientes.sql b/db/routines/vn2008/views/Clientes.sql index 153d875bc..9f8ef712e 100644 --- a/db/routines/vn2008/views/Clientes.sql +++ b/db/routines/vn2008/views/Clientes.sql @@ -22,7 +22,6 @@ AS SELECT `c`.`id` AS `id_cliente`, `c`.`credit` AS `credito`, `c`.`countryFk` AS `Id_Pais`, `c`.`isActive` AS `activo`, - `c`.`gestdocFk` AS `gestdoc_id`, `c`.`quality` AS `calidad`, `c`.`payMethodFk` AS `pay_met_id`, `c`.`created` AS `created`, diff --git a/db/versions/11311-tealFern/00-firstScript.sql b/db/versions/11311-tealFern/00-firstScript.sql new file mode 100644 index 000000000..909747f3c --- /dev/null +++ b/db/versions/11311-tealFern/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.client CHANGE gestdocFk gestdocFk__ int(11) DEFAULT NULL NULL COMMENT '@deprecated 2024-10-17'; \ No newline at end of file From 34630360866759b5bce57227b5581d203abf98ed Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 17 Oct 2024 17:20:21 +0200 Subject: [PATCH 36/42] fix: refs #6861 saleTrackingAdd --- .../saleTracking_sectorCollectionAddPrevOK.sql | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql index a5d34c2d6..003168ec8 100644 --- a/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql +++ b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql @@ -1,23 +1,15 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_sectorCollectionAddPrevOK`( vSectorCollectionFk INT - ) +) BEGIN /** * Inserta los registros de sectorCollection con el estado PREVIA OK si la reserva está picked * * @param vSectorCollectionFk Identificador de vn.sectorCollection */ - REPLACE saleTracking( - saleFk, - isChecked, - workerFk, - stateFk - ) - SELECT sgd.saleFk, - TRUE, - sc.userFk, - s.id + REPLACE saleTracking(saleFk, isChecked, workerFk, stateFk) + SELECT sgd.saleFk, TRUE, sc.userFk, s.id FROM sectorCollection sc JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk From 865da7bba2b6d071bcbfd8432ea8bfcf091e784c Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 18 Oct 2024 07:15:26 +0200 Subject: [PATCH 37/42] refactor: refs #8106 Requested changes --- db/routines/vn/procedures/ticket_getTax.sql | 35 +++++++++------------ 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/db/routines/vn/procedures/ticket_getTax.sql b/db/routines/vn/procedures/ticket_getTax.sql index fc266f978..cb9dc09d9 100644 --- a/db/routines/vn/procedures/ticket_getTax.sql +++ b/db/routines/vn/procedures/ticket_getTax.sql @@ -36,8 +36,7 @@ BEGIN (PRIMARY KEY (ticketFk, code, rate)) ENGINE = MEMORY WITH sales AS ( - SELECT s.id, - s.ticketFk, + SELECT s.ticketFk, s.itemFk, s.quantity * s.price * (100 - s.discount) / 100 total, t.companyFk, @@ -54,25 +53,21 @@ BEGIN JOIN vn.itemTaxCountry itc ON itc.itemFk = s.itemFk AND itc.countryFk = su.countryFk HAVING total - ), - ticketTax AS ( - SELECT s.ticketFk, - bp.pgcFk, - SUM(s.total) taxableBase, - pgc.rate, - tc.code, - bp.priority - FROM sales s - JOIN vn.bookingPlanner bp ON bp.countryFk = s.countryFk - AND bp.taxAreaFk = s.areaFk - AND bp.taxClassFk = s.taxClassFk - JOIN vn.pgc ON pgc.code = bp.pgcFk - JOIN vn.taxClass tc ON tc.id = bp.taxClassFk - GROUP BY s.ticketFk, pgc.code, pgc.rate - HAVING taxableBase ) - SELECT * - FROM ticketTax + SELECT s.ticketFk, + bp.pgcFk, + SUM(s.total) taxableBase, + pgc.rate, + tc.code, + bp.priority + FROM sales s + JOIN vn.bookingPlanner bp ON bp.countryFk = s.countryFk + AND bp.taxAreaFk = s.areaFk + AND bp.taxClassFk = s.taxClassFk + JOIN vn.pgc ON pgc.code = bp.pgcFk + JOIN vn.taxClass tc ON tc.id = bp.taxClassFk + GROUP BY s.ticketFk, pgc.code, pgc.rate + HAVING taxableBase ORDER BY priority; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax From 93494c3eb05ad06cab9102cc06ebdebac06dab85 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 18 Oct 2024 08:02:06 +0200 Subject: [PATCH 38/42] refactor: refs #7811 Deleted pm2 --- back/Dockerfile | 5 ++--- back/process.yml | 7 ------- 2 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 back/process.yml diff --git a/back/Dockerfile b/back/Dockerfile index 3e2a90c58..0f75f6949 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -32,8 +32,7 @@ RUN apt-get update \ RUN apt-get update \ && apt-get install -y --no-install-recommends \ samba-common-bin samba-dsdb-modules\ - && rm -rf /var/lib/apt/lists/* \ - && npm -g install pm2 + && rm -rf /var/lib/apt/lists/* # Salix @@ -55,4 +54,4 @@ COPY \ README.md \ ./ -CMD ["pm2-runtime", "./back/process.yml"] \ No newline at end of file +CMD ["node", "--tls-min-v1.0", "--openssl-legacy-provider", "./loopback/server/server.js"] \ No newline at end of file diff --git a/back/process.yml b/back/process.yml deleted file mode 100644 index 94072b57d..000000000 --- a/back/process.yml +++ /dev/null @@ -1,7 +0,0 @@ -apps: - - script: ./loopback/server/server.js - name: salix-back - instances: 1 - max_restarts: 0 - autorestart: false - node_args: --tls-min-v1.0 --openssl-legacy-provider From 02dc9520244f673d143eddcce2e176b88bc5695a Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 18 Oct 2024 08:28:08 +0200 Subject: [PATCH 39/42] fix: refs #7906 add test --- .../back/methods/zone/specs/deleteZone.spec.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index 60e704161..14cb303ea 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -9,8 +9,8 @@ describe('zone deletezone()', () => { }; const ctx = {req: activeCtx}; const zoneId = 4; + const zoneId2 = 3; let ticketIDs; - let originalTicketStates; beforeAll(async() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ @@ -44,4 +44,19 @@ describe('zone deletezone()', () => { throw e; } }); + + it('should not delete the zone if it has tickets', async() => { + const tx = await models.Zone.beginTransaction({}); + + try { + const options = {transaction: tx}; + await models.Zone.deleteZone(ctx, zoneId2, options); + + expect(e.message).toEqual('There are tickets for this area, delete them first'); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + } + }); }); From 1273e895afa18d89fabc9a16590b1b63cd73544f Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 18 Oct 2024 09:27:43 +0200 Subject: [PATCH 40/42] fix: refs #7906 fix test back --- modules/zone/back/methods/zone/specs/deleteZone.spec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index 14cb303ea..aef7fd290 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -48,15 +48,16 @@ describe('zone deletezone()', () => { it('should not delete the zone if it has tickets', async() => { const tx = await models.Zone.beginTransaction({}); + let error; try { const options = {transaction: tx}; await models.Zone.deleteZone(ctx, zoneId2, options); - - expect(e.message).toEqual('There are tickets for this area, delete them first'); - await tx.rollback(); } catch (e) { + error = e.message; await tx.rollback(); } + + expect(error).toEqual('There are tickets for this area, delete them first'); }); }); From 46993ad10324b839f25b90476dacbb7dbae15803 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 18 Oct 2024 09:29:01 +0200 Subject: [PATCH 41/42] refactor: refs #7010 deleted distinct --- modules/ticket/back/methods/ticket/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index d7e77603b..d3e53c702 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -229,7 +229,7 @@ module.exports = Self => { CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) ENGINE = InnoDB - SELECT DISTINCT t.id, + SELECT t.id, t.shipped, CAST(DATE(t.shipped) AS CHAR) shippedDate, HOUR(t.shipped) shippedHour, From bbc17d1ff886898b90cb2a75d33d8598665fcb27 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 21 Oct 2024 08:33:16 +0200 Subject: [PATCH 42/42] fix: refs #230926 item_getSimilar --- db/routines/vn/procedures/item_getSimilar.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index 537f53848..336f3521e 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -24,6 +24,7 @@ BEGIN CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated); CALL cache.visible_refresh(vVisibleCalcFk, FALSE, vWarehouseFk); + CALL buy_getUltimate(NULL, vWarehouseFk, vDated); WITH itemTags AS ( SELECT i.id, @@ -74,14 +75,13 @@ BEGIN AND a.calc_id = vAvailableCalcFk LEFT JOIN cache.visible v ON v.item_id = i.id AND v.calc_id = vVisibleCalcFk - LEFT JOIN cache.last_buy lb ON lb.item_id = i.id - AND lb.warehouse_id = vWarehouseFk + LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = i.id LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vSelf LEFT JOIN vn.itemTag it ON it.itemFk = i.id AND it.priority = vPriority LEFT JOIN vn.tag t ON t.id = it.tagFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id + LEFT JOIN vn.buy b ON b.id = bu.buyFk JOIN itemTags its WHERE a.available > 0 AND (i.typeFk = its.typeFk OR NOT vShowType) @@ -98,5 +98,7 @@ BEGIN (i.tag8 = its.tag8) DESC, match8 DESC LIMIT 100; + + DROP TEMPORARY TABLE tmp.buyUltimate; END$$ DELIMITER ;