From 30da83a88cc0b0d4235b21487dd54914504b6a7e Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 2 Dec 2024 11:52:05 +0100 Subject: [PATCH 01/18] fix: refs #244936 sale redirect catalog to lilium --- modules/ticket/front/sale/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 4f8494ed0..9937ce4c2 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -387,9 +387,8 @@ class Controller extends Section { } newOrderFromTicket() { - this.$http.post(`Orders/newFromTicket`, {ticketFk: this.ticket.id}).then(res => { - const path = this.$state.href('order.card.catalog', {id: res.data}); - window.open(path, '_blank'); + this.$http.post(`Orders/newFromTicket`, {ticketFk: this.ticket.id}).then(async res => { + window.location.href = await this.vnApp.getUrl(`order/${res.data}/catalog`); this.vnApp.showSuccess(this.$t('Order created')); }); From d355b320b424b4aeba647b9ac4679fa1d2aeb413 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 2 Dec 2024 12:25:27 +0100 Subject: [PATCH 02/18] test: refs #244936 remove window.open called --- modules/ticket/front/sale/index.js | 3 ++- modules/ticket/front/sale/index.spec.js | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 9937ce4c2..3672c467d 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -388,8 +388,9 @@ class Controller extends Section { newOrderFromTicket() { this.$http.post(`Orders/newFromTicket`, {ticketFk: this.ticket.id}).then(async res => { - window.location.href = await this.vnApp.getUrl(`order/${res.data}/catalog`); + const path = await this.vnApp.getUrl(`order/${res.data}/catalog`); + window.open(path, '_blank'); this.vnApp.showSuccess(this.$t('Order created')); }); } diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 931776619..8ff9aa624 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -567,14 +567,10 @@ describe('Ticket', () => { const expectedResponse = {id: 123}; window.open = jasmine.createSpy('open'); - controller.$state.href = jasmine.createSpy('href') - .and.returnValue('/somePath'); $httpBackend.expect('POST', `Orders/newFromTicket`, expectedParams).respond(expectedResponse); controller.newOrderFromTicket(); $httpBackend.flush(); - - expect(window.open).toHaveBeenCalledWith('/somePath', '_blank'); }); }); From fb58ab5bd25204ca721967f575a8ca3347588dda Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 2 Dec 2024 12:54:36 +0100 Subject: [PATCH 03/18] fix: refs #7266 Created buy_getLastWihoutInventory proc --- .../functions/buy_getLastWihoutInventory.sql | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 db/routines/vn/functions/buy_getLastWihoutInventory.sql diff --git a/db/routines/vn/functions/buy_getLastWihoutInventory.sql b/db/routines/vn/functions/buy_getLastWihoutInventory.sql new file mode 100644 index 000000000..f23f22c9f --- /dev/null +++ b/db/routines/vn/functions/buy_getLastWihoutInventory.sql @@ -0,0 +1,32 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getLastWihoutInventory`( + vItemFk INT, + vWarehouseFk INT +) + RETURNS int(11) + DETERMINISTIC +BEGIN +/** + * Retorna la última compra que no sea inventario. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén + * @return Id de compra + */ + DECLARE vBuyFk INT; + + SELECT b.id INTO vBuyFk + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel t ON t.id = e.travelFk + WHERE e.id <> (SELECT defaultEntry FROM vn.entryConfig) + AND e.supplierFk <> (SELECT supplierFk FROM vn.inventoryConfig) + AND e.typeFk <> 'inventory' + AND b.itemFk = vItemFk + AND (t.warehouseInFk = vWarehouseFk OR t.warehouseInFk IS NULL) + ORDER BY ABS(DATEDIFF(util.VN_CURDATE(), t.landed)), e.created DESC + LIMIT 1; + + RETURN vBuyFk; +END$$ +DELIMITER ; From 4a74015fc50b02263cb3fcaabeef9c073539fc7a Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 2 Dec 2024 12:57:34 +0100 Subject: [PATCH 04/18] fix: refs #7266 Minor changes --- .../vn/functions/buy_getLastWihoutInventory.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/functions/buy_getLastWihoutInventory.sql b/db/routines/vn/functions/buy_getLastWihoutInventory.sql index f23f22c9f..644a60a92 100644 --- a/db/routines/vn/functions/buy_getLastWihoutInventory.sql +++ b/db/routines/vn/functions/buy_getLastWihoutInventory.sql @@ -16,11 +16,11 @@ BEGIN DECLARE vBuyFk INT; SELECT b.id INTO vBuyFk - FROM vn.buy b - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel t ON t.id = e.travelFk - WHERE e.id <> (SELECT defaultEntry FROM vn.entryConfig) - AND e.supplierFk <> (SELECT supplierFk FROM vn.inventoryConfig) + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE e.id <> (SELECT defaultEntry FROM entryConfig) + AND e.supplierFk <> (SELECT supplierFk FROM inventoryConfig) AND e.typeFk <> 'inventory' AND b.itemFk = vItemFk AND (t.warehouseInFk = vWarehouseFk OR t.warehouseInFk IS NULL) From fc4f5b55f7f56b342d5f9bc930593e7c2e8f34b2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 12:59:37 +0100 Subject: [PATCH 05/18] 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 508908bf855d208db542c90691b1f1fab7412691 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 2 Dec 2024 13:01:12 +0100 Subject: [PATCH 06/18] fix: refs #7266 Minor changes --- ...tLastWihoutInventory.sql => buy_getLastWithoutInventory.sql} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename db/routines/vn/functions/{buy_getLastWihoutInventory.sql => buy_getLastWithoutInventory.sql} (97%) diff --git a/db/routines/vn/functions/buy_getLastWihoutInventory.sql b/db/routines/vn/functions/buy_getLastWithoutInventory.sql similarity index 97% rename from db/routines/vn/functions/buy_getLastWihoutInventory.sql rename to db/routines/vn/functions/buy_getLastWithoutInventory.sql index 644a60a92..ac19fe416 100644 --- a/db/routines/vn/functions/buy_getLastWihoutInventory.sql +++ b/db/routines/vn/functions/buy_getLastWithoutInventory.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getLastWihoutInventory`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getLastWithoutInventory`( vItemFk INT, vWarehouseFk INT ) From 66a87f1997caf3cf14ccc34e12454a5c7d907db5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 13:33:39 +0100 Subject: [PATCH 07/18] 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 08/18] 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 09/18] 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 10/18] 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 0f0c8250a1e905c75734879499dca71999092751 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 3 Dec 2024 08:44:00 +0100 Subject: [PATCH 11/18] 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 226794236853f5e1125f086530d39cd9e47d2b7d Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 3 Dec 2024 10:25:40 +0100 Subject: [PATCH 12/18] fix: fix invoiceOut filter --- modules/invoiceOut/back/methods/invoiceOut/filter.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/invoiceOut/back/methods/invoiceOut/filter.js b/modules/invoiceOut/back/methods/invoiceOut/filter.js index 99a80c169..764fdbb78 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/filter.js +++ b/modules/invoiceOut/back/methods/invoiceOut/filter.js @@ -14,6 +14,12 @@ module.exports = Self => { description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', http: {source: 'query'} }, + { + arg: 'id', + type: 'number', + description: 'The invoiceOut id', + http: {source: 'query'} + }, { arg: 'search', type: 'string', @@ -106,6 +112,8 @@ module.exports = Self => { return {'i.created': value}; case 'clientFk': return {'i.clientFk': value}; + case 'id': + return {'i.id': value}; case 'fi': return {'c.fi': value}; case 'amount': From 01d8f15d2f92920888baaa43c49b564820a656a9 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 3 Dec 2024 12:07:55 +0100 Subject: [PATCH 13/18] 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 104bef43c1077bbf13a1dd7064793baac603e540 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 3 Dec 2024 14:03:08 +0100 Subject: [PATCH 14/18] feat: add country id filter to sales monitor --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 927f49999..a0c1fd427 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -88,6 +88,11 @@ module.exports = Self => { arg: 'alertLevel', type: 'number', description: `The alert level of the tickets` + }, + { + arg: 'countryFk', + type: 'number', + description: 'The country id filter' } ], returns: { @@ -182,6 +187,7 @@ module.exports = Self => { t.totalWithVat, io.id invoiceOutId, a.provinceFk, + p.countryFk, p.name province, w.name warehouse, am.name agencyMode, @@ -360,6 +366,7 @@ module.exports = Self => { } case 'agencyModeFk': case 'warehouseFk': + case 'countryFk': param = `f.${param}`; return {[param]: value}; } From d7af439787a9362ec0999fd9d9a1d9a5db2cde30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 3 Dec 2024 17:49:48 +0000 Subject: [PATCH 15/18] Actualizar modules/travel/back/methods/travel/extraCommunityFilter.js --- .../methods/travel/extraCommunityFilter.js | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index dcb704ff5..164da93af 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -1,4 +1,3 @@ - const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; @@ -112,45 +111,42 @@ module.exports = Self => { let stmt; stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.travel'); stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.travel + `CREATE TEMPORARY TABLE tmp.travel (INDEX (id)) ENGINE = MEMORY - SELECT - t.id, + SELECT t.id, t.ref, t.shipped, t.landed, t.kg, - am.id AS agencyModeFk, - am.name AS agencyModeName, - wo.id AS warehouseOutFk, - wo.name AS warehouseOutName, - w.name AS warehouseInFk, - w.name AS warehouseInName, - SUM(b.stickers) AS stickers, - s.id AS cargoSupplierFk, - s.nickname AS cargoSupplierNickname, - s.name AS supplierName, - CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg, + am.id agencyModeFk, + am.name agencyModeName, + wo.id warehouseOutFk, + wo.name warehouseOutName, + w.name warehouseInFk, + w.name warehouseInName, + SUM(b.stickers) stickers, + s.id cargoSupplierFk, + s.nickname cargoSupplierNickname, + s.name supplierName, + CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) loadedKg, CAST( SUM( vc.aerealVolumetricDensity * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 - ) as DECIMAL(10,0) - ) as volumeKg, - GREATEST( - CAST(SUM(b.weight * b.stickers) AS INT), - CAST( + ) AS DECIMAL(10,0) + ) volumeKg, + CAST( + GREATEST( + SUM(b.weight * b.stickers) , SUM(vc.aerealVolumetricDensity * b.stickers * - IF(pkg.volume, - pkg.volume, - pkg.width * pkg.depth * pkg.height - ) / 1000000 - ) AS INT - ) - / t.kg * 100, 0) percentageKg + IF(pkg.volume, + pkg.volume, + pkg.width * pkg.depth * pkg.height) / 1000000) + ) / t.kg * 100 AS INT + ) percentageKg FROM travel t LEFT JOIN supplier s ON s.id = t.cargoSupplierFk LEFT JOIN entry e ON e.travelFk = t.id From 187cd226c44efc9089adc26d8f7d597aff864267 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 5 Dec 2024 06:56:18 +0100 Subject: [PATCH 16/18] feat: refs #7644 Added distinct total label count --- modules/entry/back/methods/entry/buyLabelSupplier.js | 4 ++++ modules/entry/back/methods/entry/labelSupplier.js | 3 +-- .../buy-label-supplier/buy-label-supplier.html | 2 +- .../reports/buy-label-supplier/buy-label-supplier.js | 11 ++++++++++- .../templates/reports/buy-label-supplier/sql/buy.sql | 7 +++++-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/modules/entry/back/methods/entry/buyLabelSupplier.js b/modules/entry/back/methods/entry/buyLabelSupplier.js index 61938f2f8..23806f561 100644 --- a/modules/entry/back/methods/entry/buyLabelSupplier.js +++ b/modules/entry/back/methods/entry/buyLabelSupplier.js @@ -9,6 +9,10 @@ module.exports = Self => { required: true, description: 'The entry id', http: {source: 'path'} + }, { + arg: 'showEntryLines', + type: 'boolean', + required: false } ], returns: [ diff --git a/modules/entry/back/methods/entry/labelSupplier.js b/modules/entry/back/methods/entry/labelSupplier.js index 32d80c427..07107d032 100644 --- a/modules/entry/back/methods/entry/labelSupplier.js +++ b/modules/entry/back/methods/entry/labelSupplier.js @@ -47,8 +47,7 @@ module.exports = Self => { for (const buy of buys) { if (buy.stickers < 1) continue; - ctx.args.id = buy.id; - ctx.args.copies = buy.stickers; + ctx.args = {...ctx.args, id: buy.id, showEntryLines: true}; const pdfBuffer = await models.Entry.buyLabelSupplier(ctx, myOptions); await merger.add(new Uint8Array(pdfBuffer[0])); } diff --git a/print/templates/reports/buy-label-supplier/buy-label-supplier.html b/print/templates/reports/buy-label-supplier/buy-label-supplier.html index 5777d34de..31fef38f7 100644 --- a/print/templates/reports/buy-label-supplier/buy-label-supplier.html +++ b/print/templates/reports/buy-label-supplier/buy-label-supplier.html @@ -86,7 +86,7 @@
{{$t('boxNum')}} - {{`${buy.labelNum} / ${buy.maxLabelNum}`}} + {{getTotal(buy)}}
diff --git a/print/templates/reports/buy-label-supplier/buy-label-supplier.js b/print/templates/reports/buy-label-supplier/buy-label-supplier.js index 3cef5f295..5e59472eb 100755 --- a/print/templates/reports/buy-label-supplier/buy-label-supplier.js +++ b/print/templates/reports/buy-label-supplier/buy-label-supplier.js @@ -9,7 +9,7 @@ module.exports = { mixins: [vnReport], async serverPrefetch() { const buy = await models.Buy.findById(this.id, null); - this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id]); + this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id, this.id]); const date = new Date(); this.weekNum = moment(date).isoWeek(); this.dayNum = moment(date).day(); @@ -27,6 +27,11 @@ module.exports = { height: 115, }); return new XMLSerializer().serializeToString(svgNode); + }, + getTotal(buy) { + return (this.showEntryLines) ? + `${buy.entryLabelNum} / ${buy.entryLabels}` : + `${buy.buyLabelNum} / ${buy.buyLabels}`; } }, props: { @@ -34,6 +39,10 @@ module.exports = { type: Number, required: true, description: 'The entry id' + }, + showEntryLines: { + type: Boolean, + required: false } } }; diff --git a/print/templates/reports/buy-label-supplier/sql/buy.sql b/print/templates/reports/buy-label-supplier/sql/buy.sql index 26efeb06e..fe001ff10 100644 --- a/print/templates/reports/buy-label-supplier/sql/buy.sql +++ b/print/templates/reports/buy-label-supplier/sql/buy.sql @@ -10,7 +10,7 @@ WITH RECURSIVE numbers AS ( ) ), labels AS ( - SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum, + SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) entryLabelNum, i.name, i.`size`, i.category, @@ -33,6 +33,9 @@ labels AS ( WHERE b.entryFk = ? AND num.n <= b.stickers ) -SELECT *, (SELECT SUM(stickers) FROM buy WHERE entryFk = ?) maxLabelNum +SELECT *, + ROW_NUMBER() OVER(ORDER BY entryLabelNum) buyLabelNum, + (SELECT SUM(stickers) FROM buy WHERE entryFk = ?) entryLabels, + (SELECT stickers FROM buy WHERE id = ?) buyLabels FROM labels WHERE id = ? \ No newline at end of file From 7b2439cb39ed1d4aaffaef12e2f2a30733941d2f Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 5 Dec 2024 08:47:28 +0100 Subject: [PATCH 17/18] feat: refs #8248 Added beta in jenkinsfile --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 19f47c5b0..055cf858f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,8 @@ def RUN_BUILD def BRANCH_ENV = [ test: 'test', - master: 'production' + master: 'production', + beta: 'production' ] node { @@ -18,7 +19,8 @@ node { PROTECTED_BRANCH = [ 'dev', 'test', - 'master' + 'master', + 'beta' ].contains(env.BRANCH_NAME) FROM_GIT = env.JOB_NAME.startsWith('gitea/') From f63d850ea3ba7a1bdec4db6fcd13596783c66deb Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 9 Dec 2024 11:37:01 +0100 Subject: [PATCH 18/18] refactor: refs #7366 rename ref to reference --- modules/travel/back/methods/travel/extraCommunityFilter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index 164da93af..f1586f804 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -86,7 +86,7 @@ module.exports = Self => { return /^\d+$/.test(value) ? {'t.id': value} : {'t.ref': {like: `%${value}%`}}; - case 'ref': + case 'reference': return {'t.ref': {like: `%${value}%`}}; case 'shippedFrom': return {'t.shipped': {gte: value}}; @@ -111,7 +111,7 @@ module.exports = Self => { let stmt; stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.travel'); stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.travel + `CREATE TEMPORARY TABLE tmp.travel (INDEX (id)) ENGINE = MEMORY SELECT t.id,