From df9373adeda751f5431797d6e6f9d52be06e0c31 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 19 May 2021 14:14:04 +0200 Subject: [PATCH 1/5] e2e amends due to html changes on logs --- e2e/helpers/selectors.js | 7 +++---- e2e/paths/02-client/07_edit_web_access.spec.js | 4 ++-- e2e/paths/02-client/13_log.spec.js | 4 ++-- e2e/paths/05-ticket/02_expeditions_and_log.spec.js | 11 ++++------- e2e/paths/10-travel/01_create.spec.js | 2 ++ e2e/paths/13-supplier/02_basic_data.spec.js | 2 +- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 042528c92..69425a1b7 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -448,7 +448,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) > vn-td > vn-one:nth-child(3) > div span:nth-child(3)', + fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) > vn-td > vn-one:nth-child(3) > div span:nth-child(2)', }, ticketSummary: { header: 'vn-ticket-summary > vn-card > h5', @@ -630,10 +630,9 @@ export default { ticketLog: { firstTD: 'vn-ticket-log vn-table vn-td:nth-child(1)', logButton: 'vn-left-menu a[ui-sref="ticket.card.log"]', - changedBy: 'vn-ticket-log > vn-log vn-tr:nth-child(1) > vn-td:nth-child(2) > span', - actionTaken: 'vn-ticket-log > vn-log vn-td:nth-child(1) > div > div:nth-child(3) > span.value', + firstLogEntry: 'vn-ticket-log vn-data-viewer vn-tbody vn-tr', changes: 'vn-ticket-log vn-data-viewer vn-tbody > vn-tr > vn-td:nth-child(7)', - id: 'vn-ticket-log > vn-log vn-td.before > vn-one:nth-child(1) > div > span.value' + id: 'vn-ticket-log vn-tr:nth-child(1) vn-one:nth-child(1) span' }, ticketService: { addServiceButton: 'vn-ticket-service vn-icon-button[vn-tooltip="Add service"] > button', diff --git a/e2e/paths/02-client/07_edit_web_access.spec.js b/e2e/paths/02-client/07_edit_web_access.spec.js index 82a8bb843..b1af95638 100644 --- a/e2e/paths/02-client/07_edit_web_access.spec.js +++ b/e2e/paths/02-client/07_edit_web_access.spec.js @@ -50,7 +50,7 @@ describe('Client Edit web access path', () => { let lastModificationCurrentValue = await page .waitToGetProperty(selectors.clientLog.lastModificationCurrentValue, 'innerText'); - expect(lastModificationPreviousValue).toEqual('name: BruceBanner active: true'); - expect(lastModificationCurrentValue).toEqual('name: Hulk active: false'); + expect(lastModificationPreviousValue).toEqual('name BruceBanner active true'); + expect(lastModificationCurrentValue).toEqual('name Hulk active false'); }); }); diff --git a/e2e/paths/02-client/13_log.spec.js b/e2e/paths/02-client/13_log.spec.js index 1bb859e22..9b047a47c 100644 --- a/e2e/paths/02-client/13_log.spec.js +++ b/e2e/paths/02-client/13_log.spec.js @@ -43,7 +43,7 @@ describe('Client log path', () => { let lastModificationCurrentValue = await page. waitToGetProperty(selectors.clientLog.lastModificationCurrentValue, 'innerText'); - expect(lastModificationPreviousValue).toEqual('name: DavidCharlesHaller'); - expect(lastModificationCurrentValue).toEqual('name: this is a test'); + expect(lastModificationPreviousValue).toEqual('name DavidCharlesHaller'); + expect(lastModificationCurrentValue).toEqual('name this is a test'); }); }); diff --git a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js index e4f8a7754..0e6482c94 100644 --- a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js +++ b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js @@ -31,17 +31,14 @@ describe('Ticket expeditions and log path', () => { it(`should confirm the expedition deleted is shown now in the ticket log`, async() => { await page.accessToSection('ticket.card.log'); - const changedBy = await page - .waitToGetProperty(selectors.ticketLog.changedBy, 'innerText'); - - const actionTaken = await page - .waitToGetProperty(selectors.ticketLog.actionTaken, 'innerText'); + const firstLogEntry = await page + .waitToGetProperty(selectors.ticketLog.firstLogEntry, 'innerText'); const id = await page .waitToGetProperty(selectors.ticketLog.id, 'innerText'); - expect(changedBy).toEqual('production'); - expect(actionTaken).toEqual('Deletes'); + expect(firstLogEntry).toContain('production'); + expect(firstLogEntry).toContain('Deletes'); expect(id).toEqual('2'); }); }); diff --git a/e2e/paths/10-travel/01_create.spec.js b/e2e/paths/10-travel/01_create.spec.js index 65540d433..6f5956377 100644 --- a/e2e/paths/10-travel/01_create.spec.js +++ b/e2e/paths/10-travel/01_create.spec.js @@ -35,6 +35,8 @@ describe('Travel create path', () => { }); it('should check the user was redirected to the travel basic data upon creation', async() => { + // backup code for further intermitences still on track. + // await page.screenshot({path: 'e2e/paths/10-travel/error.jpeg', type: 'jpeg'}); await page.waitForState('travel.card.basicData'); }); diff --git a/e2e/paths/13-supplier/02_basic_data.spec.js b/e2e/paths/13-supplier/02_basic_data.spec.js index 319130b98..2bc94402b 100644 --- a/e2e/paths/13-supplier/02_basic_data.spec.js +++ b/e2e/paths/13-supplier/02_basic_data.spec.js @@ -65,6 +65,6 @@ describe('Supplier basic data path', () => { it('should check the changes have been recorded', async() => { const result = await page.waitToGetProperty('#newInstance:nth-child(3)', 'innerText'); - expect(result).toEqual('note: Some notes'); + expect(result).toEqual('note Some notes'); }); }); -- 2.40.1 From 72a0b774de8c32f4e90b04252d569c64d8bd3ab0 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 19 May 2021 14:15:28 +0200 Subject: [PATCH 2/5] add and get sales now sets item.price from packaging for EMB items --- db/dump/fixtures.sql | 36 +++++++++---------- modules/item/back/models/item.json | 9 +++++ modules/ticket/back/methods/ticket/addSale.js | 19 ++++++++-- .../ticket/back/methods/ticket/getSales.js | 14 ++++++-- 4 files changed, 55 insertions(+), 23 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 55d962330..59c2f18fb 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -774,25 +774,25 @@ INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) (05080000, 'Coral y materiales similares', 2, 2), (06021010, 'Plantas vivas: Esqueje/injerto, Vid', 1, 1); -INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `isOnOffer`, `expenceFk`, `isBargain`, `comment`, `relevancy`, `image`, `taxClassFk`, `subName`, `minPrice`, `stars`) +INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `isOnOffer`, `expenceFk`, `isBargain`, `comment`, `relevancy`, `image`, `taxClassFk`, `subName`, `minPrice`, `stars`, `family`) VALUES - (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '1', 1, NULL, 0, 1), - (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '2', 1, NULL, 0, 2), - (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 0, 4751000000, 0, NULL, 0, '3', 1, NULL, 0, 5), - (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 1, 4751000000, 0, NULL, 0, '4', 2, NULL, 0, 3), - (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 1, 4751000000, 0, NULL, 0, '5', 2, NULL, 0, 3), - (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '6', 2, NULL, 0, 4), - (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '7', 2, NULL, 0, 4), - (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '8', 1, NULL, 0, 5), - (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '9', 1, NULL, 0, 4), - (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 0, 4751000000, 0, NULL, 0, '10', 1, NULL, 0, 4), - (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 1, 4751000000, 0, NULL, 0, '11', 2, NULL, 0, 4), - (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 1, 4751000000, 0, NULL, 0, '12', 2, NULL, 0, 3), - (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '13', 2, NULL, 0, 2), - (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 4), - (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 0), - (16, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 0), - (71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 0); + (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '1', 1, NULL, 0, 1, 'VT'), + (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '2', 1, NULL, 0, 2, 'VT'), + (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 0, 4751000000, 0, NULL, 0, '3', 1, NULL, 0, 5, 'VT'), + (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 1, 4751000000, 0, NULL, 0, '4', 2, NULL, 0, 3, 'VT'), + (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 1, 4751000000, 0, NULL, 0, '5', 2, NULL, 0, 3, 'VT'), + (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '6', 2, NULL, 0, 4, 'VT'), + (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '7', 2, NULL, 0, 4, 'VT'), + (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '8', 1, NULL, 0, 5, 'VT'), + (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '9', 1, NULL, 0, 4, 'VT'), + (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 0, 4751000000, 0, NULL, 0, '10', 1, NULL, 0, 4, 'VT'), + (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 1, 4751000000, 0, NULL, 0, '11', 2, NULL, 0, 4, 'VT'), + (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 1, 4751000000, 0, NULL, 0, '12', 2, NULL, 0, 3, 'VT'), + (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '13', 2, NULL, 0, 2, 'VT'), + (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 4, 'VT'), + (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 0, 'EMB'), + (16, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 0, 'VT'), + (71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 0, 'VT'); INSERT INTO `vn`.`priceFixed`(`id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3`, `started`, `ended`, `bonus`, `warehouseFk`, `created`) VALUES diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index 4bef1c5f0..0091ac888 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -124,6 +124,10 @@ "type": "boolean", "description": "Price per Kg" }, + "family": { + "type": "string", + "description": "The item family" + }, "expenseFk": { "type": "number", "mysql": { @@ -190,6 +194,11 @@ "type": "hasMany", "model": "ItemNiche", "foreignKey": "itemFk" + }, + "packaging": { + "type": "hasOne", + "model": "Packaging", + "foreignKey": "itemFk" } }, "scope": { diff --git a/modules/ticket/back/methods/ticket/addSale.js b/modules/ticket/back/methods/ticket/addSale.js index c48b04e92..4124340a6 100644 --- a/modules/ticket/back/methods/ticket/addSale.js +++ b/modules/ticket/back/methods/ticket/addSale.js @@ -44,7 +44,8 @@ module.exports = Self => { const res = await models.Item.getVisibleAvailable(itemId, ticket.warehouseFk, ticket.shipped); - if (res.available < quantity) + const whitelitedFamily = item.family == 'EMB'; + if (!whitelitedFamily && res.available < quantity) throw new UserError(`This item is not available`); const newSale = await models.Sale.create({ @@ -56,10 +57,22 @@ module.exports = Self => { await Self.rawSql('CALL vn.sale_calculateComponent(?, NULL)', [newSale.id]); - return models.Sale.findById(newSale.id, { + const sale = await models.Sale.findById(newSale.id, { include: { - relation: 'item' + relation: 'item', + scope: { + include: { + relation: 'packaging', + scope: { + fields: ['id', 'price'] + } + } + } } }); + + if (whitelitedFamily) sale.price = sale.item().packaging().price; + + return sale; }; }; diff --git a/modules/ticket/back/methods/ticket/getSales.js b/modules/ticket/back/methods/ticket/getSales.js index b59d678f2..66f5eaa3c 100644 --- a/modules/ticket/back/methods/ticket/getSales.js +++ b/modules/ticket/back/methods/ticket/getSales.js @@ -31,8 +31,14 @@ module.exports = Self => { } let filter = { - fields: ['id', 'name', 'tag5', 'value5', 'tag6', 'value6', 'tag7', 'value7', 'tag8', 'value8', 'tag9', 'value9', 'tag10', 'value10'], - where: {id: {inq: ids}} + where: {id: {inq: ids}}, + fields: ['id', 'name', 'family', 'tag5', 'value5', 'tag6', 'value6', 'tag7', 'value7', 'tag8', 'value8', 'tag9', 'value9', 'tag10', 'value10'], + include: { + relation: 'packaging', + scope: { + fields: ['id', 'price'] + } + } }; let items = await Self.app.models.Item.find(filter); @@ -52,6 +58,10 @@ module.exports = Self => { for (line of lines) { line.item = map[line.itemFk]; + + const embItem = line.item.family == 'EMB'; + if (embItem) line.price = line.item.packaging().price; + line.claim = claimMap[line.id]; } return lines; -- 2.40.1 From 5eb0ab82963bb958c2776f5ef8fa9847f65d1954 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 19 May 2021 15:25:49 +0200 Subject: [PATCH 3/5] add and edit sales no longer intervene the prices --- db/dump/fixtures.sql | 4 +-- modules/ticket/back/methods/ticket/addSale.js | 6 ++-- .../ticket/back/methods/ticket/getSales.js | 28 +++++++++++-------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 59c2f18fb..2906dce6c 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1205,8 +1205,8 @@ INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`) (96, 14, 1, 'White', 5), (97, 14, 67, 'supply', 6), (98, 14, 23, '1', 7), - (99, 15, 92, 'Shipping cost', 2), - (100, 16, 92, 'Shipping cost', 2), + (99, 15, 92, 'Trolley', 2), + (100, 16, 92, 'Pallet', 2), (101, 71, 92, 'Shipping cost', 2); INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`) diff --git a/modules/ticket/back/methods/ticket/addSale.js b/modules/ticket/back/methods/ticket/addSale.js index 4124340a6..51569acbc 100644 --- a/modules/ticket/back/methods/ticket/addSale.js +++ b/modules/ticket/back/methods/ticket/addSale.js @@ -44,8 +44,8 @@ module.exports = Self => { const res = await models.Item.getVisibleAvailable(itemId, ticket.warehouseFk, ticket.shipped); - const whitelitedFamily = item.family == 'EMB'; - if (!whitelitedFamily && res.available < quantity) + const packagingFamily = item.family == 'EMB'; + if (!packagingFamily && res.available < quantity) throw new UserError(`This item is not available`); const newSale = await models.Sale.create({ @@ -71,8 +71,6 @@ module.exports = Self => { } }); - if (whitelitedFamily) sale.price = sale.item().packaging().price; - return sale; }; }; diff --git a/modules/ticket/back/methods/ticket/getSales.js b/modules/ticket/back/methods/ticket/getSales.js index 66f5eaa3c..d522ffe98 100644 --- a/modules/ticket/back/methods/ticket/getSales.js +++ b/modules/ticket/back/methods/ticket/getSales.js @@ -31,14 +31,22 @@ module.exports = Self => { } let filter = { - where: {id: {inq: ids}}, - fields: ['id', 'name', 'family', 'tag5', 'value5', 'tag6', 'value6', 'tag7', 'value7', 'tag8', 'value8', 'tag9', 'value9', 'tag10', 'value10'], - include: { - relation: 'packaging', - scope: { - fields: ['id', 'price'] - } - } + fields: [ + 'id', + 'name', + 'tag5', + 'value5', + 'tag6', + 'value6', + 'tag7', + 'value7', + 'tag8', + 'value8', + 'tag9', + 'value9', + 'tag10', + 'value10'], + where: {id: {inq: ids}} }; let items = await Self.app.models.Item.find(filter); @@ -58,10 +66,6 @@ module.exports = Self => { for (line of lines) { line.item = map[line.itemFk]; - - const embItem = line.item.family == 'EMB'; - if (embItem) line.price = line.item.packaging().price; - line.claim = claimMap[line.id]; } return lines; -- 2.40.1 From 2494af01136fc4b337ebaae3197df4462de7e730 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 19 May 2021 15:33:35 +0200 Subject: [PATCH 4/5] removed unused relation from item @addSale --- modules/ticket/back/methods/ticket/addSale.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/modules/ticket/back/methods/ticket/addSale.js b/modules/ticket/back/methods/ticket/addSale.js index 51569acbc..365355df2 100644 --- a/modules/ticket/back/methods/ticket/addSale.js +++ b/modules/ticket/back/methods/ticket/addSale.js @@ -44,8 +44,8 @@ module.exports = Self => { const res = await models.Item.getVisibleAvailable(itemId, ticket.warehouseFk, ticket.shipped); - const packagingFamily = item.family == 'EMB'; - if (!packagingFamily && res.available < quantity) + const isPackaging = item.family == 'EMB'; + if (!isPackaging && res.available < quantity) throw new UserError(`This item is not available`); const newSale = await models.Sale.create({ @@ -59,15 +59,7 @@ module.exports = Self => { const sale = await models.Sale.findById(newSale.id, { include: { - relation: 'item', - scope: { - include: { - relation: 'packaging', - scope: { - fields: ['id', 'price'] - } - } - } + relation: 'item' } }); -- 2.40.1 From c16c93a75a3c66ecb5c865ab33a5ee339ef79ca8 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 19 May 2021 15:34:17 +0200 Subject: [PATCH 5/5] updated fixtures for item --- db/dump/fixtures.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 2906dce6c..f34386676 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -791,7 +791,7 @@ INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `d (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '13', 2, NULL, 0, 2, 'VT'), (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 4, 'VT'), (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 0, 'EMB'), - (16, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 0, 'VT'), + (16, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 0, 'EMB'), (71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, '', 2, NULL, 0, 0, 'VT'); INSERT INTO `vn`.`priceFixed`(`id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3`, `started`, `ended`, `bonus`, `warehouseFk`, `created`) -- 2.40.1