From d5693291f033303d9c1156c09c676a9a30bfe5c6 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 28 Nov 2024 09:24:02 +0100 Subject: [PATCH 01/11] refactor: refs #8004 simplify SQL query by removing redundant aliases --- modules/item/back/methods/item/filter.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index 54dd975a4..a7fde1e6c 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -178,17 +178,18 @@ module.exports = Self => { i.isFloramondo, i.recycledPlastic, i.nonRecycledPlastic, - pr.name AS producer, - it.name AS typeName, - it.workerFk AS buyerFk, - u.name AS userName, - ori.code AS origin, - ic.name AS category, + pr.name producer, + it.name typeName, + it.workerFk buyerFk, + u.name userName, + ori.code origin, + ic.name category, i.intrastatFk, - intr.description AS intrastat, + intr.description intrastat, b.grouping, b.packing, - lb.landing AS landed + lb.landing landed, + it.name typeName FROM item i LEFT JOIN itemType it ON it.id = i.typeFk LEFT JOIN itemCategory ic ON ic.id = it.categoryFk From fc4f5b55f7f56b342d5f9bc930593e7c2e8f34b2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 12:59:37 +0100 Subject: [PATCH 02/11] fix: refs #6818 update country & channel --- db/dump/fixtures.before.sql | 5 +++-- db/versions/11373-pinkMastic/00-firstScript.sql | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 db/versions/11373-pinkMastic/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 878f146d1..f28bd4cd5 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4028,7 +4028,8 @@ INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, c INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, '1169'), - (8, '1183'); + (8, '1183'), + (1, '1320'); INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) - VALUES ('saysimle-url-mock', 1320); + VALUES ('saysimle-url-mock', '1819'); diff --git a/db/versions/11373-pinkMastic/00-firstScript.sql b/db/versions/11373-pinkMastic/00-firstScript.sql new file mode 100644 index 000000000..48816aae6 --- /dev/null +++ b/db/versions/11373-pinkMastic/00-firstScript.sql @@ -0,0 +1,6 @@ +INSERT IGNORE INTO vn.saySimpleCountry + SET countryFk = 1, + channel = '1320'; + +UPDATE vn.saySimpleConfig + SET defaultChannel = '1819'; \ No newline at end of file From 66a87f1997caf3cf14ccc34e12454a5c7d907db5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 13:33:39 +0100 Subject: [PATCH 03/11] feat: refs #6818 add current country prefix --- db/dump/fixtures.before.sql | 4 +- .../11373-pinkMastic/00-firstScript.sql | 103 +++++++++++++++++- 2 files changed, 104 insertions(+), 3 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index f28bd4cd5..6e19f7539 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2037,10 +2037,10 @@ INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxC (4, 'Documentos', 1, 2.00, 1, 9, 1), (5, 'Documentos', 1, 2.00, 1, 8, 1); -INSERT INTO `pbx`.`config` (id,defaultPrefix) +INSERT IGNORE INTO `pbx`.`config` (id,defaultPrefix) VALUES (1,'0034'); -INSERT INTO `pbx`.`prefix` (country, prefix) +INSERT IGNORE INTO `pbx`.`prefix` (country, prefix) VALUES ('es', '0034'), ('fr', '0033'), diff --git a/db/versions/11373-pinkMastic/00-firstScript.sql b/db/versions/11373-pinkMastic/00-firstScript.sql index 48816aae6..2d7cd4dc7 100644 --- a/db/versions/11373-pinkMastic/00-firstScript.sql +++ b/db/versions/11373-pinkMastic/00-firstScript.sql @@ -3,4 +3,105 @@ INSERT IGNORE INTO vn.saySimpleCountry channel = '1320'; UPDATE vn.saySimpleConfig - SET defaultChannel = '1819'; \ No newline at end of file + SET defaultChannel = '1819'; + +INSERT IGNORE INTO pbx.prefix (country, prefix) VALUES + ('ES', '0034'), + ('IT', '0039'), + ('DE', '0049'), + ('RO', '0040'), + ('NL', '0031'), + ('BE', '0032'), + ('RU', '007'), + ('PT', '00351'), + ('LT', '00370'), + ('UA', '00380'), + ('CO', '0057'), + ('FI', '00358'), + ('EC', '00593'), + ('LB', '00961'), + ('IL', '00972'), + ('TH', '0066'), + ('PA', '00507'), + ('GB', '0044'), + ('FR', '0033'), + ('PL', '0048'), + ('MX', '0052'), + ('MA', '00212'), + ('AI', '001268'), + ('GH', '00233'), + ('SE', '0046'), + ('AE', '00971'), + ('KE', '00254'), + ('AD', '00376'), + ('AO', '00244'), + ('LU', '00352'), + ('BY', '00375'), + ('MD', '00373'), + ('DK', '0045'), + ('ET', '00251'), + ('AU', '0061'), + ('CA', '0001'), + ('CL', '0056'), + ('CN', '0086'), + ('CR', '00506'), + ('GT', '00502'), + ('CI', '00225'), + ('PE', '0051'), + ('LK', '0094'), + ('ZA', '0027'), + ('TR', '0090'), + ('ZW', '00263'), + ('MY', '0060'), + ('NZ', '0064'), + ('IE', '00353'), + ('MN', '00976'), + ('SV', '00503'), + ('ZM', '00260'), + ('JP', '0081'), + ('RW', '00250'), + ('AL', '00355'), + ('KW', '00965'), + ('SG', '0065'), + ('SR', '00597'), + ('KR', '0082'), + ('US', '0001'), + ('RS', '00381'), + ('AT', '0043'), + ('EG', '0020'), + ('LV', '00371'), + ('CY', '00357'), + ('CZ', '00420'), + ('BB', '001246'), + ('SK', '00421'), + ('IN', '0091'), + ('DZ', '00213'), + ('BR', '0055'), + ('GR', '0030'), + ('MC', '00377'), + ('SI', '00386'), + ('GP', '00590'), + ('NO', '0047'), + ('CH', '0041'), + ('AR', '0054'), + ('CU', '0053'), + ('GQ', '00240'), + ('GN', '00224'), + ('HN', '00504'), + ('ML', '00223'), + ('NI', '00505'), + ('PK', '0092'), + ('PY', '00595'), + ('SN', '00221'), + ('UY', '00598'), + ('VE', '0058'), + ('BG', '00359'), + ('GE', '00995'), + ('EE', '00372'), + ('SA', '00966'), + ('RN', '00234'), + ('HK', '00852'), + ('GI', '00350'), + ('CM', '00237'), + ('HU', '0036'), + ('AM', '00374'); \ No newline at end of file From fd05ce0915a3ec7748e7f6e578752aebe96b722d Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 2 Dec 2024 13:45:04 +0100 Subject: [PATCH 04/11] fix: refs #8222 fix prDeleteZone --- loopback/locale/en.json | 4 ++-- loopback/locale/es.json | 3 ++- modules/zone/back/methods/zone/deleteZone.js | 6 +++--- .../zone/back/methods/zone/specs/deleteZone.spec.js | 11 ++++++----- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index fdd39325b..b1cfd737f 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -245,6 +245,6 @@ "Invalid or expired verification code": "Invalid or expired verification code", "Payment method is required": "Payment method is required", "The raid information is not correct": "The raid information is not correct", - "Sales already moved": "Sales already moved" - + "Sales already moved": "Sales already moved", + "There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 4e691f375..6cd158eed 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,5 +388,6 @@ "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", - "The raid information is not correct": "La información de la redada no es correcta" + "The raid information is not correct": "La información de la redada no es correcta", + "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero" } diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index 7432475b3..e2e01a949 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -51,9 +51,9 @@ module.exports = Self => { }; const ticketList = await models.Ticket.find(filter, myOptions); - - if (ticketList.length > 0) - throw new UserError('There are tickets for this area, delete them first'); + const hasRefFk = ticketList.some(ticket => ticket.refFk); + if (hasRefFk) + throw new UserError('There are tickets to be invoiced'); await models.Zone.destroyById(id, myOptions); diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index aef7fd290..510713f9e 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -8,14 +8,14 @@ describe('zone deletezone()', () => { __: value => value }; const ctx = {req: activeCtx}; - const zoneId = 4; - const zoneId2 = 3; let ticketIDs; beforeAll(async() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ active: activeCtx }); + + const zoneId = 4; const originalTickets = await models.Ticket.find({ where: { zoneFk: zoneId @@ -29,7 +29,7 @@ describe('zone deletezone()', () => { it('should delete a zone and update their tickets', async() => { const tx = await models.Zone.beginTransaction({}); - + const zoneId = 4; try { const options = {transaction: tx}; await models.Zone.deleteZone(ctx, zoneId, options); @@ -47,17 +47,18 @@ describe('zone deletezone()', () => { it('should not delete the zone if it has tickets', async() => { const tx = await models.Zone.beginTransaction({}); + const zoneId = 1; let error; try { const options = {transaction: tx}; - await models.Zone.deleteZone(ctx, zoneId2, options); + await models.Zone.deleteZone(ctx, zoneId, options); await tx.rollback(); } catch (e) { error = e.message; await tx.rollback(); } - expect(error).toEqual('There are tickets for this area, delete them first'); + expect(error).toEqual('There are tickets to be invoiced'); }); }); From 13387beed97d04411dd71f5cf2d380617fd079f9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 14:31:06 +0100 Subject: [PATCH 05/11] feat: refs #6818 add PbxConfig model --- back/model-config.json | 3 +++ back/models/pbx-config.json | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 back/models/pbx-config.json diff --git a/back/model-config.json b/back/model-config.json index e0bc92200..55c34ff64 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -130,6 +130,9 @@ "Payment": { "dataSource": "vn" }, + "PbxConfig": { + "dataSource": "vn" + }, "Postcode": { "dataSource": "vn" }, diff --git a/back/models/pbx-config.json b/back/models/pbx-config.json new file mode 100644 index 000000000..44137b55d --- /dev/null +++ b/back/models/pbx-config.json @@ -0,0 +1,27 @@ +{ + "name": "PbxConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "pbx.config" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "defaultPrefix": { + "type": "string" + } + }, + "acls": [ + { + "property": "*", + "accessType": "READ", + "principalType": "ROLE", + "principalId": "employee", + "permission": "ALLOW" + } + ] +} \ No newline at end of file From 9573090318e06dff2a3bd7ea73f90f85a5600e7e Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 14:49:35 +0100 Subject: [PATCH 06/11] chore: refs #6818 rollback --- db/dump/fixtures.before.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 6e19f7539..658eb88c7 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2037,7 +2037,7 @@ INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxC (4, 'Documentos', 1, 2.00, 1, 9, 1), (5, 'Documentos', 1, 2.00, 1, 8, 1); -INSERT IGNORE INTO `pbx`.`config` (id,defaultPrefix) +INSERT INTO `pbx`.`config` (id,defaultPrefix) VALUES (1,'0034'); INSERT IGNORE INTO `pbx`.`prefix` (country, prefix) From 14892042bda2e09e0b85f027674946b9c186f265 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 3 Dec 2024 08:31:49 +0100 Subject: [PATCH 07/11] chore: refs #8267 pullinfo --- db/.pullinfo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/.pullinfo.json b/db/.pullinfo.json index 5b75584d1..b890ffc31 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "99f75145ac2e7b612a6d71e74b6e55f194a465780fd9875a15eb01e6596b447e" + "expeditionPallet_Print": "04fc5f2967ce53bfbb85f7f48b9a3dca4a4f7111ac41e1775f4cc7d6538774b2" } } } From a85d797edc8eb25a8e83a049b4ab808ae20762af Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 3 Dec 2024 08:40:26 +0100 Subject: [PATCH 08/11] chore: pullinfo --- db/.pullinfo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/.pullinfo.json b/db/.pullinfo.json index 5b75584d1..b890ffc31 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "99f75145ac2e7b612a6d71e74b6e55f194a465780fd9875a15eb01e6596b447e" + "expeditionPallet_Print": "04fc5f2967ce53bfbb85f7f48b9a3dca4a4f7111ac41e1775f4cc7d6538774b2" } } } From 0f0c8250a1e905c75734879499dca71999092751 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 3 Dec 2024 08:44:00 +0100 Subject: [PATCH 09/11] fix: fix sql --- db/versions/11375-navyIvy/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11375-navyIvy/00-firstScript.sql diff --git a/db/versions/11375-navyIvy/00-firstScript.sql b/db/versions/11375-navyIvy/00-firstScript.sql new file mode 100644 index 000000000..a90aaf519 --- /dev/null +++ b/db/versions/11375-navyIvy/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.ticket DROP FOREIGN KEY tickets_zone_fk; +ALTER TABLE vn.ticket ADD CONSTRAINT tickets_zone_fk FOREIGN KEY (zoneFk) REFERENCES vn.`zone`(id) ON DELETE SET NULL ON UPDATE CASCADE; From 01d8f15d2f92920888baaa43c49b564820a656a9 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 3 Dec 2024 12:07:55 +0100 Subject: [PATCH 10/11] fix: refs #4948 expedition_selfConsumptionPackaging --- .../vn/procedures/expedition_selfConsumptionPackaging.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql b/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql index 327934a43..166ec476c 100644 --- a/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql +++ b/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql @@ -54,7 +54,9 @@ proc:BEGIN WHERE shipped BETWEEN vCreated AND util.dayEnd(vCreated) AND clientFk = vClientFk AND addressFk = vAddressFk - AND warehouseFk = vWarehouseFk; + AND warehouseFk = vWarehouseFk + AND nickname = 'CAJAS AUTOCONSUMO' + LIMIT 1; IF vTicketFk IS NULL AND vAction = 'add' THEN INSERT INTO ticket(clientFk, warehouseFk, shipped, nickname, addressFk) From 71da7772d9636976dfefce8915be7d00df2c23fc Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 3 Dec 2024 14:33:42 +0100 Subject: [PATCH 11/11] build: new version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ef1dd8f89..4e823eaad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.50.0", + "version": "24.52.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0",