From 33f1ed360b7dc91ec7e5c453e6b693edf3d69aef Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 23 May 2024 12:16:12 +0200 Subject: [PATCH 01/92] refactor: refs #7457 Added from param if not exists --- modules/order/back/methods/order/filter.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 592ed11e6..d22fa0804 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -96,9 +96,18 @@ module.exports = Self => { teamMembersId.push(userId); } - if (args && args.myTeam) + if (args?.myTeam) args.teamIds = teamIds; + if (args?.to) + args.to.setHours(23, 59, 0, 0); + + if (!args.from) { + const yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + args.from = yesterday.toISOString().split('T')[0]; + } + const where = buildFilter(args, (param, value) => { switch (param) { case 'search': @@ -194,7 +203,7 @@ module.exports = Self => { `); stmt.merge(conn.makeWhere(filter.where)); - stmt.merge(`GROUP BY id`); + stmt.merge(`GROUP BY o.id`); stmt.merge(conn.makePagination(filter)); stmts.push(stmt); stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`); From 155597bf857c1c61c49d35449d803fed519f7d8f Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 2 Sep 2024 13:36:03 +0200 Subject: [PATCH 02/92] fix: refs #7283 remove --- e2e/paths/04-item/01_summary.spec.js | 133 -------- e2e/paths/04-item/02_basic_data.spec.js | 64 ---- e2e/paths/04-item/03_tax.spec.js | 48 --- e2e/paths/04-item/04_tags.spec.js | 79 ----- e2e/paths/04-item/05_botanical.spec.js | 66 ---- e2e/paths/04-item/06_barcode.spec.js | 37 -- e2e/paths/04-item/07_create.spec.js | 65 ---- e2e/paths/04-item/08_regularize.spec.js | 141 -------- e2e/paths/04-item/09_index.spec.js | 84 ----- e2e/paths/04-item/10_item_log.spec.js | 45 --- e2e/paths/04-item/11_descriptor.spec.js | 41 --- e2e/paths/04-item/12_request.spec.js | 45 --- e2e/paths/04-item/13_fixedPrice.spec.js | 97 ------ modules/item/front/barcode/index.html | 57 ---- modules/item/front/barcode/index.js | 17 - modules/item/front/basic-data/index.html | 318 ------------------ modules/item/front/basic-data/index.js | 87 ----- modules/item/front/basic-data/index.spec.js | 32 -- modules/item/front/basic-data/locale/es.yml | 19 -- modules/item/front/botanical/index.html | 102 ------ modules/item/front/botanical/index.js | 99 ------ modules/item/front/botanical/index.spec.js | 179 ---------- modules/item/front/botanical/locale/es.yml | 5 - modules/item/front/card/index.html | 8 - modules/item/front/card/index.js | 33 -- modules/item/front/card/index.spec.js | 32 -- modules/item/front/create/index.html | 95 ------ modules/item/front/create/index.js | 40 --- modules/item/front/create/index.spec.js | 37 -- modules/item/front/create/locale/es.yml | 1 - modules/item/front/diary/index.html | 2 - modules/item/front/diary/index.js | 21 -- modules/item/front/fetched-tags/index.html | 40 --- modules/item/front/fetched-tags/index.js | 12 - modules/item/front/fetched-tags/style.scss | 61 ---- .../front/fixed-price-search-panel/index.html | 214 ------------ .../front/fixed-price-search-panel/index.js | 60 ---- .../fixed-price-search-panel/index.spec.js | 56 --- .../fixed-price-search-panel/locale/es.yml | 4 - .../front/fixed-price-search-panel/style.scss | 71 ---- modules/item/front/fixed-price/index.html | 284 ---------------- modules/item/front/fixed-price/index.js | 254 -------------- modules/item/front/fixed-price/index.spec.js | 173 ---------- modules/item/front/fixed-price/locale/es.yml | 7 - modules/item/front/fixed-price/style.scss | 46 --- modules/item/front/index.js | 21 -- modules/item/front/index/index.html | 197 ----------- modules/item/front/index/index.js | 112 ------ modules/item/front/index/index.spec.js | 30 -- modules/item/front/index/locale/es.yml | 2 - modules/item/front/index/preview.svg | 11 - modules/item/front/index/style.scss | 34 -- modules/item/front/item-shelving/index.html | 118 ------- modules/item/front/item-shelving/index.js | 89 ----- .../item/front/item-shelving/index.spec.js | 81 ----- .../item/front/item-shelving/locale/es.yml | 5 - .../front/item-type/basic-data/index.html | 62 ---- .../item/front/item-type/basic-data/index.js | 12 - modules/item/front/item-type/card/index.html | 5 - modules/item/front/item-type/card/index.js | 23 -- .../item/front/item-type/card/index.spec.js | 27 -- .../item/front/item-type/create/index.html | 62 ---- modules/item/front/item-type/create/index.js | 15 - .../item/front/item-type/create/index.spec.js | 34 -- .../front/item-type/descriptor/index.html | 25 -- .../item/front/item-type/descriptor/index.js | 20 -- modules/item/front/item-type/index.js | 8 - modules/item/front/item-type/index/index.html | 43 --- modules/item/front/item-type/index/index.js | 14 - .../item/front/item-type/index/index.spec.js | 34 -- .../item/front/item-type/index/locale/es.yml | 2 - modules/item/front/item-type/main/index.html | 18 - modules/item/front/item-type/main/index.js | 24 -- .../item/front/item-type/main/index.spec.js | 31 -- .../item/front/item-type/main/locale/es.yml | 1 - .../front/item-type/search-panel/index.html | 22 -- .../front/item-type/search-panel/index.js | 7 - .../item/front/item-type/summary/index.html | 50 --- modules/item/front/item-type/summary/index.js | 33 -- .../front/item-type/summary/locale/es.yml | 4 - modules/item/front/last-entries/index.html | 138 -------- modules/item/front/last-entries/index.js | 105 ------ modules/item/front/last-entries/locale/es.yml | 15 - modules/item/front/main/index.html | 23 -- modules/item/front/main/index.js | 9 +- .../front/request-search-panel/index.html | 104 ------ .../item/front/request-search-panel/index.js | 48 --- .../front/request-search-panel/index.spec.js | 48 --- .../front/request-search-panel/locale/es.yml | 4 - modules/item/front/request/index.html | 172 ---------- modules/item/front/request/index.js | 143 -------- modules/item/front/request/index.spec.js | 120 ------- modules/item/front/request/locale/es.yml | 9 - modules/item/front/request/style.scss | 15 - modules/item/front/routes.json | 196 +---------- modules/item/front/search-panel/index.html | 181 ---------- modules/item/front/search-panel/index.js | 67 ---- modules/item/front/search-panel/index.spec.js | 60 ---- modules/item/front/search-panel/locale/es.yml | 8 - modules/item/front/summary/index.html | 227 ------------- modules/item/front/summary/index.js | 61 ---- modules/item/front/summary/index.spec.js | 42 --- modules/item/front/summary/locale/en.yml | 1 - modules/item/front/summary/locale/es.yml | 5 - modules/item/front/summary/style.scss | 39 --- modules/item/front/tags/index.html | 82 ----- modules/item/front/tags/index.js | 54 --- modules/item/front/tags/index.spec.js | 34 -- modules/item/front/tax/index.html | 43 --- modules/item/front/tax/index.js | 41 --- modules/item/front/tax/index.spec.js | 64 ---- modules/item/front/waste/index/index.html | 2 - modules/item/front/waste/index/index.js | 19 -- modules/item/front/waste/index/style.scss | 27 -- modules/item/front/waste/locale/es.yml | 4 - 115 files changed, 5 insertions(+), 6892 deletions(-) delete mode 100644 e2e/paths/04-item/01_summary.spec.js delete mode 100644 e2e/paths/04-item/02_basic_data.spec.js delete mode 100644 e2e/paths/04-item/03_tax.spec.js delete mode 100644 e2e/paths/04-item/04_tags.spec.js delete mode 100644 e2e/paths/04-item/05_botanical.spec.js delete mode 100644 e2e/paths/04-item/06_barcode.spec.js delete mode 100644 e2e/paths/04-item/07_create.spec.js delete mode 100644 e2e/paths/04-item/08_regularize.spec.js delete mode 100644 e2e/paths/04-item/09_index.spec.js delete mode 100644 e2e/paths/04-item/10_item_log.spec.js delete mode 100644 e2e/paths/04-item/11_descriptor.spec.js delete mode 100644 e2e/paths/04-item/12_request.spec.js delete mode 100644 e2e/paths/04-item/13_fixedPrice.spec.js delete mode 100644 modules/item/front/barcode/index.html delete mode 100644 modules/item/front/barcode/index.js delete mode 100644 modules/item/front/basic-data/index.html delete mode 100644 modules/item/front/basic-data/index.js delete mode 100644 modules/item/front/basic-data/index.spec.js delete mode 100644 modules/item/front/basic-data/locale/es.yml delete mode 100644 modules/item/front/botanical/index.html delete mode 100644 modules/item/front/botanical/index.js delete mode 100644 modules/item/front/botanical/index.spec.js delete mode 100644 modules/item/front/botanical/locale/es.yml delete mode 100644 modules/item/front/card/index.html delete mode 100644 modules/item/front/card/index.js delete mode 100644 modules/item/front/card/index.spec.js delete mode 100644 modules/item/front/create/index.html delete mode 100644 modules/item/front/create/index.js delete mode 100644 modules/item/front/create/index.spec.js delete mode 100644 modules/item/front/create/locale/es.yml delete mode 100644 modules/item/front/diary/index.html delete mode 100644 modules/item/front/diary/index.js delete mode 100644 modules/item/front/fetched-tags/index.html delete mode 100644 modules/item/front/fetched-tags/index.js delete mode 100644 modules/item/front/fetched-tags/style.scss delete mode 100644 modules/item/front/fixed-price-search-panel/index.html delete mode 100644 modules/item/front/fixed-price-search-panel/index.js delete mode 100644 modules/item/front/fixed-price-search-panel/index.spec.js delete mode 100644 modules/item/front/fixed-price-search-panel/locale/es.yml delete mode 100644 modules/item/front/fixed-price-search-panel/style.scss delete mode 100644 modules/item/front/fixed-price/index.html delete mode 100644 modules/item/front/fixed-price/index.js delete mode 100644 modules/item/front/fixed-price/index.spec.js delete mode 100644 modules/item/front/fixed-price/locale/es.yml delete mode 100644 modules/item/front/fixed-price/style.scss delete mode 100644 modules/item/front/index/index.html delete mode 100644 modules/item/front/index/index.js delete mode 100644 modules/item/front/index/index.spec.js delete mode 100644 modules/item/front/index/locale/es.yml delete mode 100644 modules/item/front/index/preview.svg delete mode 100644 modules/item/front/index/style.scss delete mode 100644 modules/item/front/item-shelving/index.html delete mode 100644 modules/item/front/item-shelving/index.js delete mode 100644 modules/item/front/item-shelving/index.spec.js delete mode 100644 modules/item/front/item-shelving/locale/es.yml delete mode 100644 modules/item/front/item-type/basic-data/index.html delete mode 100644 modules/item/front/item-type/basic-data/index.js delete mode 100644 modules/item/front/item-type/card/index.html delete mode 100644 modules/item/front/item-type/card/index.js delete mode 100644 modules/item/front/item-type/card/index.spec.js delete mode 100644 modules/item/front/item-type/create/index.html delete mode 100644 modules/item/front/item-type/create/index.js delete mode 100644 modules/item/front/item-type/create/index.spec.js delete mode 100644 modules/item/front/item-type/descriptor/index.html delete mode 100644 modules/item/front/item-type/descriptor/index.js delete mode 100644 modules/item/front/item-type/index.js delete mode 100644 modules/item/front/item-type/index/index.html delete mode 100644 modules/item/front/item-type/index/index.js delete mode 100644 modules/item/front/item-type/index/index.spec.js delete mode 100644 modules/item/front/item-type/index/locale/es.yml delete mode 100644 modules/item/front/item-type/main/index.html delete mode 100644 modules/item/front/item-type/main/index.js delete mode 100644 modules/item/front/item-type/main/index.spec.js delete mode 100644 modules/item/front/item-type/main/locale/es.yml delete mode 100644 modules/item/front/item-type/search-panel/index.html delete mode 100644 modules/item/front/item-type/search-panel/index.js delete mode 100644 modules/item/front/item-type/summary/index.html delete mode 100644 modules/item/front/item-type/summary/index.js delete mode 100644 modules/item/front/item-type/summary/locale/es.yml delete mode 100644 modules/item/front/last-entries/index.html delete mode 100644 modules/item/front/last-entries/index.js delete mode 100644 modules/item/front/last-entries/locale/es.yml delete mode 100644 modules/item/front/request-search-panel/index.html delete mode 100644 modules/item/front/request-search-panel/index.js delete mode 100644 modules/item/front/request-search-panel/index.spec.js delete mode 100644 modules/item/front/request-search-panel/locale/es.yml delete mode 100644 modules/item/front/request/index.html delete mode 100644 modules/item/front/request/index.js delete mode 100644 modules/item/front/request/index.spec.js delete mode 100644 modules/item/front/request/locale/es.yml delete mode 100644 modules/item/front/request/style.scss delete mode 100644 modules/item/front/search-panel/index.html delete mode 100644 modules/item/front/search-panel/index.js delete mode 100644 modules/item/front/search-panel/index.spec.js delete mode 100644 modules/item/front/search-panel/locale/es.yml delete mode 100644 modules/item/front/summary/index.html delete mode 100644 modules/item/front/summary/index.js delete mode 100644 modules/item/front/summary/index.spec.js delete mode 100644 modules/item/front/summary/locale/en.yml delete mode 100644 modules/item/front/summary/locale/es.yml delete mode 100644 modules/item/front/summary/style.scss delete mode 100644 modules/item/front/tags/index.html delete mode 100644 modules/item/front/tags/index.js delete mode 100644 modules/item/front/tags/index.spec.js delete mode 100644 modules/item/front/tax/index.html delete mode 100644 modules/item/front/tax/index.js delete mode 100644 modules/item/front/tax/index.spec.js delete mode 100644 modules/item/front/waste/index/index.html delete mode 100644 modules/item/front/waste/index/index.js delete mode 100644 modules/item/front/waste/index/style.scss delete mode 100644 modules/item/front/waste/locale/es.yml diff --git a/e2e/paths/04-item/01_summary.spec.js b/e2e/paths/04-item/01_summary.spec.js deleted file mode 100644 index 51195be48..000000000 --- a/e2e/paths/04-item/01_summary.spec.js +++ /dev/null @@ -1,133 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item summary path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'item'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should search for an item', async() => { - await page.doSearch('Ranged weapon'); - const resultsCount = await page.countElement(selectors.itemsIndex.searchResult); - - await page.waitForTextInElement(selectors.itemsIndex.firstSearchResult, 'Ranged weapon'); - await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); - const isVisible = await page.isVisible(selectors.itemSummary.basicData); - - expect(resultsCount).toBe(4); - expect(isVisible).toBeTruthy(); - }); - - it(`should check the item summary preview shows fields from basic data`, async() => { - await page.waitForTextInElement(selectors.itemSummary.basicData, 'Ranged weapon longbow 200cm'); - const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText'); - - expect(result).toContain('Ranged weapon longbow 200cm'); - }); - - it(`should check the item summary preview shows fields from tags`, async() => { - await page.waitForTextInElement(selectors.itemSummary.tags, 'Brown'); - const result = await page.waitToGetProperty(selectors.itemSummary.tags, 'innerText'); - - expect(result).toContain('Brown'); - }); - - 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'); - - expect(result).toContain('Abelia'); - }); - - it(`should check the item summary preview shows fields from barcode`, async() => { - await page.waitForTextInElement(selectors.itemSummary.barcode, '1'); - const result = await page.waitToGetProperty(selectors.itemSummary.barcode, 'innerText'); - - expect(result).toContain('1'); - }); - - it(`should close the summary popup`, async() => { - await page.closePopup(); - await page.waitForSelector(selectors.itemSummary.basicData, {hidden: true}); - }); - - it('should search for other item', async() => { - await page.doSearch('Melee Reinforced'); - const resultsCount = await page.countElement(selectors.itemsIndex.searchResult); - - await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); - await page.waitForSelector(selectors.itemSummary.basicData, {visible: true}); - - expect(resultsCount).toBe(3); - }); - - it(`should now check the item summary preview shows fields from basic data`, async() => { - await page.waitForTextInElement(selectors.itemSummary.basicData, 'Melee Reinforced weapon combat fist 15cm'); - const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText'); - - expect(result).toContain('Melee Reinforced weapon combat fist 15cm'); - }); - - it(`should now check the item summary preview shows fields from tags`, async() => { - await page.waitForTextInElement(selectors.itemSummary.tags, 'Silver'); - const result = await page.waitToGetProperty(selectors.itemSummary.tags, 'innerText'); - - expect(result).toContain('Silver'); - }); - - it(`should now check the item summary preview shows fields from botanical`, async() => { - await page.waitForTextInElement(selectors.itemSummary.botanical, '-'); - const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText'); - - expect(result).toContain('-'); - }); - - it(`should now close the summary popup`, async() => { - await page.closePopup(); - await page.waitForSelector(selectors.itemSummary.basicData, {hidden: true}); - }); - - it(`should navigate to one of the items detailed section`, async() => { - await page.accessToSearchResult('Melee weapon combat fist 15cm'); - await page.waitForState('item.card.summary'); - }); - - it(`should check the descritor edit button is not visible for employee`, async() => { - const visibleButton = await page.isVisible(selectors.itemDescriptor.editButton); - - expect(visibleButton).toBeFalsy(); - }); - - it(`should check the item summary shows fields from basic data section`, async() => { - await page.waitForTextInElement(selectors.itemSummary.basicData, 'Melee weapon combat fist 15cm'); - const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText'); - - expect(result).toContain('Melee weapon combat fist 15cm'); - }); - - it(`should check the item summary shows fields from tags section`, async() => { - const result = await page.waitToGetProperty(selectors.itemSummary.tags, 'innerText'); - - expect(result).toContain('Silver'); - }); - - it(`should check the item summary shows fields from botanical section`, async() => { - const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText'); - - expect(result).toContain('procera'); - }); - - it(`should check the item summary shows fields from barcodes section`, async() => { - const result = await page.waitToGetProperty(selectors.itemSummary.barcode, 'innerText'); - - expect(result).toContain('4'); - }); -}); diff --git a/e2e/paths/04-item/02_basic_data.spec.js b/e2e/paths/04-item/02_basic_data.spec.js deleted file mode 100644 index 3bad18303..000000000 --- a/e2e/paths/04-item/02_basic_data.spec.js +++ /dev/null @@ -1,64 +0,0 @@ -import getBrowser from '../../helpers/puppeteer'; - -const $ = { - form: 'vn-item-basic-data form', - intrastatForm: '.vn-dialog.shown form', - newIntrastatButton: 'vn-item-basic-data vn-icon-button[vn-tooltip="New intrastat"] > button' -}; - -describe('Item Edit basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'item'); - await page.accessToSearchResult('Melee weapon combat fist 15cm'); - }); - - beforeEach(async() => { - await page.accessToSection('item.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should edit the item basic data and confirm the item data was edited`, async() => { - const values = { - type: 'Anthurium', - intrastat: 'Coral y materiales similares', - relevancy: 1, - generic: 'Pallet', - isActive: false, - priceInKg: true, - isFragile: true, - packingOut: 5 - }; - - const message = await page.sendForm($.form, values); - await page.reloadSection('item.card.basicData'); - const formValues = await page.fetchForm($.form, Object.keys(values)); - - expect(message.isSuccess).toBeTrue(); - expect(formValues).toEqual(values); - }); - - it(`should create a new intrastat and save it`, async() => { - await page.click($.newIntrastatButton); - await page.waitForSelector($.intrastatForm); - await page.fillForm($.intrastatForm, { - id: '588420239', - description: 'Tropical Flowers' - }); - await page.respondToDialog('accept'); - - const message = await page.sendForm($.form); - await page.reloadSection('item.card.basicData'); - const formValues = await page.fetchForm($.form, ['intrastat']); - - expect(message.isSuccess).toBeTrue(); - expect(formValues).toEqual({intrastat: 'Tropical Flowers'}); - }); -}); diff --git a/e2e/paths/04-item/03_tax.spec.js b/e2e/paths/04-item/03_tax.spec.js deleted file mode 100644 index 6013094e9..000000000 --- a/e2e/paths/04-item/03_tax.spec.js +++ /dev/null @@ -1,48 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item edit tax path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'item'); - await page.accessToSearchResult('Ranged weapon longbow 200cm'); - await page.accessToSection('item.card.tax'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should add the item tax to all countries`, async() => { - await page.autocompleteSearch(selectors.itemTax.firstClass, 'General VAT'); - await page.autocompleteSearch(selectors.itemTax.secondClass, 'General VAT'); - await page.waitToClick(selectors.itemTax.submitTaxButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the first item tax class was edited`, async() => { - await page.reloadSection('item.card.tax'); - const firstVatType = await page.waitToGetProperty(selectors.itemTax.firstClass, 'value'); - - expect(firstVatType).toEqual('General VAT'); - }); - - it(`should confirm the second item tax class was edited`, async() => { - const secondVatType = await page - .waitToGetProperty(selectors.itemTax.secondClass, 'value'); - - expect(secondVatType).toEqual('General VAT'); - }); - - it(`should edit the first class without saving the form`, async() => { - await page.autocompleteSearch(selectors.itemTax.firstClass, 'Reduced VAT'); - const firstVatType = await page.waitToGetProperty(selectors.itemTax.firstClass, 'value'); - - expect(firstVatType).toEqual('Reduced VAT'); - }); -}); diff --git a/e2e/paths/04-item/04_tags.spec.js b/e2e/paths/04-item/04_tags.spec.js deleted file mode 100644 index f13cf9aa4..000000000 --- a/e2e/paths/04-item/04_tags.spec.js +++ /dev/null @@ -1,79 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item create tags path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'item'); - await page.accessToSearchResult('Ranged weapon longbow 200cm'); - await page.accessToSection('item.card.tags'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should create a new tag and delete a former one', async() => { - await page.waitToClick(selectors.itemTags.fourthRemoveTagButton); - await page.waitToClick(selectors.itemTags.addItemTagButton); - await page.autocompleteSearch(selectors.itemTags.seventhTag, 'Ancho de la base'); - await page.write(selectors.itemTags.seventhValue, '50'); - await page.clearInput(selectors.itemTags.seventhRelevancy); - await page.write(selectors.itemTags.seventhRelevancy, '4'); - await page.waitToClick(selectors.itemTags.submitItemTagsButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the fourth row data is the expected one', async() => { - await page.reloadSection('item.card.tags'); - await page.waitForSelector('vn-item-tags'); - let result = await page.waitToGetProperty(selectors.itemTags.fourthTag, 'value'); - - expect(result).toEqual('Ancho de la base'); - - result = await page - .waitToGetProperty(selectors.itemTags.fourthValue, 'value'); - - expect(result).toEqual('50'); - - result = await page - .waitToGetProperty(selectors.itemTags.fourthRelevancy, 'value'); - - expect(result).toEqual('4'); - }); - - it('should confirm the fifth row data is the expected one', async() => { - let tag = await page - .waitToGetProperty(selectors.itemTags.fifthTag, 'value'); - - let value = await page - .waitToGetProperty(selectors.itemTags.fifthValue, 'value'); - - let relevancy = await page - .waitToGetProperty(selectors.itemTags.fifthRelevancy, 'value'); - - expect(tag).toEqual('Color'); - expect(value).toEqual('Brown'); - expect(relevancy).toEqual('5'); - }); - - it('should confirm the sixth row data is the expected one', async() => { - let tag = await page - .waitToGetProperty(selectors.itemTags.sixthTag, 'value'); - - let value = await page - .waitToGetProperty(selectors.itemTags.sixthValue, 'value'); - - let relevancy = await page - .waitToGetProperty(selectors.itemTags.sixthRelevancy, 'value'); - - expect(tag).toEqual('Categoria'); - expect(value).toEqual('+1 precission'); - expect(relevancy).toEqual('6'); - }); -}); diff --git a/e2e/paths/04-item/05_botanical.spec.js b/e2e/paths/04-item/05_botanical.spec.js deleted file mode 100644 index 1671cc5d2..000000000 --- a/e2e/paths/04-item/05_botanical.spec.js +++ /dev/null @@ -1,66 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item Create botanical path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'item'); - await page.accessToSearchResult('Ranged weapon pistol 9mm'); - await page.accessToSection('item.card.botanical'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should create a new botanical for the item`, async() => { - await page.autocompleteSearch(selectors.itemBotanical.genus, 'Abelia'); - await page.autocompleteSearch(selectors.itemBotanical.species, 'dealbata'); - await page.waitToClick(selectors.itemBotanical.submitBotanicalButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the Genus for the item was created`, async() => { - await page.waitForTextInField(selectors.itemBotanical.genus, 'Abelia'); - const result = await page - .waitToGetProperty(selectors.itemBotanical.genus, 'value'); - - expect(result).toEqual('Abelia'); - }); - - it(`should confirm the Species for the item was created`, async() => { - const result = await page - .waitToGetProperty(selectors.itemBotanical.species, 'value'); - - expect(result).toEqual('dealbata'); - }); - - it(`should edit botanical for the item`, async() => { - await page.autocompleteSearch(selectors.itemBotanical.genus, 'Abies'); - await page.autocompleteSearch(selectors.itemBotanical.species, 'decurrens'); - await page.waitToClick(selectors.itemBotanical.submitBotanicalButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the Genus for the item was edited`, async() => { - await page.waitForTextInField(selectors.itemBotanical.genus, 'Abies'); - const result = await page - .waitToGetProperty(selectors.itemBotanical.genus, 'value'); - - expect(result).toEqual('Abies'); - }); - - it(`should confirm the Species for the item was edited`, async() => { - const result = await page - .waitToGetProperty(selectors.itemBotanical.species, 'value'); - - expect(result).toEqual('decurrens'); - }); -}); diff --git a/e2e/paths/04-item/06_barcode.spec.js b/e2e/paths/04-item/06_barcode.spec.js deleted file mode 100644 index 36c9c39ae..000000000 --- a/e2e/paths/04-item/06_barcode.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item Create barcodes path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'item'); - await page.accessToSearchResult('Ranged weapon longbow 200cm'); - await page.accessToSection('item.card.itemBarcode'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should click create a new code and delete a former one`, async() => { - await page.waitToClick(selectors.itemBarcodes.firstCodeRemoveButton); - await page.waitToClick(selectors.itemBarcodes.addBarcodeButton); - await page.write(selectors.itemBarcodes.thirdCode, '5'); - await page.waitToClick(selectors.itemBarcodes.submitBarcodesButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, async() => { - await page.reloadSection('item.card.itemBarcode'); - await page.waitForTextInField(selectors.itemBarcodes.thirdCode, '5'); - const result = await page - .waitToGetProperty(selectors.itemBarcodes.thirdCode, 'value'); - - expect(result).toEqual('5'); - }); -}); diff --git a/e2e/paths/04-item/07_create.spec.js b/e2e/paths/04-item/07_create.spec.js deleted file mode 100644 index c20be9ebc..000000000 --- a/e2e/paths/04-item/07_create.spec.js +++ /dev/null @@ -1,65 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -const $ = { - form: 'vn-item-create form' -}; - -describe('Item Create', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'item'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should access to the create item view by clicking the create floating button', async() => { - await page.waitToClick(selectors.itemsIndex.createItemButton); - await page.waitForState('item.create'); - }); - - it('should return to the item index by clickig the cancel button', async() => { - await page.waitToClick(selectors.itemCreateView.cancelButton); - await page.waitForState('item.index'); - }); - - it('should now access to the create item view by clicking the create floating button', async() => { - await page.waitToClick(selectors.itemsIndex.createItemButton); - await page.waitForState('item.create'); - }); - - it('should throw an error when insert an invalid priority', async() => { - const values = { - name: 'Infinity Gauntlet', - type: 'Crisantemo', - intrastat: 'Coral y materiales similares', - origin: 'Holand', - priority: null - }; - const message = await page.sendForm($.form, values); - - expect(message.text).toContain('Valid priorities'); - }); - - it('should create the Infinity Gauntlet item', async() => { - const values = { - name: 'Infinity Gauntlet', - type: 'Crisantemo', - intrastat: 'Coral y materiales similares', - origin: 'Holand', - priority: '2' - }; - - await page.fillForm($.form, values); - const formValues = await page.fetchForm($.form, Object.keys(values)); - const message = await page.sendForm($.form); - - expect(message.isSuccess).toBeTrue(); - expect(formValues).toEqual(values); - }); -}); diff --git a/e2e/paths/04-item/08_regularize.spec.js b/e2e/paths/04-item/08_regularize.spec.js deleted file mode 100644 index 9b3074776..000000000 --- a/e2e/paths/04-item/08_regularize.spec.js +++ /dev/null @@ -1,141 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item regularize path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'item'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should edit the user local warehouse', async() => { - await page.waitForSpinnerLoad(); - await page.waitToClick(selectors.globalItems.userMenuButton); - await page.autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should check the local settings were saved', async() => { - const userLocalWarehouse = await page - .waitToGetProperty(selectors.globalItems.userLocalWarehouse, 'value'); - - await page.closePopup(); - - expect(userLocalWarehouse).toContain('Warehouse Four'); - }); - - it('should search for a specific item', async() => { - await page.accessToSearchResult('Ranged weapon pistol 9mm'); - await page.waitForState('item.card.summary'); - }); - - it('should open the regularize dialog and check the warehouse matches the local user settings', async() => { - await page.waitToClick(selectors.itemDescriptor.moreMenu); - await page.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton); - const result = await page.waitToGetProperty(selectors.itemDescriptor.regularizeWarehouse, 'value'); - - expect(result).toEqual('Warehouse Four'); - }); - - it('should regularize the item', async() => { - await page.write(selectors.itemDescriptor.regularizeQuantity, '100'); - await page.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouse, 'Warehouse One'); - await page.waitToClick(selectors.itemDescriptor.regularizeSaveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should click on the Tickets button of the top bar menu', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await Promise.all([ - page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}), - page.waitToClick(selectors.globalItems.ticketsButton) - ]); - await page.waitForState('ticket.index'); - }); - - it('should clear the user local settings now', async() => { - await page.waitToClick(selectors.globalItems.userMenuButton); - await page.waitForContentLoaded(); - await page.clearInput(selectors.globalItems.userConfigFirstAutocomplete); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should search for the ticket with alias missing', async() => { - await page.keyboard.press('Escape'); - await page.accessToSearchResult('missing'); - await page.waitForState('ticket.card.summary'); - }); - - it(`should check the ticket sale quantity is showing a negative value`, async() => { - await page.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100'); - const result = await page - .waitToGetProperty(selectors.ticketSummary.firstSaleQuantity, 'innerText'); - - expect(result).toContain('-100'); - }); - - it(`should check the ticket sale discount is 100%`, async() => { - const result = await page - .waitToGetProperty(selectors.ticketSummary.firstSaleDiscount, 'innerText'); - - expect(result).toContain('100 %'); - }); - - it('should now click on the Items button of the top bar menu', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.itemsButton); - await page.waitForState('item.index'); - }); - - it('should search for the item once again', async() => { - await page.accessToSearchResult('Ranged weapon pistol 9mm'); - await page.waitForState('item.card.summary'); - }); - - it('should regularize the item once more', async() => { - await page.waitToClick(selectors.itemDescriptor.moreMenu); - await page.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton); - await page.write(selectors.itemDescriptor.regularizeQuantity, '100'); - await page.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouse, 'Warehouse One'); - await page.waitToClick(selectors.itemDescriptor.regularizeSaveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should again click on the Tickets button of the top bar menu', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await Promise.all([ - page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}), - page.waitToClick(selectors.globalItems.ticketsButton) - ]); - await page.waitForState('ticket.index'); - }); - - it('should search for the ticket missing once again', async() => { - await page.accessToSearchResult('Missing'); - await page.waitForState('ticket.card.summary'); - }); - - it(`should check the ticket contains now two sales`, async() => { - await page.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100'); - const result = await page.countElement(selectors.ticketSummary.sale); - - expect(result).toEqual(2); - }); -}); diff --git a/e2e/paths/04-item/09_index.spec.js b/e2e/paths/04-item/09_index.spec.js deleted file mode 100644 index 6e0a4bd5c..000000000 --- a/e2e/paths/04-item/09_index.spec.js +++ /dev/null @@ -1,84 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item index path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('salesPerson', 'item'); - await page.waitToClick(selectors.globalItems.searchButton); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should click on the fields to show button to open the list of columns to show', async() => { - await page.waitToClick(selectors.itemsIndex.shownColumns); - const visible = await page.isVisible(selectors.itemsIndex.shownColumnsList); - - expect(visible).toBeTruthy(); - }); - - it('should unmark all checkboxes except the first and the last ones', async() => { - await page.waitToClick(selectors.itemsIndex.idCheckbox); - await page.waitToClick(selectors.itemsIndex.stemsCheckbox); - await page.waitToClick(selectors.itemsIndex.sizeCheckbox); - await page.waitToClick(selectors.itemsIndex.typeCheckbox); - await page.waitToClick(selectors.itemsIndex.categoryCheckbox); - await page.waitToClick(selectors.itemsIndex.intrastadCheckbox); - await page.waitToClick(selectors.itemsIndex.originCheckbox); - await page.waitToClick(selectors.itemsIndex.buyerCheckbox); - await page.waitToClick(selectors.itemsIndex.weightByPieceCheckbox); - await page.waitToClick(selectors.itemsIndex.saveFieldsButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should navigate forth and back to see the images column is still visible', async() => { - await page.closePopup(); - await page.waitToClick(selectors.itemsIndex.firstSearchResult); - await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton); - await page.waitToClick(selectors.globalItems.searchButton); - await page.waitForSelector(selectors.itemsIndex.searchResult); - await page.waitImgLoad(selectors.itemsIndex.firstItemImage); - const imageVisible = await page.isVisible(selectors.itemsIndex.firstItemImageTd); - - expect(imageVisible).toBeTruthy(); - }); - - it('should check the ids column is not visible', async() => { - await page.waitForSelector(selectors.itemsIndex.firstItemId, {hidden: true}); - }); - - it('should mark all unchecked boxes to leave the index as it was', async() => { - await page.waitToClick(selectors.itemsIndex.shownColumns); - await page.waitToClick(selectors.itemsIndex.idCheckbox); - await page.waitToClick(selectors.itemsIndex.stemsCheckbox); - await page.waitToClick(selectors.itemsIndex.sizeCheckbox); - await page.waitToClick(selectors.itemsIndex.typeCheckbox); - await page.waitToClick(selectors.itemsIndex.categoryCheckbox); - await page.waitToClick(selectors.itemsIndex.intrastadCheckbox); - await page.waitToClick(selectors.itemsIndex.originCheckbox); - await page.waitToClick(selectors.itemsIndex.buyerCheckbox); - await page.waitToClick(selectors.itemsIndex.weightByPieceCheckbox); - await page.waitToClick(selectors.itemsIndex.saveFieldsButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should now navigate forth and back to see the ids column is now visible', async() => { - await page.closePopup(); - await page.waitToClick(selectors.itemsIndex.firstSearchResult); - await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton); - await page.waitToClick(selectors.globalItems.searchButton); - await page.waitForSelector(selectors.itemsIndex.searchResult); - const idVisible = await page.isVisible(selectors.itemsIndex.firstItemId); - - expect(idVisible).toBeTruthy(); - }); -}); diff --git a/e2e/paths/04-item/10_item_log.spec.js b/e2e/paths/04-item/10_item_log.spec.js deleted file mode 100644 index c88fbd337..000000000 --- a/e2e/paths/04-item/10_item_log.spec.js +++ /dev/null @@ -1,45 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item log path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('developer', 'item'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should search for the Knowledge artifact to confirm it isn't created yet`, async() => { - await page.doSearch('Knowledge artifact'); - const nResults = await page.countElement(selectors.itemsIndex.searchResult); - - expect(nResults).toEqual(1); - }); - - it('should access to the create item view by clicking the create floating button', async() => { - await page.waitToClick(selectors.itemsIndex.createItemButton); - await page.waitForState('item.create'); - }); - - it('should create the Knowledge artifact item', async() => { - await page.write(selectors.itemCreateView.temporalName, 'Knowledge artifact'); - await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo'); - await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares'); - await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand'); - await page.waitToClick(selectors.itemCreateView.createButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should return to the items index by clicking the return to items button', async() => { - await page.waitToClick(selectors.itemBasicData.goToItemIndexButton); - await page.waitForSelector(selectors.itemsIndex.createItemButton); - await page.waitForState('item.index'); - }); -}); diff --git a/e2e/paths/04-item/11_descriptor.spec.js b/e2e/paths/04-item/11_descriptor.spec.js deleted file mode 100644 index eb9ed2573..000000000 --- a/e2e/paths/04-item/11_descriptor.spec.js +++ /dev/null @@ -1,41 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item descriptor path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'item'); - await page.accessToSearchResult('1'); - await page.accessToSection('item.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should set the item to inactive', async() => { - await page.waitToClick(selectors.itemBasicData.isActiveCheckbox); - await page.waitToClick(selectors.itemBasicData.submitBasicDataButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the section and check the inactive icon is visible', async() => { - await page.reloadSection('item.card.basicData'); - const visibleIcon = await page.isVisible(selectors.itemDescriptor.inactiveIcon); - - expect(visibleIcon).toBeTruthy(); - }); - - it('should set the item back to active', async() => { - await page.waitToClick(selectors.itemBasicData.isActiveCheckbox); - await page.waitToClick(selectors.itemBasicData.submitBasicDataButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/04-item/12_request.spec.js b/e2e/paths/04-item/12_request.spec.js deleted file mode 100644 index e0f3a1b45..000000000 --- a/e2e/paths/04-item/12_request.spec.js +++ /dev/null @@ -1,45 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item request path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'item'); - await page.accessToSection('item.request'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the item request section', async() => { - await page.waitForState('item.request'); - }); - - it('should fill the id and quantity then check the concept was updated', async() => { - await page.writeOnEditableTD(selectors.itemRequest.firstRequestItemID, '4'); - await page.writeOnEditableTD(selectors.itemRequest.firstRequestQuantity, '10'); - await page.waitForTextInElement(selectors.itemRequest.firstRequestConcept, 'Melee weapon heavy shield 100cm'); - let filledConcept = await page.waitToGetProperty(selectors.itemRequest.firstRequestConcept, 'innerText'); - - expect(filledConcept).toContain('Melee weapon heavy shield 100cm'); - }); - - it('should check the status of the request should now be accepted', async() => { - let status = await page.waitToGetProperty(selectors.itemRequest.firstRequestStatus, 'innerText'); - - expect(status).toContain('Accepted'); - }); - - it('should now click on the second declain request icon then type the reason', async() => { - await page.waitToClick(selectors.itemRequest.secondRequestDecline); - await page.write(selectors.itemRequest.declineReason, 'Not quite as expected'); - await page.respondToDialog('accept'); - let status = await page.waitToGetProperty(selectors.itemRequest.secondRequestStatus, 'innerText'); - - expect(status).toContain('Denied'); - }); -}); diff --git a/e2e/paths/04-item/13_fixedPrice.spec.js b/e2e/paths/04-item/13_fixedPrice.spec.js deleted file mode 100644 index f36138e18..000000000 --- a/e2e/paths/04-item/13_fixedPrice.spec.js +++ /dev/null @@ -1,97 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -const $ = selectors.itemFixedPrice; - -describe('Item fixed prices path', () => { - let browser; - let page; - let httpRequest; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'item'); - await page.accessToSection('item.fixedPrice'); - page.on('request', req => { - if (req.url().includes(`FixedPrices/filter`)) - httpRequest = req.url(); - }); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should filter using all the fields', async() => { - await page.write($.generalSearchFilter, 'item'); - await page.keyboard.press('Enter'); - - expect(httpRequest).toContain('search=item'); - - await page.click($.chip); - await page.click($.reignFilter); - - expect(httpRequest).toContain('categoryFk'); - - await page.autocompleteSearch($.typeFilter, 'Alstroemeria'); - - expect(httpRequest).toContain('typeFk'); - - await page.click($.chip); - await page.autocompleteSearch($.buyerFilter, 'buyerNick'); - - expect(httpRequest).toContain('buyerFk'); - - await page.click($.chip); - await page.autocompleteSearch($.warehouseFilter, 'Algemesi'); - - expect(httpRequest).toContain('warehouseFk'); - - await page.click($.chip); - await page.click($.mineFilter); - - expect(httpRequest).toContain('mine=true'); - - await page.click($.chip); - await page.click($.hasMinPriceFilter); - - expect(httpRequest).toContain('hasMinPrice=true'); - - await page.click($.chip); - await page.click($.addTag); - await page.autocompleteSearch($.tagFilter, 'Color'); - await page.autocompleteSearch($.tagValueFilter, 'Brown'); - - expect(httpRequest).toContain('tags'); - - await page.click($.chip); - }); - - it('should click on the add new fixed price button', async() => { - await page.waitToClick($.add); - await page.waitForSelector($.fourthFixedPrice); - }); - - it('should fill the fixed price data', async() => { - const now = Date.vnNew(); - await page.autocompleteSearch($.fourthWarehouse, 'Warehouse one'); - await page.writeOnEditableTD($.fourthGroupingPrice, '1'); - await page.writeOnEditableTD($.fourthPackingPrice, '1'); - await page.write($.fourthMinPrice, '1'); - await page.pickDate($.fourthStarted, now); - await page.pickDate($.fourthEnded, now); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the section and check the created price has the expected ID', async() => { - await page.goto(`http://localhost:5000/#!/item/fixed-price`); - await page.autocompleteSearch($.warehouseFilter, 'Warehouse one'); - await page.click($.chip); - const result = await page.waitToGetProperty($.fourthItemID, 'value'); - - expect(result).toContain('13'); - }); -}); diff --git a/modules/item/front/barcode/index.html b/modules/item/front/barcode/index.html deleted file mode 100644 index 8d6cb3af8..000000000 --- a/modules/item/front/barcode/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/item/front/barcode/index.js b/modules/item/front/barcode/index.js deleted file mode 100644 index 4ceb87b9d..000000000 --- a/modules/item/front/barcode/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('vnItemBarcode', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html deleted file mode 100644 index af76d5966..000000000 --- a/modules/item/front/basic-data/index.html +++ /dev/null @@ -1,318 +0,0 @@ - - - - - - -
- - - - -
{{::name}}
-
- {{::category.name}} -
-
-
- - - - -
- - - - - - - -
{{::name}}
-
- #{{::id}} -
-
- - - - -
-
- - - -
{{::description}}
-
- #{{::id}} -
-
- - - - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ID - Item - Size - Producer - Color - - - - - - - {{::item.id}} - - - {{::item.name}} - {{::item.size}} - {{::item.producer.name}} - {{::item.ink.name}} - - - - - - - - diff --git a/modules/item/front/basic-data/index.js b/modules/item/front/basic-data/index.js deleted file mode 100644 index 5a303f15f..000000000 --- a/modules/item/front/basic-data/index.js +++ /dev/null @@ -1,87 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - showIntrastat(event) { - if (event.defaultPrevented) return; - event.preventDefault(); - - this.newIntrastat = { - taxClassFk: this.item.taxClassFk - }; - this.$.intrastat.show(); - } - - onIntrastatAccept() { - const query = `Items/${this.$params.id}/createIntrastat`; - return this.$http.patch(query, this.newIntrastat) - .then(res => this.item.intrastatFk = res.data.id); - } - - itemSearchFunc($search) { - return /^\d+$/.test($search) - ? {id: $search} - : {name: {like: '%' + $search + '%'}}; - } - - showFilterDialog(item) { - this.activeItem = item; - this.itemFilterParams = {}; - this.itemFilter = { - include: [ - { - relation: 'producer', - scope: { - fields: ['name'] - } - }, - { - relation: 'ink', - scope: { - fields: ['name'] - } - } - ] - }; - - this.$.filterDialog.show(); - } - - selectItem(id) { - this.activeItem['genericFk'] = id; - this.$.filterDialog.hide(); - } - - filter() { - const filter = this.itemFilter; - const params = this.itemFilterParams; - const where = {}; - for (let key in params) { - const value = params[key]; - if (!value) continue; - - switch (key) { - case 'name': - where[key] = {like: `%${value}%`}; - break; - case 'producerFk': - case 'typeFk': - case 'size': - case 'inkFk': - where[key] = value; - } - } - - filter.where = where; - - this.$.itemsModel.applyFilter(filter); - } -} - -ngModule.vnComponent('vnItemBasicData', { - template: require('./index.html'), - bindings: { - item: '<' - }, - controller: Controller -}); diff --git a/modules/item/front/basic-data/index.spec.js b/modules/item/front/basic-data/index.spec.js deleted file mode 100644 index 274453d30..000000000 --- a/modules/item/front/basic-data/index.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import './index.js'; - -describe('vnItemBasicData', () => { - describe('Component vnItemBasicData', () => { - let $httpBackend; - let $scope; - let controller; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnItemBasicData', {$element, $scope}); - controller.$.watcher = {}; - controller.$params.id = 1; - controller.item = {id: 1, name: 'Rainbow Coral'}; - })); - - describe('onIntrastatAccept()', () => { - it('should pass the data to the watcher', () => { - const newIntrastatId = 20; - $httpBackend.expect('PATCH', 'Items/1/createIntrastat').respond({id: 20}); - controller.onIntrastatAccept(); - $httpBackend.flush(); - - expect(controller.item.intrastatFk).toEqual(newIntrastatId); - }); - }); - }); -}); diff --git a/modules/item/front/basic-data/locale/es.yml b/modules/item/front/basic-data/locale/es.yml deleted file mode 100644 index fc490e448..000000000 --- a/modules/item/front/basic-data/locale/es.yml +++ /dev/null @@ -1,19 +0,0 @@ -Reference: Referencia -Full name calculates based on tags 1-3. Is not recommended to change it manually: >- - El nombre completo se calcula - basado en los tags 1-3. - No se recomienda cambiarlo manualmente -Is active: Activo -Expense: Gasto -Price in kg: Precio en kg -New intrastat: Nuevo intrastat -Identifier: Identificador -Fragile: Frágil -Is shown at website, app that this item cannot travel (wreath, palms, ...): Se muestra en la web, app que este artículo no puede viajar (coronas, palmas, ...) -Multiplier: Multiplicador -Generic: Genérico -This item does need a photo: Este artículo necesita una foto -Do photo: Hacer foto -Recycled Plastic: Plástico reciclado -Non recycled plastic: Plástico no reciclado -Minimum sales quantity: Cantidad mínima de venta diff --git a/modules/item/front/botanical/index.html b/modules/item/front/botanical/index.html deleted file mode 100644 index 2388f4e8f..000000000 --- a/modules/item/front/botanical/index.html +++ /dev/null @@ -1,102 +0,0 @@ - - -
- - - - - - - - - - -
{{name}}
-
- {{genus.name}} -
-
- - - - -
-
-
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/item/front/botanical/index.js b/modules/item/front/botanical/index.js deleted file mode 100644 index 8ade0fd9d..000000000 --- a/modules/item/front/botanical/index.js +++ /dev/null @@ -1,99 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -class Controller extends Section { - get item() { - return this._item; - } - - set item(value) { - this._item = value; - if (value) - this.getBotanicalData(); - } - - showGenus(event) { - if (event.defaultPrevented) return; - event.preventDefault(); - - this.$.genus.show(); - } - - showSpecies(event) { - if (event.defaultPrevented) return; - event.preventDefault(); - - this.$.species.show(); - } - - onGenusAccept() { - try { - if (!this.data.name) - throw new Error(`The name of the genus can't be empty`); - - this.$http.post(`genera`, this.data).then(res => { - this.vnApp.showMessage(this.$t('The genus has been created')); - this.emit('response', {$response: res.data}); - this.onGenusResponse(res.data); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - return true; - } - - onSpeciesAccept() { - try { - if (!this.data.name) - throw new Error(`The name of the species can't be empty`); - - this.$http.post(`species`, this.data).then(res => { - this.vnApp.showMessage(this.$t('The species has been created')); - this.emit('response', {$response: res.data}); - this.onSpeciesResponse(res.data); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - return true; - } - - getBotanicalData() { - const filter = { - where: {itemFk: this.item.id} - }; - const filterParams = encodeURIComponent(JSON.stringify(filter)); - this.$http.get(`ItemBotanicals?filter=${filterParams}`).then(res => { - if (res.data[0]) - this.botanical = res.data[0]; - - else - this.botanical = {itemFk: this.item.id}; - }); - } - - onSubmit() { - this.$.watcher.check(); - this.$http.patch(`ItemBotanicals`, this.botanical).then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - }); - } - - onGenusResponse(response) { - this.botanical.genusFk = response.id; - } - - onSpeciesResponse(response) { - this.botanical.specieFk = response.id; - } -} - -ngModule.vnComponent('vnItemBotanical', { - template: require('./index.html'), - bindings: { - item: '<' - }, - controller: Controller -}); diff --git a/modules/item/front/botanical/index.spec.js b/modules/item/front/botanical/index.spec.js deleted file mode 100644 index afec83cfd..000000000 --- a/modules/item/front/botanical/index.spec.js +++ /dev/null @@ -1,179 +0,0 @@ -import './index.js'; - -describe('vnItemBotanical', () => { - describe('Component vnItemBotanical', () => { - let $httpBackend; - let $scope; - let controller; - let vnApp; - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _vnApp_) => { - $httpBackend = _$httpBackend_; - vnApp = _vnApp_; - jest.spyOn(vnApp, 'showError'); - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnItemBotanical', {$element, $scope}); - controller.item = {id: 5}; - controller.$params = {itemFk: 5}; - controller.$ = { - watcher: { - check: () => {}, - notifySaved: () => {}, - updateOriginalData: () => {}}, - genus: { - show: () => {} - }, - species: { - show: () => {} - }}; - })); - - beforeEach(() => { - const response = {data: 'MyResult'}; - $httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response); - }); - - describe('showGenus()', () => { - it('should do nothing in genus field if it default is prevented', () => { - const event = { - defaultPrevented: true, - preventDefault: () => {} - }; - jest.spyOn(event, 'preventDefault'); - jest.spyOn(controller.$.genus, 'show'); - - controller.showGenus(event); - - expect(event.preventDefault).not.toHaveBeenCalledWith(); - expect(controller.$.genus.show).not.toHaveBeenCalledWith(); - }); - - it('should call show function in genus field when the default is not prevented', () => { - const event = { - defaultPrevented: false, - preventDefault: () => {} - }; - - jest.spyOn(event, 'preventDefault'); - jest.spyOn(controller.$.genus, 'show'); - - controller.showGenus(event); - - expect(event.preventDefault).toHaveBeenCalledWith(); - expect(controller.$.genus.show).toHaveBeenCalledWith(); - }); - }); - - describe('showSpecies()', () => { - it('should do nothing in species field if it default is prevented', () => { - const event = { - defaultPrevented: true, - preventDefault: () => {} - }; - jest.spyOn(event, 'preventDefault'); - jest.spyOn(controller.$.species, 'show'); - - controller.showSpecies(event); - - expect(event.preventDefault).not.toHaveBeenCalledWith(); - expect(controller.$.species.show).not.toHaveBeenCalledWith(); - }); - - it('should call show function in species field when the default is not prevented', () => { - const event = { - defaultPrevented: false, - preventDefault: () => {} - }; - - jest.spyOn(event, 'preventDefault'); - jest.spyOn(controller.$.species, 'show'); - - controller.showSpecies(event); - - expect(event.preventDefault).toHaveBeenCalledWith(); - expect(controller.$.species.show).toHaveBeenCalledWith(); - }); - }); - - describe('onGenusAccept()', () => { - it('should throw an error if the item botanical has no genus name', () => { - jest.spyOn(controller.vnApp, 'showMessage'); - - controller.data = {}; - - controller.onGenusAccept(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the genus can't be empty`); - }); - - it('should add the new genus', () => { - controller.data = { - id: 4, - name: 'Anilius' - }; - - $httpBackend.expectPOST('genera', controller.data).respond(200, controller.data); - - controller.onGenusAccept(); - $httpBackend.flush(); - - controller.onGenusResponse(controller.data); - - expect(controller.botanical.genusFk).toEqual(controller.data.id); - }); - }); - - describe('onSpeciesAccept()', () => { - it('should throw an error if the item botanical has no species name', () => { - jest.spyOn(controller.vnApp, 'showMessage'); - - controller.data = {}; - - controller.onSpeciesAccept(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the species can't be empty`); - }); - - it('should add the new species', () => { - controller.data = { - id: 2, - name: 'Spasiva' - }; - - $httpBackend.expectPOST('species', controller.data).respond(200, controller.data); - - controller.onSpeciesAccept(); - $httpBackend.flush(); - controller.onSpeciesResponse(controller.data); - }); - }); - - describe('onSubmit()', () => { - it('should make HTTP POST request to save the genus and species data', () => { - jest.spyOn(controller.$.watcher, 'updateOriginalData'); - jest.spyOn(controller.$.watcher, 'check'); - jest.spyOn(controller.$.watcher, 'notifySaved'); - - $httpBackend.expectPATCH('ItemBotanicals').respond(); - controller.onSubmit(); - $httpBackend.flush(); - - expect(controller.$.watcher.updateOriginalData).toHaveBeenCalledWith(); - expect(controller.$.watcher.check).toHaveBeenCalledWith(); - expect(controller.$.watcher.notifySaved).toHaveBeenCalledWith(); - }); - }); - - describe('getBotanicalData()', () => { - it('should get the species and genus data references of the item', () => { - controller.getBotanicalData(); - $httpBackend.flush(); - - expect(controller.botanical).toEqual(controller.$params); - }); - }); - }); -}); - diff --git a/modules/item/front/botanical/locale/es.yml b/modules/item/front/botanical/locale/es.yml deleted file mode 100644 index e1234bd71..000000000 --- a/modules/item/front/botanical/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -The genus has been created: El genus ha sido creado -The species has been created: La especie ha sido creada -Latin species name: Nombre de la especie en latín -Latin genus name: Nombre del genus en latín -Species: Especie \ No newline at end of file diff --git a/modules/item/front/card/index.html b/modules/item/front/card/index.html deleted file mode 100644 index 330d274c0..000000000 --- a/modules/item/front/card/index.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/modules/item/front/card/index.js b/modules/item/front/card/index.js deleted file mode 100644 index 2fe42fd04..000000000 --- a/modules/item/front/card/index.js +++ /dev/null @@ -1,33 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - this.$http.get(`Items/${this.$params.id}/getCard`) - .then(res => this.item = res.data); - - this.$http.get('ItemConfigs/findOne') - .then(res => { - if (this.$state.getCurrentPath()[4].state.name === 'item.card.diary') return; - this.warehouseFk = res.data.warehouseFk; - this.getWarehouseName(res.data.warehouseFk); - }); - } - - getWarehouseName(warehouseFk) { - const filter = { - where: {id: warehouseFk} - }; - this.$http.get('Warehouses/findOne', {filter}) - .then(res => { - this.warehouseText = this.$t('WarehouseFk', { - warehouseName: res.data.name - }); - }); - } -} - -ngModule.vnComponent('vnItemCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/card/index.spec.js b/modules/item/front/card/index.spec.js deleted file mode 100644 index 6ebce3d36..000000000 --- a/modules/item/front/card/index.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import './index.js'; - -describe('Item', () => { - describe('Component vnItemCard', () => { - let controller; - let $httpBackend; - let $state; - let data = {id: 1, name: 'fooName'}; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, _$httpBackend_, $stateParams, _$state_) => { - $httpBackend = _$httpBackend_; - $state = _$state_; - $state.getCurrentPath = () => [null, null, null, null, {state: {name: 'item.card.diary'}}]; - - let $element = angular.element('
'); - controller = $componentController('vnItemCard', {$element}); - - $stateParams.id = data.id; - $httpBackend.whenRoute('GET', 'Items/:id/getCard').respond(data); - })); - - it('should request data and set it on the controller', () => { - $httpBackend.expect('GET', `ItemConfigs/findOne`).respond({}); - controller.reload(); - $httpBackend.flush(); - - expect(controller.item).toEqual(data); - }); - }); -}); diff --git a/modules/item/front/create/index.html b/modules/item/front/create/index.html deleted file mode 100644 index b284abf06..000000000 --- a/modules/item/front/create/index.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - -
- - - - - - - - - - - - -
-
{{::code}}
-
{{::name}}
-
-
- {{category.name}} -
-
-
- - -
{{::description}}
-
- #{{::id}} -
-
-
-
- - - - -
- - - - - - -
diff --git a/modules/item/front/create/index.js b/modules/item/front/create/index.js deleted file mode 100644 index 4ca5f8f9f..000000000 --- a/modules/item/front/create/index.js +++ /dev/null @@ -1,40 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.fetchDefaultPriorityTag(); - } - - fetchDefaultPriorityTag() { - this.validPriorities = []; - const filter = {fields: ['defaultPriority', 'defaultTag', 'validPriorities'], limit: 1}; - this.$http.get(`ItemConfigs`, {filter}) - .then(res => { - if (res.data) { - const dataRow = res.data[0]; - dataRow.validPriorities.forEach(priority => { - this.validPriorities.push({priority}); - }); - this.item = { - priority: dataRow.defaultPriority, - tag: dataRow.defaultTag - }; - } - }); - } - - onSubmit() { - this.$.watcher.submit().then( - json => this.$state.go('item.card.basicData', {id: json.data.id}) - ); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnItemCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/create/index.spec.js b/modules/item/front/create/index.spec.js deleted file mode 100644 index 9e54988d7..000000000 --- a/modules/item/front/create/index.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import './index.js'; - -describe('Item', () => { - describe('Component vnItemCreate', () => { - let $scope; - let $state; - let controller; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $state = _$state_; - $scope.watcher = { - submit: () => { - return { - then: callback => { - callback({data: {id: 1}}); - } - }; - } - }; - const $element = angular.element(''); - controller = $componentController('vnItemCreate', {$element, $scope}); - })); - - describe('onSubmit()', () => { - it(`should call submit() on the watcher then expect a callback`, () => { - jest.spyOn($state, 'go'); - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('item.card.basicData', {id: 1}); - }); - }); - }); -}); - diff --git a/modules/item/front/create/locale/es.yml b/modules/item/front/create/locale/es.yml deleted file mode 100644 index 041826e1c..000000000 --- a/modules/item/front/create/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Temporal name: Nombre temporal \ No newline at end of file diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html deleted file mode 100644 index 7fb3b870e..000000000 --- a/modules/item/front/diary/index.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js deleted file mode 100644 index 3d86b0b60..000000000 --- a/modules/item/front/diary/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - async $onInit() { - this.$state.go('item.card.summary', {id: this.$params.id}); - window.location.href = await this.vnApp.getUrl(`item/${this.$params.id}/diary`); - } -} - -ngModule.vnComponent('vnItemDiary', { - template: require('./index.html'), - controller: Controller, - bindings: { - item: '<' - } -}); diff --git a/modules/item/front/fetched-tags/index.html b/modules/item/front/fetched-tags/index.html deleted file mode 100644 index df5936871..000000000 --- a/modules/item/front/fetched-tags/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - -
- {{::$ctrl.item.value5}} -
-
- {{::$ctrl.item.value6}} -
-
- {{::$ctrl.item.value7}} -
-
- {{::$ctrl.item.value8}} -
-
- {{::$ctrl.item.value9}} -
-
- {{::$ctrl.item.value10}} -
-
-
diff --git a/modules/item/front/fetched-tags/index.js b/modules/item/front/fetched-tags/index.js deleted file mode 100644 index e3584be23..000000000 --- a/modules/item/front/fetched-tags/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../module'; -import Component from 'core/lib/component'; -import './style.scss'; - -ngModule.vnComponent('vnFetchedTags', { - template: require('./index.html'), - controller: Component, - bindings: { - maxLength: '<', - item: '<', - } -}); diff --git a/modules/item/front/fetched-tags/style.scss b/modules/item/front/fetched-tags/style.scss deleted file mode 100644 index 250ca07ab..000000000 --- a/modules/item/front/fetched-tags/style.scss +++ /dev/null @@ -1,61 +0,0 @@ -@import "variables"; - -[vn-fetched-tags] { - min-width: 155px; - & [wide] { - width: 430px; - } - & div { - display: flex; - flex-wrap: wrap; - align-items: center; - & vn-one { - min-width: 200px; - overflow: hidden; - text-overflow: ellipsis; - font-size: 1rem; - } - & vn-one h3 { - color: $color-font-secondary; - text-transform: uppercase; - line-height: initial; - font-size: 0.75rem; - margin-bottom: 0px; - } - } -} - -vn-fetched-tags { - & > vn-horizontal { - align-items: center; - max-width: 210px; - & > vn-auto { - flex-wrap: wrap; - - & > .inline-tag { - margin: 1px; - } - } - - & > vn-auto { - display: flex; - - & > .inline-tag { - color: $color-font-secondary; - text-align: center; - font-size: .8rem; - height: 13px; - padding: 1px; - width: 64px; - min-width: 64px; - max-width: 64px; - flex: 1; - border: 1px solid $color-font-secondary; - - &.empty { - border: 1px solid darken($color-font-secondary, 30%); - } - } - } - } -} diff --git a/modules/item/front/fixed-price-search-panel/index.html b/modules/item/front/fixed-price-search-panel/index.html deleted file mode 100644 index 347e65571..000000000 --- a/modules/item/front/fixed-price-search-panel/index.html +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - - - - - - - - - - - - - -
{{name}}
-
- {{category.name}} -
-
-
-
- - - - - - - - - - - - - - - - - - - - Tags - - - - - - - - - - - - - -
- - Id/{{$ctrl.$t('Name')}}: {{$ctrl.filter.search}} - - - {{$ctrl.$t('Category')}}: {{category.selection.name}} - - - {{$ctrl.$t('Type')}}: {{type.selection.name}} - - - {{$ctrl.$t('Buyer')}}: {{buyer.selection.nickname}} - - - {{$ctrl.$t('Warehouse')}}: {{warehouse.selection.name}} - - - {{$ctrl.$t('Started')}}: {{$ctrl.filter.started | date:'dd/MM/yyyy'}} - - - {{$ctrl.$t('Ended')}}: {{$ctrl.filter.ended | date:'dd/MM/yyyy'}} - - - {{$ctrl.$t('For me')}}: {{$ctrl.filter.mine ? '✓' : '✗'}} - - - {{$ctrl.$t('Minimum price')}}: {{$ctrl.filter.hasMinPrice ? '✓' : '✗'}} - - - {{$ctrl.showTagInfo(chipTag)}} - -
-
diff --git a/modules/item/front/fixed-price-search-panel/index.js b/modules/item/front/fixed-price-search-panel/index.js deleted file mode 100644 index 0882eb5ac..000000000 --- a/modules/item/front/fixed-price-search-panel/index.js +++ /dev/null @@ -1,60 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; -import './style.scss'; - -class Controller extends SearchPanel { - constructor($element, $) { - super($element, $); - } - - $onInit() { - this.filter = { - tags: [] - }; - } - - changeCategory(id) { - if (this.filter.categoryFk != id) { - this.filter.categoryFk = id; - this.addFilters(); - } - } - - removeItemFilter(param) { - this.filter[param] = null; - if (param == 'categoryFk') this.filter['typeFk'] = null; - this.addFilters(); - } - - removeTag(tag) { - const index = this.filter.tags.indexOf(tag); - if (index > -1) this.filter.tags.splice(index, 1); - this.addFilters(); - } - - onKeyPress($event) { - if ($event.key === 'Enter') - this.addFilters(); - } - - addFilters() { - for (let i = 0; i < this.filter.tags.length; i++) { - if (!this.filter.tags[i].value) - this.filter.tags.splice(i, 1); - } - return this.model.addFilter({}, this.filter); - } - - showTagInfo(itemTag) { - if (!itemTag.tagFk) return itemTag.value; - return `${this.tags.find(tag => tag.id == itemTag.tagFk).name}: ${itemTag.value}`; - } -} - -ngModule.vnComponent('vnFixedPriceSearchPanel', { - template: require('./index.html'), - controller: Controller, - bindings: { - model: '<' - } -}); diff --git a/modules/item/front/fixed-price-search-panel/index.spec.js b/modules/item/front/fixed-price-search-panel/index.spec.js deleted file mode 100644 index 597bc108e..000000000 --- a/modules/item/front/fixed-price-search-panel/index.spec.js +++ /dev/null @@ -1,56 +0,0 @@ -import './index.js'; - -describe('Item', () => { - describe('Component vnFixedPriceSearchPanel', () => { - let $element; - let controller; - - beforeEach(ngModule('item')); - - beforeEach(angular.mock.inject($componentController => { - $element = angular.element(``); - controller = $componentController('vnFixedPriceSearchPanel', {$element}); - controller.model = {addFilter: () => {}}; - })); - - describe('removeItemFilter()', () => { - it(`should remove param from filter`, () => { - controller.filter = {tags: [], categoryFk: 1, typeFk: 1}; - const expectFilter = {tags: [], categoryFk: null, typeFk: null}; - - controller.removeItemFilter('categoryFk'); - - expect(controller.filter).toEqual(expectFilter); - }); - }); - - describe('removeTag()', () => { - it(`should remove tag from filter`, () => { - const tag = {tagFk: 1, value: 'Value'}; - controller.filter = {tags: [tag]}; - const expectFilter = {tags: []}; - - controller.removeTag(tag); - - expect(controller.filter).toEqual(expectFilter); - }); - }); - - describe('showTagInfo()', () => { - it(`should show tag value`, () => { - const tag = {value: 'Value'}; - const result = controller.showTagInfo(tag); - - expect(result).toEqual('Value'); - }); - - it(`should show tag name and value`, () => { - const tag = {tagFk: 1, value: 'Value'}; - controller.tags = [{id: 1, name: 'tagName'}]; - const result = controller.showTagInfo(tag); - - expect(result).toEqual('tagName: Value'); - }); - }); - }); -}); diff --git a/modules/item/front/fixed-price-search-panel/locale/es.yml b/modules/item/front/fixed-price-search-panel/locale/es.yml deleted file mode 100644 index 06e5e6b26..000000000 --- a/modules/item/front/fixed-price-search-panel/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Started: Inicio -Ended: Fin -Minimum price: Precio mínimo -Item ID: ID Artículo \ No newline at end of file diff --git a/modules/item/front/fixed-price-search-panel/style.scss b/modules/item/front/fixed-price-search-panel/style.scss deleted file mode 100644 index e386033dd..000000000 --- a/modules/item/front/fixed-price-search-panel/style.scss +++ /dev/null @@ -1,71 +0,0 @@ -@import "variables"; - -vn-fixed-price-search-panel vn-side-menu { - .menu { - min-width: $menu-width; - } - & > div { - .input { - padding-left: $spacing-md; - padding-right: $spacing-md; - border-color: $color-spacer; - border-bottom: $border-thin; - } - .horizontal { - padding-left: $spacing-md; - padding-right: $spacing-md; - grid-auto-flow: column; - grid-column-gap: $spacing-sm; - align-items: center; - } - .tags { - padding: $spacing-md; - padding-bottom: 0%; - padding-top: 0%; - align-items: center; - } - .chips { - display: flex; - flex-wrap: wrap; - padding: $spacing-md; - overflow: hidden; - max-width: 100%; - border-color: $color-spacer; - border-top: $border-thin; - } - .item-category { - padding: $spacing-sm; - justify-content: flex-start; - align-items: flex-start; - flex-wrap: wrap; - - vn-autocomplete[vn-id="category"] { - display: none; - } - - & > vn-one { - padding: $spacing-sm; - min-width: 33.33%; - text-align: center; - box-sizing: border-box; - - & > vn-icon { - padding: $spacing-sm; - background-color: $color-font-secondary; - border-radius: 50%; - cursor: pointer; - - &.active { - background-color: $color-main; - color: #fff; - } - & > i:before { - font-size: 2.6rem; - width: 16px; - height: 16px; - } - } - } - } - } -} diff --git a/modules/item/front/fixed-price/index.html b/modules/item/front/fixed-price/index.html deleted file mode 100644 index f1f6e1419..000000000 --- a/modules/item/front/fixed-price/index.html +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - Item ID - - Description - - Grouping price - - Packing price - - Min price - - Started - - Ended - - Warehouse -
- - - - - -
{{id}}
-
- {{name}} -
-
-
-
-
- - {{itemFk.selection.name}} - - -

{{price.subName}}

-
-
- - -
- - - {{price.rate2 | currency: 'EUR':2}} - - - - - - - - - - {{price.rate3 | currency: 'EUR':2}} - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
-
-
-
-
- -
- - - - -
- - - Edit - - {{::$ctrl.totalChecked}} - - buy(s) - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/item/front/fixed-price/index.js b/modules/item/front/fixed-price/index.js deleted file mode 100644 index fe6788e9c..000000000 --- a/modules/item/front/fixed-price/index.js +++ /dev/null @@ -1,254 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.editedColumn; - this.checkAll = false; - this.checkedFixedPrices = []; - - this.smartTableOptions = { - activeButtons: { - search: true - }, - columns: [ - { - field: 'warehouseFk', - autocomplete: { - url: 'Warehouses', - showField: 'name', - valueField: 'id', - } - }, - { - field: 'started', - searchable: false - }, - { - field: 'ended', - searchable: false - } - ] - }; - - this.filterParams = { - warehouseFk: this.vnConfig.warehouseFk - }; - } - - getFilterParams() { - return { - warehouseFk: this.vnConfig.warehouseFk - }; - } - - get columns() { - if (this._columns) return this._columns; - - this._columns = [ - {field: 'rate2', displayName: this.$t('Grouping price')}, - {field: 'rate3', displayName: this.$t('Packing price')}, - {field: 'hasMinPrice', displayName: this.$t('Has min price')}, - {field: 'minPrice', displayName: this.$t('Min price')}, - {field: 'started', displayName: this.$t('Started')}, - {field: 'ended', displayName: this.$t('Ended')}, - {field: 'warehouseFk', displayName: this.$t('Warehouse')} - ]; - - return this._columns; - } - - get checked() { - const fixedPrices = this.$.model.data || []; - const checkedBuys = []; - for (let fixedPrice of fixedPrices) { - if (fixedPrice.checked) - checkedBuys.push(fixedPrice); - } - - return checkedBuys; - } - - uncheck() { - this.checkAll = false; - this.checkedFixedPrices = []; - } - - get totalChecked() { - if (this.checkedDummyCount) - return this.checkedDummyCount; - - return this.checked.length; - } - - saveChecked(fixedPriceId) { - const index = this.checkedFixedPrices.indexOf(fixedPriceId); - if (index !== -1) - return this.checkedFixedPrices.splice(index, 1); - return this.checkedFixedPrices.push(fixedPriceId); - } - - reCheck() { - if (!this.$.model.data) return; - if (!this.checkedFixedPrices.length) return; - - this.$.model.data.forEach(fixedPrice => { - if (this.checkedFixedPrices.includes(fixedPrice.id)) - fixedPrice.checked = true; - }); - } - - onEditAccept() { - const rowsToEdit = []; - for (let row of this.checked) - rowsToEdit.push({id: row.id, itemFk: row.itemFk}); - - const data = { - field: this.editedColumn.field, - newValue: this.editedColumn.newValue, - lines: rowsToEdit - }; - - if (this.checkedDummyCount && this.checkedDummyCount > 0) { - const params = {}; - if (this.$.model.userParams) { - const userParams = this.$.model.userParams; - for (let param in userParams) { - let newParam = this.exprBuilder(param, userParams[param]); - if (!newParam) - newParam = {[param]: userParams[param]}; - Object.assign(params, newParam); - } - } - if (this.$.model.userFilter) - Object.assign(params, this.$.model.userFilter.where); - - data.filter = params; - } - - return this.$http.post('FixedPrices/editFixedPrice', data) - .then(() => { - this.uncheck(); - this.$.model.refresh(); - }); - } - - isBigger(date) { - let today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - - date = new Date(date); - date.setHours(0, 0, 0, 0); - - const timeDifference = today - date; - if (timeDifference < 0) return 'warning'; - } - - isLower(date) { - let today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - - date = new Date(date); - date.setHours(0, 0, 0, 0); - - const timeDifference = today - date; - if (timeDifference > 0) return 'warning'; - } - - add() { - if (!this.$.model.data || this.$.model.data.length == 0) { - this.$.model.data = []; - this.$.model.proxiedData = []; - - const today = Date.vnNew(); - - const millisecsInDay = 86400000; - const daysInWeek = 7; - const nextWeek = new Date(today.getTime() + daysInWeek * millisecsInDay); - - this.$.model.insert({ - started: today, - ended: nextWeek - }); - return; - } - - const lastIndex = this.$.model.data.length - 1; - const lastItem = this.$.model.data[lastIndex]; - this.$.model.insert({ - itemFk: lastItem.itemFk, - name: lastItem.name, - subName: lastItem.subName, - value5: lastItem.value5, - value6: lastItem.value6, - value7: lastItem.value7, - value8: lastItem.value8, - value9: lastItem.value9, - value10: lastItem.value10, - warehouseFk: lastItem.warehouseFk, - rate2: lastItem.rate2, - rate3: lastItem.rate3, - hasMinPrice: lastItem.hasMinPrice, - minPrice: lastItem.minPrice, - started: lastItem.started, - ended: lastItem.ended, - }); - } - - upsertPrice(price, resetMinPrice) { - if (resetMinPrice) - delete price['minPrice']; - - const requiredFields = ['itemFk', 'started', 'ended', 'rate2', 'rate3']; - for (const field of requiredFields) - if (price[field] == undefined) return; - - const query = 'FixedPrices/upsertFixedPrice'; - this.$http.patch(query, price) - .then(res => { - this.vnApp.showSuccess(this.$t('Data saved!')); - Object.assign(price, res.data); - }); - } - - removePrice($index) { - const price = this.$.model.data[$index]; - if (price.id) { - this.$http.delete(`FixedPrices/${price.id}`) - .then(() => { - this.$.model.remove($index); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } else - this.$.model.remove($index); - } - - itemSearchFunc($search) { - return /^\d+$/.test($search) - ? {id: $search} - : {name: {like: '%' + $search + '%'}}; - } - - exprBuilder(param, value) { - switch (param) { - case 'name': - return {'i.name': {like: `%${value}%`}}; - case 'itemFk': - case 'warehouseFk': - case 'rate2': - case 'rate3': - param = `fp.${param}`; - return {[param]: value}; - case 'minPrice': - param = `i.${param}`; - return {[param]: value}; - } - } -} - -ngModule.vnComponent('vnFixedPrice', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/fixed-price/index.spec.js b/modules/item/front/fixed-price/index.spec.js deleted file mode 100644 index ae24da60b..000000000 --- a/modules/item/front/fixed-price/index.spec.js +++ /dev/null @@ -1,173 +0,0 @@ -import './index'; - -describe('fixed price', () => { - describe('Component vnFixedPrice', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { - $httpBackend = _$httpBackend_; - const $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnFixedPrice', {$element, $scope}); - controller.$ = { - model: {refresh: () => {}}, - edit: {hide: () => {}} - }; - })); - - describe('get columns', () => { - it(`should return a set of columns`, () => { - let result = controller.columns; - - let length = result.length; - let anyColumn = Object.keys(result[Math.floor(Math.random() * Math.floor(length))]); - - expect(anyColumn).toContain('field', 'displayName'); - }); - }); - - describe('get checked', () => { - it(`should return a set of checked lines`, () => { - controller.$.model.data = [ - {checked: true, id: 1}, - {checked: true, id: 2}, - {checked: true, id: 3}, - {checked: false, id: 4}, - ]; - - let result = controller.checked; - - expect(result.length).toEqual(3); - }); - }); - - describe('reCheck()', () => { - it(`should recheck buys`, () => { - controller.$.model.data = [ - {checked: false, id: 1}, - {checked: false, id: 2}, - {checked: false, id: 3}, - {checked: false, id: 4}, - ]; - controller.checkedFixedPrices = [1, 2]; - - controller.reCheck(); - - expect(controller.$.model.data[0].checked).toEqual(true); - expect(controller.$.model.data[1].checked).toEqual(true); - expect(controller.$.model.data[2].checked).toEqual(false); - expect(controller.$.model.data[3].checked).toEqual(false); - }); - }); - - describe('saveChecked()', () => { - it(`should check buy`, () => { - const buyCheck = 3; - controller.checkedFixedPrices = [1, 2]; - - controller.saveChecked(buyCheck); - - expect(controller.checkedFixedPrices[2]).toEqual(buyCheck); - }); - - it(`should uncheck buy`, () => { - const buyUncheck = 3; - controller.checkedFixedPrices = [1, 2, 3]; - - controller.saveChecked(buyUncheck); - - expect(controller.checkedFixedPrices[2]).toEqual(undefined); - }); - }); - - describe('onEditAccept()', () => { - it(`should perform a query to update columns`, () => { - controller.editedColumn = {field: 'my field', newValue: 'the new value'}; - const query = 'FixedPrices/editFixedPrice'; - - $httpBackend.expectPOST(query).respond(); - controller.onEditAccept(); - $httpBackend.flush(); - - const result = controller.checked; - - expect(result.length).toEqual(0); - }); - }); - - describe('upsertPrice()', () => { - it('should do nothing if one or more required arguments are missing', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.upsertPrice({}); - - expect(controller.vnApp.showSuccess).not.toHaveBeenCalled(); - }); - - it('should perform an http request to update the price', () => { - const now = Date.vnNew(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - $httpBackend.expectPATCH('FixedPrices/upsertFixedPrice').respond(); - controller.upsertPrice({ - itemFk: 1, - started: now, - ended: now, - rate2: 1, - rate3: 2 - }); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('removePrice()', () => { - it(`should only remove the created instance by the model as it doesn't have an ID yet`, () => { - const $index = 0; - controller.$ = { - model: { - remove: () => {}, - data: [{ - foo: 'bar' - }] - } - }; - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller.$.model, 'remove'); - - $httpBackend.expectGET('Warehouses').respond(); - - controller.removePrice($index); - - expect(controller.vnApp.showSuccess).not.toHaveBeenCalled(); - expect(controller.$.model.remove).toHaveBeenCalled(); - }); - - it('should remove the instance performing an delete http request', () => { - const $index = 0; - controller.$ = { - model: { - remove: () => {}, - data: [{ - id: '1' - }] - } - }; - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller.$.model, 'remove'); - - const query = `FixedPrices/${controller.$.model.data[0].id}`; - $httpBackend.expectDELETE(query).respond(); - controller.removePrice($index); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$.model.remove).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/modules/item/front/fixed-price/locale/es.yml b/modules/item/front/fixed-price/locale/es.yml deleted file mode 100644 index 6dacf96c9..000000000 --- a/modules/item/front/fixed-price/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Fixed prices: Precios fijados -Search prices by item ID or code: Buscar por ID de artículo o código -Search fixed prices: Buscar precios fijados -Add fixed price: Añadir precio fijado -This row will be removed: Esta linea se eliminará -Edit fixed price(s): Editar precio(s) fijado(s) -Has min price: Tiene precio mínimo diff --git a/modules/item/front/fixed-price/style.scss b/modules/item/front/fixed-price/style.scss deleted file mode 100644 index f70ec2f50..000000000 --- a/modules/item/front/fixed-price/style.scss +++ /dev/null @@ -1,46 +0,0 @@ -@import "variables"; -vn-fixed-price{ - smart-table table{ - [shrink-field]{ - width: 90px; - max-width: 90px; - } - [shrink-field-expand]{ - width: 150px; - max-width: 150px; - } - } - - .minPrice { - align-items: center; - text-align: center; - vn-input-number { - width: 75px; - max-width: 75px; - } - } - - smart-table table tbody > * > td .chip { - padding: 0px; - } - - smart-table table tbody > * > td{ - padding: 0px; - padding-left: 5px; - padding-right: 5px; - } - - smart-table table tbody > * > td .chip.warning { - color: $color-font-bg - } - - .vn-field > .container > .infix > .control > input { - color: inherit; - } - - vn-input-number.inactive{ - input { - color: $color-font-light !important; - } - } -} diff --git a/modules/item/front/index.js b/modules/item/front/index.js index 354477d4d..fb1aacd39 100644 --- a/modules/item/front/index.js +++ b/modules/item/front/index.js @@ -1,27 +1,6 @@ export * from './module'; import './main'; -import './index/'; -import './search-panel'; -import './diary'; -import './create'; -import './card'; import './descriptor'; import './descriptor-popover'; -import './basic-data'; -import './fetched-tags'; -import './tags'; -import './tax'; -import './log'; -import './request'; -import './request-search-panel'; -import './last-entries'; -import './botanical'; -import './barcode'; -import './summary'; -import './waste/index/'; -import './fixed-price'; -import './fixed-price-search-panel'; -import './item-type'; -import './item-shelving'; diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html deleted file mode 100644 index 6f5cce7c0..000000000 --- a/modules/item/front/index/index.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Identifier - - Grouping - - Packing - - Description - - Stems - - Size - - Type - - Category - - Intrastat - - Origin - - Buyer - - Weight/Piece - - Multiplier - - Active - - Producer - - Landed -
- - - - {{::item.id}} - - {{::item.grouping | dashIfEmpty}}{{::item.packing | dashIfEmpty}} -
- {{::item.name}} - -

{{::item.subName}}

-
-
- - -
{{::item.stems}}{{::item.size}} - {{::item.typeName}} - - {{::item.category}} - - {{::item.intrastat}} - {{::item.origin}} - - {{::item.userName}} - - {{::item.weightByPiece}}{{::item.stemMultiplier}} - - - {{::item.producer | dashIfEmpty}}{{::item.landed | date:'dd/MM/yyyy'}} - - - - - - -
-
-
-
- - - - - - - - - - - - - - - - - Filter by selection - - - Exclude selection - - - Remove filter - - - Remove all filters - - - \ No newline at end of file diff --git a/modules/item/front/index/index.js b/modules/item/front/index/index.js deleted file mode 100644 index 2bcc2302a..000000000 --- a/modules/item/front/index/index.js +++ /dev/null @@ -1,112 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.smartTableOptions = { - activeButtons: { - search: true, - shownColumns: true, - }, - columns: [ - { - field: 'category', - autocomplete: { - url: 'ItemCategories', - valueField: 'name', - } - }, - { - field: 'origin', - autocomplete: { - url: 'Origins', - showField: 'code', - valueField: 'code' - } - }, - { - field: 'typeFk', - autocomplete: { - url: 'ItemTypes', - } - }, - { - field: 'intrastat', - autocomplete: { - url: 'Intrastats', - showField: 'description', - valueField: 'description' - } - }, - { - field: 'buyerFk', - autocomplete: { - url: 'TicketRequests/getItemTypeWorker', - searchFunction: '{firstName: $search}', - showField: 'nickname', - valueField: 'id', - } - }, - { - field: 'active', - searchable: false - }, - { - field: 'landed', - searchable: false - }, - ] - }; - } - - exprBuilder(param, value) { - switch (param) { - case 'category': - return {'ic.name': value}; - case 'buyerFk': - return {'it.workerFk': value}; - case 'grouping': - return {'b.grouping': value}; - case 'packing': - return {'b.packing': value}; - case 'origin': - return {'ori.code': value}; - case 'typeFk': - return {'i.typeFk': value}; - case 'intrastat': - return {'intr.description': value}; - case 'name': - return {'i.name': {like: `%${value}%`}}; - case 'producer': - return {'pr.name': {like: `%${value}%`}}; - case 'id': - case 'size': - case 'subname': - case 'isActive': - case 'weightByPiece': - case 'stemMultiplier': - case 'stems': - return {[`i.${param}`]: value}; - } - } - - onCloneAccept(itemFk) { - return this.$http.post(`Items/${itemFk}/clone`) - .then(res => { - this.$state.go('item.card.tags', {id: res.data.id}); - }); - } - - preview(item) { - this.itemSelected = item; - this.$.preview.show(); - } -} - -ngModule.vnComponent('vnItemIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/index/index.spec.js b/modules/item/front/index/index.spec.js deleted file mode 100644 index 18abde581..000000000 --- a/modules/item/front/index/index.spec.js +++ /dev/null @@ -1,30 +0,0 @@ -import './index.js'; - -describe('Item', () => { - describe('Component vnItemIndex', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnItemIndex', {$element, $scope}); - })); - - describe('onCloneAccept()', () => { - it('should perform a post query and then call go() then update itemSelected in the controller', () => { - jest.spyOn(controller.$state, 'go'); - - $httpBackend.expectRoute('POST', `Items/:id/clone`).respond({id: 99}); - controller.onCloneAccept(1); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('item.card.tags', {id: 99}); - }); - }); - }); -}); diff --git a/modules/item/front/index/locale/es.yml b/modules/item/front/index/locale/es.yml deleted file mode 100644 index 0d72edd28..000000000 --- a/modules/item/front/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -picture: Foto -Buy requests: Peticiones de compra \ No newline at end of file diff --git a/modules/item/front/index/preview.svg b/modules/item/front/index/preview.svg deleted file mode 100644 index 5d56b5f34..000000000 --- a/modules/item/front/index/preview.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - diff --git a/modules/item/front/index/style.scss b/modules/item/front/index/style.scss deleted file mode 100644 index e9fd9f935..000000000 --- a/modules/item/front/index/style.scss +++ /dev/null @@ -1,34 +0,0 @@ -@import "variables"; - -vn-item-product { - display: block; - - .id { - background-color: $color-main; - color: $color-font-dark; - margin-bottom: 0; - } - .image { - height: 112px; - width: 112px; - - & > img { - max-height: 100%; - max-width: 100%; - border-radius: 3px; - } - } - vn-label-value:first-of-type section{ - margin-top: 9px; - } -} - -vn-item-index { - table { - img { - border-radius: 50%; - width: 50px; - height: 50px; - } - } -} \ No newline at end of file diff --git a/modules/item/front/item-shelving/index.html b/modules/item/front/item-shelving/index.html deleted file mode 100644 index fa7a70544..000000000 --- a/modules/item/front/item-shelving/index.html +++ /dev/null @@ -1,118 +0,0 @@ - - - - - -
-
-
Total
- - -
-
-
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - Created - - Item - - Concept - - Parking - - Shelving - - Etiqueta - - Packing -
- - - {{::itemShelvingPlacementSupplyStock.created | date: 'dd/MM/yyyy'}} - {{::itemShelvingPlacementSupplyStock.itemFk}} - - - {{itemShelvingPlacementSupplyStock.longName}} - - - {{::itemShelvingPlacementSupplyStock.parking}} - - {{::itemShelvingPlacementSupplyStock.shelving}} - - {{(itemShelvingPlacementSupplyStock.stock / itemShelvingPlacementSupplyStock.packing).toFixed(2)}} - - {{::itemShelvingPlacementSupplyStock.packing}} -
-
-
-
- - - - - \ No newline at end of file diff --git a/modules/item/front/item-shelving/index.js b/modules/item/front/item-shelving/index.js deleted file mode 100644 index b8584039b..000000000 --- a/modules/item/front/item-shelving/index.js +++ /dev/null @@ -1,89 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.smartTableOptions = { - activeButtons: { - search: true - }, - columns: [ - { - field: 'parking', - autocomplete: { - url: 'Parkings', - showField: 'code', - valueField: 'code' - } - }, - { - field: 'shelving', - autocomplete: { - url: 'Shelvings', - showField: 'code', - valueField: 'code' - } - }, - { - field: 'created', - searchable: false - }, - { - field: 'itemFk', - searchable: false - }, - { - field: 'longName', - searchable: false - } - ] - }; - } - - get checked() { - const itemShelvings = this.$.model.data || []; - const checkedLines = []; - for (let itemShelving of itemShelvings) { - if (itemShelving.checked) - checkedLines.push(itemShelving.itemShelvingFk); - } - - return checkedLines; - } - - calculateTotals() { - this.labelTotal = 0; - const itemShelvings = this.$.model.data || []; - itemShelvings.forEach(itemShelving => { - const label = itemShelving.stock / itemShelving.packing; - this.labelTotal += label; - }); - } - - onRemove() { - const params = {itemShelvingIds: this.checked}; - const query = `ItemShelvings/deleteItemShelvings`; - this.$http.post(query, params) - .then(() => { - this.vnApp.showSuccess(this.$t('ItemShelvings removed')); - this.$.model.refresh(); - }); - } - - exprBuilder(param, value) { - switch (param) { - case 'parking': - case 'shelving': - case 'label': - case 'packing': - return {[param]: value}; - } - } -} - -ngModule.vnComponent('vnItemShelving', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/item-shelving/index.spec.js b/modules/item/front/item-shelving/index.spec.js deleted file mode 100644 index 55df1c27d..000000000 --- a/modules/item/front/item-shelving/index.spec.js +++ /dev/null @@ -1,81 +0,0 @@ -import './index'; -import crudModel from 'core/mocks/crud-model'; - -describe('item shelving', () => { - describe('Component vnItemShelving', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - const $element = angular.element(''); - controller = $componentController('vnItemShelving', {$element}); - controller.$.model = crudModel; - controller.$.model.data = [ - {itemShelvingFk: 1, packing: 10, stock: 1}, - {itemShelvingFk: 2, packing: 12, stock: 5}, - {itemShelvingFk: 4, packing: 20, stock: 10} - ]; - const modelData = controller.$.model.data; - modelData[0].checked = true; - modelData[1].checked = true; - })); - - describe('checked() getter', () => { - it('should return a the selected rows', () => { - const result = controller.checked; - - expect(result).toEqual(expect.arrayContaining([1, 2])); - }); - }); - - describe('calculateTotals()', () => { - it('should calculate the total of labels', () => { - controller.calculateTotals(); - - expect(controller.labelTotal).toEqual(1.0166666666666666); - }); - }); - - describe('onRemove()', () => { - it('shoud remove the selected lines', () => { - jest.spyOn(controller.$.model, 'refresh'); - const expectedParams = {itemShelvingIds: [1, 2]}; - - $httpBackend.expectPOST('ItemShelvings/deleteItemShelvings', expectedParams).respond(200); - controller.onRemove(); - $httpBackend.flush(); - - expect(controller.$.model.refresh).toHaveBeenCalled(); - }); - }); - - describe('exprBuilder()', () => { - it('should search by parking', () => { - const expr = controller.exprBuilder('parking', '700-01'); - - expect(expr).toEqual({'parking': '700-01'}); - }); - - it('should search by shelving', () => { - const expr = controller.exprBuilder('shelving', 'AAA'); - - expect(expr).toEqual({'shelving': 'AAA'}); - }); - - it('should search by label', () => { - const expr = controller.exprBuilder('label', 0.17); - - expect(expr).toEqual({'label': 0.17}); - }); - - it('should search by packing', () => { - const expr = controller.exprBuilder('packing', 10); - - expect(expr).toEqual({'packing': 10}); - }); - }); - }); -}); diff --git a/modules/item/front/item-shelving/locale/es.yml b/modules/item/front/item-shelving/locale/es.yml deleted file mode 100644 index 006363cfa..000000000 --- a/modules/item/front/item-shelving/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Shelving: Matrícula -Remove selected lines: Eliminar líneas seleccionadas -Selected lines will be deleted: Las líneas seleccionadas serán eliminadas -ItemShelvings removed: Carros eliminados -Total labels: Total etiquetas \ No newline at end of file diff --git a/modules/item/front/item-type/basic-data/index.html b/modules/item/front/item-type/basic-data/index.html deleted file mode 100644 index 1417a05ab..000000000 --- a/modules/item/front/item-type/basic-data/index.html +++ /dev/null @@ -1,62 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/item/front/item-type/basic-data/index.js b/modules/item/front/item-type/basic-data/index.js deleted file mode 100644 index ec280fdf8..000000000 --- a/modules/item/front/item-type/basic-data/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section {} - -ngModule.component('vnItemTypeBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - itemType: '<' - } -}); diff --git a/modules/item/front/item-type/card/index.html b/modules/item/front/item-type/card/index.html deleted file mode 100644 index 80af6088e..000000000 --- a/modules/item/front/item-type/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/item/front/item-type/card/index.js b/modules/item/front/item-type/card/index.js deleted file mode 100644 index fa6b37340..000000000 --- a/modules/item/front/item-type/card/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import ngModule from '../../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - const filter = { - include: [ - {relation: 'worker'}, - {relation: 'category'}, - {relation: 'itemPackingType'}, - {relation: 'temperature'} - ] - }; - - this.$http.get(`ItemTypes/${this.$params.id}`, {filter}) - .then(res => this.itemType = res.data); - } -} - -ngModule.vnComponent('vnItemTypeCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/item-type/card/index.spec.js b/modules/item/front/item-type/card/index.spec.js deleted file mode 100644 index ab2314bb9..000000000 --- a/modules/item/front/item-type/card/index.spec.js +++ /dev/null @@ -1,27 +0,0 @@ -import './index'; - -describe('component vnItemTypeCard', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnItemTypeCard', {$element: null}); - })); - - describe('reload()', () => { - it('should reload the controller data', () => { - controller.$params.id = 1; - - const itemType = {id: 1}; - - $httpBackend.expectGET('ItemTypes/1').respond(itemType); - controller.reload(); - $httpBackend.flush(); - - expect(controller.itemType).toEqual(itemType); - }); - }); -}); diff --git a/modules/item/front/item-type/create/index.html b/modules/item/front/item-type/create/index.html deleted file mode 100644 index 44cb5183d..000000000 --- a/modules/item/front/item-type/create/index.html +++ /dev/null @@ -1,62 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/item/front/item-type/create/index.js b/modules/item/front/item-type/create/index.js deleted file mode 100644 index ccf7744be..000000000 --- a/modules/item/front/item-type/create/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - return this.$.watcher.submit().then(res => - this.$state.go('item.itemType.card.basicData', {id: res.data.id}) - ); - } -} - -ngModule.component('vnItemTypeCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/item-type/create/index.spec.js b/modules/item/front/item-type/create/index.spec.js deleted file mode 100644 index 4b000df9a..000000000 --- a/modules/item/front/item-type/create/index.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -import './index'; - -describe('component vnItemTypeCreate', () => { - let $scope; - let $state; - let controller; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $state = _$state_; - $scope.watcher = { - submit: () => { - return { - then: callback => { - callback({data: {id: '1234'}}); - } - }; - } - }; - const $element = angular.element(''); - controller = $componentController('vnItemTypeCreate', {$element, $scope}); - })); - - describe('onSubmit()', () => { - it(`should call submit() on the watcher then expect a callback`, () => { - jest.spyOn($state, 'go'); - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('item.itemType.card.basicData', {id: '1234'}); - }); - }); -}); diff --git a/modules/item/front/item-type/descriptor/index.html b/modules/item/front/item-type/descriptor/index.html deleted file mode 100644 index 5a0e8ed49..000000000 --- a/modules/item/front/item-type/descriptor/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - -
- - - - - - - - -
-
-
\ No newline at end of file diff --git a/modules/item/front/item-type/descriptor/index.js b/modules/item/front/item-type/descriptor/index.js deleted file mode 100644 index 9322c599a..000000000 --- a/modules/item/front/item-type/descriptor/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import ngModule from '../../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get itemType() { - return this.entity; - } - - set itemType(value) { - this.entity = value; - } -} - -ngModule.component('vnItemTypeDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - itemType: '<' - } -}); diff --git a/modules/item/front/item-type/index.js b/modules/item/front/item-type/index.js deleted file mode 100644 index 5dcbe4097..000000000 --- a/modules/item/front/item-type/index.js +++ /dev/null @@ -1,8 +0,0 @@ -import './main'; -import './index/'; -import './summary'; -import './card'; -import './descriptor'; -import './create'; -import './basic-data'; -import './search-panel'; diff --git a/modules/item/front/item-type/index/index.html b/modules/item/front/item-type/index/index.html deleted file mode 100644 index 50b9eb172..000000000 --- a/modules/item/front/item-type/index/index.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/item/front/item-type/index/index.js b/modules/item/front/item-type/index/index.js deleted file mode 100644 index 54ecba997..000000000 --- a/modules/item/front/item-type/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(itemType) { - this.selectedItemType = itemType; - this.$.summary.show(); - } -} - -ngModule.component('vnItemTypeIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/item-type/index/index.spec.js b/modules/item/front/item-type/index/index.spec.js deleted file mode 100644 index 887c03f7f..000000000 --- a/modules/item/front/item-type/index/index.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -import './index'; - -describe('Item', () => { - describe('Component vnItemTypeIndex', () => { - let controller; - let $window; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, _$window_) => { - $window = _$window_; - const $element = angular.element(''); - controller = $componentController('vnItemTypeIndex', {$element}); - })); - - describe('preview()', () => { - it('should show the dialog summary', () => { - controller.$.summary = {show: () => {}}; - jest.spyOn(controller.$.summary, 'show'); - - const itemType = {id: 1}; - - const event = new MouseEvent('click', { - view: $window, - bubbles: true, - cancelable: true - }); - controller.preview(event, itemType); - - expect(controller.$.summary.show).toHaveBeenCalledWith(); - }); - }); - }); -}); diff --git a/modules/item/front/item-type/index/locale/es.yml b/modules/item/front/item-type/index/locale/es.yml deleted file mode 100644 index 1a71ff212..000000000 --- a/modules/item/front/item-type/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Item Type: Familia -New itemType: Nueva familia \ No newline at end of file diff --git a/modules/item/front/item-type/main/index.html b/modules/item/front/item-type/main/index.html deleted file mode 100644 index faba696c0..000000000 --- a/modules/item/front/item-type/main/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/modules/item/front/item-type/main/index.js b/modules/item/front/item-type/main/index.js deleted file mode 100644 index 0dea00abb..000000000 --- a/modules/item/front/item-type/main/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import ngModule from '../../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class ItemType extends ModuleMain { - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {or: [ - {name: {like: `%${value}%`}}, - {code: {like: `%${value}%`}} - ]}; - case 'name': - case 'code': - return {[param]: {like: `%${value}%`}}; - } - } -} - -ngModule.vnComponent('vnItemType', { - controller: ItemType, - template: require('./index.html') -}); diff --git a/modules/item/front/item-type/main/index.spec.js b/modules/item/front/item-type/main/index.spec.js deleted file mode 100644 index dcb14ec0e..000000000 --- a/modules/item/front/item-type/main/index.spec.js +++ /dev/null @@ -1,31 +0,0 @@ -import './index'; - -describe('Item', () => { - describe('Component vnItemType', () => { - let controller; - - beforeEach(ngModule('item')); - - beforeEach(inject($componentController => { - const $element = angular.element(''); - controller = $componentController('vnItemType', {$element}); - })); - - describe('exprBuilder()', () => { - it('should return a filter based on a search by id', () => { - const filter = controller.exprBuilder('search', '123'); - - expect(filter).toEqual({id: '123'}); - }); - - it('should return a filter based on a search by name or code', () => { - const filter = controller.exprBuilder('search', 'Alstroemeria'); - - expect(filter).toEqual({or: [ - {name: {like: '%Alstroemeria%'}}, - {code: {like: '%Alstroemeria%'}}, - ]}); - }); - }); - }); -}); diff --git a/modules/item/front/item-type/main/locale/es.yml b/modules/item/front/item-type/main/locale/es.yml deleted file mode 100644 index 7aceac46f..000000000 --- a/modules/item/front/item-type/main/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Search itemType by id, name or code: Buscar familia por id, nombre o código \ No newline at end of file diff --git a/modules/item/front/item-type/search-panel/index.html b/modules/item/front/item-type/search-panel/index.html deleted file mode 100644 index 4aa762900..000000000 --- a/modules/item/front/item-type/search-panel/index.html +++ /dev/null @@ -1,22 +0,0 @@ -
-
- - - - - - - - - - - -
-
\ No newline at end of file diff --git a/modules/item/front/item-type/search-panel/index.js b/modules/item/front/item-type/search-panel/index.js deleted file mode 100644 index 17a439c39..000000000 --- a/modules/item/front/item-type/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.component('vnItemTypeSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/item/front/item-type/summary/index.html b/modules/item/front/item-type/summary/index.html deleted file mode 100644 index d003c8f38..000000000 --- a/modules/item/front/item-type/summary/index.html +++ /dev/null @@ -1,50 +0,0 @@ - -
- {{summary.id}} - {{summary.name}} - {{summary.worker.firstName}} {{summary.worker.lastName}} -
- - -

Basic data

- - - - - - - - - - - - - - - - - - - - -
-
-
\ No newline at end of file diff --git a/modules/item/front/item-type/summary/index.js b/modules/item/front/item-type/summary/index.js deleted file mode 100644 index 7645de8b1..000000000 --- a/modules/item/front/item-type/summary/index.js +++ /dev/null @@ -1,33 +0,0 @@ -import ngModule from '../../module'; -import Component from 'core/lib/component'; - -class Controller extends Component { - set itemType(value) { - this._itemType = value; - this.$.summary = null; - if (!value) return; - - const filter = { - include: [ - {relation: 'worker'}, - {relation: 'category'}, - {relation: 'itemPackingType'}, - {relation: 'temperature'} - ] - }; - this.$http.get(`ItemTypes/${value.id}`, {filter}) - .then(res => this.$.summary = res.data); - } - - get itemType() { - return this._itemType; - } -} - -ngModule.component('vnItemTypeSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - itemType: '<' - } -}); diff --git a/modules/item/front/item-type/summary/locale/es.yml b/modules/item/front/item-type/summary/locale/es.yml deleted file mode 100644 index 8f4cef70f..000000000 --- a/modules/item/front/item-type/summary/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Life: Vida -Promo: Promoción -Item packing type: Tipo de embalaje -Is unconventional size: Es de tamaño poco convencional \ No newline at end of file diff --git a/modules/item/front/last-entries/index.html b/modules/item/front/last-entries/index.html deleted file mode 100644 index e3b84655c..000000000 --- a/modules/item/front/last-entries/index.html +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - Ig - Warehouse - Landed - Entry - PVP - Label - Packing - Grouping - Stems - Quantity - Cost - Kg. - Cube - Provider - - - - - - - - - {{::entry.warehouse| dashIfEmpty}} - {{::entry.landed | date:'dd/MM/yyyy HH:mm'}} - - - {{::entry.entryFk | dashIfEmpty}} - - - - {{::entry.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::entry.price3 | currency: 'EUR':2 | dashIfEmpty}} - - {{entry.stickers | dashIfEmpty}} - - - {{::entry.packing | dashIfEmpty}} - - - - - {{::entry.grouping | dashIfEmpty}} - - - {{::entry.stems | dashIfEmpty}} - {{::entry.quantity}} - - - {{::entry.cost | currency: 'EUR':3 | dashIfEmpty}} - - - {{::entry.weight | dashIfEmpty}} - {{::entry.packagingFk | dashIfEmpty}} - {{::entry.supplier | dashIfEmpty}} - - - - - - - - - - - - - - Filter by selection - - - Exclude selection - - - Remove filter - - - Remove all filters - - - Copy value - - - diff --git a/modules/item/front/last-entries/index.js b/modules/item/front/last-entries/index.js deleted file mode 100644 index a5f1f4d9d..000000000 --- a/modules/item/front/last-entries/index.js +++ /dev/null @@ -1,105 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - - const from = Date.vnNew(); - from.setDate(from.getDate() - 75); - from.setHours(0, 0, 0, 0); - - const to = Date.vnNew(); - to.setDate(to.getDate() + 10); - to.setHours(23, 59, 59, 59); - - this.filter = { - where: { - itemFk: this.$params.id, - landed: { - between: [from, to] - } - } - }; - this._dateFrom = from; - this._dateTo = to; - } - - set dateFrom(value) { - this._dateFrom = value; - - if (!value) return; - - const from = new Date(value); - from.setHours(0, 0, 0, 0); - - const to = new Date(this._dateTo); - to.setHours(23, 59, 59, 59); - - this.filter.where.landed = { - between: [from, to] - }; - this.$.model.refresh(); - } - - set dateTo(value) { - this._dateTo = value; - - if (!value) return; - - const from = new Date(this._dateFrom); - from.setHours(0, 0, 0, 0); - - const to = new Date(value); - to.setHours(23, 59, 59, 59); - - this.filter.where.landed = { - between: [from, to] - }; - this.$.model.refresh(); - } - - get dateFrom() { - return this._dateFrom; - } - - get dateTo() { - return this._dateTo; - } - - exprBuilder(param, value) { - switch (param) { - case 'id': - case 'quantity': - case 'packagingFk': - return {[`b.${param}`]: value}; - case 'supplierFk': - return {[`s.id`]: value}; - case 'warehouseFk': - return {'tr.warehouseInFk': value}; - case 'landed': - return {'tr.landed': { - between: this.dateRange(value)} - }; - } - } - - dateRange(value) { - const minHour = new Date(value); - minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(value); - maxHour.setHours(23, 59, 59, 59); - - return [minHour, maxHour]; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnItemLastEntries', { - template: require('./index.html'), - controller: Controller, - bindings: { - item: '<' - } -}); diff --git a/modules/item/front/last-entries/locale/es.yml b/modules/item/front/last-entries/locale/es.yml deleted file mode 100644 index f2917bb63..000000000 --- a/modules/item/front/last-entries/locale/es.yml +++ /dev/null @@ -1,15 +0,0 @@ -Since: Desde -Landed: F. entrega -Stems: Tallos -Quantity: Cantidad -Cost: Coste -Label: Etiquetas -Entry: Entrada -Ignored: Ignorado -Provider: Proveedor -Cube: Cubo -Price Per Unit: Precio Por Unidad -Price Per Package: Precio Por Paquete -Freight: Porte -Package: Embalaje -Comission: Comision \ No newline at end of file diff --git a/modules/item/front/main/index.html b/modules/item/front/main/index.html index 44d125758..e69de29bb 100644 --- a/modules/item/front/main/index.html +++ b/modules/item/front/main/index.html @@ -1,23 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/modules/item/front/main/index.js b/modules/item/front/main/index.js index 1d99c91a1..33e5822c3 100644 --- a/modules/item/front/main/index.js +++ b/modules/item/front/main/index.js @@ -3,11 +3,10 @@ import ModuleMain from 'salix/components/module-main'; export default class Items extends ModuleMain { constructor($element, $) { super($element, $); - - this.filterParams = { - isActive: true, - isFloramondo: false - }; + } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`claim/`); } } diff --git a/modules/item/front/request-search-panel/index.html b/modules/item/front/request-search-panel/index.html deleted file mode 100644 index 6a51a429d..000000000 --- a/modules/item/front/request-search-panel/index.html +++ /dev/null @@ -1,104 +0,0 @@ -
- - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - Or - - - - - -
- - - - - {{name}} - - - - - -
-
diff --git a/modules/item/front/request-search-panel/index.js b/modules/item/front/request-search-panel/index.js deleted file mode 100644 index 556bdd874..000000000 --- a/modules/item/front/request-search-panel/index.js +++ /dev/null @@ -1,48 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -class Controller extends SearchPanel { - constructor($element, $) { - super($element, $); - - this.states = [ - {code: 'pending', name: this.$t('Pending')}, - {code: 'accepted', name: this.$t('Accepted')}, - {code: 'denied', name: this.$t('Denied')} - ]; - } - - get from() { - return this._from; - } - - set from(value) { - this._from = value; - this.filter.scopeDays = null; - } - - get to() { - return this._to; - } - - set to(value) { - this._to = value; - this.filter.scopeDays = null; - } - - get scopeDays() { - return this._scopeDays; - } - - set scopeDays(value) { - this._scopeDays = value; - - this.filter.from = null; - this.filter.to = null; - } -} - -ngModule.vnComponent('vnRequestSearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/request-search-panel/index.spec.js b/modules/item/front/request-search-panel/index.spec.js deleted file mode 100644 index 56c76eabf..000000000 --- a/modules/item/front/request-search-panel/index.spec.js +++ /dev/null @@ -1,48 +0,0 @@ -import './index'; - -describe(' Component vnRequestSearchPanel', () => { - let controller; - - beforeEach(ngModule('item')); - - beforeEach(inject($componentController => { - controller = $componentController('vnRequestSearchPanel', {$element: null}); - controller.$t = () => {}; - controller.filter = {}; - })); - - describe('from() setter', () => { - it('should clear the scope days when setting the from property', () => { - controller.filter.scopeDays = 1; - - controller.from = Date.vnNew(); - - expect(controller.filter.scopeDays).toBeNull(); - expect(controller.from).toBeDefined(); - }); - }); - - describe('to() setter', () => { - it('should clear the scope days when setting the to property', () => { - controller.filter.scopeDays = 1; - - controller.to = Date.vnNew(); - - expect(controller.filter.scopeDays).toBeNull(); - expect(controller.to).toBeDefined(); - }); - }); - - describe('scopeDays() setter', () => { - it('should clear the date range when setting the scopeDays property', () => { - controller.filter.from = Date.vnNew(); - controller.filter.to = Date.vnNew(); - - controller.scopeDays = 1; - - expect(controller.filter.from).toBeNull(); - expect(controller.filter.to).toBeNull(); - expect(controller.scopeDays).toBeDefined(); - }); - }); -}); diff --git a/modules/item/front/request-search-panel/locale/es.yml b/modules/item/front/request-search-panel/locale/es.yml deleted file mode 100644 index 8d5276194..000000000 --- a/modules/item/front/request-search-panel/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Ink: Tinta -Origin: Origen -Producer: Productor -For me: Para mi \ No newline at end of file diff --git a/modules/item/front/request/index.html b/modules/item/front/request/index.html deleted file mode 100644 index 03c8db8ec..000000000 --- a/modules/item/front/request/index.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - - - - - Ticket ID - Shipped - Description - Requester - Requested - Price - Atender - Item - Achieved - Concept - State - - - - - - - - {{request.ticketFk}} - - - - - {{::request.shipped | date: 'dd/MM/yyyy'}} - - - {{::request.description}} - - - {{::request.requesterName}} - - - {{::request.quantity}} - {{::request.price | currency: 'EUR':2}} - - - {{::request.attenderName}} - - - - {{request.itemFk}} - - - - - - - {{request.saleQuantity}} - - - - - - - - {{request.itemDescription}} - - - {{$ctrl.getState(request.isOk)}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Filter by selection - - - Exclude selection - - - Remove filter - - - Remove all filters - - - Copy value - - - diff --git a/modules/item/front/request/index.js b/modules/item/front/request/index.js deleted file mode 100644 index 747cbeff2..000000000 --- a/modules/item/front/request/index.js +++ /dev/null @@ -1,143 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - - if (!this.$state.q) { - const today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - - const nextWeek = Date.vnNew(); - nextWeek.setHours(23, 59, 59, 59); - nextWeek.setDate(nextWeek.getDate() + 7); - - this.filterParams = { - from: today, - to: nextWeek, - state: 'pending' - }; - } - } - - fetchParams($params) { - if (!Object.entries($params).length) - $params.scopeDays = 1; - - if (typeof $params.scopeDays === 'number') { - const from = Date.vnNew(); - from.setHours(0, 0, 0, 0); - - const to = new Date(from.getTime()); - to.setDate(to.getDate() + $params.scopeDays); - to.setHours(23, 59, 59, 999); - - Object.assign($params, {from, to}); - } - - return $params; - } - - getState(isOk) { - if (isOk === null) - return 'Pending'; - else if (isOk) - return 'Accepted'; - else - return 'Denied'; - } - - confirmRequest(request) { - if (request.itemFk && request.saleQuantity) { - let params = { - itemFk: request.itemFk, - quantity: request.saleQuantity - }; - - let query = `TicketRequests/${request.id}/confirm`; - this.$http.post(query, params).then(res => { - request.itemDescription = res.data.concept; - request.isOk = true; - - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - } - - changeQuantity(request) { - if (request.saleFk) { - let params = { - quantity: request.saleQuantity - }; - - let endpoint = `Sales/${request.saleFk}`; - - this.$http.patch(endpoint, params) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) - .then(() => this.confirmRequest(request)); - } else - this.confirmRequest(request); - } - - compareDate(date) { - let today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - let timeTicket = new Date(date); - timeTicket.setHours(0, 0, 0, 0); - - let comparation = today - timeTicket; - - if (comparation == 0) - return 'warning'; - if (comparation < 0) - return 'success'; - } - - onDenyAccept(request) { - let params = { - observation: this.denyObservation - }; - - return this.$http.post(`TicketRequests/${request.id}/deny`, params) - .then(res => { - const newRequest = res.data; - request.isOk = newRequest.isOk; - request.attenderFk = newRequest.attenderFk; - request.response = newRequest.response; - - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - exprBuilder(param, value) { - switch (param) { - case 'ticketFk': - case 'quantity': - case 'price': - case 'isOk': - return {[`tr.${param}`]: value}; - case 'attenderName': - return {[`ua.name`]: value}; - case 'shipped': - return {'t.shipped': { - between: this.dateRange(value)} - }; - } - } - - dateRange(value) { - const minHour = new Date(value); - minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(value); - maxHour.setHours(23, 59, 59, 59); - - return [minHour, maxHour]; - } -} - -ngModule.vnComponent('vnItemRequest', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/request/index.spec.js b/modules/item/front/request/index.spec.js deleted file mode 100644 index aadeaddca..000000000 --- a/modules/item/front/request/index.spec.js +++ /dev/null @@ -1,120 +0,0 @@ -import './index.js'; - -describe('Item', () => { - describe('Component vnItemRequest', () => { - let $scope; - let controller; - let $httpBackend; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - controller = $componentController('vnItemRequest', {$element: null, $scope}); - })); - - afterAll(() => { - $scope.$destroy(); - $element.remove(); - }); - - describe('getState()', () => { - it(`should return an string depending to the isOK value`, () => { - let isOk = null; - let result = controller.getState(isOk); - - expect(result).toEqual('Pending'); - - isOk = 1; - result = controller.getState(isOk); - - expect(result).toEqual('Accepted'); - - isOk = 0; - result = controller.getState(isOk); - - expect(result).toEqual('Denied'); - }); - }); - - describe('confirmRequest()', () => { - it(`should do nothing if the request does't have itemFk or saleQuantity`, () => { - let request = {}; - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.confirmRequest(request); - - expect(controller.vnApp.showSuccess).not.toHaveBeenCalled(); - }); - - it('should perform a query and call vnApp.showSuccess() and refresh if the conditions are met', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - const expectedResult = {concept: 'Melee Weapon'}; - let request = {itemFk: 1, saleQuantity: 1, id: 1}; - - $httpBackend.expectPOST(`TicketRequests/${request.id}/confirm`).respond(expectedResult); - controller.confirmRequest(request); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('changeQuantity()', () => { - it(`should call confirmRequest() if there's no sale id in the request`, () => { - let request = {}; - jest.spyOn(controller, 'confirmRequest'); - - controller.changeQuantity(request); - - expect(controller.confirmRequest).toHaveBeenCalledWith(jasmine.any(Object)); - }); - - it(`should perform a query and call vnApp.showSuccess() if the conditions are met`, () => { - let request = {saleFk: 1, saleQuantity: 1}; - jest.spyOn(controller.vnApp, 'showSuccess'); - - $httpBackend.expectPATCH(`Sales/${request.saleFk}`).respond(); - controller.changeQuantity(request); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('compareDate()', () => { - it(`should return "success" if receives a future date`, () => { - let date = '3019-02-18T11:00:00.000Z'; - let result = controller.compareDate(date); - - expect(result).toEqual('success'); - }); - - it(`should return "warning" if date is today`, () => { - let date = Date.vnNew(); - let result = controller.compareDate(date); - - expect(result).toEqual('warning'); - }); - }); - - describe('onDenyAccept()', () => { - it(`should deny the request`, () => { - const request = { - id: 1, - response: 'new' - }; - - $httpBackend.expectPOST(`TicketRequests/${request.id}/deny`) - .respond({response: 'denied'}); - controller.onDenyAccept(request); - $httpBackend.flush(); - - expect(request.response).toBe('denied'); - }); - }); - }); -}); - diff --git a/modules/item/front/request/locale/es.yml b/modules/item/front/request/locale/es.yml deleted file mode 100644 index c61a00130..000000000 --- a/modules/item/front/request/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Discard: Descartar -Specify the reasons to deny this request: Especifica las razones para descartar la petición -Buy requests: Peticiones de compra -Search request by id or alias: Buscar peticiones por identificador o alias -Requested: Solicitado -Achieved: Conseguido -Pending: Pendiente -Accepted: Aceptada -Denied: Rechazada \ No newline at end of file diff --git a/modules/item/front/request/style.scss b/modules/item/front/request/style.scss deleted file mode 100644 index 59612bbd6..000000000 --- a/modules/item/front/request/style.scss +++ /dev/null @@ -1,15 +0,0 @@ -@import "variables"; - -vn-item-request { - vn-dialog[vn-id="denyReason"] { - button.close { - display: none - } - vn-button { - margin: 0 auto - } - vn-textarea { - width: 100% - } - } -} \ No newline at end of file diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 4b7cd1490..3d04e1c8b 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -6,25 +6,7 @@ "dependencies": ["worker", "client", "ticket"], "menus": { "main": [ - {"state": "item.index", "icon": "icon-item"}, - {"state": "item.request", "icon": "icon-buyrequest"}, - {"state": "item.waste.index", "icon": "icon-claims"}, - {"state": "item.fixedPrice", "icon": "icon-fixedPrice"}, - {"state": "item.itemType", "icon": "contact_support"} - ], - "card": [ - {"state": "item.card.basicData", "icon": "settings"}, - {"state": "item.card.tags", "icon": "icon-tags"}, - {"state": "item.card.last-entries", "icon": "icon-regentry"}, - {"state": "item.card.tax", "icon": "icon-tax"}, - {"state": "item.card.botanical", "icon": "local_florist"}, - {"state": "item.card.shelving", "icon": "icon-inventory"}, - {"state": "item.card.itemBarcode", "icon": "icon-barcode"}, - {"state": "item.card.diary", "icon": "icon-transaction"}, - {"state": "item.card.log", "icon": "history"} - ], - "itemType": [ - {"state": "item.itemType.card.basicData", "icon": "settings"} + {"state": "item.index", "icon": "icon-item"} ] }, "keybindings": [ @@ -44,187 +26,11 @@ "component": "vn-item-index", "description": "Items" }, - { - "url": "/create", - "state": "item.create", - "component": "vn-item-create", - "description": "New item" - }, { "url": "/:id", "state": "item.card", "abstract": true, "component": "vn-item-card" - }, - { - "url" : "/basic-data", - "state": "item.card.basicData", - "component": "vn-item-basic-data", - "description": "Basic data", - "params": { - "item": "$ctrl.item" - }, - "acl": ["buyer"] - }, - { - "url" : "/tags", - "state": "item.card.tags", - "component": "vn-item-tags", - "description": "Tags", - "params": { - "item-tags": "$ctrl.itemTags" - }, - "acl": ["buyer", "replenisher"] - }, - { - "url" : "/tax", - "state": "item.card.tax", - "component": "vn-item-tax", - "description": "Tax", - "acl": ["administrative","buyer"] - }, - { - "url" : "/botanical", - "state": "item.card.botanical", - "component": "vn-item-botanical", - "description": "Botanical", - "params": { - "item": "$ctrl.item" - }, - "acl": ["buyer"] - }, - { - "url" : "/shelving", - "state": "item.card.shelving", - "component": "vn-item-shelving", - "description": "Shelvings", - "params": { - "item": "$ctrl.item" - }, - "acl": ["employee"] - }, - { - "url" : "/barcode", - "state": "item.card.itemBarcode", - "component": "vn-item-barcode", - "description": "Barcodes", - "params": { - "item": "$ctrl.item" - }, - "acl": ["buyer","replenisher"] - }, - { - "url" : "/summary", - "state": "item.card.summary", - "component": "vn-item-summary", - "description": "Summary", - "params": { - "item": "$ctrl.item" - } - }, - { - "url" : "/diary?warehouseFk&lineFk", - "state": "item.card.diary", - "component": "vn-item-diary", - "description": "Diary", - "params": { - "item": "$ctrl.item" - }, - "acl": ["employee"] - }, - { - "url" : "/last-entries", - "state": "item.card.last-entries", - "component": "vn-item-last-entries", - "description": "Last entries", - "params": { - "item": "$ctrl.item" - }, - "acl": ["employee"] - }, - { - "url" : "/log", - "state": "item.card.log", - "component": "vn-item-log", - "description": "Log" - }, - { - "url" : "/request?q", - "state": "item.request", - "component": "vn-item-request", - "description": "Buy requests", - "params": { - "item": "$ctrl.item" - }, - "acl": ["employee"] - }, - { - "url": "/waste", - "state": "item.waste", - "component": "ui-view", - "abstract": true - }, - { - "url" : "/index", - "state": "item.waste.index", - "component": "vn-item-waste-index", - "description": "Waste breakdown", - "acl": ["buyer"] - }, - { - "url" : "/detail?buyer&family", - "state": "item.waste.detail", - "component": "vn-item-waste-detail", - "description": "Waste breakdown by item", - "acl": ["buyer"] - }, - { - "url" : "/fixed-price?q", - "state": "item.fixedPrice", - "component": "vn-fixed-price", - "description": "Fixed prices", - "acl": ["buyer"] - }, - { - "url" : "/item-type?q", - "state": "item.itemType", - "component": "vn-item-type", - "description": "Item Type", - "acl": ["buyer"] - }, - { - "url": "/create", - "state": "item.itemType.create", - "component": "vn-item-type-create", - "description": "New itemType", - "acl": ["buyer"] - }, - { - "url": "/:id", - "state": "item.itemType.card", - "component": "vn-item-type-card", - "abstract": true, - "description": "Detail" - }, - { - "url": "/summary", - "state": "item.itemType.card.summary", - "component": "vn-item-type-summary", - "description": "Summary", - "params": { - "item-type": "$ctrl.itemType" - }, - "acl": ["buyer"] - }, - { - "url": "/basic-data", - "state": "item.itemType.card.basicData", - "component": "vn-item-type-basic-data", - "description": "Basic data", - "params": { - "item-type": "$ctrl.itemType" - }, - "acl": ["buyer"] } ] } diff --git a/modules/item/front/search-panel/index.html b/modules/item/front/search-panel/index.html deleted file mode 100644 index 33f141b18..000000000 --- a/modules/item/front/search-panel/index.html +++ /dev/null @@ -1,181 +0,0 @@ - -
-
- - - - - - - - - -
{{name}}
-
- {{category.name}} -
-
> -
-
- - - - - {{name}}: {{nickname}} - - - - - Tags - - - - - - - - - - - - - - - - - More fields - - - - - - - - -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- - - - - - - -
-
diff --git a/modules/item/front/search-panel/index.js b/modules/item/front/search-panel/index.js deleted file mode 100644 index 2448728be..000000000 --- a/modules/item/front/search-panel/index.js +++ /dev/null @@ -1,67 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -class Controller extends SearchPanel { - constructor($element, $) { - super($element, $); - let model = 'Item'; - let moreFields = ['id', 'description', 'name', 'isActive']; - - let properties; - let validations = window.validations; - - if (validations && validations[model]) - properties = validations[model].properties; - else - properties = {}; - - this.moreFields = []; - for (let field of moreFields) { - let prop = properties[field]; - this.moreFields.push({ - name: field, - label: prop ? prop.description : field, - type: prop ? prop.type : null - }); - } - } - - get filter() { - let filter = this.$.filter; - - for (let fieldFilter of this.fieldFilters) - filter[fieldFilter.name] = fieldFilter.value; - - return filter; - } - - set filter(value) { - if (!value) - value = {}; - if (!value.tags) - value.tags = [{}]; - - this.fieldFilters = []; - for (let field of this.moreFields) { - if (value[field.name] != undefined) { - this.fieldFilters.push({ - name: field.name, - value: value[field.name], - info: field - }); - } - } - - this.$.filter = value; - } - - removeField(index, field) { - this.fieldFilters.splice(index, 1); - delete this.$.filter[field]; - } -} - -ngModule.vnComponent('vnItemSearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/search-panel/index.spec.js b/modules/item/front/search-panel/index.spec.js deleted file mode 100644 index 39b5b7aa5..000000000 --- a/modules/item/front/search-panel/index.spec.js +++ /dev/null @@ -1,60 +0,0 @@ -import './index.js'; - -describe('Item', () => { - describe('Component vnItemSearchPanel', () => { - let $element; - let controller; - - beforeEach(ngModule('item')); - - beforeEach(inject($componentController => { - $element = angular.element(`
`); - controller = $componentController('vnItemSearchPanel', {$element}); - })); - - describe('filter() setter', () => { - it(`should set the tags property to the scope filter with an empty array`, () => { - const expectedFilter = { - tags: [{}] - }; - controller.filter = null; - - expect(controller.filter).toEqual(expectedFilter); - }); - - it(`should set the tags property to the scope filter with an array of tags`, () => { - const expectedFilter = { - description: 'My item', - tags: [{}] - }; - const expectedFieldFilter = [{ - info: { - label: 'description', - name: 'description', - type: null - }, - name: 'description', - value: 'My item' - }]; - controller.filter = { - description: 'My item' - }; - - expect(controller.filter).toEqual(expectedFilter); - expect(controller.fieldFilters).toEqual(expectedFieldFilter); - }); - }); - - describe('removeField()', () => { - it(`should remove the description property from the fieldFilters and from the scope filter`, () => { - const expectedFilter = {tags: [{}]}; - controller.filter = {description: 'My item'}; - - controller.removeField(0, 'description'); - - expect(controller.filter).toEqual(expectedFilter); - expect(controller.fieldFilters).toEqual([]); - }); - }); - }); -}); diff --git a/modules/item/front/search-panel/locale/es.yml b/modules/item/front/search-panel/locale/es.yml deleted file mode 100644 index 67a5200d7..000000000 --- a/modules/item/front/search-panel/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -Ink: Tinta -Origin: Origen -Producer: Productor -With visible: Con visible -Field: Campo -More fields: Más campos -Add field: Añadir campo -Remove field: Quitar campo \ No newline at end of file diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html deleted file mode 100644 index 0e4cfc955..000000000 --- a/modules/item/front/summary/index.html +++ /dev/null @@ -1,227 +0,0 @@ - -
- - - - {{$ctrl.item.id}} - {{$ctrl.summary.item.name}} -
- - - - - -

Visible

-

{{$ctrl.summary.visible}}

-
- -

Available

-

{{$ctrl.summary.available}}

-
- -

- - -

-
-
-
- -

- - Basic data - -

-

- Basic data -

- - - - - - - - - - - - - - - - - {{$ctrl.summary.item.itemType.worker.user.name}} - - - - - - -
- -

- - Other data - -

-

- Other data -

- - - - - - - - - - - - - - - - - - - - -
- -

- - Tags - -

-

- Tags -

- - -
- -

- - Description - -

-

- Description -

-

- {{$ctrl.summary.item.description}} -

-
- -

- - Tax - -

-

- Tax -

- - -
- -

- - Botanical - -

-

- Botanical -

- - - - -
- -

- - Barcode - -

-

- Barcode -

-

- {{barcode.code}} -

-
-
-
- - diff --git a/modules/item/front/summary/index.js b/modules/item/front/summary/index.js deleted file mode 100644 index e17a6a8c4..000000000 --- a/modules/item/front/summary/index.js +++ /dev/null @@ -1,61 +0,0 @@ -import ngModule from '../module'; -import Summary from 'salix/components/summary'; -import './style.scss'; - -class Controller extends Summary { - getSummary() { - this.$http.get(`Items/${this.item.id}/getSummary`).then(response => { - this.summary = response.data; - }); - - this.$http.get('ItemConfigs/findOne') - .then(res => { - if (this.card) this.card.warehouseFk = res.data.warehouseFk; - this.getWarehouseName(res.data.warehouseFk); - }); - } - - getWarehouseName(warehouseFk) { - const filter = { - where: {id: warehouseFk} - }; - this.$http.get('Warehouses/findOne', {filter}) - .then(res => { - this.warehouseText = this.$t('WarehouseFk', { - warehouseName: res.data.name - }); - }); - } - - $onChanges() { - if (this.item && this.item.id) - this.getSummary(); - } - - get isBuyer() { - return this.aclService.hasAny(['buyer']); - } - - get isReplenisher() { - return this.aclService.hasAny(['replenisher']); - } - - get isAdministrative() { - return this.aclService.hasAny(['administrative']); - } - - get isEmployee() { - return this.aclService.hasAny(['employee']); - } -} - -ngModule.vnComponent('vnItemSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - item: '<', - }, - require: { - card: '?^vnItemCard' - } -}); diff --git a/modules/item/front/summary/index.spec.js b/modules/item/front/summary/index.spec.js deleted file mode 100644 index d7821bea0..000000000 --- a/modules/item/front/summary/index.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import './index.js'; - -describe('Item', () => { - describe('Component summary', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnItemSummary', {$element, $scope}); - controller.item = {id: 1}; - controller.card = {}; - })); - - describe('getSummary()', () => { - it('should perform a query to set summary', () => { - let data = {id: 1, name: 'Gem of mind'}; - $httpBackend.expect('GET', `Items/1/getSummary`).respond(200, data); - $httpBackend.expect('GET', `ItemConfigs/findOne`).respond({}); - $httpBackend.expect('GET', `Warehouses/findOne`).respond({}); - controller.getSummary(); - $httpBackend.flush(); - - expect(controller.summary).toEqual(data); - }); - }); - - describe('$onChanges()', () => { - it('should call getSummary when item.id is defined', () => { - jest.spyOn(controller, 'getSummary'); - controller.$onChanges(); - - expect(controller.getSummary).toHaveBeenCalledWith(); - }); - }); - }); -}); diff --git a/modules/item/front/summary/locale/en.yml b/modules/item/front/summary/locale/en.yml deleted file mode 100644 index 0ec208720..000000000 --- a/modules/item/front/summary/locale/en.yml +++ /dev/null @@ -1 +0,0 @@ -WarehouseFk: Calculated on the warehouse of {{ warehouseName }} diff --git a/modules/item/front/summary/locale/es.yml b/modules/item/front/summary/locale/es.yml deleted file mode 100644 index 80988c491..000000000 --- a/modules/item/front/summary/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Barcode: Códigos de barras -Other data: Otros datos -Go to the item: Ir al artículo -WarehouseFk: Calculado sobre el almacén de {{ warehouseName }} -Minimum sales quantity: Cantidad mínima de venta diff --git a/modules/item/front/summary/style.scss b/modules/item/front/summary/style.scss deleted file mode 100644 index d047f3e36..000000000 --- a/modules/item/front/summary/style.scss +++ /dev/null @@ -1,39 +0,0 @@ -@import "./variables"; - -vn-item-summary { - p { - margin: 0; - } -} - -.item-state { - padding: 6px; - background-color: $color-main; - color: $color-font-dark; - - p { - font-size: .75rem; - text-align: center; - margin: 0; - - &:first-child { - text-transform: uppercase; - line-height: 1; - } - &:last-child { - font-size: 1.5rem; - font-weight: bold; - } - } - vn-one { - padding: 0; - - &:nth-child(1) { - border-right: 1px solid white; - } - - &:nth-child(2) { - border-right: 1px solid white; - } - } -} diff --git a/modules/item/front/tags/index.html b/modules/item/front/tags/index.html deleted file mode 100644 index f9b5370fa..000000000 --- a/modules/item/front/tags/index.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/item/front/tags/index.js b/modules/item/front/tags/index.js deleted file mode 100644 index 2c3b39d45..000000000 --- a/modules/item/front/tags/index.js +++ /dev/null @@ -1,54 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.include = { - relation: 'tag', - scope: { - fields: ['id', 'name', 'isFree', 'sourceTable'] - } - }; - } - - add() { - this.$.model.insert({ - itemFk: this.$params.id, - priority: this.getHighestPriority() - }); - } - - getHighestPriority() { - let max = 0; - this.$.model.data.forEach(tag => { - if (tag.priority > max) - max = tag.priority; - }); - return max + 1; - } - - onSubmit() { - const changes = this.$.model.getChanges(); - const data = { - creates: changes.creates, - deletes: changes.deletes, - updates: changes.updates, - maxPriority: this.getHighestPriority() - }; - this.$http.patch(`Tags/onSubmit`, data).then(() => { - this.$.model.refresh(); - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - this.card.reload(); - }); - } -} - -ngModule.vnComponent('vnItemTags', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnItemCard' - } -}); diff --git a/modules/item/front/tags/index.spec.js b/modules/item/front/tags/index.spec.js deleted file mode 100644 index 8b4b8596b..000000000 --- a/modules/item/front/tags/index.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('Item', () => { - describe('Component vnItemTags', () => { - let $scope; - let controller; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - $scope.model = crudModel; - const $element = angular.element(''); - controller = $componentController('vnItemTags', {$element, $scope}); - })); - - describe('getHighestPriority', () => { - it('should return the highest priority value + 1 from the array', () => { - $scope.model.data = [{priority: 1}, {priority: 2}, {priority: 1}]; - let result = controller.getHighestPriority(); - - expect(result).toEqual(3); - }); - - it('should return 1 when there is no priority defined', () => { - $scope.model.data = []; - let result = controller.getHighestPriority(); - - expect(result).toEqual(1); - }); - }); - }); -}); diff --git a/modules/item/front/tax/index.html b/modules/item/front/tax/index.html deleted file mode 100644 index 78858704f..000000000 --- a/modules/item/front/tax/index.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - -
- - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/item/front/tax/index.js b/modules/item/front/tax/index.js deleted file mode 100644 index 2d70414ab..000000000 --- a/modules/item/front/tax/index.js +++ /dev/null @@ -1,41 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - this.getTaxes(); - } - - getTaxes() { - let filter = { - fields: ['id', 'countryFk', 'taxClassFk'], - include: [{ - relation: 'country', - scope: {fields: ['name']} - }] - }; - - let url = `Items/${this.$params.id}/taxes`; - this.$http.get(url, {params: {filter}}).then(json => { - this.taxes = json.data; - }); - } - - submit() { - let data = []; - for (let tax of this.taxes) - data.push({id: tax.id, taxClassFk: tax.taxClassFk}); - - this.$.watcher.check(); - let url = `Items/updateTaxes`; - this.$http.post(url, data).then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - }); - } -} - -ngModule.vnComponent('vnItemTax', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/tax/index.spec.js b/modules/item/front/tax/index.spec.js deleted file mode 100644 index 9565a861d..000000000 --- a/modules/item/front/tax/index.spec.js +++ /dev/null @@ -1,64 +0,0 @@ -import './index.js'; - -describe('Item', () => { - describe('Component vnItemTax', () => { - let $element; - let $stateParams; - let controller; - let $httpBackend; - - beforeEach(ngModule('item')); - - beforeEach(inject((_$httpBackend_, $rootScope, _$stateParams_, $compile) => { - $stateParams = _$stateParams_; - $stateParams.id = 1; - $httpBackend = _$httpBackend_; - - $httpBackend.whenRoute('GET', 'TaxClasses') - .respond([ - {id: 1, description: 'Reduced VAT', code: 'R'}, - {id: 2, description: 'General VAT', code: 'G'} - ]); - - $httpBackend.whenRoute('GET', 'Items/:id/taxes') - .respond([ - {id: 1, taxClassFk: 1} - ]); - - $element = $compile(` { - $element.remove(); - }); - - describe('getTaxes()', () => { - it('should perform a query to set the array of taxes into the controller', () => { - $httpBackend.flush(); - - expect(controller.taxes[0].id).toEqual(1); - expect(controller.taxes[0].taxClassFk).toEqual(1); - }); - }); - - describe('submit()', () => { - it('should perform a post to update taxes', () => { - jest.spyOn(controller.$.watcher, 'notifySaved'); - jest.spyOn(controller.$.watcher, 'updateOriginalData'); - - controller.$onInit(); - $httpBackend.flush(); - - controller.taxes.push({id: 3, description: 'General VAT', code: 'G'}); - - $httpBackend.whenPOST(`Items/updateTaxes`).respond(true); - controller.submit(); - $httpBackend.flush(); - - expect(controller.$.watcher.notifySaved).toHaveBeenCalledWith(); - expect(controller.$.watcher.updateOriginalData).toHaveBeenCalledWith(); - }); - }); - }); -}); diff --git a/modules/item/front/waste/index/index.html b/modules/item/front/waste/index/index.html deleted file mode 100644 index 7fb3b870e..000000000 --- a/modules/item/front/waste/index/index.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/modules/item/front/waste/index/index.js b/modules/item/front/waste/index/index.js deleted file mode 100644 index 86d9d3778..000000000 --- a/modules/item/front/waste/index/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - async $onInit() { - this.$state.go('item.index'); - window.location.href = 'https://grafana.verdnatura.es/d/TTNXQAxVk'; - } -} - -ngModule.vnComponent('vnItemWasteIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/item/front/waste/index/style.scss b/modules/item/front/waste/index/style.scss deleted file mode 100644 index 36fac3311..000000000 --- a/modules/item/front/waste/index/style.scss +++ /dev/null @@ -1,27 +0,0 @@ -@import "variables"; -@import "effects"; - -vn-item-waste-index, -vn-item-waste-detail { - .header { - padding: 12px 0 5px 0; - background-color: $color-bg; - font-size: 1.2rem; - margin-bottom: 10px; - } - - vn-table vn-th.waste-family, - vn-table vn-td.waste-family { - max-width: 64px; - width: 64px - } - - .hidden { - display: none; - } - - .arrow.hidden { - display: block; - transform: rotate(180deg); - } -} diff --git a/modules/item/front/waste/locale/es.yml b/modules/item/front/waste/locale/es.yml deleted file mode 100644 index b9cd33dec..000000000 --- a/modules/item/front/waste/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Family: Familia -Percentage: Porcentaje -Dwindle: Mermas -Minimize/Maximize: Minimizar/Maximizar \ No newline at end of file From 7c3d02817e475959a924a1d45e820ef9028cc482 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 2 Oct 2024 11:59:55 +0200 Subject: [PATCH 03/92] fix: refs #7283 remove tests --- .../05-ticket/01-sale/01_list_sales.spec.js | 99 ----- .../05-ticket/01-sale/02_edit_sale.spec.js | 415 ------------------ e2e/paths/05-ticket/01_observations.spec.js | 50 --- .../05-ticket/02_expeditions_and_log.spec.js | 32 -- e2e/paths/05-ticket/04_packages.spec.js | 78 ---- e2e/paths/05-ticket/05_tracking_state.spec.js | 72 --- .../05-ticket/06_basic_data_steps.spec.js | 143 ------ e2e/paths/05-ticket/08_components.spec.js | 30 -- e2e/paths/05-ticket/09_weekly.spec.js | 123 ------ e2e/paths/05-ticket/10_request.spec.js | 77 ---- e2e/paths/05-ticket/12_descriptor.spec.js | 148 ------- e2e/paths/05-ticket/13_services.spec.js | 127 ------ e2e/paths/05-ticket/14_create_ticket.spec.js | 69 --- .../15_create_ticket_from_client.spec.js | 37 -- e2e/paths/05-ticket/16_summary.spec.js | 108 ----- e2e/paths/05-ticket/17_log.spec.js | 34 -- e2e/paths/05-ticket/18_index_payout.spec.js | 70 --- e2e/paths/05-ticket/19_dms.spec.js | 49 --- e2e/paths/05-ticket/20_moveExpedition.spec.js | 50 --- e2e/paths/05-ticket/21_future.spec.js | 99 ----- e2e/paths/05-ticket/22_advance.spec.js | 79 ---- loopback/locale/en.json | 6 +- 22 files changed, 4 insertions(+), 1991 deletions(-) delete mode 100644 e2e/paths/05-ticket/01-sale/01_list_sales.spec.js delete mode 100644 e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js delete mode 100644 e2e/paths/05-ticket/01_observations.spec.js delete mode 100644 e2e/paths/05-ticket/02_expeditions_and_log.spec.js delete mode 100644 e2e/paths/05-ticket/04_packages.spec.js delete mode 100644 e2e/paths/05-ticket/05_tracking_state.spec.js delete mode 100644 e2e/paths/05-ticket/06_basic_data_steps.spec.js delete mode 100644 e2e/paths/05-ticket/08_components.spec.js delete mode 100644 e2e/paths/05-ticket/09_weekly.spec.js delete mode 100644 e2e/paths/05-ticket/10_request.spec.js delete mode 100644 e2e/paths/05-ticket/12_descriptor.spec.js delete mode 100644 e2e/paths/05-ticket/13_services.spec.js delete mode 100644 e2e/paths/05-ticket/14_create_ticket.spec.js delete mode 100644 e2e/paths/05-ticket/15_create_ticket_from_client.spec.js delete mode 100644 e2e/paths/05-ticket/16_summary.spec.js delete mode 100644 e2e/paths/05-ticket/17_log.spec.js delete mode 100644 e2e/paths/05-ticket/18_index_payout.spec.js delete mode 100644 e2e/paths/05-ticket/19_dms.spec.js delete mode 100644 e2e/paths/05-ticket/20_moveExpedition.spec.js delete mode 100644 e2e/paths/05-ticket/21_future.spec.js delete mode 100644 e2e/paths/05-ticket/22_advance.spec.js diff --git a/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js b/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js deleted file mode 100644 index ad0975889..000000000 --- a/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js +++ /dev/null @@ -1,99 +0,0 @@ -import selectors from '../../../helpers/selectors.js'; -import getBrowser from '../../../helpers/puppeteer'; - -describe('Ticket List sale path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'ticket'); - await page.accessToSearchResult('13'); - await page.accessToSection('ticket.card.sale'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should confirm the first ticket sale contains the colour tag', async() => { - const value = await page - .waitToGetProperty(selectors.ticketSales.firstSaleColour, 'innerText'); - - expect(value).toContain('Black'); - }); - - it('should confirm the first sale contains the price', async() => { - const value = await page - .waitToGetProperty(selectors.ticketSales.firstSalePrice, 'innerText'); - - expect(value).toContain('1.72'); - }); - - it('should confirm the first sale contains the discount', async() => { - const value = await page - .waitToGetProperty(selectors.ticketSales.firstSaleDiscount, 'innerText'); - - expect(value).toContain('0.00%'); - }); - - it('should confirm the first sale contains the total import', async() => { - const value = await page - .waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText'); - - expect(value).toContain('34.40'); - }); - - it('should add an empty item to the sale list', async() => { - await page.waitToClick(selectors.ticketSales.newItemButton); - const sales = await page - .countElement(selectors.ticketSales.saleLine); - - expect(sales).toEqual(2); - }); - - it('should select a valid item to be added as the second item in the sales list', async() => { - let searchValue = 'Melee weapon heavy shield 100cm'; - await page.autocompleteSearch(selectors.ticketSales.secondSaleIdAutocomplete, searchValue); - await page.waitToClick(selectors.ticketSales.secondSaleQuantityCell); - await page.type(selectors.ticketSales.secondSaleQuantity, '8'); - await page.keyboard.press('Enter'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should update the description of the new sale', async() => { - await page.click(selectors.ticketSales.secondSaleConceptCell); - await page.write(selectors.ticketSales.secondSaleConceptInput, 'Aegis of Valor'); - await page.keyboard.press('Enter'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should add a third empty item to the sale list', async() => { - await page.waitToClick(selectors.ticketSales.newItemButton); - await page.waitForNumberOfElements(selectors.ticketSales.saleLine, 3); - const sales = await page.countElement(selectors.ticketSales.saleLine); - - expect(sales).toEqual(3); - }); - - it('should select the 2nd and 3th item and delete both', async() => { - await page.waitToClick(selectors.ticketSales.secondSaleCheckbox); - await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox); - await page.waitToClick(selectors.ticketSales.deleteSaleButton); - await page.waitToClick(selectors.globalItems.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should verify there's only 1 single line remaining`, async() => { - const sales = await page.countElement(selectors.ticketSales.saleLine); - - expect(sales).toEqual(1); - }); -}); 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 deleted file mode 100644 index d9689e31a..000000000 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ /dev/null @@ -1,415 +0,0 @@ -import selectors from '../../../helpers/selectors.js'; -import getBrowser from '../../../helpers/puppeteer'; - -describe('Ticket Edit sale path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('salesPerson', 'ticket'); - await page.accessToSearchResult('16'); - await page.accessToSection('ticket.card.sale'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should click on the first sale claim icon to navigate over there`, async() => { - await page.waitToClick(selectors.ticketSales.firstSaleClaimIcon); - await page.waitForNavigation(); - await page.goBack(); - await page.goBack(); - }); - - it('should navigate to the tickets index', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.ticketsButton); - await page.waitForState('ticket.index'); - }); - - it(`should search for a ticket and then navigate to it's sales`, async() => { - await page.accessToSearchResult('16'); - await page.accessToSection('ticket.card.sale'); - }); - - it(`should set the ticket as libre`, async() => { - const searchValue = 'libre'; - await page.waitToClick(selectors.ticketSales.stateMenuButton); - await page.write(selectors.ticketSales.moreMenuState, searchValue); - try { - await page.waitForFunction(searchValue => { - const element = document.querySelector('li.active'); - if (element) - return element.innerText.toLowerCase().includes(searchValue.toLowerCase()); - }, {}, searchValue); - } catch (error) { - const builtSelector = await page.selectorFormater(selectors.ticketSales.moreMenuState); - const inputValue = await page.evaluate(() => { - return document.querySelector('.vn-drop-down.shown vn-textfield input').value; - }); - throw new Error(`${builtSelector} value is ${inputValue}! ${error}`); - } - await page.waitForState('ticket.card.sale'); - await page.keyboard.press('Enter'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should check it's state is libre now`, async() => { - await page.waitForTextInElement(selectors.ticketDescriptor.stateLabelValue, 'Libre'); - const result = await page.waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText'); - - expect(result).toEqual('State Libre'); - }); - - it(`should set the ticket as OK`, async() => { - await page.waitToClick(selectors.ticketSales.setOk); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should check it's state is OK now`, async() => { - await page.waitForTextInElement(selectors.ticketDescriptor.stateLabelValue, 'OK'); - const result = await page.waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText'); - - expect(result).toEqual('State OK'); - }); - - it(`should check the zoomed image isn't present`, async() => { - const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage); - - expect(result).toEqual(0); - }); - - it(`should click on the thumbnail image of the 1st sale and see the zoomed image`, async() => { - await page.waitToClick(selectors.ticketSales.firstSaleThumbnailImage); - const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage); - - expect(result).toEqual(1); - }); - - it(`should click on the zoomed image to close it`, async() => { - await page.waitToClick(selectors.ticketSales.firstSaleZoomedImage); - const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage); - - expect(result).toEqual(0); - }); - - it(`should click on the first sale ID making now the item descriptor visible`, async() => { - await page.waitToClick(selectors.ticketSales.firstSaleId); - await page.waitImgLoad(selectors.ticketSales.firstSaleDescriptorImage); - const visible = await page.isVisible(selectors.ticketSales.saleDescriptorPopover); - - expect(visible).toBeTruthy(); - }); - - it(`should click on the descriptor image of the 1st sale and see the zoomed image`, async() => { - await page.waitToClick('vn-item-descriptor img'); - const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage); - - expect(result).toEqual(1); - }); - - it(`should now click on the zoomed image to close it`, async() => { - await page.waitToClick(selectors.ticketSales.firstSaleZoomedImage); - const result = await page.countElement(selectors.ticketSales.firstSaleZoomedImage); - - expect(result).toEqual(0); - }); - - it(`should click on the summary icon of the item-descriptor to access to the item summary`, async() => { - await page.waitToClick(selectors.ticketSales.saleDescriptorPopoverSummaryButton); - await page.waitForState('item.card.summary'); - }); - - it('should return to ticket sales section', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.ticketsButton); - await page.accessToSearchResult('16'); - await page.accessToSection('ticket.card.sale'); - }); - - it('should remove 1 from the first sale quantity', async() => { - await page.waitToClick(selectors.ticketSales.firstSaleQuantityCell); - await page.waitForSelector(selectors.ticketSales.firstSaleQuantity); - await page.type(selectors.ticketSales.firstSaleQuantity, '9\u000d'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should update the price', async() => { - await page.waitToClick(selectors.ticketSales.firstSalePrice); - await page.waitForSelector(selectors.ticketSales.firstSalePriceInput); - await page.type(selectors.ticketSales.firstSalePriceInput, '5\u000d'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the price have been updated', async() => { - const result = await page.waitToGetProperty(selectors.ticketSales.firstSalePrice, 'innerText'); - - expect(result).toContain('5.00'); - }); - - it('should confirm the total price for that item have been updated', async() => { - const result = await page.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText'); - - expect(result).toContain('45.00'); - }); - - it('should update the discount', async() => { - await page.waitToClick(selectors.ticketSales.firstSaleDiscount); - await page.waitForSelector(selectors.ticketSales.firstSaleDiscountInput); - await page.type(selectors.ticketSales.firstSaleDiscountInput, '50'); - await page.waitToClick(selectors.ticketSales.saveSaleDiscountButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the discount have been updated', async() => { - await page.waitForTextInElement(selectors.ticketSales.firstSaleDiscount, '50.00%'); - const result = await page.waitToGetProperty(selectors.ticketSales.firstSaleDiscount, 'innerText'); - - expect(result).toContain('50.00%'); - }); - - it('should confirm the total import for that item have been updated', async() => { - await page.waitForTextInElement(selectors.ticketSales.firstSaleImport, '22.50'); - const result = await page.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText'); - - expect(result).toContain('22.50'); - }); - - it('should recalculate price of sales', async() => { - await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); - await page.waitToClick(selectors.ticketSales.secondSaleCheckbox); - - await page.waitToClick(selectors.ticketSales.moreMenu); - await page.waitToClick(selectors.ticketSales.moreMenuRecalculatePrice); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should log in as salesAssistant and navigate to ticket sales', async() => { - await page.loginAndModule('salesAssistant', 'ticket'); - await page.accessToSearchResult('15'); - await page.accessToSection('ticket.card.sale'); - }); - - it('should select the first sale and create a refund with warehouse', async() => { - await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); - await page.waitToClick(selectors.ticketSales.moreMenu); - await page.waitToClick(selectors.ticketSales.moreMenuRefund); - await page.waitToClick(selectors.ticketSales.refundWithWarehouse); - await page.waitForSnackbar(); - await page.waitForState('ticket.card.sale'); - }); - - it('should select the first sale and create a refund without warehouse', async() => { - await page.accessToSearchResult('18'); - await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); - await page.waitToClick(selectors.ticketSales.moreMenu); - await page.waitToClick(selectors.ticketSales.moreMenuRefund); - await page.waitToClick(selectors.ticketSales.refundWithoutWarehouse); - await page.waitForSnackbar(); - await page.waitForState('ticket.card.sale'); - }); - - it('should show error trying to delete a ticket with a refund', async() => { - await page.loginAndModule('salesPerson', 'ticket'); - await page.accessToSearchResult('8'); - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket); - await page.waitToClick(selectors.globalItems.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Tickets with associated refunds can\'t be deleted'); - await page.waitToClick(selectors.globalItems.cancelButton); - }); - - it('should select the third sale and create a claim of it', async() => { - await page.accessToSearchResult('16'); - await page.accessToSection('ticket.card.sale'); - await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox); - await page.waitToClick(selectors.ticketSales.moreMenu); - await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim); - await page.waitToClick(selectors.globalItems.acceptButton); - await page.waitForNavigation(); - }); - - it('should search for a ticket then access to the sales section', async() => { - await page.goBack(); - await page.goBack(); - await page.loginAndModule('salesPerson', 'ticket'); - await page.accessToSearchResult('16'); - await page.accessToSection('ticket.card.sale'); - }); - - it('should select the third sale and delete it', async() => { - await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox); - await page.waitToClick(selectors.ticketSales.deleteSaleButton); - await page.waitToClick(selectors.globalItems.acceptButton); - await page.waitForSpinnerLoad(); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the third sale was deleted`, async() => { - const result = await page.countElement(selectors.ticketSales.saleLine); - - expect(result).toEqual(3); - }); - - it('should select the second sale and transfer it to a valid ticket', async() => { - const targetTicketId = '12'; - - await page.waitToClick(selectors.ticketSales.secondSaleCheckbox); - await page.waitToClick(selectors.ticketSales.transferSaleButton); - await page.waitToClick(selectors.ticketSales.transferQuantityCell); - await page.type(selectors.ticketSales.transferQuantityInput, '10\u000d'); - await page.type(selectors.ticketSales.moveToTicketInput, targetTicketId); - await page.waitToClick(selectors.ticketSales.moveToTicketButton); - await page.expectURL(`ticket/${targetTicketId}/sale`); - }); - - it('should confirm the transfered line is the correct one', async() => { - await page.waitForSelector(selectors.ticketSales.secondSaleText); - const result = await page.waitToGetProperty(selectors.ticketSales.secondSaleText, 'innerText'); - - expect(result).toContain(`Melee weapon heavy shield`); - }); - - it('should confirm the transfered quantity is the correct one', async() => { - const result = await page.waitToGetProperty(selectors.ticketSales.firstSaleQuantityCell, 'innerText'); - - expect(result).toContain('20'); - }); - - it('should go back to the original ticket sales section', async() => { - await page.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton); - await page.accessToSearchResult('16'); - await page.accessToSection('ticket.card.sale'); - }); - - it(`should confirm the original ticket has still three lines`, async() => { - await page.waitForSelector(selectors.ticketSales.saleLine); - const result = await page.countElement(selectors.ticketSales.saleLine); - - expect(result).toEqual(3); - }); - - it(`should confirm the second sale quantity is now half of it's original value after the transfer`, async() => { - const result = await page.waitToGetProperty(selectors.ticketSales.secondSaleQuantityCell, 'innerText'); - - expect(result).toContain('10'); - }); - - it('should go back to the receiver ticket sales section', async() => { - await page.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton); - await page.accessToSearchResult('12'); - await page.accessToSection('ticket.card.sale'); - }); - - it('should transfer the sale back to the original ticket', async() => { - const targetTicketId = '16'; - - await page.waitToClick(selectors.ticketSales.secondSaleCheckbox); - await page.waitToClick(selectors.ticketSales.transferSaleButton); - await page.type(selectors.ticketSales.moveToTicketInput, targetTicketId); - await page.waitToClick(selectors.ticketSales.moveToTicketButton); - await page.expectURL(`ticket/${targetTicketId}/sale`); - }); - - it('should confirm the original ticket received the line', async() => { - const expectedLines = 4; - await page.waitForNumberOfElements(selectors.ticketSales.saleLine, expectedLines); - const result = await page.countElement(selectors.ticketSales.saleLine); - - expect(result).toEqual(expectedLines); - }); - - it(`should throw an error when attempting to create a ticket for an inactive client`, async() => { - await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); - await page.waitToClick(selectors.ticketSales.transferSaleButton); - await page.waitToClick(selectors.ticketSales.moveToNewTicketButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`You can't create a ticket for an inactive client`); - - await page.closePopup(); - }); - - it('should go now to the ticket sales section of an active, not frozen client', async() => { - await page.waitToClick(selectors.ticketDescriptor.goBackToModuleIndexButton); - await page.accessToSearchResult('13'); - await page.accessToSection('ticket.card.sale'); - }); - - it(`should select all sales, tranfer them to a new ticket and delete the sender ticket as it would've been left empty`, async() => { - const senderTicketId = '13'; - - await page.waitToClick(selectors.ticketSales.selectAllSalesCheckbox); - await page.waitToClick(selectors.ticketSales.transferSaleButton); - await page.waitToClick(selectors.ticketSales.moveToNewTicketButton); - await page.evaluate((selector, ticketId) => { - return document.querySelector(selector).innerText.toLowerCase().indexOf(`#${ticketId}`) == -1; - }, selectors.ticketDescriptor.id, senderTicketId); - await page.waitForState('ticket.card.sale'); - }); - - it('should confirm the new ticket received the line', async() => { - const expectedLines = 1; - const result = await page.countElement(selectors.ticketSales.saleLine); - - expect(result).toEqual(expectedLines); - }); - - it('should check the first sale reserved icon isnt visible', async() => { - const result = await page.isVisible(selectors.ticketSales.firstSaleReservedIcon); - - expect(result).toBeFalsy(); - }); - - it('should mark the first sale as reserved', async() => { - await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); - - await page.waitToClick(selectors.ticketSales.moreMenu); - await page.waitToClick(selectors.ticketSales.moreMenuReserve); - await page.closePopup(); - await page.waitForClassNotPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide'); - const result = await page.isVisible(selectors.ticketSales.firstSaleReservedIcon); - - expect(result).toBeTruthy(); - }); - - it('should unmark the first sale as reserved', async() => { - await page.waitToClick(selectors.ticketSales.moreMenu); - await page.waitToClick(selectors.ticketSales.moreMenuUnmarkReseved); - await page.waitForClassPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide'); - const result = await page.isVisible(selectors.ticketSales.firstSaleReservedIcon); - - expect(result).toBeFalsy(); - }); - - it('should log in as Production role and go to a target ticket summary', async() => { - await page.loginAndModule('production', 'ticket'); - await page.accessToSearchResult('13'); - await page.waitForState('ticket.card.summary'); - }); - - it(`should check the ticket is deleted`, async() => { - await page.waitForSelector(selectors.ticketDescriptor.isDeletedIcon); - }); -}); diff --git a/e2e/paths/05-ticket/01_observations.spec.js b/e2e/paths/05-ticket/01_observations.spec.js deleted file mode 100644 index cf37f9ff1..000000000 --- a/e2e/paths/05-ticket/01_observations.spec.js +++ /dev/null @@ -1,50 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket Create notes path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'ticket'); - await page.accessToSearchResult('5'); - await page.accessToSection('ticket.card.observation'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should create a new note', async() => { - await page.waitToClick(selectors.ticketNotes.addNoteButton); - await page.autocompleteSearch(selectors.ticketNotes.firstNoteType, 'ItemPicker'); - await page.write(selectors.ticketNotes.firstDescription, 'description'); - await page.waitToClick(selectors.ticketNotes.submitNotesButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the note is the expected one', async() => { - await page.reloadSection('ticket.card.observation'); - const result = await page - .waitToGetProperty(selectors.ticketNotes.firstNoteType, 'value'); - - expect(result).toEqual('ItemPicker'); - - const firstDescription = await page - .waitToGetProperty(selectors.ticketNotes.firstDescription, 'value'); - - expect(firstDescription).toEqual('description'); - }); - - it('should delete the note', async() => { - await page.waitToClick(selectors.ticketNotes.firstNoteRemoveButton); - await page.waitToClick(selectors.ticketNotes.submitNotesButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js deleted file mode 100644 index 4e8005043..000000000 --- a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket expeditions and log path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('production', 'ticket'); - await page.accessToSearchResult('1'); - await page.accessToSection('ticket.card.expedition'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should delete a former expedition and confirm the remaining expedition are the expected ones`, async() => { - await page.waitToClick(selectors.ticketExpedition.thirdSaleCheckbox); - await page.waitToClick(selectors.ticketExpedition.deleteExpeditionButton); - await page.waitToClick(selectors.globalItems.acceptButton); - await page.reloadSection('ticket.card.expedition'); - - await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {}); - const result = await page - .countElement(selectors.ticketExpedition.expeditionRow); - - expect(result).toEqual(6); - }); -}); diff --git a/e2e/paths/05-ticket/04_packages.spec.js b/e2e/paths/05-ticket/04_packages.spec.js deleted file mode 100644 index 1e6a0a173..000000000 --- a/e2e/paths/05-ticket/04_packages.spec.js +++ /dev/null @@ -1,78 +0,0 @@ -import getBrowser from '../../helpers/puppeteer'; - -const $ = { - firstPackage: 'vn-autocomplete[label="Package"]', - firstQuantity: 'vn-ticket-package vn-horizontal:nth-child(1) vn-input-number[ng-model="package.quantity"]', - firstRemovePackageButton: 'vn-icon-button[vn-tooltip="Remove package"]', - addPackageButton: 'vn-icon-button[vn-tooltip="Add package"]', - savePackagesButton: `button[type=submit]` -}; - -describe('Ticket Create packages path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'ticket'); - await page.accessToSearchResult('1'); - await page.accessToSection('ticket.card.package'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should attempt create a new package but receive an error if package is blank`, async() => { - await page.waitToClick($.firstRemovePackageButton); - await page.waitToClick($.addPackageButton); - await page.write($.firstQuantity, '99'); - await page.waitToClick($.savePackagesButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Package cannot be blank'); - }); - - it(`should delete the first package and receive and error to save a new one with blank quantity`, async() => { - await page.clearInput($.firstQuantity); - await page.autocompleteSearch($.firstPackage, 'Container medical box 100cm'); - await page.waitToClick($.savePackagesButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Some fields are invalid'); - }); - - it(`should confirm the quantity input isn't invalid yet`, async() => { - const result = await page - .evaluate(selector => { - return document.querySelector(`${selector} input`).checkValidity(); - }, $.firstQuantity); - - expect(result).toBeTruthy(); - }); - - it(`should create a new package with correct data`, async() => { - await page.clearInput($.firstQuantity); - await page.write($.firstQuantity, '-99'); - await page.waitToClick($.savePackagesButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the first select is the expected one`, async() => { - await page.reloadSection('ticket.card.package'); - await page.waitForTextInField($.firstPackage, 'Container medical box 100cm'); - const result = await page.waitToGetProperty($.firstPackage, 'value'); - - expect(result).toEqual('Container medical box 100cm'); - }); - - it(`should confirm quantity is just a number and the string part was ignored by the imput number`, async() => { - await page.waitForTextInField($.firstQuantity, '-99'); - const result = await page.waitToGetProperty($.firstQuantity, 'value'); - - expect(result).toEqual('-99'); - }); -}); diff --git a/e2e/paths/05-ticket/05_tracking_state.spec.js b/e2e/paths/05-ticket/05_tracking_state.spec.js deleted file mode 100644 index 5cfc1c9d4..000000000 --- a/e2e/paths/05-ticket/05_tracking_state.spec.js +++ /dev/null @@ -1,72 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket Create new tracking state path', () => { - let browser; - let page; - - afterAll(async() => { - await browser.close(); - }); - - describe('as production', () => { - it('should log into the ticket 1 tracking', async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('production', 'ticket'); - await page.accessToSearchResult('1'); - await page.accessToSection('ticket.card.tracking.index'); - }); - - it('should access to the create state view by clicking the create floating button', async() => { - await page.waitToClick(selectors.ticketTracking.createStateButton); - await page.waitForSelector(selectors.createStateView.state, {visible: true}); - await page.waitForState('ticket.card.tracking.edit'); - }); - - it(`should create a new state`, async() => { - await page.autocompleteSearch(selectors.createStateView.state, 'OK'); - await page.waitToClick(selectors.createStateView.saveStateButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - }); - - describe('as salesPerson', () => { - it('should now log into the ticket 1 tracking', async() => { - await page.loginAndModule('salesPerson', 'ticket'); - await page.accessToSearchResult('1'); - await page.accessToSection('ticket.card.tracking.index'); - }); - - it('should now access to the create state view by clicking the create floating button', async() => { - await page.waitForSelector('.vn-popup', {hidden: true}); - await page.waitToClick(selectors.ticketTracking.createStateButton); - await page.waitForState('ticket.card.tracking.edit'); - }); - - it(`should attemp to create an state for which salesPerson doesn't have permissions`, async() => { - await page.autocompleteSearch(selectors.createStateView.state, 'Encajado'); - await page.waitToClick(selectors.createStateView.saveStateButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`You don't have enough privileges`); - }); - - it(`should make sure the worker gets autocomplete uppon selecting the assigned state`, async() => { - await page.autocompleteSearch(selectors.createStateView.state, 'asignado'); - const result = await page - .waitToGetProperty(selectors.createStateView.worker, 'value'); - - expect(result).toEqual('salesperson'); - }); - - it(`should succesfully create a valid state`, async() => { - await page.waitToClick(selectors.createStateView.saveStateButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - }); -}); diff --git a/e2e/paths/05-ticket/06_basic_data_steps.spec.js b/e2e/paths/05-ticket/06_basic_data_steps.spec.js deleted file mode 100644 index 77f0e0459..000000000 --- a/e2e/paths/05-ticket/06_basic_data_steps.spec.js +++ /dev/null @@ -1,143 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket Edit basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'ticket'); - await page.accessToSearchResult('11'); - await page.accessToSection('ticket.card.basicData.stepOne'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should confirm the zone autocomplete is disabled unless your role is productionBoss`, async() => { - await page.waitForSelector(selectors.ticketBasicData.zone, {}); - const disabled = await page.evaluate(selector => { - return document.querySelector(selector).disabled; - }, `${selectors.ticketBasicData.zone} input`); - - expect(disabled).toBeTruthy(); - }); - - it(`should now log as productionBoss to perform the rest of the tests`, async() => { - await page.loginAndModule('productionBoss', 'ticket'); - await page.accessToSearchResult('11'); - await page.accessToSection('ticket.card.basicData.stepOne'); - }); - - it(`should confirm the zone autocomplete is enabled for the role productionBoss`, async() => { - await page.waitForSpinnerLoad(); - await page.waitForSelector(selectors.ticketBasicData.zone); - const disabled = await page.evaluate(selector => { - return document.querySelector(selector).disabled; - }, `${selectors.ticketBasicData.zone} input`); - - expect(disabled).toBeFalsy(); - }); - - it(`should check the zone is for Gotham247`, async() => { - let zone = await page - .waitToGetProperty(selectors.ticketBasicData.zone, 'value'); - - expect(zone).toContain('Zone 247 A'); - }); - - it(`should edit the ticket agency then check there are no zones for it`, async() => { - await page.autocompleteSearch(selectors.ticketBasicData.agency, 'Super-Man delivery'); - let emptyZone = await page - .expectPropertyValue(selectors.ticketBasicData.zone, 'value', ''); - - expect(emptyZone).toBeTruthy(); - }); - - it(`should edit the ticket zone then check the agency is for the new zone`, async() => { - await page.clearInput(selectors.ticketBasicData.agency); - await page.autocompleteSearch(selectors.ticketBasicData.zone, 'Zone expensive A'); - let zone = await page - .waitToGetProperty(selectors.ticketBasicData.agency, 'value'); - - expect(zone).toContain('Gotham247Expensive'); - }); - - it(`should click next`, async() => { - await page.waitToClick(selectors.ticketBasicData.nextStepButton); - await page.waitForState('ticket.card.basicData.stepTwo'); - }); - - it(`should have a price diference`, async() => { - const result = await page - .waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText'); - - expect(result).toContain('-€228.25'); - }); - - it(`should select a new reason for the changes made then click on finalize`, async() => { - await page.waitToClick(selectors.ticketBasicData.chargesReason); - await page.waitToClick(selectors.ticketBasicData.finalizeButton); - await page.waitForState('ticket.card.summary'); - }); - - it(`should not find ticket`, async() => { - await page.doSearch('29'); - const count = await page.countElement(selectors.ticketsIndex.searchResult); - - expect(count).toEqual(0); - }); - - it(`should split ticket without negatives`, async() => { - const newAgency = 'Gotham247'; - const newDate = Date.vnNew(); - newDate.setDate(newDate.getDate() - 1); - - await page.accessToSearchResult('14'); - await page.accessToSection('ticket.card.basicData.stepOne'); - - await page.autocompleteSearch(selectors.ticketBasicData.agency, newAgency); - await page.pickDate(selectors.ticketBasicData.shipped, newDate); - - await page.waitToClick(selectors.ticketBasicData.nextStepButton); - - await page.waitToClick(selectors.ticketBasicData.finalizeButton); - - await page.waitForState('ticket.card.summary'); - - const newTicketAgency = await page - .waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryAgency, 'innerText'); - const newTicketDate = await page - .waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryDate, 'innerText'); - - expect(newAgency).toEqual(newTicketAgency); - expect(newTicketDate).toContain(newDate.getDate()); - }); - - it(`should new ticket have sale of old ticket`, async() => { - await page.accessToSection('ticket.card.sale'); - await page.waitForState('ticket.card.sale'); - - const item = await page.waitToGetProperty(selectors.ticketSales.firstSaleId, 'innerText'); - - expect(item).toEqual('4'); - }); - - it(`should old ticket have old date and agency`, async() => { - const oldDate = Date.vnNew(); - const oldAgency = 'Super-Man delivery'; - - await page.accessToSearchResult('14'); - - const oldTicketAgency = await page - .waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryAgency, 'innerText'); - const oldTicketDate = await page - .waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryDate, 'innerText'); - - expect(oldTicketAgency).toEqual(oldAgency); - expect(oldTicketDate).toContain(oldDate.getDate()); - }); -}); diff --git a/e2e/paths/05-ticket/08_components.spec.js b/e2e/paths/05-ticket/08_components.spec.js deleted file mode 100644 index ab2aa85b2..000000000 --- a/e2e/paths/05-ticket/08_components.spec.js +++ /dev/null @@ -1,30 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket List components path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'ticket'); - await page.accessToSearchResult('1'); - await page.accessToSection('ticket.card.components'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should confirm the total base is correct', async() => { - const name = 'Base €'; - const minLength = name.length; - - await page.waitPropertyLength(selectors.ticketComponents.base, 'innerText', minLength); - const base = await page.waitToGetProperty(selectors.ticketComponents.base, 'innerText'); - - expect(base).toContain('Base'); - expect(base.length).toBeGreaterThan(minLength); - }); -}); diff --git a/e2e/paths/05-ticket/09_weekly.spec.js b/e2e/paths/05-ticket/09_weekly.spec.js deleted file mode 100644 index 370d422e6..000000000 --- a/e2e/paths/05-ticket/09_weekly.spec.js +++ /dev/null @@ -1,123 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket descriptor path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyerBoss', 'ticket'); - await page.accessToSection('ticket.weekly.index'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should count the amount of tickets in the turns section', async() => { - const result = await page.countElement(selectors.ticketsIndex.weeklyTicket); - - expect(result).toEqual(6); - }); - - it('should go back to the ticket index then search and access a ticket summary', async() => { - await page.accessToSection('ticket.index'); - await page.accessToSearchResult('33'); - }); - - it('should add the ticket to thursday turn using the descriptor more menu', async() => { - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn); - await page.waitToClick(selectors.ticketDescriptor.thursdayButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Current ticket deleted and added to shift'); - }); - - it('should again click on the Tickets button of the top bar menu', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.ticketsButton); - await page.waitForState('ticket.index'); - }); - - it('should confirm the ticket 33 was added to thursday', async() => { - await page.accessToSection('ticket.weekly.index'); - const result = await page.waitToGetProperty(selectors.ticketsIndex.thirdWeeklyTicket, 'value'); - - expect(result).toEqual('Thursday'); - }); - - it('should click on the Tickets button of the top bar menu once more', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.ticketsButton); - await page.waitForState('ticket.index'); - }); - - it('should now search for the ticket 33', async() => { - await page.accessToSearchResult('33'); - await page.waitForState('ticket.card.summary'); - }); - - it('should add the ticket to saturday turn using the descriptor more menu', async() => { - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn); - await page.waitToClick(selectors.ticketDescriptor.saturdayButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Current ticket deleted and added to shift'); - }); - - it('should click on the Tickets button of the top bar menu once again', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.ticketsButton); - await page.waitForState('ticket.index'); - }); - - it('should confirm the ticket 33 was added on saturday', async() => { - await page.accessToSection('ticket.weekly.index'); - await page.waitForTimeout(5000); - - const result = await page.waitToGetProperty(selectors.ticketsIndex.thirdWeeklyTicket, 'value'); - - expect(result).toEqual('Saturday'); - }); - - it('should now search for the weekly ticket 33', async() => { - await page.doSearch('33'); - const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); - - expect(nResults).toEqual(2); - }); - - it('should delete the weekly ticket 33', async() => { - await page.waitToClick(selectors.ticketsIndex.firstWeeklyTicketDeleteIcon); - await page.waitToClick(selectors.ticketsIndex.acceptDeleteTurn); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the sixth weekly ticket was deleted', async() => { - await page.doSearch(); - const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); - - expect(nResults).toEqual(6); - }); - - it('should update the agency then remove it afterwards', async() => { - await page.autocompleteSearch(selectors.ticketsIndex.firstWeeklyTicketAgency, 'Gotham247'); - let message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - - await page.clearInput(selectors.ticketsIndex.firstWeeklyTicketAgency); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/05-ticket/10_request.spec.js b/e2e/paths/05-ticket/10_request.spec.js deleted file mode 100644 index 1b580aec2..000000000 --- a/e2e/paths/05-ticket/10_request.spec.js +++ /dev/null @@ -1,77 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket purchase request path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('salesPerson', 'ticket'); - await page.accessToSearchResult('1'); - await page.accessToSection('ticket.card.request.index'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should add a new request', async() => { - await page.waitToClick(selectors.ticketRequests.addRequestButton); - await page.write(selectors.ticketRequests.descriptionInput, 'New stuff'); - await page.write(selectors.ticketRequests.quantity, '9'); - await page.autocompleteSearch(selectors.ticketRequests.atender, 'buyerNick'); - await page.write(selectors.ticketRequests.price, '999'); - await page.waitToClick(selectors.ticketRequests.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should have been redirected to the request index', async() => { - await page.waitForState('ticket.card.request.index'); - }); - - it(`should edit the third request quantity as it's state is still new`, async() => { - await page.write(selectors.ticketRequests.thirdRequestQuantity, '9'); - await page.keyboard.press('Enter'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should check the new request was added', async() => { - await page.reloadSection('ticket.card.request.index'); - const result = await page.waitToGetProperty(selectors.ticketRequests.thirdRequestQuantity, 'value'); - - expect(result).toEqual('99'); - }); - - it(`should check the first request can't be edited as its state is different to new`, async() => { - await page.waitForClassPresent(selectors.ticketRequests.firstRequestQuantity, 'disabled'); - const result = await page.isDisabled(selectors.ticketRequests.firstRequestQuantity); - - expect(result).toBe(true); - }); - - it(`should check the second request can't be edited as its state is different to new`, async() => { - await page.waitForClassPresent(selectors.ticketRequests.secondRequestQuantity, 'disabled'); - const result = await page.isDisabled(selectors.ticketRequests.secondRequestQuantity); - - expect(result).toBe(true); - }); - - it('should delete the added request', async() => { - await page.waitToClick(selectors.ticketRequests.thirdRemoveRequestButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should check the request was deleted', async() => { - await page.reloadSection('ticket.card.request.index'); - await page.waitForSelector(selectors.ticketRequests.addRequestButton); - await page.waitForSelector(selectors.ticketRequests.thirdDescription, {hidden: true}); - }); -}); diff --git a/e2e/paths/05-ticket/12_descriptor.spec.js b/e2e/paths/05-ticket/12_descriptor.spec.js deleted file mode 100644 index 95a114c45..000000000 --- a/e2e/paths/05-ticket/12_descriptor.spec.js +++ /dev/null @@ -1,148 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket descriptor path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('salesperson', 'ticket'); - }); - - afterAll(async() => { - await browser.close(); - }); - - describe('Delete ticket', () => { - it('should search for an specific ticket', async() => { - await page.accessToSearchResult('18'); - await page.waitForState('ticket.card.summary'); - }); - - it(`should update the shipped hour using the descriptor menu`, async() => { - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitToClick(selectors.ticketDescriptor.moreMenuChangeShippedHour); - await page.pickTime(selectors.ticketDescriptor.changeShippedHour, '08:15'); - await page.waitToClick(selectors.ticketDescriptor.acceptChangeHourButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Shipped hour updated'); - }); - - it(`should confirm the ticket descriptor shows the correct shipping hour`, async() => { - await page.waitForState('ticket.card.summary'); - const result = await page - .waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryDate, 'innerText'); - - expect(result).toContain('08:15'); - }); - - it('should delete the ticket using the descriptor menu', async() => { - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket); - await page.waitToClick(selectors.ticketDescriptor.acceptDialog); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Ticket deleted. You can undo this action within the first hour'); - }); - - it('should have been relocated to the ticket index', async() => { - await page.waitForState('ticket.index'); - }); - - it(`should search for the deleted ticket and check the deletedTicket icon and it's date`, async() => { - await page.write(selectors.ticketsIndex.topbarSearch, '18'); - await page.waitToClick(selectors.globalItems.searchButton); - await page.waitForState('ticket.card.summary'); - await page.isVisible(selectors.ticketDescriptor.isDeletedIcon); - const result = await page.waitToGetProperty(selectors.ticketsIndex.searchResultDate, 'innerText'); - - expect(result).toContain(2000); - }); - }); - - describe('Restore ticket', () => { - it('should restore the ticket using the descriptor menu', async() => { - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitToClick(selectors.ticketDescriptor.moreMenuRestoreTicket); - await page.waitToClick(selectors.ticketDescriptor.acceptDialog); - await page.waitForState('ticket.card.summary'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - }); - - describe('Make invoice', () => { - it('should login as administrative role then search for a ticket', async() => { - const invoiceableTicketId = '14'; - - await page.loginAndModule('administrative', 'ticket'); - await page.accessToSearchResult(invoiceableTicketId); - await page.waitForState('ticket.card.summary'); - }); - - it(`should make sure the ticket doesn't have an invoiceOutFk yet`, async() => { - const result = await page - .waitToGetProperty(selectors.ticketSummary.invoiceOutRef, 'innerText'); - - expect(result).toEqual('-'); - }); - - it('should invoice the ticket using the descriptor menu', async() => { - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitForContentLoaded(); - await page.waitToClick(selectors.ticketDescriptor.moreMenuMakeInvoice); - await page.waitToClick(selectors.ticketDescriptor.acceptInvoiceOutButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Ticket invoiced'); - }); - - it(`should make sure the ticket summary have an invoiceOutFk`, async() => { - await page.waitForTextInElement(selectors.ticketSummary.invoiceOutRef, 'T4444445'); - const result = await page.waitToGetProperty(selectors.ticketSummary.invoiceOutRef, 'innerText'); - - expect(result).toEqual('T4444445'); - }); - - it(`should regenerate the invoice using the descriptor menu`, async() => { - const expectedMessage = 'The invoice PDF document has been regenerated'; - - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitForContentLoaded(); - await page.waitToClick(selectors.ticketDescriptor.moreMenuRegenerateInvoice); - await page.respondToDialog('accept'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(expectedMessage); - }); - }); - - describe('SMS', () => { - it('should send the payment SMS using the descriptor menu', async() => { - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitToClick(selectors.ticketDescriptor.moreMenuSMSOptions); - await page.waitToClick(selectors.ticketDescriptor.moreMenuPaymentSMS); - await page.waitForSelector(selectors.ticketDescriptor.SMStext); - await page.waitPropertyLength(selectors.ticketDescriptor.SMStext, 'value', 128); - await page.waitToClick(selectors.ticketDescriptor.sendSMSbutton); - const message = await page.waitForSnackbar(); - - expect(message).toBeDefined(); - }); - - it('should send the import SMS using the descriptor menu', async() => { - await page.waitToClick(selectors.ticketDescriptor.moreMenuSMSOptions); - await page.waitToClick(selectors.ticketDescriptor.moreMenuSendImportSms); - await page.waitForSelector(selectors.ticketDescriptor.SMStext); - await page.waitPropertyLength(selectors.ticketDescriptor.SMStext, 'value', 144); - await page.waitToClick(selectors.ticketDescriptor.sendSMSbutton); - const message = await page.waitForSnackbar(); - - expect(message).toBeDefined(); - }); - }); -}); diff --git a/e2e/paths/05-ticket/13_services.spec.js b/e2e/paths/05-ticket/13_services.spec.js deleted file mode 100644 index 50df23582..000000000 --- a/e2e/paths/05-ticket/13_services.spec.js +++ /dev/null @@ -1,127 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket services path', () => { - let browser; - let page; - const invoicedTicketId = '1'; - - afterAll(async() => { - await browser.close(); - }); - - describe('as employee', () => { - it('should log in as employee, search for an invoice and get to services', async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'ticket'); - await page.accessToSearchResult(invoicedTicketId); - await page.accessToSection('ticket.card.service'); - }); - - it('should find the add descripton button disabled for this user role', async() => { - await page.waitForClassPresent(selectors.ticketService.firstAddServiceTypeButton, 'disabled'); - await page.waitToClick(selectors.ticketService.addServiceButton); - await page.waitForSelector(selectors.ticketService.firstAddServiceTypeButton); - const disabled = await page.isDisabled(selectors.ticketService.firstAddServiceTypeButton); - - expect(disabled).toBe(true); - }); - - it('should receive an error if you attempt to save a service without access rights', async() => { - await page.clearInput(selectors.ticketService.firstPrice); - await page.write(selectors.ticketService.firstPrice, '999'); - await page.waitToClick(selectors.ticketService.saveServiceButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`The current ticket can't be modified`); - }); - }); - - describe('as administrative', () => { - let editableTicketId = '16'; - it('should navigate to the services of a target ticket', async() => { - await page.loginAndModule('administrative', 'ticket'); - await page.accessToSearchResult(editableTicketId); - await page.accessToSection('ticket.card.service'); - }); - - it('should click on the add button to prepare the form to create a new service', async() => { - await page.waitToClick(selectors.ticketService.addServiceButton); - const result = await page - .isVisible(selectors.ticketService.firstServiceType); - - expect(result).toBeTruthy(); - }); - - it('should receive an error if you attempt to save it with empty fields', async() => { - await page.waitToClick(selectors.ticketService.saveServiceButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`can't be blank`); - }); - - it('should click on the add new service type to open the dialog', async() => { - await page.waitToClick(selectors.ticketService.firstAddServiceTypeButton); - await page.waitForSelector('.vn-dialog.shown'); - const result = await page.isVisible(selectors.ticketService.newServiceTypeName); - - expect(result).toBeTruthy(); - }); - - it('should receive an error if service type is empty on submit', async() => { - await page.waitToClick(selectors.ticketService.saveServiceTypeButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`Name can't be empty`); - }); - - it('should create a new service type then add price then create the service', async() => { - await page.write(selectors.ticketService.newServiceTypeName, 'Documentos'); - await page.waitToClick(selectors.ticketService.saveServiceTypeButton); - await page.write(selectors.ticketService.firstPrice, '999'); - await page.waitToClick(selectors.ticketService.saveServiceButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the service description was created correctly', async() => { - await page.reloadSection('ticket.card.service'); - const result = await page - .waitToGetProperty(selectors.ticketService.firstServiceType, 'value'); - - expect(result).toEqual('Documentos'); - }); - - it('should confirm the service quantity was created correctly', async() => { - const result = await page - .waitToGetProperty(selectors.ticketService.firstQuantity, 'value'); - - expect(result).toEqual('1'); - }); - - it('should confirm the service price was created correctly', async() => { - const result = await page - .waitToGetProperty(selectors.ticketService.firstPrice, 'value'); - - expect(result).toEqual('999'); - }); - - it('should delete the service', async() => { - await page.waitToClick(selectors.ticketService.fistDeleteServiceButton); - await page.waitForNumberOfElements(selectors.ticketService.serviceLine, 0); - await page.waitToClick(selectors.ticketService.saveServiceButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the service was removed`, async() => { - await page.reloadSection('ticket.card.service'); - const nResults = await page.countElement(selectors.ticketService.serviceLine); - - expect(nResults).toEqual(0); - }); - }); -}); diff --git a/e2e/paths/05-ticket/14_create_ticket.spec.js b/e2e/paths/05-ticket/14_create_ticket.spec.js deleted file mode 100644 index 1f9c0c40a..000000000 --- a/e2e/paths/05-ticket/14_create_ticket.spec.js +++ /dev/null @@ -1,69 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket create path', () => { - let browser; - let page; - let nextMonth = Date.vnNew(); - nextMonth.setMonth(nextMonth.getMonth() + 1); - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('salesPerson', 'ticket'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should open the new ticket form', async() => { - await page.waitToClick(selectors.ticketsIndex.newTicketButton); - await page.waitForState('ticket.create'); - }); - - it('should succeed to create a ticket', async() => { - await page.autocompleteSearch(selectors.createTicketView.client, 'Clark Kent'); - await page.pickDate(selectors.createTicketView.deliveryDate, nextMonth); - await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse Two'); - await page.autocompleteSearch(selectors.createTicketView.agency, 'Gotham247'); - await page.waitToClick(selectors.createTicketView.createButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should check the url is now the summary of the ticket', async() => { - await page.waitForState('ticket.card.summary'); - }); - - it('should again open the new ticket form', async() => { - await page.waitToClick(selectors.globalItems.returnToModuleIndexButton); - await page.waitToClick(selectors.ticketsIndex.newTicketButton); - await page.waitForState('ticket.create'); - }); - - it('should succeed to create another ticket for the same client', async() => { - await page.autocompleteSearch(selectors.createTicketView.client, 'Clark Kent'); - await page.pickDate(selectors.createTicketView.deliveryDate, nextMonth); - await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse One'); - await page.autocompleteSearch(selectors.createTicketView.agency, 'Gotham247'); - await page.waitToClick(selectors.createTicketView.createButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should check the url is now the summary of the created ticket', async() => { - await page.waitForState('ticket.card.summary'); - }); - - it('should delete the current ticket', async() => { - await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket); - await page.waitToClick(selectors.ticketDescriptor.acceptDialog); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Ticket deleted. You can undo this action within the first hour'); - }); -}); diff --git a/e2e/paths/05-ticket/15_create_ticket_from_client.spec.js b/e2e/paths/05-ticket/15_create_ticket_from_client.spec.js deleted file mode 100644 index 51ead6461..000000000 --- a/e2e/paths/05-ticket/15_create_ticket_from_client.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import getBrowser from '../../helpers/puppeteer'; - -const $ = { - form: 'vn-ticket-create-card', - moreMenu: 'vn-client-descriptor vn-icon-button[icon=more_vert]', - simpleTicketButton: '.vn-menu [name="simpleTicket"]' -}; - -describe('Ticket create from client path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'client'); - await page.accessToSearchResult('Petter Parker'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should create simple ticket and check if the client details are the expected ones', async() => { - await page.waitToClick($.moreMenu); - await page.waitToClick($.simpleTicketButton); - await page.waitForState('ticket.create'); - - const values = { - client: 'Petter Parker', - address: 'Petter Parker' - }; - const formValues = await page.fetchForm($.form, Object.keys(values)); - - expect(formValues).toEqual(values); - }); -}); diff --git a/e2e/paths/05-ticket/16_summary.spec.js b/e2e/paths/05-ticket/16_summary.spec.js deleted file mode 100644 index a6017e454..000000000 --- a/e2e/paths/05-ticket/16_summary.spec.js +++ /dev/null @@ -1,108 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket Summary path', () => { - let browser; - let page; - const ticketId = '20'; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should navigate to the target ticket summary section', async() => { - await page.loginAndModule('employee', 'ticket'); - await page.accessToSearchResult(ticketId); - await page.waitForState('ticket.card.summary'); - }); - - it(`should display details from the ticket and it's client on the top of the header`, async() => { - await page.waitForTextInElement(selectors.ticketSummary.header, 'Bruce Banner'); - const result = await page.waitToGetProperty(selectors.ticketSummary.header, 'innerText'); - - expect(result).toContain(`Ticket #${ticketId}`); - expect(result).toContain('Bruce Banner (1109)'); - expect(result).toContain('Somewhere in Thailand'); - }); - - it('should display ticket details', async() => { - let result = await page - .waitToGetProperty(selectors.ticketSummary.state, 'innerText'); - - expect(result).toContain('Arreglar'); - }); - - it('should display delivery details', async() => { - let result = await page - .waitToGetProperty(selectors.ticketSummary.route, 'innerText'); - - expect(result).toContain('3'); - }); - - it('should display the ticket total', async() => { - let result = await page - .waitToGetProperty(selectors.ticketSummary.total, 'innerText'); - - expect(result).toContain('€155.54'); - }); - - it('should display the ticket line(s)', async() => { - let result = await page - .waitToGetProperty(selectors.ticketSummary.firstSaleItemId, 'innerText'); - - expect(result).toContain('2'); - }); - - it(`should click on the first sale ID to make the item descriptor visible`, async() => { - await page.waitToClick(selectors.ticketSummary.firstSaleItemId); - await page.waitImgLoad(selectors.ticketSummary.firstSaleDescriptorImage); - const visible = await page.isVisible(selectors.ticketSummary.itemDescriptorPopover); - - expect(visible).toBeTruthy(); - }); - - it(`should check the url for the item diary link of the descriptor is for the right item id`, async() => { - await page.waitForSelector(selectors.ticketSummary.itemDescriptorPopoverItemDiaryButton, {visible: true}); - }); - - it('should log in as production then navigate to the summary of the same ticket', async() => { - await page.loginAndModule('production', 'ticket'); - await page.accessToSearchResult(ticketId); - await page.waitForState('ticket.card.summary'); - }); - - it('should set the ticket state to OK using the top right button', async() => { - const searchValue = 'OK'; - await page.waitToClick(selectors.ticketSummary.stateButton); - await page.write(selectors.ticketSummary.stateAutocomplete, searchValue); - try { - await page.waitForFunction(text => { - const element = document.querySelector('li.active'); - if (element) - return element.innerText.toLowerCase().includes(text.toLowerCase()); - }, {}, searchValue); - } catch (error) { - const state = await page.evaluate(() => { - const stateSelector = 'vn-ticket-summary vn-label-value:nth-child(1) > section > span'; - return document.querySelector(stateSelector).value; - }); - throw new Error(`${stateSelector} innerText is ${state}! ${error}`); - } - await page.keyboard.press('Enter'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the ticket state was updated', async() => { - await page.waitForSpinnerLoad(); - const result = await page.waitToGetProperty(selectors.ticketSummary.state, 'innerText'); - - expect(result).toContain('OK'); - }); -}); diff --git a/e2e/paths/05-ticket/17_log.spec.js b/e2e/paths/05-ticket/17_log.spec.js deleted file mode 100644 index e1da2df44..000000000 --- a/e2e/paths/05-ticket/17_log.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket log path', () => { - let browser; - let page; - const ticketId = '5'; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should navigate to the target ticket notes section', async() => { - await page.loginAndModule('employee', 'ticket'); - await page.accessToSearchResult(ticketId); - await page.accessToSection('ticket.card.observation'); - await page.waitForState('ticket.card.observation'); - }); - - it('should create a new note for the test', async() => { - await page.waitToClick(selectors.ticketNotes.addNoteButton); - await page.autocompleteSearch(selectors.ticketNotes.firstNoteType, 'ItemPicker'); - await page.write(selectors.ticketNotes.firstDescription, 'description'); - await page.waitToClick(selectors.ticketNotes.submitNotesButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/05-ticket/18_index_payout.spec.js b/e2e/paths/05-ticket/18_index_payout.spec.js deleted file mode 100644 index 9c5518424..000000000 --- a/e2e/paths/05-ticket/18_index_payout.spec.js +++ /dev/null @@ -1,70 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; -const $ = { - newPayment: '.vn-dialog.shown', - anyBalanceLine: 'vn-client-balance-index vn-tbody > vn-tr', - firstLineReference: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td-editable' -}; - -describe('Ticket index payout path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'ticket'); - await page.waitForState('ticket.index'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should check the second ticket from a client and 1 of another', async() => { - await page.waitToClick(selectors.globalItems.searchButton); - await page.waitToClick(selectors.ticketsIndex.thirdTicketCheckbox); - await page.waitToClick(selectors.ticketsIndex.fifthTicketCheckbox); - await page.waitToClick(selectors.ticketsIndex.payoutButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('You cannot make a payment on account from multiple clients'); - }); - - it('should search for tickets of the same client then open the payout form', async() => { - await page.waitToClick(selectors.ticketsIndex.openAdvancedSearchButton); - await page.write(selectors.ticketsIndex.advancedSearchClient, '1101'); - await page.keyboard.press('Enter'); - await page.waitForNumberOfElements(selectors.ticketsIndex.anySearchResult, 10); - await page.waitToClick(selectors.ticketsIndex.firstTicketCheckbox); - await page.waitToClick(selectors.ticketsIndex.secondTicketCheckbox); - - await page.waitToClick(selectors.ticketsIndex.payoutButton); - - await page.waitForSelector(selectors.ticketsIndex.payoutCompany); - }); - - it('should fill the company and bank to perform a payout and check a new balance line was entered', async() => { - await page.fillForm($.newPayment, { - company: 'VNL', - bank: 'cash', - amountPaid: 100, - description: 'Payment', - viewReceipt: false - }); - await page.respondToDialog('accept'); - const message = await page.waitForSnackbar(); - - await page.waitToClick(selectors.globalItems.homeButton); - await page.selectModule('client'); - await page.accessToSearchResult('1101'); - await page.accessToSection('client.card.balance.index'); - await page.waitForSelector($.anyBalanceLine); - const count = await page.countElement($.anyBalanceLine); - const reference = await page.innerText($.firstLineReference); - - expect(message.isSuccess).toBeTrue(); - expect(count).toEqual(4); - expect(reference).toContain('Payment'); - }); -}); diff --git a/e2e/paths/05-ticket/19_dms.spec.js b/e2e/paths/05-ticket/19_dms.spec.js deleted file mode 100644 index be2ac4338..000000000 --- a/e2e/paths/05-ticket/19_dms.spec.js +++ /dev/null @@ -1,49 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket DMS path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'ticket'); - await page.accessToSearchResult('1'); - await page.accessToSection('ticket.card.dms.index'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should import a document', async() => { - await page.waitToClick(selectors.ticketDms.import); - await page.autocompleteSearch(selectors.ticketDms.document, '1'); - await page.waitToClick(selectors.ticketDms.saveImport); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should check there's a listed document now`, async() => { - const result = await page.countElement(selectors.ticketDms.anyDocument); - - expect(result).toEqual(1); - }); - - it('should attempt to import an existing document on this ticket', async() => { - await page.waitToClick(selectors.ticketDms.import); - await page.autocompleteSearch(selectors.ticketDms.document, '1'); - await page.waitToClick(selectors.ticketDms.saveImport); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('This document already exists on this ticket'); - }); - - it(`should check there's still one document`, async() => { - const result = await page.countElement(selectors.ticketDms.anyDocument); - - expect(result).toEqual(1); - }); -}); diff --git a/e2e/paths/05-ticket/20_moveExpedition.spec.js b/e2e/paths/05-ticket/20_moveExpedition.spec.js deleted file mode 100644 index ae23c9c99..000000000 --- a/e2e/paths/05-ticket/20_moveExpedition.spec.js +++ /dev/null @@ -1,50 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket expeditions', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('production', 'ticket'); - await page.accessToSearchResult('1'); - await page.accessToSection('ticket.card.expedition'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should move one expedition to new ticket withoute route`, async() => { - await page.waitToClick(selectors.ticketExpedition.thirdSaleCheckbox); - await page.waitToClick(selectors.ticketExpedition.moveExpeditionButton); - await page.waitToClick(selectors.ticketExpedition.moreMenuWithoutRoute); - await page.waitToClick(selectors.ticketExpedition.saveButton); - await page.waitForState('ticket.card.summary'); - await page.accessToSection('ticket.card.expedition'); - - await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {}); - const result = await page - .countElement(selectors.ticketExpedition.expeditionRow); - - expect(result).toEqual(2); - }); - - it(`should move one expedition to new ticket with route`, async() => { - await page.waitToClick(selectors.ticketExpedition.firstSaleCheckbox); - await page.waitToClick(selectors.ticketExpedition.moveExpeditionButton); - await page.waitToClick(selectors.ticketExpedition.moreMenuWithRoute); - await page.write(selectors.ticketExpedition.newRouteId, '1'); - await page.waitToClick(selectors.ticketExpedition.saveButton); - await page.waitForState('ticket.card.summary'); - await page.accessToSection('ticket.card.expedition'); - - await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {}); - const result = await page - .countElement(selectors.ticketExpedition.expeditionRow); - - expect(result).toEqual(2); - }); -}); diff --git a/e2e/paths/05-ticket/21_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js deleted file mode 100644 index 60bb9c38d..000000000 --- a/e2e/paths/05-ticket/21_future.spec.js +++ /dev/null @@ -1,99 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket Future path', () => { - let browser; - let page; - let httpRequest; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'ticket'); - await page.accessToSection('ticket.future'); - page.on('request', req => { - if (req.url().includes(`Tickets/getTicketsFuture`)) - httpRequest = req.url(); - }); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should search with required data, check three last tickets and move to the future', async() => { - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.warehouseFk); - await page.waitToClick(selectors.ticketFuture.submit); - let message = await page.waitForSnackbar(); - - expect(message.text).toContain('warehouseFk is a required argument'); - - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.futureScopeDays); - await page.waitToClick(selectors.ticketFuture.submit); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('futureScopeDays is a required argument'); - - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.originScopeDays); - await page.waitToClick(selectors.ticketFuture.submit); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('originScopeDays is a required argument'); - - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.waitToClick(selectors.ticketFuture.submit); - - expect(httpRequest).toBeDefined(); - - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - - await page.autocompleteSearch(selectors.ticketFuture.ipt, 'H'); - await page.waitToClick(selectors.ticketFuture.submit); - - expect(httpRequest).toContain('ipt=H'); - - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - - await page.clearInput(selectors.ticketFuture.ipt); - - await page.autocompleteSearch(selectors.ticketFuture.futureIpt, 'H'); - await page.waitToClick(selectors.ticketFuture.submit); - - expect(httpRequest).toContain('futureIpt=H'); - - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - - await page.clearInput(selectors.ticketFuture.futureIpt); - - await page.autocompleteSearch(selectors.ticketFuture.state, 'Free'); - await page.waitToClick(selectors.ticketFuture.submit); - - expect(httpRequest).toContain('state=0'); - - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - - await page.clearInput(selectors.ticketFuture.state); - - await page.autocompleteSearch(selectors.ticketFuture.futureState, 'Free'); - await page.waitToClick(selectors.ticketFuture.submit); - - expect(httpRequest).toContain('futureState=0'); - - await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.state); - await page.clearInput(selectors.ticketFuture.futureState); - await page.waitToClick(selectors.ticketFuture.submit); - - await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 5); - await page.waitToClick(selectors.ticketFuture.multiCheck); - await page.waitToClick(selectors.ticketFuture.firstCheck); - await page.waitToClick(selectors.ticketFuture.moveButton); - await page.waitToClick(selectors.globalItems.acceptButton); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('Tickets moved successfully!'); - }); -}); diff --git a/e2e/paths/05-ticket/22_advance.spec.js b/e2e/paths/05-ticket/22_advance.spec.js deleted file mode 100644 index 0e5b5e0c3..000000000 --- a/e2e/paths/05-ticket/22_advance.spec.js +++ /dev/null @@ -1,79 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Ticket Advance path', () => { - let browser; - let page; - let httpRequest; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'ticket'); - await page.accessToSection('ticket.advance'); - page.on('request', req => { - if (req.url().includes(`Tickets/getTicketsAdvance`)) - httpRequest = req.url(); - }); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should search with the required data, check the first ticket and move to the present', async() => { - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.clearInput(selectors.ticketAdvance.warehouseFk); - - await page.waitToClick(selectors.ticketAdvance.submit); - let message = await page.waitForSnackbar(); - - expect(message.text).toContain('warehouseFk is a required argument'); - - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.clearInput(selectors.ticketAdvance.dateToAdvance); - await page.waitToClick(selectors.ticketAdvance.submit); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('dateToAdvance is a required argument'); - - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.clearInput(selectors.ticketAdvance.dateFuture); - await page.waitToClick(selectors.ticketAdvance.submit); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('dateFuture is a required argument'); - - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.waitToClick(selectors.ticketAdvance.submit); - - expect(httpRequest).toBeDefined(); - - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'H'); - await page.waitToClick(selectors.ticketAdvance.submit); - - expect(httpRequest).toContain('futureIpt=H'); - - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.clearInput(selectors.ticketAdvance.futureIpt); - await page.waitToClick(selectors.ticketAdvance.submit); - - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'H'); - await page.waitToClick(selectors.ticketAdvance.submit); - - expect(httpRequest).toContain('ipt=H'); - - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.clearInput(selectors.ticketAdvance.ipt); - await page.waitToClick(selectors.ticketAdvance.submit); - - await page.waitToClick(selectors.ticketAdvance.firstCheck); - await page.waitToClick(selectors.ticketAdvance.moveButton); - await page.waitToClick(selectors.ticketAdvance.acceptButton); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('Tickets moved successfully!'); - }); -}); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ea84cb6eb..627be5122 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -240,5 +240,7 @@ "There is already a tray with the same height": "There is already a tray with the same height", "The height must be greater than 50cm": "The height must be greater than 50cm", "The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm", - "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line" -} + "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", + "null": "null", + "Invalid or expired verification code": "Invalid or expired verification code" +} \ No newline at end of file From a35c10adabbb4ea937fe43d55d8ca617a0f8d312 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 17 Oct 2024 08:35:24 +0200 Subject: [PATCH 04/92] fix: refs #7457 error on empty from param and add translate --- loopback/locale/en.json | 3 ++- loopback/locale/es.json | 3 ++- loopback/locale/fr.json | 5 +++-- loopback/locale/pt.json | 3 ++- modules/order/back/methods/order/filter.js | 9 +++------ 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ea84cb6eb..0f6457754 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -240,5 +240,6 @@ "There is already a tray with the same height": "There is already a tray with the same height", "The height must be greater than 50cm": "The height must be greater than 50cm", "The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm", - "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line" + "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", + "The from field is required": "The 'from' field is required" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9308fd4ec..8118b6f65 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -382,5 +382,6 @@ "This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha", "No valid travel thermograph found": "No se encontró un termógrafo válido", "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", - "type cannot be blank": "Se debe rellenar el tipo" + "type cannot be blank": "Se debe rellenar el tipo", + "The from field is required": "El campo 'desde' es obligatorio" } \ No newline at end of file diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index a6648b186..5bc98c3dd 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -123,7 +123,7 @@ "Added sale to ticket": "J'ai ajouté la ligne suivante au ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", "Changed sale discount": "J'ai changé le rabais des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "J'ai créé la réclamation [{{claimId}}]({{{claimUrl}}}) des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": " le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})",, + "Changed sale price": " le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})", "Changed sale quantity": "J'ai changé {{changes}} du ticket [{{ticketId}}]({{{ticketUrl}}})", "Changes in sales": "la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}}", "State": "État", @@ -362,5 +362,6 @@ "It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré", "Cannot send mail": "Impossible d'envoyer le mail", "Original invoice not found": "Facture originale introuvable", - "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne" + "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne", + "The from field is required": "Le champ de est requis" } diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index a43f0e780..91dc372c3 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -362,5 +362,6 @@ "It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso", "Original invoice not found": "Fatura original não encontrada", "Cannot send mail": "Não é possível enviar o email", - "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha" + "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha", + "The from field is required": "O campo de origem é obrigatório" } diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index affa53a55..5b5fe8701 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -2,6 +2,7 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethod('filter', { @@ -84,6 +85,8 @@ module.exports = Self => { const args = ctx.args; + if (!args.from) + throw new UserError('The from field is required'); // Apply filter by team const teamMembersId = []; if (args.myTeam != null) { @@ -106,12 +109,6 @@ module.exports = Self => { if (args?.to) args.to.setHours(23, 59, 0, 0); - if (!args.from) { - const yesterday = new Date(); - yesterday.setDate(yesterday.getDate() - 1); - args.from = yesterday.toISOString().split('T')[0]; - } - const where = buildFilter(args, (param, value) => { switch (param) { case 'search': From 78ee7e141d4c118099a6ecf2770771346cd296c0 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 17 Oct 2024 08:40:25 +0200 Subject: [PATCH 05/92] fix: refs #7457 remove translate and use param definition for restriction --- loopback/locale/en.json | 3 +-- loopback/locale/es.json | 3 +-- loopback/locale/fr.json | 3 +-- loopback/locale/pt.json | 3 +-- modules/order/back/methods/order/filter.js | 7 ++----- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 0f6457754..ea84cb6eb 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -240,6 +240,5 @@ "There is already a tray with the same height": "There is already a tray with the same height", "The height must be greater than 50cm": "The height must be greater than 50cm", "The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm", - "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", - "The from field is required": "The 'from' field is required" + "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 8118b6f65..9308fd4ec 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -382,6 +382,5 @@ "This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha", "No valid travel thermograph found": "No se encontró un termógrafo válido", "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", - "type cannot be blank": "Se debe rellenar el tipo", - "The from field is required": "El campo 'desde' es obligatorio" + "type cannot be blank": "Se debe rellenar el tipo" } \ No newline at end of file diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 5bc98c3dd..3f6cc69e7 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -362,6 +362,5 @@ "It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré", "Cannot send mail": "Impossible d'envoyer le mail", "Original invoice not found": "Facture originale introuvable", - "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne", - "The from field is required": "Le champ de est requis" + "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne" } diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index 91dc372c3..a43f0e780 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -362,6 +362,5 @@ "It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso", "Original invoice not found": "Fatura original não encontrada", "Cannot send mail": "Não é possível enviar o email", - "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha", - "The from field is required": "O campo de origem é obrigatório" + "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha" } diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 5b5fe8701..844adb51e 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -2,7 +2,6 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; -const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethod('filter', { @@ -23,7 +22,8 @@ module.exports = Self => { }, { arg: 'from', type: 'date', - description: 'The from date' + description: 'The from date', + required: true }, { arg: 'to', type: 'date', @@ -84,9 +84,6 @@ module.exports = Self => { Object.assign(myOptions, options); const args = ctx.args; - - if (!args.from) - throw new UserError('The from field is required'); // Apply filter by team const teamMembersId = []; if (args.myTeam != null) { From 989b68c33a85259243ecfd587cbff7dafcd5eff6 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 17 Oct 2024 12:44:05 +0200 Subject: [PATCH 06/92] fix: refs #6861 setQuantity --- .../procedures/itemShelvingSale_setQuantity.sql | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index cde1b6872..f141762b5 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -3,7 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQ vItemShelvingSaleFk INT(10), vQuantity DECIMAL(10,0), vIsItemShelvingSaleEmpty BOOLEAN, - vSectorFk INT + vSectorFk INT, + vShelvingFk VARCHAR(10) ) BEGIN /** @@ -24,6 +25,7 @@ BEGIN DECLARE vItemFk INT; DECLARE vTotalQuantity INT; DECLARE vStateCode VARCHAR(45); + DECLARE vCurrentShelvingFk VARCHAR(10); DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -45,18 +47,25 @@ BEGIN iss.saleFk, iss.itemShelvingFk, SUM(IFNULL(iss.quantity,0)), - IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED') + IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED'), + ish.shelvingFk INTO vItemFk, vSaleFk, vItemShelvingFk, vReservedQuantity, - vStateCode + vStateCode, + vCurrentShelvingFk FROM itemShelvingSale iss JOIN sale s ON s.id = iss.saleFk + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk WHERE iss.id = vItemShelvingSaleFk AND NOT iss.isPicked; + IF NOT (vCurrentShelvingFk <=> vShelvingFk) THEN + CALL util.throw('The shelving can not be different from the shelving reserved'); + END IF; + IF vQuantity > vReservedQuantity OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN From 7e0f19b368c796def55b3ebcb070535ff79c2f78 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 18 Oct 2024 08:21:09 +0200 Subject: [PATCH 07/92] feat: refs #8127 entry_getCommission --- .../vn/functions/entry_getCommission.sql | 78 +++++++++---------- .../vn/procedures/entry_updateComission.sql | 4 +- 2 files changed, 39 insertions(+), 43 deletions(-) diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql index 4a19f4e63..898ac8521 100644 --- a/db/routines/vn/functions/entry_getCommission.sql +++ b/db/routines/vn/functions/entry_getCommission.sql @@ -1,58 +1,54 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_getCommission`(vTravelFk INT, - vCurrencyFk INT, - vSupplierFk INT + vCurrencyFk INT, + vSupplierFk INT ) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA BEGIN - DECLARE vCommission INT; - DECLARE vCurrentCommission INT; - DECLARE vIsCurrencyUsd INT; - DECLARE vLastEntryFk INT; - - SELECT count(*) INTO vIsCurrencyUsd - FROM currency c - WHERE c.code = 'USD' AND id = vCurrencyFk; - - IF NOT vIsCurrencyUsd THEN - - SELECT e.id INTO vLastEntryFk - FROM vn.entry e - JOIN vn.travel tr ON tr.id = e.travelFk - WHERE e.supplierFk = vSupplierFk - ORDER BY tr.landed DESC - LIMIT 1; - - IF vLastEntryFk THEN - - SELECT commission INTO vCurrentCommission - FROM vn.entry - WHERE id = vLastEntryFk; - - ELSE - - SELECT commission INTO vCurrentCommission - FROM supplier s - WHERE s.id = vSupplierFk; - - END IF; - - RETURN vCurrentCommission; - - ELSE + DECLARE vCommission INT; + DECLARE vCurrentCommission INT; + DECLARE vIsNotEUR INT; + DECLARE vLastEntryFk INT; + SELECT count(*) INTO vIsNotEUR + FROM currency c + WHERE c.code <> 'EUR' AND id = vCurrencyFk; + + IF vIsNotEUR THEN SELECT ROUND(-100 * (1 - (1 / r.value))) INTO vCommission FROM travel t LEFT JOIN referenceCurrent r ON r.currencyFk = vCurrencyFk AND r.`dated` <= t.shipped WHERE t.id = vTravelFk ORDER BY r.`dated` DESC LIMIT 1; - + RETURN IFNULL(vCommission, 0); - - END IF; - + + ELSE + SELECT e.id INTO vLastEntryFk + FROM vn.entry e + JOIN vn.travel tr ON tr.id = e.travelFk + WHERE e.supplierFk = vSupplierFk + ORDER BY tr.landed DESC + LIMIT 1; + + IF vLastEntryFk THEN + SELECT commission INTO vCurrentCommission + FROM vn.entry + WHERE id = vLastEntryFk; + + ELSE + SELECT commission INTO vCurrentCommission + FROM supplier s + WHERE s.id = vSupplierFk; + + END IF; + + RETURN vCurrentCommission; + + END IF; + END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/entry_updateComission.sql b/db/routines/vn/procedures/entry_updateComission.sql index e2de2a4a5..8db28f97d 100644 --- a/db/routines/vn/procedures/entry_updateComission.sql +++ b/db/routines/vn/procedures/entry_updateComission.sql @@ -22,7 +22,7 @@ BEGIN FROM vn.entry e JOIN vn.travel t ON t.id = e.travelFk JOIN vn.warehouse w ON w.id = t.warehouseInFk - WHERE t.shipped >= util.VN_CURDATE() + WHERE t.landed >= util.VN_CURDATE() AND e.currencyFk = vCurrency AND NOT e.isBooked; @@ -33,7 +33,7 @@ BEGIN SET e.commission = vComission; SELECT `name` INTO vCurrencyName - FROM currency + FROM currency WHERE id = vCurrency; CALL entry_recalc(); From 6031b1fe3f42f7193bd223313e4c0dbc96feb428 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 28 Oct 2024 12:17:56 +0100 Subject: [PATCH 08/92] feat: refs #8169 create table itemTextureTag --- .../00-firstScript.sql | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 db/versions/11324-salmonCataractarum/00-firstScript.sql diff --git a/db/versions/11324-salmonCataractarum/00-firstScript.sql b/db/versions/11324-salmonCataractarum/00-firstScript.sql new file mode 100644 index 000000000..3a528382a --- /dev/null +++ b/db/versions/11324-salmonCataractarum/00-firstScript.sql @@ -0,0 +1,71 @@ +CREATE TABLE IF NOT EXISTS `vn`.`itemTextureTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y encerado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y esponjoso'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y foam'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y látex'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Arenosa'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Aterciopelado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Flocado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Foam'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Gasa'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Goma'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Látex'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Latón'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Mate'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Metálico'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado y engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado y rugoso'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Pluma'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plástico'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plástico engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Poliéster'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Poliéster texturizado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Rugoso'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Rígido'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Seminatural'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Silicona'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Suave'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela con brillo'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela con texturas'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela dura'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela engomada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela escarchada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela flocada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela flocada engomada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela foam'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela micro peach'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela plastificada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela plástico engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela poliéster'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela PVC'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela ratan'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rigida'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rugosa'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rústica'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela sintética'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y cristal'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y foam'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y goma'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y látex'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y madera'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y plástico'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y seco'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemTextureTag' + WHERE name= 'Textura'; + +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; \ No newline at end of file From 6927f4b28df4486277c11be1fc0e3760495b26a5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 8 Nov 2024 11:51:00 +0100 Subject: [PATCH 09/92] feat: refs #6818 saysimple integration --- back/model-config.json | 3 +++ back/models/country.json | 7 ++++- back/models/say-simple-country.json | 26 +++++++++++++++++++ db/dump/fixtures.before.sql | 3 +++ .../11330-greenMoss/00-firstScript.sql | 6 +++++ modules/client/back/methods/client/summary.js | 5 +++- 6 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 back/models/say-simple-country.json create mode 100644 db/versions/11330-greenMoss/00-firstScript.sql diff --git a/back/model-config.json b/back/model-config.json index 5368769fd..efb148ee8 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -139,6 +139,9 @@ "StarredModule": { "dataSource": "vn" }, + "SaySimpleCountry": { + "dataSource": "vn" + }, "TempContainer": { "dataSource": "tempStorage" }, diff --git a/back/models/country.json b/back/models/country.json index 80d456702..ee72ae49d 100644 --- a/back/models/country.json +++ b/back/models/country.json @@ -44,6 +44,11 @@ "type": "belongsTo", "model": "Continent", "foreignKey": "continentFk" + }, + "saySimpleCountry": { + "type": "hasOne", + "model": "SaySimpleCountry", + "foreignKey": "countryFk" } }, "acls": [ @@ -54,4 +59,4 @@ "permission": "ALLOW" } ] -} +} \ No newline at end of file diff --git a/back/models/say-simple-country.json b/back/models/say-simple-country.json new file mode 100644 index 000000000..39acd5f0b --- /dev/null +++ b/back/models/say-simple-country.json @@ -0,0 +1,26 @@ +{ + "name": "SaySimpleCountry", + "base": "VnModel", + "options": { + "mysql": { + "table": "saySimpleCountry" + } + }, + "properties": { + "countryFk": { + "type": "number", + "id": true + }, + "channel": { + "type": "number" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index f25a4aab4..7bb0ace84 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4008,3 +4008,6 @@ UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA"; UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; +INSERT INTO vn.saySimpleCountry (countryFk, channel) + VALUES (19, 1169), + (8, 1183); \ No newline at end of file diff --git a/db/versions/11330-greenMoss/00-firstScript.sql b/db/versions/11330-greenMoss/00-firstScript.sql new file mode 100644 index 000000000..e0ef77e2d --- /dev/null +++ b/db/versions/11330-greenMoss/00-firstScript.sql @@ -0,0 +1,6 @@ +CREATE TABLE IF NOT EXISTS vn.saySimpleCountry( + countryFk MEDIUMINT(8) UNSIGNED, + channel INT(4) COMMENT 'channel de whatsapp de saySimple', + PRIMARY KEY (countryFk), + CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES vn.country (`id`) ON UPDATE CASCADE +); \ No newline at end of file diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js index 8162096f0..9242fbd44 100644 --- a/modules/client/back/methods/client/summary.js +++ b/modules/client/back/methods/client/summary.js @@ -54,7 +54,10 @@ module.exports = Self => { { relation: 'country', scope: { - fields: ['name'] + fields: ['id', 'name'], + include: { + relation: 'saySimpleCountry', + } } }, { From 9b28cf9130dff4346f627d1888a1f7de7cb4ddcd Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 8 Nov 2024 12:51:09 +0100 Subject: [PATCH 10/92] feat: refs #6818 add records --- db/dump/fixtures.before.sql | 2 +- db/versions/11330-greenMoss/00-firstScript.sql | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 7bb0ace84..ce4e9ddfc 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4008,6 +4008,6 @@ UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA"; UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; -INSERT INTO vn.saySimpleCountry (countryFk, channel) +INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, 1169), (8, 1183); \ No newline at end of file diff --git a/db/versions/11330-greenMoss/00-firstScript.sql b/db/versions/11330-greenMoss/00-firstScript.sql index e0ef77e2d..762e456b1 100644 --- a/db/versions/11330-greenMoss/00-firstScript.sql +++ b/db/versions/11330-greenMoss/00-firstScript.sql @@ -3,4 +3,8 @@ CREATE TABLE IF NOT EXISTS vn.saySimpleCountry( channel INT(4) COMMENT 'channel de whatsapp de saySimple', PRIMARY KEY (countryFk), CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES vn.country (`id`) ON UPDATE CASCADE -); \ No newline at end of file +); + +INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) + VALUES (19, 1169), + (8, 1183); \ No newline at end of file From 6ef1f950d17897d377cc9fb342835f4a3e745543 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 8 Nov 2024 17:47:10 +0100 Subject: [PATCH 11/92] feat: refs #6818 add config table --- back/model-config.json | 3 +++ back/models/say-simple-config.json | 26 +++++++++++++++++++ back/models/say-simple-country.json | 2 +- db/dump/fixtures.before.sql | 6 ++++- .../11330-greenMoss/00-firstScript.sql | 8 +++++- 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 back/models/say-simple-config.json diff --git a/back/model-config.json b/back/model-config.json index efb148ee8..364ffabdf 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -142,6 +142,9 @@ "SaySimpleCountry": { "dataSource": "vn" }, + "SaySimpleConfig": { + "dataSource": "vn" + }, "TempContainer": { "dataSource": "tempStorage" }, diff --git a/back/models/say-simple-config.json b/back/models/say-simple-config.json new file mode 100644 index 000000000..edc4caa43 --- /dev/null +++ b/back/models/say-simple-config.json @@ -0,0 +1,26 @@ +{ + "name": "SaySimpleConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "saySimpleConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "url": { + "type": "string" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/back/models/say-simple-country.json b/back/models/say-simple-country.json index 39acd5f0b..adddddc02 100644 --- a/back/models/say-simple-country.json +++ b/back/models/say-simple-country.json @@ -19,7 +19,7 @@ { "accessType": "READ", "principalType": "ROLE", - "principalId": "$everyone", + "principalId": "$authenticated", "permission": "ALLOW" } ] diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index ce4e9ddfc..cd2fb8b6b 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4010,4 +4010,8 @@ UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, 1169), - (8, 1183); \ No newline at end of file + (8, 1183), + (NULL, 1320); + +INSERT IGNORE INTO vn.saySimpleConfig (url) + VALUES ('saysimle-url-mock'); \ No newline at end of file diff --git a/db/versions/11330-greenMoss/00-firstScript.sql b/db/versions/11330-greenMoss/00-firstScript.sql index 762e456b1..127c8e40e 100644 --- a/db/versions/11330-greenMoss/00-firstScript.sql +++ b/db/versions/11330-greenMoss/00-firstScript.sql @@ -5,6 +5,12 @@ CREATE TABLE IF NOT EXISTS vn.saySimpleCountry( CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES vn.country (`id`) ON UPDATE CASCADE ); +CREATE TABLE IF NOT EXISTS vn.saySimpleConfig( + id INT AUTO_INCREMENT PRIMARY KEY, + url VARCHAR(255) NOT NULL +); + INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, 1169), - (8, 1183); \ No newline at end of file + (8, 1183), + (NULL, 1320); \ No newline at end of file From fc61f7e4aba587c1577e28e9009d673e9fd9302a Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 11 Nov 2024 07:27:50 +0100 Subject: [PATCH 12/92] fix: refs #7457 remove group by calc time reduce bellow 1s --- modules/order/back/methods/order/filter.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 844adb51e..eff2eecb6 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -201,7 +201,6 @@ module.exports = Self => { `); stmt.merge(conn.makeWhere(filter.where)); - stmt.merge(`GROUP BY o.id`); stmt.merge(conn.makePagination(filter)); stmts.push(stmt); stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`); @@ -214,7 +213,6 @@ module.exports = Self => { const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); - return result[ordersIndex]; }; }; From 94ed23ca07fbe1cf8d2f3c5769ed309bd8d4303f Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 11 Nov 2024 07:51:26 +0100 Subject: [PATCH 13/92] feat: refs #8169 modifica role --- db/versions/11324-salmonCataractarum/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11324-salmonCataractarum/00-firstScript.sql b/db/versions/11324-salmonCataractarum/00-firstScript.sql index 3a528382a..5c17ed549 100644 --- a/db/versions/11324-salmonCataractarum/00-firstScript.sql +++ b/db/versions/11324-salmonCataractarum/00-firstScript.sql @@ -68,4 +68,4 @@ UPDATE vn.tag sourceTable='itemTextureTag' WHERE name= 'Textura'; -GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; \ No newline at end of file +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemTextureTag TO logisticAssist; From d6349f113cfb4979d3e3064d12d600a92bffb462 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 11 Nov 2024 08:06:22 +0100 Subject: [PATCH 14/92] feat: refs #7743 add simple spec for sendMail --- .../specs/sendMail.spec.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js diff --git a/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js b/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js new file mode 100644 index 000000000..133d7271c --- /dev/null +++ b/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js @@ -0,0 +1,20 @@ +const models = require('vn-loopback/server/server').models; + +describe('sendMail', () => { + it('should insert in mail', async() => { + const ctx = { + req: {accessToken: {userId: 50}}, + args: {workerFk: 1106, year: 2001, week: 1} + }; + const tx = await models.Sale.beginTransaction({}); + const options = {transaction: tx}; + options.transaction = tx; + + const mailCountBefore = await models.Mail.count(options); + await models.WorkerTimeControl.sendMail(ctx, options); + const mailCountAfter = await models.Mail.count(options); + + expect(mailCountAfter).toBeGreaterThan(mailCountBefore); + await tx.rollback(); + }); +}); From 50a73c98a2b3a2e3a39f4cc2b497bc507799f171 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 11 Nov 2024 08:12:07 +0100 Subject: [PATCH 15/92] feat: refs #7743 add try catch stmt to the test --- .../worker-time-control/specs/login.spec.js | 1 - .../specs/sendMail.spec.js | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/specs/login.spec.js b/modules/worker/back/methods/worker-time-control/specs/login.spec.js index e125a876d..eff0edaa7 100644 --- a/modules/worker/back/methods/worker-time-control/specs/login.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/login.spec.js @@ -1,5 +1,4 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); const UserError = require('vn-loopback/util/user-error'); describe('workerTimeControl login()', () => { diff --git a/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js b/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js index 133d7271c..1395c7a46 100644 --- a/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/sendMail.spec.js @@ -2,17 +2,24 @@ const models = require('vn-loopback/server/server').models; describe('sendMail', () => { it('should insert in mail', async() => { + const tx = await models.Sale.beginTransaction({}); + const options = {transaction: tx}; + options.transaction = tx; + let mailCountBefore; + let mailCountAfter; const ctx = { req: {accessToken: {userId: 50}}, args: {workerFk: 1106, year: 2001, week: 1} }; - const tx = await models.Sale.beginTransaction({}); - const options = {transaction: tx}; - options.transaction = tx; - const mailCountBefore = await models.Mail.count(options); - await models.WorkerTimeControl.sendMail(ctx, options); - const mailCountAfter = await models.Mail.count(options); + try { + mailCountBefore = await models.Mail.count(options); + await models.WorkerTimeControl.sendMail(ctx, options); + mailCountAfter = await models.Mail.count(options); + } catch (e) { + await tx.rollback(); + throw e; + } expect(mailCountAfter).toBeGreaterThan(mailCountBefore); await tx.rollback(); From 5c054fe0d3a6e73a71ab26f8e19ada1c0b757e6c Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 09:09:51 +0100 Subject: [PATCH 16/92] feat: refs #6869 add back --- .../vn/procedures/itemShelving_get.sql | 30 ----------- .../back/methods/item-shelving/getItems.js | 51 +++++++++++++++++++ modules/item/back/models/item-shelving.js | 1 + 3 files changed, 52 insertions(+), 30 deletions(-) delete mode 100644 db/routines/vn/procedures/itemShelving_get.sql create mode 100644 modules/item/back/methods/item-shelving/getItems.js diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql deleted file mode 100644 index 07384b721..000000000 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ /dev/null @@ -1,30 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8)) -BEGIN -/** -* Lista artículos de itemshelving -* -* @param vSelf matrícula del carro -**/ - SELECT ish.itemFk item, - i.name, - i.longName, - i.size, - ish.visible, - ish.packing, - ish.grouping, - p.code, - ish.id, - s.priority, - ish.isChecked, - ic.url, - ish.available, - ish.buyFk - FROM itemShelving ish - JOIN item i ON i.id = ish.itemFk - JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci - LEFT JOIN parking p ON s.parkingFk = p.id - JOIN hedera.imageConfig ic - WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf; -END$$ -DELIMITER ; diff --git a/modules/item/back/methods/item-shelving/getItems.js b/modules/item/back/methods/item-shelving/getItems.js new file mode 100644 index 000000000..2fe50d785 --- /dev/null +++ b/modules/item/back/methods/item-shelving/getItems.js @@ -0,0 +1,51 @@ +module.exports = Self => { + Self.remoteMethod('getItems', { + description: 'shelving item list', + accessType: 'READ', + accepts: [{ + arg: 'code', + type: 'string', + required: true, + description: 'Shelving code' + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/getItems`, + verb: 'GET' + } + }); + + Self.getItems = async(code, options) => { + const models = Self.app.models; + const myOptions = {}; + if (typeof options == 'object') + Object.assign(myOptions, options); + + const shelving = await models.Shelving.findOne({ + fields: ['priority', 'parkingFk'], + include: { + relation: 'parking', + scope: {fields: ['code']} + }, + where: {code} + }, myOptions); + + const itemShelvings = await Self.find({ + fields: ['itemFk', 'visible', 'packing', 'grouping', 'isChecked', 'available', 'buyFk'], + include: { + relation: 'item', + scope: {fields: ['name', 'longName', 'size']} + }, + where: {shelvingFk: code} + }, myOptions); + return { + code: shelving.parking().code, + priority: shelving.priority, + itemShelvings, + }; + // Add image from hedera.imageConfig + }; +}; diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index be72dac37..ba6ab780d 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -5,4 +5,5 @@ module.exports = Self => { require('../methods/item-shelving/getAlternative')(Self); require('../methods/item-shelving/updateFromSale')(Self); require('../methods/item-shelving/getListItemNewer')(Self); + require('../methods/item-shelving/getItems')(Self); }; From a41fc36f9092105384ccdd3bcf7f8adcc193d435 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 13:02:09 +0100 Subject: [PATCH 17/92] feat: refs #6869 define model --- back/model-config.json | 3 ++ back/models/image-config.json | 22 ++++++++ .../back/methods/item-shelving/getItems.js | 51 ------------------- modules/item/back/models/item-shelving.js | 1 - modules/item/back/models/item-shelving.json | 3 ++ modules/shelving/back/models/shelving.json | 10 +++- 6 files changed, 36 insertions(+), 54 deletions(-) create mode 100644 back/models/image-config.json delete mode 100644 modules/item/back/methods/item-shelving/getItems.js diff --git a/back/model-config.json b/back/model-config.json index 5368769fd..73db0a31b 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -79,6 +79,9 @@ "ImageCollectionSize": { "dataSource": "vn" }, + "ImageConfig": { + "dataSource": "vn" + }, "ImageContainer": { "dataSource": "imageStorage" }, diff --git a/back/models/image-config.json b/back/models/image-config.json new file mode 100644 index 000000000..11f4c2284 --- /dev/null +++ b/back/models/image-config.json @@ -0,0 +1,22 @@ +{ + "name": "ImageConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "hedera.imageConfig" + } + }, + "properties": { + "url": { + "type": "string" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/modules/item/back/methods/item-shelving/getItems.js b/modules/item/back/methods/item-shelving/getItems.js deleted file mode 100644 index 2fe50d785..000000000 --- a/modules/item/back/methods/item-shelving/getItems.js +++ /dev/null @@ -1,51 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('getItems', { - description: 'shelving item list', - accessType: 'READ', - accepts: [{ - arg: 'code', - type: 'string', - required: true, - description: 'Shelving code' - }], - returns: { - type: 'object', - root: true - }, - http: { - path: `/getItems`, - verb: 'GET' - } - }); - - Self.getItems = async(code, options) => { - const models = Self.app.models; - const myOptions = {}; - if (typeof options == 'object') - Object.assign(myOptions, options); - - const shelving = await models.Shelving.findOne({ - fields: ['priority', 'parkingFk'], - include: { - relation: 'parking', - scope: {fields: ['code']} - }, - where: {code} - }, myOptions); - - const itemShelvings = await Self.find({ - fields: ['itemFk', 'visible', 'packing', 'grouping', 'isChecked', 'available', 'buyFk'], - include: { - relation: 'item', - scope: {fields: ['name', 'longName', 'size']} - }, - where: {shelvingFk: code} - }, myOptions); - return { - code: shelving.parking().code, - priority: shelving.priority, - itemShelvings, - }; - // Add image from hedera.imageConfig - }; -}; diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index ba6ab780d..be72dac37 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -5,5 +5,4 @@ module.exports = Self => { require('../methods/item-shelving/getAlternative')(Self); require('../methods/item-shelving/updateFromSale')(Self); require('../methods/item-shelving/getListItemNewer')(Self); - require('../methods/item-shelving/getItems')(Self); }; diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 5df3b0703..b0e3f17fa 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -41,6 +41,9 @@ }, "available": { "type": "number" + }, + "buyFk": { + "type": "number" } }, "relations": { diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json index 46fce31e8..f6df57d43 100644 --- a/modules/shelving/back/models/shelving.json +++ b/modules/shelving/back/models/shelving.json @@ -1,6 +1,6 @@ { "name": "Shelving", - "base": "VnModel", + "base": "VnModel", "mixins": { "Loggable": true }, @@ -44,6 +44,12 @@ "type": "belongsTo", "model": "Worker", "foreignKey": "id" + }, + "itemShelving": { + "type": "hasMany", + "model": "ItemShelving", + "foreignKey": "shelvingFk", + "primaryKey": "code" } } -} +} \ No newline at end of file From 7c016da8f9bb16218965e991fc4b5b14a46581b6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 16:16:42 +0100 Subject: [PATCH 18/92] refactor: refs #7641 entry report style --- .../reports/entry-order/assets/css/style.css | 5 +++ .../reports/entry-order/entry-order.html | 44 +++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css index 767b1185a..1a5ea3eb6 100644 --- a/print/templates/reports/entry-order/assets/css/style.css +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -17,4 +17,9 @@ h3 { .tags { font-size: 10px; margin: 0; +} + +.column-oriented th, +.column-oriented td{ + padding: 5px } \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index e5d3bfb6d..ff5159aa2 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -41,36 +41,36 @@ + - + - - - - - - - - + + + + + + + + - - - - - + + + - - - - - + + + + From e38adf4296c55492ff62fb9c14fd6c1e0adb3d92 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 16:23:17 +0100 Subject: [PATCH 19/92] fix: refs #7641 align columns --- print/templates/reports/entry-order/entry-order.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index ff5159aa2..5ce306827 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -77,8 +77,8 @@ - + From 90e7ab1ec1d18366c7b1a394ddfaa03e90c01d52 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 08:25:23 +0100 Subject: [PATCH 20/92] refactor: refs #7950 Created cmr model --- db/dump/.dump/data.sql | 2 +- db/versions/11336-chocolateRaphis/00-firstScript.sql | 8 ++++++++ .../{route/downloadCmrsZip.js => cmr/downloadZip.js} | 8 ++++---- .../route/back/methods/{route/cmrs.js => cmr/filter.js} | 6 +++--- modules/route/back/methods/{route/cmr.js => cmr/print.js} | 8 ++++---- .../specs/downloadZip.spec.js} | 4 ++-- modules/route/back/model-config.json | 3 +++ modules/route/back/models/cmr.js | 5 +++++ modules/route/back/models/route.js | 4 ---- modules/ticket/back/methods/ticket/saveCmr.js | 6 +++--- modules/ticket/back/methods/ticket/saveSign.js | 4 ++-- .../back/methods/ticket/sendCmrEmail.js} | 8 ++++---- modules/ticket/back/models/ticket-methods.js | 1 + 13 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 db/versions/11336-chocolateRaphis/00-firstScript.sql rename modules/route/back/methods/{route/downloadCmrsZip.js => cmr/downloadZip.js} (87%) rename modules/route/back/methods/{route/cmrs.js => cmr/filter.js} (98%) rename modules/route/back/methods/{route/cmr.js => cmr/print.js} (82%) rename modules/route/back/methods/{route/specs/downloadCmrsZip.spec.js => cmr/specs/downloadZip.spec.js} (83%) create mode 100644 modules/route/back/models/cmr.js rename modules/{route/back/methods/route/cmrEmail.js => ticket/back/methods/ticket/sendCmrEmail.js} (92%) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 5f464c5e2..13e4a466f 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -2045,7 +2045,7 @@ INSERT INTO `ACL` VALUES (756,'Route','findOne','READ','ALLOW','ROLE','employee' INSERT INTO `ACL` VALUES (757,'Route','getRoutesByWorker','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (758,'Route','canViewAllRoute','READ','ALLOW','ROLE','deliveryAssistant',NULL); INSERT INTO `ACL` VALUES (759,'Route','cmr','READ','ALLOW','ROLE','employee',NULL); -INSERT INTO `ACL` VALUES (760,'Route','downloadCmrsZip','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (760,'Cmr','downloadZip','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (761,'Route','downloadZip','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (762,'Route','filter','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (763,'Route','getByWorker','READ','ALLOW','ROLE','employee',NULL); diff --git a/db/versions/11336-chocolateRaphis/00-firstScript.sql b/db/versions/11336-chocolateRaphis/00-firstScript.sql new file mode 100644 index 000000000..c86dc39e9 --- /dev/null +++ b/db/versions/11336-chocolateRaphis/00-firstScript.sql @@ -0,0 +1,8 @@ +DELETE FROM salix.ACL + WHERE property IN ('cmrs', 'cmr', 'downloadCmrsZip') + AND model = 'Route'; + +INSERT INTO salix.ACL (model,property,principalId) + VALUES ('Cmr','filter','production'), + ('Cmr','downloadZip','production'), + ('Cmr','print','production') \ No newline at end of file diff --git a/modules/route/back/methods/route/downloadCmrsZip.js b/modules/route/back/methods/cmr/downloadZip.js similarity index 87% rename from modules/route/back/methods/route/downloadCmrsZip.js rename to modules/route/back/methods/cmr/downloadZip.js index 895ff7a16..fcf4ce61c 100644 --- a/modules/route/back/methods/route/downloadCmrsZip.js +++ b/modules/route/back/methods/cmr/downloadZip.js @@ -1,7 +1,7 @@ const JSZip = require('jszip'); module.exports = Self => { - Self.remoteMethodCtx('downloadCmrsZip', { + Self.remoteMethodCtx('downloadZip', { description: 'Download a zip file with multiple cmrs pdfs', accessType: 'READ', accepts: [ @@ -27,13 +27,13 @@ module.exports = Self => { } ], http: { - path: '/downloadCmrsZip', + path: '/downloadZip', verb: 'GET' }, accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.downloadCmrsZip = async function(ctx, ids, options) { + Self.downloadZip = async function(ctx, ids, options) { const models = Self.app.models; const myOptions = {}; const zip = new JSZip(); @@ -44,7 +44,7 @@ module.exports = Self => { const downloadAddZip = async id => { ctx.args = ctx.args || {}; ctx.args.id = Number(id); - const [data] = await models.Route.cmr(ctx, myOptions); + const [data] = await models.Cmr.print(ctx, myOptions); zip.file(`${id}.pdf`, data, {binary: true}); }; diff --git a/modules/route/back/methods/route/cmrs.js b/modules/route/back/methods/cmr/filter.js similarity index 98% rename from modules/route/back/methods/route/cmrs.js rename to modules/route/back/methods/cmr/filter.js index 6f271a4cf..d5a217b1c 100644 --- a/modules/route/back/methods/route/cmrs.js +++ b/modules/route/back/methods/cmr/filter.js @@ -3,7 +3,7 @@ const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; module.exports = Self => { - Self.remoteMethod('cmrs', { + Self.remoteMethod('filter', { description: 'Returns an array of cmrs', accessType: 'READ', accepts: [ @@ -57,12 +57,12 @@ module.exports = Self => { root: true }, http: { - path: `/cmrs`, + path: `/filter`, verb: 'GET' } }); - Self.cmrs = async( + Self.filter = async( filter, cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, shipped, warehouseFk, options ) => { const params = {cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, warehouseFk, shipped}; diff --git a/modules/route/back/methods/route/cmr.js b/modules/route/back/methods/cmr/print.js similarity index 82% rename from modules/route/back/methods/route/cmr.js rename to modules/route/back/methods/cmr/print.js index 5033dee2f..2fe807829 100644 --- a/modules/route/back/methods/route/cmr.js +++ b/modules/route/back/methods/cmr/print.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethodCtx('cmr', { - description: 'Returns the cmr', + Self.remoteMethodCtx('print', { + description: 'Returns the cmr pdf', accessType: 'READ', accepts: [ { @@ -27,11 +27,11 @@ module.exports = Self => { } ], http: { - path: '/:id/cmr', + path: '/:id/print', verb: 'GET' }, accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.cmr = (ctx, id) => Self.printReport(ctx, id, 'cmr'); + Self.print = (ctx, id) => Self.printReport(ctx, id, 'cmr'); }; diff --git a/modules/route/back/methods/route/specs/downloadCmrsZip.spec.js b/modules/route/back/methods/cmr/specs/downloadZip.spec.js similarity index 83% rename from modules/route/back/methods/route/specs/downloadCmrsZip.spec.js rename to modules/route/back/methods/cmr/specs/downloadZip.spec.js index 7312a5d44..74870038f 100644 --- a/modules/route/back/methods/route/specs/downloadCmrsZip.spec.js +++ b/modules/route/back/methods/cmr/specs/downloadZip.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('route downloadCmrsZip()', () => { +describe('route downloadZip()', () => { it('should create a zip file with the given cmr ids', async() => { const tx = await models.Route.beginTransaction({}); const ctx = { @@ -13,7 +13,7 @@ describe('route downloadCmrsZip()', () => { }; let cmrs = '1,2'; try { - const stream = await models.Route.downloadCmrsZip(ctx, cmrs); + const stream = await models.Cmr.downloadZip(ctx, cmrs); expect(stream[0]).toBeDefined(); await tx.rollback(); diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json index ccae87bd9..be5aa07ca 100644 --- a/modules/route/back/model-config.json +++ b/modules/route/back/model-config.json @@ -5,6 +5,9 @@ "AgencyTermConfig": { "dataSource": "vn" }, + "Cmr": { + "dataSource": "vn" + }, "DeliveryPoint": { "dataSource": "vn" }, diff --git a/modules/route/back/models/cmr.js b/modules/route/back/models/cmr.js new file mode 100644 index 000000000..f9a153d52 --- /dev/null +++ b/modules/route/back/models/cmr.js @@ -0,0 +1,5 @@ +module.exports = Self => { + require('../methods/cmr/print')(Self); + require('../methods/cmr/filter')(Self); + require('../methods/cmr/downloadZip')(Self); +}; diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index 242623d6e..cd8685cec 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -14,10 +14,6 @@ module.exports = Self => { require('../methods/route/driverRouteEmail')(Self); require('../methods/route/sendSms')(Self); require('../methods/route/downloadZip')(Self); - require('../methods/route/cmr')(Self); - require('../methods/route/cmrs')(Self); - require('../methods/route/downloadCmrsZip')(Self); - require('../methods/route/cmrEmail')(Self); require('../methods/route/getExpeditionSummary')(Self); require('../methods/route/getByWorker')(Self); }; diff --git a/modules/ticket/back/methods/ticket/saveCmr.js b/modules/ticket/back/methods/ticket/saveCmr.js index 339ac1e38..4571508db 100644 --- a/modules/ticket/back/methods/ticket/saveCmr.js +++ b/modules/ticket/back/methods/ticket/saveCmr.js @@ -41,7 +41,7 @@ module.exports = Self => { for (const ticketId of tickets) { const ticket = await models.Ticket.findById(ticketId, null, myOptions); - if (ticket.cmrFk) { + if (ticket.$cmrFk) { const hasDmsCmr = await Self.rawSql(` SELECT d.id FROM ticketDms td @@ -53,8 +53,8 @@ module.exports = Self => { if (hasDmsCmr.length) throw new UserError('This ticket already has a cmr saved'); - ctx.args.id = ticket.cmrFk; - const response = await models.Route.cmr(ctx, myOptions); + ctx.args.id = ticket.$cmrFk; + const response = await models.Cmr.print(ctx, myOptions); const pdfStream = Readable.from(Buffer.from(response[0])); const data = { workerFk: ctx.req.accessToken.userId, diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index bc0da686c..ac2a7bc66 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -151,7 +151,7 @@ module.exports = Self => { await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, stateCode], myOptions); - if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.cmrFk) { + if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.$cmrFk) { await models.Ticket.saveCmr(ctx, [ticketId], myOptions); externalTickets.push(ticketId); } @@ -161,6 +161,6 @@ module.exports = Self => { if (tx) await tx.rollback(); throw e; } - await models.Route.cmrEmail(ctx, externalTickets); + await models.Ticket.sendCmrEmail(ctx, externalTickets); }; }; diff --git a/modules/route/back/methods/route/cmrEmail.js b/modules/ticket/back/methods/ticket/sendCmrEmail.js similarity index 92% rename from modules/route/back/methods/route/cmrEmail.js rename to modules/ticket/back/methods/ticket/sendCmrEmail.js index 0c4cc5061..27f22ca14 100644 --- a/modules/route/back/methods/route/cmrEmail.js +++ b/modules/ticket/back/methods/ticket/sendCmrEmail.js @@ -2,7 +2,7 @@ const {Email} = require('vn-print'); const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethodCtx('cmrEmail', { + Self.remoteMethodCtx('sendCmrEmail', { description: 'Sends the email with an cmr attached PDF', accessType: 'WRITE', accepts: [ @@ -14,12 +14,12 @@ module.exports = Self => { } ], http: { - path: '/cmrEmail', + path: '/sendCmrEmail', verb: 'POST' } }); - Self.cmrEmail = async function(ctx, tickets, options) { + Self.sendCmrEmail = async function(ctx, tickets, options) { const models = Self.app.models; const myOptions = {}; let tx; @@ -70,7 +70,7 @@ module.exports = Self => { await email.send({ overrideAttachments: true, attachments: [{ - filename: `${ticket.cmrFk}.pdf`, + filename: `${ticket.$cmrFk}.pdf`, content: response[0] }] }); diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index 7fe968b26..620b3e184 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -40,6 +40,7 @@ module.exports = function(Self) { require('../methods/ticket/expeditionPalletLabel')(Self); require('../methods/ticket/saveSign')(Self); require('../methods/ticket/saveCmr')(Self); + require('../methods/ticket/sendCmrEmail')(Self); require('../methods/ticket/invoiceTickets')(Self); require('../methods/ticket/invoiceTicketsAndPdf')(Self); require('../methods/ticket/docuwareDownload')(Self); From 3a8c37aef83218ba5674ab45dc1437fe9d68814f Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 12 Nov 2024 11:59:51 +0100 Subject: [PATCH 21/92] fix: refs #6861 refs#6861 getTickets --- back/methods/collection/getTickets.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js index 48301a366..4e91839f2 100644 --- a/back/methods/collection/getTickets.js +++ b/back/methods/collection/getTickets.js @@ -57,10 +57,10 @@ module.exports = Self => { ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving, COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving, sh.code, - p2.code parkingCode, - p2.pickingOrder pickingOrder, - p.code parkingCodePrevia, - p.pickingOrder pickingOrderPrevia, + p2.code parkingCodePrevia, + p2.pickingOrder pickingOrderPrevia, + p.code parkingCode, + p.pickingOrder pickingOrder, iss.id itemShelvingSaleFk, iss.isPicked, iss.itemShelvingFk From d52f537f0cb3d993eba447dbdbe42ffb21c70c12 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 13:04:23 +0100 Subject: [PATCH 22/92] refactor: refs #8153 Optimized order_getTax --- .../hedera/procedures/order_getTax.sql | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql index d24ffe7ef..8fa965343 100644 --- a/db/routines/hedera/procedures/order_getTax.sql +++ b/db/routines/hedera/procedures/order_getTax.sql @@ -15,41 +15,47 @@ BEGIN ENGINE = MEMORY SELECT DISTINCT o.address_id addressFk, o.company_id companyFk FROM tmp.`order` tmpOrder - JOIN hedera.`order` o ON o.id = tmpOrder.orderFk; + JOIN `order` o ON o.id = tmpOrder.orderFk; - CALL vn.addressTaxArea; + CALL vn.addressTaxArea(); -- Calcula el IVA y el recargo desglosado. - - DROP TEMPORARY TABLE IF EXISTS tmp.orderTax; - CREATE TEMPORARY TABLE tmp.orderTax - (INDEX (orderFk)) + CREATE OR REPLACE TEMPORARY TABLE tmp.orderTax + (PRIMARY KEY (orderFk, code, rate)) ENGINE = MEMORY - SELECT o.id orderFk, + WITH orders AS ( + SELECT tor.orderFk, + oro.amount * oro.price total, + s.countryFk, + ata.areaFk, + itc.taxClassFk + FROM orderRow oro + JOIN tmp.order tor ON tor.orderFk = oro.orderFk + JOIN `order` o ON o.id = tor.orderFk + JOIN vn.item i ON i.id = oro.itemFk + JOIN vn.`client` c ON c.id = o.customer_id + JOIN vn.supplier s ON s.id = o.company_id + JOIN tmp.addressTaxArea ata ON ata.addressFk = o.address_id + AND ata.companyFk = o.company_id + JOIN vn.itemTaxCountry itc ON itc.itemFk = i.id + AND itc.countryFk = s.countryFk + HAVING total + ) + SELECT o.orderFk, tc.code, - SUM(m.amount * m.price) taxableBase, + SUM(o.total) taxableBase, pgc.rate - FROM tmp.`order` tmpOrder - JOIN `order` o ON o.id = tmpOrder.orderFk - JOIN orderRow m ON m.orderFk = o.id - JOIN vn.item i ON i.id = m.itemFk - JOIN vn.`client` c ON c.id = o.customer_id - JOIN vn.supplier s ON s.id = o.company_id - JOIN tmp.addressTaxArea ata - ON ata.addressFk = o.address_id AND ata.companyFk = o.company_id - JOIN vn.itemTaxCountry itc - ON itc.itemFk = i.id AND itc.countryFk = s.countryFk - JOIN vn.bookingPlanner bp - ON bp.countryFk = s.countryFk - AND bp.taxAreaFk = ata.areaFk - AND bp.taxClassFk = itc.taxClassFk - JOIN vn.pgc ON pgc.`code` = bp.pgcFk + FROM orders o + JOIN vn.bookingPlanner bp ON bp.countryFk = o.countryFk + AND bp.taxAreaFk = o.areaFk + AND bp.taxClassFk = o.taxClassFk + JOIN vn.pgc ON pgc.code = bp.pgcFk JOIN vn.taxClass tc ON tc.id = bp.taxClassFk - GROUP BY tmpOrder.orderFk, pgc.`code`, pgc.rate - HAVING taxableBase != 0; + GROUP BY o.orderFk, pgc.code, pgc.rate + HAVING taxableBase + ORDER BY bp.priority; - DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount; - CREATE TEMPORARY TABLE tmp.orderAmount + CREATE OR REPLACE TEMPORARY TABLE tmp.orderAmount (INDEX (orderFk)) ENGINE = MEMORY SELECT orderFk, taxableBase, `code`, From 127c6fced0cd744794f2eda0e65d3667dfcf8bab Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 13:25:51 +0100 Subject: [PATCH 23/92] refactor: refs #8153 Optimized order_getTax --- db/routines/hedera/procedures/order_getTax.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql index 8fa965343..90c47bfc7 100644 --- a/db/routines/hedera/procedures/order_getTax.sql +++ b/db/routines/hedera/procedures/order_getTax.sql @@ -9,6 +9,7 @@ BEGIN * @param vOrder El identificador del pedido * @return tmp.orderTax Bases imponibles, IVA y recargo de equivalencia */ + -- No poner create or replace, ya que da problemas DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; CREATE TEMPORARY TABLE tmp.addressCompany (INDEX (addressFk, companyFk)) @@ -55,7 +56,9 @@ BEGIN HAVING taxableBase ORDER BY bp.priority; - CREATE OR REPLACE TEMPORARY TABLE tmp.orderAmount + -- No poner create or replace, ya que da problemas + DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount; + CREATE TEMPORARY TABLE tmp.orderAmount (INDEX (orderFk)) ENGINE = MEMORY SELECT orderFk, taxableBase, `code`, From 3c8ef7cdba7ab7dfe9f237f23a92871ce9ac2b86 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 14:54:11 +0100 Subject: [PATCH 24/92] refactor: refs #7950 Requested changes --- modules/ticket/back/methods/ticket/saveCmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/saveCmr.js b/modules/ticket/back/methods/ticket/saveCmr.js index 4571508db..a96bb6a27 100644 --- a/modules/ticket/back/methods/ticket/saveCmr.js +++ b/modules/ticket/back/methods/ticket/saveCmr.js @@ -53,7 +53,7 @@ module.exports = Self => { if (hasDmsCmr.length) throw new UserError('This ticket already has a cmr saved'); - ctx.args.id = ticket.$cmrFk; + Object.assign(ctx.args, {id: ticket.$cmrFk}); const response = await models.Cmr.print(ctx, myOptions); const pdfStream = Readable.from(Buffer.from(response[0])); const data = { From 4add10f3dde74909f531c0955d28a315a27580ab Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 12 Nov 2024 17:52:51 +0100 Subject: [PATCH 25/92] feat: refs #7994 remove comment script --- db/versions/11251-navyChrysanthemum/01-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11251-navyChrysanthemum/01-firstScript.sql b/db/versions/11251-navyChrysanthemum/01-firstScript.sql index c942e0400..e3e08e0aa 100644 --- a/db/versions/11251-navyChrysanthemum/01-firstScript.sql +++ b/db/versions/11251-navyChrysanthemum/01-firstScript.sql @@ -1 +1 @@ --- ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity'; \ No newline at end of file +ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity'; \ No newline at end of file From ebc04205317fd6f5c3f6d9eea2146a3db324b05b Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 13 Nov 2024 06:50:21 +0100 Subject: [PATCH 26/92] fix: problem calculation updated --- db/routines/vn/procedures/sale_getProblems.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index b50b4784d..cd65bb81c 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -127,7 +127,7 @@ BEGIN LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk WHERE IFNULL(v.visible, 0) < s.quantity - AND IFNULL(av.available, 0) < s.quantity + AND IFNULL(av.available, 0) < 0 AND IFNULL(issw.visible, 0) < s.quantity AND NOT s.isPicked AND NOT s.reserved @@ -190,7 +190,7 @@ BEGIN LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk WHERE IFNULL(v.visible, 0) < s.quantity - AND IFNULL(av.available, 0) >= s.quantity + AND IFNULL(av.available, 0) >= 0 AND IFNULL(issw.visible, 0) < s.quantity AND s.quantity > 0 AND NOT s.isPicked From 628b67e1e58e98e594d0dd9a1ed2cd4580fd7c90 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 07:10:52 +0100 Subject: [PATCH 27/92] fix: refs #8153 Version --- db/routines/hedera/procedures/order_getTax.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql index 90c47bfc7..c33b421f3 100644 --- a/db/routines/hedera/procedures/order_getTax.sql +++ b/db/routines/hedera/procedures/order_getTax.sql @@ -30,7 +30,7 @@ BEGIN s.countryFk, ata.areaFk, itc.taxClassFk - FROM orderRow oro + FROM hedera.orderRow oro JOIN tmp.order tor ON tor.orderFk = oro.orderFk JOIN `order` o ON o.id = tor.orderFk JOIN vn.item i ON i.id = oro.itemFk From ab2e35b64cd7f0cd1f6d82816dcb6e3d6b7cb440 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 07:12:49 +0100 Subject: [PATCH 28/92] fix: refs #8153 Version --- db/routines/hedera/procedures/order_getTax.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql index c33b421f3..371416c29 100644 --- a/db/routines/hedera/procedures/order_getTax.sql +++ b/db/routines/hedera/procedures/order_getTax.sql @@ -32,7 +32,7 @@ BEGIN itc.taxClassFk FROM hedera.orderRow oro JOIN tmp.order tor ON tor.orderFk = oro.orderFk - JOIN `order` o ON o.id = tor.orderFk + JOIN hedera.`order` o ON o.id = tor.orderFk JOIN vn.item i ON i.id = oro.itemFk JOIN vn.`client` c ON c.id = o.customer_id JOIN vn.supplier s ON s.id = o.company_id From c2381f0febba0dd5414466712c019df469ef9142 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 07:42:58 +0100 Subject: [PATCH 29/92] refactor: refs #7920 Main change --- db/dump/fixtures.before.sql | 42 +++++++++---------- .../11342-crimsonDendro/00-firstScript.sql | 20 +++++++++ 2 files changed, 41 insertions(+), 21 deletions(-) create mode 100644 db/versions/11342-crimsonDendro/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 8544686e8..630e24e1d 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1254,9 +1254,9 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`,`buyFk`, `userFk`) VALUES - (2, 'GVC', 1, 1, 1, 2,1106), - (4, 'HEJ', 1, 1, 1, NULL,1106), - (1, 'UXN', 2, 12, 12, NULL,1106); + (2, 11, 1, 1, 1, 2,1106), + (4, 12, 1, 1, 1, NULL,1106), + (1, 13, 2, 12, 12, NULL,1106); INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) VALUES @@ -3425,7 +3425,7 @@ INSERT INTO vn.buy INSERT INTO vn.itemShelving SET id = 9931, itemFk = 999993, - shelvingFk = 'NCC', + shelvingFk = 16, visible = 10, `grouping` = 5, packing = 10; @@ -3752,7 +3752,7 @@ INSERT vn.sale USE vn; DELETE ish.* FROM vn.itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector s ON s.id = p.sectorFk JOIN vn.warehouse w ON w.id = s.warehouseFk @@ -3761,22 +3761,22 @@ DELETE ish.* FROM vn.itemShelving ish INSERT INTO vn.itemShelving (itemFk, shelvingFk, visible, created, `grouping`, packing, packagingFk, userFk, isChecked) VALUES - (999991, 'NAA', 8, '2023-09-20', 1, 20, NULL, 103, NULL), - (999998, 'NAA', 80, '2023-09-20', 10, 30, NULL, 103, NULL), - (1000001, 'NAA', 6, '2023-09-20', 3, 50, NULL, 103, NULL), - (1000000, 'NBB', 50, '2023-09-18', 25, 500, NULL, 103, NULL), - (999993, 'NBB', 25, '2023-09-18', NULL, 10, NULL, 103, NULL), - (999999, 'NBB', 30, '2023-09-18', 10, 500, NULL, 103, NULL), - (999993, 'NCC', 25, '2023-09-20', 5, 10, NULL, 103, NULL), - (999997, 'NCC', 10, '2023-09-20', NULL, 100, NULL, 103, NULL), - (999999, 'NCC', 40, '2023-09-20', 10, 500, NULL, 103, NULL), - (999995, 'NDD', 10, '2023-09-19', NULL, 20, NULL, 103, NULL), - (999994, 'NDD', 48, '2023-09-19', 4, 20, NULL, 103, NULL), - (1000001, 'NEE', 6, '2023-09-21', 3, 50, NULL, 103, NULL), - (999992, 'NEE', 50, '2023-09-21', NULL, 1, NULL, 103, NULL), - (1000000, 'NEE', 25, '2023-09-21', 25, 500, NULL, 103, NULL), - (999996, 'PAA', 5, '2023-09-27', 1, 5, NULL, 103, NULL), - (999997, 'PCC', 10, '2023-09-27', 5, 100, NULL, 103, NULL); + (999991, 14, 8, '2023-09-20', 1, 20, NULL, 103, NULL), + (999998, 14, 80, '2023-09-20', 10, 30, NULL, 103, NULL), + (1000001, 14, 6, '2023-09-20', 3, 50, NULL, 103, NULL), + (1000000, 15, 50, '2023-09-18', 25, 500, NULL, 103, NULL), + (999993, 15, 25, '2023-09-18', NULL, 10, NULL, 103, NULL), + (999999, 15, 30, '2023-09-18', 10, 500, NULL, 103, NULL), + (999993, 16, 25, '2023-09-20', 5, 10, NULL, 103, NULL), + (999997, 16, 10, '2023-09-20', NULL, 100, NULL, 103, NULL), + (999999, 16, 40, '2023-09-20', 10, 500, NULL, 103, NULL), + (999995, 17, 10, '2023-09-19', NULL, 20, NULL, 103, NULL), + (999994, 17, 48, '2023-09-19', 4, 20, NULL, 103, NULL), + (1000001, 18, 6, '2023-09-21', 3, 50, NULL, 103, NULL), + (999992, 18, 50, '2023-09-21', NULL, 1, NULL, 103, NULL), + (1000000, 18, 25, '2023-09-21', 25, 500, NULL, 103, NULL), + (999996, 19, 5, '2023-09-27', 1, 5, NULL, 103, NULL), + (999997, 21, 10, '2023-09-27', 5, 100, NULL, 103, NULL); -- Previous for Bolas de madera INSERT IGNORE INTO vn.sectorCollection diff --git a/db/versions/11342-crimsonDendro/00-firstScript.sql b/db/versions/11342-crimsonDendro/00-firstScript.sql new file mode 100644 index 000000000..56bea2c03 --- /dev/null +++ b/db/versions/11342-crimsonDendro/00-firstScript.sql @@ -0,0 +1,20 @@ +CREATE OR REPLACE TEMPORARY TABLE tItemShelving + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT ish.id, s.id shelvingFk + FROM shelving s + JOIN itemShelving ish ON ish.shelvingFk = s.code; + +ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2, + MODIFY COLUMN shelvingFk int(11) NOT NULL; + +UPDATE itemShelving ish + JOIN tItemShelving tis ON tis.id = ish.id + SET ish.shelvingFk = tis.shelvingFk; + +DROP TEMPORARY TABLE tItemShelving; + +ALTER TABLE vn.itemShelving + ADD CONSTRAINT itemShelving_shelving_FK FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(id) + ON DELETE RESTRICT + ON UPDATE CASCADE; From 779a75cd7823e0e8cc202ae56831aa8495ffcd33 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 09:03:44 +0100 Subject: [PATCH 30/92] refactor: refs #7920 Major changes --- db/dump/.dump/structure.sql | 3390 ++++++++--------- .../inventoryDiscrepancyDetail_replace.sql | 2 +- db/routines/vn/functions/hasItemsInSector.sql | 2 +- .../vn/functions/itemsInSector_get.sql | 2 +- .../vn/procedures/collectionPlacement_get.sql | 2 +- .../vn/procedures/entry_splitByShelving.sql | 20 +- .../procedures/itemPlacementSupplyAiming.sql | 22 +- .../itemPlacementSupplyGetOrder.sql | 30 +- .../itemPlacementSupplyStockGetTargetList.sql | 15 +- .../vn/procedures/itemShelvingMatch.sql | 2 +- .../procedures/itemShelvingSale_addBySale.sql | 4 +- .../vn/procedures/itemShelving_add.sql | 15 +- .../vn/procedures/itemShelving_addByClaim.sql | 17 +- .../vn/procedures/itemShelving_addList.sql | 15 +- .../vn/procedures/itemShelving_get.sql | 14 +- .../itemShelving_getAlternatives.sql | 28 +- .../vn/procedures/itemShelving_getInfo.sql | 2 +- .../itemShelving_getItemDetails.sql | 19 +- .../procedures/itemShelving_getSaleDate.sql | 30 +- .../vn/procedures/itemShelving_inventory.sql | 2 +- .../itemShelving_selfConsumption.sql | 17 +- .../vn/procedures/itemShelving_transfer.sql | 15 +- db/routines/vn/procedures/item_devalueA2.sql | 30 +- .../vn/procedures/productionControl.sql | 2 +- .../vn/procedures/sale_boxPickingPrint.sql | 4 +- .../vn/procedures/sale_getBoxPickingList.sql | 2 +- .../vn/procedures/sale_getProblems.sql | 2 +- db/routines/vn/procedures/shelving_clean.sql | 10 +- 28 files changed, 1892 insertions(+), 1823 deletions(-) diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index e4e59a6bf..e6c0e6674 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -2955,55 +2955,55 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `analisis_ventas_update`() -BEGIN - DECLARE vLastMonth DATE; - - SET vLastMonth = util.firstDayOfMonth(TIMESTAMPADD(MONTH, -1, util.VN_CURDATE())); - - DELETE FROM analisis_ventas - WHERE Año > YEAR(vLastMonth) - OR (Año = YEAR(vLastMonth) AND Mes >= MONTH(vLastMonth)); - - INSERT INTO analisis_ventas ( - Familia, - Reino, - Comercial, - Comprador, - Provincia, - almacen, - Año, - Mes, - Semana, - Vista, - Importe - ) - SELECT - it.name, - ic.name, - w.code, - w2.code, - p.name, - wa.name, - tm.year, - tm.month, - tm.week, - dm.description, - bt.importe - FROM bs.ventas bt - LEFT JOIN vn.itemType it ON it.id = bt.tipo_id - LEFT JOIN vn.itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN vn.client c on c.id = bt.Id_Cliente - LEFT JOIN vn.worker w ON w.id = c.salesPersonFk - LEFT JOIN vn.worker w2 ON w2.id = it.workerFk - JOIN vn.time tm ON tm.dated = bt.fecha - JOIN vn.sale s ON s.id = bt.Id_Movimiento - LEFT JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.agencyMode am ON am.id = t.agencyModeFk - LEFT JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk - LEFT JOIN vn.address a ON a.id = t.addressFk - LEFT JOIN vn.province p ON p.id = a.provinceFk - LEFT JOIN vn.warehouse wa ON wa.id = t.warehouseFk - WHERE bt.fecha >= vLastMonth AND ic.merchandise; +BEGIN + DECLARE vLastMonth DATE; + + SET vLastMonth = util.firstDayOfMonth(TIMESTAMPADD(MONTH, -1, util.VN_CURDATE())); + + DELETE FROM analisis_ventas + WHERE Año > YEAR(vLastMonth) + OR (Año = YEAR(vLastMonth) AND Mes >= MONTH(vLastMonth)); + + INSERT INTO analisis_ventas ( + Familia, + Reino, + Comercial, + Comprador, + Provincia, + almacen, + Año, + Mes, + Semana, + Vista, + Importe + ) + SELECT + it.name, + ic.name, + w.code, + w2.code, + p.name, + wa.name, + tm.year, + tm.month, + tm.week, + dm.description, + bt.importe + FROM bs.ventas bt + LEFT JOIN vn.itemType it ON it.id = bt.tipo_id + LEFT JOIN vn.itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN vn.client c on c.id = bt.Id_Cliente + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + LEFT JOIN vn.worker w2 ON w2.id = it.workerFk + JOIN vn.time tm ON tm.dated = bt.fecha + JOIN vn.sale s ON s.id = bt.Id_Movimiento + LEFT JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk + LEFT JOIN vn.address a ON a.id = t.addressFk + LEFT JOIN vn.province p ON p.id = a.provinceFk + LEFT JOIN vn.warehouse wa ON wa.id = t.warehouseFk + WHERE bt.fecha >= vLastMonth AND ic.merchandise; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -3021,21 +3021,21 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`() -BEGIN - DECLARE vDateShort DATETIME; - DECLARE vDateLong DATETIME; - DECLARE vOneYearAgo DATETIME; - - SET vDateShort = TIMESTAMPADD(MONTH, -2, util.VN_CURDATE()); - SET vDateLong = TIMESTAMPADD(MONTH, -18,util.VN_CURDATE()); - SET vOneYearAgo = TIMESTAMPADD(YEAR, -1,util.VN_CURDATE()); - - DELETE FROM bi.Greuge_Evolution - WHERE (Fecha < vDateShort AND weekday(Fecha) != 1) - OR Fecha < vOneYearAgo; - - DELETE FROM bi.defaulters WHERE `date` < vDateLong; - DELETE FROM bi.defaulting WHERE `date` < vDateLong; +BEGIN + DECLARE vDateShort DATETIME; + DECLARE vDateLong DATETIME; + DECLARE vOneYearAgo DATETIME; + + SET vDateShort = TIMESTAMPADD(MONTH, -2, util.VN_CURDATE()); + SET vDateLong = TIMESTAMPADD(MONTH, -18,util.VN_CURDATE()); + SET vOneYearAgo = TIMESTAMPADD(YEAR, -1,util.VN_CURDATE()); + + DELETE FROM bi.Greuge_Evolution + WHERE (Fecha < vDateShort AND weekday(Fecha) != 1) + OR Fecha < vOneYearAgo; + + DELETE FROM bi.defaulters WHERE `date` < vDateLong; + DELETE FROM bi.defaulting WHERE `date` < vDateLong; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -3224,18 +3224,18 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `facturacion_media_anual_update`() -BEGIN - TRUNCATE TABLE bs.clientAnnualConsumption; - - REPLACE bi.facturacion_media_anual(Id_Cliente, Consumo) - SELECT clientFk, avg(Facturacion) - FROM ( - SELECT clientFk, YEAR(issued) year, MONTH(issued) month, sum(amount) as Facturacion - FROM vn.invoiceOut - WHERE issued BETWEEN TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) AND TIMESTAMPADD(DAY, - DAY(util.VN_CURDATE()),util.VN_CURDATE()) - GROUP BY clientFk, year, month - ) vol - GROUP BY clientFk; +BEGIN + TRUNCATE TABLE bs.clientAnnualConsumption; + + REPLACE bi.facturacion_media_anual(Id_Cliente, Consumo) + SELECT clientFk, avg(Facturacion) + FROM ( + SELECT clientFk, YEAR(issued) year, MONTH(issued) month, sum(amount) as Facturacion + FROM vn.invoiceOut + WHERE issued BETWEEN TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) AND TIMESTAMPADD(DAY, - DAY(util.VN_CURDATE()),util.VN_CURDATE()) + GROUP BY clientFk, year, month + ) vol + GROUP BY clientFk; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -4516,29 +4516,29 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `carteras_add`() -BEGIN -/** - * Inserta en la tabla @bs.carteras las ventas desde el año pasado - * agrupadas por trabajador, año y mes - */ - DECLARE vYear INT DEFAULT YEAR(util.VN_CURDATE()) - 1; - - DELETE FROM bs.carteras WHERE Año >= vYear; - - CALL util.time_generate( - MAKEDATE(vYear, 1), - (SELECT MAX(fecha) FROM ventas) - ); - - INSERT INTO carteras(Año, Mes , CodigoTrabajador, Peso) - SELECT t.`year`, t.`month`, w.code, SUM(v.importe) - FROM tmp.time t - JOIN ventas v on t.dated = v.fecha - JOIN vn.client c on c.id = v.Id_Cliente - JOIN vn.worker w ON w.id = c.salesPersonFk - GROUP BY w.code, t.`year`, t.`month`; - - DROP TEMPORARY TABLE tmp.time; +BEGIN +/** + * Inserta en la tabla @bs.carteras las ventas desde el año pasado + * agrupadas por trabajador, año y mes + */ + DECLARE vYear INT DEFAULT YEAR(util.VN_CURDATE()) - 1; + + DELETE FROM bs.carteras WHERE Año >= vYear; + + CALL util.time_generate( + MAKEDATE(vYear, 1), + (SELECT MAX(fecha) FROM ventas) + ); + + INSERT INTO carteras(Año, Mes , CodigoTrabajador, Peso) + SELECT t.`year`, t.`month`, w.code, SUM(v.importe) + FROM tmp.time t + JOIN ventas v on t.dated = v.fecha + JOIN vn.client c on c.id = v.Id_Cliente + JOIN vn.worker w ON w.id = c.salesPersonFk + GROUP BY w.code, t.`year`, t.`month`; + + DROP TEMPORARY TABLE tmp.time; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -5465,82 +5465,82 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `nightTask_launchAll`() -BEGIN -/** - * Runs all nightly tasks. - */ - DECLARE vDone BOOL; - DECLARE vError VARCHAR(255); - DECLARE vErrorCode VARCHAR(255); - DECLARE vSchema VARCHAR(255); - DECLARE vProcedure VARCHAR(255); - DECLARE vLogMail VARCHAR(255); - DECLARE vNightTaskFk INT; - - DECLARE vQueue CURSOR FOR - SELECT id, `schema`, `procedure` - FROM nightTask - WHERE finished <= util.VN_CURDATE() - OR finished IS NULL - ORDER BY `order`; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - SET max_sp_recursion_depth = 3; - - SELECT logMail INTO vLogMail - FROM nightTaskConfig LIMIT 1; - - OPEN vQueue; - l: LOOP - SET vDone = FALSE; - FETCH vQueue INTO vNightTaskFk, vSchema, vProcedure; - - IF vDone THEN - LEAVE l; - END IF; - - UPDATE nightTask - SET `started` = util.VN_NOW(), - `finished` = NULL, - `error` = NULL, - `errorCode` = NULL - WHERE id = vNightTaskFk; - - SET vError = NULL; - CALL nightTask_launchTask( - vSchema, - vProcedure, - vError, - vErrorCode - ); - - IF vError IS NOT NULL THEN - IF vLogMail IS NOT NULL THEN - CALL vn.mail_insert( - vLogMail, - NULL, - CONCAT('Nightly task failed (', vSchema, '.', vProcedure, ')'), - CONCAT( - '[', vErrorCode, '] ', vError, CHAR(13, 10), -- Line break - 'See ', SCHEMA(), '.nightTask table for more info.' - ) - ); - END IF; - - UPDATE nightTask - SET `error` = vError, - `errorCode` = vErrorCode - WHERE id = vNightTaskFk; - ELSE - UPDATE nightTask - SET finished = util.VN_NOW(), - lastFinished = util.VN_NOW() - WHERE id = vNightTaskFk; - END IF; - END LOOP; - CLOSE vQueue; +BEGIN +/** + * Runs all nightly tasks. + */ + DECLARE vDone BOOL; + DECLARE vError VARCHAR(255); + DECLARE vErrorCode VARCHAR(255); + DECLARE vSchema VARCHAR(255); + DECLARE vProcedure VARCHAR(255); + DECLARE vLogMail VARCHAR(255); + DECLARE vNightTaskFk INT; + + DECLARE vQueue CURSOR FOR + SELECT id, `schema`, `procedure` + FROM nightTask + WHERE finished <= util.VN_CURDATE() + OR finished IS NULL + ORDER BY `order`; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + SET max_sp_recursion_depth = 3; + + SELECT logMail INTO vLogMail + FROM nightTaskConfig LIMIT 1; + + OPEN vQueue; + l: LOOP + SET vDone = FALSE; + FETCH vQueue INTO vNightTaskFk, vSchema, vProcedure; + + IF vDone THEN + LEAVE l; + END IF; + + UPDATE nightTask + SET `started` = util.VN_NOW(), + `finished` = NULL, + `error` = NULL, + `errorCode` = NULL + WHERE id = vNightTaskFk; + + SET vError = NULL; + CALL nightTask_launchTask( + vSchema, + vProcedure, + vError, + vErrorCode + ); + + IF vError IS NOT NULL THEN + IF vLogMail IS NOT NULL THEN + CALL vn.mail_insert( + vLogMail, + NULL, + CONCAT('Nightly task failed (', vSchema, '.', vProcedure, ')'), + CONCAT( + '[', vErrorCode, '] ', vError, CHAR(13, 10), -- Line break + 'See ', SCHEMA(), '.nightTask table for more info.' + ) + ); + END IF; + + UPDATE nightTask + SET `error` = vError, + `errorCode` = vErrorCode + WHERE id = vNightTaskFk; + ELSE + UPDATE nightTask + SET finished = util.VN_NOW(), + lastFinished = util.VN_NOW() + WHERE id = vNightTaskFk; + END IF; + END LOOP; + CLOSE vQueue; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -7285,27 +7285,27 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cache_calc_end`(IN `v_calc` INT) -BEGIN - DECLARE v_cache_name VARCHAR(255); - DECLARE v_params VARCHAR(255); - - -- Libera el bloqueo y actualiza la fecha de ultimo refresco. - - UPDATE cache_calc cc JOIN cache c ON c.id = cc.cache_id - SET - cc.last_refresh = NOW(), - cc.expires = ADDTIME(NOW(), c.lifetime), - cc.connection_id = NULL - WHERE cc.id = v_calc; - - SELECT c.name, ca.params INTO v_cache_name, v_params - FROM cache c - JOIN cache_calc ca ON c.id = ca.cache_id - WHERE ca.id = v_calc; - - IF v_cache_name IS NOT NULL THEN - DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, ''))); - END IF; +BEGIN + DECLARE v_cache_name VARCHAR(255); + DECLARE v_params VARCHAR(255); + + -- Libera el bloqueo y actualiza la fecha de ultimo refresco. + + UPDATE cache_calc cc JOIN cache c ON c.id = cc.cache_id + SET + cc.last_refresh = NOW(), + cc.expires = ADDTIME(NOW(), c.lifetime), + cc.connection_id = NULL + WHERE cc.id = v_calc; + + SELECT c.name, ca.params INTO v_cache_name, v_params + FROM cache c + JOIN cache_calc ca ON c.id = ca.cache_id + WHERE ca.id = v_calc; + + IF v_cache_name IS NOT NULL THEN + DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, ''))); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -7323,89 +7323,89 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cache_calc_start`(OUT `v_calc` INT, INOUT `v_refresh` INT, IN `v_cache_name` VARCHAR(50), IN `v_params` VARCHAR(100)) -proc: BEGIN - DECLARE v_valid BOOL; - DECLARE v_lock_id VARCHAR(100); - DECLARE v_cache_id INT; - DECLARE v_expires DATETIME; - DECLARE v_clean_time DATETIME; - DECLARE vLastRefresh DATETIME; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - IF v_lock_id IS NOT NULL THEN - DO RELEASE_LOCK(v_lock_id); - END IF; - - RESIGNAL; - END; - - SET v_params = IFNULL(v_params, ''); - - -- Si el servidor se ha reiniciado invalida todos los calculos. - - SELECT COUNT(*) > 0 INTO v_valid FROM cache_valid; - - IF !v_valid - THEN - DELETE FROM cache_calc; - INSERT INTO cache_valid (valid) VALUES (TRUE); - END IF; - - -- Obtiene un bloqueo exclusivo para que no haya problemas de concurrencia. - - SET v_lock_id = CONCAT_WS('/', v_cache_name, v_params); - - IF !GET_LOCK(v_lock_id, 30) - THEN - SET v_calc = NULL; - SET v_refresh = FALSE; - LEAVE proc; - END IF; - - -- Comprueba si el calculo solicitado existe y esta actualizado. - - SELECT c.id, ca.id, ca.expires, ca.last_refresh - INTO v_cache_id, v_calc, v_expires, vLastRefresh - FROM cache c - LEFT JOIN cache_calc ca - ON ca.cache_id = c.id AND ca.params = v_params COLLATE 'utf8_general_ci' - WHERE c.name = v_cache_name COLLATE 'utf8_general_ci'; - - -- Si existe una calculo valido libera el bloqueo y devuelve su identificador. - - IF !v_refresh AND NOW() < v_expires AND vLastRefresh >= CURDATE() - THEN - DO RELEASE_LOCK(v_lock_id); - SET v_refresh = FALSE; - LEAVE proc; - END IF; - - -- Si el calculo no existe le crea una entrada en la tabla de calculos. - - IF v_calc IS NULL - THEN - INSERT INTO cache_calc SET - cache_id = v_cache_id, - cacheName = v_cache_name, - params = v_params, - last_refresh = NULL, - expires = NULL, - connection_id = CONNECTION_ID(); - - SET v_calc = LAST_INSERT_ID(); - ELSE - UPDATE cache_calc - SET - last_refresh = NULL, - expires = NULL, - connection_id = CONNECTION_ID() - WHERE id = v_calc; - END IF; - - -- Si se debe recalcular mantiene el bloqueo y devuelve su identificador. - - SET v_refresh = TRUE; +proc: BEGIN + DECLARE v_valid BOOL; + DECLARE v_lock_id VARCHAR(100); + DECLARE v_cache_id INT; + DECLARE v_expires DATETIME; + DECLARE v_clean_time DATETIME; + DECLARE vLastRefresh DATETIME; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + IF v_lock_id IS NOT NULL THEN + DO RELEASE_LOCK(v_lock_id); + END IF; + + RESIGNAL; + END; + + SET v_params = IFNULL(v_params, ''); + + -- Si el servidor se ha reiniciado invalida todos los calculos. + + SELECT COUNT(*) > 0 INTO v_valid FROM cache_valid; + + IF !v_valid + THEN + DELETE FROM cache_calc; + INSERT INTO cache_valid (valid) VALUES (TRUE); + END IF; + + -- Obtiene un bloqueo exclusivo para que no haya problemas de concurrencia. + + SET v_lock_id = CONCAT_WS('/', v_cache_name, v_params); + + IF !GET_LOCK(v_lock_id, 30) + THEN + SET v_calc = NULL; + SET v_refresh = FALSE; + LEAVE proc; + END IF; + + -- Comprueba si el calculo solicitado existe y esta actualizado. + + SELECT c.id, ca.id, ca.expires, ca.last_refresh + INTO v_cache_id, v_calc, v_expires, vLastRefresh + FROM cache c + LEFT JOIN cache_calc ca + ON ca.cache_id = c.id AND ca.params = v_params COLLATE 'utf8_general_ci' + WHERE c.name = v_cache_name COLLATE 'utf8_general_ci'; + + -- Si existe una calculo valido libera el bloqueo y devuelve su identificador. + + IF !v_refresh AND NOW() < v_expires AND vLastRefresh >= CURDATE() + THEN + DO RELEASE_LOCK(v_lock_id); + SET v_refresh = FALSE; + LEAVE proc; + END IF; + + -- Si el calculo no existe le crea una entrada en la tabla de calculos. + + IF v_calc IS NULL + THEN + INSERT INTO cache_calc SET + cache_id = v_cache_id, + cacheName = v_cache_name, + params = v_params, + last_refresh = NULL, + expires = NULL, + connection_id = CONNECTION_ID(); + + SET v_calc = LAST_INSERT_ID(); + ELSE + UPDATE cache_calc + SET + last_refresh = NULL, + expires = NULL, + connection_id = CONNECTION_ID() + WHERE id = v_calc; + END IF; + + -- Si se debe recalcular mantiene el bloqueo y devuelve su identificador. + + SET v_refresh = TRUE; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -10429,28 +10429,28 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `contact_request`( - vName VARCHAR(100), - vPhone VARCHAR(15), - vEmail VARCHAR(100), +CREATE DEFINER=`root`@`localhost` PROCEDURE `contact_request`( + vName VARCHAR(100), + vPhone VARCHAR(15), + vEmail VARCHAR(100), vMessage TEXT) READS SQL DATA -BEGIN -/** - * Set actions for contact request - * - * @param vName Name - * @param vPhone Phone number - * @param vEmail e-mail - * @param vMessage text of the message - */ - - CALL vn.mail_insert( - 'floranet@verdnatura.es', - vEmail, - 'Contact request', - CONCAT('Phone: ',vPhone, ' Message: ', vMessage) - ); +BEGIN +/** + * Set actions for contact request + * + * @param vName Name + * @param vPhone Phone number + * @param vEmail e-mail + * @param vMessage text of the message + */ + + CALL vn.mail_insert( + 'floranet@verdnatura.es', + vEmail, + 'Contact request', + CONCAT('Phone: ',vPhone, ' Message: ', vMessage) + ); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -10469,27 +10469,27 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `deliveryDate_get`(vPostalCode VARCHAR(15)) READS SQL DATA -BEGIN -/** - * Returns available dates for this postalCode, in the next seven days. - * - * @param vPostalCode Delivery address postal code - */ - DECLARE vCurrentDayOfWeek INT; - - SET vCurrentDayOfWeek = DAYOFWEEK(NOW()); - - SELECT DISTINCT nextDay - FROM ( - SELECT CURDATE() + INTERVAL IF( - apc.dayOfWeek >= vCurrentDayOfWeek, - apc.dayOfWeek - vCurrentDayOfWeek, - 7 - apc.dayOfWeek - ) DAY nextDay, - NOW() + INTERVAL apc.hoursInAdvance HOUR minDeliveryTime - FROM addressPostCode apc - WHERE apc.postCode = vPostalCode - HAVING nextDay > minDeliveryTime) sub; +BEGIN +/** + * Returns available dates for this postalCode, in the next seven days. + * + * @param vPostalCode Delivery address postal code + */ + DECLARE vCurrentDayOfWeek INT; + + SET vCurrentDayOfWeek = DAYOFWEEK(NOW()); + + SELECT DISTINCT nextDay + FROM ( + SELECT CURDATE() + INTERVAL IF( + apc.dayOfWeek >= vCurrentDayOfWeek, + apc.dayOfWeek - vCurrentDayOfWeek, + 7 - apc.dayOfWeek + ) DAY nextDay, + NOW() + INTERVAL apc.hoursInAdvance HOUR minDeliveryTime + FROM addressPostCode apc + WHERE apc.postCode = vPostalCode + HAVING nextDay > minDeliveryTime) sub; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -42397,37 +42397,37 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`vn`@`localhost` FUNCTION `client_getDebt`(`vClient` INT, `vDate` DATE) RETURNS decimal(10,2) READS SQL DATA -BEGIN -/** - * Returns the risk of a customer. - * - * @param vClient client id - * @param vDate date to check the risk - * @return Client risk - */ - DECLARE vDebt DECIMAL(10,2); - DECLARE vHasDebt BOOLEAN; - - SELECT COUNT(*) INTO vHasDebt - FROM `client` c - WHERE c.id = vClient AND c.typeFk = 'normal'; - - IF NOT vHasDebt THEN - RETURN 0; - END IF; - - CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt (clientFk INT); - INSERT INTO tmp.clientGetDebt SET clientFk = vClient; - - CALL vn.client_getDebt(vDate); - - SELECT risk INTO vDebt FROM tmp.risk; - - DROP TEMPORARY TABLE - tmp.clientGetDebt, - tmp.risk; - - RETURN vDebt; +BEGIN +/** + * Returns the risk of a customer. + * + * @param vClient client id + * @param vDate date to check the risk + * @return Client risk + */ + DECLARE vDebt DECIMAL(10,2); + DECLARE vHasDebt BOOLEAN; + + SELECT COUNT(*) INTO vHasDebt + FROM `client` c + WHERE c.id = vClient AND c.typeFk = 'normal'; + + IF NOT vHasDebt THEN + RETURN 0; + END IF; + + CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt (clientFk INT); + INSERT INTO tmp.clientGetDebt SET clientFk = vClient; + + CALL vn.client_getDebt(vDate); + + SELECT risk INTO vDebt FROM tmp.risk; + + DROP TEMPORARY TABLE + tmp.clientGetDebt, + tmp.risk; + + RETURN vDebt; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -51221,93 +51221,93 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_addWithReservation`( - vItemFk INT, - vQuantity INT, - vTicketFk INT, - vSaleGroupFk INT, - vSectorFk INT +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_addWithReservation`( + vItemFk INT, + vQuantity INT, + vTicketFk INT, + vSaleGroupFk INT, + vSectorFk INT ) -BEGIN -/** - * En el ámbito de las colecciones se añade una línea de sale a un ticket - * de una colección en caso de tener disponible y se realiza la reserva. - * - * @param vItemFk id of item - * @param vQuantity quantity to be added to the ticket - * @param vTicketFk ticket to which the sales line is added - * @param vSaleGroupFk saleGroupFk id to add saleGroupDetail - */ - - DECLARE vWarehouseFk INT; - DECLARE vCacheAvailableFk INT; - DECLARE vAvailable INT; - DECLARE vSaleFk INT; - DECLARE vConcept VARCHAR(50); - DECLARE vItemName VARCHAR(50); - DECLARE vHasThrow BOOLEAN DEFAULT FALSE; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - SELECT t.warehouseFk INTO vWarehouseFk - FROM ticket t - JOIN ticketCollection tc ON tc.ticketFk = t.id - WHERE t.id = vTicketFk; - - CALL cache.available_refresh( - vCacheAvailableFk, - FALSE, - vWarehouseFk, - util.VN_CURDATE()); - - SELECT available INTO vAvailable - FROM cache.available - WHERE calc_id = vCacheAvailableFk - AND item_id = vItemFk; - - IF vAvailable < vQuantity THEN - SET vHasThrow = TRUE; - ELSE - SELECT `name`, - CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name) - INTO vItemName, vConcept - FROM item - WHERE id = vItemFk; - - START TRANSACTION; - - INSERT INTO sale - SET itemFk = vItemFk, - ticketFk = vTicketFk, - concept = vConcept, - quantity = vQuantity, - isAdded = TRUE; - - SELECT LAST_INSERT_ID() INTO vSaleFk; - - CALL sale_calculateComponent(vSaleFk, NULL); - CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); - - IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN - SET vHasThrow = TRUE; - END IF; - END IF; - - IF vHasThrow THEN - CALL util.throw("There is no available for the selected item"); - END IF; - - IF vSaleGroupFk THEN - INSERT INTO saleGroupDetail - SET saleFk = vSaleFk, - saleGroupFk = vSaleGroupFk; - END IF; - - COMMIT; +BEGIN +/** + * En el ámbito de las colecciones se añade una línea de sale a un ticket + * de una colección en caso de tener disponible y se realiza la reserva. + * + * @param vItemFk id of item + * @param vQuantity quantity to be added to the ticket + * @param vTicketFk ticket to which the sales line is added + * @param vSaleGroupFk saleGroupFk id to add saleGroupDetail + */ + + DECLARE vWarehouseFk INT; + DECLARE vCacheAvailableFk INT; + DECLARE vAvailable INT; + DECLARE vSaleFk INT; + DECLARE vConcept VARCHAR(50); + DECLARE vItemName VARCHAR(50); + DECLARE vHasThrow BOOLEAN DEFAULT FALSE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + SELECT t.warehouseFk INTO vWarehouseFk + FROM ticket t + JOIN ticketCollection tc ON tc.ticketFk = t.id + WHERE t.id = vTicketFk; + + CALL cache.available_refresh( + vCacheAvailableFk, + FALSE, + vWarehouseFk, + util.VN_CURDATE()); + + SELECT available INTO vAvailable + FROM cache.available + WHERE calc_id = vCacheAvailableFk + AND item_id = vItemFk; + + IF vAvailable < vQuantity THEN + SET vHasThrow = TRUE; + ELSE + SELECT `name`, + CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name) + INTO vItemName, vConcept + FROM item + WHERE id = vItemFk; + + START TRANSACTION; + + INSERT INTO sale + SET itemFk = vItemFk, + ticketFk = vTicketFk, + concept = vConcept, + quantity = vQuantity, + isAdded = TRUE; + + SELECT LAST_INSERT_ID() INTO vSaleFk; + + CALL sale_calculateComponent(vSaleFk, NULL); + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); + + IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN + SET vHasThrow = TRUE; + END IF; + END IF; + + IF vHasThrow THEN + CALL util.throw("There is no available for the selected item"); + END IF; + + IF vSaleGroupFk THEN + INSERT INTO saleGroupDetail + SET saleFk = vSaleFk, + saleGroupFk = vSaleGroupFk; + END IF; + + COMMIT; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -51324,145 +51324,145 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_assign`( - vUserFk INT, - OUT vCollectionFk INT +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_assign`( + vUserFk INT, + OUT vCollectionFk INT ) -BEGIN -/** - * Comprueba si existen colecciones libres que se ajustan - * al perfil del usuario y le asigna la más antigua. - * Añade un registro al semillero de colecciones. - * - * @param vUserFk Id de usuario - * @param vCollectionFk Id de colección - */ - DECLARE vHasTooMuchCollections BOOL; - DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vCollectionWorker INT; - DECLARE vMaxNotAssignedCollectionLifeTime TIME; - - DECLARE vCollections CURSOR FOR - WITH collections AS ( - SELECT tc.collectionFk, - SUM(sv.volume) volume, - c.saleTotalCount, - c.itemPackingTypeFk, - c.trainFk, - c.warehouseFk, - c.wagons - FROM vn.ticketCollection tc - JOIN vn.collection c ON c.id = tc.collectionFk - JOIN vn.saleVolume sv ON sv.ticketFk = tc.ticketFk - WHERE c.workerFk IS NULL - AND sv.shipped >= util.VN_CURDATE() - GROUP BY tc.collectionFk - ) SELECT c.collectionFk - FROM collections c - JOIN vn.operator o - WHERE o.workerFk = vUserFk - AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) - AND (c.itemPackingTypeFk = o.itemPackingTypeFk OR o.itemPackingTypeFk IS NULL) - AND o.numberOfWagons = c.wagons - AND o.trainFk = c.trainFk - AND o.warehouseFk = c.warehouseFk; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - -- Si hay colecciones sin terminar, sale del proceso - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - CALL collection_get(vUserFk); - - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime - INTO vHasTooMuchCollections, vMaxNotAssignedCollectionLifeTime - FROM productionConfig pc - LEFT JOIN tmp.collection ON TRUE; - - DROP TEMPORARY TABLE tmp.collection; - - IF vHasTooMuchCollections THEN - CALL util.throw('Hay colecciones pendientes'); - END IF; - - -- Se eliminan las colecciones sin asignar que estan obsoletas - - INSERT INTO ticketTracking(stateFk, ticketFk) - SELECT s.id, tc.ticketFk - FROM `collection` c - JOIN ticketCollection tc ON tc.collectionFk = c.id - JOIN `state` s ON s.code = 'PRINTED_AUTO' - WHERE c.workerFk IS NULL - AND TIMEDIFF(util.VN_NOW(), c.created) > vMaxNotAssignedCollectionLifeTime; - - DELETE FROM `collection` - WHERE workerFk IS NULL - AND TIMEDIFF(util.VN_NOW(), created) > vMaxNotAssignedCollectionLifeTime; - - -- Se añade registro al semillero - - INSERT INTO collectionHotbed(userFk) VALUES(vUserFk); - - -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion - - OPEN vCollections; - l: LOOP - SET vDone = FALSE; - FETCH vCollections INTO vCollectionFk; - - IF vDone THEN - LEAVE l; - END IF; - - BEGIN - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - SET vCollectionFk = NULL; - RESIGNAL; - END; - - START TRANSACTION; - - SELECT workerFk INTO vCollectionWorker - FROM `collection` - WHERE id = vCollectionFk FOR UPDATE; - - IF vCollectionWorker IS NULL THEN - UPDATE `collection` - SET workerFk = vUserFk - WHERE id = vCollectionFk; - - COMMIT; - LEAVE l; - END IF; - - ROLLBACK; - END; - END LOOP; - CLOSE vCollections; - - IF vCollectionFk IS NULL THEN - CALL collection_new(vUserFk, vCollectionFk); - - START TRANSACTION; - - SELECT workerFk INTO vCollectionWorker - FROM `collection` - WHERE id = vCollectionFk FOR UPDATE; - - IF vCollectionWorker IS NULL THEN - UPDATE `collection` - SET workerFk = vUserFk - WHERE id = vCollectionFk; - END IF; - - COMMIT; - END IF; +BEGIN +/** + * Comprueba si existen colecciones libres que se ajustan + * al perfil del usuario y le asigna la más antigua. + * Añade un registro al semillero de colecciones. + * + * @param vUserFk Id de usuario + * @param vCollectionFk Id de colección + */ + DECLARE vHasTooMuchCollections BOOL; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vCollectionWorker INT; + DECLARE vMaxNotAssignedCollectionLifeTime TIME; + + DECLARE vCollections CURSOR FOR + WITH collections AS ( + SELECT tc.collectionFk, + SUM(sv.volume) volume, + c.saleTotalCount, + c.itemPackingTypeFk, + c.trainFk, + c.warehouseFk, + c.wagons + FROM vn.ticketCollection tc + JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.saleVolume sv ON sv.ticketFk = tc.ticketFk + WHERE c.workerFk IS NULL + AND sv.shipped >= util.VN_CURDATE() + GROUP BY tc.collectionFk + ) SELECT c.collectionFk + FROM collections c + JOIN vn.operator o + WHERE o.workerFk = vUserFk + AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) + AND (c.itemPackingTypeFk = o.itemPackingTypeFk OR o.itemPackingTypeFk IS NULL) + AND o.numberOfWagons = c.wagons + AND o.trainFk = c.trainFk + AND o.warehouseFk = c.warehouseFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + -- Si hay colecciones sin terminar, sale del proceso + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + CALL collection_get(vUserFk); + + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime + INTO vHasTooMuchCollections, vMaxNotAssignedCollectionLifeTime + FROM productionConfig pc + LEFT JOIN tmp.collection ON TRUE; + + DROP TEMPORARY TABLE tmp.collection; + + IF vHasTooMuchCollections THEN + CALL util.throw('Hay colecciones pendientes'); + END IF; + + -- Se eliminan las colecciones sin asignar que estan obsoletas + + INSERT INTO ticketTracking(stateFk, ticketFk) + SELECT s.id, tc.ticketFk + FROM `collection` c + JOIN ticketCollection tc ON tc.collectionFk = c.id + JOIN `state` s ON s.code = 'PRINTED_AUTO' + WHERE c.workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), c.created) > vMaxNotAssignedCollectionLifeTime; + + DELETE FROM `collection` + WHERE workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), created) > vMaxNotAssignedCollectionLifeTime; + + -- Se añade registro al semillero + + INSERT INTO collectionHotbed(userFk) VALUES(vUserFk); + + -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion + + OPEN vCollections; + l: LOOP + SET vDone = FALSE; + FETCH vCollections INTO vCollectionFk; + + IF vDone THEN + LEAVE l; + END IF; + + BEGIN + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + SET vCollectionFk = NULL; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + + COMMIT; + LEAVE l; + END IF; + + ROLLBACK; + END; + END LOOP; + CLOSE vCollections; + + IF vCollectionFk IS NULL THEN + CALL collection_new(vUserFk, vCollectionFk); + + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + END IF; + + COMMIT; + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -51530,146 +51530,146 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_getAssigned`( - vUserFk INT, - OUT vCollectionFk INT +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_getAssigned`( + vUserFk INT, + OUT vCollectionFk INT ) -BEGIN -/** - * Comprueba si existen colecciones libres que se ajustan - * al perfil del usuario y le asigna la más antigua. - * Añade un registro al semillero de colecciones. - * - * @param vUserFk Id de usuario - * @param vCollectionFk Id de colección - */ - DECLARE vHasTooMuchCollections BOOL; - DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vCollectionWorker INT; - DECLARE vMaxNotAssignedCollectionLifeTime TIME; - - DECLARE vCollections CURSOR FOR - WITH collections AS ( - SELECT tc.collectionFk, - SUM(sv.volume) volume, - c.saleTotalCount, - c.itemPackingTypeFk, - c.trainFk, - c.warehouseFk, - c.wagons - FROM vn.ticketCollection tc - JOIN vn.collection c ON c.id = tc.collectionFk - JOIN vn.saleVolume sv ON sv.ticketFk = tc.ticketFk - WHERE c.workerFk IS NULL - AND sv.shipped >= util.VN_CURDATE() - GROUP BY tc.collectionFk - ) SELECT c.collectionFk - FROM collections c - JOIN vn.operator o - WHERE o.workerFk = vUserFk - AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) - AND (c.itemPackingTypeFk = o.itemPackingTypeFk OR o.itemPackingTypeFk IS NULL) - AND o.numberOfWagons = c.wagons - AND o.trainFk = c.trainFk - AND o.warehouseFk = c.warehouseFk; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - -- Si hay colecciones sin terminar, sale del proceso - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - CALL collection_get(vUserFk); - - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime - INTO vHasTooMuchCollections, vMaxNotAssignedCollectionLifeTime - FROM productionConfig pc - LEFT JOIN tmp.collection ON TRUE; - - DROP TEMPORARY TABLE tmp.collection; - - IF vHasTooMuchCollections THEN - CALL util.throw('Hay colecciones pendientes'); - END IF; - - -- Se eliminan las colecciones sin asignar que estan obsoletas - - INSERT INTO ticketTracking(stateFk, ticketFk) - SELECT s.id, tc.ticketFk - FROM `collection` c - JOIN ticketCollection tc ON tc.collectionFk = c.id - JOIN `state` s ON s.code = 'PRINTED_AUTO' - WHERE c.workerFk IS NULL - AND TIMEDIFF(util.VN_NOW(), c.created) > vMaxNotAssignedCollectionLifeTime; - - DELETE FROM `collection` - WHERE workerFk IS NULL - AND TIMEDIFF(util.VN_NOW(), created) > vMaxNotAssignedCollectionLifeTime; - - -- Se añade registro al semillero - - INSERT INTO collectionHotbed(userFk) VALUES(vUserFk); - - -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion - - OPEN vCollections; - l: LOOP - SET vDone = FALSE; - FETCH vCollections INTO vCollectionFk; - - IF vDone THEN - LEAVE l; - END IF; - - BEGIN - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - SET vCollectionFk = NULL; - RESIGNAL; - END; - - START TRANSACTION; - - SELECT workerFk INTO vCollectionWorker - FROM `collection` - WHERE id = vCollectionFk FOR UPDATE; - - IF vCollectionWorker IS NULL THEN - UPDATE `collection` - SET workerFk = vUserFk - WHERE id = vCollectionFk; - - COMMIT; - LEAVE l; - END IF; - - ROLLBACK; - END; - END LOOP; - CLOSE vCollections; - - IF vCollectionFk IS NULL THEN - CALL collection_new(vUserFk, vCollectionFk); - - START TRANSACTION; - - SELECT workerFk INTO vCollectionWorker - FROM `collection` - WHERE id = vCollectionFk FOR UPDATE; - - IF vCollectionWorker IS NULL THEN - UPDATE `collection` - SET workerFk = vUserFk - WHERE id = vCollectionFk; - END IF; - - COMMIT; - END IF; - CALL itemShelvingSale_addByCollection(vCollectionFk); +BEGIN +/** + * Comprueba si existen colecciones libres que se ajustan + * al perfil del usuario y le asigna la más antigua. + * Añade un registro al semillero de colecciones. + * + * @param vUserFk Id de usuario + * @param vCollectionFk Id de colección + */ + DECLARE vHasTooMuchCollections BOOL; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vCollectionWorker INT; + DECLARE vMaxNotAssignedCollectionLifeTime TIME; + + DECLARE vCollections CURSOR FOR + WITH collections AS ( + SELECT tc.collectionFk, + SUM(sv.volume) volume, + c.saleTotalCount, + c.itemPackingTypeFk, + c.trainFk, + c.warehouseFk, + c.wagons + FROM vn.ticketCollection tc + JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.saleVolume sv ON sv.ticketFk = tc.ticketFk + WHERE c.workerFk IS NULL + AND sv.shipped >= util.VN_CURDATE() + GROUP BY tc.collectionFk + ) SELECT c.collectionFk + FROM collections c + JOIN vn.operator o + WHERE o.workerFk = vUserFk + AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) + AND (c.itemPackingTypeFk = o.itemPackingTypeFk OR o.itemPackingTypeFk IS NULL) + AND o.numberOfWagons = c.wagons + AND o.trainFk = c.trainFk + AND o.warehouseFk = c.warehouseFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + -- Si hay colecciones sin terminar, sale del proceso + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + CALL collection_get(vUserFk); + + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime + INTO vHasTooMuchCollections, vMaxNotAssignedCollectionLifeTime + FROM productionConfig pc + LEFT JOIN tmp.collection ON TRUE; + + DROP TEMPORARY TABLE tmp.collection; + + IF vHasTooMuchCollections THEN + CALL util.throw('Hay colecciones pendientes'); + END IF; + + -- Se eliminan las colecciones sin asignar que estan obsoletas + + INSERT INTO ticketTracking(stateFk, ticketFk) + SELECT s.id, tc.ticketFk + FROM `collection` c + JOIN ticketCollection tc ON tc.collectionFk = c.id + JOIN `state` s ON s.code = 'PRINTED_AUTO' + WHERE c.workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), c.created) > vMaxNotAssignedCollectionLifeTime; + + DELETE FROM `collection` + WHERE workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), created) > vMaxNotAssignedCollectionLifeTime; + + -- Se añade registro al semillero + + INSERT INTO collectionHotbed(userFk) VALUES(vUserFk); + + -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion + + OPEN vCollections; + l: LOOP + SET vDone = FALSE; + FETCH vCollections INTO vCollectionFk; + + IF vDone THEN + LEAVE l; + END IF; + + BEGIN + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + SET vCollectionFk = NULL; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + + COMMIT; + LEAVE l; + END IF; + + ROLLBACK; + END; + END LOOP; + CLOSE vCollections; + + IF vCollectionFk IS NULL THEN + CALL collection_new(vUserFk, vCollectionFk); + + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + END IF; + + COMMIT; + END IF; + CALL itemShelvingSale_addByCollection(vCollectionFk); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60050,53 +60050,53 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_addByCollection`( - vCollectionFk INT(11) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_addByCollection`( + vCollectionFk INT(11) ) -BEGIN -/** - * Reserva cantidades con ubicaciones para el contenido de una colección - * - * @param vCollectionFk Identificador de collection - */ - DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vSaleFk INT; - DECLARE vSales CURSOR FOR - WITH sales AS ( - SELECT s.id saleFk, s.quantity, SUM(IFNULL(iss.quantity, 0)) quantityReserved - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id - WHERE tc.collectionFk = vCollectionFk - GROUP BY s.id - HAVING quantity <> quantityReserved - ), trackedSales AS ( - SELECT sa.saleFk - FROM sales sa - JOIN vn.saleTracking st ON st.saleFk = sa.saleFk - JOIN vn.`state` s ON s.id = st.stateFk - WHERE st.isChecked - AND s.`code` IN ('PREVIOUS_PREPARATION', 'OK PREVIOUS', 'OK STOWAWAY') - GROUP BY sa.saleFk - ) SELECT s.saleFk - FROM sales s - LEFT JOIN trackedSales ts ON ts.saleFk = s.saleFk - WHERE ts.saleFk IS NULL; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - OPEN vSales; - l: LOOP - SET vDone = FALSE; - FETCH vSales INTO vSaleFk; - - IF vDone THEN - LEAVE l; - END IF; - - CALL itemShelvingSale_addBySale(vSaleFk, NULL); - END LOOP; - CLOSE vSales; +BEGIN +/** + * Reserva cantidades con ubicaciones para el contenido de una colección + * + * @param vCollectionFk Identificador de collection + */ + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSaleFk INT; + DECLARE vSales CURSOR FOR + WITH sales AS ( + SELECT s.id saleFk, s.quantity, SUM(IFNULL(iss.quantity, 0)) quantityReserved + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id + WHERE tc.collectionFk = vCollectionFk + GROUP BY s.id + HAVING quantity <> quantityReserved + ), trackedSales AS ( + SELECT sa.saleFk + FROM sales sa + JOIN vn.saleTracking st ON st.saleFk = sa.saleFk + JOIN vn.`state` s ON s.id = st.stateFk + WHERE st.isChecked + AND s.`code` IN ('PREVIOUS_PREPARATION', 'OK PREVIOUS', 'OK STOWAWAY') + GROUP BY sa.saleFk + ) SELECT s.saleFk + FROM sales s + LEFT JOIN trackedSales ts ON ts.saleFk = s.saleFk + WHERE ts.saleFk IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vSales; + l: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL itemShelvingSale_addBySale(vSaleFk, NULL); + END LOOP; + CLOSE vSales; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60437,56 +60437,56 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_doReserve`() -proc: BEGIN -/** - * Genera reservas de la tabla vn.itemShelvingSaleReserve - */ - DECLARE vDone BOOL; - DECLARE vSaleFk INT; - DECLARE vSectorFk INT; - - DECLARE vSales CURSOR FOR - SELECT DISTINCT saleFk, sectorFk FROM tSale; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('vn.itemShelvingSale_doReserve'); - ROLLBACK; - RESIGNAL; - END; - - IF !GET_LOCK('vn.itemShelvingSale_doReserve', 0) THEN - LEAVE proc; - END IF; - - CREATE OR REPLACE TEMPORARY TABLE tSale - ENGINE = MEMORY - SELECT id, saleFk, sectorFk FROM itemShelvingSaleReserve; - - OPEN vSales; - - myLoop: LOOP - SET vDone = FALSE; - FETCH vSales INTO vSaleFk, vSectorFk; - - IF vDone THEN - LEAVE myLoop; - END IF; - - CALL itemShelvingSale_addBySale (vSaleFk, vSectorFk); - END LOOP; - - CLOSE vSales; - - DELETE iss FROM itemShelvingSaleReserve iss - JOIN tSale s ON s.id = iss.id AND s.sectorFk = iss.sectorFk; - - DROP TEMPORARY TABLE tSale; - - DO RELEASE_LOCK('vn.itemShelvingSale_doReserve'); +proc: BEGIN +/** + * Genera reservas de la tabla vn.itemShelvingSaleReserve + */ + DECLARE vDone BOOL; + DECLARE vSaleFk INT; + DECLARE vSectorFk INT; + + DECLARE vSales CURSOR FOR + SELECT DISTINCT saleFk, sectorFk FROM tSale; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK('vn.itemShelvingSale_doReserve'); + ROLLBACK; + RESIGNAL; + END; + + IF !GET_LOCK('vn.itemShelvingSale_doReserve', 0) THEN + LEAVE proc; + END IF; + + CREATE OR REPLACE TEMPORARY TABLE tSale + ENGINE = MEMORY + SELECT id, saleFk, sectorFk FROM itemShelvingSaleReserve; + + OPEN vSales; + + myLoop: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk, vSectorFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + CALL itemShelvingSale_addBySale (vSaleFk, vSectorFk); + END LOOP; + + CLOSE vSales; + + DELETE iss FROM itemShelvingSaleReserve iss + JOIN tSale s ON s.id = iss.id AND s.sectorFk = iss.sectorFk; + + DROP TEMPORARY TABLE tSale; + + DO RELEASE_LOCK('vn.itemShelvingSale_doReserve'); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60571,37 +60571,37 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_setPicked`( - vSaleGroupFk INT(10) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_setPicked`( + vSaleGroupFk INT(10) ) -BEGIN -/** - * Gestiona la reserva de un vn.saleGroup actualizando vn.itemShelvingSale.isPicked - * y cambiando el estado de la vn.sale - * - * @param vSaleGroupFk Id saleGroupFk - */ - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - IF NOT (SELECT COUNT(*) FROM saleGroup WHERE id = vSaleGroupFk) THEN - CALL util.throw('Sale group not exists'); - END IF; - - START TRANSACTION; - - UPDATE itemShelvingSale iss - JOIN sale s ON s.id = iss.saleFk - JOIN saleGroupDetail sg ON sg.saleFk = s.id - SET iss.isPicked = TRUE - WHERE sg.saleGroupFk = vSaleGroupFk; - - CALL saleTracking_addPreparedSaleGroup(vSaleGroupFk); - - COMMIT; +BEGIN +/** + * Gestiona la reserva de un vn.saleGroup actualizando vn.itemShelvingSale.isPicked + * y cambiando el estado de la vn.sale + * + * @param vSaleGroupFk Id saleGroupFk + */ + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF NOT (SELECT COUNT(*) FROM saleGroup WHERE id = vSaleGroupFk) THEN + CALL util.throw('Sale group not exists'); + END IF; + + START TRANSACTION; + + UPDATE itemShelvingSale iss + JOIN sale s ON s.id = iss.saleFk + JOIN saleGroupDetail sg ON sg.saleFk = s.id + SET iss.isPicked = TRUE + WHERE sg.saleGroupFk = vSaleGroupFk; + + CALL saleTracking_addPreparedSaleGroup(vSaleGroupFk); + + COMMIT; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60618,114 +60618,114 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_setQuantity`( - vItemShelvingSaleFk INT(10), - vQuantity DECIMAL(10,0), - vIsItemShelvingSaleEmpty BOOLEAN, - vSectorFk INT +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_setQuantity`( + vItemShelvingSaleFk INT(10), + vQuantity DECIMAL(10,0), + vIsItemShelvingSaleEmpty BOOLEAN, + vSectorFk INT ) -BEGIN -/** - * Gestiona la reserva de un itemShelvingFk, actualizando isPicked y quantity - * en itemShelvingSale y sale.isPicked en caso necesario. - * Si la reserva de la ubicación es fallida, se regulariza la situación - * - * @param vItemShelvingSaleFk Id itemShelvingSaleFK - * @param vQuantity Cantidad real que se ha cogido de la ubicación - * @param vIsItemShelvingSaleEmpty determina si la ubicación itemShelvingSale se ha - * quedado vacio tras el movimiento - * @param vSectorFk Id del sector - */ - DECLARE vSaleFk INT; - DECLARE vItemShelvingFk INT; - DECLARE vReservedQuantity INT; - DECLARE vRemainingQuantity INT; - DECLARE vItemFk INT; - DECLARE vTotalQuantity INT; - DECLARE vStateCode VARCHAR(45); - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - IF vQuantity > vReservedQuantity - OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) - OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN - CALL util.throw('The quantity cannot be different from the reserved'); - END IF; - - IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN - CALL util.throw('Reservation completed'); - END IF; - - SELECT s.itemFk, - iss.saleFk, - iss.itemShelvingFk, - SUM(IFNULL(iss.quantity,0)), - IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED') - INTO vItemFk, - vSaleFk, - vItemShelvingFk, - vReservedQuantity, - vStateCode - FROM itemShelvingSale iss - JOIN sale s ON s.id = iss.saleFk - LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk - WHERE iss.id = vItemShelvingSaleFk - AND NOT iss.isPicked; - - IF vQuantity > vReservedQuantity - OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) - OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN - CALL util.throw('The quantity cannot be different from the reserved'); - END IF; - - START TRANSACTION; - - UPDATE itemShelvingSale - SET isPicked = TRUE, - quantity = vQuantity - WHERE id = vItemShelvingSaleFk; - - SELECT id INTO vItemShelvingFk - FROM itemShelving - WHERE id = vItemShelvingFk - FOR UPDATE; - - UPDATE itemShelving - SET visible = GREATEST(0, visible - vQuantity) - WHERE id = vItemShelvingFk; - - SELECT SUM(IF(isPicked OR id = vItemShelvingSaleFk, 0, quantity)), SUM(quantity) - INTO vRemainingQuantity, vTotalQuantity - FROM itemShelvingSale - WHERE saleFk = vSaleFk; - - IF vRemainingQuantity = 0 AND NOT vIsItemShelvingSaleEmpty THEN - CALL saleTracking_new( - vSaleFk, - TRUE, - vTotalQuantity, - `account`.`myUser_getId`(), - NULL, - vStateCode, - TRUE); - - UPDATE sale s - SET s.quantity = vTotalQuantity, - isPicked = TRUE - WHERE s.id = vSaleFk; - END IF; - - COMMIT; - - IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk) - SELECT vSaleFk, vSectorFk; - CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk); - END IF; +BEGIN +/** + * Gestiona la reserva de un itemShelvingFk, actualizando isPicked y quantity + * en itemShelvingSale y sale.isPicked en caso necesario. + * Si la reserva de la ubicación es fallida, se regulariza la situación + * + * @param vItemShelvingSaleFk Id itemShelvingSaleFK + * @param vQuantity Cantidad real que se ha cogido de la ubicación + * @param vIsItemShelvingSaleEmpty determina si la ubicación itemShelvingSale se ha + * quedado vacio tras el movimiento + * @param vSectorFk Id del sector + */ + DECLARE vSaleFk INT; + DECLARE vItemShelvingFk INT; + DECLARE vReservedQuantity INT; + DECLARE vRemainingQuantity INT; + DECLARE vItemFk INT; + DECLARE vTotalQuantity INT; + DECLARE vStateCode VARCHAR(45); + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF vQuantity > vReservedQuantity + OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) + OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN + CALL util.throw('The quantity cannot be different from the reserved'); + END IF; + + IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN + CALL util.throw('Reservation completed'); + END IF; + + SELECT s.itemFk, + iss.saleFk, + iss.itemShelvingFk, + SUM(IFNULL(iss.quantity,0)), + IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED') + INTO vItemFk, + vSaleFk, + vItemShelvingFk, + vReservedQuantity, + vStateCode + FROM itemShelvingSale iss + JOIN sale s ON s.id = iss.saleFk + LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk + WHERE iss.id = vItemShelvingSaleFk + AND NOT iss.isPicked; + + IF vQuantity > vReservedQuantity + OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) + OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN + CALL util.throw('The quantity cannot be different from the reserved'); + END IF; + + START TRANSACTION; + + UPDATE itemShelvingSale + SET isPicked = TRUE, + quantity = vQuantity + WHERE id = vItemShelvingSaleFk; + + SELECT id INTO vItemShelvingFk + FROM itemShelving + WHERE id = vItemShelvingFk + FOR UPDATE; + + UPDATE itemShelving + SET visible = GREATEST(0, visible - vQuantity) + WHERE id = vItemShelvingFk; + + SELECT SUM(IF(isPicked OR id = vItemShelvingSaleFk, 0, quantity)), SUM(quantity) + INTO vRemainingQuantity, vTotalQuantity + FROM itemShelvingSale + WHERE saleFk = vSaleFk; + + IF vRemainingQuantity = 0 AND NOT vIsItemShelvingSaleEmpty THEN + CALL saleTracking_new( + vSaleFk, + TRUE, + vTotalQuantity, + `account`.`myUser_getId`(), + NULL, + vStateCode, + TRUE); + + UPDATE sale s + SET s.quantity = vTotalQuantity, + isPicked = TRUE + WHERE s.id = vSaleFk; + END IF; + + COMMIT; + + IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN + INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk) + SELECT vSaleFk, vSectorFk; + CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60742,63 +60742,63 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_unpicked`( - vSelf INT(11) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_unpicked`( + vSelf INT(11) ) -BEGIN -/** - * Desmarca una línea que ya estaba sacada, devolviendo la cantidad al itemShelving - * - * @param vSelf Identificador del itemShelvingSale - */ - DECLARE vSaleFk INT; - DECLARE vReservedQuantity INT; - DECLARE vIsSaleGroup BOOL; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - IF (SELECT NOT isPicked FROM itemShelvingSale WHERE id = vSelf) THEN - CALL util.throw('Reserva no completada'); - END IF; - - SELECT ish.saleFk, ish.quantity, IF(sg.id, TRUE, FALSE) - INTO vSaleFk, vReservedQuantity, vIsSaleGroup - FROM itemShelvingSale ish - LEFT JOIN saleGroupDetail sg ON sg.saleFk = ish.saleFk - WHERE ish.id = vSelf; - - /*IF vIsSaleGroup THEN - CALL util.throw('Can not unpicked a sale group'); - END IF;*/ - - START TRANSACTION; - - UPDATE itemShelvingSale - SET isPicked = FALSE - WHERE id = vSelf; - - UPDATE sale s - JOIN itemShelvingSale ish ON ish.saleFk = s.id - SET s.isPicked = FALSE - WHERE ish.id = vSelf; - - UPDATE itemShelvingSale iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - SET ish.visible = ish.visible + iss.quantity - WHERE iss.id = vSelf; - - CALL saleTracking_new( - vSaleFk, - FALSE, - vReservedQuantity, - `account`.`myUser_getId`(), - NULL, - 'ON_PREPARATION', - TRUE); - COMMIT; +BEGIN +/** + * Desmarca una línea que ya estaba sacada, devolviendo la cantidad al itemShelving + * + * @param vSelf Identificador del itemShelvingSale + */ + DECLARE vSaleFk INT; + DECLARE vReservedQuantity INT; + DECLARE vIsSaleGroup BOOL; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF (SELECT NOT isPicked FROM itemShelvingSale WHERE id = vSelf) THEN + CALL util.throw('Reserva no completada'); + END IF; + + SELECT ish.saleFk, ish.quantity, IF(sg.id, TRUE, FALSE) + INTO vSaleFk, vReservedQuantity, vIsSaleGroup + FROM itemShelvingSale ish + LEFT JOIN saleGroupDetail sg ON sg.saleFk = ish.saleFk + WHERE ish.id = vSelf; + + /*IF vIsSaleGroup THEN + CALL util.throw('Can not unpicked a sale group'); + END IF;*/ + + START TRANSACTION; + + UPDATE itemShelvingSale + SET isPicked = FALSE + WHERE id = vSelf; + + UPDATE sale s + JOIN itemShelvingSale ish ON ish.saleFk = s.id + SET s.isPicked = FALSE + WHERE ish.id = vSelf; + + UPDATE itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + SET ish.visible = ish.visible + iss.quantity + WHERE iss.id = vSelf; + + CALL saleTracking_new( + vSaleFk, + FALSE, + vReservedQuantity, + `account`.`myUser_getId`(), + NULL, + 'ON_PREPARATION', + TRUE); + COMMIT; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -61293,167 +61293,167 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_getSaleDate`(vShelvingFk VARCHAR(3)) -BEGIN - - /* Devuelve la mínima fecha en que se necesita cada producto en esa matrícula. - * - * @param vShelvingFk Matrícula del carro o pallet - */ - - DECLARE vWarehouseFk INT; - DECLARE vStockScopeDays INT; - - SELECT s.warehouseFk, stockScopeDays - INTO vWarehouseFk, vStockScopeDays - FROM sector s - JOIN operator o ON s.id = o.sectorFk - JOIN productionConfig pc - WHERE o.workerFk = account.myUser_getId(); - - IF vWarehouseFk IS NULL - THEN CALL util.throw('WarehouseFk not setted'); - END IF; - - IF vStockScopeDays IS NULL - THEN CALL util.throw('StockScopeDays not setted'); - END IF; - - CREATE OR REPLACE TEMPORARY TABLE tmp.tItems - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT itemFk, SUM(visible) visible - FROM itemShelving - WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci - GROUP BY itemFk; - - CREATE OR REPLACE TEMPORARY TABLE tmp.tStockByDay - (INDEX (itemFk, dated)) - ENGINE = MEMORY - SELECT dated, - SUM(t3.amount) OVER (PARTITION BY t3.itemFk ORDER BY dated) stock, - t3.itemFk - FROM ( - SELECT t.itemFk, dated, SUM(amount) amount - FROM ( - SELECT t2.itemFk, t2.amount, t2.dated - FROM ( - SELECT item_id itemFk, amount, util.VN_CURDATE() dated - FROM cache.stock s - JOIN tmp.tItems i ON i.itemFk = s.item_id - WHERE s.warehouse_id = vWarehouseFk - UNION ALL - SELECT ish.itemFk, - SUM(ish.visible), util.VN_CURDATE() - FROM itemShelving ish - JOIN tmp.tItems i ON i.itemFk = ish.itemFk - JOIN shelving sh ON sh.code = ish.shelvingFk - JOIN parking p ON sh.parkingFk = p.id - JOIN sector s ON s.id = p.sectorFk - WHERE s.isReserve - GROUP BY ish.itemFk - UNION ALL - SELECT iei.itemFk, SUM(quantity), landed - FROM itemEntryIn iei - JOIN tmp.tItems i ON i.itemFk = iei.itemFk - WHERE iei.landed BETWEEN util.VN_CURDATE() AND util.VN_CURDATE() + INTERVAL vStockScopeDays DAY - AND iei.warehouseInFk = vWarehouseFk - AND NOT isVirtualStock - GROUP BY iei.itemFk, iei.landed - UNION ALL - SELECT ieo.itemFk, SUM(quantity), shipped - FROM itemEntryOut ieo - JOIN tmp.tItems i ON i.itemFk = ieo.itemFk - WHERE ieo.shipped BETWEEN util.VN_CURDATE() AND util.VN_CURDATE() + INTERVAL vStockScopeDays DAY - AND ieo.warehouseOutFk = vWarehouseFk - GROUP BY ieo.itemFk, ieo.shipped - UNION ALL - SELECT i.itemFk, SUM(ito.quantity), DATE(ito.shipped) - FROM itemTicketOut ito - JOIN tmp.tItems i ON i.itemFk = ito.itemFk - WHERE ito.shipped BETWEEN util.VN_CURDATE() AND util.VN_CURDATE() + INTERVAL vStockScopeDays DAY - AND ito.warehouseFk = vWarehouseFk - GROUP BY ito.itemFk, ito.shipped - ) t2 - JOIN tmp.tItems i ON i.itemFk = t2.itemFk)t - GROUP BY t.itemFk, dated - ) t3; - - -- Se restan las entradas de hoy - UPDATE tmp.tStockByDay sbd - JOIN (SELECT iei.itemFk, SUM(quantity) todayEntry - FROM itemEntryIn iei - JOIN tmp.tItems i ON i.itemFk = iei.itemFk - WHERE iei.landed = util.VN_CURDATE() - AND iei.warehouseInFk = vWarehouseFk - AND NOT iei.isVirtualStock) sub ON sub.itemFk = sbd.itemFk - SET sbd.stock = sbd.stock - sub.todayEntry - WHERE sbd.dated = util.VN_CURDATE(); - - -- Se añaden las lineas de venta servidas - UPDATE tmp.tStockByDay sbd - JOIN (SELECT s.itemFK, SUM(quantity) amount - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - WHERE t.warehouseFk = vWarehouseFk - AND t.shipped BETWEEN util.VN_CURDATE() AND util.midnight() - AND s.isPicked - GROUP BY s.itemFk) sub ON sub.itemFk = sbd.itemFk - SET sbd.stock = sbd.stock + sub.amount; - - -- Se añaden los items ubicados hoy - UPDATE tmp.tStockByDay sbd - JOIN (SELECT ish.itemFK, SUM(ish.visible) amount - FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk - JOIN parking p ON p.id = sh.parkingFk - JOIN sector s ON s.id = p.sectorFk - WHERE s.warehouseFk = vWarehouseFk - AND NOT s.isReserve - AND ish.created BETWEEN util.VN_CURDATE() AND util.midnight() - GROUP BY ish.itemFk) sub ON sub.itemFk = sbd.itemFk - SET sbd.stock = sbd.stock + sub.amount; - - SELECT ts.itemFk, - i.longName, - IF(ts.stock<=0, ts.dated, NULL) dated, - ts.stock, - sub4.visible, - sub4.shelvingFk - FROM( - SELECT IFNULL(sub2.minDated, sub.minDated) dated, - IFNULL(sub2.itemFk, sub.itemFk) itemFk - FROM(SELECT sbd.itemFk, - MIN(dated) minDated, - sbd.stock - FROM tmp.tItems ti - LEFT JOIN tmp.tStockByDay sbd ON sbd.itemFk = ti.itemFk - GROUP BY itemFk)sub - LEFT JOIN ( - SELECT sbd.itemFk, - MIN(dated) minDated, - sbd.stock - FROM tmp.tItems ti - LEFT JOIN tmp.tStockByDay sbd ON sbd.itemFk = ti.itemFk - WHERE sbd.stock <= 0 - GROUP BY itemFk)sub2 ON sub2.itemFk =sub.itemFk - WHERE sub2.itemFk IS NOT NULL - OR (sub2.itemFk IS NULL AND sub.itemFk IS NOT NULL)) sub3 - LEFT JOIN tmp.tStockByDay ts ON ts.itemFk = sub3.itemFk AND ts.dated = sub3.dated - JOIN (SELECT ish.itemFk, - ish.visible, - p.sectorFk, - ish.shelvingFk - FROM itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - LEFT JOIN parking p ON p.id = parkingFk - LEFT JOIN vn.sector s ON s.id = p.sectorFk - WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci - ) sub4 ON sub4.itemFk = ts.itemFk - LEFT JOIN sector s ON s.id = sub4.sectorFk - LEFT JOIN item i ON i.id = ts.itemFk - WHERE NOT s.isReserve; - - DROP TEMPORARY TABLE tmp.tStockByDay, tmp.tItems; - +BEGIN + + /* Devuelve la mínima fecha en que se necesita cada producto en esa matrícula. + * + * @param vShelvingFk Matrícula del carro o pallet + */ + + DECLARE vWarehouseFk INT; + DECLARE vStockScopeDays INT; + + SELECT s.warehouseFk, stockScopeDays + INTO vWarehouseFk, vStockScopeDays + FROM sector s + JOIN operator o ON s.id = o.sectorFk + JOIN productionConfig pc + WHERE o.workerFk = account.myUser_getId(); + + IF vWarehouseFk IS NULL + THEN CALL util.throw('WarehouseFk not setted'); + END IF; + + IF vStockScopeDays IS NULL + THEN CALL util.throw('StockScopeDays not setted'); + END IF; + + CREATE OR REPLACE TEMPORARY TABLE tmp.tItems + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT itemFk, SUM(visible) visible + FROM itemShelving + WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci + GROUP BY itemFk; + + CREATE OR REPLACE TEMPORARY TABLE tmp.tStockByDay + (INDEX (itemFk, dated)) + ENGINE = MEMORY + SELECT dated, + SUM(t3.amount) OVER (PARTITION BY t3.itemFk ORDER BY dated) stock, + t3.itemFk + FROM ( + SELECT t.itemFk, dated, SUM(amount) amount + FROM ( + SELECT t2.itemFk, t2.amount, t2.dated + FROM ( + SELECT item_id itemFk, amount, util.VN_CURDATE() dated + FROM cache.stock s + JOIN tmp.tItems i ON i.itemFk = s.item_id + WHERE s.warehouse_id = vWarehouseFk + UNION ALL + SELECT ish.itemFk, - SUM(ish.visible), util.VN_CURDATE() + FROM itemShelving ish + JOIN tmp.tItems i ON i.itemFk = ish.itemFk + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON sh.parkingFk = p.id + JOIN sector s ON s.id = p.sectorFk + WHERE s.isReserve + GROUP BY ish.itemFk + UNION ALL + SELECT iei.itemFk, SUM(quantity), landed + FROM itemEntryIn iei + JOIN tmp.tItems i ON i.itemFk = iei.itemFk + WHERE iei.landed BETWEEN util.VN_CURDATE() AND util.VN_CURDATE() + INTERVAL vStockScopeDays DAY + AND iei.warehouseInFk = vWarehouseFk + AND NOT isVirtualStock + GROUP BY iei.itemFk, iei.landed + UNION ALL + SELECT ieo.itemFk, SUM(quantity), shipped + FROM itemEntryOut ieo + JOIN tmp.tItems i ON i.itemFk = ieo.itemFk + WHERE ieo.shipped BETWEEN util.VN_CURDATE() AND util.VN_CURDATE() + INTERVAL vStockScopeDays DAY + AND ieo.warehouseOutFk = vWarehouseFk + GROUP BY ieo.itemFk, ieo.shipped + UNION ALL + SELECT i.itemFk, SUM(ito.quantity), DATE(ito.shipped) + FROM itemTicketOut ito + JOIN tmp.tItems i ON i.itemFk = ito.itemFk + WHERE ito.shipped BETWEEN util.VN_CURDATE() AND util.VN_CURDATE() + INTERVAL vStockScopeDays DAY + AND ito.warehouseFk = vWarehouseFk + GROUP BY ito.itemFk, ito.shipped + ) t2 + JOIN tmp.tItems i ON i.itemFk = t2.itemFk)t + GROUP BY t.itemFk, dated + ) t3; + + -- Se restan las entradas de hoy + UPDATE tmp.tStockByDay sbd + JOIN (SELECT iei.itemFk, SUM(quantity) todayEntry + FROM itemEntryIn iei + JOIN tmp.tItems i ON i.itemFk = iei.itemFk + WHERE iei.landed = util.VN_CURDATE() + AND iei.warehouseInFk = vWarehouseFk + AND NOT iei.isVirtualStock) sub ON sub.itemFk = sbd.itemFk + SET sbd.stock = sbd.stock - sub.todayEntry + WHERE sbd.dated = util.VN_CURDATE(); + + -- Se añaden las lineas de venta servidas + UPDATE tmp.tStockByDay sbd + JOIN (SELECT s.itemFK, SUM(quantity) amount + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + WHERE t.warehouseFk = vWarehouseFk + AND t.shipped BETWEEN util.VN_CURDATE() AND util.midnight() + AND s.isPicked + GROUP BY s.itemFk) sub ON sub.itemFk = sbd.itemFk + SET sbd.stock = sbd.stock + sub.amount; + + -- Se añaden los items ubicados hoy + UPDATE tmp.tStockByDay sbd + JOIN (SELECT ish.itemFK, SUM(ish.visible) amount + FROM itemShelving ish + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON p.id = sh.parkingFk + JOIN sector s ON s.id = p.sectorFk + WHERE s.warehouseFk = vWarehouseFk + AND NOT s.isReserve + AND ish.created BETWEEN util.VN_CURDATE() AND util.midnight() + GROUP BY ish.itemFk) sub ON sub.itemFk = sbd.itemFk + SET sbd.stock = sbd.stock + sub.amount; + + SELECT ts.itemFk, + i.longName, + IF(ts.stock<=0, ts.dated, NULL) dated, + ts.stock, + sub4.visible, + sub4.shelvingFk + FROM( + SELECT IFNULL(sub2.minDated, sub.minDated) dated, + IFNULL(sub2.itemFk, sub.itemFk) itemFk + FROM(SELECT sbd.itemFk, + MIN(dated) minDated, + sbd.stock + FROM tmp.tItems ti + LEFT JOIN tmp.tStockByDay sbd ON sbd.itemFk = ti.itemFk + GROUP BY itemFk)sub + LEFT JOIN ( + SELECT sbd.itemFk, + MIN(dated) minDated, + sbd.stock + FROM tmp.tItems ti + LEFT JOIN tmp.tStockByDay sbd ON sbd.itemFk = ti.itemFk + WHERE sbd.stock <= 0 + GROUP BY itemFk)sub2 ON sub2.itemFk =sub.itemFk + WHERE sub2.itemFk IS NOT NULL + OR (sub2.itemFk IS NULL AND sub.itemFk IS NOT NULL)) sub3 + LEFT JOIN tmp.tStockByDay ts ON ts.itemFk = sub3.itemFk AND ts.dated = sub3.dated + JOIN (SELECT ish.itemFk, + ish.visible, + p.sectorFk, + ish.shelvingFk + FROM itemShelving ish + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + LEFT JOIN parking p ON p.id = parkingFk + LEFT JOIN vn.sector s ON s.id = p.sectorFk + WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci + ) sub4 ON sub4.itemFk = ts.itemFk + LEFT JOIN sector s ON s.id = sub4.sectorFk + LEFT JOIN item i ON i.id = ts.itemFk + WHERE NOT s.isReserve; + + DROP TEMPORARY TABLE tmp.tStockByDay, tmp.tItems; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -63193,50 +63193,50 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_getAtp`(vDated DATE) -BEGIN -/** - * Calcula el valor mínimo acumulado para cada artículo ordenado por fecha y - * almacén. - * - * @param vDated Si no hay movimientos en la fecha indicada, debe devolver 0 - * @table tmp.itemCalc(itemFk, wareHouseFk, dated, quantity) - * @return tmp.itemAtp(itemFk, warehouseFk, quantity) - */ - CREATE OR REPLACE TEMPORARY TABLE tItemOrdered - (UNIQUE(itemFk, warehouseFk, dated)) - ENGINE = MEMORY - SELECT itemFk, warehouseFk, dated, SUM(quantity) quantity - FROM ( - SELECT itemFk, warehouseFk, dated, quantity - FROM tmp.itemCalc - UNION ALL - SELECT itemFk, warehouseFk, vDated, 0 - FROM (SELECT DISTINCT itemFk, warehouseFk FROM tmp.itemCalc) t2 - ) t1 - GROUP BY itemFk, warehouseFk, dated - ORDER BY itemFk, warehouseFk, dated; - - SET @lastItemFk := 0; - SET @lastWareHouseFk := 0; - SET @lastQuantity := 0; - - CREATE OR REPLACE TEMPORARY TABLE tmp.itemAtp - (INDEX (itemFk, wareHouseFk)) - SELECT itemFk, wareHouseFk, MIN(quantityAccumulated) quantity - FROM ( - SELECT - itemFk, - IF(itemFk <> @lastItemFk OR wareHouseFk <> @lastWareHouseFk, - @lastQuantity := quantity, - @lastQuantity := @lastQuantity + quantity) quantityAccumulated, - wareHouseFk, - @lastItemFk := itemFk, - @lastWareHouseFk := wareHouseFk - FROM tItemOrdered - )sub - GROUP BY itemFk, wareHouseFk; - - DROP TEMPORARY TABLE tItemOrdered; +BEGIN +/** + * Calcula el valor mínimo acumulado para cada artículo ordenado por fecha y + * almacén. + * + * @param vDated Si no hay movimientos en la fecha indicada, debe devolver 0 + * @table tmp.itemCalc(itemFk, wareHouseFk, dated, quantity) + * @return tmp.itemAtp(itemFk, warehouseFk, quantity) + */ + CREATE OR REPLACE TEMPORARY TABLE tItemOrdered + (UNIQUE(itemFk, warehouseFk, dated)) + ENGINE = MEMORY + SELECT itemFk, warehouseFk, dated, SUM(quantity) quantity + FROM ( + SELECT itemFk, warehouseFk, dated, quantity + FROM tmp.itemCalc + UNION ALL + SELECT itemFk, warehouseFk, vDated, 0 + FROM (SELECT DISTINCT itemFk, warehouseFk FROM tmp.itemCalc) t2 + ) t1 + GROUP BY itemFk, warehouseFk, dated + ORDER BY itemFk, warehouseFk, dated; + + SET @lastItemFk := 0; + SET @lastWareHouseFk := 0; + SET @lastQuantity := 0; + + CREATE OR REPLACE TEMPORARY TABLE tmp.itemAtp + (INDEX (itemFk, wareHouseFk)) + SELECT itemFk, wareHouseFk, MIN(quantityAccumulated) quantity + FROM ( + SELECT + itemFk, + IF(itemFk <> @lastItemFk OR wareHouseFk <> @lastWareHouseFk, + @lastQuantity := quantity, + @lastQuantity := @lastQuantity + quantity) quantityAccumulated, + wareHouseFk, + @lastItemFk := itemFk, + @lastWareHouseFk := wareHouseFk + FROM tItemOrdered + )sub + GROUP BY itemFk, wareHouseFk; + + DROP TEMPORARY TABLE tItemOrdered; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -65424,176 +65424,176 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `multipleInventory`( - vDate DATE, - vWarehouseFk TINYINT, - vMaxDays TINYINT +CREATE DEFINER=`vn`@`localhost` PROCEDURE `multipleInventory`( + vDate DATE, + vWarehouseFk TINYINT, + vMaxDays TINYINT ) -proc: BEGIN - DECLARE vDateTomorrow DATE DEFAULT vDate + INTERVAL 1 DAY; - DECLARE vDateFrom DATE DEFAULT vDate; - DECLARE vDateTo DATETIME; - DECLARE vDateToTomorrow DATETIME; - DECLARE vDefaultDayRange INT; - DECLARE vCalcFk INT; - - IF vDate < util.VN_CURDATE() THEN - LEAVE proc; - END IF; - - IF vDate = util.VN_CURDATE() THEN - SELECT inventoried INTO vDateFrom - FROM config; - END IF; - - SELECT defaultDayRange INTO vDefaultDayRange - FROM comparativeConfig; - - SET vDateTo = vDate + INTERVAL IFNULL(vMaxDays, vDefaultDayRange) DAY; - SET vDateToTomorrow = vDateTo + INTERVAL 1 DAY; - - ALTER TABLE tmp.itemInventory - ADD `avalaible` INT NOT NULL, - ADD `sd` INT NOT NULL, - ADD `rest` INT NOT NULL, - ADD `expected` INT NOT NULL, - ADD `inventory` INT NOT NULL, - ADD `visible` INT NOT NULL, - ADD `life` TINYINT NOT NULL DEFAULT '0'; - - -- Calculo del inventario - CREATE OR REPLACE TEMPORARY TABLE tItemInventoryCalc - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT itemFk, - SUM(quantity) quantity - FROM ( - SELECT s.itemFk, - s.quantity quantity - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN warehouse w ON w.id = t.warehouseFk - WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate) - AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk - AND w.isComparative - UNION ALL - SELECT b.itemFk, b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseInFk - WHERE t.landed BETWEEN vDateFrom AND util.dayEnd(vDate) - AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk - AND w.isComparative - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - UNION ALL - SELECT b.itemFk, - b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseOutFk - WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate) - AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk - AND w.isComparative - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - ) sub - GROUP BY itemFk; - - -- Cálculo del visible - CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); - - CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc - (PRIMARY KEY (item_id)) - ENGINE = MEMORY - SELECT item_id, visible - FROM cache.visible - WHERE calc_id = vCalcFk; - - UPDATE tmp.itemInventory it - LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id - LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id - SET it.inventory = iic.quantity, - it.visible = ivc.visible, - it.avalaible = iic.quantity, - it.sd = iic.quantity; - - -- Calculo del disponible - CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc - (INDEX (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT sub.itemFk, - vWarehouseFk warehouseFk, - sub.dated, - SUM(sub.quantity) quantity - FROM ( - SELECT s.itemFk, - DATE(t.shipped) dated, - - s.quantity quantity - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN warehouse w ON w.id = t.warehouseFk - WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo - AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk - AND w.isComparative - UNION ALL - SELECT b.itemFk, t.landed, b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseInFk - WHERE t.landed BETWEEN vDateTomorrow AND vDateTo - AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk - AND w.isComparative - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - UNION ALL - SELECT b.itemFk, t.shipped, - b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseOutFk - WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo - AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk - AND w.isComparative - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - ) sub - GROUP BY sub.itemFk, sub.dated; - - CALL item_getAtp(vDate); - CALL travel_upcomingArrivals(vWarehouseFk, vDate); - - CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT it.itemFk, - SUM(it.quantity) quantity, - im.quantity minQuantity - FROM tmp.itemCalc it - JOIN tmp.itemAtp im ON im.itemFk = it.itemFk - JOIN item i ON i.id = it.itemFk - LEFT JOIN origin o ON o.id = i.originFk - LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk - WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, - t.landing, - vDateToTomorrow) - GROUP BY it.itemFk; - - UPDATE tmp.itemInventory it - JOIN tItemAvailableCalc iac ON iac.itemFk = it.id - SET it.avalaible = IF(iac.minQuantity > 0, - it.avalaible, - it.avalaible + iac.minQuantity), - it.sd = it.inventory + iac.quantity; - - DROP TEMPORARY TABLE - tmp.itemTravel, - tmp.itemCalc, - tmp.itemAtp, - tItemInventoryCalc, - tItemVisibleCalc, - tItemAvailableCalc; +proc: BEGIN + DECLARE vDateTomorrow DATE DEFAULT vDate + INTERVAL 1 DAY; + DECLARE vDateFrom DATE DEFAULT vDate; + DECLARE vDateTo DATETIME; + DECLARE vDateToTomorrow DATETIME; + DECLARE vDefaultDayRange INT; + DECLARE vCalcFk INT; + + IF vDate < util.VN_CURDATE() THEN + LEAVE proc; + END IF; + + IF vDate = util.VN_CURDATE() THEN + SELECT inventoried INTO vDateFrom + FROM config; + END IF; + + SELECT defaultDayRange INTO vDefaultDayRange + FROM comparativeConfig; + + SET vDateTo = vDate + INTERVAL IFNULL(vMaxDays, vDefaultDayRange) DAY; + SET vDateToTomorrow = vDateTo + INTERVAL 1 DAY; + + ALTER TABLE tmp.itemInventory + ADD `avalaible` INT NOT NULL, + ADD `sd` INT NOT NULL, + ADD `rest` INT NOT NULL, + ADD `expected` INT NOT NULL, + ADD `inventory` INT NOT NULL, + ADD `visible` INT NOT NULL, + ADD `life` TINYINT NOT NULL DEFAULT '0'; + + -- Calculo del inventario + CREATE OR REPLACE TEMPORARY TABLE tItemInventoryCalc + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT itemFk, + SUM(quantity) quantity + FROM ( + SELECT s.itemFk, - s.quantity quantity + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN warehouse w ON w.id = t.warehouseFk + WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate) + AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk + AND w.isComparative + UNION ALL + SELECT b.itemFk, b.quantity + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseInFk + WHERE t.landed BETWEEN vDateFrom AND util.dayEnd(vDate) + AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk + AND w.isComparative + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid + UNION ALL + SELECT b.itemFk, - b.quantity + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseOutFk + WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate) + AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk + AND w.isComparative + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid + ) sub + GROUP BY itemFk; + + -- Cálculo del visible + CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); + + CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc + (PRIMARY KEY (item_id)) + ENGINE = MEMORY + SELECT item_id, visible + FROM cache.visible + WHERE calc_id = vCalcFk; + + UPDATE tmp.itemInventory it + LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id + LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id + SET it.inventory = iic.quantity, + it.visible = ivc.visible, + it.avalaible = iic.quantity, + it.sd = iic.quantity; + + -- Calculo del disponible + CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc + (INDEX (itemFk, warehouseFk)) + ENGINE = MEMORY + SELECT sub.itemFk, + vWarehouseFk warehouseFk, + sub.dated, + SUM(sub.quantity) quantity + FROM ( + SELECT s.itemFk, + DATE(t.shipped) dated, + - s.quantity quantity + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN warehouse w ON w.id = t.warehouseFk + WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo + AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk + AND w.isComparative + UNION ALL + SELECT b.itemFk, t.landed, b.quantity + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseInFk + WHERE t.landed BETWEEN vDateTomorrow AND vDateTo + AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk + AND w.isComparative + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid + UNION ALL + SELECT b.itemFk, t.shipped, - b.quantity + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseOutFk + WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo + AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk + AND w.isComparative + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid + ) sub + GROUP BY sub.itemFk, sub.dated; + + CALL item_getAtp(vDate); + CALL travel_upcomingArrivals(vWarehouseFk, vDate); + + CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT it.itemFk, + SUM(it.quantity) quantity, + im.quantity minQuantity + FROM tmp.itemCalc it + JOIN tmp.itemAtp im ON im.itemFk = it.itemFk + JOIN item i ON i.id = it.itemFk + LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk + WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, + t.landing, + vDateToTomorrow) + GROUP BY it.itemFk; + + UPDATE tmp.itemInventory it + JOIN tItemAvailableCalc iac ON iac.itemFk = it.id + SET it.avalaible = IF(iac.minQuantity > 0, + it.avalaible, + it.avalaible + iac.minQuantity), + it.sd = it.inventory + iac.quantity; + + DROP TEMPORARY TABLE + tmp.itemTravel, + tmp.itemCalc, + tmp.itemAtp, + tItemInventoryCalc, + tItemVisibleCalc, + tItemAvailableCalc; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -70251,30 +70251,30 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`vn`@`localhost` PROCEDURE `sectorCollection_new`(vSectorFk INT) -BEGIN -/** - * Inserta una nueva colección, si el usuario no tiene ninguna vacia. - * Esto se hace para evitar que por error se generen colecciones sin sentido. - * - * @param vSectorFk Identificador de #vn.sector - */ - DECLARE hasEmptyCollections BOOL; - DECLARE vUserFk INT; - - SET vUserFk = account.myUser_getId(); - - SELECT (COUNT(sc.id) > 0) INTO hasEmptyCollections - FROM vn.sectorCollection sc - LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id - WHERE ISNULL(scsg.id) - AND sc.userFk = vUserFk - AND sc.sectorFk = vSectorFk - AND sc.created >= util.VN_CURDATE(); - - IF NOT hasEmptyCollections THEN - INSERT INTO vn.sectorCollection(userFk, sectorFk) - VALUES(vUserFk, vSectorFk); - END IF; +BEGIN +/** + * Inserta una nueva colección, si el usuario no tiene ninguna vacia. + * Esto se hace para evitar que por error se generen colecciones sin sentido. + * + * @param vSectorFk Identificador de #vn.sector + */ + DECLARE hasEmptyCollections BOOL; + DECLARE vUserFk INT; + + SET vUserFk = account.myUser_getId(); + + SELECT (COUNT(sc.id) > 0) INTO hasEmptyCollections + FROM vn.sectorCollection sc + LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + WHERE ISNULL(scsg.id) + AND sc.userFk = vUserFk + AND sc.sectorFk = vSectorFk + AND sc.created >= util.VN_CURDATE(); + + IF NOT hasEmptyCollections THEN + INSERT INTO vn.sectorCollection(userFk, sectorFk) + VALUES(vUserFk, vSectorFk); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -74173,62 +74173,62 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_DelayTruckSplit`( - vTicketFk INT +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_DelayTruckSplit`( + vTicketFk INT ) -BEGIN -/** - * Splita las lineas de ticket que no estan ubicadas - * - * @param vTicketFk Id ticket - */ - DECLARE vNewTicketFk INT; - DECLARE vTotalLines INT; - DECLARE vLinesToSplit INT; - - DROP TEMPORARY TABLE IF EXISTS tmp.SalesToSplit; - - SELECT COUNT(*) INTO vTotalLines - FROM sale - WHERE ticketFk = vTicketFk; - - CREATE TEMPORARY TABLE tmp.SalesToSplit - SELECT s.id saleFk - FROM ticket t - JOIN sale s ON t.id = s.ticketFk - LEFT JOIN ( - SELECT ish.itemFk itemFk, - SUM(ish.visible) visible, - s.warehouseFk warehouseFk - FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk - JOIN parking p ON p.id = sh.parkingFk - JOIN sector s ON s.id = p.sectorFk - GROUP BY ish.itemFk, - s.warehouseFk - ) issw ON issw.itemFk = s.itemFk - AND issw.warehouseFk = t.warehouseFk - WHERE s.quantity > IFNULL(issw.visible, 0) - AND s.quantity > 0 - AND NOT s.isPicked - AND NOT s.reserved - AND t.id = vTicketFk; - - SELECT COUNT(*) INTO vLinesToSplit - FROM tmp.SalesToSplit; - - IF vLinesToSplit = vTotalLines AND vLinesToSplit > 0 THEN - SET vNewTicketFk = vTicketFk; - ELSE - CALL ticket_Clone(vTicketFk, vNewTicketFk); - UPDATE sale s - JOIN tmp.SalesToSplit sts ON sts.saleFk = s.id - SET s.ticketFk = vNewTicketFk; - END IF; - - CALL ticket_setState(vNewTicketFk, 'FIXING'); - - DROP TEMPORARY TABLE tmp.SalesToSplit; +BEGIN +/** + * Splita las lineas de ticket que no estan ubicadas + * + * @param vTicketFk Id ticket + */ + DECLARE vNewTicketFk INT; + DECLARE vTotalLines INT; + DECLARE vLinesToSplit INT; + + DROP TEMPORARY TABLE IF EXISTS tmp.SalesToSplit; + + SELECT COUNT(*) INTO vTotalLines + FROM sale + WHERE ticketFk = vTicketFk; + + CREATE TEMPORARY TABLE tmp.SalesToSplit + SELECT s.id saleFk + FROM ticket t + JOIN sale s ON t.id = s.ticketFk + LEFT JOIN ( + SELECT ish.itemFk itemFk, + SUM(ish.visible) visible, + s.warehouseFk warehouseFk + FROM itemShelving ish + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON p.id = sh.parkingFk + JOIN sector s ON s.id = p.sectorFk + GROUP BY ish.itemFk, + s.warehouseFk + ) issw ON issw.itemFk = s.itemFk + AND issw.warehouseFk = t.warehouseFk + WHERE s.quantity > IFNULL(issw.visible, 0) + AND s.quantity > 0 + AND NOT s.isPicked + AND NOT s.reserved + AND t.id = vTicketFk; + + SELECT COUNT(*) INTO vLinesToSplit + FROM tmp.SalesToSplit; + + IF vLinesToSplit = vTotalLines AND vLinesToSplit > 0 THEN + SET vNewTicketFk = vTicketFk; + ELSE + CALL ticket_Clone(vTicketFk, vNewTicketFk); + UPDATE sale s + JOIN tmp.SalesToSplit sts ON sts.saleFk = s.id + SET s.ticketFk = vNewTicketFk; + END IF; + + CALL ticket_setState(vNewTicketFk, 'FIXING'); + + DROP TEMPORARY TABLE tmp.SalesToSplit; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -74246,84 +74246,84 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_doCmr`(vSelf INT) -BEGIN -/** -* Crea u actualiza la información del CMR asociado con -* un ticket específico en caso de que sea necesario. -* -* @param vSelf El id del ticket -*/ - DECLARE vCmrFk INT; - SELECT cmrFk INTO vCmrFk - FROM ticket - WHERE id = vSelf; - - CREATE OR REPLACE TEMPORARY TABLE tTicket - SELECT wo.firstName, - v.numberPlate, - com.id companyFk, - a.id addressFk, - c2.defaultAddressFk, - IFNULL(sat.supplierFk, su.id) supplierFk, - t.landed - FROM ticket t - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN `state` s ON s.id = ts.stateFk - JOIN alertLevel al ON al.id = s.alertLevel - JOIN client c ON c.id = t.clientFk - JOIN `address` a ON a.id = t.addressFk - JOIN province p ON p.id = a.provinceFk - JOIN country co ON co.id = p.countryFk - JOIN warehouse w ON w.id = t.warehouseFk - JOIN company com ON com.id = t.companyFk - JOIN client c2 ON c2.id = com.clientFk - JOIN supplierAccount sa ON sa.id = com.supplierAccountFk - JOIN supplier su ON su.id = sa.supplierFk - LEFT JOIN route r ON r.id = t.routeFk - LEFT JOIN worker wo ON wo.id = r.workerFk - LEFT JOIN vehicle v ON v.id = r.vehicleFk - LEFT JOIN agencyMode am ON am.id = r.agencyModeFk - LEFT JOIN agency ag ON ag.id = am.agencyFk - LEFT JOIN supplierAgencyTerm sat ON sat.agencyFk = ag.id - AND wo.isFreelance - WHERE al.code IN ('PACKED', 'DELIVERED') - AND co.code <> 'ES' - AND am.name <> 'ABONO' - AND w.code = 'ALG' - AND t.id = vSelf - GROUP BY t.id; - - IF vCmrFk THEN - UPDATE cmr c - JOIN tTicket t - SET c.senderInstruccions = t.firstName, - c.truckPlate = t.numberPlate, - c.companyFk = t.companyFk, - c.addressToFk = t.addressFk, - c.addressFromFk = t.defaultAddressFk, - c.supplierFk = t.supplierFk, - c.ead = t.landed - WHERE id = vCmrFk; - ELSE - INSERT INTO cmr ( - senderInstruccions, - truckPlate, - companyFk, - addressToFk, - addressFromFk, - supplierFk, - ead - ) - SELECT * FROM tTicket; - - IF (SELECT EXISTS(SELECT * FROM tTicket)) THEN - UPDATE ticket - SET cmrFk = LAST_INSERT_ID() - WHERE id = vSelf; - END IF; - END IF; - - DROP TEMPORARY TABLE tTicket; +BEGIN +/** +* Crea u actualiza la información del CMR asociado con +* un ticket específico en caso de que sea necesario. +* +* @param vSelf El id del ticket +*/ + DECLARE vCmrFk INT; + SELECT cmrFk INTO vCmrFk + FROM ticket + WHERE id = vSelf; + + CREATE OR REPLACE TEMPORARY TABLE tTicket + SELECT wo.firstName, + v.numberPlate, + com.id companyFk, + a.id addressFk, + c2.defaultAddressFk, + IFNULL(sat.supplierFk, su.id) supplierFk, + t.landed + FROM ticket t + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN `state` s ON s.id = ts.stateFk + JOIN alertLevel al ON al.id = s.alertLevel + JOIN client c ON c.id = t.clientFk + JOIN `address` a ON a.id = t.addressFk + JOIN province p ON p.id = a.provinceFk + JOIN country co ON co.id = p.countryFk + JOIN warehouse w ON w.id = t.warehouseFk + JOIN company com ON com.id = t.companyFk + JOIN client c2 ON c2.id = com.clientFk + JOIN supplierAccount sa ON sa.id = com.supplierAccountFk + JOIN supplier su ON su.id = sa.supplierFk + LEFT JOIN route r ON r.id = t.routeFk + LEFT JOIN worker wo ON wo.id = r.workerFk + LEFT JOIN vehicle v ON v.id = r.vehicleFk + LEFT JOIN agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN agency ag ON ag.id = am.agencyFk + LEFT JOIN supplierAgencyTerm sat ON sat.agencyFk = ag.id + AND wo.isFreelance + WHERE al.code IN ('PACKED', 'DELIVERED') + AND co.code <> 'ES' + AND am.name <> 'ABONO' + AND w.code = 'ALG' + AND t.id = vSelf + GROUP BY t.id; + + IF vCmrFk THEN + UPDATE cmr c + JOIN tTicket t + SET c.senderInstruccions = t.firstName, + c.truckPlate = t.numberPlate, + c.companyFk = t.companyFk, + c.addressToFk = t.addressFk, + c.addressFromFk = t.defaultAddressFk, + c.supplierFk = t.supplierFk, + c.ead = t.landed + WHERE id = vCmrFk; + ELSE + INSERT INTO cmr ( + senderInstruccions, + truckPlate, + companyFk, + addressToFk, + addressFromFk, + supplierFk, + ead + ) + SELECT * FROM tTicket; + + IF (SELECT EXISTS(SELECT * FROM tTicket)) THEN + UPDATE ticket + SET cmrFk = LAST_INSERT_ID() + WHERE id = vSelf; + END IF; + END IF; + + DROP TEMPORARY TABLE tTicket; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -81979,126 +81979,126 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getLeaves`( - vSelf INT, - vParentFk INT, - vSearch VARCHAR(255), - vHasInsert BOOL +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getLeaves`( + vSelf INT, + vParentFk INT, + vSearch VARCHAR(255), + vHasInsert BOOL ) -BEGIN -/** - * Devuelve las ubicaciones incluidas en la ruta y que sean hijos de parentFk. - * @param vSelf Id de la zona - * @param vParentFk Id del geo a calcular - * @param vSearch Cadena a buscar - * @param vHasInsert Indica si inserta en tmp.zoneNodes - * Optional @table tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk) - */ - DECLARE vIsNumber BOOL; - DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch <> ''; - - CREATE OR REPLACE TEMPORARY TABLE tNodes - (UNIQUE (id)) - ENGINE = MEMORY - SELECT id - FROM zoneGeo - LIMIT 0; - - IF vIsSearch THEN - SET vIsNumber = vSearch REGEXP '^[0-9]+$'; - - INSERT INTO tNodes - SELECT id - FROM zoneGeo - WHERE (vIsNumber AND `name` = vSearch) - OR (!vIsNumber AND `name` LIKE CONCAT('%', vSearch, '%')) - LIMIT 1000; - - ELSEIF vParentFk IS NULL THEN - INSERT INTO tNodes - SELECT geoFk - FROM zoneIncluded - WHERE zoneFk = vSelf; - END IF; - - IF vParentFk IS NULL THEN - CREATE OR REPLACE TEMPORARY TABLE tChilds - (INDEX(id)) - ENGINE = MEMORY - SELECT id FROM tNodes; - - CREATE OR REPLACE TEMPORARY TABLE tParents - (INDEX(id)) - ENGINE = MEMORY - SELECT id FROM zoneGeo LIMIT 0; - - myLoop: LOOP - DELETE FROM tParents; - INSERT INTO tParents - SELECT parentFk id - FROM zoneGeo g - JOIN tChilds c ON c.id = g.id - WHERE g.parentFk IS NOT NULL; - - INSERT IGNORE INTO tNodes - SELECT id FROM tParents; - - IF NOT ROW_COUNT() THEN - LEAVE myLoop; - END IF; - - DELETE FROM tChilds; - INSERT INTO tChilds - SELECT id FROM tParents; - END LOOP; - - DROP TEMPORARY TABLE tChilds, tParents; - END IF; - - IF NOT vIsSearch THEN - INSERT IGNORE INTO tNodes - SELECT id - FROM zoneGeo - WHERE parentFk <=> vParentFk; - END IF; - - CREATE OR REPLACE TEMPORARY TABLE tZones - SELECT g.id, - g.name, - g.parentFk, - g.sons, - NOT g.sons OR `type` = 'country' isChecked, - i.isIncluded selected, - g.`depth`, - vSelf - FROM zoneGeo g - JOIN tNodes n ON n.id = g.id - LEFT JOIN zoneIncluded i ON i.geoFk = g.id - AND i.zoneFk = vSelf - ORDER BY g.`depth`, selected DESC, g.name; - - IF vHasInsert THEN - INSERT IGNORE INTO tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk) - SELECT id, - name, - parentFk, - sons, - isChecked, - vSelf - FROM tZones - WHERE selected - OR (selected IS NULL AND vParentFk IS NOT NULL); - ELSE - SELECT id, - name, - parentFk, - sons, - selected - FROM tZones - ORDER BY `depth`, selected DESC, name; - END IF; - - DROP TEMPORARY TABLE tNodes, tZones; +BEGIN +/** + * Devuelve las ubicaciones incluidas en la ruta y que sean hijos de parentFk. + * @param vSelf Id de la zona + * @param vParentFk Id del geo a calcular + * @param vSearch Cadena a buscar + * @param vHasInsert Indica si inserta en tmp.zoneNodes + * Optional @table tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk) + */ + DECLARE vIsNumber BOOL; + DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch <> ''; + + CREATE OR REPLACE TEMPORARY TABLE tNodes + (UNIQUE (id)) + ENGINE = MEMORY + SELECT id + FROM zoneGeo + LIMIT 0; + + IF vIsSearch THEN + SET vIsNumber = vSearch REGEXP '^[0-9]+$'; + + INSERT INTO tNodes + SELECT id + FROM zoneGeo + WHERE (vIsNumber AND `name` = vSearch) + OR (!vIsNumber AND `name` LIKE CONCAT('%', vSearch, '%')) + LIMIT 1000; + + ELSEIF vParentFk IS NULL THEN + INSERT INTO tNodes + SELECT geoFk + FROM zoneIncluded + WHERE zoneFk = vSelf; + END IF; + + IF vParentFk IS NULL THEN + CREATE OR REPLACE TEMPORARY TABLE tChilds + (INDEX(id)) + ENGINE = MEMORY + SELECT id FROM tNodes; + + CREATE OR REPLACE TEMPORARY TABLE tParents + (INDEX(id)) + ENGINE = MEMORY + SELECT id FROM zoneGeo LIMIT 0; + + myLoop: LOOP + DELETE FROM tParents; + INSERT INTO tParents + SELECT parentFk id + FROM zoneGeo g + JOIN tChilds c ON c.id = g.id + WHERE g.parentFk IS NOT NULL; + + INSERT IGNORE INTO tNodes + SELECT id FROM tParents; + + IF NOT ROW_COUNT() THEN + LEAVE myLoop; + END IF; + + DELETE FROM tChilds; + INSERT INTO tChilds + SELECT id FROM tParents; + END LOOP; + + DROP TEMPORARY TABLE tChilds, tParents; + END IF; + + IF NOT vIsSearch THEN + INSERT IGNORE INTO tNodes + SELECT id + FROM zoneGeo + WHERE parentFk <=> vParentFk; + END IF; + + CREATE OR REPLACE TEMPORARY TABLE tZones + SELECT g.id, + g.name, + g.parentFk, + g.sons, + NOT g.sons OR `type` = 'country' isChecked, + i.isIncluded selected, + g.`depth`, + vSelf + FROM zoneGeo g + JOIN tNodes n ON n.id = g.id + LEFT JOIN zoneIncluded i ON i.geoFk = g.id + AND i.zoneFk = vSelf + ORDER BY g.`depth`, selected DESC, g.name; + + IF vHasInsert THEN + INSERT IGNORE INTO tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk) + SELECT id, + name, + parentFk, + sons, + isChecked, + vSelf + FROM tZones + WHERE selected + OR (selected IS NULL AND vParentFk IS NOT NULL); + ELSE + SELECT id, + name, + parentFk, + sons, + selected + FROM tZones + ORDER BY `depth`, selected DESC, name; + END IF; + + DROP TEMPORARY TABLE tNodes, tZones; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -82281,48 +82281,48 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getPostalCode`(vSelf INT) -BEGIN -/** - * Devuelve los códigos postales incluidos en una zona - */ - DECLARE vGeoFk INT DEFAULT NULL; - - CREATE OR REPLACE TEMPORARY TABLE tmp.zoneNodes ( - geoFk INT, - name VARCHAR(100), - parentFk INT, - sons INT, - isChecked BOOL DEFAULT 0, - zoneFk INT, - PRIMARY KEY zoneNodesPk (zoneFk, geoFk), - INDEX(geoFk)) - ENGINE = MEMORY; - - CALL zone_getLeaves(vSelf, NULL , NULL, TRUE); - - UPDATE tmp.zoneNodes - SET isChecked = 0 - WHERE parentFk IS NULL; - - myLoop: LOOP - SET vGeoFk = NULL; - SELECT geoFk INTO vGeoFk - FROM tmp.zoneNodes - WHERE NOT isChecked - LIMIT 1; - - CALL zone_getLeaves(vSelf, vGeoFk, NULL, TRUE); - UPDATE tmp.zoneNodes - SET isChecked = TRUE - WHERE geoFk = vGeoFk; - - IF vGeoFk IS NULL THEN - LEAVE myLoop; - END IF; - END LOOP; - - DELETE FROM tmp.zoneNodes - WHERE sons > 0; +BEGIN +/** + * Devuelve los códigos postales incluidos en una zona + */ + DECLARE vGeoFk INT DEFAULT NULL; + + CREATE OR REPLACE TEMPORARY TABLE tmp.zoneNodes ( + geoFk INT, + name VARCHAR(100), + parentFk INT, + sons INT, + isChecked BOOL DEFAULT 0, + zoneFk INT, + PRIMARY KEY zoneNodesPk (zoneFk, geoFk), + INDEX(geoFk)) + ENGINE = MEMORY; + + CALL zone_getLeaves(vSelf, NULL , NULL, TRUE); + + UPDATE tmp.zoneNodes + SET isChecked = 0 + WHERE parentFk IS NULL; + + myLoop: LOOP + SET vGeoFk = NULL; + SELECT geoFk INTO vGeoFk + FROM tmp.zoneNodes + WHERE NOT isChecked + LIMIT 1; + + CALL zone_getLeaves(vSelf, vGeoFk, NULL, TRUE); + UPDATE tmp.zoneNodes + SET isChecked = TRUE + WHERE geoFk = vGeoFk; + + IF vGeoFk IS NULL THEN + LEAVE myLoop; + END IF; + END LOOP; + + DELETE FROM tmp.zoneNodes + WHERE sons > 0; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; diff --git a/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql b/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql index 863005373..b698f0e3e 100644 --- a/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql +++ b/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql @@ -32,7 +32,7 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tVisible SELECT itemFk, SUM(visible) totalVisible FROM vn.itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector sc ON sc.id = p.sectorFk WHERE sc.warehouseFk = vWarehouseFk diff --git a/db/routines/vn/functions/hasItemsInSector.sql b/db/routines/vn/functions/hasItemsInSector.sql index 7a5c4cf60..faf9e8a90 100644 --- a/db/routines/vn/functions/hasItemsInSector.sql +++ b/db/routines/vn/functions/hasItemsInSector.sql @@ -9,7 +9,7 @@ BEGIN SELECT count(*) INTO vItemCount FROM vn.sale s JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk WHERE s.ticketFk = vTicketFk AND p.sectorFk = vSectorFk; diff --git a/db/routines/vn/functions/itemsInSector_get.sql b/db/routines/vn/functions/itemsInSector_get.sql index 254ebe1b5..9043e55cb 100644 --- a/db/routines/vn/functions/itemsInSector_get.sql +++ b/db/routines/vn/functions/itemsInSector_get.sql @@ -10,7 +10,7 @@ BEGIN SELECT count(*) INTO vItemCount FROM vn.sale s JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk WHERE s.ticketFk = vTicketFk AND p.sectorFk = vSectorFk; diff --git a/db/routines/vn/procedures/collectionPlacement_get.sql b/db/routines/vn/procedures/collectionPlacement_get.sql index 239dbd3a2..8d2301e1e 100644 --- a/db/routines/vn/procedures/collectionPlacement_get.sql +++ b/db/routines/vn/procedures/collectionPlacement_get.sql @@ -83,7 +83,7 @@ BEGIN AND s.semaphore = 1 GROUP BY st.saleFk) st ON st.saleFk = ts.saleFk JOIN itemShelving ish ON ish.itemFk = ts.itemFk - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector sc ON sc.id = p.sectorFk JOIN sectorType st ON st.id = sc.typeFk diff --git a/db/routines/vn/procedures/entry_splitByShelving.sql b/db/routines/vn/procedures/entry_splitByShelving.sql index fbf0cef90..026c47daa 100644 --- a/db/routines/vn/procedures/entry_splitByShelving.sql +++ b/db/routines/vn/procedures/entry_splitByShelving.sql @@ -1,10 +1,15 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`( + vShelvingCode VARCHAR(3), + vFromEntryFk INT, + vToEntryFk INT +) BEGIN /** - * Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr�cula + * Divide las compras entre dos entradas de + * acuerdo con lo ubicado en una matricula. * - * @param vShelvingFk Identificador de vn.shelving + * @param vShelvingCode Código de vn.shelving * @param vFromEntryFk Entrada origen * @param vToEntryFk Entrada destino */ @@ -23,7 +28,7 @@ BEGIN WHERE b.entryFk = vFromEntryFk ORDER BY b.stickers DESC LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk - WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci + WHERE ish.shelvingFk = vShelvingCode COLLATE utf8_general_ci AND NOT ish.isSplit GROUP BY ish.id; @@ -107,9 +112,10 @@ BEGIN UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID(); END IF; - UPDATE itemShelving - SET isSplit = TRUE - WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci; + UPDATE itemShelving ish + JOIN shelving sh ON sh.id = ish.shelvingFk + SET ish.isSplit = TRUE + WHERE sh.code = vShelvingCode COLLATE utf8_general_ci; END LOOP; CLOSE cur; END$$ diff --git a/db/routines/vn/procedures/itemPlacementSupplyAiming.sql b/db/routines/vn/procedures/itemPlacementSupplyAiming.sql index b96860623..ae0890564 100644 --- a/db/routines/vn/procedures/itemPlacementSupplyAiming.sql +++ b/db/routines/vn/procedures/itemPlacementSupplyAiming.sql @@ -1,5 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`( + vShelvingCode VARCHAR(10), + vQuantity INT, + vItemFk INT +) BEGIN SELECT ish.itemFk, @@ -9,21 +13,21 @@ BEGIN ish.itemShelvingFk, ish.shelving, ish.stock, - LEAST(ish.stock,quantity) as total, + LEAST(ish.stock,vQuantity) total, CONCAT( - CAST(FLOOR(LEAST(ish.stock,quantity) / ish.packing) AS DECIMAL(10,0)), + CAST(FLOOR(LEAST(ish.stock, vQuantity) / ish.packing) AS DECIMAL(10,0)), ' x ', ish.packing, IF ( - LEAST(ish.stock,quantity) MOD ish.packing, - CONCAT(' + ',CAST(LEAST(ish.stock,quantity) MOD ish.packing AS DECIMAL(10,0))), + LEAST(ish.stock, vQuantity) MOD ish.packing, + CONCAT(' + ',CAST(LEAST(ish.stock, vQuantity) MOD ish.packing AS DECIMAL(10,0))), '' ), ' = ', - LEAST(ish.stock,quantity) - ) as proposal - FROM vn.itemShelvingPlacementSupplyStock ish - WHERE ish.shelving = vShelvingFk COLLATE utf8_general_ci + LEAST(ish.stock, vQuantity) + ) proposal + FROM itemShelvingPlacementSupplyStock ish + WHERE ish.shelving = vShelvingCode COLLATE utf8_general_ci AND ish.itemFk = vItemFk; END$$ diff --git a/db/routines/vn/procedures/itemPlacementSupplyGetOrder.sql b/db/routines/vn/procedures/itemPlacementSupplyGetOrder.sql index 958dc7e78..d2648ca6c 100644 --- a/db/routines/vn/procedures/itemPlacementSupplyGetOrder.sql +++ b/db/routines/vn/procedures/itemPlacementSupplyGetOrder.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyGetOrder`(vSector INT ) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyGetOrder`( + vSectorFk INT +) BEGIN DECLARE vId INT; @@ -7,31 +9,35 @@ BEGIN DECLARE vNextParkingFk INT; SELECT sh.parkingFk INTO vLastParkingFk - FROM vn.itemShelvingPlacementSupply isps - JOIN vn.itemShelving ish ON ish.id = isps.itemShelvingFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + FROM itemShelvingPlacementSupply isps + JOIN itemShelving ish ON ish.id = isps.itemShelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk WHERE isps.userFk = getUser() ORDER BY isps.created DESC LIMIT 1; - SET vNextParkingFk = vn.itemShelvingPlacementSupply_ClosestGet(vLastParkingFk); + SET vNextParkingFk = itemShelvingPlacementSupply_ClosestGet(vLastParkingFk); SELECT ipsl.id INTO vId - FROM vn.itemPlacementSupplyList ipsl - JOIN vn.itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk + FROM itemPlacementSupplyList ipsl + JOIN itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk WHERE ipsl.saldo > 0 AND (ipsl.repoUserFk is NULL OR ipsl.repoUserFk = getUser()) - AND ipsl.sectorFk = vSector - ORDER BY ipsl.repoUserFk DESC, ipsl.priority DESC, (ispss.parkingFk = vNextParkingFk) DESC, ispss.parking DESC, ipsl.created + AND ipsl.sectorFk = vSectorFk + ORDER BY ipsl.repoUserFk DESC, + ipsl.priority DESC, + (ispss.parkingFk = vNextParkingFk) DESC, + ispss.parking DESC, + ipsl.created LIMIT 1; - UPDATE vn.itemPlacementSupply + UPDATE itemPlacementSupply SET repoUserFk = getUser() WHERE id = vId; - SELECT * FROM vn.itemPlacementSupplyList + SELECT * FROM itemPlacementSupplyList WHERE id = vId - AND sectorFk = vSector; + AND sectorFk = vSectorFk; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql index cefa64d13..92c17b82f 100644 --- a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql +++ b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql @@ -1,5 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`( + vItemFk INT, + vSectorFk INT +) BEGIN /** * Devuelve la lista de ubicaciones para itemFk en ese sector. Se utiliza en la preparación previa. @@ -13,11 +16,11 @@ BEGIN SUM(ish.visible) stockTotal, ish.created, p.pickingOrder - FROM vn.itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN vn.sector sc ON sc.id = p.sectorFk - JOIN vn.warehouse w ON w.id = sc.warehouseFk + FROM itemShelving ish + JOIN shelving sh ON sh.id = ish.shelvingFk + JOIN parking p ON p.id = sh.parkingFk + JOIN sector sc ON sc.id = p.sectorFk + JOIN warehouse w ON w.id = sc.warehouseFk WHERE ish.visible > 0 AND ish.itemFk = vItemFk GROUP BY ish.id diff --git a/db/routines/vn/procedures/itemShelvingMatch.sql b/db/routines/vn/procedures/itemShelvingMatch.sql index 850c7907b..4ffa66fcb 100644 --- a/db/routines/vn/procedures/itemShelvingMatch.sql +++ b/db/routines/vn/procedures/itemShelvingMatch.sql @@ -20,7 +20,7 @@ BEGIN LEFT JOIN ( SELECT itemFk, sum(cast(visible / packing AS DECIMAL(10,0))) AS etiquetas FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk LEFT JOIN parking pk ON pk.id = sh.parkingFk WHERE ish.created BETWEEN vFromTimed AND vToTimed GROUP BY itemFk diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql index 06736732a..eeec60248 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql @@ -27,7 +27,7 @@ proc: BEGIN ish.available FROM sale s JOIN itemShelving ish ON ish.itemFk = s.itemFk - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector sc ON sc.id = p.sectorFk JOIN productionConfig pc @@ -61,7 +61,7 @@ proc: BEGIN FROM sale s LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - LEFT JOIN shelving sh ON sh.code = ish.shelvingFk + LEFT JOIN shelving sh ON sh.id = ish.shelvingFk LEFT JOIN parking p ON p.id = sh.parkingFk WHERE s.id = vSaleFk; diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index 92d1609e4..a8f0b5250 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_add`( - vShelvingFk VARCHAR(8), + vShelvingCode VARCHAR(10), vBarcode VARCHAR(22), vQuantity INT, vPackagingFk VARCHAR(10), @@ -12,7 +12,7 @@ BEGIN /** * Añade registro o lo actualiza si ya existe. * - * @param vShelvingFk matrícula del carro + * @param vShelvingCode matrícula del carro * @param vBarcode el id del registro * @param vQuantity indica la cantidad del producto * @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra @@ -23,10 +23,15 @@ BEGIN **/ DECLARE vItemFk INT; DECLARE vBuyFk INT; + DECLARE vShelvingFk INT; SELECT id INTO vBuyFk FROM buy WHERE id = vBarcode; + SELECT id INTO vShelvingFk + FROM shelving + WHERE code COLLATE utf8_unicode_ci = vShelvingCode; + SELECT barcodeToItem(vBarcode) INTO vItemFk; IF vBuyFk IS NULL THEN @@ -40,7 +45,7 @@ BEGIN END IF; IF (SELECT COUNT(*) FROM itemShelving - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk + WHERE shelvingFk = vShelvingFk AND itemFk = vItemFk AND packing = vPacking AND buyFk = vBuyFk) THEN @@ -48,7 +53,9 @@ BEGIN UPDATE itemShelving SET visible = visible + vQuantity, available = available + vQuantity - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; + WHERE shelvingFk = vShelvingFk + AND itemFk = vItemFk + AND packing = vPacking; ELSE diff --git a/db/routines/vn/procedures/itemShelving_addByClaim.sql b/db/routines/vn/procedures/itemShelving_addByClaim.sql index 5e7cdf3fc..55ac3e337 100644 --- a/db/routines/vn/procedures/itemShelving_addByClaim.sql +++ b/db/routines/vn/procedures/itemShelving_addByClaim.sql @@ -1,29 +1,38 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`( + vClaimFk INT, + vShelvingCode VARCHAR(10) +) BEGIN /** * Insert items of claim into itemShelving. * * @param vClaimFk The claim - * @param vShelvingFk The shelving + * @param vShelvingCode The shelving code * @table tmp.buyUltimate */ DECLARE vWarehouseFk INT; + DECLARE vShelvingFk INT; SELECT t.warehouseFk INTO vWarehouseFk FROM claim c JOIN ticket t ON t.id = c.ticketFk WHERE c.id = vClaimFk; + SELECT id INTO vShelvingFk + FROM shelving + WHERE code COLLATE utf8_unicode_ci = vShelvingCode; + CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE()); INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible) - SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible + SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity visible FROM claim c JOIN claimBeginning cb ON c.id = cb.claimFk JOIN sale s ON s.id = cb.saleFk JOIN ticket t ON t.id = s.ticketFk - JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk AND bu.warehouseFk = t.warehouseFk + JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk + AND bu.warehouseFk = t.warehouseFk JOIN buy b ON b.id = bu.buyFk WHERE c.id = vClaimFk; END$$ diff --git a/db/routines/vn/procedures/itemShelving_addList.sql b/db/routines/vn/procedures/itemShelving_addList.sql index ade92b9fd..04fa1e10c 100644 --- a/db/routines/vn/procedures/itemShelving_addList.sql +++ b/db/routines/vn/procedures/itemShelving_addList.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addList`( - vShelvingFk VARCHAR(3), + vShelvingCode VARCHAR(10), vList TEXT, vIsChecking BOOL, vWarehouseFk INT @@ -13,7 +13,7 @@ BEGIN * Cuando es TRUE sólo inserta los elementos de la colección que no están ya en * ese shelving, actualizando los valores del campo itemShelving.isChecked * - * @param vShelvingFk Identificador de shelving + * @param vShelvingCode Código de shelving * @param vList JSON array con esta estructura: '[value1, value2, ...]' * @param vIsChecking Define si hay que añadir o comprobar los items * @param vWarehouseFk Identificador de warehouse @@ -24,6 +24,11 @@ BEGIN DECLARE vPath VARCHAR(6); DECLARE vItemFk INT; DECLARE vIsChecked BOOL; + DECLARE vShelvingFk INT; + + SELECT id INTO vShelvingFk + FROM shelving + WHERE code COLLATE utf8_unicode_ci = vShelvingCode; WHILE vCounter < vListLength DO SET vPath = CONCAT('$[', vCounter, ']'); @@ -34,17 +39,17 @@ BEGIN SELECT IF(COUNT(*), TRUE, FALSE) INTO vIsChecked FROM itemShelving - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk + WHERE shelvingFk = vShelvingFk AND itemFk = vItemFk; END IF; IF NOT vIsChecking OR NOT vIsChecked THEN - CALL itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk); + CALL itemShelving_add(vShelvingCode, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk); END IF; UPDATE itemShelving SET isChecked = vIsChecked - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk + WHERE shelvingFk = vShelvingFk AND itemFk = vItemFk AND isChecked IS NULL; diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql index 07384b721..93022c2af 100644 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -1,10 +1,12 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`( + vShelvingCode VARCHAR(10) +) BEGIN /** -* Lista artículos de itemshelving +* Lista artículos de itemShelving. * -* @param vSelf matrícula del carro +* @param vShelvingCode Matrícula del carro **/ SELECT ish.itemFk item, i.name, @@ -22,9 +24,9 @@ BEGIN ish.buyFk FROM itemShelving ish JOIN item i ON i.id = ish.itemFk - JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci - LEFT JOIN parking p ON s.parkingFk = p.id + JOIN shelving s ON s.id = ish.shelvingFk + LEFT JOIN parking p ON p.id = s.parkingFk JOIN hedera.imageConfig ic - WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf; + WHERE s.code COLLATE utf8_unicode_ci = vShelvingCode; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelving_getAlternatives.sql b/db/routines/vn/procedures/itemShelving_getAlternatives.sql index 89176c4f5..3eff3254b 100644 --- a/db/routines/vn/procedures/itemShelving_getAlternatives.sql +++ b/db/routines/vn/procedures/itemShelving_getAlternatives.sql @@ -1,21 +1,31 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(vShelvingFk VARCHAR(10)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`( + vShelvingCode VARCHAR(10) +) BEGIN /** - * Devuelve un listado de posibles ubicaciones alternativas a ubicar los item de la matricula - * del carro que se le ha pasado. + * Devuelve un listado de posibles ubicaciones alternativas a ubicar + * los item de la matricula del carro que se le ha pasado. * - * @param vShelvingFk matricula del carro + * @param vShelvingCode Matricula del carro */ - SELECT is2.id,is2.shelvingFk , p.code, is2.itemFk , is2.visible, p.pickingOrder + DECLARE vShelvingFk INT; + + SELECT id INTO vShelvingFk + FROM shelving + WHERE code COLLATE utf8_unicode_ci = vShelvingCode; + + SELECT is2.id,is2.shelvingFk, p.code, is2.itemFk , is2.visible, p.pickingOrder FROM itemShelving is2 - JOIN shelving sh ON sh.code = is2.shelvingFk + JOIN shelving sh ON sh.id = is2.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector s ON s.id = p.sectorFk - LEFT JOIN operator o ON o.sectorFk = s.id AND o.workerFk = account.myUser_getId() + LEFT JOIN operator o ON o.sectorFk = s.id + AND o.workerFk = account.myUser_getId() JOIN warehouse wh ON wh.id = s.warehouseFk - JOIN itemShelving is3 ON is3.itemFk = is2.itemFk AND is3.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci - WHERE is2.shelvingFk <> vShelvingFk COLLATE utf8_unicode_ci + JOIN itemShelving is3 ON is3.itemFk = is2.itemFk + AND is3.shelvingFk = vShelvingFk + WHERE is2.shelvingFk <> vShelvingFk GROUP BY is2.id ORDER BY p.pickingOrder DESC; END$$ diff --git a/db/routines/vn/procedures/itemShelving_getInfo.sql b/db/routines/vn/procedures/itemShelving_getInfo.sql index f02100e8b..f4c8c5b35 100644 --- a/db/routines/vn/procedures/itemShelving_getInfo.sql +++ b/db/routines/vn/procedures/itemShelving_getInfo.sql @@ -16,7 +16,7 @@ BEGIN ish.itemFk itemFk, sh.priority FROM vn.itemShelving ish - JOIN vn.shelving sh ON sh.`code` = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk JOIN vn.parking pk ON pk.id = sh.parkingFk WHERE ish.itemFk = vItemFk ORDER BY sh.priority DESC, created ASC; diff --git a/db/routines/vn/procedures/itemShelving_getItemDetails.sql b/db/routines/vn/procedures/itemShelving_getItemDetails.sql index 4e641ca72..36f9830f0 100644 --- a/db/routines/vn/procedures/itemShelving_getItemDetails.sql +++ b/db/routines/vn/procedures/itemShelving_getItemDetails.sql @@ -1,14 +1,14 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`( vBarcodeItem INT, - vShelvingFK VARCHAR(10) + vShelvingCode VARCHAR(10) ) BEGIN /** * Obtiene el precio y visible de un item * * @param vBarcodeItem barcode de artículo - * @param vShelvingFK Ubicación actual del artículo + * @param vShelvingCode Ubicación actual del artículo */ DECLARE vIsItem BOOL; DECLARE vBuyFk INT; @@ -38,18 +38,19 @@ BEGIN WITH visible AS( SELECT itemFk, IFNULL(buyingValue, 0) + - IFNULL(freightValue, 0) + - IFNULL(comissionValue, 0) + - IFNULL(packageValue, 0) itemCost - FROM vn.buy b + IFNULL(freightValue, 0) + + IFNULL(comissionValue, 0) + + IFNULL(packageValue, 0) itemCost + FROM vn.buy b WHERE b.id = vBuyFk ) SELECT v.itemFk, - vShelvingFK, + vShelvingCode, v.itemCost, SUM(ish.visible) visible FROM vn.itemShelving ish + JOIN vn.shelving sh ON sh.id = ish.shelvingFK JOIN visible v - WHERE ish.shelvingFK = vShelvingFK COLLATE utf8mb3_general_ci - AND ish.itemFk = v.itemFk; + WHERE sh.code = vShelvingCode COLLATE utf8mb3_general_ci + AND ish.itemFk = v.itemFk; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelving_getSaleDate.sql b/db/routines/vn/procedures/itemShelving_getSaleDate.sql index d8ab6ed0c..fad4d5abc 100644 --- a/db/routines/vn/procedures/itemShelving_getSaleDate.sql +++ b/db/routines/vn/procedures/itemShelving_getSaleDate.sql @@ -1,14 +1,20 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getSaleDate`(vShelvingFk VARCHAR(3)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getSaleDate`( + vShelvingCode VARCHAR(10) +) BEGIN - - /* Devuelve la mínima fecha en que se necesita cada producto en esa matrícula. - * - * @param vShelvingFk Matrícula del carro o pallet - */ - +/** + * Devuelve la mínima fecha en que se necesita cada producto en esa matrícula. + * + * @param vShelvingCode Matrícula del carro o pallet + */ DECLARE vWarehouseFk INT; DECLARE vStockScopeDays INT; + DECLARE vShelvingFk INT; + + SELECT id INTO vShelvingFk + FROM shelving + WHERE code COLLATE utf8_unicode_ci = vShelvingCode; SELECT s.warehouseFk, stockScopeDays INTO vWarehouseFk, vStockScopeDays @@ -30,7 +36,7 @@ BEGIN ENGINE = MEMORY SELECT itemFk, SUM(visible) visible FROM itemShelving - WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci + WHERE shelvingFk = vShelvingFk GROUP BY itemFk; CREATE OR REPLACE TEMPORARY TABLE tmp.tStockByDay @@ -52,7 +58,7 @@ BEGIN SELECT ish.itemFk, - SUM(ish.visible), util.VN_CURDATE() FROM itemShelving ish JOIN tmp.tItems i ON i.itemFk = ish.itemFk - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON sh.parkingFk = p.id JOIN sector s ON s.id = p.sectorFk WHERE s.isReserve @@ -110,7 +116,7 @@ BEGIN UPDATE tmp.tStockByDay sbd JOIN (SELECT ish.itemFK, SUM(ish.visible) amount FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector s ON s.id = p.sectorFk WHERE s.warehouseFk = vWarehouseFk @@ -150,10 +156,10 @@ BEGIN p.sectorFk, ish.shelvingFk FROM itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk LEFT JOIN parking p ON p.id = parkingFk LEFT JOIN vn.sector s ON s.id = p.sectorFk - WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci + WHERE ish.shelvingFk = vShelvingFk ) sub4 ON sub4.itemFk = ts.itemFk LEFT JOIN sector s ON s.id = sub4.sectorFk LEFT JOIN item i ON i.id = ts.itemFk diff --git a/db/routines/vn/procedures/itemShelving_inventory.sql b/db/routines/vn/procedures/itemShelving_inventory.sql index b57df02e0..9ae96c7a8 100644 --- a/db/routines/vn/procedures/itemShelving_inventory.sql +++ b/db/routines/vn/procedures/itemShelving_inventory.sql @@ -42,7 +42,7 @@ BEGIN JOIN item i ON i.id = ish.itemFk JOIN itemType it ON it.id = i.typeFk JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk LEFT JOIN ( SELECT s.itemFk, sum(s.quantity) notPrepared diff --git a/db/routines/vn/procedures/itemShelving_selfConsumption.sql b/db/routines/vn/procedures/itemShelving_selfConsumption.sql index 083d8d74c..5820b9d28 100644 --- a/db/routines/vn/procedures/itemShelving_selfConsumption.sql +++ b/db/routines/vn/procedures/itemShelving_selfConsumption.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_selfConsumption`( - vShelvingFk VARCHAR(10) COLLATE utf8_general_ci, + vShelvingCode VARCHAR(10) COLLATE utf8_general_ci, vItemFk INT, vQuantity INT ) @@ -9,9 +9,9 @@ BEGIN * Leave the indicated amount on the shelve * and create a ticket with the difference. * - * @param vShelvingFk id of the shelve where the item is located. - * @param vItemFk article of which the self-consumption ticket is to be created. - * @param vQuantity amount that will stay on the shelve + * @param vShelvingCode Code of the shelve where the item is located + * @param vItemFk Item of which the self-consumption ticket is to be created + * @param vQuantity Amount that will stay on the shelve */ DECLARE vVisible INT; DECLARE vClientFk INT; @@ -21,6 +21,11 @@ BEGIN DECLARE vAgencyModeFk INT; DECLARE vItemShelvingFk INT; DECLARE vAddressFk INT; + DECLARE vShelvingFk INT; + + SELECT id INTO vShelvingFk + FROM shelving + WHERE code = vShelvingCode; SELECT c.id, pc.clientSelfConsumptionFk, @@ -37,7 +42,7 @@ BEGIN JOIN parking p ON p.sectorFk = s.id JOIN shelving s2 ON s2.parkingFk = p.id JOIN productionConfig pc - WHERE s2.code = vShelvingFk; + WHERE s2.id = vShelvingFk; IF vClientFk IS NULL THEN CALL util.throw('The company does not have a customer assigned'); @@ -47,7 +52,7 @@ BEGIN CALL util.throw('The shelf cannot have NULL or negative quantities'); END IF; - IF vShelvingFk IS NULL THEN + IF vShelvingCode IS NULL THEN CALL util.throw('The shelf is necessary'); END IF; diff --git a/db/routines/vn/procedures/itemShelving_transfer.sql b/db/routines/vn/procedures/itemShelving_transfer.sql index 95d70227f..e0e6af110 100644 --- a/db/routines/vn/procedures/itemShelving_transfer.sql +++ b/db/routines/vn/procedures/itemShelving_transfer.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_transfer`( vItemShelvingFk INT, - vShelvingFk VARCHAR(10) + vShelvingCode VARCHAR(10) ) BEGIN /** @@ -9,9 +9,14 @@ BEGIN * fusionando si coincide el packing y la fecha. * * @param vItemShelvingFk Identificador de itemShelving - * @param vShelvingFk Identificador de shelving + * @param vShelvingCode Código de shelving */ DECLARE vNewItemShelvingFk INT; + DECLARE vShelvingFk INT; + + SELECT id INTO vShelvingFk + FROM shelving + WHERE code COLLATE utf8_unicode_ci = vShelvingCode; SELECT MAX(ish.id) INTO vNewItemShelvingFk FROM itemShelving ish @@ -26,7 +31,7 @@ BEGIN AND ish2.packing = ish.packing AND DATE(ish2.created) = DATE(ish.created) AND ish2.buyFk = ish.buyFk - WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; + WHERE ish.shelvingFk = vShelvingFk; IF vNewItemShelvingFk THEN UPDATE itemShelving ish @@ -38,9 +43,7 @@ BEGIN DELETE FROM itemShelving WHERE id = vItemShelvingFk; ELSE - IF (SELECT EXISTS(SELECT id FROM shelving - WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN - + IF (SELECT EXISTS(SELECT id FROM shelving WHERE id = vShelvingFk)) THEN UPDATE itemShelving SET shelvingFk = vShelvingFk WHERE id = vItemShelvingFk; diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql index d0178f6a7..282f6e01e 100644 --- a/db/routines/vn/procedures/item_devalueA2.sql +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_devalueA2`( vSelf INT, - vShelvingFK VARCHAR(10), + vShelvingCode VARCHAR(10), vBuyingValue DECIMAL(10,4), vQuantity INT ) @@ -12,7 +12,7 @@ BEGIN * de almacén y shelvings correspondientes * * @param vSelf Id de artículo a devaluar - * @param vShelvingFK Ubicación actual del artículo + * @param vShelvingCode Código de shelving / ubicación * @param vBuyingValue Nuevo precio de coste * @param vQuantity Cantidad del ítem a pasar a A2 */ @@ -109,10 +109,11 @@ BEGIN CALL util.throw ('The item has not a buy'); END IF; - SELECT id,visible INTO vTargetItemShelvingFk, vCurrentVisible - FROM itemShelving - WHERE shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci - AND itemFk = vSelf + SELECT ish.id, ish.visible INTO vTargetItemShelvingFk, vCurrentVisible + FROM itemShelving ish + JOIN shelving sh ON sh.id = ish.shelvingFk + WHERE sh.code = vShelvingCode COLLATE utf8mb3_general_ci + AND ish.itemFk = vSelf LIMIT 1; IF vCurrentVisible IS NULL THEN @@ -388,16 +389,17 @@ BEGIN userFk, isChecked) SELECT vItemA2Fk, - shelvingFk, + ish.shelvingFk, vQuantity , - `grouping`, - packing, - packagingFk, + ish.`grouping`, + ish.packing, + ish.packagingFk, account.myUser_getId(), - isChecked - FROM itemShelving - WHERE itemFK = vSelf - AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci + ish.isChecked + FROM itemShelving ish + JOIN shelving sh ON sh.id = ish.shelvingFk + WHERE ish.itemFK = vSelf + AND sh.code = vShelvingCode COLLATE utf8mb3_general_ci ON DUPLICATE KEY UPDATE visible = vQuantity + VALUES(visible); diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index 1d206e20d..813c65ab2 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -217,7 +217,7 @@ proc: BEGIN st.code = 'previousPrepared' isPreviousPrepared, sc.itemPackingTypeFk FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector sc ON sc.id = p.sectorFk JOIN sectorType st ON st.id = sc.typeFk diff --git a/db/routines/vn/procedures/sale_boxPickingPrint.sql b/db/routines/vn/procedures/sale_boxPickingPrint.sql index 6bb954a78..aa4a14acd 100644 --- a/db/routines/vn/procedures/sale_boxPickingPrint.sql +++ b/db/routines/vn/procedures/sale_boxPickingPrint.sql @@ -74,7 +74,7 @@ w1: WHILE vQuantity >= vPacking DO p.pickingOrder, ish.created FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk LEFT JOIN itemShelvingSale iss ON iss.itemShelvingFk = ish.id @@ -264,7 +264,7 @@ w1: WHILE vQuantity >= vPacking DO SELECT shelvingFk, p.code INTO vShelving, vParkingCode FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk WHERE ish.id = vItemShelvingFk; diff --git a/db/routines/vn/procedures/sale_getBoxPickingList.sql b/db/routines/vn/procedures/sale_getBoxPickingList.sql index f343ab375..4f6a08083 100644 --- a/db/routines/vn/procedures/sale_getBoxPickingList.sql +++ b/db/routines/vn/procedures/sale_getBoxPickingList.sql @@ -41,7 +41,7 @@ BEGIN AND iss.created >= vDated GROUP BY iss.itemShelvingFk, s.itemFk) tISS ON tISS.itemFk = ish.itemFk AND tISS.itemShelvingFk = ish.id - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk JOIN agencyMode am ON am.id = pb.agencyModeFk diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index b50b4784d..f074b2a4a 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -87,7 +87,7 @@ BEGIN SUM(ish.visible) visible, s.warehouseFk warehouseFk FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector s ON s.id = p.sectorFk GROUP BY ish.itemFk, s.warehouseFk; diff --git a/db/routines/vn/procedures/shelving_clean.sql b/db/routines/vn/procedures/shelving_clean.sql index 0b29968bc..155338827 100644 --- a/db/routines/vn/procedures/shelving_clean.sql +++ b/db/routines/vn/procedures/shelving_clean.sql @@ -12,12 +12,12 @@ BEGIN DELETE ish.* FROM itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk WHERE sh.parkingFk IS NULL AND ish.created < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); UPDATE shelving sh - LEFT JOIN itemShelving its ON its.shelvingFk = sh.`code` + LEFT JOIN itemShelving its ON its.shelvingFk = sh.id SET isPrinted = 0, parkingFk = NULL WHERE its.id IS NULL @@ -27,11 +27,11 @@ UPDATE shelving sh OR sh.parked < util.VN_CURDATE() - INTERVAL 2 WEEK ) - AND IF(code REGEXP '^[A-Za-z]{2}[0-9]', LEFT (code, 2) NOT IN ( - SELECT DISTINCT LEFT(its.shelvingFk, 2) + SELECT DISTINCT LEFT(sh.code, 2) FROM itemShelving its - WHERE its.shelvingFk REGEXP '^[A-Za-z]{2}[0-9]' + JOIN shelving sh ON sh.id = its.shelvingFk + WHERE sh.code REGEXP '^[A-Za-z]{2}[0-9]' ), TRUE); END$$ From b025a8b80431bd1d15d85d7aa3383b85d1b7f829 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 13 Nov 2024 09:10:18 +0100 Subject: [PATCH 31/92] fix: refs #7404 filter an rounding issues --- .../vn/procedures/stockBought_calculate.sql | 2 +- .../methods/stock-bought/getStockBought.js | 9 ++++--- .../stock-bought/getStockBoughtDetail.js | 27 +++++++++++++------ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/db/routines/vn/procedures/stockBought_calculate.sql b/db/routines/vn/procedures/stockBought_calculate.sql index ba044604a..c3b5a0dc6 100644 --- a/db/routines/vn/procedures/stockBought_calculate.sql +++ b/db/routines/vn/procedures/stockBought_calculate.sql @@ -59,7 +59,7 @@ proc: BEGIN INSERT INTO stockBought(workerFk, bought, dated) SELECT tb.workerFk, - ROUND(GREATEST(tb.bought - IFNULL(ts.sold, 0), 0), 1), + ROUND(GREATEST(tb.bought - IFNULL(ts.sold, 0), 0), 2), vDated FROM tStockBought tb LEFT JOIN tStockSold ts ON ts.workerFk = tb.workerFk; diff --git a/modules/entry/back/methods/stock-bought/getStockBought.js b/modules/entry/back/methods/stock-bought/getStockBought.js index c1f99c496..9768b58e7 100644 --- a/modules/entry/back/methods/stock-bought/getStockBought.js +++ b/modules/entry/back/methods/stock-bought/getStockBought.js @@ -6,6 +6,9 @@ module.exports = Self => { arg: 'workerFk', type: 'number', description: 'The id for a buyer', + }, { + arg: 'filter', + type: 'object', }, { arg: 'dated', @@ -23,7 +26,7 @@ module.exports = Self => { } }); - Self.getStockBought = async(workerFk, dated = Date.vnNew()) => { + Self.getStockBought = async(workerFk, filter, dated = Date.vnNew()) => { const models = Self.app.models; const today = Date.vnNew(); dated.setHours(0, 0, 0, 0); @@ -31,7 +34,7 @@ module.exports = Self => { await models.StockBought.rawSql(`CALL vn.stockBought_calculate(?)`, [dated]); - const filter = { + const defaultFilter = { where: {dated}, include: [ { @@ -53,6 +56,6 @@ module.exports = Self => { if (workerFk) filter.where.workerFk = workerFk; - return models.StockBought.find(filter); + return models.StockBought.find({...filter, ...defaultFilter}); }; }; diff --git a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js index d5f712edf..60b099682 100644 --- a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js +++ b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js @@ -1,3 +1,4 @@ +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; module.exports = Self => { Self.remoteMethod('getStockBoughtDetail', { description: 'Returns the detail of stock bought for a given date and a worker', @@ -12,6 +13,9 @@ module.exports = Self => { type: 'string', description: 'The date to filter', required: true, + }, { + arg: 'filter', + type: 'object', } ], returns: { @@ -24,11 +28,10 @@ module.exports = Self => { } }); - Self.getStockBoughtDetail = async(workerFk, dated) => { - const models = Self.app.models; + Self.getStockBoughtDetail = async(workerFk, dated, filter, options) => { + const conn = Self.dataSource.connector; const myOptions = {}; let tx; - let result; if (typeof options == 'object') Object.assign(myOptions, options); @@ -39,8 +42,10 @@ module.exports = Self => { } try { - await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated], myOptions); - result = await Self.rawSql( + const stmts = []; + stmts.push(new ParameterizedSQL(`CALL vn.item_calculateStock(?)`, [dated])); + + const query = new ParameterizedSQL( `SELECT b.entryFk entryFk, i.id itemFk, i.name itemName, @@ -61,11 +66,17 @@ module.exports = Self => { JOIN volumeConfig vc WHERE ic.display AND w.id = ?`, - [workerFk], myOptions + [workerFk] ); - await Self.rawSql(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate;`, [], myOptions); + + stmts.push(query.merge(conn.makeSuffix(filter))); + + stmts.push(new ParameterizedSQL(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate`)); + + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await conn.executeStmt(sql, myOptions); if (tx) await tx.commit(); - return result; + return result[1]; } catch (e) { await tx.rollback(); throw e; From 5d908fd5f9e3ff6d553ab90ce24a1698f6e12979 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 09:33:28 +0100 Subject: [PATCH 32/92] feat: refs #7641 improve style --- .../reports/entry-order/assets/css/style.css | 5 ++++ .../reports/entry-order/entry-order.html | 25 ++++++++++++------- .../reports/entry-order/locale/es.yml | 3 ++- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css index 1a5ea3eb6..858ae704e 100644 --- a/print/templates/reports/entry-order/assets/css/style.css +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -22,4 +22,9 @@ h3 { .column-oriented th, .column-oriented td{ padding: 5px +} + +[row] { + display: flex; + column-gap: 5px; } \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index 5ce306827..cbdfa631f 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -41,12 +41,13 @@
{{$t('reference')}} {{$t('boxes')}} {{$t('packing')}}{{$t('concept')}}{{$t('reference')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}{{$t('concept')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}
{{buy.comment}} {{buy.stickers}}x{{buy.packing}}{{buy.name}}{{buy.comment}} - {{buy.tag5}} → {{buy.value5}} - {{buy.tag6}} → {{buy.value6}} - {{buy.tag7}} → {{buy.value7}} + x{{buy.packing}}{{buy.name}} + {{buy.tag5}} → {{buy.value5}} + {{buy.tag6}} → {{buy.value6}} + {{buy.tag7}} → {{buy.value7}} {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= + {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= {{buy.buyingValue * buy.quantity | currency('EUR', $i18n.locale)}}
{{getTotalBy('stickers')}} {{getTotalBy('stickers')}}
- + - - + + + @@ -56,15 +57,20 @@ - + - - + + @@ -83,6 +89,7 @@ + diff --git a/print/templates/reports/entry-order/locale/es.yml b/print/templates/reports/entry-order/locale/es.yml index 5a6716ba1..9ec357802 100644 --- a/print/templates/reports/entry-order/locale/es.yml +++ b/print/templates/reports/entry-order/locale/es.yml @@ -16,4 +16,5 @@ entry: Entrada {0} supplierData: Datos del proveedor notes: Notas reference: Referencia -tags: Tags \ No newline at end of file +tags: Etiquetas +code: Código \ No newline at end of file From 1086981b536b8825f0ee4eace4448f088015f9bb Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 09:35:06 +0100 Subject: [PATCH 33/92] fix: refs #7779 ticket_splitItemPackingType --- .../vn/procedures/ticket_splitItemPackingType.sql | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 9a4bc01eb..92ff393cd 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -14,7 +14,7 @@ proc:BEGIN */ DECLARE vDone INT DEFAULT FALSE; DECLARE vHasItemPackingType BOOL; - DECLARE vItemPackingTypeFk INT; + DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; DECLARE vNewTicketFk INT; DECLARE vItemPackingTypes CURSOR FOR @@ -36,14 +36,10 @@ proc:BEGIN ) ENGINE=MEMORY SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk; - IF NOT vHasItemPackingType THEN - LEAVE proc; - END IF; - CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( ticketFk INT, saleFk INT, - itemPackingTypeFk INT + itemPackingTypeFk VARCHAR(1) ) ENGINE=MEMORY; INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) @@ -55,7 +51,6 @@ proc:BEGIN AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; OPEN vItemPackingTypes; - l: LOOP SET vDone = FALSE; FETCH vItemPackingTypes INTO vItemPackingTypeFk; @@ -71,7 +66,6 @@ proc:BEGIN WHERE itemPackingTypeFk = vItemPackingTypeFk; END LOOP; - CLOSE vItemPackingTypes; UPDATE sale s From 2273dc636e4652900fd816301d2baba335483bff Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 09:56:38 +0100 Subject: [PATCH 34/92] refactor: refs #7920 Major changes --- db/routines/vn/procedures/shelvingChange.sql | 11 +++++------ .../vn/procedures/shelvingParking_get.sql | 19 +++++++++++-------- .../vn/procedures/shelving_getSpam.sql | 4 ++-- .../ticketDown_PrintableSelection.sql | 2 +- .../vn/procedures/ticket_DelayTruckSplit.sql | 2 +- .../vn/procedures/ticket_getSplitList.sql | 2 +- db/routines/vn/views/itemShelvingList.sql | 2 +- .../itemShelvingPlacementSupplyStock.sql | 2 +- db/routines/vn/views/itemShelvingSaleSum.sql | 2 +- db/routines/vn/views/itemShelvingStock.sql | 2 +- .../vn/views/itemShelvingStockFull.sql | 2 +- 11 files changed, 26 insertions(+), 24 deletions(-) diff --git a/db/routines/vn/procedures/shelvingChange.sql b/db/routines/vn/procedures/shelvingChange.sql index 2e7e92082..f0756b385 100644 --- a/db/routines/vn/procedures/shelvingChange.sql +++ b/db/routines/vn/procedures/shelvingChange.sql @@ -1,11 +1,10 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8)) BEGIN - - UPDATE vn.itemShelving - SET shelvingFk = vShelvingD COLLATE utf8_unicode_ci - WHERE shelvingFk = vShelvingO COLLATE utf8_unicode_ci; - - + UPDATE itemShelving ish + JOIN shelving sh1 ON sh1.code = vShelvingD COLLATE utf8_unicode_ci + JOIN shelving sh2 ON sh2.code = vShelvingO COLLATE utf8_unicode_ci + SET ish.shelvingFk = sh1.id + WHERE ish.shelvingFk = sh2.id; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/shelvingParking_get.sql b/db/routines/vn/procedures/shelvingParking_get.sql index a9ed9f74a..c05e8afc3 100644 --- a/db/routines/vn/procedures/shelvingParking_get.sql +++ b/db/routines/vn/procedures/shelvingParking_get.sql @@ -1,8 +1,10 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT) -BEGIN - - +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingParking_get`( + vShelvingCode VARCHAR(10), + vWarehouseFk INT, + vDayRange INT +) +BEGIN SELECT s.itemFk, s.concept, CAST(SUM(s.quantity) AS DECIMAL(10,0)) as sinServir, @@ -10,14 +12,15 @@ SELECT s.itemFk, FROM vn.sale s LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk - LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk AND ist.warehouseFk = vWarehouseFk - JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk AND ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci + LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk + AND ist.warehouseFk = vWarehouseFk + JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk + JOIN shelving sh ON sh.id = ish.shelvingFk + AND sh.code = vShelvingCode COLLATE utf8_general_ci WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), util.VN_CURDATE())) AND iss.saleFk IS NULL AND t.warehouseFk = vWarehouseFk GROUP BY s.itemFk HAVING sinServir > aparcado; - - END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/shelving_getSpam.sql b/db/routines/vn/procedures/shelving_getSpam.sql index cef407285..a80021cdf 100644 --- a/db/routines/vn/procedures/shelving_getSpam.sql +++ b/db/routines/vn/procedures/shelving_getSpam.sql @@ -25,7 +25,7 @@ BEGIN LEFT JOIN ( SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS reserva FROM vn.itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector s ON s.id = p.sectorFk WHERE s.code = 'FUENTES_PICASSE' @@ -68,7 +68,7 @@ BEGIN sh.isSpam FROM vn.itemShelving ish JOIN vn.item i ON i.id = ish.itemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector s ON s.id = p.sectorFk JOIN vn.warehouse w ON w.id = s.warehouseFk diff --git a/db/routines/vn/procedures/ticketDown_PrintableSelection.sql b/db/routines/vn/procedures/ticketDown_PrintableSelection.sql index 082a890a6..8f448d647 100644 --- a/db/routines/vn/procedures/ticketDown_PrintableSelection.sql +++ b/db/routines/vn/procedures/ticketDown_PrintableSelection.sql @@ -9,7 +9,7 @@ BEGIN JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id JOIN vn.itemShelving ish ON ish.id = iss.itemShelvingFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.shelving sh ON sh.id = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk WHERE p.sectorFk = vSectorFk ) sub ON sub.id = td.ticketFk diff --git a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql index 1dc45d065..3d22207f3 100644 --- a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql +++ b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql @@ -27,7 +27,7 @@ BEGIN SUM(ish.visible) visible, s.warehouseFk warehouseFk FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector s ON s.id = p.sectorFk GROUP BY ish.itemFk, diff --git a/db/routines/vn/procedures/ticket_getSplitList.sql b/db/routines/vn/procedures/ticket_getSplitList.sql index 988bc2931..66e9bdb57 100644 --- a/db/routines/vn/procedures/ticket_getSplitList.sql +++ b/db/routines/vn/procedures/ticket_getSplitList.sql @@ -28,7 +28,7 @@ BEGIN SUM(ish.visible) visible, s.warehouseFk warehouseFk FROM itemShelving ish - JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector s ON s.id = p.sectorFk GROUP BY ish.itemFk, diff --git a/db/routines/vn/views/itemShelvingList.sql b/db/routines/vn/views/itemShelvingList.sql index 457d6f28a..f2cfeda58 100644 --- a/db/routines/vn/views/itemShelvingList.sql +++ b/db/routines/vn/views/itemShelvingList.sql @@ -15,7 +15,7 @@ FROM ( ( ( `vn`.`itemShelving` `ish` - JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) + JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`) ) JOIN `vn`.`item` `i` ON(`i`.`id` = `ish`.`itemFk`) ) diff --git a/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql b/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql index fa1c11314..1ebb6410c 100644 --- a/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql +++ b/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql @@ -18,7 +18,7 @@ FROM ( ( ( `vn`.`itemShelving` `ish` - JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) + JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`) ) LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) ) diff --git a/db/routines/vn/views/itemShelvingSaleSum.sql b/db/routines/vn/views/itemShelvingSaleSum.sql index 9a402d6f4..60581faa9 100644 --- a/db/routines/vn/views/itemShelvingSaleSum.sql +++ b/db/routines/vn/views/itemShelvingSaleSum.sql @@ -13,7 +13,7 @@ FROM ( `vn`.`itemShelvingSale` `iss` JOIN `vn`.`itemShelving` `ish` ON(`ish`.`id` = `iss`.`itemShelvingFk`) ) - JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) + JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`) ) JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) ) diff --git a/db/routines/vn/views/itemShelvingStock.sql b/db/routines/vn/views/itemShelvingStock.sql index 41777eaec..725a06f88 100644 --- a/db/routines/vn/views/itemShelvingStock.sql +++ b/db/routines/vn/views/itemShelvingStock.sql @@ -21,7 +21,7 @@ FROM ( ( ( `vn`.`itemShelving` `ish` - LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) + LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`) ) LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) ) diff --git a/db/routines/vn/views/itemShelvingStockFull.sql b/db/routines/vn/views/itemShelvingStockFull.sql index c767823d6..c8a82685c 100644 --- a/db/routines/vn/views/itemShelvingStockFull.sql +++ b/db/routines/vn/views/itemShelvingStockFull.sql @@ -19,7 +19,7 @@ FROM ( ( ( `vn`.`itemShelving` `ish` - JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) + JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`) ) JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) ) From 274a365ec0b7edf5d6a87166dc655b2194f8fc00 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 13 Nov 2024 11:03:57 +0100 Subject: [PATCH 35/92] feat: refs #6403 add debug on cancel shipment --- back/methods/mrw-config/cancelShipment.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 56d206529..98aa8be39 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -39,6 +39,9 @@ module.exports = Self => { const xmlString = response.data; const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); + + await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipment', xmlDoc]); + const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; return result.toLowerCase().includes('se ha cancelado correctamente'); }; From b3bf0024e30a73d43c0633e0d0780adc2cf8b6c7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 11:15:31 +0100 Subject: [PATCH 36/92] refactor: refs #7920 Major changes --- back/methods/collection/getTickets.js | 4 ++-- db/routines/vn/procedures/entry_splitByShelving.sql | 4 ++-- db/routines/vn/procedures/itemShelvingLog_get.sql | 13 +++++++------ .../item/back/methods/item-shelving-sale/filter.js | 2 +- .../back/methods/item-shelving/getListItemNewer.js | 8 ++++---- modules/item/back/models/item-shelving.json | 3 +-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js index 48301a366..693358fb0 100644 --- a/back/methods/collection/getTickets.js +++ b/back/methods/collection/getTickets.js @@ -73,7 +73,7 @@ module.exports = Self => { JOIN item i ON i.id = s.itemFk JOIN itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - LEFT JOIN shelving sh ON sh.code = ish.shelvingFk + LEFT JOIN shelving sh ON sh.id = ish.shelvingFk LEFT JOIN parking p ON p.id = sh.parkingFk LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk LEFT JOIN origin o ON o.id = i.originFk @@ -114,7 +114,7 @@ module.exports = Self => { JOIN item i ON i.id = s.itemFk JOIN itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - LEFT JOIN shelving sh ON sh.code = ish.shelvingFk + LEFT JOIN shelving sh ON sh.id = ish.shelvingFk LEFT JOIN parking p ON p.id = sh.parkingFk LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk LEFT JOIN origin o ON o.id = i.originFk diff --git a/db/routines/vn/procedures/entry_splitByShelving.sql b/db/routines/vn/procedures/entry_splitByShelving.sql index 026c47daa..3201900e6 100644 --- a/db/routines/vn/procedures/entry_splitByShelving.sql +++ b/db/routines/vn/procedures/entry_splitByShelving.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`( - vShelvingCode VARCHAR(3), + vShelvingCode VARCHAR(10), vFromEntryFk INT, vToEntryFk INT ) @@ -19,7 +19,7 @@ BEGIN DECLARE vDone BOOLEAN DEFAULT FALSE; DECLARE cur CURSOR FOR - SELECT bb.id buyFk, + SELECT bb.id buyFk, LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers, bb.stickers buyStickers FROM itemShelving ish diff --git a/db/routines/vn/procedures/itemShelvingLog_get.sql b/db/routines/vn/procedures/itemShelvingLog_get.sql index 52e7a273f..de4211e41 100644 --- a/db/routines/vn/procedures/itemShelvingLog_get.sql +++ b/db/routines/vn/procedures/itemShelvingLog_get.sql @@ -1,14 +1,14 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`(vShelvingFk VARCHAR(10) ) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`( + vShelvingFk VARCHAR(10) +) BEGIN - /** * Devuelve el log de los item en cada carro * * @param vShelvingFk Matrícula del carro * */ - SELECT isl.itemShelvingFk, isl.created, isl.accion, @@ -28,8 +28,9 @@ BEGIN FROM item JOIN itemShelvingLog isl ON item.id = isl.itemFk JOIN worker ON isl.workerFk = worker.id - WHERE shelvingFk = vShelvingFk OR isl.itemFk = vShelvingFk - ORDER BY isl.created DESC; - + JOIN shelving sh ON sh.id = isl.shelvingFk + WHERE sh.code = vShelvingFk COLLATE utf8mb3_unicode_ci + OR isl.itemFk = vShelvingFk -- ?? Respeto porque ya estaba + ORDER BY isl.created DESC; END$$ DELIMITER ; diff --git a/modules/item/back/methods/item-shelving-sale/filter.js b/modules/item/back/methods/item-shelving-sale/filter.js index 01a9f1856..edd04b61f 100644 --- a/modules/item/back/methods/item-shelving-sale/filter.js +++ b/modules/item/back/methods/item-shelving-sale/filter.js @@ -41,7 +41,7 @@ module.exports = Self => { u.name FROM itemShelvingSale iss LEFT JOIN itemShelving ish ON iss.itemShelvingFk = ish.id - LEFT JOIN shelving s ON ish.shelvingFk = s.code + LEFT JOIN shelving s ON ish.shelvingFk = s.id LEFT JOIN parking p ON s.parkingFk = p.id LEFT JOIN account.user u ON u.id = iss.userFk` ); diff --git a/modules/item/back/methods/item-shelving/getListItemNewer.js b/modules/item/back/methods/item-shelving/getListItemNewer.js index 74c73532a..5c4ca277d 100644 --- a/modules/item/back/methods/item-shelving/getListItemNewer.js +++ b/modules/item/back/methods/item-shelving/getListItemNewer.js @@ -45,19 +45,19 @@ module.exports = Self => { WITH tItemShelving AS( SELECT is2.itemFk, is2.created, p.sectorFK, is2.id FROM vn.itemShelving is2 - JOIN vn.shelving sh ON sh.code = is2.shelvingFk + JOIN vn.shelving sh ON sh.id = is2.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector s ON s.id = p.sectorFk JOIN vn.productionConfig pc - WHERE is2.shelvingFk = ? AND s.code = pc.sectorFromCode + WHERE sh.code = ? AND s.code = pc.sectorFromCode ), tItemInSector AS ( SELECT is2.itemFk, is2.created, is2.shelvingFk FROM vn.itemShelving is2 - JOIN vn.shelving sh ON sh.code = is2.shelvingFk + JOIN vn.shelving sh ON sh.id = is2.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector s ON s.id = p.sectorFk JOIN vn.productionConfig pc - WHERE is2.shelvingFk <> ? + WHERE sh.code <> ? AND s.code = pc.sectorFromCode) SELECT ti.itemFK, tis.shelvingFk FROM tItemShelving ti diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 5df3b0703..9a0ebc61d 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -57,8 +57,7 @@ "shelving": { "type": "belongsTo", "model": "Shelving", - "foreignKey": "shelvingFk", - "primaryKey": "code" + "foreignKey": "shelvingFk" } } } \ No newline at end of file From 755312b981fd89a6fb60b6d155d6d6792cec3fbb Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 11:51:23 +0100 Subject: [PATCH 37/92] refactor: refs #7920 Fix tests --- .../methods/item-shelving/getAlternative.js | 14 +++++++++++--- .../specs/updateFromSale.spec.js | 2 +- .../item-shelving/specs/upsertItem.spec.js | 19 ++++++++++++++----- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/modules/item/back/methods/item-shelving/getAlternative.js b/modules/item/back/methods/item-shelving/getAlternative.js index 8108bfa6e..de34739bc 100644 --- a/modules/item/back/methods/item-shelving/getAlternative.js +++ b/modules/item/back/methods/item-shelving/getAlternative.js @@ -3,7 +3,7 @@ module.exports = Self => { description: 'Returns a list of items and possible alternative locations', accessType: 'READ', accepts: [{ - arg: 'shelvingFk', + arg: 'shelvingCode', type: 'string', required: true, }], @@ -17,13 +17,21 @@ module.exports = Self => { } }); - Self.getAlternative = async(shelvingFk, options) => { + Self.getAlternative = async(shelvingCode, options) => { const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); + const shelving = await models.Shelving.findOne({ + where: { + code: shelvingCode + } + }); + + if (!shelving) return []; + const {id: shelvingFk} = shelving; const filterItemShelvings = { fields: ['id', 'visible', 'itemFk', 'shelvingFk'], where: {shelvingFk}, @@ -42,7 +50,7 @@ module.exports = Self => { if (itemShelvings) { const [alternatives] = await models.ItemShelving.rawSql('CALL vn.itemShelving_getAlternatives(?)', - [shelvingFk], myOptions + [shelvingCode], myOptions ); return itemShelvings.map(itemShelving => { const item = itemShelving.item(); diff --git a/modules/item/back/methods/item-shelving/specs/updateFromSale.spec.js b/modules/item/back/methods/item-shelving/specs/updateFromSale.spec.js index dfa294000..2cdb5994b 100644 --- a/modules/item/back/methods/item-shelving/specs/updateFromSale.spec.js +++ b/modules/item/back/methods/item-shelving/specs/updateFromSale.spec.js @@ -5,7 +5,7 @@ describe('itemShelving updateFromSale()', () => { const tx = await models.ItemBarcode.beginTransaction({}); const options = {transaction: tx}; const saleFk = 2; - const filter = {where: {itemFk: 4, shelvingFk: 'HEJ'} + const filter = {where: {itemFk: 4, shelvingFk: 12} }; try { const {visible: visibleBefore} = await models.ItemShelving.findOne(filter, options); diff --git a/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js b/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js index f01cb985d..edc850211 100644 --- a/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js +++ b/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js @@ -18,22 +18,31 @@ describe('ItemShelving upsertItem()', () => { }); it('should add two new records', async() => { - const shelvingFk = 'GVC'; + const shelvingCode = 'GVC'; const items = [1, 1, 1, 2]; - - await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options); + const {id: shelvingFk} = await models.Shelving.findOne({ + where: { + code: shelvingCode + } + }); + await models.ItemShelving.upsertItem(ctx, shelvingCode, items, warehouseFk, options); const itemShelvings = await models.ItemShelving.find({where: {shelvingFk}}, options); expect(itemShelvings.length).toEqual(2); }); it('should update the visible items', async() => { - const shelvingFk = 'GVC'; + const shelvingCode = 'GVC'; const items = [2, 2]; + const {id: shelvingFk} = await models.Shelving.findOne({ + where: { + code: shelvingCode + } + }); const {visible: visibleItemsBefore} = await models.ItemShelving.findOne({ where: {shelvingFk, itemFk: items[0]} }, options); - await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options); + await models.ItemShelving.upsertItem(ctx, shelvingCode, items, warehouseFk, options); const {visible: visibleItemsAfter} = await models.ItemShelving.findOne({ where: {shelvingFk, itemFk: items[0]} From 5a134668da73d8a7205856248d2b40b2e14de8fa Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 12:04:47 +0100 Subject: [PATCH 38/92] refactor: refs #7920 itemShelvingLog --- .../{00-firstScript.sql => 00-itemShelving.sql} | 6 +++--- .../11342-crimsonDendro/01-itemShelvingLog.sql | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) rename db/versions/11342-crimsonDendro/{00-firstScript.sql => 00-itemShelving.sql} (73%) create mode 100644 db/versions/11342-crimsonDendro/01-itemShelvingLog.sql diff --git a/db/versions/11342-crimsonDendro/00-firstScript.sql b/db/versions/11342-crimsonDendro/00-itemShelving.sql similarity index 73% rename from db/versions/11342-crimsonDendro/00-firstScript.sql rename to db/versions/11342-crimsonDendro/00-itemShelving.sql index 56bea2c03..7a173e203 100644 --- a/db/versions/11342-crimsonDendro/00-firstScript.sql +++ b/db/versions/11342-crimsonDendro/00-itemShelving.sql @@ -3,14 +3,14 @@ CREATE OR REPLACE TEMPORARY TABLE tItemShelving ENGINE = MEMORY SELECT ish.id, s.id shelvingFk FROM shelving s - JOIN itemShelving ish ON ish.shelvingFk = s.code; + JOIN itemShelving ish ON ish.shelvingFk = s.code COLLATE utf8mb3_unicode_ci; ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2, MODIFY COLUMN shelvingFk int(11) NOT NULL; UPDATE itemShelving ish - JOIN tItemShelving tis ON tis.id = ish.id - SET ish.shelvingFk = tis.shelvingFk; + JOIN tItemShelving tish ON tish.id = ish.id + SET ish.shelvingFk = tish.shelvingFk; DROP TEMPORARY TABLE tItemShelving; diff --git a/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql new file mode 100644 index 000000000..05f04b5ff --- /dev/null +++ b/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql @@ -0,0 +1,14 @@ +CREATE OR REPLACE TEMPORARY TABLE tItemShelvingLog + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT ishl.id, s.id shelvingFk + FROM shelving s + JOIN itemShelvingLog ishl ON ishl.shelvingFk = s.code COLLATE utf8mb3_unicode_ci; + +ALTER TABLE vn.itemShelvingLog MODIFY COLUMN shelvingFk int(11) NOT NULL; + +UPDATE itemShelvingLog ishl + JOIN tItemShelvingLog tishl ON tishl.id = ishl.id + SET ishl.shelvingFk = tishl.shelvingFk; + +DROP TEMPORARY TABLE tItemShelvingLog; From aa1c017f2203e8e7226dd3a4dd54054698201175 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 12:17:58 +0100 Subject: [PATCH 39/92] fix: refs #7779 ticket_splitItemPackingType --- .../ticket_splitItemPackingType.sql | 145 ++++++++++++------ 1 file changed, 94 insertions(+), 51 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 92ff393cd..0ee865af5 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -3,81 +3,124 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki vSelf INT, vOriginalItemPackingTypeFk VARCHAR(1) ) -proc:BEGIN +BEGIN /** - * Clona y reparte las líneas de ventas de un ticket en funcion del tipo de empaquetado. - * Respeta el id de ticket original para el tipo de empaquetado propuesto. + * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado. + * Respeta el id inicial para el tipo propuesto. * * @param vSelf Id ticket - * @param vOriginalItemPackingTypeFk Tipo empaquetado que se mantiene el ticket original + * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ - DECLARE vDone INT DEFAULT FALSE; - DECLARE vHasItemPackingType BOOL; DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; DECLARE vNewTicketFk INT; + DECLARE vPackingTypesToSplit INT; + DECLARE vDone INT DEFAULT FALSE; - DECLARE vItemPackingTypes CURSOR FOR - SELECT DISTINCT itemPackingTypeFk - FROM tSalesToMove; + DECLARE vSaleGroup CURSOR FOR + SELECT itemPackingTypeFk + FROM tSaleGroup + WHERE itemPackingTypeFk IS NOT NULL + ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - SELECT COUNT(*) INTO vHasItemPackingType - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - WHERE t.id = vSelf - AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk; + START TRANSACTION; + + SELECT id + FROM sale + WHERE ticketFk = vSelf + AND NOT quantity + FOR UPDATE; + + DELETE FROM sale + WHERE NOT quantity + AND ticketFk = vSelf; + + CREATE OR REPLACE TEMPORARY TABLE tSale + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros + FROM sale s + JOIN item i ON i.id = s.itemFk + LEFT JOIN saleVolume sv ON sv.saleFk = s.id + WHERE s.ticketFk = vSelf; + + CREATE OR REPLACE TEMPORARY TABLE tSaleGroup + ENGINE = MEMORY + SELECT itemPackingTypeFk, SUM(litros) totalLitros + FROM tSale + GROUP BY itemPackingTypeFk; + + SELECT COUNT(*) INTO vPackingTypesToSplit + FROM tSaleGroup + WHERE itemPackingTypeFk IS NOT NULL; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( ticketFk INT, itemPackingTypeFk VARCHAR(1) - ) ENGINE=MEMORY - SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk; + ) ENGINE = MEMORY; - CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( - ticketFk INT, - saleFk INT, - itemPackingTypeFk VARCHAR(1) - ) ENGINE=MEMORY; + CASE vPackingTypesToSplit + WHEN 0 THEN + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + VALUES(vSelf, vItemPackingTypeFk); + WHEN 1 THEN + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + SELECT vSelf, itemPackingTypeFk + FROM tSaleGroup + WHERE itemPackingTypeFk IS NOT NULL; + ELSE + OPEN vSaleGroup; + FETCH vSaleGroup INTO vItemPackingTypeFk; - INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) - SELECT s.id, i.itemPackingTypeFk - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - WHERE t.id = vSelf - AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + VALUES(vSelf, vItemPackingTypeFk); - OPEN vItemPackingTypes; - l: LOOP - SET vDone = FALSE; - FETCH vItemPackingTypes INTO vItemPackingTypeFk; + l: LOOP + SET vDone = FALSE; + FETCH vSaleGroup INTO vItemPackingTypeFk; - IF vDone THEN - LEAVE l; - END IF; + IF vDone THEN + LEAVE l; + END IF; - CALL ticket_Clone(vSelf, vNewTicketFk); + CALL ticket_Clone(vSelf, vNewTicketFk); - UPDATE tSalesToMove - SET ticketFk = vNewTicketFk - WHERE itemPackingTypeFk = vItemPackingTypeFk; + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + VALUES(vNewTicketFk, vItemPackingTypeFk); + END LOOP; - END LOOP; - CLOSE vItemPackingTypes; + CLOSE vSaleGroup; - UPDATE sale s - JOIN tSalesToMove stm ON stm.saleFk = s.id - SET s.ticketFk = stm.ticketFk - WHERE stm.ticketFk; + SELECT s.id + FROM sale s + JOIN tSale ts ON ts.id = s.id + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk + FOR UPDATE; - INSERT INTO tmp.ticketIPT (ticketFk, itemPackingTypeFk) - SELECT ticketFk, itemPackingTypeFk - FROM tSalesToMove - GROUP BY ticketFk; + UPDATE sale s + JOIN tSale ts ON ts.id = s.id + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk + SET s.ticketFk = t.ticketFk; - DROP TEMPORARY TABLE tSalesToMove; + SELECT itemPackingTypeFk INTO vItemPackingTypeFk + FROM tSaleGroup sg + WHERE sg.itemPackingTypeFk IS NOT NULL + ORDER BY sg.itemPackingTypeFk + LIMIT 1; + + UPDATE sale s + JOIN tSale ts ON ts.id = s.id + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk + SET s.ticketFk = t.ticketFk + WHERE ts.itemPackingTypeFk IS NULL; + END CASE; + + COMMIT; + + DROP TEMPORARY TABLE + tSale, + tSaleGroup; END$$ DELIMITER ; From 72e067ff81a589db4849b19c4eddd73c675ca780 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 12:53:18 +0100 Subject: [PATCH 40/92] fix: refs #7244 Added collection ACL --- db/versions/11343-silverAsparagus/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11343-silverAsparagus/00-firstScript.sql diff --git a/db/versions/11343-silverAsparagus/00-firstScript.sql b/db/versions/11343-silverAsparagus/00-firstScript.sql new file mode 100644 index 000000000..3ca29e8b4 --- /dev/null +++ b/db/versions/11343-silverAsparagus/00-firstScript.sql @@ -0,0 +1,2 @@ +INSERT INTO salix.ACL (model,property,accessType,principalId) + VALUES ('Collection','*','WRITE','productionBoss'); From 344427da458857a3896dad0853d55a2d4c96dfd2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 13:46:40 +0100 Subject: [PATCH 41/92] feat: refs #8151 moveExpeditions --- .../back/methods/expedition/moveExpeditions.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index 1c6689912..3e9c95ec6 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -80,11 +80,19 @@ module.exports = Self => { const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions); promises.push(expeditionUpdated); } - await Promise.all(promises); + await models.Ticket.updateAll({id: ticket.id}, {packages: promises.length}, myOptions); + const state = await models.State.findOne({ + where: {code: 'PACKED'} + }, myOptions); + + await models.Ticket.state(ctx, { + ticketFk: ticket.id, + stateFk: state.id, + userFk: ctx.req.accessToken.userId + }, myOptions); if (tx) await tx.commit(); - return ticket; } catch (e) { if (tx) await tx.rollback(); From 018393fa93fec4d0642521852eb31686b569ac70 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 14:04:02 +0100 Subject: [PATCH 42/92] feat: refs #8151 Added test --- .../methods/expedition/moveExpeditions.js | 4 +- .../expedition/specs/moveExpeditions.spec.js | 44 ++++++++++++++++++- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index 3e9c95ec6..3ad41897f 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -82,9 +82,7 @@ module.exports = Self => { } await Promise.all(promises); await models.Ticket.updateAll({id: ticket.id}, {packages: promises.length}, myOptions); - const state = await models.State.findOne({ - where: {code: 'PACKED'} - }, myOptions); + const state = await models.State.findOne({where: {code: 'PACKED'}}); await models.Ticket.state(ctx, { ticketFk: ticket.id, diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js index c1c7c2c12..4c4971a0d 100644 --- a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('ticket moveExpeditions()', () => { +fdescribe('ticket moveExpeditions()', () => { const ctx = beforeAll.getCtx(); it('should move the selected expeditions to new ticket', async() => { @@ -32,5 +32,45 @@ describe('ticket moveExpeditions()', () => { throw e; } }); -}); + it('should move expeditions to a new ticket, set state to PACKED, and update packages count correctly', async() => { + const tx = await models.Expedition.beginTransaction({}); + const myCtx = ctx; + + try { + const options = {transaction: tx}; + myCtx.args = { + clientId: 1101, + landed: Date.vnNew(), + warehouseId: 1, + addressId: 121, + agencyModeId: 1, + routeId: null, + expeditionIds: [1, 2] + }; + + const ticket = await models.Expedition.moveExpeditions(myCtx, options); + + const newestTicketIdInFixtures = 27; + + expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures); + + const updatedTicket = await models.Ticket.findById(ticket.id, null, options); + const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options); + + const state = await models.TicketState.findOne({where: {ticketFk: ticket.id}}, options); + + expect(state.stateFk).toBe(packedState.id); + expect(state.userFk).toBe(myCtx.req.accessToken.userId); + + const expectedPackagesCount = myCtx.args.expeditionIds.length; + + expect(updatedTicket.$packages).toBe(expectedPackagesCount); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); From d4a60f63c9125798d1a58474832542d11e80cc04 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 14:05:03 +0100 Subject: [PATCH 43/92] feat: refs #8151 Added test --- .../back/methods/expedition/specs/moveExpeditions.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js index 4c4971a0d..2f0fd673c 100644 --- a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('ticket moveExpeditions()', () => { +describe('ticket moveExpeditions()', () => { const ctx = beforeAll.getCtx(); it('should move the selected expeditions to new ticket', async() => { From 21693cfd718e47eb84ffc654161ff304c84fec05 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 13 Nov 2024 14:33:52 +0100 Subject: [PATCH 44/92] feat: refs #7994 new version script fix --- db/versions/11251-navyChrysanthemum/00-firstScript.sql | 5 ++--- db/versions/11344-grayBamboo/00-firstScript.sql | 3 +++ .../01-firstScript.sql | 0 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 db/versions/11344-grayBamboo/00-firstScript.sql rename db/versions/{11251-navyChrysanthemum => 11344-grayBamboo}/01-firstScript.sql (100%) diff --git a/db/versions/11251-navyChrysanthemum/00-firstScript.sql b/db/versions/11251-navyChrysanthemum/00-firstScript.sql index 801405e59..7c2c69839 100644 --- a/db/versions/11251-navyChrysanthemum/00-firstScript.sql +++ b/db/versions/11251-navyChrysanthemum/00-firstScript.sql @@ -1,3 +1,2 @@ -UPDATE vn.sale - SET originalQuantity = quantity - WHERE originalQuantity IS NULL +-- Debido a que tardaba mucho en la subida a master, se ha creado una nueva versión para que el proceso no se vea afectado y se ejecute por la noche. +-- Se crea de nuevo en la versión 11344-grayBamboo diff --git a/db/versions/11344-grayBamboo/00-firstScript.sql b/db/versions/11344-grayBamboo/00-firstScript.sql new file mode 100644 index 000000000..1fbd2a0d8 --- /dev/null +++ b/db/versions/11344-grayBamboo/00-firstScript.sql @@ -0,0 +1,3 @@ +UPDATE vn.sale + SET originalQuantity = quantity + WHERE originalQuantity IS NULL \ No newline at end of file diff --git a/db/versions/11251-navyChrysanthemum/01-firstScript.sql b/db/versions/11344-grayBamboo/01-firstScript.sql similarity index 100% rename from db/versions/11251-navyChrysanthemum/01-firstScript.sql rename to db/versions/11344-grayBamboo/01-firstScript.sql From e1b0fc298cadabeb9e13cbc21fe3367e3728716b Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 13 Nov 2024 20:26:54 +0100 Subject: [PATCH 45/92] feat: refs #8143 deprecate recoverPass and sync from account.user --- db/routines/account/views/myUser.sql | 3 +-- db/versions/11345-salmonEucalyptus/00-firstScript.sql | 2 ++ modules/account/back/locale/vn-user/en.yml | 2 -- modules/account/back/locale/vn-user/es.yml | 2 -- 4 files changed, 3 insertions(+), 6 deletions(-) create mode 100644 db/versions/11345-salmonEucalyptus/00-firstScript.sql diff --git a/db/routines/account/views/myUser.sql b/db/routines/account/views/myUser.sql index f520d893b..8d927dc0f 100644 --- a/db/routines/account/views/myUser.sql +++ b/db/routines/account/views/myUser.sql @@ -7,8 +7,7 @@ AS SELECT `u`.`id` AS `id`, `u`.`email` AS `email`, `u`.`nickname` AS `nickname`, `u`.`lang` AS `lang`, - `u`.`role` AS `role`, - `u`.`recoverPass` AS `recoverPass` + `u`.`role` AS `role` FROM `account`.`user` `u` WHERE `u`.`name` = `myUser_getName`() WITH CASCADED CHECK OPTION diff --git a/db/versions/11345-salmonEucalyptus/00-firstScript.sql b/db/versions/11345-salmonEucalyptus/00-firstScript.sql new file mode 100644 index 000000000..ecbc36c40 --- /dev/null +++ b/db/versions/11345-salmonEucalyptus/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE account.user CHANGE recoverPass recoverPass__ tinyint(3) unsigned NOT NULL DEFAULT 1 COMMENT '@deprecated 2024-11-13'; +ALTER TABLE account.user CHANGE sync sync__ tinyint(4) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-11-13'; \ No newline at end of file diff --git a/modules/account/back/locale/vn-user/en.yml b/modules/account/back/locale/vn-user/en.yml index 51de7c40d..f911ee1eb 100644 --- a/modules/account/back/locale/vn-user/en.yml +++ b/modules/account/back/locale/vn-user/en.yml @@ -15,7 +15,5 @@ columns: image: image hasGrant: has grant userFk: user - recoverPass: recover password role: role - sync: pending sync lastPassChange: password changed diff --git a/modules/account/back/locale/vn-user/es.yml b/modules/account/back/locale/vn-user/es.yml index 85e8bc0dc..c05dd872c 100644 --- a/modules/account/back/locale/vn-user/es.yml +++ b/modules/account/back/locale/vn-user/es.yml @@ -15,7 +15,5 @@ columns: image: imagen hasGrant: puede delegar userFk: usuario - recoverPass: recuperar contraseña role: rol - sync: Pendiente de sincronizar lastPassChange: contraseña modificada From 9c0af7f7c6be825edcb1f04359c5d7f911d17df1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 07:57:13 +0100 Subject: [PATCH 46/92] refactor: refs #7950 Requested changes --- loopback/common/methods/vn-model/printService.js | 2 +- modules/ticket/back/methods/ticket/saveCmr.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/loopback/common/methods/vn-model/printService.js b/loopback/common/methods/vn-model/printService.js index 12a6a67cc..ed784229b 100644 --- a/loopback/common/methods/vn-model/printService.js +++ b/loopback/common/methods/vn-model/printService.js @@ -2,7 +2,7 @@ const {Report, Email} = require('vn-print'); module.exports = Self => { Self.printReport = async function(ctx, id, reportName) { - const args = Object.assign({}, ctx.args); + const args = Object.assign({id}, ctx.args); const params = {lang: ctx.req.getLocale()}; delete args.ctx; diff --git a/modules/ticket/back/methods/ticket/saveCmr.js b/modules/ticket/back/methods/ticket/saveCmr.js index a96bb6a27..5ac748751 100644 --- a/modules/ticket/back/methods/ticket/saveCmr.js +++ b/modules/ticket/back/methods/ticket/saveCmr.js @@ -53,8 +53,7 @@ module.exports = Self => { if (hasDmsCmr.length) throw new UserError('This ticket already has a cmr saved'); - Object.assign(ctx.args, {id: ticket.$cmrFk}); - const response = await models.Cmr.print(ctx, myOptions); + const response = await models.Cmr.print(ctx, ticket.$cmrFk, myOptions); const pdfStream = Readable.from(Buffer.from(response[0])); const data = { workerFk: ctx.req.accessToken.userId, From b7655b4f9208a807d217f1934f76806c5b740a6d Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 08:24:42 +0100 Subject: [PATCH 47/92] feat: refs #8057 Added geoFk columns --- db/versions/11346-yellowPhormium/00-address.sql | 4 ++++ db/versions/11346-yellowPhormium/01-client.sql | 7 +++++++ db/versions/11346-yellowPhormium/02-supplier.sql | 6 ++++++ 3 files changed, 17 insertions(+) create mode 100644 db/versions/11346-yellowPhormium/00-address.sql create mode 100644 db/versions/11346-yellowPhormium/01-client.sql create mode 100644 db/versions/11346-yellowPhormium/02-supplier.sql diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql new file mode 100644 index 000000000..02e09bd00 --- /dev/null +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.address + ADD geoFk int(11) DEFAULT NULL NULL AFTER isLogifloraAllowed, + ADD CONSTRAINT address_zoneGeo_FK FOREIGN KEY (geoFk) + REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql new file mode 100644 index 000000000..c58810fb1 --- /dev/null +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -0,0 +1,7 @@ +ALTER TABLE vn.client + CHANGE hasDailyInvoice hasDailyInvoice tinyint(1) DEFAULT 0 NOT NULL + COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice' + AFTER recommendedCredit, + ADD geoFk int(11) DEFAULT NULL NULL AFTER hasDailyInvoice, + ADD CONSTRAINT client_zoneGeo_FK FOREIGN KEY (geoFk) + REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql new file mode 100644 index 000000000..f38202d5e --- /dev/null +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.supplier + CHANGE companySize companySize enum('small','medium','big') CHARACTER SET utf8mb3 + COLLATE utf8mb3_general_ci DEFAULT NULL NULL AFTER stamp, + ADD geoFk int(11) DEFAULT NULL NULL AFTER companySize, + ADD CONSTRAINT supplier_zoneGeo_FK FOREIGN KEY (geoFk) + REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; From d4b0da50d0a60cab3e1da5c02358c2cdf060a190 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 09:00:19 +0100 Subject: [PATCH 48/92] feat: refs #8057 Added data updates --- .../11346-yellowPhormium/00-address.sql | 23 +++++++++++++-- .../11346-yellowPhormium/01-client.sql | 29 +++++++++++++++---- .../11346-yellowPhormium/02-supplier.sql | 27 +++++++++++++---- 3 files changed, 65 insertions(+), 14 deletions(-) diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index 02e09bd00..8e1315072 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -1,4 +1,21 @@ ALTER TABLE vn.address - ADD geoFk int(11) DEFAULT NULL NULL AFTER isLogifloraAllowed, - ADD CONSTRAINT address_zoneGeo_FK FOREIGN KEY (geoFk) - REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; + ADD geoFk int(11) DEFAULT NULL NULL AFTER isLogifloraAllowed, + ADD CONSTRAINT address_zoneGeo_FK FOREIGN KEY (geoFk) + REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +CREATE OR REPLACE TEMPORARY TABLE tAddressGeo + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT a.id, p.geoFk + FROM address a + JOIN town t ON t.provinceFk = a.provinceFk + JOIN postCode p ON p.townFk = t.id + AND p.`code` = a.postalCode + GROUP BY a.id + ORDER BY (a.city SOUNDS LIKE t.`name`) DESC; + +UPDATE address a + JOIN tAddressGeo tag ON tag.id = a.id + SET a.geoFk = tag.geoFk; + +DROP TEMPORARY TABLE tAddressGeo; diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index c58810fb1..932b28ef5 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -1,7 +1,24 @@ ALTER TABLE vn.client - CHANGE hasDailyInvoice hasDailyInvoice tinyint(1) DEFAULT 0 NOT NULL - COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice' - AFTER recommendedCredit, - ADD geoFk int(11) DEFAULT NULL NULL AFTER hasDailyInvoice, - ADD CONSTRAINT client_zoneGeo_FK FOREIGN KEY (geoFk) - REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; + CHANGE hasDailyInvoice hasDailyInvoice tinyint(1) DEFAULT 0 NOT NULL + COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice' + AFTER recommendedCredit, + ADD geoFk int(11) DEFAULT NULL NULL AFTER hasDailyInvoice, + ADD CONSTRAINT client_zoneGeo_FK FOREIGN KEY (geoFk) + REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +CREATE OR REPLACE TEMPORARY TABLE tClientGeo + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT c.id, p.geoFk + FROM client c + JOIN town t ON t.provinceFk = c.provinceFk + JOIN postCode p ON p.townFk = t.id + AND p.`code` = c.postcode + GROUP BY c.id + ORDER BY (c.city SOUNDS LIKE t.`name`) DESC; + +UPDATE client c + JOIN tClientGeo tcg ON tcg.id = c.id + SET c.geoFk = tcg.geoFk; + +DROP TEMPORARY TABLE tClientGeo; diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index f38202d5e..ef5e04a43 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -1,6 +1,23 @@ ALTER TABLE vn.supplier - CHANGE companySize companySize enum('small','medium','big') CHARACTER SET utf8mb3 - COLLATE utf8mb3_general_ci DEFAULT NULL NULL AFTER stamp, - ADD geoFk int(11) DEFAULT NULL NULL AFTER companySize, - ADD CONSTRAINT supplier_zoneGeo_FK FOREIGN KEY (geoFk) - REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; + CHANGE companySize companySize enum('small','medium','big') CHARACTER SET utf8mb3 + COLLATE utf8mb3_general_ci DEFAULT NULL NULL AFTER stamp, + ADD geoFk int(11) DEFAULT NULL NULL AFTER companySize, + ADD CONSTRAINT supplier_zoneGeo_FK FOREIGN KEY (geoFk) + REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +CREATE OR REPLACE TEMPORARY TABLE tSupplierGeo + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT sa.supplierFk id, p.geoFk + FROM supplierAddress sa + JOIN town t ON t.provinceFk = sa.provinceFk + JOIN postCode p ON p.townFk = t.id + AND p.`code` = sa.postalCode + GROUP BY sa.supplierFk + ORDER BY (sa.city SOUNDS LIKE t.`name`) DESC; + +UPDATE supplier s + JOIN tSupplierGeo tsg ON tsg.id = s.id + SET s.geoFk = tsg.geoFk; + +DROP TEMPORARY TABLE tSupplierGeo; From cba1abad68cb90b238c3f0a7f7f4d158d247488c Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 09:27:38 +0100 Subject: [PATCH 49/92] feat: refs #8057 Added data updates --- db/routines/vn/functions/client_getGeo.sql | 25 +++++++++++++++++++ db/routines/vn/functions/supplier_getGeo.sql | 25 +++++++++++++++++++ .../vn/triggers/address_beforeInsert.sql | 1 + .../vn/triggers/address_beforeUpdate.sql | 6 ++++- .../vn/triggers/client_beforeInsert.sql | 8 +++--- .../vn/triggers/client_beforeUpdate.sql | 6 +++++ .../vn/triggers/supplier_beforeInsert.sql | 1 + .../vn/triggers/supplier_beforeUpdate.sql | 5 ++++ .../11346-yellowPhormium/02-supplier.sql | 12 ++++----- 9 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 db/routines/vn/functions/client_getGeo.sql create mode 100644 db/routines/vn/functions/supplier_getGeo.sql diff --git a/db/routines/vn/functions/client_getGeo.sql b/db/routines/vn/functions/client_getGeo.sql new file mode 100644 index 000000000..067eb84bc --- /dev/null +++ b/db/routines/vn/functions/client_getGeo.sql @@ -0,0 +1,25 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_getGeo`(vSelf INT) + RETURNS int(11) + DETERMINISTIC +BEGIN +/** + * Returns the geo for the passed client. + * + * @param vSelf The address id + * @return The geo id + */ + DECLARE vGeoFk INT; + + SELECT p.geoFk INTO vGeoFk + FROM client c + JOIN town t ON t.provinceFk = c.provinceFk + JOIN postCode p ON p.townFk = t.id + AND p.`code` = c.postcode + WHERE c.id = vSelf + ORDER BY (c.city SOUNDS LIKE t.`name`) DESC + LIMIT 1; + + RETURN vGeoFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/functions/supplier_getGeo.sql b/db/routines/vn/functions/supplier_getGeo.sql new file mode 100644 index 000000000..93115d712 --- /dev/null +++ b/db/routines/vn/functions/supplier_getGeo.sql @@ -0,0 +1,25 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`supplier_getGeo`(vSelf INT) + RETURNS int(11) + DETERMINISTIC +BEGIN +/** + * Returns the geo for the passed supplier. + * + * @param vSelf The address id + * @return The geo id + */ + DECLARE vGeoFk INT; + + SELECT p.geoFk INTO vGeoFk + FROM supplier s + JOIN town t ON t.provinceFk = s.provinceFk + JOIN postCode p ON p.townFk = t.id + AND p.`code` = s.postCode + WHERE s.id = vSelf + ORDER BY (s.city SOUNDS LIKE t.`name`) DESC + LIMIT 1; + + RETURN vGeoFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/address_beforeInsert.sql b/db/routines/vn/triggers/address_beforeInsert.sql index 56ef7aa51..a4f384f14 100644 --- a/db/routines/vn/triggers/address_beforeInsert.sql +++ b/db/routines/vn/triggers/address_beforeInsert.sql @@ -6,6 +6,7 @@ BEGIN DECLARE vIsEqualizated BOOL; SET NEW.editorFk = account.myUser_getId(); + SET NEW.geoFk = address_getGeo(NEW.id); IF (NEW.phone <> '') THEN CALL pbx.phone_isValid(NEW.phone); diff --git a/db/routines/vn/triggers/address_beforeUpdate.sql b/db/routines/vn/triggers/address_beforeUpdate.sql index 35887912c..0b19a6266 100644 --- a/db/routines/vn/triggers/address_beforeUpdate.sql +++ b/db/routines/vn/triggers/address_beforeUpdate.sql @@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`address_beforeUpdate` BEFORE UPDATE ON `address` FOR EACH ROW BEGIN - SET NEW.editorFk = account.myUser_getId(); IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN @@ -14,5 +13,10 @@ BEGIN CALL pbx.phone_isValid(NEW.mobile); END IF; + IF NOT (NEW.provinceFk <=> OLD.provinceFk) + OR (NEW.postalCode <=> OLD.postalCode) THEN + + SET NEW.geoFk = address_getGeo(NEW.id); + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/client_beforeInsert.sql b/db/routines/vn/triggers/client_beforeInsert.sql index 45de107f1..b4038a2ba 100644 --- a/db/routines/vn/triggers/client_beforeInsert.sql +++ b/db/routines/vn/triggers/client_beforeInsert.sql @@ -3,8 +3,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`client_beforeInsert` BEFORE INSERT ON `client` FOR EACH ROW BEGIN - SET NEW.editorFk = account.myUser_getId(); + SET NEW.accountingAccount = 4300000000 + NEW.id; + SET NEW.lastSalesPersonFk = NEW.salesPersonFk; + SET NEW.geoFk = client_getGeo(NEW.id); IF (NEW.phone <> '') THEN CALL pbx.phone_isValid(NEW.phone); @@ -13,9 +15,5 @@ BEGIN IF (NEW.mobile <> '') THEN CALL pbx.phone_isValid(NEW.mobile); END IF; - - SET NEW.accountingAccount = 4300000000 + NEW.id; - - SET NEW.lastSalesPersonFk = NEW.salesPersonFk; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/client_beforeUpdate.sql b/db/routines/vn/triggers/client_beforeUpdate.sql index 7142d6604..00418a9e7 100644 --- a/db/routines/vn/triggers/client_beforeUpdate.sql +++ b/db/routines/vn/triggers/client_beforeUpdate.sql @@ -72,5 +72,11 @@ BEGIN IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN SET NEW.isTaxDataChecked = 0; END IF; + + IF NOT (NEW.provinceFk <=> OLD.provinceFk) + OR (NEW.postcode <=> OLD.postcode) THEN + + SET NEW.geoFk = client_getGeo(NEW.id); + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/supplier_beforeInsert.sql b/db/routines/vn/triggers/supplier_beforeInsert.sql index b141ec8fb..5bbfc79a1 100644 --- a/db/routines/vn/triggers/supplier_beforeInsert.sql +++ b/db/routines/vn/triggers/supplier_beforeInsert.sql @@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplier_beforeInsert` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + SET NEW.geoFk = supplier_getGeo(NEW.id); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/supplier_beforeUpdate.sql b/db/routines/vn/triggers/supplier_beforeUpdate.sql index af730b49d..10b63ee72 100644 --- a/db/routines/vn/triggers/supplier_beforeUpdate.sql +++ b/db/routines/vn/triggers/supplier_beforeUpdate.sql @@ -40,5 +40,10 @@ BEGIN SET NEW.isPayMethodChecked = FALSE; END IF; + IF NOT (NEW.provinceFk <=> OLD.provinceFk) + OR (NEW.postcode <=> OLD.postcode) THEN + + SET NEW.geoFk = client_getGeo(NEW.id); + END IF; END$$ DELIMITER ; diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index ef5e04a43..b3e25bd7e 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -8,13 +8,13 @@ ALTER TABLE vn.supplier CREATE OR REPLACE TEMPORARY TABLE tSupplierGeo (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT sa.supplierFk id, p.geoFk - FROM supplierAddress sa - JOIN town t ON t.provinceFk = sa.provinceFk + SELECT s.id, p.geoFk + FROM supplier s + JOIN town t ON t.provinceFk = s.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = sa.postalCode - GROUP BY sa.supplierFk - ORDER BY (sa.city SOUNDS LIKE t.`name`) DESC; + AND p.`code` = s.postCode + GROUP BY s.id + ORDER BY (s.city SOUNDS LIKE t.`name`) DESC; UPDATE supplier s JOIN tSupplierGeo tsg ON tsg.id = s.id From bde192966e00803c883aa7a418ae7431ea018775 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 09:30:36 +0100 Subject: [PATCH 50/92] feat: refs #8057 Added data updates --- db/routines/vn/triggers/supplier_beforeUpdate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/supplier_beforeUpdate.sql b/db/routines/vn/triggers/supplier_beforeUpdate.sql index 10b63ee72..55c671185 100644 --- a/db/routines/vn/triggers/supplier_beforeUpdate.sql +++ b/db/routines/vn/triggers/supplier_beforeUpdate.sql @@ -43,7 +43,7 @@ BEGIN IF NOT (NEW.provinceFk <=> OLD.provinceFk) OR (NEW.postcode <=> OLD.postcode) THEN - SET NEW.geoFk = client_getGeo(NEW.id); + SET NEW.geoFk = supplier_getGeo(NEW.id); END IF; END$$ DELIMITER ; From b9397c527ddbaffc660b30005729bba3b6d44a3c Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 09:32:02 +0100 Subject: [PATCH 51/92] feat: refs #8057 Added data updates --- db/routines/vn/triggers/supplier_beforeUpdate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/supplier_beforeUpdate.sql b/db/routines/vn/triggers/supplier_beforeUpdate.sql index 55c671185..b502340a3 100644 --- a/db/routines/vn/triggers/supplier_beforeUpdate.sql +++ b/db/routines/vn/triggers/supplier_beforeUpdate.sql @@ -41,7 +41,7 @@ BEGIN END IF; IF NOT (NEW.provinceFk <=> OLD.provinceFk) - OR (NEW.postcode <=> OLD.postcode) THEN + OR (NEW.postCode <=> OLD.postCode) THEN SET NEW.geoFk = supplier_getGeo(NEW.id); END IF; From 5f50d842133451d5f6453d5f318aa57efa5bb9af Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 09:42:49 +0100 Subject: [PATCH 52/92] feat: refs #7244 Requested changes --- db/versions/11343-silverAsparagus/00-firstScript.sql | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/db/versions/11343-silverAsparagus/00-firstScript.sql b/db/versions/11343-silverAsparagus/00-firstScript.sql index 3ca29e8b4..4e69a532d 100644 --- a/db/versions/11343-silverAsparagus/00-firstScript.sql +++ b/db/versions/11343-silverAsparagus/00-firstScript.sql @@ -1,2 +1,9 @@ -INSERT INTO salix.ACL (model,property,accessType,principalId) - VALUES ('Collection','*','WRITE','productionBoss'); +INSERT INTO salix.ACL (model, property, accessType, principalId) + VALUES ('Collection', 'create', 'WRITE', 'productionBoss'), + ('Collection', 'upsert', 'WRITE', 'productionBoss'), + ('Collection', 'replaceById', 'WRITE', 'productionBoss'), + ('Collection', 'updateAll', 'WRITE', 'productionBoss'), + ('Collection', 'updateAttributes', 'WRITE', 'productionBoss'), + ('Collection', 'deleteById', 'WRITE', 'productionBoss'), + ('Collection', 'destroyAll', 'WRITE', 'productionBoss'), + ('Collection', 'destroyById', 'WRITE', 'productionBoss'); \ No newline at end of file From 8449a6c6d337477b86564d34e7f6cccc93fca630 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 09:42:59 +0100 Subject: [PATCH 53/92] feat: refs #7244 Requested changes --- db/versions/11343-silverAsparagus/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11343-silverAsparagus/00-firstScript.sql b/db/versions/11343-silverAsparagus/00-firstScript.sql index 4e69a532d..bcee42eea 100644 --- a/db/versions/11343-silverAsparagus/00-firstScript.sql +++ b/db/versions/11343-silverAsparagus/00-firstScript.sql @@ -6,4 +6,4 @@ INSERT INTO salix.ACL (model, property, accessType, principalId) ('Collection', 'updateAttributes', 'WRITE', 'productionBoss'), ('Collection', 'deleteById', 'WRITE', 'productionBoss'), ('Collection', 'destroyAll', 'WRITE', 'productionBoss'), - ('Collection', 'destroyById', 'WRITE', 'productionBoss'); \ No newline at end of file + ('Collection', 'destroyById', 'WRITE', 'productionBoss'); From d387486ea861154b88ae30a18a184c02f506209b Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 09:59:01 +0100 Subject: [PATCH 54/92] refactor: refs #7920 Requested changes --- db/routines/vn/procedures/itemShelvingLog_get.sql | 8 ++++---- db/routines/vn/procedures/item_devalueA2.sql | 6 +++--- .../vn/procedures/sale_boxPickingPrint.sql | 6 +++--- db/routines/vn/procedures/shelvingChange.sql | 15 +++++++++------ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingLog_get.sql b/db/routines/vn/procedures/itemShelvingLog_get.sql index de4211e41..5a943e867 100644 --- a/db/routines/vn/procedures/itemShelvingLog_get.sql +++ b/db/routines/vn/procedures/itemShelvingLog_get.sql @@ -1,12 +1,12 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`( - vShelvingFk VARCHAR(10) + vShelvingCode VARCHAR(10) ) BEGIN /** * Devuelve el log de los item en cada carro * - * @param vShelvingFk Matrícula del carro + * @param vShelvingCode Matrícula del carro * */ SELECT isl.itemShelvingFk, @@ -29,8 +29,8 @@ BEGIN JOIN itemShelvingLog isl ON item.id = isl.itemFk JOIN worker ON isl.workerFk = worker.id JOIN shelving sh ON sh.id = isl.shelvingFk - WHERE sh.code = vShelvingFk COLLATE utf8mb3_unicode_ci - OR isl.itemFk = vShelvingFk -- ?? Respeto porque ya estaba + WHERE sh.code = vShelvingCode COLLATE utf8mb3_unicode_ci + OR isl.itemFk = vShelvingCode -- ?? Respeto porque ya estaba ORDER BY isl.created DESC; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql index 282f6e01e..3264165a6 100644 --- a/db/routines/vn/procedures/item_devalueA2.sql +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_devalueA2`( vSelf INT, - vShelvingCode VARCHAR(10), + vShelvingCode VARCHAR(10) COLLATE utf8mb3_general_ci, vBuyingValue DECIMAL(10,4), vQuantity INT ) @@ -112,7 +112,7 @@ BEGIN SELECT ish.id, ish.visible INTO vTargetItemShelvingFk, vCurrentVisible FROM itemShelving ish JOIN shelving sh ON sh.id = ish.shelvingFk - WHERE sh.code = vShelvingCode COLLATE utf8mb3_general_ci + WHERE sh.code = vShelvingCode AND ish.itemFk = vSelf LIMIT 1; @@ -399,7 +399,7 @@ BEGIN FROM itemShelving ish JOIN shelving sh ON sh.id = ish.shelvingFk WHERE ish.itemFK = vSelf - AND sh.code = vShelvingCode COLLATE utf8mb3_general_ci + AND sh.code = vShelvingCode ON DUPLICATE KEY UPDATE visible = vQuantity + VALUES(visible); diff --git a/db/routines/vn/procedures/sale_boxPickingPrint.sql b/db/routines/vn/procedures/sale_boxPickingPrint.sql index aa4a14acd..f156ff8f8 100644 --- a/db/routines/vn/procedures/sale_boxPickingPrint.sql +++ b/db/routines/vn/procedures/sale_boxPickingPrint.sql @@ -27,7 +27,7 @@ BEGIN DECLARE vQuantity INT; DECLARE vRemainder INT DEFAULT 0; DECLARE vRemainderSaleFk INT; - DECLARE vShelving VARCHAR(10); + DECLARE vShelvingFk VARCHAR(10); DECLARE vTicketFk INT; SELECT s.quantity, @@ -262,7 +262,7 @@ w1: WHILE vQuantity >= vPacking DO CALL dipole.expedition_Add(vExpeditionFk,vPrinterFk, TRUE); SELECT shelvingFk, p.code - INTO vShelving, vParkingCode + INTO vShelvingFk, vParkingCode FROM itemShelving ish JOIN shelving sh ON sh.id = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk @@ -273,7 +273,7 @@ w1: WHILE vQuantity >= vPacking DO itemFk = vItemFk, quantity = vPacking, longName = vConcept, - shelvingFk = vShelving, + shelvingFk = vShelvingFk, parkingCode = vParkingCode, phone = RIGHT(phone,vMaxPhoneLength), street = RIGHT(street, vMAxStreetLength) diff --git a/db/routines/vn/procedures/shelvingChange.sql b/db/routines/vn/procedures/shelvingChange.sql index f0756b385..901b1cf95 100644 --- a/db/routines/vn/procedures/shelvingChange.sql +++ b/db/routines/vn/procedures/shelvingChange.sql @@ -1,10 +1,13 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingChange`( + `vShelvingO` VARCHAR(10), + `vShelvingD` VARCHAR(10) +) BEGIN - UPDATE itemShelving ish - JOIN shelving sh1 ON sh1.code = vShelvingD COLLATE utf8_unicode_ci - JOIN shelving sh2 ON sh2.code = vShelvingO COLLATE utf8_unicode_ci - SET ish.shelvingFk = sh1.id - WHERE ish.shelvingFk = sh2.id; + UPDATE itemShelving ish + JOIN shelving sh1 ON sh1.code = vShelvingD COLLATE utf8_unicode_ci + JOIN shelving sh2 ON sh2.code = vShelvingO COLLATE utf8_unicode_ci + SET ish.shelvingFk = sh1.id + WHERE ish.shelvingFk = sh2.id; END$$ DELIMITER ; From 534b50f51a65ccea3d282aee57041c9c3641c6ac Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 10:45:28 +0100 Subject: [PATCH 55/92] feat: refs #8151 Requested changes --- .../expedition/specs/moveExpeditions.spec.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js index 2f0fd673c..9c91df5d6 100644 --- a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('ticket moveExpeditions()', () => { +fdescribe('ticket moveExpeditions()', () => { const ctx = beforeAll.getCtx(); it('should move the selected expeditions to new ticket', async() => { @@ -17,14 +17,13 @@ describe('ticket moveExpeditions()', () => { agencyModeId: 1, routeId: null, expeditionIds: [1, 2] - }; - + const newestTicketIdInFixtures = await models.Ticket.findOne({ + order: 'id DESC' + }, options); const ticket = await models.Expedition.moveExpeditions(ctx, options); - const newestTicketIdInFixtures = 27; - - expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures); + expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures.id); await tx.rollback(); } catch (e) { @@ -49,11 +48,12 @@ describe('ticket moveExpeditions()', () => { expeditionIds: [1, 2] }; + const newestTicketIdInFixtures = await models.Ticket.findOne({ + order: 'id DESC' + }, options); const ticket = await models.Expedition.moveExpeditions(myCtx, options); - const newestTicketIdInFixtures = 27; - - expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures); + expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures.id); const updatedTicket = await models.Ticket.findById(ticket.id, null, options); const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options); From b3dcaf4cf549fc9cdbf0f99ca1611c49e816ccd7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Nov 2024 10:53:13 +0100 Subject: [PATCH 56/92] feat: refs #8151 Requested changes --- .../back/methods/expedition/specs/moveExpeditions.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js index 9c91df5d6..0edae9c6a 100644 --- a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('ticket moveExpeditions()', () => { +describe('ticket moveExpeditions()', () => { const ctx = beforeAll.getCtx(); it('should move the selected expeditions to new ticket', async() => { From c8ab5d434496dc14d53210546fd96e11d20f8796 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 11:16:45 +0100 Subject: [PATCH 57/92] fix: refs #6818 add defaultChannel --- back/models/say-simple-config.json | 3 +++ db/dump/fixtures.before.sql | 9 +++++---- db/versions/11347-redErica/00-firstScript.sql | 7 +++++++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 db/versions/11347-redErica/00-firstScript.sql diff --git a/back/models/say-simple-config.json b/back/models/say-simple-config.json index edc4caa43..d5d4f8a6f 100644 --- a/back/models/say-simple-config.json +++ b/back/models/say-simple-config.json @@ -13,6 +13,9 @@ }, "url": { "type": "string" + }, + "defaultChannel": { + "type": "number" } }, "acls": [ diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 68d8be097..2af9e3c23 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4024,8 +4024,9 @@ 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), - (NULL, 1320); + (8, 1183); -INSERT IGNORE INTO vn.saySimpleConfig (url) - VALUES ('saysimle-url-mock'); \ No newline at end of file +ALTER TABLE vn.saySimpleConfig ADD COLUMN defaultChannel TINYINT(4); + +INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) + VALUES ('saysimle-url-mock', 1320); \ No newline at end of file diff --git a/db/versions/11347-redErica/00-firstScript.sql b/db/versions/11347-redErica/00-firstScript.sql new file mode 100644 index 000000000..dcd4c9248 --- /dev/null +++ b/db/versions/11347-redErica/00-firstScript.sql @@ -0,0 +1,7 @@ +DROP TABLE IF EXISTS vn.saySimpleConfig; + +CREATE TABLE vn.saySimpleConfig( + id INT AUTO_INCREMENT PRIMARY KEY, + url VARCHAR(255) NOT NULL, + defaultChannel INT(4) +); \ No newline at end of file From a37332f7be6c7d2ab4b8aecfa61b7c91c14ff536 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 11:18:38 +0100 Subject: [PATCH 58/92] fix: refs #6818 add defaultChannel --- db/dump/fixtures.before.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 2af9e3c23..eafd8c721 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4026,7 +4026,5 @@ INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, 1169), (8, 1183); -ALTER TABLE vn.saySimpleConfig ADD COLUMN defaultChannel TINYINT(4); - INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) VALUES ('saysimle-url-mock', 1320); \ No newline at end of file From c4375b2505efee560cd0c710dc130368118a7422 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 15:29:18 +0100 Subject: [PATCH 59/92] feat: refs #7641 fine tunning --- print/templates/reports/entry-order/entry-order.html | 7 ++++++- print/templates/reports/entry-order/sql/buys.sql | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index cbdfa631f..a4e153fa9 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -67,9 +67,14 @@
Color→ Lavanda
Altura→ 100cm
+
{{buy.tag5}}→ {{buy.value5}}
+
{{buy.tag6}}→ {{buy.value6}}
- label→ valor +
Color→ Lavanda
+
Altura→ 100cm
+
{{buy.tag7}}→ {{buy.value7}}
+
{{buy.tag8}}→ {{buy.value8}}
diff --git a/print/templates/reports/entry-order/sql/buys.sql b/print/templates/reports/entry-order/sql/buys.sql index 92c055483..545849908 100644 --- a/print/templates/reports/entry-order/sql/buys.sql +++ b/print/templates/reports/entry-order/sql/buys.sql @@ -10,7 +10,9 @@ SELECT b.itemFk, i.tag6, i.value6, i.tag7, - i.value7 + i.value7, + i.tag8, + i.value8 FROM buy b JOIN item i ON i.id = b.itemFk LEFT JOIN item i2 ON i2.id = b.itemOriginalFk From ab2e88806e70f748e23800662b3cb40a3bdd8a5c Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 15:29:54 +0100 Subject: [PATCH 60/92] fix: refs #7641 drop boilerplate code --- print/templates/reports/entry-order/entry-order.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index a4e153fa9..90a95481f 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -65,14 +65,10 @@
{{$t('reference')}}{{$t('code')}} {{$t('boxes')}} {{$t('packing')}}{{$t('concept')}}{{$t('tags')}}{{$t('concept')}}{{$t('reference')}}{{$t('tags')}} {{$t('quantity')}} {{$t('price')}}
{{buy.comment}}{{buy.itemFk}} {{buy.stickers}} x {{buy.packing}}{{buy.name}} - {{buy.tag5}} → {{buy.value5}} - {{buy.tag6}} → {{buy.value6}} - {{buy.tag7}} → {{buy.value7}} + {{buy.name}}referencia de prueba +
+
Color→ Lavanda
+
Altura→ 100cm
+
+
+ label→ valor +
{{buy.quantity | number($i18n.locale)}} x {{getTotalBy('quantity') | number($i18n.locale)}} {{buy.quantity | number($i18n.locale)}}referencia de prueba
-
Color→ Lavanda
-
Altura→ 100cm
{{buy.tag5}}→ {{buy.value5}}
{{buy.tag6}}→ {{buy.value6}}
-
Color→ Lavanda
-
Altura→ 100cm
{{buy.tag7}}→ {{buy.value7}}
{{buy.tag8}}→ {{buy.value8}}
From eff251fbb5d002e446ef0093f87aa8d7be3459d7 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 15:46:51 +0100 Subject: [PATCH 61/92] feat: refs #7874 add default type --- db/versions/11348-bronzeCamellia/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11348-bronzeCamellia/00-firstScript.sql diff --git a/db/versions/11348-bronzeCamellia/00-firstScript.sql b/db/versions/11348-bronzeCamellia/00-firstScript.sql new file mode 100644 index 000000000..fa466f1a4 --- /dev/null +++ b/db/versions/11348-bronzeCamellia/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.clientObservation MODIFY COLUMN observationTypeFk tinyint(3) unsigned DEFAULT 4 NOT NULL; +UPDATE vn.clientObservation SET observationTypeFk=4 WHERE observationTypeFk=0; From 9ac54f463a9a714e092f2da8006905f5c580e2cc Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 14 Nov 2024 15:48:11 +0100 Subject: [PATCH 62/92] fix: refs #7457 add with on select to reduce --- modules/order/back/methods/order/filter.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index eff2eecb6..307843d46 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -23,7 +23,6 @@ module.exports = Self => { arg: 'from', type: 'date', description: 'The from date', - required: true }, { arg: 'to', type: 'date', @@ -153,7 +152,12 @@ module.exports = Self => { CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) ENGINE = MEMORY - SELECT o.id, + WITH wOrderTicket AS( + SELECT orderFk, + ticketFk + FROM orderTicket + GROUP BY orderFk + )SELECT o.id, o.total, o.date_send landed, o.date_make created, From 4766d25ddaddf7a551e4a9b5af88cc775f758e0c Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 15:54:53 +0100 Subject: [PATCH 63/92] feat: refs #7874 use name --- modules/client/back/models/client-observation.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/back/models/client-observation.json b/modules/client/back/models/client-observation.json index 86351862d..1d906420a 100644 --- a/modules/client/back/models/client-observation.json +++ b/modules/client/back/models/client-observation.json @@ -55,7 +55,7 @@ "relation": "user", "scope": { "fields": [ - "nickname" + "name" ] } } From f96b9146494749f4e44ad6a3ce9d1844ecefdded Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 16:39:26 +0100 Subject: [PATCH 64/92] fix: refs #6818 use right col type --- db/dump/fixtures.before.sql | 4 ++-- db/versions/11347-redErica/00-firstScript.sql | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index eafd8c721..c99f523b5 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4023,8 +4023,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); + VALUES (19, `1169`), + (8, `1183`); INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) VALUES ('saysimle-url-mock', 1320); \ No newline at end of file diff --git a/db/versions/11347-redErica/00-firstScript.sql b/db/versions/11347-redErica/00-firstScript.sql index dcd4c9248..5da1d6096 100644 --- a/db/versions/11347-redErica/00-firstScript.sql +++ b/db/versions/11347-redErica/00-firstScript.sql @@ -3,5 +3,7 @@ DROP TABLE IF EXISTS vn.saySimpleConfig; CREATE TABLE vn.saySimpleConfig( id INT AUTO_INCREMENT PRIMARY KEY, url VARCHAR(255) NOT NULL, - defaultChannel INT(4) -); \ No newline at end of file + defaultChannel VARCHAR(128) +); + +ALTER TABLE vn.saySimpleCountry MODIFY COLUMN channel VARCHAR(128); \ No newline at end of file From 4b659c0b4822ac9db5ff0ac9652da72b57976c7f Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 16:39:35 +0100 Subject: [PATCH 65/92] fix: refs #6818 use right col type --- db/dump/fixtures.before.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index c99f523b5..cc258e2e3 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4023,8 +4023,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`); + VALUES (19, '1169'), + (8, '1183'); INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) VALUES ('saysimle-url-mock', 1320); \ No newline at end of file From e344ae3bf2d1c109cf327477a6e7c12a2ec1bc6a Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Nov 2024 07:48:17 +0100 Subject: [PATCH 66/92] refactor: refs #7920 Fix version --- db/versions/11342-crimsonDendro/00-itemShelving.sql | 6 +++--- db/versions/11342-crimsonDendro/01-itemShelvingLog.sql | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/db/versions/11342-crimsonDendro/00-itemShelving.sql b/db/versions/11342-crimsonDendro/00-itemShelving.sql index 7a173e203..90739c08a 100644 --- a/db/versions/11342-crimsonDendro/00-itemShelving.sql +++ b/db/versions/11342-crimsonDendro/00-itemShelving.sql @@ -2,13 +2,13 @@ CREATE OR REPLACE TEMPORARY TABLE tItemShelving (PRIMARY KEY (id)) ENGINE = MEMORY SELECT ish.id, s.id shelvingFk - FROM shelving s - JOIN itemShelving ish ON ish.shelvingFk = s.code COLLATE utf8mb3_unicode_ci; + FROM vn.shelving s + JOIN vn.itemShelving ish ON ish.shelvingFk = s.code COLLATE utf8mb3_unicode_ci; ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2, MODIFY COLUMN shelvingFk int(11) NOT NULL; -UPDATE itemShelving ish +UPDATE vn.itemShelving ish JOIN tItemShelving tish ON tish.id = ish.id SET ish.shelvingFk = tish.shelvingFk; diff --git a/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql index 05f04b5ff..4289e4bca 100644 --- a/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql +++ b/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql @@ -2,12 +2,12 @@ CREATE OR REPLACE TEMPORARY TABLE tItemShelvingLog (PRIMARY KEY (id)) ENGINE = MEMORY SELECT ishl.id, s.id shelvingFk - FROM shelving s - JOIN itemShelvingLog ishl ON ishl.shelvingFk = s.code COLLATE utf8mb3_unicode_ci; + FROM vn.shelving s + JOIN vn.itemShelvingLog ishl ON ishl.shelvingFk = s.code COLLATE utf8mb3_unicode_ci; ALTER TABLE vn.itemShelvingLog MODIFY COLUMN shelvingFk int(11) NOT NULL; -UPDATE itemShelvingLog ishl +UPDATE vn.itemShelvingLog ishl JOIN tItemShelvingLog tishl ON tishl.id = ishl.id SET ishl.shelvingFk = tishl.shelvingFk; From e49285ace8eadae94c6601e7f2d015e9731e754e Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Nov 2024 07:51:37 +0100 Subject: [PATCH 67/92] refactor: refs #7920 Fix version --- db/versions/11342-crimsonDendro/00-itemShelving.sql | 4 ++-- db/versions/11342-crimsonDendro/01-itemShelvingLog.sql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/versions/11342-crimsonDendro/00-itemShelving.sql b/db/versions/11342-crimsonDendro/00-itemShelving.sql index 90739c08a..706affb2f 100644 --- a/db/versions/11342-crimsonDendro/00-itemShelving.sql +++ b/db/versions/11342-crimsonDendro/00-itemShelving.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE TEMPORARY TABLE tItemShelving +CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelving (PRIMARY KEY (id)) ENGINE = MEMORY SELECT ish.id, s.id shelvingFk @@ -12,7 +12,7 @@ UPDATE vn.itemShelving ish JOIN tItemShelving tish ON tish.id = ish.id SET ish.shelvingFk = tish.shelvingFk; -DROP TEMPORARY TABLE tItemShelving; +DROP TEMPORARY TABLE tmp.tItemShelving; ALTER TABLE vn.itemShelving ADD CONSTRAINT itemShelving_shelving_FK FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(id) diff --git a/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql index 4289e4bca..f9ae025a6 100644 --- a/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql +++ b/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE TEMPORARY TABLE tItemShelvingLog +CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelvingLog (PRIMARY KEY (id)) ENGINE = MEMORY SELECT ishl.id, s.id shelvingFk @@ -11,4 +11,4 @@ UPDATE vn.itemShelvingLog ishl JOIN tItemShelvingLog tishl ON tishl.id = ishl.id SET ishl.shelvingFk = tishl.shelvingFk; -DROP TEMPORARY TABLE tItemShelvingLog; +DROP TEMPORARY TABLE tmp.tItemShelvingLog; From b5463e5560ad91c3a20acb52895cc1d830cf6ecf Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Nov 2024 07:54:33 +0100 Subject: [PATCH 68/92] refactor: refs #7920 Fix version --- db/versions/11342-crimsonDendro/00-itemShelving.sql | 2 +- db/versions/11342-crimsonDendro/01-itemShelvingLog.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11342-crimsonDendro/00-itemShelving.sql b/db/versions/11342-crimsonDendro/00-itemShelving.sql index 706affb2f..a7b137ca5 100644 --- a/db/versions/11342-crimsonDendro/00-itemShelving.sql +++ b/db/versions/11342-crimsonDendro/00-itemShelving.sql @@ -9,7 +9,7 @@ ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2, MODIFY COLUMN shelvingFk int(11) NOT NULL; UPDATE vn.itemShelving ish - JOIN tItemShelving tish ON tish.id = ish.id + JOIN tmp.tItemShelving tish ON tish.id = ish.id SET ish.shelvingFk = tish.shelvingFk; DROP TEMPORARY TABLE tmp.tItemShelving; diff --git a/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql index f9ae025a6..bcf217cfc 100644 --- a/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql +++ b/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql @@ -8,7 +8,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelvingLog ALTER TABLE vn.itemShelvingLog MODIFY COLUMN shelvingFk int(11) NOT NULL; UPDATE vn.itemShelvingLog ishl - JOIN tItemShelvingLog tishl ON tishl.id = ishl.id + JOIN tmp.tItemShelvingLog tishl ON tishl.id = ishl.id SET ishl.shelvingFk = tishl.shelvingFk; DROP TEMPORARY TABLE tmp.tItemShelvingLog; From 7a4455d6d01d2fe4a3157f94889e4b928edc807c Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 15 Nov 2024 08:12:16 +0100 Subject: [PATCH 69/92] feat: refs #6869 refs#6869 itemShelving_get --- .../vn/procedures/itemShelving_get.sql | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 db/routines/vn/procedures/itemShelving_get.sql diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql new file mode 100644 index 000000000..07384b721 --- /dev/null +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -0,0 +1,30 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8)) +BEGIN +/** +* Lista artículos de itemshelving +* +* @param vSelf matrícula del carro +**/ + SELECT ish.itemFk item, + i.name, + i.longName, + i.size, + ish.visible, + ish.packing, + ish.grouping, + p.code, + ish.id, + s.priority, + ish.isChecked, + ic.url, + ish.available, + ish.buyFk + FROM itemShelving ish + JOIN item i ON i.id = ish.itemFk + JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci + LEFT JOIN parking p ON s.parkingFk = p.id + JOIN hedera.imageConfig ic + WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf; +END$$ +DELIMITER ; From e1a091535e454838f5a2409860c4d8172d7c9699 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Nov 2024 08:45:28 +0100 Subject: [PATCH 70/92] refactor: refs #7920 Fix version --- .../11342-crimsonDendro/00-itemShelving.sql | 18 ++---------------- .../11342-crimsonDendro/01-itemShelving.sql | 2 ++ .../11342-crimsonDendro/01-itemShelvingLog.sql | 14 -------------- .../11342-crimsonDendro/02-itemShelving.sql | 3 +++ .../11342-crimsonDendro/03-itemShelving.sql | 4 ++++ .../11342-crimsonDendro/04-itemShelvingLog.sql | 6 ++++++ .../11342-crimsonDendro/05-itemShelvingLog.sql | 1 + .../11342-crimsonDendro/06-itemShelvingLog.sql | 5 +++++ 8 files changed, 23 insertions(+), 30 deletions(-) create mode 100644 db/versions/11342-crimsonDendro/01-itemShelving.sql delete mode 100644 db/versions/11342-crimsonDendro/01-itemShelvingLog.sql create mode 100644 db/versions/11342-crimsonDendro/02-itemShelving.sql create mode 100644 db/versions/11342-crimsonDendro/03-itemShelving.sql create mode 100644 db/versions/11342-crimsonDendro/04-itemShelvingLog.sql create mode 100644 db/versions/11342-crimsonDendro/05-itemShelvingLog.sql create mode 100644 db/versions/11342-crimsonDendro/06-itemShelvingLog.sql diff --git a/db/versions/11342-crimsonDendro/00-itemShelving.sql b/db/versions/11342-crimsonDendro/00-itemShelving.sql index a7b137ca5..4d083bf97 100644 --- a/db/versions/11342-crimsonDendro/00-itemShelving.sql +++ b/db/versions/11342-crimsonDendro/00-itemShelving.sql @@ -2,19 +2,5 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelving (PRIMARY KEY (id)) ENGINE = MEMORY SELECT ish.id, s.id shelvingFk - FROM vn.shelving s - JOIN vn.itemShelving ish ON ish.shelvingFk = s.code COLLATE utf8mb3_unicode_ci; - -ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2, - MODIFY COLUMN shelvingFk int(11) NOT NULL; - -UPDATE vn.itemShelving ish - JOIN tmp.tItemShelving tish ON tish.id = ish.id - SET ish.shelvingFk = tish.shelvingFk; - -DROP TEMPORARY TABLE tmp.tItemShelving; - -ALTER TABLE vn.itemShelving - ADD CONSTRAINT itemShelving_shelving_FK FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(id) - ON DELETE RESTRICT - ON UPDATE CASCADE; + FROM vn.itemShelving ish + JOIN vn.shelving s ON s.code = ish.shelvingFk COLLATE utf8mb3_unicode_ci; diff --git a/db/versions/11342-crimsonDendro/01-itemShelving.sql b/db/versions/11342-crimsonDendro/01-itemShelving.sql new file mode 100644 index 000000000..23099ac6b --- /dev/null +++ b/db/versions/11342-crimsonDendro/01-itemShelving.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2, + MODIFY COLUMN shelvingFk int(11) NOT NULL; diff --git a/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql deleted file mode 100644 index bcf217cfc..000000000 --- a/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelvingLog - (PRIMARY KEY (id)) - ENGINE = MEMORY - SELECT ishl.id, s.id shelvingFk - FROM vn.shelving s - JOIN vn.itemShelvingLog ishl ON ishl.shelvingFk = s.code COLLATE utf8mb3_unicode_ci; - -ALTER TABLE vn.itemShelvingLog MODIFY COLUMN shelvingFk int(11) NOT NULL; - -UPDATE vn.itemShelvingLog ishl - JOIN tmp.tItemShelvingLog tishl ON tishl.id = ishl.id - SET ishl.shelvingFk = tishl.shelvingFk; - -DROP TEMPORARY TABLE tmp.tItemShelvingLog; diff --git a/db/versions/11342-crimsonDendro/02-itemShelving.sql b/db/versions/11342-crimsonDendro/02-itemShelving.sql new file mode 100644 index 000000000..9d0e65d0b --- /dev/null +++ b/db/versions/11342-crimsonDendro/02-itemShelving.sql @@ -0,0 +1,3 @@ +UPDATE vn.itemShelving ish + JOIN tmp.tItemShelving tish ON tish.id = ish.id + SET ish.shelvingFk = tish.shelvingFk; \ No newline at end of file diff --git a/db/versions/11342-crimsonDendro/03-itemShelving.sql b/db/versions/11342-crimsonDendro/03-itemShelving.sql new file mode 100644 index 000000000..cb9825bfc --- /dev/null +++ b/db/versions/11342-crimsonDendro/03-itemShelving.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.itemShelving + ADD CONSTRAINT itemShelving_shelving_FK FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(id) + ON DELETE RESTRICT + ON UPDATE CASCADE; diff --git a/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql new file mode 100644 index 000000000..fbf997825 --- /dev/null +++ b/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelvingLog + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT ishl.id, s.id shelvingFk + FROM vn.itemShelvingLog ishl + JOIN vn.shelving s ON s.code = ishl.shelvingFk COLLATE utf8mb3_unicode_ci; diff --git a/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql new file mode 100644 index 000000000..88daedc36 --- /dev/null +++ b/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql @@ -0,0 +1 @@ +ALTER TABLE vn.itemShelvingLog MODIFY COLUMN shelvingFk int(11) NOT NULL; diff --git a/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql new file mode 100644 index 000000000..3ebe32d7f --- /dev/null +++ b/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql @@ -0,0 +1,5 @@ +UPDATE vn.itemShelvingLog ishl + JOIN tmp.tItemShelvingLog tishl ON tishl.id = ishl.id + SET ishl.shelvingFk = tishl.shelvingFk; + +DROP TEMPORARY TABLE tmp.tItemShelvingLog; From 07318656b78ebde742ad48a9b36bff327a7755d8 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 15 Nov 2024 08:47:30 +0100 Subject: [PATCH 71/92] feat: refs #8135 refs#8135 updateTicketACL --- db/versions/11349-azureBamboo/00-firstScript.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/versions/11349-azureBamboo/00-firstScript.sql diff --git a/db/versions/11349-azureBamboo/00-firstScript.sql b/db/versions/11349-azureBamboo/00-firstScript.sql new file mode 100644 index 000000000..09c919b79 --- /dev/null +++ b/db/versions/11349-azureBamboo/00-firstScript.sql @@ -0,0 +1,7 @@ + + +UPDATE salix.ACL + SET principalId = 'deliveryAssistant' +WHERE model = 'Ticket' + AND property = 'updateAttributes' + AND principalId = "delivery"; From c5f1b05671c6fefaa22df376af105589dd60b402 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 15 Nov 2024 11:32:20 +0100 Subject: [PATCH 72/92] feat: refs #8127 quitar esquemas --- db/routines/vn/functions/entry_getCommission.sql | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql index 898ac8521..a4afdabd4 100644 --- a/db/routines/vn/functions/entry_getCommission.sql +++ b/db/routines/vn/functions/entry_getCommission.sql @@ -25,18 +25,17 @@ BEGIN LIMIT 1; RETURN IFNULL(vCommission, 0); - ELSE SELECT e.id INTO vLastEntryFk - FROM vn.entry e - JOIN vn.travel tr ON tr.id = e.travelFk + FROM `entry` e + JOIN travel tr ON tr.id = e.travelFk WHERE e.supplierFk = vSupplierFk ORDER BY tr.landed DESC LIMIT 1; IF vLastEntryFk THEN SELECT commission INTO vCurrentCommission - FROM vn.entry + FROM `entry` WHERE id = vLastEntryFk; ELSE @@ -47,8 +46,6 @@ BEGIN END IF; RETURN vCurrentCommission; - END IF; - END$$ DELIMITER ; From a3945070f2faf7fc83a8a7d5f099d0113fdf3965 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Nov 2024 11:34:18 +0100 Subject: [PATCH 73/92] refactor: refs #7920 No changes in itemShelvingLog table --- db/versions/11342-crimsonDendro/04-itemShelvingLog.sql | 2 ++ db/versions/11342-crimsonDendro/05-itemShelvingLog.sql | 2 +- db/versions/11342-crimsonDendro/06-itemShelvingLog.sql | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql index fbf997825..1135b9d09 100644 --- a/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql +++ b/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql @@ -1,6 +1,8 @@ +/* CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelvingLog (PRIMARY KEY (id)) ENGINE = MEMORY SELECT ishl.id, s.id shelvingFk FROM vn.itemShelvingLog ishl JOIN vn.shelving s ON s.code = ishl.shelvingFk COLLATE utf8mb3_unicode_ci; +*/ diff --git a/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql index 88daedc36..b0e3b55cc 100644 --- a/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql +++ b/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql @@ -1 +1 @@ -ALTER TABLE vn.itemShelvingLog MODIFY COLUMN shelvingFk int(11) NOT NULL; +-- ALTER TABLE vn.itemShelvingLog MODIFY COLUMN shelvingFk int(11) NOT NULL; diff --git a/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql index 3ebe32d7f..f97f61e42 100644 --- a/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql +++ b/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql @@ -1,5 +1,7 @@ +/* UPDATE vn.itemShelvingLog ishl JOIN tmp.tItemShelvingLog tishl ON tishl.id = ishl.id SET ishl.shelvingFk = tishl.shelvingFk; DROP TEMPORARY TABLE tmp.tItemShelvingLog; +*/ \ No newline at end of file From b529ccfe2919102c548e3401ee45f94073164600 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Nov 2024 12:43:15 +0100 Subject: [PATCH 74/92] feat: refs #7920 Added ItemShelving in shelvingLog --- db/versions/11350-silverArborvitae/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11350-silverArborvitae/00-firstScript.sql diff --git a/db/versions/11350-silverArborvitae/00-firstScript.sql b/db/versions/11350-silverArborvitae/00-firstScript.sql new file mode 100644 index 000000000..b5e87133e --- /dev/null +++ b/db/versions/11350-silverArborvitae/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.shelvingLog + MODIFY COLUMN changedModel enum('Shelving', 'ItemShelving') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'Shelving' NOT NULL; From 6ed521ae5ea9913f258240cbff344d0d70599711 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 15 Nov 2024 13:10:19 +0100 Subject: [PATCH 75/92] fix: redirect to invoice-out summary from salix' descriptor --- modules/invoiceOut/front/index.js | 2 +- modules/invoiceOut/front/routes.json | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/invoiceOut/front/index.js b/modules/invoiceOut/front/index.js index a5e51d439..6d58a0a45 100644 --- a/modules/invoiceOut/front/index.js +++ b/modules/invoiceOut/front/index.js @@ -1,7 +1,7 @@ export * from './module'; import './main'; -import './summary'; import './descriptor'; import './descriptor-popover'; import './descriptor-menu'; +import './summary'; diff --git a/modules/invoiceOut/front/routes.json b/modules/invoiceOut/front/routes.json index 7c7495cb9..eba34dbbb 100644 --- a/modules/invoiceOut/front/routes.json +++ b/modules/invoiceOut/front/routes.json @@ -34,6 +34,21 @@ "params": { "invoice-out": "$ctrl.invoiceOut" } + }, + { + "url": "/:id", + "state": "invoiceOut.card", + "abstract": true, + "component": "vn-invoice-out-card" + }, + { + "url": "/negative-bases", + "state": "invoiceOut.negative-bases", + "component": "vn-negative-bases", + "description": "Negative bases", + "acl": [ + "administrative" + ] } ] } From 4783cc23ac43ff999a1875368d8f3afcfce9125f Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 15 Nov 2024 14:22:19 +0100 Subject: [PATCH 76/92] refactor: deleted negative bases route due to not being used --- modules/invoiceOut/front/routes.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/modules/invoiceOut/front/routes.json b/modules/invoiceOut/front/routes.json index eba34dbbb..908df3972 100644 --- a/modules/invoiceOut/front/routes.json +++ b/modules/invoiceOut/front/routes.json @@ -40,15 +40,6 @@ "state": "invoiceOut.card", "abstract": true, "component": "vn-invoice-out-card" - }, - { - "url": "/negative-bases", - "state": "invoiceOut.negative-bases", - "component": "vn-negative-bases", - "description": "Negative bases", - "acl": [ - "administrative" - ] } ] } From 6c00efae895790e83d0541bf6212215c3c0b3e30 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sun, 17 Nov 2024 17:57:54 +0100 Subject: [PATCH 77/92] feat: refs #7289 #7289 apply option 1 --- loopback/locale/en.json | 4 +++- loopback/locale/es.json | 6 ++++-- modules/ticket/back/methods/ticket/transferSales.js | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 95f6ff326..86ebebc89 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -244,5 +244,7 @@ "Invalid or expired verification code": "Invalid or expired verification code", "There are tickets for this area, delete them first": "There are tickets for this area, delete them first", "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}", - "Payment method is required": "Payment method is required" + "Payment method is required": "Payment method is required", + "Sales already moved": "Sales already moved" + } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 37976c0ea..a68fcc4e4 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -387,5 +387,7 @@ "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero", "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén", "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" -} \ No newline at end of file + "The web user's email already exists": "El correo del usuario web ya existe", + "Sales already moved": "Ya han sido transferidas", + "Línea ya ha sido transferida": "Línea ya ha sido transferida" +} diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 5f5fdde67..bc3c467d7 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -80,6 +80,9 @@ module.exports = Self => { const hasClaimedSales = await models.ClaimBeginning.findOne({where: {saleFk: {inq: saleIds}}}); if (ticketId != id && hasClaimedSales) throw new UserError(`Can't transfer claimed sales`); + const missingSales = sales.some(({id}) => !map.has(id)); + if (missingSales) + throw new UserError($t('Sales already moved')); for (const sale of sales) { const originalSale = map.get(sale.id); From 353ca659cd98d133632c5a0e90ef332d9d1438b7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 08:58:38 +0100 Subject: [PATCH 78/92] feat: refs #8057 Requested changes --- db/routines/vn/functions/address_getGeo.sql | 5 +++-- db/routines/vn/functions/client_getGeo.sql | 4 ++-- db/routines/vn/functions/supplier_getGeo.sql | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/functions/address_getGeo.sql b/db/routines/vn/functions/address_getGeo.sql index 04155c30c..248e8c787 100644 --- a/db/routines/vn/functions/address_getGeo.sql +++ b/db/routines/vn/functions/address_getGeo.sql @@ -14,9 +14,10 @@ BEGIN SELECT p.geoFk INTO vGeoFk FROM address a JOIN town t ON t.provinceFk = a.provinceFk - JOIN postCode p ON p.townFk = t.id AND p.`code` = a.postalCode + JOIN postCode p ON p.townFk = t.id WHERE a.id = vSelf - ORDER BY (a.city SOUNDS LIKE t.`name`) DESC + ORDER BY (a.city SOUNDS LIKE t.name) DESC, + (p.code = a.postalCode) DESC LIMIT 1; RETURN vGeoFk; diff --git a/db/routines/vn/functions/client_getGeo.sql b/db/routines/vn/functions/client_getGeo.sql index 067eb84bc..624becf1e 100644 --- a/db/routines/vn/functions/client_getGeo.sql +++ b/db/routines/vn/functions/client_getGeo.sql @@ -15,9 +15,9 @@ BEGIN FROM client c JOIN town t ON t.provinceFk = c.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = c.postcode WHERE c.id = vSelf - ORDER BY (c.city SOUNDS LIKE t.`name`) DESC + ORDER BY (c.city SOUNDS LIKE t.name) DESC, + (p.code = c.postcode) DESC LIMIT 1; RETURN vGeoFk; diff --git a/db/routines/vn/functions/supplier_getGeo.sql b/db/routines/vn/functions/supplier_getGeo.sql index 93115d712..29b6736f3 100644 --- a/db/routines/vn/functions/supplier_getGeo.sql +++ b/db/routines/vn/functions/supplier_getGeo.sql @@ -15,9 +15,11 @@ BEGIN FROM supplier s JOIN town t ON t.provinceFk = s.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = s.postCode + LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id WHERE s.id = vSelf - ORDER BY (s.city SOUNDS LIKE t.`name`) DESC + ORDER BY (s.city SOUNDS LIKE t.name) DESC, + (p.code = s.postCode) DESC, + (p.code = sad.postalCode) DESC LIMIT 1; RETURN vGeoFk; From 9558d030ff8baa3b1d2a81af61f5b5e692fc4199 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 18 Nov 2024 10:10:30 +0100 Subject: [PATCH 79/92] feat: refs #7289 #7289 remove bad translation --- loopback/locale/es.json | 3 +-- modules/ticket/back/methods/ticket/transferSales.js | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index a68fcc4e4..8bf9f31c4 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,6 +388,5 @@ "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén", "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", - "Línea ya ha sido transferida": "Línea ya ha sido transferida" + "Sales already moved": "Ya han sido transferidas" } diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index bc3c467d7..580a8e1f7 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -80,6 +80,7 @@ module.exports = Self => { const hasClaimedSales = await models.ClaimBeginning.findOne({where: {saleFk: {inq: saleIds}}}); if (ticketId != id && hasClaimedSales) throw new UserError(`Can't transfer claimed sales`); + const missingSales = sales.some(({id}) => !map.has(id)); if (missingSales) throw new UserError($t('Sales already moved')); From dd637b9333ea75f966f8efb8e1823bae39de960a Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 18 Nov 2024 10:34:23 +0100 Subject: [PATCH 80/92] fix: refs #6869 use id as primaryKey --- modules/shelving/back/models/shelving.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json index f6df57d43..84e260b9e 100644 --- a/modules/shelving/back/models/shelving.json +++ b/modules/shelving/back/models/shelving.json @@ -48,8 +48,7 @@ "itemShelving": { "type": "hasMany", "model": "ItemShelving", - "foreignKey": "shelvingFk", - "primaryKey": "code" + "foreignKey": "shelvingFk" } } } \ No newline at end of file From a64f9b74ec9d6d69231d62caa7dfbfa642890764 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 10:52:41 +0100 Subject: [PATCH 81/92] feat: refs #8057 Requested changes --- db/versions/11346-yellowPhormium/00-address.sql | 4 ++-- db/versions/11346-yellowPhormium/01-client.sql | 4 ++-- db/versions/11346-yellowPhormium/02-supplier.sql | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index 8e1315072..a8ee88b94 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -10,9 +10,9 @@ CREATE OR REPLACE TEMPORARY TABLE tAddressGeo FROM address a JOIN town t ON t.provinceFk = a.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = a.postalCode GROUP BY a.id - ORDER BY (a.city SOUNDS LIKE t.`name`) DESC; + ORDER BY (a.city SOUNDS LIKE t.`name`) DESC, + (p.code = a.postalCode) DESC; UPDATE address a JOIN tAddressGeo tag ON tag.id = a.id diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index 932b28ef5..e1294c30e 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -13,9 +13,9 @@ CREATE OR REPLACE TEMPORARY TABLE tClientGeo FROM client c JOIN town t ON t.provinceFk = c.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = c.postcode GROUP BY c.id - ORDER BY (c.city SOUNDS LIKE t.`name`) DESC; + ORDER BY (c.city SOUNDS LIKE t.`name`) DESC, + (p.code = c.postcode) DESC; UPDATE client c JOIN tClientGeo tcg ON tcg.id = c.id diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index b3e25bd7e..57cdefaea 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -12,9 +12,11 @@ CREATE OR REPLACE TEMPORARY TABLE tSupplierGeo FROM supplier s JOIN town t ON t.provinceFk = s.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = s.postCode + LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id GROUP BY s.id - ORDER BY (s.city SOUNDS LIKE t.`name`) DESC; + ORDER BY (s.city SOUNDS LIKE t.`name`) DESC, + (p.code = s.postCode) DESC, + (p.code = sad.postalCode) DESC; UPDATE supplier s JOIN tSupplierGeo tsg ON tsg.id = s.id From aed4bc89c7eb09f808778804fa5ee94d93909e0a Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 12:53:36 +0100 Subject: [PATCH 82/92] feat: refs #8057 Fix version --- db/versions/11346-yellowPhormium/00-address.sql | 6 +++--- db/versions/11346-yellowPhormium/01-client.sql | 6 +++--- db/versions/11346-yellowPhormium/02-supplier.sql | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index a8ee88b94..70683fc8f 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -3,7 +3,7 @@ ALTER TABLE vn.address ADD CONSTRAINT address_zoneGeo_FK FOREIGN KEY (geoFk) REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; -CREATE OR REPLACE TEMPORARY TABLE tAddressGeo +CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo (PRIMARY KEY (id)) ENGINE = MEMORY SELECT a.id, p.geoFk @@ -15,7 +15,7 @@ CREATE OR REPLACE TEMPORARY TABLE tAddressGeo (p.code = a.postalCode) DESC; UPDATE address a - JOIN tAddressGeo tag ON tag.id = a.id + JOIN tmp.tAddressGeo tag ON tag.id = a.id SET a.geoFk = tag.geoFk; -DROP TEMPORARY TABLE tAddressGeo; +DROP TEMPORARY TABLE tmp.tAddressGeo; diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index e1294c30e..a8bd16921 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -6,7 +6,7 @@ ALTER TABLE vn.client ADD CONSTRAINT client_zoneGeo_FK FOREIGN KEY (geoFk) REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; -CREATE OR REPLACE TEMPORARY TABLE tClientGeo +CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo (PRIMARY KEY (id)) ENGINE = MEMORY SELECT c.id, p.geoFk @@ -18,7 +18,7 @@ CREATE OR REPLACE TEMPORARY TABLE tClientGeo (p.code = c.postcode) DESC; UPDATE client c - JOIN tClientGeo tcg ON tcg.id = c.id + JOIN tmp.tClientGeo tcg ON tcg.id = c.id SET c.geoFk = tcg.geoFk; -DROP TEMPORARY TABLE tClientGeo; +DROP TEMPORARY TABLE tmp.tClientGeo; diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index 57cdefaea..5f902d039 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -5,7 +5,7 @@ ALTER TABLE vn.supplier ADD CONSTRAINT supplier_zoneGeo_FK FOREIGN KEY (geoFk) REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; -CREATE OR REPLACE TEMPORARY TABLE tSupplierGeo +CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo (PRIMARY KEY (id)) ENGINE = MEMORY SELECT s.id, p.geoFk @@ -19,7 +19,7 @@ CREATE OR REPLACE TEMPORARY TABLE tSupplierGeo (p.code = sad.postalCode) DESC; UPDATE supplier s - JOIN tSupplierGeo tsg ON tsg.id = s.id + JOIN tmp.tSupplierGeo tsg ON tsg.id = s.id SET s.geoFk = tsg.geoFk; -DROP TEMPORARY TABLE tSupplierGeo; +DROP TEMPORARY TABLE tmp.tSupplierGeo; From 2b770c020141d637de644d2e40251f9eefc54e19 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 12:56:37 +0100 Subject: [PATCH 83/92] feat: refs #8057 Fix version --- db/versions/11346-yellowPhormium/00-address.sql | 8 ++++---- db/versions/11346-yellowPhormium/01-client.sql | 8 ++++---- db/versions/11346-yellowPhormium/02-supplier.sql | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index 70683fc8f..2f8033b0a 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -7,14 +7,14 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo (PRIMARY KEY (id)) ENGINE = MEMORY SELECT a.id, p.geoFk - FROM address a - JOIN town t ON t.provinceFk = a.provinceFk - JOIN postCode p ON p.townFk = t.id + FROM vn.address a + JOIN vn.town t ON t.provinceFk = a.provinceFk + JOIN vn.postCode p ON p.townFk = t.id GROUP BY a.id ORDER BY (a.city SOUNDS LIKE t.`name`) DESC, (p.code = a.postalCode) DESC; -UPDATE address a +UPDATE vn.address a JOIN tmp.tAddressGeo tag ON tag.id = a.id SET a.geoFk = tag.geoFk; diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index a8bd16921..855d873f9 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -10,14 +10,14 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo (PRIMARY KEY (id)) ENGINE = MEMORY SELECT c.id, p.geoFk - FROM client c - JOIN town t ON t.provinceFk = c.provinceFk - JOIN postCode p ON p.townFk = t.id + FROM vn.client c + JOIN vn.town t ON t.provinceFk = c.provinceFk + JOIN vn.postCode p ON p.townFk = t.id GROUP BY c.id ORDER BY (c.city SOUNDS LIKE t.`name`) DESC, (p.code = c.postcode) DESC; -UPDATE client c +UPDATE vn.client c JOIN tmp.tClientGeo tcg ON tcg.id = c.id SET c.geoFk = tcg.geoFk; diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index 5f902d039..9a0cd5b42 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -9,16 +9,16 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo (PRIMARY KEY (id)) ENGINE = MEMORY SELECT s.id, p.geoFk - FROM supplier s - JOIN town t ON t.provinceFk = s.provinceFk - JOIN postCode p ON p.townFk = t.id - LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id + FROM vn.supplier s + JOIN vn.town t ON t.provinceFk = s.provinceFk + JOIN vn.postCode p ON p.townFk = t.id + LEFT JOIN vn.supplierAddress sad ON sad.supplierFk = s.id GROUP BY s.id ORDER BY (s.city SOUNDS LIKE t.`name`) DESC, (p.code = s.postCode) DESC, (p.code = sad.postalCode) DESC; -UPDATE supplier s +UPDATE vn.supplier s JOIN tmp.tSupplierGeo tsg ON tsg.id = s.id SET s.geoFk = tsg.geoFk; From cdcc5051d2ba4619f140e9938a55f59941bcf85a Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 13:09:33 +0100 Subject: [PATCH 84/92] feat: refs #8057 Fix version --- db/routines/vn/functions/address_getGeo.sql | 1 + db/routines/vn/functions/client_getGeo.sql | 1 + db/routines/vn/functions/supplier_getGeo.sql | 1 + db/versions/11346-yellowPhormium/00-address.sql | 1 + db/versions/11346-yellowPhormium/01-client.sql | 1 + db/versions/11346-yellowPhormium/02-supplier.sql | 1 + 6 files changed, 6 insertions(+) diff --git a/db/routines/vn/functions/address_getGeo.sql b/db/routines/vn/functions/address_getGeo.sql index 248e8c787..0800d226a 100644 --- a/db/routines/vn/functions/address_getGeo.sql +++ b/db/routines/vn/functions/address_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM address a JOIN town t ON t.provinceFk = a.provinceFk JOIN postCode p ON p.townFk = t.id + JOIN zoneGeo zg ON zg.id = p.geoFk WHERE a.id = vSelf ORDER BY (a.city SOUNDS LIKE t.name) DESC, (p.code = a.postalCode) DESC diff --git a/db/routines/vn/functions/client_getGeo.sql b/db/routines/vn/functions/client_getGeo.sql index 624becf1e..e16653ee5 100644 --- a/db/routines/vn/functions/client_getGeo.sql +++ b/db/routines/vn/functions/client_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM client c JOIN town t ON t.provinceFk = c.provinceFk JOIN postCode p ON p.townFk = t.id + JOIN zoneGeo zg ON zg.id = p.geoFk WHERE c.id = vSelf ORDER BY (c.city SOUNDS LIKE t.name) DESC, (p.code = c.postcode) DESC diff --git a/db/routines/vn/functions/supplier_getGeo.sql b/db/routines/vn/functions/supplier_getGeo.sql index 29b6736f3..10ca5b8b8 100644 --- a/db/routines/vn/functions/supplier_getGeo.sql +++ b/db/routines/vn/functions/supplier_getGeo.sql @@ -16,6 +16,7 @@ BEGIN JOIN town t ON t.provinceFk = s.provinceFk JOIN postCode p ON p.townFk = t.id LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id + JOIN zoneGeo zg ON zg.id = p.geoFk WHERE s.id = vSelf ORDER BY (s.city SOUNDS LIKE t.name) DESC, (p.code = s.postCode) DESC, diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index 2f8033b0a..6837e0d86 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -10,6 +10,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo FROM vn.address a JOIN vn.town t ON t.provinceFk = a.provinceFk JOIN vn.postCode p ON p.townFk = t.id + JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY a.id ORDER BY (a.city SOUNDS LIKE t.`name`) DESC, (p.code = a.postalCode) DESC; diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index 855d873f9..a95d21efa 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -13,6 +13,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo FROM vn.client c JOIN vn.town t ON t.provinceFk = c.provinceFk JOIN vn.postCode p ON p.townFk = t.id + JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY c.id ORDER BY (c.city SOUNDS LIKE t.`name`) DESC, (p.code = c.postcode) DESC; diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index 9a0cd5b42..a28e7d680 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -13,6 +13,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo JOIN vn.town t ON t.provinceFk = s.provinceFk JOIN vn.postCode p ON p.townFk = t.id LEFT JOIN vn.supplierAddress sad ON sad.supplierFk = s.id + JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY s.id ORDER BY (s.city SOUNDS LIKE t.`name`) DESC, (p.code = s.postCode) DESC, From 8d4769d74d45e4f0ec430c0273479cddea173c2e Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 13:34:20 +0100 Subject: [PATCH 85/92] feat: refs #8057 More precision in getGeo --- db/routines/vn/functions/address_getGeo.sql | 1 + db/routines/vn/functions/client_getGeo.sql | 1 + db/routines/vn/functions/supplier_getGeo.sql | 1 + db/versions/11346-yellowPhormium/00-address.sql | 1 + db/versions/11346-yellowPhormium/01-client.sql | 1 + db/versions/11346-yellowPhormium/02-supplier.sql | 1 + 6 files changed, 6 insertions(+) diff --git a/db/routines/vn/functions/address_getGeo.sql b/db/routines/vn/functions/address_getGeo.sql index 0800d226a..213eb91c3 100644 --- a/db/routines/vn/functions/address_getGeo.sql +++ b/db/routines/vn/functions/address_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM address a JOIN town t ON t.provinceFk = a.provinceFk JOIN postCode p ON p.townFk = t.id + AND (p.code = a.postalCode OR a.postalCode IS NULL) JOIN zoneGeo zg ON zg.id = p.geoFk WHERE a.id = vSelf ORDER BY (a.city SOUNDS LIKE t.name) DESC, diff --git a/db/routines/vn/functions/client_getGeo.sql b/db/routines/vn/functions/client_getGeo.sql index e16653ee5..9c2e3212e 100644 --- a/db/routines/vn/functions/client_getGeo.sql +++ b/db/routines/vn/functions/client_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM client c JOIN town t ON t.provinceFk = c.provinceFk JOIN postCode p ON p.townFk = t.id + AND (p.code = c.postcode OR c.postcode IS NULL) JOIN zoneGeo zg ON zg.id = p.geoFk WHERE c.id = vSelf ORDER BY (c.city SOUNDS LIKE t.name) DESC, diff --git a/db/routines/vn/functions/supplier_getGeo.sql b/db/routines/vn/functions/supplier_getGeo.sql index 10ca5b8b8..86984272c 100644 --- a/db/routines/vn/functions/supplier_getGeo.sql +++ b/db/routines/vn/functions/supplier_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM supplier s JOIN town t ON t.provinceFk = s.provinceFk JOIN postCode p ON p.townFk = t.id + AND (p.code = s.postCode OR s.postCode IS NULL) LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id JOIN zoneGeo zg ON zg.id = p.geoFk WHERE s.id = vSelf diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index 6837e0d86..f91d0ae9f 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -10,6 +10,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo FROM vn.address a JOIN vn.town t ON t.provinceFk = a.provinceFk JOIN vn.postCode p ON p.townFk = t.id + AND (p.code = a.postalCode OR a.postalCode IS NULL) JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY a.id ORDER BY (a.city SOUNDS LIKE t.`name`) DESC, diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index a95d21efa..cb6fe41e8 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -13,6 +13,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo FROM vn.client c JOIN vn.town t ON t.provinceFk = c.provinceFk JOIN vn.postCode p ON p.townFk = t.id + AND (p.code = c.postcode OR c.postcode IS NULL) JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY c.id ORDER BY (c.city SOUNDS LIKE t.`name`) DESC, diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index a28e7d680..4e866525e 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -12,6 +12,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo FROM vn.supplier s JOIN vn.town t ON t.provinceFk = s.provinceFk JOIN vn.postCode p ON p.townFk = t.id + AND (p.code = s.postCode OR s.postCode IS NULL) LEFT JOIN vn.supplierAddress sad ON sad.supplierFk = s.id JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY s.id From 6619ec451c4a7dc98aa7a3adab4014dd00e9b0c1 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 18 Nov 2024 13:46:56 +0100 Subject: [PATCH 86/92] fix: getSales --- modules/ticket/back/methods/ticket/getSales.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/ticket/back/methods/ticket/getSales.js b/modules/ticket/back/methods/ticket/getSales.js index e721d90ae..5b2288d31 100644 --- a/modules/ticket/back/methods/ticket/getSales.js +++ b/modules/ticket/back/methods/ticket/getSales.js @@ -37,6 +37,7 @@ module.exports = Self => { 'name', 'subName', 'itemPackingTypeFk', + 'size', 'tag5', 'value5', 'tag6', From 33d9ba9b44117c1dde72c64449b340a011370371 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 19 Nov 2024 06:21:00 +0100 Subject: [PATCH 87/92] fix: refs #7404 negative quantity --- db/routines/vn/procedures/stockBought_calculate.sql | 2 +- .../back/methods/stock-bought/getStockBoughtDetail.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/stockBought_calculate.sql b/db/routines/vn/procedures/stockBought_calculate.sql index c3b5a0dc6..c248d0deb 100644 --- a/db/routines/vn/procedures/stockBought_calculate.sql +++ b/db/routines/vn/procedures/stockBought_calculate.sql @@ -80,7 +80,7 @@ proc: BEGIN UPDATE stockBought s JOIN tStockSold ts ON ts.workerFk = s.workerFk - SET s.bought = IF(s.bought < ts.sold, ROUND(s.bought - ts.sold, 1), 0) + SET s.bought = IF(s.bought < ABS(ts.sold), 0, ROUND(s.bought - ABS(ts.sold), 1)) WHERE s.dated = vDated; DROP TEMPORARY TABLE tCurrentData, tmp.item, tmp.buyUltimate, tStockSold; diff --git a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js index 60b099682..723e04cb9 100644 --- a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js +++ b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js @@ -50,8 +50,11 @@ module.exports = Self => { i.id itemFk, i.name itemName, ti.quantity, - ROUND((ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id)) - / (vc.trolleyM3 * 1000000),1) volume, + ROUND((ac.conversionCoefficient * + (ti.quantity / b.packing) * + buy_getVolume(b.id) + ) / (vc.trolleyM3 * 1000000), + 2) volume, b.packagingFk packagingFk, b.packing FROM tmp.item ti From 413e9e1e9f02ae2ac0b9b01c00231f5c63f9462c Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 19 Nov 2024 07:59:27 +0100 Subject: [PATCH 89/92] build: refs #8144 change package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 767ec231e..d36360498 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.44.0", + "version": "24.48.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 6a65ab42cedd640cec468282173443879739f907 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 19 Nov 2024 09:12:42 +0100 Subject: [PATCH 90/92] build: change package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d36360498..ef1dd8f89 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.48.0", + "version": "24.50.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From d21b42a5670cb092616c814943f01ab54edcaeb6 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 19 Nov 2024 11:24:00 +0100 Subject: [PATCH 91/92] feat: refs #8099 refs#8099 addComplmentSalary --- db/dump/fixtures.before.sql | 4 ++ .../11353-wheatCymbidium/00-firstScript.sql | 9 +++++ modules/route/back/model-config.json | 8 +++- modules/route/back/models/routeAction.json | 30 +++++++++++++++ .../route/back/models/routeComplement.json | 37 +++++++++++++++++++ 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 db/versions/11353-wheatCymbidium/00-firstScript.sql create mode 100644 modules/route/back/models/routeAction.json create mode 100644 modules/route/back/models/routeComplement.json diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index eb376b6c6..48e886ac9 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4008,6 +4008,10 @@ INSERT IGNORE INTO pbx.queueMember UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA"; UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; +INSERT INTO vn.routeAction (id, name, price, isMainlineDelivered) VALUES(1, 'Pintar traje', 50.00, 0); +INSERT INTO vn.routeComplement (id, dated, workerFk, price, routeActionFk) VALUES(1, util.VN_CURDATE(), 9, 50.00, 1); + + INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, code, stratus, hasWorkerWaiting, reserve, routeFk, dayMinute, lastUnloaded, hasStrapper, typeDefaultFk, motors, editorFk) VALUES (0, 0, 0, 0, NULL, 3, 1, 0, 'ENT', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), (1, 0, 9900, 0, NULL, 1, 0, 0, 'NOK', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), diff --git a/db/versions/11353-wheatCymbidium/00-firstScript.sql b/db/versions/11353-wheatCymbidium/00-firstScript.sql new file mode 100644 index 000000000..f29ae2f0e --- /dev/null +++ b/db/versions/11353-wheatCymbidium/00-firstScript.sql @@ -0,0 +1,9 @@ + + +USE vn; + +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) +VALUES('RouteAction', '*', 'READ', 'ALLOW', 'ROLE', 'delivery'); + +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) +VALUES('RouteComplement', '*', '*', 'ALLOW', 'ROLE', 'delivery'); diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json index be5aa07ca..fb1c5d7fd 100644 --- a/modules/route/back/model-config.json +++ b/modules/route/back/model-config.json @@ -23,6 +23,12 @@ "Route": { "dataSource": "vn" }, + "RouteAction": { + "dataSource": "vn" + }, + "RouteComplement": { + "dataSource": "vn" + }, "RouteLog": { "dataSource": "vn" }, @@ -32,4 +38,4 @@ "RoutesMonitor": { "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/modules/route/back/models/routeAction.json b/modules/route/back/models/routeAction.json new file mode 100644 index 000000000..88f7a8226 --- /dev/null +++ b/modules/route/back/models/routeAction.json @@ -0,0 +1,30 @@ +{ + "name": "RouteAction", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "routeAction" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string", + "required": true + }, + "price": { + "type": "number" + }, + "isMainlineDelivered": { + "type": "boolean", + "required": true + } + } +} \ No newline at end of file diff --git a/modules/route/back/models/routeComplement.json b/modules/route/back/models/routeComplement.json new file mode 100644 index 000000000..e2086f78d --- /dev/null +++ b/modules/route/back/models/routeComplement.json @@ -0,0 +1,37 @@ +{ + "name": "RouteComplement", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "routeComplement" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "dated": { + "type": "date" + }, + "price": { + "type": "number" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "routeAction": { + "type": "belongsTo", + "model": "RouteAction", + "foreignKey": "routeActionFk" + } + } +} \ No newline at end of file From feb11c123e50c3896c5b1bec0e860d0be5af8963 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 19 Nov 2024 11:45:40 +0100 Subject: [PATCH 92/92] feat: refs #8099 refs#8099 addComplmentSalary --- db/versions/11353-wheatCymbidium/00-firstScript.sql | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/db/versions/11353-wheatCymbidium/00-firstScript.sql b/db/versions/11353-wheatCymbidium/00-firstScript.sql index f29ae2f0e..557ffab9e 100644 --- a/db/versions/11353-wheatCymbidium/00-firstScript.sql +++ b/db/versions/11353-wheatCymbidium/00-firstScript.sql @@ -3,7 +3,13 @@ USE vn; INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) -VALUES('RouteAction', '*', 'READ', 'ALLOW', 'ROLE', 'delivery'); +VALUES('RouteAction', 'find', 'READ', 'ALLOW', 'ROLE', 'delivery'); INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) -VALUES('RouteComplement', '*', '*', 'ALLOW', 'ROLE', 'delivery'); +VALUES('RouteComplement', 'find', 'READ', 'ALLOW', 'ROLE', 'delivery'); + +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) +VALUES('RouteComplement', 'create', 'WRITE', 'ALLOW', 'ROLE', 'delivery'); + +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) +VALUES('RouteComplement', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'delivery'); \ No newline at end of file