From 2f2d65bfd67c3880a9fc76e8d0c4718027c86b31 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 16 Mar 2023 10:33:24 +0100 Subject: [PATCH 01/13] =?UTF-8?q?refs=20#5342=20feat:=20a=C3=B1adido=20ico?= =?UTF-8?q?no=20en=20los=20tickets=20que=20tengan=20sales=20fragiles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- db/changes/231201/00-sale_getWarnings.sql | 35 +++++++++++++++ db/changes/231201/00-ticket_getWarnings.sql | 36 ++++++++++++++++ .../back/methods/sales-monitor/salesFilter.js | 19 +++++++- modules/monitor/front/index/locale/es.yml | 3 +- .../monitor/front/index/tickets/index.html | 43 +++++++++++-------- 6 files changed, 117 insertions(+), 21 deletions(-) create mode 100644 db/changes/231201/00-sale_getWarnings.sql create mode 100644 db/changes/231201/00-ticket_getWarnings.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index dde790aaa..8f4e45398 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2312.01] - 2023-04-06 ### Added -- +- (Monitor tickets) Muestra un icono al lado de la zona, si es frágil y se envía por agencia ### Changed - diff --git a/db/changes/231201/00-sale_getWarnings.sql b/db/changes/231201/00-sale_getWarnings.sql new file mode 100644 index 000000000..ee2c7b8f2 --- /dev/null +++ b/db/changes/231201/00-sale_getWarnings.sql @@ -0,0 +1,35 @@ +DROP PROCEDURE IF EXISTS `vn`.`sale_getWarnings`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`sale_getWarnings`() +BEGIN +/** + * Calcula las advertencias de cada venta para un conjunto de tickets. + * + * @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular + * @return tmp.sale_warnings + */ + + DROP TEMPORARY TABLE IF EXISTS tmp.sale_warnings; + CREATE TEMPORARY TABLE tmp.sale_warnings ( + ticketFk INT(11), + saleFk INT(11), + isFragile INTEGER(1) DEFAULT 0, + PRIMARY KEY (ticketFk, saleFk) + ) ENGINE = MEMORY; + + -- Frágil + INSERT INTO tmp.sale_warnings(ticketFk, saleFk, isFragile) + SELECT tt.ticketFk, s.id, TRUE + FROM tmp.sale_getWarnings tt + LEFT JOIN sale s ON s.ticketFk = tt.ticketFk + LEFT JOIN item i ON i.id = s.itemFk + LEFT JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk + LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE dm.code IN ('AGENCY', 'DELIVERY') + AND (ic.code = 'plant' OR it.code IN ('ZKA', 'ZKE')); +END$$ +DELIMITER ; diff --git a/db/changes/231201/00-ticket_getWarnings.sql b/db/changes/231201/00-ticket_getWarnings.sql new file mode 100644 index 000000000..0cd420bd3 --- /dev/null +++ b/db/changes/231201/00-ticket_getWarnings.sql @@ -0,0 +1,36 @@ +DROP PROCEDURE IF EXISTS `vn`.`ticket_getWarnings`; + +DELIMITER $$ +$$ +CREATE PROCEDURE `vn`.`ticket_getWarnings`() +BEGIN +/** + * Calcula las adventencias para un conjunto de tickets. + * Agrupados por ticket + * + * @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular + * @return tmp.ticket_warnings + */ + CALL sale_getWarnings(); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket_warnings; + CREATE TEMPORARY TABLE tmp.ticket_warnings + (PRIMARY KEY (ticketFk)) + ENGINE = MEMORY + SELECT + sw.ticketFk, + MAX(sw.isFragile) AS isFragile, + 0 AS totalWarnings + FROM tmp.sale_warnings sw + GROUP BY sw.ticketFk; + + UPDATE tmp.ticket_warnings tw + SET tw.totalWarnings = + ( + (tw.isFragile) + ); + + DROP TEMPORARY TABLE + tmp.sale_warnings; +END$$ +DELIMITER ; diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 881fc637a..c9a25b1a1 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -295,11 +295,26 @@ module.exports = Self => { risk = t.debt + t.credit, totalProblems = totalProblems + 1 `); + stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getWarnings'); + stmt = new ParameterizedSQL(` - SELECT t.*, tp.*, - ((tp.risk) + cc.riskTolerance < 0) AS hasHighRisk + CREATE TEMPORARY TABLE tmp.sale_getWarnings + (INDEX (ticketFk, agencyModeFk)) + ENGINE = MEMORY + SELECT f.id ticketFk, f.agencyModeFk + FROM tmp.filter f`); + stmts.push(stmt); + + stmts.push('CALL ticket_getWarnings()'); + + stmt = new ParameterizedSQL(` + SELECT t.*, + tp.*, + ((tp.risk) + cc.riskTolerance < 0) AS hasHighRisk, + tw.* FROM tmp.tickets t LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = t.id + LEFT JOIN tmp.ticket_warnings tw ON tw.ticketFk = t.id JOIN clientConfig cc`); const hasProblems = args.problems; diff --git a/modules/monitor/front/index/locale/es.yml b/modules/monitor/front/index/locale/es.yml index 126528caa..f114a2259 100644 --- a/modules/monitor/front/index/locale/es.yml +++ b/modules/monitor/front/index/locale/es.yml @@ -12,4 +12,5 @@ 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 \ No newline at end of file +Toggle auto-refresh every 2 minutes: Conmuta el refresco automático cada 2 minutos +Is fragile: Es frágil diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html index b8559154e..539d4b3cb 100644 --- a/modules/monitor/front/index/tickets/index.html +++ b/modules/monitor/front/index/tickets/index.html @@ -19,13 +19,13 @@ Tickets monitor - + - State + Zone @@ -80,7 +81,7 @@ @@ -169,12 +170,20 @@ class="link"> {{ticket.refFk}} - {{ticket.state}} + + + + - Filter by selection - Exclude selection - Remove filter - Remove all filters - Copy value From 23ce51abf07c23fb7b0253d72706bba3bd3e2ce7 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 16 Mar 2023 11:34:57 +0100 Subject: [PATCH 02/13] refs #5342 add changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f4e45398..e7d1da557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2312.01] - 2023-04-06 ### Added -- (Monitor tickets) Muestra un icono al lado de la zona, si es frágil y se envía por agencia +- (Monitor tickets) Muestra un icono al lado de la zona, si el ticket es frágil y se envía por agencia ### Changed - From 5598bbaaa8a645a76475149e89dcb5b48b9751b3 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 22 Mar 2023 10:13:37 +0100 Subject: [PATCH 03/13] fix e2e --- e2e/helpers/selectors.js | 3 +-- e2e/paths/03-worker/04_time_control.spec.js | 6 +++--- e2e/paths/03-worker/06_create.spec.js | 1 - e2e/paths/05-ticket/21_future.spec.js | 6 +++--- e2e/paths/05-ticket/22_advance.spec.js | 8 ++++---- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index f20d75310..0762a79f0 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -524,7 +524,7 @@ export default { }, itemLog: { anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr', - fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) table tr:nth-child(4) td.after', + fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) table tr:nth-child(5) td.after', }, ticketSummary: { header: 'vn-ticket-summary > vn-card > h5', @@ -1040,7 +1040,6 @@ export default { boss: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bossFk"]', role: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.roleFk"]', iban: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.iban"]', - switft: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bankEntityFk"]', createButton: 'vn-worker-create vn-submit[label="Create"]', }, workerPda: { diff --git a/e2e/paths/03-worker/04_time_control.spec.js b/e2e/paths/03-worker/04_time_control.spec.js index eb1417ba9..5f64aa6ce 100644 --- a/e2e/paths/03-worker/04_time_control.spec.js +++ b/e2e/paths/03-worker/04_time_control.spec.js @@ -27,7 +27,7 @@ describe('Worker time control path', () => { date.setMonth(date.getMonth() + 1); let month = date.toLocaleString('default', {month: 'long'}); - await page.click(selectors.workerTimeControl.nextMonthButton); + await page.waitToClick(selectors.workerTimeControl.nextMonthButton); let result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText'); expect(result).toContain(month); @@ -36,7 +36,7 @@ describe('Worker time control path', () => { date.setDate(1); month = date.toLocaleString('default', {month: 'long'}); - await page.click(selectors.workerTimeControl.previousMonthButton); + await page.waitToClick(selectors.workerTimeControl.previousMonthButton); result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText'); expect(result).toContain(month); @@ -49,7 +49,7 @@ describe('Worker time control path', () => { await page.loginAndModule('salesBoss', 'worker'); await page.goto(`http://localhost:5000/#!/worker/${hankPymId}/time-control?timestamp=${timestamp}`); - await page.click(selectors.workerTimeControl.secondWeekDay); + await page.waitToClick(selectors.workerTimeControl.secondWeekDay); result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText'); diff --git a/e2e/paths/03-worker/06_create.spec.js b/e2e/paths/03-worker/06_create.spec.js index 5f6f5cf9f..98e67edbf 100644 --- a/e2e/paths/03-worker/06_create.spec.js +++ b/e2e/paths/03-worker/06_create.spec.js @@ -26,7 +26,6 @@ describe('Worker create path', () => { await page.write(selectors.workerCreate.street, 'S/ Doomstadt'); await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com'); await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332'); - await page.autocompleteSearch(selectors.workerCreate.switft, 'BBKKESMMMMM'); // should check for autocompleted worker code and worker user name const workerCode = await page diff --git a/e2e/paths/05-ticket/21_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js index 2b8057247..626056958 100644 --- a/e2e/paths/05-ticket/21_future.spec.js +++ b/e2e/paths/05-ticket/21_future.spec.js @@ -54,7 +54,7 @@ describe('Ticket Future path', () => { it('should search with the origin IPT', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.autocompleteSearch(selectors.ticketFuture.ipt, 'Horizontal'); + await page.autocompleteSearch(selectors.ticketFuture.ipt, 'H'); await page.waitToClick(selectors.ticketFuture.submit); expect(httpRequest).toContain('ipt=H'); @@ -65,7 +65,7 @@ describe('Ticket Future path', () => { await page.clearInput(selectors.ticketFuture.ipt); - await page.autocompleteSearch(selectors.ticketFuture.futureIpt, 'Horizontal'); + await page.autocompleteSearch(selectors.ticketFuture.futureIpt, 'H'); await page.waitToClick(selectors.ticketFuture.submit); expect(httpRequest).toContain('futureIpt=H'); @@ -108,7 +108,7 @@ describe('Ticket Future path', () => { it('should search in smart-table with an IPT Destination', async() => { await page.waitToClick(selectors.ticketFuture.tableButtonSearch); - await page.autocompleteSearch(selectors.ticketFuture.tableFutureIpt, 'Horizontal'); + await page.autocompleteSearch(selectors.ticketFuture.tableFutureIpt, 'H'); expect(httpRequest).toContain('futureIpt'); await page.waitToClick(selectors.ticketFuture.tableButtonSearch); diff --git a/e2e/paths/05-ticket/22_advance.spec.js b/e2e/paths/05-ticket/22_advance.spec.js index f8442bf12..15f9dd5bb 100644 --- a/e2e/paths/05-ticket/22_advance.spec.js +++ b/e2e/paths/05-ticket/22_advance.spec.js @@ -54,7 +54,7 @@ describe('Ticket Advance path', () => { it('should search with the origin IPT', async() => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'Horizontal'); + await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'H'); await page.waitToClick(selectors.ticketAdvance.submit); expect(httpRequest).toContain('futureIpt=H'); @@ -66,7 +66,7 @@ describe('Ticket Advance path', () => { it('should search with the destination IPT', async() => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'Horizontal'); + await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'H'); await page.waitToClick(selectors.ticketAdvance.submit); expect(httpRequest).toContain('ipt=H'); @@ -78,7 +78,7 @@ describe('Ticket Advance path', () => { it('should search in smart-table with an IPT Origin', async() => { await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.autocompleteSearch(selectors.ticketAdvance.tableFutureIpt, 'Vertical'); + await page.autocompleteSearch(selectors.ticketAdvance.tableFutureIpt, 'V'); expect(httpRequest).toContain('futureIpt'); @@ -89,7 +89,7 @@ describe('Ticket Advance path', () => { it('should search in smart-table with an IPT Destination', async() => { await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.autocompleteSearch(selectors.ticketAdvance.tableIpt, 'Vertical'); + await page.autocompleteSearch(selectors.ticketAdvance.tableIpt, 'V'); expect(httpRequest).toContain('ipt'); From d276c7b6116ac2638f31e4f3848354c8358cc4f7 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 22 Mar 2023 10:57:18 +0100 Subject: [PATCH 04/13] refs #5342 unificados proc x_getWarnings --- db/changes/231201/00-itemType_isFragile.sql | 5 +++ db/changes/231201/00-sale_getWarnings.sql | 35 ------------------- db/changes/231201/00-ticket_getWarnings.sql | 30 +++++++++++----- .../back/methods/sales-monitor/salesFilter.js | 3 ++ 4 files changed, 29 insertions(+), 44 deletions(-) create mode 100644 db/changes/231201/00-itemType_isFragile.sql delete mode 100644 db/changes/231201/00-sale_getWarnings.sql diff --git a/db/changes/231201/00-itemType_isFragile.sql b/db/changes/231201/00-itemType_isFragile.sql new file mode 100644 index 000000000..00a74b8b6 --- /dev/null +++ b/db/changes/231201/00-itemType_isFragile.sql @@ -0,0 +1,5 @@ +ALTER TABLE `vn`.`itemType` ADD isFragile tinyint(1) NULL; +ALTER TABLE `vn`.`itemType` MODIFY COLUMN isFragile tinyint(1) DEFAULT 0 NOT NULL; +UPDATE `vn`.`itemType` + SET isFragile = 1 + WHERE code IN ('ZKA', 'ZKE'); diff --git a/db/changes/231201/00-sale_getWarnings.sql b/db/changes/231201/00-sale_getWarnings.sql deleted file mode 100644 index ee2c7b8f2..000000000 --- a/db/changes/231201/00-sale_getWarnings.sql +++ /dev/null @@ -1,35 +0,0 @@ -DROP PROCEDURE IF EXISTS `vn`.`sale_getWarnings`; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`sale_getWarnings`() -BEGIN -/** - * Calcula las advertencias de cada venta para un conjunto de tickets. - * - * @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular - * @return tmp.sale_warnings - */ - - DROP TEMPORARY TABLE IF EXISTS tmp.sale_warnings; - CREATE TEMPORARY TABLE tmp.sale_warnings ( - ticketFk INT(11), - saleFk INT(11), - isFragile INTEGER(1) DEFAULT 0, - PRIMARY KEY (ticketFk, saleFk) - ) ENGINE = MEMORY; - - -- Frágil - INSERT INTO tmp.sale_warnings(ticketFk, saleFk, isFragile) - SELECT tt.ticketFk, s.id, TRUE - FROM tmp.sale_getWarnings tt - LEFT JOIN sale s ON s.ticketFk = tt.ticketFk - LEFT JOIN item i ON i.id = s.itemFk - LEFT JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk - LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE dm.code IN ('AGENCY', 'DELIVERY') - AND (ic.code = 'plant' OR it.code IN ('ZKA', 'ZKE')); -END$$ -DELIMITER ; diff --git a/db/changes/231201/00-ticket_getWarnings.sql b/db/changes/231201/00-ticket_getWarnings.sql index 0cd420bd3..605fe6ad0 100644 --- a/db/changes/231201/00-ticket_getWarnings.sql +++ b/db/changes/231201/00-ticket_getWarnings.sql @@ -11,7 +11,26 @@ BEGIN * @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular * @return tmp.ticket_warnings */ - CALL sale_getWarnings(); + DROP TEMPORARY TABLE IF EXISTS tmp.sale_warnings; + CREATE TEMPORARY TABLE tmp.sale_warnings ( + ticketFk INT(11), + saleFk INT(11), + isFragile INTEGER(1) DEFAULT 0, + PRIMARY KEY (ticketFk, saleFk) + ) ENGINE = MEMORY; + + -- Frágil + INSERT INTO tmp.sale_warnings(ticketFk, saleFk, isFragile) + SELECT tt.ticketFk, s.id, TRUE + FROM tmp.sale_getWarnings tt + LEFT JOIN sale s ON s.ticketFk = tt.ticketFk + LEFT JOIN item i ON i.id = s.itemFk + LEFT JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk + LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE dm.code IN ('AGENCY') + AND (ic.code = 'plant' OR it.isFragile); DROP TEMPORARY TABLE IF EXISTS tmp.ticket_warnings; CREATE TEMPORARY TABLE tmp.ticket_warnings @@ -19,17 +38,10 @@ BEGIN ENGINE = MEMORY SELECT sw.ticketFk, - MAX(sw.isFragile) AS isFragile, - 0 AS totalWarnings + MAX(sw.isFragile) AS isFragile FROM tmp.sale_warnings sw GROUP BY sw.ticketFk; - UPDATE tmp.ticket_warnings tw - SET tw.totalWarnings = - ( - (tw.isFragile) - ); - DROP TEMPORARY TABLE tmp.sale_warnings; END$$ diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index c9a25b1a1..b6ebcc5a2 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -402,6 +402,9 @@ module.exports = Self => { tmp.filter, tmp.ticket_problems, tmp.sale_getProblems, + tmp.sale_warnings, + tmp.sale_getWarnings, + tmp.ticket_warnings, tmp.risk`); const sql = ParameterizedSQL.join(stmts, ';'); From 59c3ef23de9f1887a0428d9ee49bca6e4d7743aa Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 22 Mar 2023 11:03:13 +0100 Subject: [PATCH 05/13] grabUser added --- modules/entry/back/models/buy.json | 5 +++-- modules/entry/back/models/entry.json | 3 ++- modules/item/back/models/item.json | 5 +++-- modules/route/back/models/route.json | 3 ++- modules/ticket/back/models/sale.json | 3 ++- modules/ticket/back/models/ticket.json | 7 ++++--- modules/travel/back/models/travel.json | 3 ++- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json index 8e36d0eef..de2ddffd6 100644 --- a/modules/entry/back/models/buy.json +++ b/modules/entry/back/models/buy.json @@ -3,7 +3,8 @@ "base": "Loggable", "log": { "model": "EntryLog", - "relation": "entry" + "relation": "entry", + "grabUser": true }, "options": { "mysql": { @@ -70,4 +71,4 @@ "foreignKey": "packageFk" } } -} \ No newline at end of file +} diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index d9b7c52df..48b4d1be0 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -2,7 +2,8 @@ "name": "Entry", "base": "Loggable", "log": { - "model":"EntryLog" + "model":"EntryLog", + "grabUser": true }, "options": { "mysql": { diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index 2f58c30a9..dc38a44e6 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -3,7 +3,8 @@ "base": "Loggable", "log": { "model": "ItemLog", - "showField": "id" + "showField": "id", + "grabUser": true }, "options": { "mysql": { @@ -214,4 +215,4 @@ } } } -} \ No newline at end of file +} diff --git a/modules/route/back/models/route.json b/modules/route/back/models/route.json index 12b9785db..3b12f4ee6 100644 --- a/modules/route/back/models/route.json +++ b/modules/route/back/models/route.json @@ -2,7 +2,8 @@ "name": "Route", "base": "Loggable", "log": { - "model":"RouteLog" + "model":"RouteLog", + "grabUser": true }, "options": { "mysql": { diff --git a/modules/ticket/back/models/sale.json b/modules/ticket/back/models/sale.json index b30954ad1..b1f70f5e2 100644 --- a/modules/ticket/back/models/sale.json +++ b/modules/ticket/back/models/sale.json @@ -4,7 +4,8 @@ "log": { "model": "TicketLog", "relation": "ticket", - "showField": "concept" + "showField": "concept", + "grabUser": true }, "options": { "mysql": { diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json index 09b01d213..89ebde85d 100644 --- a/modules/ticket/back/models/ticket.json +++ b/modules/ticket/back/models/ticket.json @@ -3,7 +3,8 @@ "base": "Loggable", "log": { "model":"TicketLog", - "showField": "id" + "showField": "id", + "grabUser": true }, "options": { "mysql": { @@ -36,7 +37,7 @@ "type": "number" }, "updated": { - "type": "date", + "type": "date", "mysql": { "columnName": "created" } @@ -136,4 +137,4 @@ "foreignKey": "zoneFk" } } -} \ No newline at end of file +} diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json index c20b7b0bf..7dd9f5bba 100644 --- a/modules/travel/back/models/travel.json +++ b/modules/travel/back/models/travel.json @@ -3,7 +3,8 @@ "base": "Loggable", "log": { "model":"TravelLog", - "showField": "ref" + "showField": "ref", + "grabUser": true }, "options": { "mysql": { From 81472a5e50b63758cbecac683ef2470275ed8566 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 22 Mar 2023 11:36:28 +0100 Subject: [PATCH 06/13] removed duplicated log --- modules/ticket/back/methods/ticket/new.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index e6048421e..e7e4cd01b 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -126,19 +126,6 @@ module.exports = Self => { ], myOptions); const ticket = await models.Ticket.findById(result[1][0].newTicketId, null, myOptions); - const cleanInstance = JSON.parse(JSON.stringify(ticket)); - - const logRecord = { - originFk: cleanInstance.id, - userFk: myUserId, - action: 'insert', - changedModel: 'Ticket', - changedModelId: cleanInstance.id, - oldInstance: {}, - newInstance: cleanInstance - }; - - await models.TicketLog.create(logRecord, myOptions); if (tx) await tx.commit(); From 27bb50ad1278f85876123cec20f6f12b1260a8ce Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 22 Mar 2023 12:17:48 +0100 Subject: [PATCH 07/13] refs #5342 esta tabla ya se borra en el proc --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index b6ebcc5a2..484f3d0b1 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -402,7 +402,6 @@ module.exports = Self => { tmp.filter, tmp.ticket_problems, tmp.sale_getProblems, - tmp.sale_warnings, tmp.sale_getWarnings, tmp.ticket_warnings, tmp.risk`); From fcd422eb497efd7634f065d07482990a7ac4ea7a Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 22 Mar 2023 14:55:54 +0100 Subject: [PATCH 08/13] added relation --- modules/claim/back/models/claim.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/claim/back/models/claim.json b/modules/claim/back/models/claim.json index cd5b767e4..4b26720e5 100644 --- a/modules/claim/back/models/claim.json +++ b/modules/claim/back/models/claim.json @@ -82,6 +82,11 @@ "type": "hasMany", "model": "ClaimDms", "foreignKey": "claimFk" + }, + "lines": { + "type": "hasMany", + "model": "ClaimBeginning", + "foreignKey": "claimFk" } } } From 7e37d7f3f1b943009e14206852f6482a0b357642 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 23 Mar 2023 09:25:56 +0100 Subject: [PATCH 09/13] refs #5342 actualido el itemType.isFragile para las 'plants' --- db/changes/231201/00-itemType_isFragile.sql | 11 ++++++++++- db/changes/231201/00-ticket_getWarnings.sql | 3 +-- db/dump/fixtures.sql | 14 +++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/db/changes/231201/00-itemType_isFragile.sql b/db/changes/231201/00-itemType_isFragile.sql index 00a74b8b6..5b25288f3 100644 --- a/db/changes/231201/00-itemType_isFragile.sql +++ b/db/changes/231201/00-itemType_isFragile.sql @@ -1,5 +1,14 @@ ALTER TABLE `vn`.`itemType` ADD isFragile tinyint(1) NULL; ALTER TABLE `vn`.`itemType` MODIFY COLUMN isFragile tinyint(1) DEFAULT 0 NOT NULL; + UPDATE `vn`.`itemType` SET isFragile = 1 - WHERE code IN ('ZKA', 'ZKE'); +WHERE code IN ('ZKA', 'ZKE'); + +UPDATE `vn`.`itemType` + SET isFragile = 1 +WHERE id IN (SELECT it.id + FROM itemCategory ic + JOIN itemType it ON it.categoryFk = ic.id + WHERE ic.code = 'plant'); + diff --git a/db/changes/231201/00-ticket_getWarnings.sql b/db/changes/231201/00-ticket_getWarnings.sql index 605fe6ad0..5253b58ab 100644 --- a/db/changes/231201/00-ticket_getWarnings.sql +++ b/db/changes/231201/00-ticket_getWarnings.sql @@ -26,11 +26,10 @@ BEGIN LEFT JOIN sale s ON s.ticketFk = tt.ticketFk LEFT JOIN item i ON i.id = s.itemFk LEFT JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk WHERE dm.code IN ('AGENCY') - AND (ic.code = 'plant' OR it.isFragile); + AND it.isFragile; DROP TEMPORARY TABLE IF EXISTS tmp.ticket_warnings; CREATE TEMPORARY TABLE tmp.ticket_warnings diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 2145f8429..f78313cc9 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -838,14 +838,14 @@ INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) ('warm', 'Warm', 'Warm'), ('cool', 'Cool', 'Cool'); -INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`, `workerFk`, `isPackaging`, `temperatureFk`) +INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`, `workerFk`, `isPackaging`, `temperatureFk`, `isFragile`) VALUES - (1, 'CRI', 'Crisantemo', 2, 31, 35, 0, 'cool'), - (2, 'ITG', 'Anthurium', 1, 31, 35, 0, 'cool'), - (3, 'WPN', 'Paniculata', 2, 31, 35, 0, 'cool'), - (4, 'PRT', 'Delivery ports', 3, NULL, 35, 1, 'warm'), - (5, 'CON', 'Container', 3, NULL, 35, 1, 'warm'), - (6, 'ALS', 'Alstroemeria', 1, 31, 16, 0, 'warm'); + (1, 'CRI', 'Crisantemo', 2, 31, 35, 0, 'cool', 0), + (2, 'ITG', 'Anthurium', 1, 31, 35, 0, 'cool', 1), + (3, 'WPN', 'Paniculata', 2, 31, 35, 0, 'cool', 0), + (4, 'PRT', 'Delivery ports', 3, NULL, 35, 1, 'warm', 0), + (5, 'CON', 'Container', 3, NULL, 35, 1, 'warm', 0), + (6, 'ALS', 'Alstroemeria', 1, 31, 16, 0, 'warm', 1); INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`) VALUES From 4e5364dc0b68c833d41837f48d7aabff591224a8 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 23 Mar 2023 10:05:02 +0100 Subject: [PATCH 10/13] refs #5036 fix tests logs --- .../collection/spec/setSaleQuantity.spec.js | 15 +++++++++++++ e2e/helpers/selectors.js | 1 - e2e/paths/04-item/10_item_log.spec.js | 6 ++--- .../05-ticket/01-sale/02_edit_sale.spec.js | 1 + .../10-travel/02_basic_data_and_log.spec.js | 2 ++ .../claim/specs/regularizeClaim.spec.js | 15 +++++++++++++ .../entry/specs/editLatestBuys.spec.js | 16 ++++++++++++++ .../specs/upsertFixedPrice.spec.js | 12 ++++++++++ .../back/methods/item/specs/clone.spec.js | 14 ++++++++++++ .../item/back/methods/item/specs/new.spec.js | 15 +++++++++++++ .../methods/item/specs/regularize.spec.js | 15 +++++++++++++ .../back/methods/route/specs/clone.spec.js | 16 ++++++++++++++ .../route/specs/updateWorkCenter.spec.js | 14 ++++++++++++ .../back/methods/sale/specs/canEdit.spec.js | 14 ++++++++++++ .../methods/sale/specs/deleteSales.spec.js | 15 +++++++++++++ .../back/methods/sale/specs/reserve.spec.js | 15 +++++++++++++ .../methods/sale/specs/updateConcept.spec.js | 15 +++++++++++++ .../methods/sale/specs/updatePrice.spec.js | 15 +++++++++++++ .../methods/sale/specs/updateQuantity.spec.js | 15 +++++++++++++ .../back/methods/ticket/specs/addSale.spec.js | 14 ++++++++++++ .../back/methods/ticket/specs/merge.spec.js | 22 +++++++++++-------- .../ticket/specs/updateDiscount.spec.js | 14 ++++++++++++ 22 files changed, 268 insertions(+), 13 deletions(-) diff --git a/back/methods/collection/spec/setSaleQuantity.spec.js b/back/methods/collection/spec/setSaleQuantity.spec.js index 63dc3bd2d..acdf2ebb5 100644 --- a/back/methods/collection/spec/setSaleQuantity.spec.js +++ b/back/methods/collection/spec/setSaleQuantity.spec.js @@ -1,6 +1,21 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('setSaleQuantity()', () => { + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + it('should change quantity sale', async() => { const tx = await models.Ticket.beginTransaction({}); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 0762a79f0..f4c67f002 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -524,7 +524,6 @@ export default { }, itemLog: { anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr', - fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) table tr:nth-child(5) td.after', }, ticketSummary: { header: 'vn-ticket-summary > vn-card > h5', diff --git a/e2e/paths/04-item/10_item_log.spec.js b/e2e/paths/04-item/10_item_log.spec.js index 46979a761..6a7bd7ae2 100644 --- a/e2e/paths/04-item/10_item_log.spec.js +++ b/e2e/paths/04-item/10_item_log.spec.js @@ -48,14 +48,14 @@ describe('Item log path', () => { await page.accessToSection('item.card.log'); }); - it(`should confirm the log is showing 5 entries`, async() => { + it(`should confirm the log is showing 4 entries`, async() => { await page.waitForSelector(selectors.itemLog.anyLineCreated); const anyLineCreatedCount = await page.countElement(selectors.itemLog.anyLineCreated); - expect(anyLineCreatedCount).toEqual(5); + expect(anyLineCreatedCount).toEqual(4); }); - it(`should confirm the log is showing the intrastat for the created item`, async() => { + xit(`should confirm the log is showing the intrastat for the created item`, async() => { const fifthLineCreatedProperty = await page .waitToGetProperty(selectors.itemLog.fifthLineCreatedProperty, 'innerText'); diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 36161ae1d..f9b520981 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -197,6 +197,7 @@ describe('Ticket Edit sale path', () => { }); it('should check in the history that logs has been added', async() => { + pending('https://redmine.verdnatura.es/issues/5455'); await page.reload({waitUntil: ['networkidle0', 'domcontentloaded']}); await page.waitToClick(selectors.ticketSales.firstSaleHistoryButton); await page.waitForSelector(selectors.ticketSales.firstSaleHistory); diff --git a/e2e/paths/10-travel/02_basic_data_and_log.spec.js b/e2e/paths/10-travel/02_basic_data_and_log.spec.js index 341b38f59..bffcb8642 100644 --- a/e2e/paths/10-travel/02_basic_data_and_log.spec.js +++ b/e2e/paths/10-travel/02_basic_data_and_log.spec.js @@ -89,11 +89,13 @@ describe('Travel basic data path', () => { }); it('should navigate to the travel logs', async() => { + pending('https://redmine.verdnatura.es/issues/5455'); await page.accessToSection('travel.card.log'); await page.waitForState('travel.card.log'); }); it('should check the 1st log contains details from the changes made', async() => { + pending('https://redmine.verdnatura.es/issues/5455'); const result = await page.waitToGetProperty(selectors.travelLog.firstLogFirstTD, 'innerText'); expect(result).toContain('new reference!'); diff --git a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js index bf26d2255..276843c32 100644 --- a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js @@ -1,4 +1,5 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('claim regularizeClaim()', () => { const userId = 18; @@ -39,6 +40,20 @@ describe('claim regularizeClaim()', () => { return await models.ClaimEnd.create(claimEnds, options); } + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + it('should send a chat message with value "Trash" and then change claim state to resolved', async() => { const tx = await models.Claim.beginTransaction({}); diff --git a/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js b/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js index 86ed9dddc..99d2df67b 100644 --- a/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js +++ b/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js @@ -1,6 +1,22 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('Buy editLatestsBuys()', () => { + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + it('should change the value of a given column for the selected buys', async() => { const tx = await models.Buy.beginTransaction({}); const options = {transaction: tx}; diff --git a/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js b/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js index 5a47de6bf..86f73122d 100644 --- a/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js +++ b/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js @@ -1,4 +1,5 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('upsertFixedPrice()', () => { const now = Date.vnNew(); @@ -7,6 +8,17 @@ describe('upsertFixedPrice()', () => { beforeAll(async() => { originalFixedPrice = await models.FixedPrice.findById(fixedPriceId); + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); }); it(`should toggle the hasMinPrice boolean if there's a minPrice and update the rest of the data`, async() => { diff --git a/modules/item/back/methods/item/specs/clone.spec.js b/modules/item/back/methods/item/specs/clone.spec.js index 1f4a87ac1..01210677e 100644 --- a/modules/item/back/methods/item/specs/clone.spec.js +++ b/modules/item/back/methods/item/specs/clone.spec.js @@ -1,7 +1,21 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('item clone()', () => { let nextItemId; + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); beforeEach(async() => { let query = `SELECT i1.id + 1 as id FROM vn.item i1 diff --git a/modules/item/back/methods/item/specs/new.spec.js b/modules/item/back/methods/item/specs/new.spec.js index e34ab2cf5..a1c741649 100644 --- a/modules/item/back/methods/item/specs/new.spec.js +++ b/modules/item/back/methods/item/specs/new.spec.js @@ -1,6 +1,21 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('item new()', () => { + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + it('should create a new item, adding the name as a tag', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; diff --git a/modules/item/back/methods/item/specs/regularize.spec.js b/modules/item/back/methods/item/specs/regularize.spec.js index ea0cdfa5a..e7df9a003 100644 --- a/modules/item/back/methods/item/specs/regularize.spec.js +++ b/modules/item/back/methods/item/specs/regularize.spec.js @@ -1,6 +1,21 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('regularize()', () => { + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 18}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + it('should create a new ticket and add a line', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; diff --git a/modules/route/back/methods/route/specs/clone.spec.js b/modules/route/back/methods/route/specs/clone.spec.js index 9192854f8..496ae1c89 100644 --- a/modules/route/back/methods/route/specs/clone.spec.js +++ b/modules/route/back/methods/route/specs/clone.spec.js @@ -1,6 +1,22 @@ const app = require('vn-loopback/server/server'); +const LoopBackContext = require('loopback-context'); describe('route clone()', () => { + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + const createdDate = Date.vnNew(); it('should throw an error if the amount of ids pased to the clone function do no match the database', async() => { const ids = [996, 997, 998, 999]; diff --git a/modules/route/back/methods/route/specs/updateWorkCenter.spec.js b/modules/route/back/methods/route/specs/updateWorkCenter.spec.js index 5328dc240..baa63f226 100644 --- a/modules/route/back/methods/route/specs/updateWorkCenter.spec.js +++ b/modules/route/back/methods/route/specs/updateWorkCenter.spec.js @@ -1,6 +1,20 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('route updateWorkCenter()', () => { + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); const routeId = 1; it('should set the commission work center if the worker has workCenter', async() => { diff --git a/modules/ticket/back/methods/sale/specs/canEdit.spec.js b/modules/ticket/back/methods/sale/specs/canEdit.spec.js index a6c299321..62f98421a 100644 --- a/modules/ticket/back/methods/sale/specs/canEdit.spec.js +++ b/modules/ticket/back/methods/sale/specs/canEdit.spec.js @@ -1,7 +1,21 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('sale canEdit()', () => { const employeeId = 1; + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); describe('sale editTracked', () => { it('should return true if the role is production regardless of the saleTrackings', async() => { diff --git a/modules/ticket/back/methods/sale/specs/deleteSales.spec.js b/modules/ticket/back/methods/sale/specs/deleteSales.spec.js index 82cf916b3..3d3e06e22 100644 --- a/modules/ticket/back/methods/sale/specs/deleteSales.spec.js +++ b/modules/ticket/back/methods/sale/specs/deleteSales.spec.js @@ -1,6 +1,21 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('sale deleteSales()', () => { + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + it('should throw an error if the ticket of the given sales is not editable', async() => { const tx = await models.Sale.beginTransaction({}); diff --git a/modules/ticket/back/methods/sale/specs/reserve.spec.js b/modules/ticket/back/methods/sale/specs/reserve.spec.js index 7ab79f9c0..259cb8cd5 100644 --- a/modules/ticket/back/methods/sale/specs/reserve.spec.js +++ b/modules/ticket/back/methods/sale/specs/reserve.spec.js @@ -1,4 +1,5 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('sale reserve()', () => { const ctx = { @@ -9,6 +10,20 @@ describe('sale reserve()', () => { } }; + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + it('should throw an error if the ticket can not be modified', async() => { const tx = await models.Sale.beginTransaction({}); diff --git a/modules/ticket/back/methods/sale/specs/updateConcept.spec.js b/modules/ticket/back/methods/sale/specs/updateConcept.spec.js index 0e7e9bf0f..1b42e7140 100644 --- a/modules/ticket/back/methods/sale/specs/updateConcept.spec.js +++ b/modules/ticket/back/methods/sale/specs/updateConcept.spec.js @@ -1,6 +1,21 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('sale updateConcept()', () => { + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + const ctx = {req: {accessToken: {userId: 9}}}; const saleId = 25; diff --git a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js index 51cd2403f..133be8de3 100644 --- a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js +++ b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js @@ -1,6 +1,21 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('sale updatePrice()', () => { + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 18}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + const ctx = { req: { accessToken: {userId: 18}, diff --git a/modules/ticket/back/methods/sale/specs/updateQuantity.spec.js b/modules/ticket/back/methods/sale/specs/updateQuantity.spec.js index 53a05cd7e..4778f6b6d 100644 --- a/modules/ticket/back/methods/sale/specs/updateQuantity.spec.js +++ b/modules/ticket/back/methods/sale/specs/updateQuantity.spec.js @@ -1,6 +1,21 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('sale updateQuantity()', () => { + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + const ctx = { req: { accessToken: {userId: 9}, diff --git a/modules/ticket/back/methods/ticket/specs/addSale.spec.js b/modules/ticket/back/methods/ticket/specs/addSale.spec.js index cfd149511..2e568716a 100644 --- a/modules/ticket/back/methods/ticket/specs/addSale.spec.js +++ b/modules/ticket/back/methods/ticket/specs/addSale.spec.js @@ -1,7 +1,21 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('ticket addSale()', () => { const ticketId = 13; + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); it('should create a new sale for the ticket with id 13', async() => { const tx = await models.Ticket.beginTransaction({}); diff --git a/modules/ticket/back/methods/ticket/specs/merge.spec.js b/modules/ticket/back/methods/ticket/specs/merge.spec.js index 78eb0c8f3..3254e58a8 100644 --- a/modules/ticket/back/methods/ticket/specs/merge.spec.js +++ b/modules/ticket/back/methods/ticket/specs/merge.spec.js @@ -10,11 +10,15 @@ describe('ticket merge()', () => { workerFk: 1 }; - const activeCtx = { - accessToken: {userId: 9}, - }; - - beforeEach(() => { + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ active: activeCtx }); @@ -35,16 +39,16 @@ describe('ticket merge()', () => { try { const options = {transaction: tx}; - const chatNotificationBeforeMerge = await models.Chat.find(); + const chatNotificationBeforeMerge = await models.Chat.find(null, options); await models.Ticket.merge(ctx, [tickets], options); - const createdTicketLog = await models.TicketLog.find({where: {originFk: tickets.originId}}, options); + const createdTicketLog = await models.TicketLog.find({where: {originFk: tickets.destinationId}}, options); const deletedTicket = await models.Ticket.findOne({where: {id: tickets.originId}}, options); const salesTicketFuture = await models.Sale.find({where: {ticketFk: tickets.destinationId}}, options); - const chatNotificationAfterMerge = await models.Chat.find(); + const chatNotificationAfterMerge = await models.Chat.find(null, options); - expect(createdTicketLog.length).toEqual(2); + expect(createdTicketLog.length).toEqual(1); expect(deletedTicket.isDeleted).toEqual(true); expect(salesTicketFuture.length).toEqual(2); expect(chatNotificationBeforeMerge.length).toEqual(chatNotificationAfterMerge.length - 2); diff --git a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js index 1f6712087..41de1fd6e 100644 --- a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js +++ b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js @@ -1,6 +1,20 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('sale updateDiscount()', () => { + beforeAll(async() => { + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); const originalSaleId = 8; it('should throw an error if no sales were selected', async() => { From 805df64bb27f6c67c562bd8837934b5f838a58a1 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 23 Mar 2023 10:54:04 +0100 Subject: [PATCH 11/13] fallo cantidad reclamados --- .../claim/back/methods/claim-state/isEditable.js | 16 ++++++++-------- modules/claim/front/detail/index.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/claim/back/methods/claim-state/isEditable.js b/modules/claim/back/methods/claim-state/isEditable.js index 2d0a8dc44..ad51d543a 100644 --- a/modules/claim/back/methods/claim-state/isEditable.js +++ b/modules/claim/back/methods/claim-state/isEditable.js @@ -26,13 +26,13 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - - const state = await models.ClaimState.findById(id, { - include: { - relation: 'writeRole' - } - }, myOptions); - const roleWithGrants = state && state.writeRole().name; - return await models.Account.hasRole(userId, roleWithGrants, myOptions); + + const state = await models.ClaimState.findById(id, { + include: { + relation: 'writeRole' + } + }, myOptions); + const roleWithGrants = state && state.writeRole().name; + return await models.Account.hasRole(userId, roleWithGrants, myOptions); }; }; diff --git a/modules/claim/front/detail/index.js b/modules/claim/front/detail/index.js index 833519579..56f39e074 100644 --- a/modules/claim/front/detail/index.js +++ b/modules/claim/front/detail/index.js @@ -151,7 +151,7 @@ class Controller extends Section { isClaimEditable() { if (!this.claim) return; - this.$http.get(`ClaimStates/${this.claim.id}/isEditable`).then(res => { + this.$http.get(`ClaimStates/${this.claim.claimStateFk}/isEditable`).then(res => { this.isRewritable = res.data; }); } From 4762f3b54f67c272229a8b51febb9e2b9724e4ac Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 23 Mar 2023 13:33:14 +0100 Subject: [PATCH 12/13] fix(deliveryNote): ticket without delivery address --- .../reports/delivery-note/delivery-note.html | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html index eb133c0cd..0be5a30f0 100644 --- a/print/templates/reports/delivery-note/delivery-note.html +++ b/print/templates/reports/delivery-note/delivery-note.html @@ -33,7 +33,7 @@
{{$t('deliveryAddress')}}
-
+

{{address.nickname}}

{{address.street}}
{{address.postalCode}}, {{address.city}} ({{address.province}})
@@ -245,13 +245,8 @@
- + \ No newline at end of file From a45308c6a5bb53a94bd6943ddb9f2511f8a62c0b Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 24 Mar 2023 07:58:27 +0100 Subject: [PATCH 13/13] refs #5342 fix: testFront --- modules/claim/front/detail/index.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/claim/front/detail/index.spec.js b/modules/claim/front/detail/index.spec.js index 8f3049339..1ef779fd7 100644 --- a/modules/claim/front/detail/index.spec.js +++ b/modules/claim/front/detail/index.spec.js @@ -22,7 +22,8 @@ describe('claim', () => { controller = $componentController('vnClaimDetail', {$element, $scope}); controller.claim = { ticketFk: 1, - id: 2} + id: 2, + claimStateFk: 2} ; controller.salesToClaim = [{saleFk: 1}, {saleFk: 2}]; controller.salesClaimed = [{id: 1, sale: {}}];