diff --git a/db/changes/10360-september/00-ACL.sql b/db/changes/10360-september/00-ACL.sql new file mode 100644 index 0000000000..6a3fcf708e --- /dev/null +++ b/db/changes/10360-september/00-ACL.sql @@ -0,0 +1,4 @@ +DELETE FROM `salix`.`ACL` WHERE id = 48; +DELETE FROM `salix`.`ACL` WHERE id = 49; +DELETE FROM `salix`.`ACL` WHERE id = 50; +DELETE FROM `salix`.`ACL` WHERE id = 107; \ No newline at end of file diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index c4402b2eed..bc18f88854 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -323,7 +323,6 @@ export default { idCheckbox: '.vn-popover.shown vn-horizontal:nth-child(1) > vn-check', stemsCheckbox: '.vn-popover.shown vn-horizontal:nth-child(2) > vn-check', sizeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check', - nicheCheckbox: '.vn-popover.shown vn-horizontal:nth-child(4) > vn-check', typeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(5) > vn-check', categoryCheckbox: '.vn-popover.shown vn-horizontal:nth-child(6) > vn-check', intrastadCheckbox: '.vn-popover.shown vn-horizontal:nth-child(7) > vn-check', @@ -420,17 +419,6 @@ export default { submitBarcodesButton: 'vn-item-barcode button[type=submit]', firstCodeRemoveButton: 'vn-item-barcode vn-horizontal:nth-child(1) vn-icon[icon="delete"]' }, - itemNiches: { - addNicheButton: 'vn-item-niche vn-icon[icon="add_circle"]', - firstWarehouse: 'vn-item-niche vn-autocomplete[ng-model="niche.warehouseFk"]', - firstCode: 'vn-item-niche vn-horizontal:nth-child(1) vn-textfield[ng-model="niche.code"]', - secondWarehouse: 'vn-item-niche vn-horizontal:nth-child(2) > vn-autocomplete[ng-model="niche.warehouseFk"]', - secondCode: 'vn-item-niche vn-horizontal:nth-child(2) vn-textfield[ng-model="niche.code"]', - secondNicheRemoveButton: 'vn-item-niche vn-horizontal:nth-child(2) > vn-none > vn-icon-button[icon="delete"]', - thirdWarehouse: 'vn-item-niche vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="niche.warehouseFk"]', - thirdCode: 'vn-item-niche vn-horizontal:nth-child(3) vn-textfield[ng-model="niche.code"]', - submitNichesButton: 'vn-item-niche button[type=submit]' - }, itemBotanical: { genus: 'vn-item-botanical vn-autocomplete[ng-model="$ctrl.botanical.genusFk"]', species: 'vn-item-botanical vn-autocomplete[ng-model="$ctrl.botanical.specieFk"]', @@ -440,7 +428,6 @@ export default { basicData: 'vn-item-summary [name="basicData"]', vat: 'vn-item-summary [name="tax"]', tags: 'vn-item-summary [name="tags"]', - niche: 'vn-item-summary [name="niche"]', botanical: 'vn-item-summary [name="botanical"]', barcode: 'vn-item-summary [name="barcode"]' }, diff --git a/e2e/paths/04-item/01_summary.spec.js b/e2e/paths/04-item/01_summary.spec.js index d6f784be85..a7526accb5 100644 --- a/e2e/paths/04-item/01_summary.spec.js +++ b/e2e/paths/04-item/01_summary.spec.js @@ -40,13 +40,6 @@ describe('Item summary path', () => { expect(result).toContain('Brown'); }); - it(`should check the item summary preview shows fields from niche`, async() => { - await page.waitForTextInElement(selectors.itemSummary.niche, 'A1'); - const result = await page.waitToGetProperty(selectors.itemSummary.niche, 'innerText'); - - expect(result).toContain('A1'); - }); - it(`should check the item summary preview shows fields from botanical`, async() => { await page.waitForTextInElement(selectors.itemSummary.botanical, 'Abelia'); const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText'); @@ -126,12 +119,6 @@ describe('Item summary path', () => { expect(result).toContain('Silver'); }); - it(`should check the item summary shows fields from niches section`, async() => { - const result = await page.waitToGetProperty(selectors.itemSummary.niche, 'innerText'); - - expect(result).toContain('One A4'); - }); - it(`should check the item summary shows fields from botanical section`, async() => { const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText'); diff --git a/e2e/paths/04-item/06_botanical.spec.js b/e2e/paths/04-item/05_botanical.spec.js similarity index 100% rename from e2e/paths/04-item/06_botanical.spec.js rename to e2e/paths/04-item/05_botanical.spec.js diff --git a/e2e/paths/04-item/05_niche.spec.js b/e2e/paths/04-item/05_niche.spec.js deleted file mode 100644 index e3d1d70be9..0000000000 --- a/e2e/paths/04-item/05_niche.spec.js +++ /dev/null @@ -1,66 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item create niche path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'item'); - await page.accessToSearchResult('Ranged weapon longbow 2m'); - await page.accessToSection('item.card.niche'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should click create a new niche and delete a former one`, async() => { - await page.waitForTextInField(selectors.itemNiches.firstWarehouse, 'Warehouse One'); - await page.waitToClick(selectors.itemNiches.addNicheButton); - await page.waitToClick(selectors.itemNiches.secondNicheRemoveButton); - await page.autocompleteSearch(selectors.itemNiches.thirdWarehouse, 'Warehouse Two'); - await page.write(selectors.itemNiches.thirdCode, 'A44'); - await page.waitToClick(selectors.itemNiches.submitNichesButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the first niche is the expected one`, async() => { - await page.reloadSection('item.card.niche'); - await page.waitForTextInField(selectors.itemNiches.firstWarehouse, 'Warehouse One'); - let result = await page - .waitToGetProperty(selectors.itemNiches.firstWarehouse, 'value'); - - expect(result).toEqual('Warehouse One'); - - result = await page - .waitToGetProperty(selectors.itemNiches.firstCode, 'value'); - - expect(result).toEqual('A11'); - }); - - it(`should confirm the second niche is the expected one`, async() => { - let result = await page - .waitToGetProperty(selectors.itemNiches.secondWarehouse, 'value'); - - expect(result).toEqual('Warehouse Three'); - result = await page - .waitToGetProperty(selectors.itemNiches.secondCode, 'value'); - - expect(result).toEqual('A33'); - }); - - it(`should confirm the third niche is the expected one`, async() => { - let result = await page - .waitToGetProperty(selectors.itemNiches.thirdWarehouse, 'value'); - - expect(result).toEqual('Warehouse Two'); - result = await page - .waitToGetProperty(selectors.itemNiches.thirdCode, 'value'); - - expect(result).toEqual('A44'); - }); -}); diff --git a/e2e/paths/04-item/07_barcode.spec.js b/e2e/paths/04-item/06_barcode.spec.js similarity index 100% rename from e2e/paths/04-item/07_barcode.spec.js rename to e2e/paths/04-item/06_barcode.spec.js diff --git a/e2e/paths/04-item/08_create_and_clone.spec.js b/e2e/paths/04-item/07_create_and_clone.spec.js similarity index 100% rename from e2e/paths/04-item/08_create_and_clone.spec.js rename to e2e/paths/04-item/07_create_and_clone.spec.js diff --git a/e2e/paths/04-item/09_regularize.spec.js b/e2e/paths/04-item/08_regularize.spec.js similarity index 100% rename from e2e/paths/04-item/09_regularize.spec.js rename to e2e/paths/04-item/08_regularize.spec.js diff --git a/e2e/paths/04-item/10_index.spec.js b/e2e/paths/04-item/09_index.spec.js similarity index 96% rename from e2e/paths/04-item/10_index.spec.js rename to e2e/paths/04-item/09_index.spec.js index 3d7ab16327..262627e996 100644 --- a/e2e/paths/04-item/10_index.spec.js +++ b/e2e/paths/04-item/09_index.spec.js @@ -26,7 +26,6 @@ describe('Item index path', () => { await page.waitToClick(selectors.itemsIndex.idCheckbox); await page.waitToClick(selectors.itemsIndex.stemsCheckbox); await page.waitToClick(selectors.itemsIndex.sizeCheckbox); - await page.waitToClick(selectors.itemsIndex.nicheCheckbox); await page.waitToClick(selectors.itemsIndex.typeCheckbox); await page.waitToClick(selectors.itemsIndex.categoryCheckbox); await page.waitToClick(selectors.itemsIndex.intrastadCheckbox); @@ -59,7 +58,6 @@ describe('Item index path', () => { await page.waitToClick(selectors.itemsIndex.idCheckbox); await page.waitToClick(selectors.itemsIndex.stemsCheckbox); await page.waitToClick(selectors.itemsIndex.sizeCheckbox); - await page.waitToClick(selectors.itemsIndex.nicheCheckbox); await page.waitToClick(selectors.itemsIndex.typeCheckbox); await page.waitToClick(selectors.itemsIndex.categoryCheckbox); await page.waitToClick(selectors.itemsIndex.intrastadCheckbox); diff --git a/e2e/paths/04-item/11_item_log.spec.js b/e2e/paths/04-item/10_item_log.spec.js similarity index 100% rename from e2e/paths/04-item/11_item_log.spec.js rename to e2e/paths/04-item/10_item_log.spec.js diff --git a/e2e/paths/04-item/12_descriptor.spec.js b/e2e/paths/04-item/11_descriptor.spec.js similarity index 100% rename from e2e/paths/04-item/12_descriptor.spec.js rename to e2e/paths/04-item/11_descriptor.spec.js diff --git a/e2e/paths/04-item/13_request.spec.js b/e2e/paths/04-item/12_request.spec.js similarity index 100% rename from e2e/paths/04-item/13_request.spec.js rename to e2e/paths/04-item/12_request.spec.js diff --git a/e2e/paths/04-item/14_fixedPrice.spec.js b/e2e/paths/04-item/13_fixedPrice.spec.js similarity index 100% rename from e2e/paths/04-item/14_fixedPrice.spec.js rename to e2e/paths/04-item/13_fixedPrice.spec.js diff --git a/front/core/styles/icons/salixfont.css b/front/core/styles/icons/salixfont.css index 0a036b3d0f..d6466a0ebd 100644 --- a/front/core/styles/icons/salixfont.css +++ b/front/core/styles/icons/salixfont.css @@ -239,9 +239,6 @@ .icon-mandatory:before { content: "\e921"; } -.icon-niche:before { - content: "\e922"; -} .icon-no036:before { content: "\e923"; } diff --git a/front/core/styles/icons/salixfont.svg b/front/core/styles/icons/salixfont.svg index 83b9ad33a6..7ff0f037d9 100644 --- a/front/core/styles/icons/salixfont.svg +++ b/front/core/styles/icons/salixfont.svg @@ -41,7 +41,6 @@ - diff --git a/loopback/common/methods/vn-model/specs/rewriteDbError.spec.js b/loopback/common/methods/vn-model/specs/rewriteDbError.spec.js index 5319b185a4..e2f842a15d 100644 --- a/loopback/common/methods/vn-model/specs/rewriteDbError.spec.js +++ b/loopback/common/methods/vn-model/specs/rewriteDbError.spec.js @@ -1,19 +1,29 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('Model rewriteDbError()', () => { it('should extend rewriteDbError properties to any model passed', () => { - let exampleModel = app.models.ItemNiche; + const exampleModel = models.ItemTag; expect(exampleModel.rewriteDbError).toBeDefined(); }); it('should handle a duplicated warehouse error', async() => { - let itemNiche = {itemFk: 1, warehouseFK: 1, code: 'A11'}; + const tx = await models.Ticket.beginTransaction({}); + let error; - await app.models.ItemNiche.create(itemNiche).catch(e => { + + try { + const options = {transaction: tx}; + + const itemTag = {itemFk: 1, tagFk: 56, value: 'Ranged weapon', priority: 1}; + await models.ItemTag.create(itemTag, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); error = e; - }).finally(() => { - expect(error.message).toEqual(`The warehouse can't be repeated`); - }); + } + + expect(error.message).toEqual(`The tag can't be repeated`); }); }); diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index a10eff7112..f06fd0db59 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -112,8 +112,6 @@ module.exports = Self => { return {'it.workerFk': value}; case 'origin': return {'ori.code': value}; - case 'niche': - return {'ip.code': value}; case 'intrastat': return {'intr.description': value}; } @@ -148,8 +146,7 @@ module.exports = Self => { ic.name AS category, intr.description AS intrastat, b.grouping, - b.packing, - ip.code AS niche, @visibleCalc + b.packing FROM item i LEFT JOIN itemType it ON it.id = i.typeFk LEFT JOIN itemCategory ic ON ic.id = it.categoryFk @@ -159,8 +156,7 @@ module.exports = Self => { LEFT JOIN producer pr ON pr.id = i.producerFk LEFT JOIN origin ori ON ori.id = i.originFk LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = it.warehouseFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN itemPlacement ip ON ip.itemFk = i.id AND ip.warehouseFk = it.warehouseFk` + LEFT JOIN vn.buy b ON b.id = lb.buy_id` ); if (ctx.args.tags) { diff --git a/modules/item/back/methods/item/getSummary.js b/modules/item/back/methods/item/getSummary.js index 6422d87ff4..ffcfc806ec 100644 --- a/modules/item/back/methods/item/getSummary.js +++ b/modules/item/back/methods/item/getSummary.js @@ -92,19 +92,11 @@ module.exports = Self => { }; promises.push(models.ItemBotanical.find(filter, myOptions)); - // Niches - filter = { - where: {itemFk: id}, - include: {relation: 'warehouse'} - }; - promises.push(models.ItemNiche.find(filter, myOptions)); - let res = await Promise.all(promises); summary.item = res[0]; summary.tags = res[1]; [summary.botanical] = res[2]; - summary.niches = res[3]; const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions); diff --git a/modules/item/back/methods/item/specs/getSummary.spec.js b/modules/item/back/methods/item/specs/getSummary.spec.js index a658b42896..eec737d11e 100644 --- a/modules/item/back/methods/item/specs/getSummary.spec.js +++ b/modules/item/back/methods/item/specs/getSummary.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('item getSummary()', () => { - it('should return summary with item, tags, botanical, niches, available and visible defined ', async() => { + it('should return summary with item, tags, botanical, available and visible defined ', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; @@ -14,7 +14,6 @@ describe('item getSummary()', () => { expect(keys).toContain('item'); expect(keys).toContain('tags'); expect(keys).toContain('botanical'); - expect(keys).toContain('niches'); expect(keys).toContain('available'); expect(keys).toContain('visible'); diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index ab680b6965..6e171e9b09 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -26,9 +26,6 @@ "ItemLog": { "dataSource": "vn" }, - "ItemNiche": { - "dataSource": "vn" - }, "ItemPlacement": { "dataSource": "vn" }, diff --git a/modules/item/back/models/item-niche.js b/modules/item/back/models/item-niche.js deleted file mode 100644 index b9e3888815..0000000000 --- a/modules/item/back/models/item-niche.js +++ /dev/null @@ -1,9 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.rewriteDbError(function(err) { - if (err.code === 'ER_DUP_ENTRY') - return new UserError(`The warehouse can't be repeated`); - return err; - }); -}; diff --git a/modules/item/back/models/item-niche.json b/modules/item/back/models/item-niche.json deleted file mode 100644 index 260eb07b90..0000000000 --- a/modules/item/back/models/item-niche.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "ItemNiche", - "base": "Loggable", - "log": { - "model": "ItemLog", - "relation": "item", - "showField": "code" - }, - "options": { - "mysql": { - "table": "itemPlacement" - } - }, - "properties": { - "id": { - "type": "Number", - "id": 1, - "description": "Identifier" - }, - "warehouseFk": { - "type": "Number", - "description": "Identifier" - }, - "code": { - "type": "String", - "required": true - } - }, - "relations": { - "item": { - "type": "belongsTo", - "model": "Item", - "foreignKey": "itemFk" - }, - "warehouse": { - "type": "belongsTo", - "model": "Warehouse", - "foreignKey": "warehouseFk", - "required": true - } - } -} diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index ee3f16fdd0..1c09ca4f4a 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -196,11 +196,6 @@ "model": "ItemTaxCountry", "foreignKey": "itemFk" }, - "itemNiche": { - "type": "hasMany", - "model": "ItemNiche", - "foreignKey": "itemFk" - }, "packaging": { "type": "hasOne", "model": "Packaging", diff --git a/modules/item/front/index.js b/modules/item/front/index.js index 8cb22ef40e..c328b1c8d8 100644 --- a/modules/item/front/index.js +++ b/modules/item/front/index.js @@ -16,7 +16,6 @@ import './log'; import './request'; import './request-search-panel'; import './last-entries'; -import './niche'; import './botanical'; import './barcode'; import './summary'; diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index bcebaee484..36ef4839a0 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -18,7 +18,6 @@ Description Stems Size - Niche Type Category Intrastat @@ -63,7 +62,6 @@ {{::item.stems}} {{::item.size}} - {{::item.niche}} {{::item.typeName}} diff --git a/modules/item/front/index/index.js b/modules/item/front/index/index.js index 175beb88a0..3235d684e4 100644 --- a/modules/item/front/index/index.js +++ b/modules/item/front/index/index.js @@ -23,8 +23,6 @@ class Controller extends Section { return {'b.packing': value}; case 'origin': return {'ori.code': value}; - case 'niche': - return {'ip.code': value}; case 'typeFk': return {'i.typeFk': value}; case 'intrastat': diff --git a/modules/item/front/locale/es.yml b/modules/item/front/locale/es.yml index 6166622e57..27348d41c8 100644 --- a/modules/item/front/locale/es.yml +++ b/modules/item/front/locale/es.yml @@ -30,8 +30,6 @@ New species: Nueva especie New genus: Nuevo genus Add tag: Añadir etiqueta Remove tag: Quitar etiqueta -Add niche: Añadir nicho -Remove niche: Quitar nicho Add barcode: Añadir código de barras Remove barcode: Quitar código de barras Buyer: Comprador @@ -56,7 +54,6 @@ Summary: Vista previa Basic data: Datos básicos Tax: IVA History: Historial -Niches: Nichos Botanical: Botánico Barcodes: Códigos de barras Diary: Histórico diff --git a/modules/item/front/niche/index.html b/modules/item/front/niche/index.html deleted file mode 100644 index 1c376b90e1..0000000000 --- a/modules/item/front/niche/index.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/item/front/niche/index.js b/modules/item/front/niche/index.js deleted file mode 100644 index 51621b7148..0000000000 --- a/modules/item/front/niche/index.js +++ /dev/null @@ -1,17 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - }); - } -} - -ngModule.vnComponent('vnItemNiche', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index f6b3bfe293..8f3e037469 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -15,7 +15,6 @@ {"state": "item.card.basicData", "icon": "settings"}, {"state": "item.card.tags", "icon": "icon-tags"}, {"state": "item.card.tax", "icon": "icon-tax"}, - {"state": "item.card.niche", "icon": "place"}, {"state": "item.card.botanical", "icon": "local_florist"}, {"state": "item.card.itemBarcode", "icon": "icon-barcode"}, {"state": "item.card.diary", "icon": "icon-transaction"}, @@ -79,16 +78,6 @@ "description": "Tax", "acl": ["administrative","buyer"] }, - { - "url" : "/niche", - "state": "item.card.niche", - "component": "vn-item-niche", - "description": "Niches", - "params": { - "item": "$ctrl.item" - }, - "acl": ["buyer","replenisher"] - }, { "url" : "/botanical", "state": "item.card.botanical", diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html index 90d51bb636..b5ea79efb5 100644 --- a/modules/item/front/summary/index.html +++ b/modules/item/front/summary/index.html @@ -138,24 +138,6 @@ value="{{tax.taxClass.description}}"> - -

- - Niche - -

-

- Niche -

- - -