From 5c054fe0d3a6e73a71ab26f8e19ada1c0b757e6c Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 09:09:51 +0100 Subject: [PATCH 01/17] feat: refs #6869 add back --- .../vn/procedures/itemShelving_get.sql | 30 ----------- .../back/methods/item-shelving/getItems.js | 51 +++++++++++++++++++ modules/item/back/models/item-shelving.js | 1 + 3 files changed, 52 insertions(+), 30 deletions(-) delete mode 100644 db/routines/vn/procedures/itemShelving_get.sql create mode 100644 modules/item/back/methods/item-shelving/getItems.js diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql deleted file mode 100644 index 07384b721..000000000 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ /dev/null @@ -1,30 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8)) -BEGIN -/** -* Lista artículos de itemshelving -* -* @param vSelf matrícula del carro -**/ - SELECT ish.itemFk item, - i.name, - i.longName, - i.size, - ish.visible, - ish.packing, - ish.grouping, - p.code, - ish.id, - s.priority, - ish.isChecked, - ic.url, - ish.available, - ish.buyFk - FROM itemShelving ish - JOIN item i ON i.id = ish.itemFk - JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci - LEFT JOIN parking p ON s.parkingFk = p.id - JOIN hedera.imageConfig ic - WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf; -END$$ -DELIMITER ; diff --git a/modules/item/back/methods/item-shelving/getItems.js b/modules/item/back/methods/item-shelving/getItems.js new file mode 100644 index 000000000..2fe50d785 --- /dev/null +++ b/modules/item/back/methods/item-shelving/getItems.js @@ -0,0 +1,51 @@ +module.exports = Self => { + Self.remoteMethod('getItems', { + description: 'shelving item list', + accessType: 'READ', + accepts: [{ + arg: 'code', + type: 'string', + required: true, + description: 'Shelving code' + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/getItems`, + verb: 'GET' + } + }); + + Self.getItems = async(code, options) => { + const models = Self.app.models; + const myOptions = {}; + if (typeof options == 'object') + Object.assign(myOptions, options); + + const shelving = await models.Shelving.findOne({ + fields: ['priority', 'parkingFk'], + include: { + relation: 'parking', + scope: {fields: ['code']} + }, + where: {code} + }, myOptions); + + const itemShelvings = await Self.find({ + fields: ['itemFk', 'visible', 'packing', 'grouping', 'isChecked', 'available', 'buyFk'], + include: { + relation: 'item', + scope: {fields: ['name', 'longName', 'size']} + }, + where: {shelvingFk: code} + }, myOptions); + return { + code: shelving.parking().code, + priority: shelving.priority, + itemShelvings, + }; + // Add image from hedera.imageConfig + }; +}; diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index be72dac37..ba6ab780d 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -5,4 +5,5 @@ module.exports = Self => { require('../methods/item-shelving/getAlternative')(Self); require('../methods/item-shelving/updateFromSale')(Self); require('../methods/item-shelving/getListItemNewer')(Self); + require('../methods/item-shelving/getItems')(Self); }; From a41fc36f9092105384ccdd3bcf7f8adcc193d435 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 13:02:09 +0100 Subject: [PATCH 02/17] feat: refs #6869 define model --- back/model-config.json | 3 ++ back/models/image-config.json | 22 ++++++++ .../back/methods/item-shelving/getItems.js | 51 ------------------- modules/item/back/models/item-shelving.js | 1 - modules/item/back/models/item-shelving.json | 3 ++ modules/shelving/back/models/shelving.json | 10 +++- 6 files changed, 36 insertions(+), 54 deletions(-) create mode 100644 back/models/image-config.json delete mode 100644 modules/item/back/methods/item-shelving/getItems.js diff --git a/back/model-config.json b/back/model-config.json index 5368769fd..73db0a31b 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -79,6 +79,9 @@ "ImageCollectionSize": { "dataSource": "vn" }, + "ImageConfig": { + "dataSource": "vn" + }, "ImageContainer": { "dataSource": "imageStorage" }, diff --git a/back/models/image-config.json b/back/models/image-config.json new file mode 100644 index 000000000..11f4c2284 --- /dev/null +++ b/back/models/image-config.json @@ -0,0 +1,22 @@ +{ + "name": "ImageConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "hedera.imageConfig" + } + }, + "properties": { + "url": { + "type": "string" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/modules/item/back/methods/item-shelving/getItems.js b/modules/item/back/methods/item-shelving/getItems.js deleted file mode 100644 index 2fe50d785..000000000 --- a/modules/item/back/methods/item-shelving/getItems.js +++ /dev/null @@ -1,51 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('getItems', { - description: 'shelving item list', - accessType: 'READ', - accepts: [{ - arg: 'code', - type: 'string', - required: true, - description: 'Shelving code' - }], - returns: { - type: 'object', - root: true - }, - http: { - path: `/getItems`, - verb: 'GET' - } - }); - - Self.getItems = async(code, options) => { - const models = Self.app.models; - const myOptions = {}; - if (typeof options == 'object') - Object.assign(myOptions, options); - - const shelving = await models.Shelving.findOne({ - fields: ['priority', 'parkingFk'], - include: { - relation: 'parking', - scope: {fields: ['code']} - }, - where: {code} - }, myOptions); - - const itemShelvings = await Self.find({ - fields: ['itemFk', 'visible', 'packing', 'grouping', 'isChecked', 'available', 'buyFk'], - include: { - relation: 'item', - scope: {fields: ['name', 'longName', 'size']} - }, - where: {shelvingFk: code} - }, myOptions); - return { - code: shelving.parking().code, - priority: shelving.priority, - itemShelvings, - }; - // Add image from hedera.imageConfig - }; -}; diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index ba6ab780d..be72dac37 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -5,5 +5,4 @@ module.exports = Self => { require('../methods/item-shelving/getAlternative')(Self); require('../methods/item-shelving/updateFromSale')(Self); require('../methods/item-shelving/getListItemNewer')(Self); - require('../methods/item-shelving/getItems')(Self); }; diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 5df3b0703..b0e3f17fa 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -41,6 +41,9 @@ }, "available": { "type": "number" + }, + "buyFk": { + "type": "number" } }, "relations": { diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json index 46fce31e8..f6df57d43 100644 --- a/modules/shelving/back/models/shelving.json +++ b/modules/shelving/back/models/shelving.json @@ -1,6 +1,6 @@ { "name": "Shelving", - "base": "VnModel", + "base": "VnModel", "mixins": { "Loggable": true }, @@ -44,6 +44,12 @@ "type": "belongsTo", "model": "Worker", "foreignKey": "id" + }, + "itemShelving": { + "type": "hasMany", + "model": "ItemShelving", + "foreignKey": "shelvingFk", + "primaryKey": "code" } } -} +} \ No newline at end of file From b7655b4f9208a807d217f1934f76806c5b740a6d Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 08:24:42 +0100 Subject: [PATCH 03/17] feat: refs #8057 Added geoFk columns --- db/versions/11346-yellowPhormium/00-address.sql | 4 ++++ db/versions/11346-yellowPhormium/01-client.sql | 7 +++++++ db/versions/11346-yellowPhormium/02-supplier.sql | 6 ++++++ 3 files changed, 17 insertions(+) create mode 100644 db/versions/11346-yellowPhormium/00-address.sql create mode 100644 db/versions/11346-yellowPhormium/01-client.sql create mode 100644 db/versions/11346-yellowPhormium/02-supplier.sql diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql new file mode 100644 index 000000000..02e09bd00 --- /dev/null +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.address + ADD geoFk int(11) DEFAULT NULL NULL AFTER isLogifloraAllowed, + ADD CONSTRAINT address_zoneGeo_FK FOREIGN KEY (geoFk) + REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql new file mode 100644 index 000000000..c58810fb1 --- /dev/null +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -0,0 +1,7 @@ +ALTER TABLE vn.client + CHANGE hasDailyInvoice hasDailyInvoice tinyint(1) DEFAULT 0 NOT NULL + COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice' + AFTER recommendedCredit, + ADD geoFk int(11) DEFAULT NULL NULL AFTER hasDailyInvoice, + ADD CONSTRAINT client_zoneGeo_FK FOREIGN KEY (geoFk) + REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql new file mode 100644 index 000000000..f38202d5e --- /dev/null +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.supplier + CHANGE companySize companySize enum('small','medium','big') CHARACTER SET utf8mb3 + COLLATE utf8mb3_general_ci DEFAULT NULL NULL AFTER stamp, + ADD geoFk int(11) DEFAULT NULL NULL AFTER companySize, + ADD CONSTRAINT supplier_zoneGeo_FK FOREIGN KEY (geoFk) + REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; From d4b0da50d0a60cab3e1da5c02358c2cdf060a190 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 09:00:19 +0100 Subject: [PATCH 04/17] feat: refs #8057 Added data updates --- .../11346-yellowPhormium/00-address.sql | 23 +++++++++++++-- .../11346-yellowPhormium/01-client.sql | 29 +++++++++++++++---- .../11346-yellowPhormium/02-supplier.sql | 27 +++++++++++++---- 3 files changed, 65 insertions(+), 14 deletions(-) diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index 02e09bd00..8e1315072 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -1,4 +1,21 @@ ALTER TABLE vn.address - ADD geoFk int(11) DEFAULT NULL NULL AFTER isLogifloraAllowed, - ADD CONSTRAINT address_zoneGeo_FK FOREIGN KEY (geoFk) - REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; + ADD geoFk int(11) DEFAULT NULL NULL AFTER isLogifloraAllowed, + ADD CONSTRAINT address_zoneGeo_FK FOREIGN KEY (geoFk) + REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +CREATE OR REPLACE TEMPORARY TABLE tAddressGeo + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT a.id, p.geoFk + FROM address a + JOIN town t ON t.provinceFk = a.provinceFk + JOIN postCode p ON p.townFk = t.id + AND p.`code` = a.postalCode + GROUP BY a.id + ORDER BY (a.city SOUNDS LIKE t.`name`) DESC; + +UPDATE address a + JOIN tAddressGeo tag ON tag.id = a.id + SET a.geoFk = tag.geoFk; + +DROP TEMPORARY TABLE tAddressGeo; diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index c58810fb1..932b28ef5 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -1,7 +1,24 @@ ALTER TABLE vn.client - CHANGE hasDailyInvoice hasDailyInvoice tinyint(1) DEFAULT 0 NOT NULL - COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice' - AFTER recommendedCredit, - ADD geoFk int(11) DEFAULT NULL NULL AFTER hasDailyInvoice, - ADD CONSTRAINT client_zoneGeo_FK FOREIGN KEY (geoFk) - REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; + CHANGE hasDailyInvoice hasDailyInvoice tinyint(1) DEFAULT 0 NOT NULL + COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice' + AFTER recommendedCredit, + ADD geoFk int(11) DEFAULT NULL NULL AFTER hasDailyInvoice, + ADD CONSTRAINT client_zoneGeo_FK FOREIGN KEY (geoFk) + REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +CREATE OR REPLACE TEMPORARY TABLE tClientGeo + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT c.id, p.geoFk + FROM client c + JOIN town t ON t.provinceFk = c.provinceFk + JOIN postCode p ON p.townFk = t.id + AND p.`code` = c.postcode + GROUP BY c.id + ORDER BY (c.city SOUNDS LIKE t.`name`) DESC; + +UPDATE client c + JOIN tClientGeo tcg ON tcg.id = c.id + SET c.geoFk = tcg.geoFk; + +DROP TEMPORARY TABLE tClientGeo; diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index f38202d5e..ef5e04a43 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -1,6 +1,23 @@ ALTER TABLE vn.supplier - CHANGE companySize companySize enum('small','medium','big') CHARACTER SET utf8mb3 - COLLATE utf8mb3_general_ci DEFAULT NULL NULL AFTER stamp, - ADD geoFk int(11) DEFAULT NULL NULL AFTER companySize, - ADD CONSTRAINT supplier_zoneGeo_FK FOREIGN KEY (geoFk) - REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; + CHANGE companySize companySize enum('small','medium','big') CHARACTER SET utf8mb3 + COLLATE utf8mb3_general_ci DEFAULT NULL NULL AFTER stamp, + ADD geoFk int(11) DEFAULT NULL NULL AFTER companySize, + ADD CONSTRAINT supplier_zoneGeo_FK FOREIGN KEY (geoFk) + REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +CREATE OR REPLACE TEMPORARY TABLE tSupplierGeo + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT sa.supplierFk id, p.geoFk + FROM supplierAddress sa + JOIN town t ON t.provinceFk = sa.provinceFk + JOIN postCode p ON p.townFk = t.id + AND p.`code` = sa.postalCode + GROUP BY sa.supplierFk + ORDER BY (sa.city SOUNDS LIKE t.`name`) DESC; + +UPDATE supplier s + JOIN tSupplierGeo tsg ON tsg.id = s.id + SET s.geoFk = tsg.geoFk; + +DROP TEMPORARY TABLE tSupplierGeo; From cba1abad68cb90b238c3f0a7f7f4d158d247488c Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 09:27:38 +0100 Subject: [PATCH 05/17] feat: refs #8057 Added data updates --- db/routines/vn/functions/client_getGeo.sql | 25 +++++++++++++++++++ db/routines/vn/functions/supplier_getGeo.sql | 25 +++++++++++++++++++ .../vn/triggers/address_beforeInsert.sql | 1 + .../vn/triggers/address_beforeUpdate.sql | 6 ++++- .../vn/triggers/client_beforeInsert.sql | 8 +++--- .../vn/triggers/client_beforeUpdate.sql | 6 +++++ .../vn/triggers/supplier_beforeInsert.sql | 1 + .../vn/triggers/supplier_beforeUpdate.sql | 5 ++++ .../11346-yellowPhormium/02-supplier.sql | 12 ++++----- 9 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 db/routines/vn/functions/client_getGeo.sql create mode 100644 db/routines/vn/functions/supplier_getGeo.sql diff --git a/db/routines/vn/functions/client_getGeo.sql b/db/routines/vn/functions/client_getGeo.sql new file mode 100644 index 000000000..067eb84bc --- /dev/null +++ b/db/routines/vn/functions/client_getGeo.sql @@ -0,0 +1,25 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_getGeo`(vSelf INT) + RETURNS int(11) + DETERMINISTIC +BEGIN +/** + * Returns the geo for the passed client. + * + * @param vSelf The address id + * @return The geo id + */ + DECLARE vGeoFk INT; + + SELECT p.geoFk INTO vGeoFk + FROM client c + JOIN town t ON t.provinceFk = c.provinceFk + JOIN postCode p ON p.townFk = t.id + AND p.`code` = c.postcode + WHERE c.id = vSelf + ORDER BY (c.city SOUNDS LIKE t.`name`) DESC + LIMIT 1; + + RETURN vGeoFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/functions/supplier_getGeo.sql b/db/routines/vn/functions/supplier_getGeo.sql new file mode 100644 index 000000000..93115d712 --- /dev/null +++ b/db/routines/vn/functions/supplier_getGeo.sql @@ -0,0 +1,25 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`supplier_getGeo`(vSelf INT) + RETURNS int(11) + DETERMINISTIC +BEGIN +/** + * Returns the geo for the passed supplier. + * + * @param vSelf The address id + * @return The geo id + */ + DECLARE vGeoFk INT; + + SELECT p.geoFk INTO vGeoFk + FROM supplier s + JOIN town t ON t.provinceFk = s.provinceFk + JOIN postCode p ON p.townFk = t.id + AND p.`code` = s.postCode + WHERE s.id = vSelf + ORDER BY (s.city SOUNDS LIKE t.`name`) DESC + LIMIT 1; + + RETURN vGeoFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/address_beforeInsert.sql b/db/routines/vn/triggers/address_beforeInsert.sql index 56ef7aa51..a4f384f14 100644 --- a/db/routines/vn/triggers/address_beforeInsert.sql +++ b/db/routines/vn/triggers/address_beforeInsert.sql @@ -6,6 +6,7 @@ BEGIN DECLARE vIsEqualizated BOOL; SET NEW.editorFk = account.myUser_getId(); + SET NEW.geoFk = address_getGeo(NEW.id); IF (NEW.phone <> '') THEN CALL pbx.phone_isValid(NEW.phone); diff --git a/db/routines/vn/triggers/address_beforeUpdate.sql b/db/routines/vn/triggers/address_beforeUpdate.sql index 35887912c..0b19a6266 100644 --- a/db/routines/vn/triggers/address_beforeUpdate.sql +++ b/db/routines/vn/triggers/address_beforeUpdate.sql @@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`address_beforeUpdate` BEFORE UPDATE ON `address` FOR EACH ROW BEGIN - SET NEW.editorFk = account.myUser_getId(); IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN @@ -14,5 +13,10 @@ BEGIN CALL pbx.phone_isValid(NEW.mobile); END IF; + IF NOT (NEW.provinceFk <=> OLD.provinceFk) + OR (NEW.postalCode <=> OLD.postalCode) THEN + + SET NEW.geoFk = address_getGeo(NEW.id); + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/client_beforeInsert.sql b/db/routines/vn/triggers/client_beforeInsert.sql index 45de107f1..b4038a2ba 100644 --- a/db/routines/vn/triggers/client_beforeInsert.sql +++ b/db/routines/vn/triggers/client_beforeInsert.sql @@ -3,8 +3,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`client_beforeInsert` BEFORE INSERT ON `client` FOR EACH ROW BEGIN - SET NEW.editorFk = account.myUser_getId(); + SET NEW.accountingAccount = 4300000000 + NEW.id; + SET NEW.lastSalesPersonFk = NEW.salesPersonFk; + SET NEW.geoFk = client_getGeo(NEW.id); IF (NEW.phone <> '') THEN CALL pbx.phone_isValid(NEW.phone); @@ -13,9 +15,5 @@ BEGIN IF (NEW.mobile <> '') THEN CALL pbx.phone_isValid(NEW.mobile); END IF; - - SET NEW.accountingAccount = 4300000000 + NEW.id; - - SET NEW.lastSalesPersonFk = NEW.salesPersonFk; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/client_beforeUpdate.sql b/db/routines/vn/triggers/client_beforeUpdate.sql index 7142d6604..00418a9e7 100644 --- a/db/routines/vn/triggers/client_beforeUpdate.sql +++ b/db/routines/vn/triggers/client_beforeUpdate.sql @@ -72,5 +72,11 @@ BEGIN IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN SET NEW.isTaxDataChecked = 0; END IF; + + IF NOT (NEW.provinceFk <=> OLD.provinceFk) + OR (NEW.postcode <=> OLD.postcode) THEN + + SET NEW.geoFk = client_getGeo(NEW.id); + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/supplier_beforeInsert.sql b/db/routines/vn/triggers/supplier_beforeInsert.sql index b141ec8fb..5bbfc79a1 100644 --- a/db/routines/vn/triggers/supplier_beforeInsert.sql +++ b/db/routines/vn/triggers/supplier_beforeInsert.sql @@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplier_beforeInsert` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + SET NEW.geoFk = supplier_getGeo(NEW.id); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/supplier_beforeUpdate.sql b/db/routines/vn/triggers/supplier_beforeUpdate.sql index af730b49d..10b63ee72 100644 --- a/db/routines/vn/triggers/supplier_beforeUpdate.sql +++ b/db/routines/vn/triggers/supplier_beforeUpdate.sql @@ -40,5 +40,10 @@ BEGIN SET NEW.isPayMethodChecked = FALSE; END IF; + IF NOT (NEW.provinceFk <=> OLD.provinceFk) + OR (NEW.postcode <=> OLD.postcode) THEN + + SET NEW.geoFk = client_getGeo(NEW.id); + END IF; END$$ DELIMITER ; diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index ef5e04a43..b3e25bd7e 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -8,13 +8,13 @@ ALTER TABLE vn.supplier CREATE OR REPLACE TEMPORARY TABLE tSupplierGeo (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT sa.supplierFk id, p.geoFk - FROM supplierAddress sa - JOIN town t ON t.provinceFk = sa.provinceFk + SELECT s.id, p.geoFk + FROM supplier s + JOIN town t ON t.provinceFk = s.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = sa.postalCode - GROUP BY sa.supplierFk - ORDER BY (sa.city SOUNDS LIKE t.`name`) DESC; + AND p.`code` = s.postCode + GROUP BY s.id + ORDER BY (s.city SOUNDS LIKE t.`name`) DESC; UPDATE supplier s JOIN tSupplierGeo tsg ON tsg.id = s.id From bde192966e00803c883aa7a418ae7431ea018775 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 09:30:36 +0100 Subject: [PATCH 06/17] feat: refs #8057 Added data updates --- db/routines/vn/triggers/supplier_beforeUpdate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/supplier_beforeUpdate.sql b/db/routines/vn/triggers/supplier_beforeUpdate.sql index 10b63ee72..55c671185 100644 --- a/db/routines/vn/triggers/supplier_beforeUpdate.sql +++ b/db/routines/vn/triggers/supplier_beforeUpdate.sql @@ -43,7 +43,7 @@ BEGIN IF NOT (NEW.provinceFk <=> OLD.provinceFk) OR (NEW.postcode <=> OLD.postcode) THEN - SET NEW.geoFk = client_getGeo(NEW.id); + SET NEW.geoFk = supplier_getGeo(NEW.id); END IF; END$$ DELIMITER ; From b9397c527ddbaffc660b30005729bba3b6d44a3c Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 09:32:02 +0100 Subject: [PATCH 07/17] feat: refs #8057 Added data updates --- db/routines/vn/triggers/supplier_beforeUpdate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/supplier_beforeUpdate.sql b/db/routines/vn/triggers/supplier_beforeUpdate.sql index 55c671185..b502340a3 100644 --- a/db/routines/vn/triggers/supplier_beforeUpdate.sql +++ b/db/routines/vn/triggers/supplier_beforeUpdate.sql @@ -41,7 +41,7 @@ BEGIN END IF; IF NOT (NEW.provinceFk <=> OLD.provinceFk) - OR (NEW.postcode <=> OLD.postcode) THEN + OR (NEW.postCode <=> OLD.postCode) THEN SET NEW.geoFk = supplier_getGeo(NEW.id); END IF; From 7a4455d6d01d2fe4a3157f94889e4b928edc807c Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 15 Nov 2024 08:12:16 +0100 Subject: [PATCH 08/17] feat: refs #6869 refs#6869 itemShelving_get --- .../vn/procedures/itemShelving_get.sql | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 db/routines/vn/procedures/itemShelving_get.sql diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql new file mode 100644 index 000000000..07384b721 --- /dev/null +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -0,0 +1,30 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8)) +BEGIN +/** +* Lista artículos de itemshelving +* +* @param vSelf matrícula del carro +**/ + SELECT ish.itemFk item, + i.name, + i.longName, + i.size, + ish.visible, + ish.packing, + ish.grouping, + p.code, + ish.id, + s.priority, + ish.isChecked, + ic.url, + ish.available, + ish.buyFk + FROM itemShelving ish + JOIN item i ON i.id = ish.itemFk + JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci + LEFT JOIN parking p ON s.parkingFk = p.id + JOIN hedera.imageConfig ic + WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf; +END$$ +DELIMITER ; From 6c00efae895790e83d0541bf6212215c3c0b3e30 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sun, 17 Nov 2024 17:57:54 +0100 Subject: [PATCH 09/17] feat: refs #7289 #7289 apply option 1 --- loopback/locale/en.json | 4 +++- loopback/locale/es.json | 6 ++++-- modules/ticket/back/methods/ticket/transferSales.js | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 95f6ff326..86ebebc89 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -244,5 +244,7 @@ "Invalid or expired verification code": "Invalid or expired verification code", "There are tickets for this area, delete them first": "There are tickets for this area, delete them first", "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}", - "Payment method is required": "Payment method is required" + "Payment method is required": "Payment method is required", + "Sales already moved": "Sales already moved" + } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 37976c0ea..a68fcc4e4 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -387,5 +387,7 @@ "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero", "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén", "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", - "The web user's email already exists": "El correo del usuario web ya existe" -} \ No newline at end of file + "The web user's email already exists": "El correo del usuario web ya existe", + "Sales already moved": "Ya han sido transferidas", + "Línea ya ha sido transferida": "Línea ya ha sido transferida" +} diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 5f5fdde67..bc3c467d7 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -80,6 +80,9 @@ module.exports = Self => { const hasClaimedSales = await models.ClaimBeginning.findOne({where: {saleFk: {inq: saleIds}}}); if (ticketId != id && hasClaimedSales) throw new UserError(`Can't transfer claimed sales`); + const missingSales = sales.some(({id}) => !map.has(id)); + if (missingSales) + throw new UserError($t('Sales already moved')); for (const sale of sales) { const originalSale = map.get(sale.id); From 353ca659cd98d133632c5a0e90ef332d9d1438b7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 08:58:38 +0100 Subject: [PATCH 10/17] feat: refs #8057 Requested changes --- db/routines/vn/functions/address_getGeo.sql | 5 +++-- db/routines/vn/functions/client_getGeo.sql | 4 ++-- db/routines/vn/functions/supplier_getGeo.sql | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/functions/address_getGeo.sql b/db/routines/vn/functions/address_getGeo.sql index 04155c30c..248e8c787 100644 --- a/db/routines/vn/functions/address_getGeo.sql +++ b/db/routines/vn/functions/address_getGeo.sql @@ -14,9 +14,10 @@ BEGIN SELECT p.geoFk INTO vGeoFk FROM address a JOIN town t ON t.provinceFk = a.provinceFk - JOIN postCode p ON p.townFk = t.id AND p.`code` = a.postalCode + JOIN postCode p ON p.townFk = t.id WHERE a.id = vSelf - ORDER BY (a.city SOUNDS LIKE t.`name`) DESC + ORDER BY (a.city SOUNDS LIKE t.name) DESC, + (p.code = a.postalCode) DESC LIMIT 1; RETURN vGeoFk; diff --git a/db/routines/vn/functions/client_getGeo.sql b/db/routines/vn/functions/client_getGeo.sql index 067eb84bc..624becf1e 100644 --- a/db/routines/vn/functions/client_getGeo.sql +++ b/db/routines/vn/functions/client_getGeo.sql @@ -15,9 +15,9 @@ BEGIN FROM client c JOIN town t ON t.provinceFk = c.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = c.postcode WHERE c.id = vSelf - ORDER BY (c.city SOUNDS LIKE t.`name`) DESC + ORDER BY (c.city SOUNDS LIKE t.name) DESC, + (p.code = c.postcode) DESC LIMIT 1; RETURN vGeoFk; diff --git a/db/routines/vn/functions/supplier_getGeo.sql b/db/routines/vn/functions/supplier_getGeo.sql index 93115d712..29b6736f3 100644 --- a/db/routines/vn/functions/supplier_getGeo.sql +++ b/db/routines/vn/functions/supplier_getGeo.sql @@ -15,9 +15,11 @@ BEGIN FROM supplier s JOIN town t ON t.provinceFk = s.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = s.postCode + LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id WHERE s.id = vSelf - ORDER BY (s.city SOUNDS LIKE t.`name`) DESC + ORDER BY (s.city SOUNDS LIKE t.name) DESC, + (p.code = s.postCode) DESC, + (p.code = sad.postalCode) DESC LIMIT 1; RETURN vGeoFk; From 9558d030ff8baa3b1d2a81af61f5b5e692fc4199 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 18 Nov 2024 10:10:30 +0100 Subject: [PATCH 11/17] feat: refs #7289 #7289 remove bad translation --- loopback/locale/es.json | 3 +-- modules/ticket/back/methods/ticket/transferSales.js | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index a68fcc4e4..8bf9f31c4 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,6 +388,5 @@ "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén", "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", "The web user's email already exists": "El correo del usuario web ya existe", - "Sales already moved": "Ya han sido transferidas", - "Línea ya ha sido transferida": "Línea ya ha sido transferida" + "Sales already moved": "Ya han sido transferidas" } diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index bc3c467d7..580a8e1f7 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -80,6 +80,7 @@ module.exports = Self => { const hasClaimedSales = await models.ClaimBeginning.findOne({where: {saleFk: {inq: saleIds}}}); if (ticketId != id && hasClaimedSales) throw new UserError(`Can't transfer claimed sales`); + const missingSales = sales.some(({id}) => !map.has(id)); if (missingSales) throw new UserError($t('Sales already moved')); From dd637b9333ea75f966f8efb8e1823bae39de960a Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 18 Nov 2024 10:34:23 +0100 Subject: [PATCH 12/17] fix: refs #6869 use id as primaryKey --- modules/shelving/back/models/shelving.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json index f6df57d43..84e260b9e 100644 --- a/modules/shelving/back/models/shelving.json +++ b/modules/shelving/back/models/shelving.json @@ -48,8 +48,7 @@ "itemShelving": { "type": "hasMany", "model": "ItemShelving", - "foreignKey": "shelvingFk", - "primaryKey": "code" + "foreignKey": "shelvingFk" } } } \ No newline at end of file From a64f9b74ec9d6d69231d62caa7dfbfa642890764 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 10:52:41 +0100 Subject: [PATCH 13/17] feat: refs #8057 Requested changes --- db/versions/11346-yellowPhormium/00-address.sql | 4 ++-- db/versions/11346-yellowPhormium/01-client.sql | 4 ++-- db/versions/11346-yellowPhormium/02-supplier.sql | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index 8e1315072..a8ee88b94 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -10,9 +10,9 @@ CREATE OR REPLACE TEMPORARY TABLE tAddressGeo FROM address a JOIN town t ON t.provinceFk = a.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = a.postalCode GROUP BY a.id - ORDER BY (a.city SOUNDS LIKE t.`name`) DESC; + ORDER BY (a.city SOUNDS LIKE t.`name`) DESC, + (p.code = a.postalCode) DESC; UPDATE address a JOIN tAddressGeo tag ON tag.id = a.id diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index 932b28ef5..e1294c30e 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -13,9 +13,9 @@ CREATE OR REPLACE TEMPORARY TABLE tClientGeo FROM client c JOIN town t ON t.provinceFk = c.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = c.postcode GROUP BY c.id - ORDER BY (c.city SOUNDS LIKE t.`name`) DESC; + ORDER BY (c.city SOUNDS LIKE t.`name`) DESC, + (p.code = c.postcode) DESC; UPDATE client c JOIN tClientGeo tcg ON tcg.id = c.id diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index b3e25bd7e..57cdefaea 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -12,9 +12,11 @@ CREATE OR REPLACE TEMPORARY TABLE tSupplierGeo FROM supplier s JOIN town t ON t.provinceFk = s.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = s.postCode + LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id GROUP BY s.id - ORDER BY (s.city SOUNDS LIKE t.`name`) DESC; + ORDER BY (s.city SOUNDS LIKE t.`name`) DESC, + (p.code = s.postCode) DESC, + (p.code = sad.postalCode) DESC; UPDATE supplier s JOIN tSupplierGeo tsg ON tsg.id = s.id From aed4bc89c7eb09f808778804fa5ee94d93909e0a Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 12:53:36 +0100 Subject: [PATCH 14/17] feat: refs #8057 Fix version --- db/versions/11346-yellowPhormium/00-address.sql | 6 +++--- db/versions/11346-yellowPhormium/01-client.sql | 6 +++--- db/versions/11346-yellowPhormium/02-supplier.sql | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index a8ee88b94..70683fc8f 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -3,7 +3,7 @@ ALTER TABLE vn.address ADD CONSTRAINT address_zoneGeo_FK FOREIGN KEY (geoFk) REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; -CREATE OR REPLACE TEMPORARY TABLE tAddressGeo +CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo (PRIMARY KEY (id)) ENGINE = MEMORY SELECT a.id, p.geoFk @@ -15,7 +15,7 @@ CREATE OR REPLACE TEMPORARY TABLE tAddressGeo (p.code = a.postalCode) DESC; UPDATE address a - JOIN tAddressGeo tag ON tag.id = a.id + JOIN tmp.tAddressGeo tag ON tag.id = a.id SET a.geoFk = tag.geoFk; -DROP TEMPORARY TABLE tAddressGeo; +DROP TEMPORARY TABLE tmp.tAddressGeo; diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index e1294c30e..a8bd16921 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -6,7 +6,7 @@ ALTER TABLE vn.client ADD CONSTRAINT client_zoneGeo_FK FOREIGN KEY (geoFk) REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; -CREATE OR REPLACE TEMPORARY TABLE tClientGeo +CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo (PRIMARY KEY (id)) ENGINE = MEMORY SELECT c.id, p.geoFk @@ -18,7 +18,7 @@ CREATE OR REPLACE TEMPORARY TABLE tClientGeo (p.code = c.postcode) DESC; UPDATE client c - JOIN tClientGeo tcg ON tcg.id = c.id + JOIN tmp.tClientGeo tcg ON tcg.id = c.id SET c.geoFk = tcg.geoFk; -DROP TEMPORARY TABLE tClientGeo; +DROP TEMPORARY TABLE tmp.tClientGeo; diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index 57cdefaea..5f902d039 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -5,7 +5,7 @@ ALTER TABLE vn.supplier ADD CONSTRAINT supplier_zoneGeo_FK FOREIGN KEY (geoFk) REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; -CREATE OR REPLACE TEMPORARY TABLE tSupplierGeo +CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo (PRIMARY KEY (id)) ENGINE = MEMORY SELECT s.id, p.geoFk @@ -19,7 +19,7 @@ CREATE OR REPLACE TEMPORARY TABLE tSupplierGeo (p.code = sad.postalCode) DESC; UPDATE supplier s - JOIN tSupplierGeo tsg ON tsg.id = s.id + JOIN tmp.tSupplierGeo tsg ON tsg.id = s.id SET s.geoFk = tsg.geoFk; -DROP TEMPORARY TABLE tSupplierGeo; +DROP TEMPORARY TABLE tmp.tSupplierGeo; From 2b770c020141d637de644d2e40251f9eefc54e19 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 12:56:37 +0100 Subject: [PATCH 15/17] feat: refs #8057 Fix version --- db/versions/11346-yellowPhormium/00-address.sql | 8 ++++---- db/versions/11346-yellowPhormium/01-client.sql | 8 ++++---- db/versions/11346-yellowPhormium/02-supplier.sql | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index 70683fc8f..2f8033b0a 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -7,14 +7,14 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo (PRIMARY KEY (id)) ENGINE = MEMORY SELECT a.id, p.geoFk - FROM address a - JOIN town t ON t.provinceFk = a.provinceFk - JOIN postCode p ON p.townFk = t.id + FROM vn.address a + JOIN vn.town t ON t.provinceFk = a.provinceFk + JOIN vn.postCode p ON p.townFk = t.id GROUP BY a.id ORDER BY (a.city SOUNDS LIKE t.`name`) DESC, (p.code = a.postalCode) DESC; -UPDATE address a +UPDATE vn.address a JOIN tmp.tAddressGeo tag ON tag.id = a.id SET a.geoFk = tag.geoFk; diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index a8bd16921..855d873f9 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -10,14 +10,14 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo (PRIMARY KEY (id)) ENGINE = MEMORY SELECT c.id, p.geoFk - FROM client c - JOIN town t ON t.provinceFk = c.provinceFk - JOIN postCode p ON p.townFk = t.id + FROM vn.client c + JOIN vn.town t ON t.provinceFk = c.provinceFk + JOIN vn.postCode p ON p.townFk = t.id GROUP BY c.id ORDER BY (c.city SOUNDS LIKE t.`name`) DESC, (p.code = c.postcode) DESC; -UPDATE client c +UPDATE vn.client c JOIN tmp.tClientGeo tcg ON tcg.id = c.id SET c.geoFk = tcg.geoFk; diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index 5f902d039..9a0cd5b42 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -9,16 +9,16 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo (PRIMARY KEY (id)) ENGINE = MEMORY SELECT s.id, p.geoFk - FROM supplier s - JOIN town t ON t.provinceFk = s.provinceFk - JOIN postCode p ON p.townFk = t.id - LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id + FROM vn.supplier s + JOIN vn.town t ON t.provinceFk = s.provinceFk + JOIN vn.postCode p ON p.townFk = t.id + LEFT JOIN vn.supplierAddress sad ON sad.supplierFk = s.id GROUP BY s.id ORDER BY (s.city SOUNDS LIKE t.`name`) DESC, (p.code = s.postCode) DESC, (p.code = sad.postalCode) DESC; -UPDATE supplier s +UPDATE vn.supplier s JOIN tmp.tSupplierGeo tsg ON tsg.id = s.id SET s.geoFk = tsg.geoFk; From cdcc5051d2ba4619f140e9938a55f59941bcf85a Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 13:09:33 +0100 Subject: [PATCH 16/17] feat: refs #8057 Fix version --- db/routines/vn/functions/address_getGeo.sql | 1 + db/routines/vn/functions/client_getGeo.sql | 1 + db/routines/vn/functions/supplier_getGeo.sql | 1 + db/versions/11346-yellowPhormium/00-address.sql | 1 + db/versions/11346-yellowPhormium/01-client.sql | 1 + db/versions/11346-yellowPhormium/02-supplier.sql | 1 + 6 files changed, 6 insertions(+) diff --git a/db/routines/vn/functions/address_getGeo.sql b/db/routines/vn/functions/address_getGeo.sql index 248e8c787..0800d226a 100644 --- a/db/routines/vn/functions/address_getGeo.sql +++ b/db/routines/vn/functions/address_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM address a JOIN town t ON t.provinceFk = a.provinceFk JOIN postCode p ON p.townFk = t.id + JOIN zoneGeo zg ON zg.id = p.geoFk WHERE a.id = vSelf ORDER BY (a.city SOUNDS LIKE t.name) DESC, (p.code = a.postalCode) DESC diff --git a/db/routines/vn/functions/client_getGeo.sql b/db/routines/vn/functions/client_getGeo.sql index 624becf1e..e16653ee5 100644 --- a/db/routines/vn/functions/client_getGeo.sql +++ b/db/routines/vn/functions/client_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM client c JOIN town t ON t.provinceFk = c.provinceFk JOIN postCode p ON p.townFk = t.id + JOIN zoneGeo zg ON zg.id = p.geoFk WHERE c.id = vSelf ORDER BY (c.city SOUNDS LIKE t.name) DESC, (p.code = c.postcode) DESC diff --git a/db/routines/vn/functions/supplier_getGeo.sql b/db/routines/vn/functions/supplier_getGeo.sql index 29b6736f3..10ca5b8b8 100644 --- a/db/routines/vn/functions/supplier_getGeo.sql +++ b/db/routines/vn/functions/supplier_getGeo.sql @@ -16,6 +16,7 @@ BEGIN JOIN town t ON t.provinceFk = s.provinceFk JOIN postCode p ON p.townFk = t.id LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id + JOIN zoneGeo zg ON zg.id = p.geoFk WHERE s.id = vSelf ORDER BY (s.city SOUNDS LIKE t.name) DESC, (p.code = s.postCode) DESC, diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index 2f8033b0a..6837e0d86 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -10,6 +10,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo FROM vn.address a JOIN vn.town t ON t.provinceFk = a.provinceFk JOIN vn.postCode p ON p.townFk = t.id + JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY a.id ORDER BY (a.city SOUNDS LIKE t.`name`) DESC, (p.code = a.postalCode) DESC; diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index 855d873f9..a95d21efa 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -13,6 +13,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo FROM vn.client c JOIN vn.town t ON t.provinceFk = c.provinceFk JOIN vn.postCode p ON p.townFk = t.id + JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY c.id ORDER BY (c.city SOUNDS LIKE t.`name`) DESC, (p.code = c.postcode) DESC; diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index 9a0cd5b42..a28e7d680 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -13,6 +13,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo JOIN vn.town t ON t.provinceFk = s.provinceFk JOIN vn.postCode p ON p.townFk = t.id LEFT JOIN vn.supplierAddress sad ON sad.supplierFk = s.id + JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY s.id ORDER BY (s.city SOUNDS LIKE t.`name`) DESC, (p.code = s.postCode) DESC, From 8d4769d74d45e4f0ec430c0273479cddea173c2e Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 13:34:20 +0100 Subject: [PATCH 17/17] feat: refs #8057 More precision in getGeo --- db/routines/vn/functions/address_getGeo.sql | 1 + db/routines/vn/functions/client_getGeo.sql | 1 + db/routines/vn/functions/supplier_getGeo.sql | 1 + db/versions/11346-yellowPhormium/00-address.sql | 1 + db/versions/11346-yellowPhormium/01-client.sql | 1 + db/versions/11346-yellowPhormium/02-supplier.sql | 1 + 6 files changed, 6 insertions(+) diff --git a/db/routines/vn/functions/address_getGeo.sql b/db/routines/vn/functions/address_getGeo.sql index 0800d226a..213eb91c3 100644 --- a/db/routines/vn/functions/address_getGeo.sql +++ b/db/routines/vn/functions/address_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM address a JOIN town t ON t.provinceFk = a.provinceFk JOIN postCode p ON p.townFk = t.id + AND (p.code = a.postalCode OR a.postalCode IS NULL) JOIN zoneGeo zg ON zg.id = p.geoFk WHERE a.id = vSelf ORDER BY (a.city SOUNDS LIKE t.name) DESC, diff --git a/db/routines/vn/functions/client_getGeo.sql b/db/routines/vn/functions/client_getGeo.sql index e16653ee5..9c2e3212e 100644 --- a/db/routines/vn/functions/client_getGeo.sql +++ b/db/routines/vn/functions/client_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM client c JOIN town t ON t.provinceFk = c.provinceFk JOIN postCode p ON p.townFk = t.id + AND (p.code = c.postcode OR c.postcode IS NULL) JOIN zoneGeo zg ON zg.id = p.geoFk WHERE c.id = vSelf ORDER BY (c.city SOUNDS LIKE t.name) DESC, diff --git a/db/routines/vn/functions/supplier_getGeo.sql b/db/routines/vn/functions/supplier_getGeo.sql index 10ca5b8b8..86984272c 100644 --- a/db/routines/vn/functions/supplier_getGeo.sql +++ b/db/routines/vn/functions/supplier_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM supplier s JOIN town t ON t.provinceFk = s.provinceFk JOIN postCode p ON p.townFk = t.id + AND (p.code = s.postCode OR s.postCode IS NULL) LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id JOIN zoneGeo zg ON zg.id = p.geoFk WHERE s.id = vSelf diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index 6837e0d86..f91d0ae9f 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -10,6 +10,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo FROM vn.address a JOIN vn.town t ON t.provinceFk = a.provinceFk JOIN vn.postCode p ON p.townFk = t.id + AND (p.code = a.postalCode OR a.postalCode IS NULL) JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY a.id ORDER BY (a.city SOUNDS LIKE t.`name`) DESC, diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index a95d21efa..cb6fe41e8 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -13,6 +13,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo FROM vn.client c JOIN vn.town t ON t.provinceFk = c.provinceFk JOIN vn.postCode p ON p.townFk = t.id + AND (p.code = c.postcode OR c.postcode IS NULL) JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY c.id ORDER BY (c.city SOUNDS LIKE t.`name`) DESC, diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index a28e7d680..4e866525e 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -12,6 +12,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo FROM vn.supplier s JOIN vn.town t ON t.provinceFk = s.provinceFk JOIN vn.postCode p ON p.townFk = t.id + AND (p.code = s.postCode OR s.postCode IS NULL) LEFT JOIN vn.supplierAddress sad ON sad.supplierFk = s.id JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY s.id