From fac93bd74ce1213a2471d1b1a47a8cb64047c153 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 4 Feb 2020 09:34:31 +0100 Subject: [PATCH 01/55] summary --- modules/entry/front/index.js | 5 +- modules/entry/front/routes.json | 8 ++ modules/entry/front/summary/index.html | 140 ++++++++++++++++++++++ modules/entry/front/summary/index.js | 56 +++++++++ modules/entry/front/summary/index.spec.js | 108 +++++++++++++++++ modules/entry/front/summary/locale/es.yml | 0 modules/entry/front/summary/style.scss | 10 ++ 7 files changed, 323 insertions(+), 4 deletions(-) create mode 100644 modules/entry/front/summary/index.html create mode 100644 modules/entry/front/summary/index.js create mode 100644 modules/entry/front/summary/index.spec.js create mode 100644 modules/entry/front/summary/locale/es.yml create mode 100644 modules/entry/front/summary/style.scss diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index a0272fccf1..25e054a717 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -5,7 +5,4 @@ import './index/'; import './search-panel'; import './descriptor'; import './card'; -// import './summary'; -// import './basic-data'; -// import './log'; -// import './create'; +import './summary'; diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index f23ff02bfb..ee4853eab9 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -27,6 +27,14 @@ "state": "entry.card", "abstract": true, "component": "vn-entry-card" + }, { + "url": "/summary", + "state": "entry.card.summary", + "component": "vn-entry-summary", + "description": "Summary", + "params": { + "entry": "$ctrl.entry" + } } ] } \ No newline at end of file diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html new file mode 100644 index 0000000000..5397c72ca2 --- /dev/null +++ b/modules/entry/front/summary/index.html @@ -0,0 +1,140 @@ + +
{{$ctrl.travelData.id}} - {{$ctrl.travelData.ref}}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Entries

+ + + + Confirmed + Entry Id + Supplier + Reference + HB + Freight + Package + CC + Pallet + m3 + + + + + + + + + + {{entry.id}} + {{entry.supplierName}} + {{entry.ref}} + {{entry.hb}} + {{entry.freightValue | currency: 'EUR': 2}} + {{entry.packageValue | currency: 'EUR': 2}} + {{entry.cc}} + {{entry.pallet}} + {{entry.m3}} + + + + + + + + + + + + + + + {{$ctrl.total('hb')}} + {{$ctrl.total('freightValue') | currency: 'EUR': 2}} + {{$ctrl.total('packageValue') | currency: 'EUR': 2}} + {{$ctrl.total('cc')}} + {{$ctrl.total('pallet')}} + {{$ctrl.total('m3')}} + + + + +
+ +

Thermographs

+ + + + Code + Temperature + State + Destination + Created + + + + + {{thermograph.thermographFk}} + {{thermograph.temperature}} + {{thermograph.result}} + {{thermograph.warehouse.name}} + {{thermograph.created | date: 'dd/MM/yyyy'}} + + + +
+
+
+ + + + \ No newline at end of file diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js new file mode 100644 index 0000000000..be17feb29b --- /dev/null +++ b/modules/entry/front/summary/index.js @@ -0,0 +1,56 @@ +import ngModule from '../module'; +import './style.scss'; +import Component from 'core/lib/component'; + +class Controller extends Component { + constructor($element, $, $httpParamSerializer) { + super($element, $); + this.entries = []; + this.$httpParamSerializer = $httpParamSerializer; + } + + get entry() { + return this._entry; + } + + set entry(value) { + this._entry = value; + + // if (value && value.id) { + // this.getTravel(); + // this.getEntries(); + // this.getThermographs(); + // } + } + + // getTravel() { + // return this.$http.get(`/api/Travels/${this.travel.id}/getTravel`).then(response => { + // this.travelData = response.data; + // }); + // } + + // getEntries() { + // return this.$http.get(`/api/Travels/${this.travel.id}/getEntries`).then(response => { + // this.entries = response.data; + // }); + // } + + // total(field) { + // let total = 0; + + // for (let entry of this.entries) + // total += entry[field]; + + // return total; + // } +} + +Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; + +ngModule.component('vnEntrySummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + entry: '<' + } +}); diff --git a/modules/entry/front/summary/index.spec.js b/modules/entry/front/summary/index.spec.js new file mode 100644 index 0000000000..5411d8a0d3 --- /dev/null +++ b/modules/entry/front/summary/index.spec.js @@ -0,0 +1,108 @@ +import './index'; + +describe('component vnTravelSummary', () => { + let controller; + let $httpBackend; + let $scope; + let $element; + let $httpParamSerializer; + + beforeEach(angular.mock.module('travel', $translateProvider => { + $translateProvider.translations('en', {}); + })); + + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + $httpBackend = _$httpBackend_; + $httpParamSerializer = _$httpParamSerializer_; + $scope = $rootScope.$new(); + $element = angular.element(``); + controller = $componentController('vnTravelSummary', {$element, $scope}); + })); + + describe('travel setter/getter', () => { + it('should return the travel', () => { + controller.travel = {id: null}; + + expect(controller.travel).toEqual(jasmine.any(Object)); + }); + + it('should return the travel and then call both getTravel() and getEntries()', () => { + spyOn(controller, 'getTravel'); + spyOn(controller, 'getEntries'); + spyOn(controller, 'getThermographs'); + controller.travel = {id: 99}; + + + expect(controller._travel.id).toEqual(99); + expect(controller.getTravel).toHaveBeenCalledWith(); + expect(controller.getEntries).toHaveBeenCalledWith(); + expect(controller.getThermographs).toHaveBeenCalledWith(); + }); + }); + + describe('getTravel()', () => { + it('should perform a get and then store data on the controller', () => { + controller._travel = {id: 999}; + + const query = `/api/Travels/${controller._travel.id}/getTravel`; + $httpBackend.expectGET(query).respond('I am the travelData'); + controller.getTravel(); + $httpBackend.flush(); + + expect(controller.travelData).toEqual('I am the travelData'); + }); + }); + + describe('getEntries()', () => { + it('should call the getEntries method to get the entries data', () => { + controller._travel = {id: 999}; + + const query = `/api/Travels/${controller._travel.id}/getEntries`; + $httpBackend.expectGET(query).respond('I am the entries'); + controller.getEntries(); + $httpBackend.flush(); + + expect(controller.entries).toEqual('I am the entries'); + }); + }); + + describe('getThermographs()', () => { + it('should call the getThermographs method to get the thermographs', () => { + controller._travel = {id: 2}; + const params = { + filter: { + include: { + relation: 'warehouse', + scope: { + fields: ['id', 'name'] + } + }, + where: { + travelFk: controller._travel.id + } + } + }; + const serializedParams = $httpParamSerializer(params); + const query = `TravelThermographs?${serializedParams}`; + $httpBackend.expectGET(query).respond('I am the thermographs'); + controller.getThermographs(); + $httpBackend.flush(); + + expect(controller.travelThermographs).toEqual('I am the thermographs'); + }); + }); + + describe('total()', () => { + it('should calculate the total amount of a given property for every row', () => { + controller.entries = [ + {id: 1, freightValue: 1, packageValue: 2, cc: 0.01}, + {id: 2, freightValue: 1, packageValue: 2, cc: 0.01}, + {id: 3, freightValue: 1, packageValue: 2, cc: 0.01} + ]; + + expect(controller.total('freightValue')).toEqual(3); + expect(controller.total('packageValue')).toEqual(6); + expect(controller.total('cc')).toEqual(0.03); + }); + }); +}); diff --git a/modules/entry/front/summary/locale/es.yml b/modules/entry/front/summary/locale/es.yml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/modules/entry/front/summary/style.scss b/modules/entry/front/summary/style.scss new file mode 100644 index 0000000000..922b36ad8f --- /dev/null +++ b/modules/entry/front/summary/style.scss @@ -0,0 +1,10 @@ +@import "variables"; + + +vn-travel-summary .summary { + max-width: $width-lg; + + vn-icon[icon=insert_drive_file]{ + color: $color-font-secondary; + } +} \ No newline at end of file From c78c154ab0161d4e35e10b2dd4aa528cd99f661f Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 11 Feb 2020 14:41:59 +0100 Subject: [PATCH 02/55] Added datalist --- front/core/components/datalist/index.js | 2 - .../order/back/methods/order/catalogFilter.js | 1 + modules/order/front/catalog/index.html | 13 ++-- modules/order/front/catalog/index.js | 74 +++++++++++-------- modules/order/front/catalog/index.spec.js | 55 ++++++++++++-- modules/order/front/locale/es.yml | 1 + 6 files changed, 102 insertions(+), 44 deletions(-) diff --git a/front/core/components/datalist/index.js b/front/core/components/datalist/index.js index d5feb18932..0964a14805 100644 --- a/front/core/components/datalist/index.js +++ b/front/core/components/datalist/index.js @@ -157,8 +157,6 @@ export default class Datalist extends Textfield { this.destroyList(); } else this.buildList(); - - this.emit('select', {selection}); }); } diff --git a/modules/order/back/methods/order/catalogFilter.js b/modules/order/back/methods/order/catalogFilter.js index 3814aa12d1..114cd27864 100644 --- a/modules/order/back/methods/order/catalogFilter.js +++ b/modules/order/back/methods/order/catalogFilter.js @@ -162,6 +162,7 @@ module.exports = Self => { `SELECT it.tagFk, it.itemFk, + it.value, t.name FROM tmp.ticketCalculateItem tci JOIN vn.itemTag it ON it.itemFk = tci.itemFk diff --git a/modules/order/front/catalog/index.html b/modules/order/front/catalog/index.html index 5cc72e3c8f..37767e81bb 100644 --- a/modules/order/front/catalog/index.html +++ b/modules/order/front/catalog/index.html @@ -85,12 +85,15 @@ - + show-field="value" + value-field="value" + label="Search tag"> @@ -101,7 +104,7 @@ style="cursor: pointer;"> - + { - // Add new tag filters - item.tags.forEach(itemTag => { - const alreadyAdded = newFilterList.findIndex(filter => { - return filter.field == itemTag.tagFk; - }); - - if (alreadyAdded == -1) { - newFilterList.push({ - name: itemTag.name, - field: itemTag.tagFk, - isTag: true - }); - } - }); - }); - - // Add default filters - Replaces tags with same name - this.defaultOrderFields.forEach(orderField => { - const index = newFilterList.findIndex(newfield => { - return newfield.name == orderField.name; - }); - - if (index > -1) - newFilterList[index] = orderField; - else - newFilterList.push(orderField); - }); - - this.orderFields = newFilterList; + this.buildTagsFilter(value); + this.buildOrderFilter(value); } get categoryId() { @@ -273,6 +244,45 @@ class Controller { this.$state.go(this.$state.current.name, params); } + + // Builds the tags filter + buildTagsFilter(items) { + const tagValues = []; + items.forEach(item => { + item.tags.forEach(itemTag => { + const alreadyAdded = tagValues.findIndex(tag => { + return tag.value == itemTag.value; + }); + + if (alreadyAdded == -1) + tagValues.push(itemTag); + }); + }); + this.tagValues = tagValues; + } + + // Builds the order filter + buildOrderFilter(items) { + const tags = []; + items.forEach(item => { + item.tags.forEach(itemTag => { + const alreadyAdded = tags.findIndex(tag => { + return tag.field == itemTag.tagFk; + }); + + if (alreadyAdded == -1) { + tags.push({ + name: itemTag.name, + field: itemTag.tagFk, + isTag: true + }); + } + }); + }); + let newFilterList = [].concat(this.defaultOrderFields); + newFilterList = newFilterList.concat(tags); + this.orderFields = newFilterList; + } } Controller.$inject = ['$http', '$scope', '$state', '$compile', '$transitions']; diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js index dd9e132577..01da618009 100644 --- a/modules/order/front/catalog/index.spec.js +++ b/modules/order/front/catalog/index.spec.js @@ -37,16 +37,19 @@ describe('Order', () => { describe('items() setter', () => { it(`should return an object with order params`, () => { - let expectedResult = [{field: 'showOrder, price', name: 'Color'}]; - let unexpectedResult = [{tagFk: 5, name: 'Color'}]; - controller.items = [{id: 1, name: 'My Item', tags: [ + spyOn(controller, 'buildTagsFilter'); + spyOn(controller, 'buildOrderFilter').and.callThrough(); + const expectedResult = [{field: 'showOrder, price', name: 'Color and price'}]; + const items = [{id: 1, name: 'My Item', tags: [ {tagFk: 4, name: 'Length'}, {tagFk: 5, name: 'Color'} ]}]; + controller.items = items; - expect(controller.orderFields.length).toEqual(5); + expect(controller.orderFields.length).toEqual(6); expect(controller.orderFields).toEqual(jasmine.arrayContaining(expectedResult)); - expect(controller.orderFields).not.toEqual(jasmine.arrayContaining(unexpectedResult)); + expect(controller.buildTagsFilter).toHaveBeenCalledWith(items); + expect(controller.buildOrderFilter).toHaveBeenCalledWith(items); }); }); @@ -222,6 +225,48 @@ describe('Order', () => { expect(controller.$.model.addFilter).toHaveBeenCalledWith(null, expectedOrder); }); }); + + describe('buildTagsFilter()', () => { + it(`should create an array of non repeated tag values and then set the tagValues property`, () => { + const items = [ + { + id: 1, name: 'My Item 1', tags: [ + {tagFk: 4, name: 'Length', value: 1}, + {tagFk: 5, name: 'Color', value: 'red'} + ] + }, + { + id: 2, name: 'My Item 2', tags: [ + {tagFk: 4, name: 'Length', value: 1}, + {tagFk: 5, name: 'Color', value: 'blue'} + ] + }]; + controller.buildTagsFilter(items); + + expect(controller.tagValues.length).toEqual(3); + }); + }); + + describe('buildOrderFilter()', () => { + it(`should create an array of non repeated tags plus default filters and then set the orderFields property`, () => { + const items = [ + { + id: 1, name: 'My Item 1', tags: [ + {tagFk: 4, name: 'Length'}, + {tagFk: 5, name: 'Color'} + ] + }, + { + id: 2, name: 'My Item 2', tags: [ + {tagFk: 5, name: 'Color'}, + {tagFk: 6, name: 'Relevancy'} + ] + }]; + controller.buildOrderFilter(items); + + expect(controller.orderFields.length).toEqual(7); + }); + }); }); }); diff --git a/modules/order/front/locale/es.yml b/modules/order/front/locale/es.yml index 0ada37bfd0..565d4f2518 100644 --- a/modules/order/front/locale/es.yml +++ b/modules/order/front/locale/es.yml @@ -16,6 +16,7 @@ Item id: Id de artículo Order by: Ordenar por Order: Orden Price: Precio +Color and price: Color y precio Ascendant: Ascendente Descendant: Descendente Created from: Creado desde From f7dc279489e0dffe5dd25ac33edfd383c3a78847 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 13 Feb 2020 09:47:05 +0100 Subject: [PATCH 03/55] #2002 e2e client.summary --- e2e/helpers/selectors.js | 11 ++++ e2e/paths/02-client/19_summary.spec.js | 80 ++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 e2e/paths/02-client/19_summary.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 5647457522..63d40f9d5b 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -27,6 +27,17 @@ export default { createClientButton: `vn-float-button`, othersButton: 'vn-left-menu li[name="Others"] > a' }, + clientSummary: { + header: 'vn-client-summary > vn-card > h5', + email: 'vn-client-summary vn-label-value[label="Email"]', + street: 'vn-client-summary vn-label-value[label="Street"]', + verifiedData: 'vn-client-summary > vn-card > vn-horizontal vn-check[ng-model="$ctrl.summary.isTaxDataChecked"]', + payMethod: 'vn-client-summary vn-label-value[label="Pay method"]', + defaultAdressName: 'vn-client-summary vn-label-value[label="Name"]', + userName: 'vn-client-summary vn-label-value[label="User"]', + rate: 'vn-client-summary vn-label-value[label="Rate"]', + credit: 'vn-client-summary vn-label-value[label="Credit"]', + }, createClientView: { name: 'vn-client-create vn-textfield[ng-model="$ctrl.client.name"]', taxNumber: 'vn-client-create vn-textfield[ng-model="$ctrl.client.fi"]', diff --git a/e2e/paths/02-client/19_summary.spec.js b/e2e/paths/02-client/19_summary.spec.js new file mode 100644 index 0000000000..11b5a298ec --- /dev/null +++ b/e2e/paths/02-client/19_summary.spec.js @@ -0,0 +1,80 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Client summary 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 reach the first route summary section', async() => { + let url = await page.expectURL('#!/client/102/summary'); + + expect(url).toBe(true); + }); + + it('should display details from the client on the header', async() => { + await page.waitForTextInElement(selectors.clientSummary.header, 'Petter Parker'); + const result = await page.waitToGetProperty(selectors.clientSummary.header, 'innerText'); + + expect(result).toContain('Petter Parker'); + }); + + it('should display some basic data', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.email, 'innerText'); + + expect(result).toContain('PetterParker@mydomain.com'); + }); + + it('should display fiscal address details', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.street, 'innerText'); + + expect(result).toContain('20 Ingram Street'); + }); + + it('should display some fiscal data', async() => { + await page.waitForClassPresent(selectors.clientSummary.verifiedData, 'checked'); + const result = await page.waitToGetProperty(selectors.clientSummary.verifiedData, 'innerText'); + + expect(result).toContain('Verified data'); + }); + + it('should display pay method details', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.payMethod, 'innerText'); + + expect(result).toContain('PayMethod five'); + }); + + it('should display default address details', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.defaultAdressName, 'innerText'); + + expect(result).toContain('Petter Parker'); + }); + + it('should display web access details', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.userName, 'innerText'); + + expect(result).toContain('PetterParker'); + }); + + it('should display business data', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.rate, 'innerText'); + + expect(result).toContain('%'); + }); + + it('should display financial information', async() => { + const result = await page.waitToGetProperty(selectors.clientSummary.credit, 'innerText'); + + expect(result).toContain('€300.00'); + }); +}); From df873b4ac06a98d8299ae8c9d046788a819900f1 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 13 Feb 2020 11:05:00 +0100 Subject: [PATCH 04/55] added datalist to catalog filter --- e2e/helpers/selectors.js | 4 ++-- front/core/components/datalist/index.js | 2 +- front/core/components/datalist/style.scss | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100755 front/core/components/datalist/style.scss diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 99c78eea2f..d92bb5b14e 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -606,8 +606,8 @@ export default { plantRealmButton: 'vn-order-catalog > vn-side-menu vn-icon[icon="icon-plant"]', type: 'vn-autocomplete[data="$ctrl.itemTypes"]', itemId: 'vn-order-catalog > vn-side-menu vn-textfield[ng-model="$ctrl.itemId"]', - itemTagValue: 'vn-order-catalog > vn-side-menu vn-textfield[ng-model="$ctrl.value"]', - openTagSearch: 'vn-order-catalog > vn-side-menu > div > vn-vertical > vn-textfield[ng-model="$ctrl.value"] .append i', + itemTagValue: 'vn-order-catalog > vn-side-menu vn-datalist[ng-model="$ctrl.value"]', + openTagSearch: 'vn-order-catalog > vn-side-menu > div > vn-vertical > vn-datalist[ng-model="$ctrl.value"] .append i', tag: 'vn-order-catalog-search-panel vn-autocomplete[ng-model="filter.tagFk"]', tagValue: 'vn-order-catalog-search-panel vn-textfield[ng-model="filter.value"]', searchTagButton: 'vn-order-catalog-search-panel button[type=submit]', diff --git a/front/core/components/datalist/index.js b/front/core/components/datalist/index.js index 0964a14805..bf3cab9a18 100644 --- a/front/core/components/datalist/index.js +++ b/front/core/components/datalist/index.js @@ -3,6 +3,7 @@ import ArrayModel from '../array-model/array-model'; import CrudModel from '../crud-model/crud-model'; import {mergeWhere} from 'vn-loopback/util/filter'; import Textfield from '../textfield/textfield'; +import './style.scss'; export default class Datalist extends Textfield { constructor($element, $scope, $compile, $transclude) { @@ -12,7 +13,6 @@ export default class Datalist extends Textfield { this._selection = null; this.buildInput('text'); - this.input.setAttribute('autocomplete', 'off'); } diff --git a/front/core/components/datalist/style.scss b/front/core/components/datalist/style.scss new file mode 100755 index 0000000000..db4ed2bb09 --- /dev/null +++ b/front/core/components/datalist/style.scss @@ -0,0 +1,7 @@ +@import "effects"; + +vn-datalist { + input::-webkit-calendar-picker-indicator { + display: none + } +} \ No newline at end of file From 39470e837b7e8f24790064cf65242dc7d615849a Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 13 Feb 2020 13:20:31 +0100 Subject: [PATCH 05/55] 2094 Regularize claim send chat even if doesn't have destination --- back/methods/chat/sendCheckingPresence.js | 2 +- loopback/locale/en.json | 2 +- loopback/locale/es.json | 2 +- .../back/methods/claim/regularizeClaim.js | 49 ++++++++++--------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 70b4da58f4..b2a3ca725f 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -36,7 +36,7 @@ module.exports = Self => { relation: 'department' } }); - const department = workerDepartment.department(); + const department = workerDepartment && workerDepartment.department(); const channelName = department.chatName; if (channelName) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 23717ba8f3..49cd0f1719 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -61,7 +61,7 @@ "MESSAGE_BOUGHT_UNITS": "Bought {{quantity}} units of {{concept}} (#{{itemId}}) for the ticket id [#{{ticketId}}]({{{url}}})", "MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} (#{{clientId}})]({{{url}}}) to *{{credit}} €*", "MESSAGE_CHANGED_PAYMETHOD": "I have changed the pay method for client [{{clientName}} (#{{clientId}})]({{{url}}})", - "MESSAGE_CLAIM_ITEM_REGULARIZE": "I sent *{{quantity}}* units of [{{concept}} (#{{itemId}})]({{{itemUrl}}}) to {{nickname}} coming from ticket id [#{{ticketId}}]({{{ticketUrl}}})", + "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} (#{{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [#{{ticketId}}]({{{ticketUrl}}})", "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}" diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 90d4f8793d..64fabd5226 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -124,7 +124,7 @@ "MESSAGE_BOUGHT_UNITS": "Se ha comprado {{quantity}} unidades de {{concept}} (#{{itemId}}) para el ticket id [#{{ticketId}}]({{{url}}})", "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} (#{{clientId}})]({{{url}}}) a *{{credit}} €*", "MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} (#{{clientId}})]({{{url}}})", - "MESSAGE_CLAIM_ITEM_REGULARIZE": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a {{nickname}} provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})", + "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})", "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto" } \ No newline at end of file diff --git a/modules/claim/back/methods/claim/regularizeClaim.js b/modules/claim/back/methods/claim/regularizeClaim.js index 8a4f6dc957..adf1623c66 100644 --- a/modules/claim/back/methods/claim/regularizeClaim.js +++ b/modules/claim/back/methods/claim/regularizeClaim.js @@ -37,27 +37,43 @@ module.exports = Self => { for (let i = 0; i < claimEnds.length; i++) { const claimEnd = claimEnds[i]; const destination = claimEnd.claimDestination(); - const addressFk = destination && destination.addressFk; + const sale = await getSale(claimEnd.saleFk, options); + const addressId = destination && destination.addressFk; - if (!addressFk) continue; + let address; + if (addressId) + address = await models.Address.findById(addressId, null, options); + + const salesPerson = sale.ticket().client().salesPerson(); + if (salesPerson) { + const nickname = address && address.nickname || destination.description; + const origin = ctx.req.headers.origin; + const message = $t('Sent units from ticket', { + quantity: sale.quantity, + concept: sale.concept, + itemId: sale.itemFk, + ticketId: sale.ticketFk, + nickname: nickname, + ticketUrl: `${origin}/#!/ticket/${sale.ticketFk}/summary`, + itemUrl: `${origin}/#!/item/${sale.itemFk}/summary` + }); + await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message); + } + + if (!address) continue; - let sale = await getSale(claimEnd.saleFk, options); let ticketFk = await getTicketId({ - addressFk: addressFk, + addressFk: addressId, companyFk: sale.ticket().companyFk, warehouseFk: sale.ticket().warehouseFk }, options); - let address = await models.Address.findOne({ - where: {id: addressFk} - }, options); - if (!ticketFk) { ticketFk = await createTicket(ctx, { clientId: address.clientFk, warehouseId: sale.ticket().warehouseFk, companyId: sale.ticket().companyFk, - addressId: addressFk + addressId: addressId }, options); } @@ -69,21 +85,6 @@ module.exports = Self => { price: sale.price, discount: 100 }, options); - - const salesPerson = sale.ticket().client().salesPerson(); - if (salesPerson) { - const origin = ctx.req.headers.origin; - const message = $t('MESSAGE_CLAIM_ITEM_REGULARIZE', { - quantity: sale.quantity, - concept: sale.concept, - itemId: sale.itemFk, - ticketId: sale.ticketFk, - nickname: address.nickname, - ticketUrl: `${origin}/#!/ticket/${sale.ticketFk}/summary`, - itemUrl: `${origin}/#!/item/${sale.itemFk}/summary` - }); - await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message); - } } let claim = await Self.findById(params.claimFk, null, options); From be07e33e5f65af733eec711c3578845066f45b93 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 13 Feb 2020 14:39:33 +0100 Subject: [PATCH 06/55] updated unit test --- .../claim/specs/regularizeClaim.spec.js | 44 ++++++++++++++++--- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js index fd3fb3c3de..96f2c81720 100644 --- a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js @@ -1,6 +1,6 @@ const app = require('vn-loopback/server/server'); -describe('regularizeClaim()', () => { +fdescribe('regularizeClaim()', () => { const claimFk = 1; const pendentState = 1; const resolvedState = 3; @@ -21,15 +21,20 @@ describe('regularizeClaim()', () => { done(); }); - it('should change claim state to resolved', async() => { - const ctx = {req: { - accessToken: {userId: 18}, - headers: {origin: 'http://localhost'}} + it('should send a chat message with value "Trash" and then change claim state to resolved', async() => { + const ctx = { + req: { + accessToken: {userId: 18}, + headers: {origin: 'http://localhost'} + } }; - ctx.req.__ = value => { - return value; + ctx.req.__ = (value, params) => { + return params.nickname; }; + let params = {claimFk: claimFk}; + const chatModel = app.models.Chat; + spyOn(chatModel, 'sendCheckingPresence').and.callThrough(); claimEnds = await app.models.ClaimEnd.importTicketSales(ctx, { claimFk: claimFk, @@ -49,5 +54,30 @@ describe('regularizeClaim()', () => { expect(trashTicket.addressFk).toEqual(trashAddress); expect(claimBefore.claimStateFk).toEqual(pendentState); expect(claimAfter.claimStateFk).toEqual(resolvedState); + expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Trash'); + }); + + it('should send a chat message with value "Bueno" and then change claim state to resolved', async() => { + const ctx = { + req: { + accessToken: {userId: 18}, + headers: {origin: 'http://localhost'} + } + }; + ctx.req.__ = (value, params) => { + return params.nickname; + }; + + let params = {claimFk: claimFk}; + const chatModel = app.models.Chat; + spyOn(chatModel, 'sendCheckingPresence').and.callThrough(); + + claimEnds.forEach(async claimEnd => { + claimEnd.updateAttributes({claimDestinationFk: 1}); + }); + + await app.models.Claim.regularizeClaim(ctx, params); + + expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno'); }); }); From 5360c407d58ec008a6309560424172c05b231e20 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 13 Feb 2020 14:46:18 +0100 Subject: [PATCH 07/55] updated unit test --- .../claim/back/methods/claim/specs/regularizeClaim.spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js index 96f2c81720..c2be4379dd 100644 --- a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js @@ -5,6 +5,7 @@ fdescribe('regularizeClaim()', () => { const pendentState = 1; const resolvedState = 3; const trashDestination = 2; + const okDestination = 1; const trashAddress = 12; let claimEnds = []; let trashTicket; @@ -55,6 +56,7 @@ fdescribe('regularizeClaim()', () => { expect(claimBefore.claimStateFk).toEqual(pendentState); expect(claimAfter.claimStateFk).toEqual(resolvedState); expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Trash'); + expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(4); }); it('should send a chat message with value "Bueno" and then change claim state to resolved', async() => { @@ -73,11 +75,12 @@ fdescribe('regularizeClaim()', () => { spyOn(chatModel, 'sendCheckingPresence').and.callThrough(); claimEnds.forEach(async claimEnd => { - claimEnd.updateAttributes({claimDestinationFk: 1}); + claimEnd.updateAttributes({claimDestinationFk: okDestination}); }); await app.models.Claim.regularizeClaim(ctx, params); expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno'); + expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(4); }); }); From fd45c41210a4049ed50b9fcc35a399e26336044b Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 13 Feb 2020 15:01:24 +0100 Subject: [PATCH 08/55] removed focus --- modules/claim/back/methods/claim/specs/regularizeClaim.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js index c2be4379dd..c7aa1cf0a9 100644 --- a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js @@ -1,6 +1,6 @@ const app = require('vn-loopback/server/server'); -fdescribe('regularizeClaim()', () => { +describe('regularizeClaim()', () => { const claimFk = 1; const pendentState = 1; const resolvedState = 3; From bba6c9be15a23b1e091d9e8ee89a474e670fa011 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 14 Feb 2020 07:53:13 +0100 Subject: [PATCH 09/55] Return response when the sender equals recipient --- back/methods/chat/send.js | 2 ++ back/methods/chat/spec/send.spec.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index b0a9431c79..53e5da7cc0 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -32,6 +32,8 @@ module.exports = Self => { if (sender.name != recipient) return sendMessage(sender, to, message); + + return false; }; async function sendMessage(sender, channel, message) { diff --git a/back/methods/chat/spec/send.spec.js b/back/methods/chat/spec/send.spec.js index b2585a9a15..56f2a9c275 100644 --- a/back/methods/chat/spec/send.spec.js +++ b/back/methods/chat/spec/send.spec.js @@ -9,10 +9,10 @@ describe('chat send()', () => { expect(response.message).toEqual('Fake notification sent'); }); - it('should not return a response', async() => { + it('should retrun false as response', async() => { let ctx = {req: {accessToken: {userId: 18}}}; let response = await app.models.Chat.send(ctx, '@salesPerson', 'I changed something'); - expect(response).toBeUndefined(); + expect(response).toBeFalsy(); }); }); From 84bf95db1325b811dd489b59568ccd397a05bc9b Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 14 Feb 2020 12:01:17 +0100 Subject: [PATCH 10/55] 2106 - Sms max length fix --- modules/client/front/sms/index.html | 13 ++++++++++--- modules/client/front/sms/index.js | 11 ++++++----- modules/client/front/sms/index.spec.js | 12 ++++++++---- modules/client/front/sms/locale/es.yml | 4 +++- modules/ticket/front/sms/index.html | 11 +++++++++-- modules/ticket/front/sms/index.js | 11 ++++++----- modules/ticket/front/sms/index.spec.js | 12 ++++++++---- modules/ticket/front/sms/locale/es.yml | 4 +++- 8 files changed, 53 insertions(+), 25 deletions(-) diff --git a/modules/client/front/sms/index.html b/modules/client/front/sms/index.html index facbb76948..fb2f1dfff2 100644 --- a/modules/client/front/sms/index.html +++ b/modules/client/front/sms/index.html @@ -13,20 +13,27 @@ rule> - + - {{'Characters remaining' | translate}}: {{$ctrl.charactersRemaining()}} + {{'Characters remaining' | translate}}: + + {{$ctrl.charactersRemaining()}} + diff --git a/modules/client/front/sms/index.js b/modules/client/front/sms/index.js index 851ce1a66e..c7d89e7170 100644 --- a/modules/client/front/sms/index.js +++ b/modules/client/front/sms/index.js @@ -17,13 +17,12 @@ class Controller extends Component { } charactersRemaining() { - let elementMaxLength; - let textAreaLength; const element = this.$scope.message; + const value = element.input.value; - textAreaLength = element.input.textLength; - elementMaxLength = element.maxlength; - return elementMaxLength - textAreaLength; + const maxLength = 160; + const textAreaLength = new Blob([value]).size; + return maxLength - textAreaLength; } onResponse(response) { @@ -33,6 +32,8 @@ class Controller extends Component { throw new Error(`The destination can't be empty`); if (!this.sms.message) throw new Error(`The message can't be empty`); + if (this.charactersRemaining() < 0) + throw new Error(`The message it's too long`); this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => { this.vnApp.showMessage(this.$translate.instant('SMS sent!')); diff --git a/modules/client/front/sms/index.spec.js b/modules/client/front/sms/index.spec.js index 26a597c174..03d9cbf1d9 100644 --- a/modules/client/front/sms/index.spec.js +++ b/modules/client/front/sms/index.spec.js @@ -15,6 +15,11 @@ describe('Client', () => { controller = $componentController('vnClientSms', {$element, $scope}); controller.client = {id: 101}; controller.$params = {id: 101}; + controller.$scope.message = { + input: { + value: 'My SMS' + } + }; })); describe('onResponse()', () => { @@ -56,14 +61,13 @@ describe('Client', () => { it('should return the characters remaining in a element', () => { controller.$scope.message = { input: { - textLength: 50 - }, - maxlength: 150 + value: 'My message 0€' + } }; let result = controller.charactersRemaining(); - expect(result).toEqual(100); + expect(result).toEqual(145); }); }); }); diff --git a/modules/client/front/sms/locale/es.yml b/modules/client/front/sms/locale/es.yml index 4438e4fce4..64c3fcca67 100644 --- a/modules/client/front/sms/locale/es.yml +++ b/modules/client/front/sms/locale/es.yml @@ -4,4 +4,6 @@ Message: Mensaje SMS sent!: ¡SMS enviado! Characters remaining: Carácteres restantes The destination can't be empty: El destinatario no puede estar vacio -The message can't be empty: El mensaje no puede estar vacio \ No newline at end of file +The message can't be empty: El mensaje no puede estar vacio +The message it's too long: El mensaje es demasiado largo +Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios \ No newline at end of file diff --git a/modules/ticket/front/sms/index.html b/modules/ticket/front/sms/index.html index f74bc29e5e..2003aa4fd4 100644 --- a/modules/ticket/front/sms/index.html +++ b/modules/ticket/front/sms/index.html @@ -18,15 +18,22 @@ vn-id="message" label="Message" ng-model="$ctrl.sms.message" + info="Special characters like accents counts as a multiple" rows="5" - maxlength="160" required="true" rule> - {{'Characters remaining' | translate}}: {{$ctrl.charactersRemaining()}} + {{'Characters remaining' | translate}}: + + {{$ctrl.charactersRemaining()}} + diff --git a/modules/ticket/front/sms/index.js b/modules/ticket/front/sms/index.js index 0d639d46e2..ac11315132 100644 --- a/modules/ticket/front/sms/index.js +++ b/modules/ticket/front/sms/index.js @@ -17,13 +17,12 @@ class Controller extends Component { } charactersRemaining() { - let elementMaxLength; - let textAreaLength; const element = this.$scope.message; + const value = element.input.value; - textAreaLength = element.input.textLength; - elementMaxLength = element.maxlength; - return elementMaxLength - textAreaLength; + const maxLength = 160; + const textAreaLength = new Blob([value]).size; + return maxLength - textAreaLength; } onResponse(response) { @@ -33,6 +32,8 @@ class Controller extends Component { throw new Error(`The destination can't be empty`); if (!this.sms.message) throw new Error(`The message can't be empty`); + if (this.charactersRemaining() < 0) + throw new Error(`The message it's too long`); this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => { this.vnApp.showMessage(this.$translate.instant('SMS sent!')); diff --git a/modules/ticket/front/sms/index.spec.js b/modules/ticket/front/sms/index.spec.js index d02b3f3eb6..96c10edd10 100644 --- a/modules/ticket/front/sms/index.spec.js +++ b/modules/ticket/front/sms/index.spec.js @@ -14,6 +14,11 @@ describe('Ticket', () => { $element = angular.element(''); controller = $componentController('vnTicketSms', {$element, $scope}); controller.$params = {id: 11}; + controller.$scope.message = { + input: { + value: 'My SMS' + } + }; })); describe('onResponse()', () => { @@ -55,14 +60,13 @@ describe('Ticket', () => { it('should return the characters remaining in a element', () => { controller.$scope.message = { input: { - textLength: 50 - }, - maxlength: 150 + value: 'My message 0€' + } }; let result = controller.charactersRemaining(); - expect(result).toEqual(100); + expect(result).toEqual(145); }); }); }); diff --git a/modules/ticket/front/sms/locale/es.yml b/modules/ticket/front/sms/locale/es.yml index 4438e4fce4..64c3fcca67 100644 --- a/modules/ticket/front/sms/locale/es.yml +++ b/modules/ticket/front/sms/locale/es.yml @@ -4,4 +4,6 @@ Message: Mensaje SMS sent!: ¡SMS enviado! Characters remaining: Carácteres restantes The destination can't be empty: El destinatario no puede estar vacio -The message can't be empty: El mensaje no puede estar vacio \ No newline at end of file +The message can't be empty: El mensaje no puede estar vacio +The message it's too long: El mensaje es demasiado largo +Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios \ No newline at end of file From 4e2ab537ee287c0c81f435464ed8b4bf311dcc12 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Fri, 14 Feb 2020 14:52:47 +0100 Subject: [PATCH 11/55] unstable with the rest of tests --- e2e/helpers/extensions.js | 23 ++++++------- e2e/helpers/selectors.js | 10 ++++++ e2e/paths/04-item/13_request.spec.js | 48 +++++++++++++++++++++++++++ modules/item/front/request/index.html | 2 +- 4 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 e2e/paths/04-item/13_request.spec.js diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 816eea0643..32c531f7cc 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -179,6 +179,13 @@ let actions = { await this.click(selector); }, + writeOnEditableTD: async function(selector, text) { + let builtSelector = await this.selectorFormater(selector); + await this.waitToClick(selector); + await this.type(builtSelector, text); + await this.keyboard.press('Enter'); + }, + focusElement: async function(selector) { await this.wait(selector); return await this.evaluate(selector => { @@ -284,22 +291,14 @@ let actions = { }, {}, selector, text); }, - selectorFormater: async function(selector) { - let builtSelector = `${selector} input`; - - if (selector.includes('vn-autocomplete')) - return builtSelector = `${selector} input`; - + selectorFormater: function(selector) { if (selector.includes('vn-textarea')) - return builtSelector = `${selector} textarea`; - - if (selector.includes('vn-textfield')) - return builtSelector = `${selector} input`; + return `${selector} textarea`; if (selector.includes('vn-input-file')) - return builtSelector = `${selector} section`; + return `${selector} section`; - return builtSelector; + return `${selector} input`; }, waitForTextInField: async function(selector, text) { diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 63d40f9d5b..16a9bb3991 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -250,6 +250,16 @@ export default { inactiveIcon: 'vn-item-descriptor vn-icon[icon="icon-unavailable"]', navigateBackToIndex: 'vn-item-descriptor vn-icon[icon="chevron_left"]' }, + itemRequest: { + firstRequestItemID: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td-editable:nth-child(7)', + firstRequestQuantity: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td-editable:nth-child(8)', + firstRequestConcept: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(9)', + firstRequestStatus: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(10)', + firstRequestDecline: 'vn-item-request vn-tbody > vn-tr:nth-child(1) vn-icon-button[icon="thumb_down"]', + declineReason: 'vn-textarea[ng-model="$ctrl.denyObservation"]', + acceptDeclineReason: 'button[response="accept"]', + + }, itemBasicData: { basicDataButton: 'vn-left-menu a[ui-sref="item.card.basicData"]', goToItemIndexButton: 'vn-item-descriptor [ui-sref="item.index"]', diff --git a/e2e/paths/04-item/13_request.spec.js b/e2e/paths/04-item/13_request.spec.js new file mode 100644 index 0000000000..9e53e300ae --- /dev/null +++ b/e2e/paths/04-item/13_request.spec.js @@ -0,0 +1,48 @@ +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() => { + const result = await page.expectURL('/item/request'); + + expect(result).toBe(true); + }); + + 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 1x0.5m'); + let filledConcept = await page.waitToGetProperty(selectors.itemRequest.firstRequestConcept, 'innerText'); + + expect(filledConcept).toContain('Melee weapon heavy shield 1x0.5m'); + }); + + it('should the status of the request should now be accepted', async() => { + let status = await page.waitToGetProperty(selectors.itemRequest.firstRequestStatus, 'innerText'); + + expect(status).toContain('Aceptada'); + }); + + it('should now click on the first declain request icon then type the reason', async() => { + await page.waitToClick(selectors.itemRequest.firstRequestDecline); + await page.write(selectors.itemRequest.declineReason, 'not quite as expected'); + await page.waitToClick(selectors.itemRequest.acceptDeclineReason); + await page.waitForContentLoaded(); + let status = await page.waitToGetProperty(selectors.itemRequest.firstRequestStatus, 'innerText'); + + expect(status).toContain('Denegada'); + }); +}); diff --git a/modules/item/front/request/index.html b/modules/item/front/request/index.html index e0cf05107d..3216e05e16 100644 --- a/modules/item/front/request/index.html +++ b/modules/item/front/request/index.html @@ -85,7 +85,7 @@ Date: Mon, 17 Feb 2020 07:22:55 +0100 Subject: [PATCH 12/55] Added form dialog --- modules/item/back/methods/item/getCard.js | 3 + modules/item/back/models/item.json | 112 +++++++++++----------- modules/item/front/basic-data/index.html | 46 ++++++++- modules/item/front/basic-data/index.js | 22 +++-- 4 files changed, 115 insertions(+), 68 deletions(-) diff --git a/modules/item/back/methods/item/getCard.js b/modules/item/back/methods/item/getCard.js index 9780c5601e..50ff22321d 100644 --- a/modules/item/back/methods/item/getCard.js +++ b/modules/item/back/methods/item/getCard.js @@ -55,6 +55,9 @@ module.exports = Self => { } }] } + }, + { + relation: 'taxClass' } ] }; diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index d8d1cb64d1..dbaa3a4090 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -1,13 +1,13 @@ { "name": "Item", - "base": "Loggable", - "log": { - "model":"ItemLog", + "base": "Loggable", + "log": { + "model": "ItemLog", "showField": "id" - }, + }, "options": { "mysql": { - "table": "item" + "table": "item" } }, "properties": { @@ -125,55 +125,55 @@ } }, "relations": { - "itemType": { - "type": "belongsTo", - "model": "ItemType", - "foreignKey": "typeFk" - }, - "ink": { - "type": "belongsTo", - "model": "Ink", - "foreignKey": "inkFk" - }, - "origin": { - "type": "belongsTo", - "model": "Origin", - "foreignKey": "originFk" - }, - "producer": { - "type": "belongsTo", - "model": "Producer", - "foreignKey": "producerFk" - }, - "intrastat": { - "type": "belongsTo", - "model": "Intrastat", - "foreignKey": "intrastatFk" - }, - "expense": { - "type": "belongsTo", - "model": "Expense", - "foreignKey": "expenseFk" - }, - "tags": { - "type": "hasMany", - "model": "ItemTag", - "foreignKey": "itemFk" - }, - "itemBarcode": { - "type": "hasMany", - "model": "ItemBarcode", - "foreignKey": "itemFk" - }, - "taxes": { - "type": "hasMany", - "model": "ItemTaxCountry", - "foreignKey": "itemFk" - }, - "itemNiche": { - "type": "hasMany", - "model": "ItemNiche", - "foreignKey": "itemFk" - } + "itemType": { + "type": "belongsTo", + "model": "ItemType", + "foreignKey": "typeFk" + }, + "ink": { + "type": "belongsTo", + "model": "Ink", + "foreignKey": "inkFk" + }, + "origin": { + "type": "belongsTo", + "model": "Origin", + "foreignKey": "originFk" + }, + "producer": { + "type": "belongsTo", + "model": "Producer", + "foreignKey": "producerFk" + }, + "intrastat": { + "type": "belongsTo", + "model": "Intrastat", + "foreignKey": "intrastatFk" + }, + "expense": { + "type": "belongsTo", + "model": "Expense", + "foreignKey": "expenseFk" + }, + "tags": { + "type": "hasMany", + "model": "ItemTag", + "foreignKey": "itemFk" + }, + "itemBarcode": { + "type": "hasMany", + "model": "ItemBarcode", + "foreignKey": "itemFk" + }, + "taxes": { + "type": "hasMany", + "model": "ItemTaxCountry", + "foreignKey": "itemFk" + }, + "itemNiche": { + "type": "hasMany", + "model": "ItemNiche", + "foreignKey": "itemFk" + } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html index bd0cec86de..16d37ff044 100644 --- a/modules/item/front/basic-data/index.html +++ b/modules/item/front/basic-data/index.html @@ -55,6 +55,13 @@
{{::id}}
{{::description}}
+ + + + - + @@ -134,3 +141,38 @@ + + + + +
New intrastat
+ + + + + + + + + + +
+ + + + +
\ No newline at end of file diff --git a/modules/item/front/basic-data/index.js b/modules/item/front/basic-data/index.js index 123aa59cdc..3c3d62c747 100644 --- a/modules/item/front/basic-data/index.js +++ b/modules/item/front/basic-data/index.js @@ -1,20 +1,22 @@ import ngModule from '../module'; +import Component from 'core/lib/component'; +class Controller extends Component { + showIntrastat(event) { + if (event.defaultPrevented) return; + event.preventDefault(); -class Controller { - constructor($scope, $timeout) { - this.$scope = $scope; - this.$timeout = $timeout; + this.newIntrastat = { + taxClassFk: this.item.taxClassFk + }; + this.$.intrastat.show(); } - $onChanges(data) { - this.$timeout(() => { - this.$scope.watcher.data = data.item.currentValue; - }); + onCustomAgentAccept() { + return this.$http.post(`CustomsAgents`, this.newCustomsAgent) + .then(res => this.address.customsAgentFk = res.data.id); } } -Controller.$inject = ['$scope', '$timeout']; - ngModule.component('vnItemBasicData', { template: require('./index.html'), bindings: { From 578556b1d553403d16ac679bc777275ba54d9e5e Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 17 Feb 2020 08:38:19 +0100 Subject: [PATCH 13/55] 2121 - Client balance fix balance on pagination --- modules/client/front/balance/index/index.html | 6 +-- modules/client/front/balance/index/index.js | 13 +++++- .../client/front/balance/index/index.spec.js | 43 +++++++++++++++++++ 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/modules/client/front/balance/index/index.html b/modules/client/front/balance/index/index.html index f42998bbd9..8cdb5c9712 100644 --- a/modules/client/front/balance/index/index.html +++ b/modules/client/front/balance/index/index.html @@ -85,9 +85,9 @@
{{::balance.bankFk}} - {{::balance.debit | currency: 'EUR':2}} - {{::balance.credit | currency: 'EUR':2}} - {{balance.balance | currency: 'EUR':2}} + {{::balance.debit | currency: 'EUR':2}} + {{::balance.credit | currency: 'EUR':2}} + {{balance.balance | currency: 'EUR':2}} { expect(expectedBalances[2].balance).toEqual(213.24); }); }); + + describe('balances() setter', () => { + it('should set the balances data and not call the getBalances() method', () => { + spyOn(controller, 'getBalances'); + controller.$.riskModel.data = null; + controller.balances = [{ + id: 1, + debit: 1000, + credit: null + }, { + id: 2, + debit: null, + credit: 500 + }, { + id: 3, + debit: null, + credit: 300 + }]; + + expect(controller.balances).toBeDefined(); + expect(controller.getBalances).not.toHaveBeenCalledWith(); + }); + + it('should set the balances data and then call the getBalances() method', () => { + spyOn(controller, 'getBalances'); + controller.balances = [{ + id: 1, + debit: 1000, + credit: null + }, { + id: 2, + debit: null, + credit: 500 + }, { + id: 3, + debit: null, + credit: 300 + }]; + + expect(controller.balances).toBeDefined(); + expect(controller.getBalances).toHaveBeenCalledWith(); + }); + }); }); }); From 03f0a415f9f0c79cbc217ed8925f73b531c2cb83 Mon Sep 17 00:00:00 2001 From: jgallego Date: Mon, 17 Feb 2020 12:01:11 +0100 Subject: [PATCH 14/55] zoneClosure fase 2 --- db/changes/10141-zoneDoCalc/00-ticket.sql | 4 +- .../01-zoneClosure_recalc.sql | 1 - .../10141-zoneDoCalc/02-insertPastTickets.sql | 62 +++++++ .../03-getOptionsForLanding.sql | 66 +++++++ .../10141-zoneDoCalc/03-rutasAnalyze.sql | 171 ++++++++++++++++++ db/changes/10141-zoneDoCalc/03-saleVolume.sql | 26 +++ .../10141-zoneDoCalc/03-viewSaleFreight__.sql | 24 +++ .../03-zone_geShippedWarehouse.sql | 41 +++++ .../10141-zoneDoCalc/03-zone_getAgency.sql | 42 +++++ .../10141-zoneDoCalc/03-zone_getAvailable.sql | 18 ++ .../10141-zoneDoCalc/03-zone_getWarehouse.sql | 41 +++++ 11 files changed, 493 insertions(+), 3 deletions(-) delete mode 100644 db/changes/10141-zoneDoCalc/01-zoneClosure_recalc.sql create mode 100644 db/changes/10141-zoneDoCalc/02-insertPastTickets.sql create mode 100644 db/changes/10141-zoneDoCalc/03-getOptionsForLanding.sql create mode 100644 db/changes/10141-zoneDoCalc/03-rutasAnalyze.sql create mode 100644 db/changes/10141-zoneDoCalc/03-saleVolume.sql create mode 100644 db/changes/10141-zoneDoCalc/03-viewSaleFreight__.sql create mode 100644 db/changes/10141-zoneDoCalc/03-zone_geShippedWarehouse.sql create mode 100644 db/changes/10141-zoneDoCalc/03-zone_getAgency.sql create mode 100644 db/changes/10141-zoneDoCalc/03-zone_getAvailable.sql create mode 100644 db/changes/10141-zoneDoCalc/03-zone_getWarehouse.sql diff --git a/db/changes/10141-zoneDoCalc/00-ticket.sql b/db/changes/10141-zoneDoCalc/00-ticket.sql index c116e51399..a756a11afe 100644 --- a/db/changes/10141-zoneDoCalc/00-ticket.sql +++ b/db/changes/10141-zoneDoCalc/00-ticket.sql @@ -3,9 +3,9 @@ ADD COLUMN `zonePrice` DECIMAL(10,2) NULL DEFAULT NULL AFTER `collectionFk`, ADD COLUMN `zoneBonus` DECIMAL(10,2) NULL DEFAULT NULL AFTER `zonePrice`, ADD COLUMN `zoneClosure` TIME NULL AFTER `zoneBonus`; -CREATE TABLE vn.`zoneCalcTicket` ( +CREATE TABLE `vn`.`zoneCalcTicket` ( `zoneFk` int(11) NOT NULL PRIMARY KEY, - CONSTRAINT `zoneCalcTicketfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `zoneCalcTicketfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `vn`.`zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; DROP EVENT IF EXISTS vn.`zone_doCalc`; diff --git a/db/changes/10141-zoneDoCalc/01-zoneClosure_recalc.sql b/db/changes/10141-zoneDoCalc/01-zoneClosure_recalc.sql deleted file mode 100644 index f015eb894b..0000000000 --- a/db/changes/10141-zoneDoCalc/01-zoneClosure_recalc.sql +++ /dev/null @@ -1 +0,0 @@ -USE `vn`; diff --git a/db/changes/10141-zoneDoCalc/02-insertPastTickets.sql b/db/changes/10141-zoneDoCalc/02-insertPastTickets.sql new file mode 100644 index 0000000000..4314e5d7d9 --- /dev/null +++ b/db/changes/10141-zoneDoCalc/02-insertPastTickets.sql @@ -0,0 +1,62 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_doCalcInitialize`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_doCalcInitialize`() +proc: BEGIN +/** + * Initialize ticket + */ + DECLARE vDone BOOL; + DECLARE vTicketFk INT; + DECLARE vLanded DATE; + DECLARE vZoneFk INT; + + DECLARE cCur CURSOR FOR + SELECT t.id, t.landed, t.zoneFk + FROM ticket t + WHERE (zonePrice IS NULL OR zoneBonus IS NULL OR zoneClosure IS NULL) + AND landed >= '2019-01-01' AND shipped >= '2019-01-01' + GROUP BY landed, zoneFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cCur; + + myLoop: LOOP + SET vDone = FALSE; + FETCH cCur INTO vTicketFk, vLanded, vZoneFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + DROP TEMPORARY TABLE IF EXISTS tmp.zone; + CREATE TEMPORARY TABLE tmp.zone + (INDEX (id)) + ENGINE = MEMORY + SELECT vZoneFk id; + + CALL zone_getOptionsForLanding(vLanded, TRUE); + + UPDATE ticket t + LEFT JOIN tmp.zoneOption zo ON TRUE + SET zonePrice = zo.price, zoneBonus = zo.bonus, zoneClosure = zo.`hour` + WHERE t.zoneFk = vZoneFk AND landed = vLanded; + + UPDATE ticket t + LEFT JOIN vn.zone z ON z.id = t.zoneFk + SET zonePrice = z.price, zoneBonus = z.bonus, zoneClosure = z.`hour` + WHERE t.zonePrice IS NULL AND z.id = vZoneFk + AND landed >= '2019-01-01' AND shipped >= '2019-01-01'; + + END LOOP; + + CLOSE cCur; + + DELETE FROM zoneCalcTicket; +END$$ + +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10141-zoneDoCalc/03-getOptionsForLanding.sql b/db/changes/10141-zoneDoCalc/03-getOptionsForLanding.sql new file mode 100644 index 0000000000..e0f5f9a48b --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-getOptionsForLanding.sql @@ -0,0 +1,66 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getOptionsForLanding`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE, vShowExpiredZones BOOLEAN) +BEGIN +/** + * Gets computed options for the passed zones and delivery date. + * + * @table tmp.zones(id) The zones ids + * @param vLanded The delivery date + * @return tmp.zoneOption The computed options + */ + DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; + CREATE TEMPORARY TABLE tmp.zoneOption + ENGINE = MEMORY + SELECT + zoneFk, + `hour`, + travelingDays, + price, + bonus, + TIMESTAMPADD(DAY, -travelingDays, vLanded) shipped + FROM ( + SELECT t.id zoneFk, + TIME(IFNULL(e.`hour`, z.`hour`)) `hour`, + IFNULL(e.travelingDays, z.travelingDays) travelingDays, + IFNULL(e.price, z.price) price, + IFNULL(e.bonus, z.bonus) bonus + FROM tmp.zone t + JOIN zone z ON z.id = t.id + JOIN zoneEvent e ON e.zoneFk = t.id + WHERE ( + e.`type` = 'day' + AND e.dated = vLanded + ) OR ( + e.`type` != 'day' + AND e.weekDays & (1 << WEEKDAY(vLanded)) + AND (e.`started` IS NULL OR vLanded >= e.`started`) + AND (e.`ended` IS NULL OR vLanded <= e.`ended`) + ) + ORDER BY + zoneFk, + CASE + WHEN e.`type` = 'day' + THEN 1 + WHEN e.`type` = 'range' + THEN 2 + ELSE 3 + END + ) t + GROUP BY zoneFk; + + DELETE t FROM tmp.zoneOption t + JOIN zoneExclusion e + ON e.zoneFk = t.zoneFk AND e.`dated` = vLanded; + + IF NOT vShowExpiredZones THEN + DELETE FROM tmp.zoneOption + WHERE shipped < CURDATE() + OR (shipped = CURDATE() AND CURTIME() > `hour`); + END IF; +END$$ + +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10141-zoneDoCalc/03-rutasAnalyze.sql b/db/changes/10141-zoneDoCalc/03-rutasAnalyze.sql new file mode 100644 index 0000000000..313f2f797a --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-rutasAnalyze.sql @@ -0,0 +1,171 @@ +USE `vn`; +DROP procedure IF EXISTS `rutasAnalyze`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `rutasAnalyze`(vYear INT, vMonth INT) +BEGIN + +/* Analiza los costes de las rutas de reparto y lo almacena en la tabla Rutas_Master +* +* PAK 15/4/2019 +*/ + + DELETE FROM bi.rutasBoard + WHERE year = vYear AND month = vMonth; + + -- Rellenamos la tabla con los datos de las rutas VOLUMETRICAS, especialmente con los bultos "virtuales" + INSERT INTO bi.rutasBoard(year, + month, + warehouse_id, + Id_Ruta, + Id_Agencia, + km, + Dia, + Fecha, + Bultos, + Matricula, + Tipo, + Terceros) + SELECT YEAR(r.created), + MONTH(r.created), + GREATEST(1,a.warehouseFk), + r.id, + r.agencyModeFk, + r.kmEnd - r.kmStart, + DAYNAME(r.created), + r.created, + SUM(sv.volume / ebv.m3), + v.numberPlate, + IF(ISNULL(`r`.`cost`), 'P', 'A'), + r.cost + FROM vn.route r + JOIN vn.ticket t ON t.routeFk = r.id + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN vn.agency a ON a.id = am.agencyFk + LEFT JOIN vn.vehicle v ON v.id = r.vehicleFk + JOIN vn.saleVolume sv ON sv.ticketFk = t.id + JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = 71 + WHERE YEAR(r.created) = vYear AND MONTH(r.created) = vMonth + AND z.isVolumetric + GROUP BY r.id; + + -- Rellenamos la tabla con los datos de las rutas NO VOLUMETRICAS, especialmente con los bultos "virtuales" + INSERT INTO bi.rutasBoard(year, + month, + warehouse_id, + Id_Ruta, + Id_Agencia, + km, + Dia, + Fecha, + Bultos, + Matricula, + Tipo, + Terceros) + SELECT YEAR(r.created), + MONTH(r.created), + GREATEST(1,a.warehouseFk), + r.id, + r.agencyModeFk, + r.kmEnd - r.kmStart, + DAYNAME(r.created), + r.created, + SUM(t.packages), + v.numberPlate, + IF(ISNULL(`r`.`cost`), 'P', 'A'), + r.cost + FROM vn.route r + JOIN vn.ticket t ON t.routeFk = r.id + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN vn.agency a ON a.id = am.agencyFk + LEFT JOIN vn.vehicle v ON v.id = r.vehicleFk + WHERE YEAR(r.created) = vYear AND MONTH(r.created) = vMonth + AND z.isVolumetric = FALSE + GROUP BY r.id + ON DUPLICATE KEY UPDATE Bultos = Bultos + VALUES(Bultos); + + -- Coste REAL de cada bulto "virtual", de acuerdo con el valor apuntado a mano en la ruta + UPDATE bi.rutasBoard r + INNER JOIN vn2008.Rutas_Master rm ON rm.año = r.year AND rm.mes = r.month AND rm.warehouse_id = r.warehouse_id + SET r.coste_bulto = IF(r.Tipo ='A', r.Terceros, r.km * rm.coste_km ) / r.Bultos + WHERE r.Bultos > 0 + AND rm.año = vYear + AND rm.mes = vMonth; + + -- Coste PRACTICO de cada bulto, de acuerdo con los componentes de tipo AGENCIA en cada linea de venta + UPDATE bi.rutasBoard r + JOIN ( + SELECT t.routeFk, sum(s.quantity * sc.value) practicoTotal + FROM vn.route r + JOIN vn.time tm ON tm.dated = r.created + JOIN vn.ticket t ON t.routeFk = r.id + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.saleComponent sc ON sc.saleFk = s.id + JOIN vn.`component` c ON c.id = sc.componentFk + JOIN vn.componentType ct ON ct.id = c.typeFk + WHERE ct.type = 'agencia' + AND tm.year = vYear + AND tm.month = vMonth + GROUP BY r.id + ) sub ON sub.routeFk = r.Id_Ruta + SET r.practico = sub.practicoTotal / r.Bultos; + + -- Coste TEORICO de una caja "virtual" para cada ruta, teniendo en cuenta que hay carros, pallets, etc + UPDATE bi.rutasBoard r + JOIN ( + SELECT t.routeFk, + SUM(t.zonePrice/ ebv.ratio)/ count(*) AS BultoTeoricoMedio + FROM vn.ticket t + JOIN vn.route r ON r.id = t.routeFk + JOIN vn.time tm ON tm.dated = r.created + JOIN vn.expedition e ON e.ticketFk = t.id + JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.isBox + JOIN vn.address ad ON ad.id = t.addressFk + JOIN vn.client c ON c.id = ad.clientFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + WHERE tm.year = vYear + AND tm.month = vMonth + AND z.isVolumetric = FALSE + GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk + SET r.teorico = sub.BultoTeoricoMedio; + + -- Coste VOLUMETRICO TEORICO de una caja "virtual" para cada ruta + UPDATE bi.rutasBoard r + JOIN ( + SELECT t.routeFk, + SUM(freight) AS BultoTeoricoMedio + FROM vn.ticket t + JOIN vn.route r ON r.id = t.routeFk + JOIN vn.time tm ON tm.dated = r.created + JOIN vn.saleVolume sf ON sf.ticketFk = t.id + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.zone z ON z.id = t.zoneFk + WHERE tm.year = vYear + AND tm.month = vMonth + AND z.isVolumetric != FALSE + GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk + SET r.teorico = sub.BultoTeoricoMedio / r.Bultos; + + -- La diferencia entre el teorico y el practico se deberia de cobrar en greuges, cada noche + UPDATE bi.rutasBoard r + JOIN ( + SELECT t.routeFk, + Sum(g.amount) AS greuge + FROM vn.ticket t + JOIN vn.route r ON r.id = t.routeFk + JOIN vn.time tm ON tm.dated = r.created + JOIN vn.greuge g ON g.ticketFk = t.id + JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk + WHERE tm.year = vYear + AND tm.month = vMonth + AND gt.name = 'Diferencia portes' + GROUP BY t.routeFk) sub ON r.Id_Ruta = sub.routeFk + SET r.greuge = sub.greuge / r.Bultos; + +END$$ + +DELIMITER ; + diff --git a/db/changes/10141-zoneDoCalc/03-saleVolume.sql b/db/changes/10141-zoneDoCalc/03-saleVolume.sql new file mode 100644 index 0000000000..2ded49a8d3 --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-saleVolume.sql @@ -0,0 +1,26 @@ +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `saleVolume` AS + SELECT + `s`.`ticketFk` AS `ticketFk`, + `s`.`id` AS `saleFk`, + IFNULL(ROUND(((((`i`.`compression` * (GREATEST(`i`.`density`, 167) / 167)) * `ic`.`cm3`) * `s`.`quantity`) / 1000), + 2), + 0) AS `litros`, + `t`.`routeFk` AS `routeFk`, + `t`.`shipped` AS `shipped`, + (((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`, + ((((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) * (GREATEST(`i`.`density`, 167) / 167)) / 1000000) AS `physicalWeight`, + (((`s`.`quantity` * `ic`.`cm3`) * `i`.`density`) / 1000000) AS `weight`, + (((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume`, + ((((`s`.`quantity` * `ic`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight` + FROM + ((((`sale` `s` + JOIN `item` `i` ON ((`i`.`id` = `s`.`itemFk`))) + JOIN `ticket` `t` ON ((`t`.`id` = `s`.`ticketFk`))) + JOIN `packaging` `cb` ON ((`cb`.`id` = '94'))) + JOIN `itemCost` `ic` ON (((`ic`.`itemFk` = `s`.`itemFk`) + AND (`ic`.`warehouseFk` = `t`.`warehouseFk`)))); diff --git a/db/changes/10141-zoneDoCalc/03-viewSaleFreight__.sql b/db/changes/10141-zoneDoCalc/03-viewSaleFreight__.sql new file mode 100644 index 0000000000..903c8b48ac --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-viewSaleFreight__.sql @@ -0,0 +1,24 @@ +DROP VIEW IF EXISTS `vn`.`saleFreight` ; +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `saleFreight__` AS + SELECT + `s`.`ticketFk` AS `ticketFk`, + `t`.`clientFk` AS `clientFk`, + `t`.`routeFk` AS `routeFk`, + `s`.`id` AS `saleFk`, + `t`.`zoneFk` AS `zoneFk`, + `t`.`companyFk` AS `companyFk`, + `t`.`shipped` AS `shipped`, + `t`.`zonePrice` AS `price`, + ((((`s`.`quantity` * `r`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight` + FROM + ((((`vn`.`sale` `s` + JOIN `vn`.`item` `i` ON ((`i`.`id` = `s`.`itemFk`))) + JOIN `vn`.`ticket` `t` ON ((`t`.`id` = `s`.`ticketFk`))) + JOIN `vn`.`packaging` `cb` ON ((`cb`.`id` = '94'))) + JOIN `bi`.`rotacion` `r` ON (((`r`.`Id_Article` = `s`.`itemFk`) + AND (`r`.`warehouse_id` = `t`.`warehouseFk`)))); diff --git a/db/changes/10141-zoneDoCalc/03-zone_geShippedWarehouse.sql b/db/changes/10141-zoneDoCalc/03-zone_geShippedWarehouse.sql new file mode 100644 index 0000000000..14d5d8cd9a --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-zone_geShippedWarehouse.sql @@ -0,0 +1,41 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getShippedWarehouse`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) +BEGIN +/** + * Devuelve la mínima fecha de envío para cada warehouse + * + * @param vLanded La fecha de recepcion + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id de la agencia + * @return tmp.zoneGetShipped + */ + + CALL zone_getFromGeo(address_getGeo(vAddressFk)); + CALL zone_getOptionsForLanding(vLanded,TRUE); + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped; + CREATE TEMPORARY TABLE tmp.zoneGetShipped + ENGINE = MEMORY + SELECT * FROM ( + SELECT zo.zoneFk, + TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped, + zo.`hour`, + zw.warehouseFk, + z.agencyModeFk + FROM tmp.zoneOption zo + JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk + JOIN zone z ON z.id = zo.zoneFk + WHERE z.agencyModeFk = vAgencyModeFk + ORDER BY shipped) t + GROUP BY warehouseFk; + + DROP TEMPORARY TABLE + tmp.zone, + tmp.zoneOption; +END$$ + +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10141-zoneDoCalc/03-zone_getAgency.sql b/db/changes/10141-zoneDoCalc/03-zone_getAgency.sql new file mode 100644 index 0000000000..b2837d43cd --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-zone_getAgency.sql @@ -0,0 +1,42 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getAgency`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getAgency`(vAddress INT, vLanded DATE) +BEGIN +/** + * Devuelve el listado de agencias disponibles para la fecha + * y dirección pasadas. + * + * @param vAddress Id de dirección de envío, %NULL si es recogida + * @param vLanded Fecha de recogida + * @select Listado de agencias disponibles + */ + + CALL zone_getFromGeo(address_getGeo(vAddress)); + CALL zone_getOptionsForLanding(vLanded, FALSE); + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetAgency; + CREATE TEMPORARY TABLE tmp.zoneGetAgency + (INDEX (agencyModeFk)) ENGINE = MEMORY + SELECT am.name agencyMode, + am.description, + z.agencyModeFk, + am.deliveryMethodFk, + TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped, + TRUE isIncluded, + zo.zoneFk + FROM tmp.zoneOption zo + JOIN zone z ON z.id = zo.zoneFk + JOIN agencyMode am ON am.id = z.agencyModeFk + GROUP BY agencyModeFk; + + DROP TEMPORARY TABLE + tmp.zone, + tmp.zoneOption; + +END$$ + +DELIMITER ; + diff --git a/db/changes/10141-zoneDoCalc/03-zone_getAvailable.sql b/db/changes/10141-zoneDoCalc/03-zone_getAvailable.sql new file mode 100644 index 0000000000..2ef1a1ae96 --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-zone_getAvailable.sql @@ -0,0 +1,18 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getAvailable`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getAvailable`(vAddress INT, vLanded DATE) +BEGIN + CALL zone_getFromGeo(address_getGeo(vAddress)); + CALL zone_getOptionsForLanding(vLanded, FALSE); + + SELECT * FROM tmp.zoneOption; + + DROP TEMPORARY TABLE + tmp.zone, + tmp.zoneOption; +END$$ + +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10141-zoneDoCalc/03-zone_getWarehouse.sql b/db/changes/10141-zoneDoCalc/03-zone_getWarehouse.sql new file mode 100644 index 0000000000..c1cea8b136 --- /dev/null +++ b/db/changes/10141-zoneDoCalc/03-zone_getWarehouse.sql @@ -0,0 +1,41 @@ +USE `vn`; +DROP procedure IF EXISTS `zone_getWarehouse`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT) +BEGIN +/** + * Devuelve el listado de agencias disponibles para la fecha, + * dirección y almacén pasados. + * + * @param vAddress + * @param vWarehouse warehouse + * @param vLanded Fecha de recogida + * @select Listado de agencias disponibles + */ + + CALL zone_getFromGeo(address_getGeo(vAddress)); + CALL zone_getOptionsForLanding(vLanded, FALSE); + + SELECT am.id agencyModeFk, + am.name agencyMode, + am.description, + am.deliveryMethodFk, + TIMESTAMPADD(DAY, -zo.travelingDays, vLanded) shipped, + zw.warehouseFk, + z.id zoneFk + FROM tmp.zoneOption zo + JOIN zone z ON z.id = zo.zoneFk + JOIN agencyMode am ON am.id = z.agencyModeFk + JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk + WHERE zw.warehouseFk + GROUP BY z.agencyModeFk + ORDER BY agencyMode; + + DROP TEMPORARY TABLE + tmp.zone, + tmp.zoneOption; +END$$ + +DELIMITER ; \ No newline at end of file From 844b27acb9511c5400f094640a47388c78104111 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 17 Feb 2020 12:47:03 +0100 Subject: [PATCH 15/55] 2118 - Create new intrastat --- db/changes/10160-postValentineDay/00-ACL.sql | 2 + .../00-taxClassCode.sql | 23 +++++++ db/dump/fixtures.sql | 8 ++- e2e/helpers/selectors.js | 4 ++ e2e/paths/04-item/02_basic_data.spec.js | 24 +++++++- .../item/back/methods/item/createIntrastat.js | 61 +++++++++++++++++++ modules/item/back/methods/item/getCard.js | 3 - .../item/specs/createIntrastat.spec.js | 22 +++++++ modules/item/back/model-config.json | 3 + modules/item/back/models/item.js | 1 + modules/item/back/models/tax-class-code.json | 47 ++++++++++++++ .../__snapshots__/index.spec.js.snap | 3 - modules/item/front/basic-data/index.html | 18 ++---- modules/item/front/basic-data/index.js | 7 ++- 14 files changed, 201 insertions(+), 25 deletions(-) create mode 100644 db/changes/10160-postValentineDay/00-ACL.sql create mode 100644 db/changes/10160-postValentineDay/00-taxClassCode.sql create mode 100644 modules/item/back/methods/item/createIntrastat.js create mode 100644 modules/item/back/methods/item/specs/createIntrastat.spec.js create mode 100644 modules/item/back/models/tax-class-code.json delete mode 100644 modules/item/front/basic-data/__snapshots__/index.spec.js.snap diff --git a/db/changes/10160-postValentineDay/00-ACL.sql b/db/changes/10160-postValentineDay/00-ACL.sql new file mode 100644 index 0000000000..5b6301e3df --- /dev/null +++ b/db/changes/10160-postValentineDay/00-ACL.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES ('Intrastat', '*', '*', 'ALLOW', 'ROLE', 'buyer'); diff --git a/db/changes/10160-postValentineDay/00-taxClassCode.sql b/db/changes/10160-postValentineDay/00-taxClassCode.sql new file mode 100644 index 0000000000..bdc7cb474c --- /dev/null +++ b/db/changes/10160-postValentineDay/00-taxClassCode.sql @@ -0,0 +1,23 @@ +ALTER TABLE `vn`.`taxClassCode` +DROP FOREIGN KEY `taxClassCode_ibfk_2`, +DROP FOREIGN KEY `taxClassCode_ibfk_1`; +ALTER TABLE `vn`.`taxClassCode` +ADD COLUMN `id` INT NOT NULL AUTO_INCREMENT FIRST, +DROP PRIMARY KEY, +ADD PRIMARY KEY (`id`), +DROP INDEX `iva_codigo_id` ; + +ALTER TABLE `vn`.`taxClassCode` +ADD UNIQUE INDEX `taxClassCode_unique` (`taxClassFk` ASC, `effectived` ASC, `taxCodeFk` ASC) VISIBLE; + +ALTER TABLE `vn`.`taxClassCode` +ADD CONSTRAINT `taxClassCode_taxClassFk` + FOREIGN KEY (`taxClassFk`) + REFERENCES `vn`.`taxClass` (`id`) + ON DELETE RESTRICT + ON UPDATE CASCADE, +ADD CONSTRAINT `taxClassCode_taxCodeFk` + FOREIGN KEY (`taxCodeFk`) + REFERENCES `vn`.`taxCode` (`id`) + ON DELETE RESTRICT + ON UPDATE CASCADE; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index f3dd36976b..80bb377090 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -684,8 +684,14 @@ INSERT INTO `vn`.`taxCode`(`id`, `dated`, `code`, `taxTypeFk`, `rate`, `equaliza INSERT INTO `vn`.`taxClass`(`id`, `description`, `code`) VALUES - (1, 'Reduced VAT','R'), + (1, 'Reduced VAT', 'R'), (2, 'General VAT', 'G'); + +INSERT INTO `vn`.`taxClassCode`(`id`, `taxClassFk`, `effectived`, `taxCodeFk`) + VALUES + (1, 1, CURDATE(), 1), + (2, 1, CURDATE(), 21), + (3, 2, CURDATE(), 2); INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) VALUES diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 63d40f9d5b..1510ff8936 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -262,6 +262,10 @@ export default { longName: 'vn-textfield[ng-model="$ctrl.item.longName"]', isActiveCheckbox: 'vn-check[label="Active"]', priceInKgCheckbox: 'vn-check[label="Price in kg"]', + newIntrastatButton: 'vn-item-basic-data vn-icon-button[vn-tooltip="New intrastat"] > button', + newIntrastatId: '.vn-dialog.shown vn-input-number[ng-model="$ctrl.newIntrastat.intrastatId"]', + newIntrastatDescription: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newIntrastat.description"]', + acceptIntrastatButton: '.vn-dialog.shown button[response="accept"]', submitBasicDataButton: `button[type=submit]` }, itemTags: { diff --git a/e2e/paths/04-item/02_basic_data.spec.js b/e2e/paths/04-item/02_basic_data.spec.js index 2c8a8a7a10..64827ed9ba 100644 --- a/e2e/paths/04-item/02_basic_data.spec.js +++ b/e2e/paths/04-item/02_basic_data.spec.js @@ -39,6 +39,26 @@ describe('Item Edit basic data path', () => { expect(result).toEqual('Data saved!'); }, 20000); + it(`should create a new intrastat`, async() => { + await page.waitToClick(selectors.itemBasicData.newIntrastatButton); + await page.write(selectors.itemBasicData.newIntrastatId, '588420239'); + await page.write(selectors.itemBasicData.newIntrastatDescription, 'Tropical Flowers'); + await page.waitToClick(selectors.itemBasicData.acceptIntrastatButton); + await page.waitForTextInField(selectors.itemBasicData.intrastat, 'Tropical Flowers'); + let newcode = await page.waitToGetProperty(selectors.itemBasicData.intrastat, 'value'); + + expect(newcode).toEqual('588420239 Tropical Flowers'); + }); + + it(`should save with the new intrastat`, async() => { + await page.waitFor(250); + await page.waitForTextInField(selectors.itemBasicData.intrastat, 'Tropical Flowers'); + await page.waitToClick(selectors.itemBasicData.submitBasicDataButton); + const result = await page.waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + it(`should confirm the item name was edited`, async() => { await page.reloadSection('item.card.basicData'); const result = await page.waitToGetProperty(selectors.itemBasicData.name, 'value'); @@ -53,11 +73,11 @@ describe('Item Edit basic data path', () => { expect(result).toEqual('Anthurium'); }); - it(`should confirm the item intrastad was edited`, async() => { + it(`should confirm the item intrastat was edited`, async() => { const result = await page .waitToGetProperty(selectors.itemBasicData.intrastat, 'value'); - expect(result).toEqual('5080000 Coral y materiales similares'); + expect(result).toEqual('588420239 Tropical Flowers'); }); it(`should confirm the item relevancy was edited`, async() => { diff --git a/modules/item/back/methods/item/createIntrastat.js b/modules/item/back/methods/item/createIntrastat.js new file mode 100644 index 0000000000..1a88d16e25 --- /dev/null +++ b/modules/item/back/methods/item/createIntrastat.js @@ -0,0 +1,61 @@ +let UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethod('createIntrastat', { + description: 'Creates a new item intrastat', + accessType: 'WRITE', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The item id', + http: {source: 'path'} + }, + { + arg: 'intrastatId', + type: 'number', + required: true + }, + { + arg: 'description', + type: 'string', + required: true + }], + returns: { + type: 'boolean', + root: true + }, + http: { + path: `/:id/createIntrastat`, + verb: 'PATCH' + } + }); + + Self.createIntrastat = async(id, intrastatId, description) => { + const models = Self.app.models; + const country = await models.Country.findOne({ + where: {code: 'ES'} + }); + + const itemTaxCountry = await models.ItemTaxCountry.findOne({ + where: { + itemFk: id, + countryFk: country.id + }, + order: 'effectived DESC' + }); + const taxClassCode = await models.TaxClassCode.findOne({ + where: { + taxClassFk: itemTaxCountry.taxClassFk + }, + order: 'effectived DESC' + }); + + return models.Intrastat.create({ + id: intrastatId, + description: description, + taxClassFk: itemTaxCountry.taxClassFk, + taxCodeFk: taxClassCode.taxCodeFk + }); + }; +}; diff --git a/modules/item/back/methods/item/getCard.js b/modules/item/back/methods/item/getCard.js index 50ff22321d..9780c5601e 100644 --- a/modules/item/back/methods/item/getCard.js +++ b/modules/item/back/methods/item/getCard.js @@ -55,9 +55,6 @@ module.exports = Self => { } }] } - }, - { - relation: 'taxClass' } ] }; diff --git a/modules/item/back/methods/item/specs/createIntrastat.spec.js b/modules/item/back/methods/item/specs/createIntrastat.spec.js new file mode 100644 index 0000000000..fb10de858a --- /dev/null +++ b/modules/item/back/methods/item/specs/createIntrastat.spec.js @@ -0,0 +1,22 @@ +const app = require('vn-loopback/server/server'); + +describe('createIntrastat()', () => { + let newIntrastat; + + afterAll(async done => { + await app.models.Intrastat.destroyById(newIntrastat.id); + + done(); + }); + + it('should create a new intrastat', async() => { + const intrastatId = 588420239; + const description = 'Tropical Flowers'; + const itemId = 9; + newIntrastat = await app.models.Item.createIntrastat(itemId, intrastatId, description); + + expect(newIntrastat.description).toEqual(description); + expect(newIntrastat.taxClassFk).toEqual(1); + expect(newIntrastat.taxCodeFk).toEqual(21); + }); +}); diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index db8eed9d56..d8ec5914a1 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -62,6 +62,9 @@ "TaxClass": { "dataSource": "vn" }, + "TaxClassCode": { + "dataSource": "vn" + }, "TaxCode": { "dataSource": "vn" }, diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js index 6c221e94df..01061ce999 100644 --- a/modules/item/back/models/item.js +++ b/modules/item/back/models/item.js @@ -12,6 +12,7 @@ module.exports = Self => { require('../methods/item/getVisibleAvailable')(Self); require('../methods/item/new')(Self); require('../methods/item/getWasteDetail')(Self); + require('../methods/item/createIntrastat')(Self); Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'}); diff --git a/modules/item/back/models/tax-class-code.json b/modules/item/back/models/tax-class-code.json new file mode 100644 index 0000000000..efe6a13db8 --- /dev/null +++ b/modules/item/back/models/tax-class-code.json @@ -0,0 +1,47 @@ +{ + "name": "TaxClassCode", + "base": "VnModel", + "options": { + "mysql": { + "table": "taxClassCode" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "effectived": { + "type": "date", + "required": true + }, + "taxClassFk": { + "type": "number", + "required": true + }, + "taxCodeFk": { + "type": "number", + "required": true + } + }, + "relations": { + "taxClass": { + "type": "belongsTo", + "model": "TaxClass", + "foreignKey": "taxClassFk" + }, + "taxCode": { + "type": "belongsTo", + "model": "TaxCode", + "foreignKey": "taxCodeFk" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/modules/item/front/basic-data/__snapshots__/index.spec.js.snap b/modules/item/front/basic-data/__snapshots__/index.spec.js.snap deleted file mode 100644 index 92219bb339..0000000000 --- a/modules/item/front/basic-data/__snapshots__/index.spec.js.snap +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`vnItemBasicData Component vnItemBasicData $onChanges() should pass the data to the watcher 1`] = `"the current value of an item"`; diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html index 16d37ff044..3cd879945d 100644 --- a/modules/item/front/basic-data/index.html +++ b/modules/item/front/basic-data/index.html @@ -149,27 +149,19 @@
New intrastat
- - + + + - - - -
diff --git a/modules/item/front/basic-data/index.js b/modules/item/front/basic-data/index.js index 3c3d62c747..33a60b32d4 100644 --- a/modules/item/front/basic-data/index.js +++ b/modules/item/front/basic-data/index.js @@ -11,9 +11,10 @@ class Controller extends Component { this.$.intrastat.show(); } - onCustomAgentAccept() { - return this.$http.post(`CustomsAgents`, this.newCustomsAgent) - .then(res => this.address.customsAgentFk = res.data.id); + onIntrastatAccept() { + const query = `Items/${this.$params.id}/createIntrastat`; + return this.$http.patch(query, this.newIntrastat) + .then(res => this.item.intrastatFk = res.data.id); } } From 7d8e88e884a4f558f06ac1b7134696775db48976 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 17 Feb 2020 13:32:12 +0100 Subject: [PATCH 16/55] Updated unit test --- modules/item/front/basic-data/index.spec.js | 25 ++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/modules/item/front/basic-data/index.spec.js b/modules/item/front/basic-data/index.spec.js index e7578b54c0..178fac2784 100644 --- a/modules/item/front/basic-data/index.spec.js +++ b/modules/item/front/basic-data/index.spec.js @@ -2,26 +2,31 @@ import './index.js'; describe('vnItemBasicData', () => { describe('Component vnItemBasicData', () => { + let $httpBackend; let $scope; let controller; - let $timeout; + let $element; beforeEach(ngModule('item')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$timeout_) => { - $timeout = _$timeout_; + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); - controller = $componentController('vnItemBasicData', {$scope, $timeout}); - controller.$scope.watcher = {}; + $element = angular.element(''); + controller = $componentController('vnItemBasicData', {$element, $scope}); + controller.$.watcher = {}; + controller.$params.id = 1; + controller.item = {id: 1, name: 'Rainbow Coral'}; })); - describe('$onChanges()', () => { + describe('onIntrastatAccept()', () => { it('should pass the data to the watcher', () => { - const data = {item: {currentValue: 'the current value of an item'}}; - controller.$onChanges(data); - $timeout.flush(); + const newIntrastatId = 20; + $httpBackend.expect('PATCH', 'Items/1/createIntrastat').respond({id: 20}); + controller.onIntrastatAccept(); + $httpBackend.flush(); - expect(controller.$scope.watcher.data).toMatchSnapshot(); + expect(controller.item.intrastatFk).toEqual(newIntrastatId); }); }); }); From a148daa36878748204d3275a009ff7ecafdebf60 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 17 Feb 2020 14:47:43 +0100 Subject: [PATCH 17/55] 2125 - ticket create invalid type fix --- modules/ticket/front/create/card.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/front/create/card.js b/modules/ticket/front/create/card.js index 2e775c18b0..54cc56c684 100644 --- a/modules/ticket/front/create/card.js +++ b/modules/ticket/front/create/card.js @@ -14,7 +14,7 @@ class Controller { $onInit() { if (this.$stateParams && this.$stateParams.clientFk) - this.clientId = this.$stateParams.clientFk; + this.clientId = parseInt(this.$stateParams.clientFk); this.warehouseId = this.vnConfig.warehouseFk; } From fe8a0b4583e877550310a69764687c87cc775e6e Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 18 Feb 2020 07:21:35 +0100 Subject: [PATCH 18/55] Added translation. taxClassCode.sql removed --- .../00-taxClassCode.sql | 23 ------------------- db/dump/fixtures.sql | 8 +++---- modules/item/back/models/tax-class-code.json | 19 ++++++++------- modules/item/front/basic-data/locale/es.yml | 4 +++- 4 files changed, 16 insertions(+), 38 deletions(-) delete mode 100644 db/changes/10160-postValentineDay/00-taxClassCode.sql diff --git a/db/changes/10160-postValentineDay/00-taxClassCode.sql b/db/changes/10160-postValentineDay/00-taxClassCode.sql deleted file mode 100644 index bdc7cb474c..0000000000 --- a/db/changes/10160-postValentineDay/00-taxClassCode.sql +++ /dev/null @@ -1,23 +0,0 @@ -ALTER TABLE `vn`.`taxClassCode` -DROP FOREIGN KEY `taxClassCode_ibfk_2`, -DROP FOREIGN KEY `taxClassCode_ibfk_1`; -ALTER TABLE `vn`.`taxClassCode` -ADD COLUMN `id` INT NOT NULL AUTO_INCREMENT FIRST, -DROP PRIMARY KEY, -ADD PRIMARY KEY (`id`), -DROP INDEX `iva_codigo_id` ; - -ALTER TABLE `vn`.`taxClassCode` -ADD UNIQUE INDEX `taxClassCode_unique` (`taxClassFk` ASC, `effectived` ASC, `taxCodeFk` ASC) VISIBLE; - -ALTER TABLE `vn`.`taxClassCode` -ADD CONSTRAINT `taxClassCode_taxClassFk` - FOREIGN KEY (`taxClassFk`) - REFERENCES `vn`.`taxClass` (`id`) - ON DELETE RESTRICT - ON UPDATE CASCADE, -ADD CONSTRAINT `taxClassCode_taxCodeFk` - FOREIGN KEY (`taxCodeFk`) - REFERENCES `vn`.`taxCode` (`id`) - ON DELETE RESTRICT - ON UPDATE CASCADE; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 80bb377090..d561767132 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -687,11 +687,11 @@ INSERT INTO `vn`.`taxClass`(`id`, `description`, `code`) (1, 'Reduced VAT', 'R'), (2, 'General VAT', 'G'); -INSERT INTO `vn`.`taxClassCode`(`id`, `taxClassFk`, `effectived`, `taxCodeFk`) +INSERT INTO `vn`.`taxClassCode`(`taxClassFk`, `effectived`, `taxCodeFk`) VALUES - (1, 1, CURDATE(), 1), - (2, 1, CURDATE(), 21), - (3, 2, CURDATE(), 2); + (1, CURDATE(), 1), + (1, CURDATE(), 21), + (2, CURDATE(), 2); INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) VALUES diff --git a/modules/item/back/models/tax-class-code.json b/modules/item/back/models/tax-class-code.json index efe6a13db8..ef8c529d96 100644 --- a/modules/item/back/models/tax-class-code.json +++ b/modules/item/back/models/tax-class-code.json @@ -7,21 +7,20 @@ } }, "properties": { - "id": { - "type": "number", - "id": true - }, - "effectived": { - "type": "date", - "required": true - }, "taxClassFk": { "type": "number", - "required": true + "required": true, + "id": 1 }, "taxCodeFk": { "type": "number", - "required": true + "required": true, + "id": 2 + }, + "effectived": { + "type": "date", + "required": true, + "id": 3 } }, "relations": { diff --git a/modules/item/front/basic-data/locale/es.yml b/modules/item/front/basic-data/locale/es.yml index 67780557a3..07e6817709 100644 --- a/modules/item/front/basic-data/locale/es.yml +++ b/modules/item/front/basic-data/locale/es.yml @@ -5,4 +5,6 @@ Full name calculates based on tags 1-3. Is not recommended to change it manually No se recomienda cambiarlo manualmente Is active: Activo Expense: Gasto -Price in kg: Precio en kg \ No newline at end of file +Price in kg: Precio en kg +New intrastat: Nuevo intrastat +Identifier: Identificador \ No newline at end of file From 30e38802992e763badf6aad916b4a9fcaca4dcff Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 18 Feb 2020 07:50:18 +0100 Subject: [PATCH 19/55] Removed comments --- modules/order/front/catalog/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index ef33e493f3..ff14c592b5 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -245,7 +245,6 @@ class Controller { this.$state.go(this.$state.current.name, params); } - // Builds the tags filter buildTagsFilter(items) { const tagValues = []; items.forEach(item => { @@ -261,7 +260,6 @@ class Controller { this.tagValues = tagValues; } - // Builds the order filter buildOrderFilter(items) { const tags = []; items.forEach(item => { From 3f978bd32b5544c40d6e700cf0bcab2193ba95ee Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 18 Feb 2020 10:33:17 +0100 Subject: [PATCH 20/55] entry index refactor --- db/dump/fixtures.sql | 20 ++-- modules/entry/back/methods/entry/filter.js | 1 + .../back/methods/entry/specs/filter.spec.js | 6 +- modules/entry/front/index/index.html | 59 +++++++---- modules/entry/front/index/index.js | 12 ++- modules/entry/front/index/locale/es.yml | 15 +++ modules/entry/front/index/style.scss | 5 + modules/entry/front/locale/es.yml | 14 +-- modules/entry/front/routes.json | 1 + .../item/back/methods/item/getLastEntries.js | 1 + .../back/methods/travel/specs/filter.spec.js | 2 +- .../front/descriptor-popover/index.html | 12 +++ .../travel/front/descriptor-popover/index.js | 88 +++++++++++++++ .../front/descriptor-popover/index.spec.js | 100 ++++++++++++++++++ modules/travel/front/index.js | 2 +- .../worker/front/descriptor-popover/index.js | 1 - .../front/descriptor-popover/style.scss | 11 -- 17 files changed, 292 insertions(+), 58 deletions(-) create mode 100644 modules/entry/front/index/locale/es.yml create mode 100644 modules/entry/front/index/style.scss create mode 100644 modules/travel/front/descriptor-popover/index.html create mode 100644 modules/travel/front/descriptor-popover/index.js create mode 100644 modules/travel/front/descriptor-popover/index.spec.js delete mode 100644 modules/worker/front/descriptor-popover/style.scss diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index d561767132..f7d5d94f1c 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1129,17 +1129,19 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO (4, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 50.00, 500, 'fourth travel', 0), (5, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 2, 1, 50.00, 500, 'fifth travel', 1), (6, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 4, 2, 1, 50.00, 500, 'sixth travel', 1), - (7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500, 'seventh travel', 1); + (7, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500, 'seventh travel', 1), + (8, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 2, 1, 50.00, 500, 'eight travel', 1); -INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`, `ref`, `notes`, `evaNotes`) +INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`, `ref`,`isInventory`, `isRaid`, `notes`, `evaNotes`) VALUES - (1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 442, 'Movement 1', 'this is the note one', 'observation one'), - (2, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 442, 'Movement 2', 'this is the note two', 'observation two'), - (3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 442, 'Movement 3', 'this is the note three', 'observation three'), - (4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 69, 'Movement 4', 'this is the note four', 'observation four'), - (5, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 442, 'Movement 5', 'this is the note five', 'observation five'), - (6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 442, 'Movement 6', 'this is the note six', 'observation six'), - (7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movement 7', 'this is the note seven', 'observation seven'); + (1, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 442, 'Movement 1', 0, 0, '', ''), + (2, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 442, 'Movement 2', 0, 0, 'this is the note two', 'observation two'), + (3, 1, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 3, 442, 'Movement 3', 0, 0, 'this is the note three', 'observation three'), + (4, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 69, 'Movement 4', 0, 0, 'this is the note four', 'observation four'), + (5, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 5, 442, 'Movement 5', 0, 0, 'this is the note five', 'observation five'), + (6, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 6, 442, 'Movement 6', 0, 0, 'this is the note six', 'observation six'), + (7, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movement 7', 0, 0, 'this is the note seven', 'observation seven'), + (8, 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 7, 442, 'Movement 8', 1, 1, '', ''); INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) VALUES diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index 8cbe5e15e6..93e9558a96 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -127,6 +127,7 @@ module.exports = Self => { e.companyFk, e.gestDocFk, e.invoiceInFk, + t.landed, s.name AS supplierName, co.code AS companyCode, cu.code AS currencyCode diff --git a/modules/entry/back/methods/entry/specs/filter.spec.js b/modules/entry/back/methods/entry/specs/filter.spec.js index 9b935d831a..25d2da0b42 100644 --- a/modules/entry/back/methods/entry/specs/filter.spec.js +++ b/modules/entry/back/methods/entry/specs/filter.spec.js @@ -23,7 +23,7 @@ describe('Entry filter()', () => { let result = await app.models.Entry.filter(ctx); - expect(result.length).toEqual(7); + expect(result.length).toEqual(8); }); it('should return the entry matching the supplier', async() => { @@ -35,7 +35,7 @@ describe('Entry filter()', () => { let result = await app.models.Entry.filter(ctx); - expect(result.length).toEqual(5); + expect(result.length).toEqual(6); }); it('should return the entry matching the company', async() => { @@ -47,7 +47,7 @@ describe('Entry filter()', () => { let result = await app.models.Entry.filter(ctx); - expect(result.length).toEqual(6); + expect(result.length).toEqual(7); }); it('should return the entries matching isBooked', async() => { diff --git a/modules/entry/front/index/index.html b/modules/entry/front/index/index.html index 8ddd4d3a39..86d62b1581 100644 --- a/modules/entry/front/index/index.html +++ b/modules/entry/front/index/index.html @@ -16,45 +16,68 @@ + Id - Created - Travel - Notes + Landed Reference - Booked - Is inventory - Confirmed - Ordered - Is raid - Commission Supplier Currency Company + Booked + Confirmed + Ordered + Notes + + + + + + {{::entry.id}} - {{::entry.created | date:'dd/MM/yyyy'}} - {{::entry.travelFk}} - {{::entry.notes}} + + + {{::entry.landed | date:'dd/MM/yyyy'}} + + {{::entry.ref}} - - - - - - {{::entry.commission}} {{::entry.supplierName}} {{::entry.currencyCode}} {{::entry.companyCode}} + + + + + + + + + diff --git a/modules/entry/front/index/index.js b/modules/entry/front/index/index.js index ec78c06dfa..53d2f45e07 100644 --- a/modules/entry/front/index/index.js +++ b/modules/entry/front/index/index.js @@ -1,5 +1,5 @@ import ngModule from '../module'; - +import './style.scss'; export default class Controller { constructor($scope) { this.$ = $scope; @@ -11,6 +11,16 @@ export default class Controller { else this.$.model.clear(); } + + showTravelDescriptor(event, travelFk) { + if (event.defaultPrevented) return; + event.preventDefault(); + event.stopPropagation(); + + this.selectedTravel = travelFk; + this.$.travelDescriptor.parent = event.target; + this.$.travelDescriptor.show(); + } } Controller.$inject = ['$scope']; diff --git a/modules/entry/front/index/locale/es.yml b/modules/entry/front/index/locale/es.yml new file mode 100644 index 0000000000..8ef9b2c7af --- /dev/null +++ b/modules/entry/front/index/locale/es.yml @@ -0,0 +1,15 @@ +Inventory entry: Es inventario +Virtual entry: Es una redada +Supplier: Proveedor +Currency: Moneda +Company: Empresa +Confirmed: Confirmada +Ordered: Pedida +Is raid: Redada +Commission: Comisión +Landed: F. entrega +Reference: Referencia +Created: Creado +Booked: Facturado +Is inventory: Inventario +Notes: Notas \ No newline at end of file diff --git a/modules/entry/front/index/style.scss b/modules/entry/front/index/style.scss new file mode 100644 index 0000000000..ab759d2ccb --- /dev/null +++ b/modules/entry/front/index/style.scss @@ -0,0 +1,5 @@ +@import "variables"; + + vn-icon[icon=insert_drive_file]{ + color: $color-font-secondary; + } diff --git a/modules/entry/front/locale/es.yml b/modules/entry/front/locale/es.yml index 214be93d4d..3de6c59a83 100644 --- a/modules/entry/front/locale/es.yml +++ b/modules/entry/front/locale/es.yml @@ -1,15 +1,3 @@ #Ordenar alfabeticamente -Reference: Referencia -Created: Creado -Booked: Facturado -Is inventory: Inventario -Notes: Notas -Travel: Envío -Supplier: Proveedor -Currency: Moneda -Company: Empresa -Confirmed: Confirmada -Ordered: Pedida -Is raid: Redada -Commission: Comisión + # Sections diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index f23ff02bfb..bd1ace3f25 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -2,6 +2,7 @@ "module": "entry", "name": "Entries", "icon": "icon-entry", + "dependencies": ["travel"], "validations": true, "menus": { "main": [ diff --git a/modules/item/back/methods/item/getLastEntries.js b/modules/item/back/methods/item/getLastEntries.js index bab808cef1..a438afcb63 100644 --- a/modules/item/back/methods/item/getLastEntries.js +++ b/modules/item/back/methods/item/getLastEntries.js @@ -22,6 +22,7 @@ module.exports = Self => { let where = filter.where; let query = `CALL vn.itemLastEntries(?, ?)`; let [lastEntries] = await Self.rawSql(query, [where.itemFk, where.date]); + return lastEntries; }; }; diff --git a/modules/travel/back/methods/travel/specs/filter.spec.js b/modules/travel/back/methods/travel/specs/filter.spec.js index f2fe44989d..03849f2b0e 100644 --- a/modules/travel/back/methods/travel/specs/filter.spec.js +++ b/modules/travel/back/methods/travel/specs/filter.spec.js @@ -23,7 +23,7 @@ describe('Travel filter()', () => { let result = await app.models.Travel.filter(ctx); - expect(result.length).toEqual(7); + expect(result.length).toEqual(8); }); it('should return the travel matching "total entries"', async() => { diff --git a/modules/travel/front/descriptor-popover/index.html b/modules/travel/front/descriptor-popover/index.html new file mode 100644 index 0000000000..fc0fb0301d --- /dev/null +++ b/modules/travel/front/descriptor-popover/index.html @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/modules/travel/front/descriptor-popover/index.js b/modules/travel/front/descriptor-popover/index.js new file mode 100644 index 0000000000..bac0d95fdc --- /dev/null +++ b/modules/travel/front/descriptor-popover/index.js @@ -0,0 +1,88 @@ +import ngModule from '../module'; +import Component from 'core/lib/component'; + +class Controller extends Component { + constructor($element, $scope, $http, $timeout, $q) { + super($element, $scope); + this.$timeout = $timeout; + this.$http = $http; + this.$q = $q; + this.travel = null; + this._quicklinks = {}; + } + + set travelFk(travelFk) { + if (travelFk == this._travelFk) return; + + this._travelFk = travelFk; + this.travel = null; + this.loadData(); + } + + get travelFk() { + return this._travelFk; + } + + get quicklinks() { + return this._quicklinks; + } + + set quicklinks(value = {}) { + Object.keys(value).forEach(key => { + this._quicklinks[key] = value[key]; + }); + } + + show() { + this.$.popover.parent = this.parent; + this.$.popover.show(); + } + + loadData() { + let query = `Travels/findOne`; + let filter = { + fields: [ + 'id', + 'ref', + 'shipped', + 'landed', + 'totalEntries', + 'warehouseInFk', + 'warehouseOutFk' + ], + where: { + id: this._travelFk + }, + include: [ + { + relation: 'warehouseIn', + scope: { + fields: ['name'] + } + }, { + relation: 'warehouseOut', + scope: { + fields: ['name'] + } + } + ] + }; + + this.$http.get(query, {params: {filter}}).then(res => { + this.travel = res.data; + this.$.$applyAsync(() => { + this.$.popover.relocate(); + }); + }); + } +} +Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q']; + +ngModule.component('vnTravelDescriptorPopover', { + template: require('./index.html'), + controller: Controller, + bindings: { + travelFk: '<', + quicklinks: '<' + } +}); diff --git a/modules/travel/front/descriptor-popover/index.spec.js b/modules/travel/front/descriptor-popover/index.spec.js new file mode 100644 index 0000000000..72ba3aeafa --- /dev/null +++ b/modules/travel/front/descriptor-popover/index.spec.js @@ -0,0 +1,100 @@ +import './index.js'; + +describe('travel Component vnTravelDescriptorPopover', () => { + let $httpBackend; + let $httpParamSerializer; + let $scope; + let controller; + let $element; + + beforeEach(ngModule('travel')); + + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + $httpBackend = _$httpBackend_; + $httpParamSerializer = _$httpParamSerializer_; + $element = angular.element(`
`); + $scope = $rootScope.$new(); + $scope.popover = {relocate: () => {}, show: () => {}}; + controller = $componentController('vnTravelDescriptorPopover', {$scope, $element}); + })); + + describe('travelFk()', () => { + it(`should not apply any changes if the received id is the same stored in _travelFk`, () => { + controller.travel = 'I exist!'; + controller._travelFk = 1; + spyOn(controller, 'loadData'); + controller.travelFk = 1; + + expect(controller.travel).toEqual('I exist!'); + expect(controller._travelFk).toEqual(1); + expect(controller.loadData).not.toHaveBeenCalled(); + }); + + it(`should set the received id into _travelFk, set the travel to null and then call loadData()`, () => { + controller.travel = `Please don't`; + controller._travelFk = 1; + spyOn(controller, 'loadData'); + controller.travelFk = 999; + + expect(controller.travel).toBeNull(); + expect(controller._travelFk).toEqual(999); + expect(controller.loadData).toHaveBeenCalledWith(); + }); + }); + + describe('show()', () => { + it(`should call the show()`, () => { + spyOn(controller.$.popover, 'show'); + controller.show(); + + expect(controller.$.popover.show).toHaveBeenCalledWith(); + }); + }); + + describe('loadData()', () => { + it(`should perform a get query to store the worker data into the controller`, () => { + controller.travelFk = 1; + controller.canceler = null; + let response = {}; + + let config = { + filter: { + fields: [ + 'id', + 'ref', + 'shipped', + 'landed', + 'totalEntries', + 'warehouseInFk', + 'warehouseOutFk' + ], + where: { + id: controller.travelFk + }, + include: [ + { + relation: 'warehouseIn', + scope: { + fields: ['name'] + } + }, { + relation: 'warehouseOut', + scope: { + fields: ['name'] + } + } + ] + } + }; + + let json = $httpParamSerializer(config); + + $httpBackend.whenGET(`Travels/findOne?${json}`).respond(response); + $httpBackend.expectGET(`Travels/findOne?${json}`); + controller.loadData(); + $httpBackend.flush(); + + expect(controller.travel).toEqual(response); + }); + }); +}); diff --git a/modules/travel/front/index.js b/modules/travel/front/index.js index 1f5346e987..b72f9fd51c 100644 --- a/modules/travel/front/index.js +++ b/modules/travel/front/index.js @@ -11,4 +11,4 @@ import './log'; import './create'; import './thermograph/index/'; import './thermograph/create/'; - +import './descriptor-popover'; diff --git a/modules/worker/front/descriptor-popover/index.js b/modules/worker/front/descriptor-popover/index.js index b648e8bd20..55843a67da 100644 --- a/modules/worker/front/descriptor-popover/index.js +++ b/modules/worker/front/descriptor-popover/index.js @@ -1,6 +1,5 @@ import ngModule from '../module'; import Component from 'core/lib/component'; -import './style.scss'; class Controller extends Component { constructor($element, $scope, $http, $timeout, $q) { diff --git a/modules/worker/front/descriptor-popover/style.scss b/modules/worker/front/descriptor-popover/style.scss deleted file mode 100644 index 58e65d3206..0000000000 --- a/modules/worker/front/descriptor-popover/style.scss +++ /dev/null @@ -1,11 +0,0 @@ -vn-ticket-descriptor-popover { - vn-ticket-descriptor { - display: block; - width: 16em; - max-height: 28em; - - & > vn-card { - margin: 0!important; - } - } -} \ No newline at end of file From 6540ef9598cfdae1e88ac1bcc62d0d1b8b3079a2 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 18 Feb 2020 11:07:55 +0100 Subject: [PATCH 21/55] change Fk to Id --- modules/entry/front/index/index.html | 2 +- .../travel/front/descriptor-popover/index.js | 14 ++++++------ .../front/descriptor-popover/index.spec.js | 22 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/modules/entry/front/index/index.html b/modules/entry/front/index/index.html index 86d62b1581..f0f5404899 100644 --- a/modules/entry/front/index/index.html +++ b/modules/entry/front/index/index.html @@ -76,7 +76,7 @@ + travel-id="$ctrl.selectedTravel"> { controller = $componentController('vnTravelDescriptorPopover', {$scope, $element}); })); - describe('travelFk()', () => { - it(`should not apply any changes if the received id is the same stored in _travelFk`, () => { + describe('travelId()', () => { + it(`should not apply any changes if the received id is the same stored in _travelId`, () => { controller.travel = 'I exist!'; - controller._travelFk = 1; + controller._travelId = 1; spyOn(controller, 'loadData'); - controller.travelFk = 1; + controller.travelId = 1; expect(controller.travel).toEqual('I exist!'); - expect(controller._travelFk).toEqual(1); + expect(controller._travelId).toEqual(1); expect(controller.loadData).not.toHaveBeenCalled(); }); - it(`should set the received id into _travelFk, set the travel to null and then call loadData()`, () => { + it(`should set the received id into _travelId, set the travel to null and then call loadData()`, () => { controller.travel = `Please don't`; - controller._travelFk = 1; + controller._travelId = 1; spyOn(controller, 'loadData'); - controller.travelFk = 999; + controller.travelId = 999; expect(controller.travel).toBeNull(); - expect(controller._travelFk).toEqual(999); + expect(controller._travelId).toEqual(999); expect(controller.loadData).toHaveBeenCalledWith(); }); }); @@ -53,7 +53,7 @@ describe('travel Component vnTravelDescriptorPopover', () => { describe('loadData()', () => { it(`should perform a get query to store the worker data into the controller`, () => { - controller.travelFk = 1; + controller.travelId = 1; controller.canceler = null; let response = {}; @@ -69,7 +69,7 @@ describe('travel Component vnTravelDescriptorPopover', () => { 'warehouseOutFk' ], where: { - id: controller.travelFk + id: controller.travelId }, include: [ { From 2460725d98a147bb8d39a61feff1d0c11f366df8 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 18 Feb 2020 11:14:02 +0100 Subject: [PATCH 22/55] Refactor + updated tests --- modules/client/front/sample/create/index.html | 5 +- modules/client/front/sample/create/index.js | 78 ++++--- .../client/front/sample/create/index.spec.js | 190 +++++++++--------- .../client/front/sample/create/locale/es.yml | 4 +- 4 files changed, 130 insertions(+), 147 deletions(-) diff --git a/modules/client/front/sample/create/index.html b/modules/client/front/sample/create/index.html index 6a87d55b68..cd3412868b 100644 --- a/modules/client/front/sample/create/index.html +++ b/modules/client/front/sample/create/index.html @@ -15,7 +15,8 @@ + ng-model="$ctrl.clientSample.recipient" + info="Its only used when sample is sent"> @@ -30,7 +31,7 @@ { - this.$.showPreview.show(); - let dialog = document.body.querySelector('div.vn-dialog'); - let body = dialog.querySelector('tpl-body'); - let scroll = dialog.querySelector('div:first-child'); - - body.innerHTML = res.data; - scroll.scrollTop = 0; - }); + this.clientSample.companyId = value; } onSubmit() { @@ -73,28 +42,49 @@ class Controller extends Component { ); } + showPreview() { + this.send(true, res => { + this.$.showPreview.show(); + const dialog = document.body.querySelector('div.vn-dialog'); + const body = dialog.querySelector('tpl-body'); + const scroll = dialog.querySelector('div:first-child'); + + body.innerHTML = res.data; + scroll.scrollTop = 0; + }); + } + sendSample() { - let sampleType = this.$.sampleType.selection; - let params = { + this.send(false, () => { + this.vnApp.showSuccess(this.$translate.instant('Notification sent!')); + this.$state.go('client.card.sample.index'); + }); + } + + send(isPreview, cb) { + const sampleType = this.$.sampleType.selection; + const params = { clientId: this.$params.id, recipient: this.clientSample.recipient }; + if (!params.recipient) + return this.vnApp.showError(this.$translate.instant('Email cannot be blank')); + if (!sampleType) return this.vnApp.showError(this.$translate.instant('Choose a sample')); - if (sampleType.hasCompany && !this.clientSample.companyFk) + if (sampleType.hasCompany && !this.clientSample.companyId) return this.vnApp.showError(this.$translate.instant('Choose a company')); if (sampleType.hasCompany) - params.companyId = this.clientSample.companyFk; + params.companyId = this.clientSample.companyId; + + if (isPreview) params.isPreview = true; const serializedParams = this.$httpParamSerializer(params); const query = `email/${sampleType.code}?${serializedParams}`; - this.$http.get(query).then(res => { - this.vnApp.showSuccess(this.$translate.instant('Notification sent!')); - this.$state.go('client.card.sample.index'); - }); + this.$http.get(query).then(cb); } } Controller.$inject = ['$element', '$scope', 'vnApp', '$httpParamSerializer', 'vnConfig']; diff --git a/modules/client/front/sample/create/index.spec.js b/modules/client/front/sample/create/index.spec.js index efcda54012..da9a557f1e 100644 --- a/modules/client/front/sample/create/index.spec.js +++ b/modules/client/front/sample/create/index.spec.js @@ -40,84 +40,16 @@ describe('Client', () => { $httpParamSerializer = _$httpParamSerializer_; $element = angular.element(''); controller = $componentController('vnClientSampleCreate', {$element, $scope}); + const element = document.createElement('div'); + document.body.querySelector = () => { + return { + querySelector: () => { + return element; + } + }; + }; })); - describe('showPreview()', () => { - it(`should perform a query (GET) and open a sample preview`, () => { - spyOn(controller.$.showPreview, 'show'); - const element = document.createElement('div'); - document.body.querySelector = () => { - return { - querySelector: () => { - return element; - } - }; - }; - - controller.$.sampleType.selection = { - hasCompany: false, - code: 'MyReport' - }; - - controller.clientSample = { - clientFk: 101 - }; - - let event = {preventDefault: () => {}}; - - const params = { - clientId: 101, - isPreview: true - }; - const serializedParams = $httpParamSerializer(params); - - $httpBackend.when('GET', `email/MyReport?${serializedParams}`).respond(true); - $httpBackend.expect('GET', `email/MyReport?${serializedParams}`); - controller.showPreview(event); - $httpBackend.flush(); - - expect(controller.$.showPreview.show).toHaveBeenCalledWith(); - }); - - it(`should perform a query (GET) with companyFk param and open a sample preview`, () => { - spyOn(controller.$.showPreview, 'show'); - const element = document.createElement('div'); - document.body.querySelector = () => { - return { - querySelector: () => { - return element; - } - }; - }; - - controller.$.sampleType.selection = { - hasCompany: true, - code: 'MyReport' - }; - - controller.clientSample = { - clientFk: 101, - companyFk: 442 - }; - - let event = {preventDefault: () => {}}; - - const params = { - clientId: 101, - companyId: 442, - isPreview: true - }; - const serializedParams = $httpParamSerializer(params); - - $httpBackend.when('GET', `email/MyReport?${serializedParams}`).respond(true); - $httpBackend.expect('GET', `email/MyReport?${serializedParams}`); - controller.showPreview(event); - $httpBackend.flush(); - - expect(controller.$.showPreview.show).toHaveBeenCalledWith(); - }); - }); - describe('onSubmit()', () => { it(`should call sendSample() method`, () => { spyOn(controller, 'sendSample'); @@ -127,55 +59,113 @@ describe('Client', () => { }); }); - describe('sendSample()', () => { - it(`should perform a query (GET) and call go() method`, () => { - spyOn(controller.$state, 'go'); + describe('send()', () => { + it(`should not perform an HTTP query if no recipient is specified`, () => { + spyOn(controller.$http, 'get'); controller.$.sampleType.selection = { hasCompany: false, code: 'MyReport' }; - controller.clientSample = { - clientFk: 101 - }; - - const params = { clientId: 101 }; - const serializedParams = $httpParamSerializer(params); - $httpBackend.when('GET', `email/MyReport?${serializedParams}`).respond(true); - $httpBackend.expect('GET', `email/MyReport?${serializedParams}`); - controller.sendSample(); - $httpBackend.flush(); + controller.send(false, () => {}); - expect(controller.$state.go).toHaveBeenCalledWith('client.card.sample.index'); + expect(controller.$http.get).not.toHaveBeenCalled(); }); - it(`should perform a query (GET) with companyFk param and call go() method`, () => { - spyOn(controller.$state, 'go'); + it(`should not perform an HTTP query if no sample is specified`, () => { + spyOn(controller.$http, 'get'); + + controller.$.sampleType.selection = null; + controller.clientSample = { + clientId: 101, + recipient: 'client@email.com' + }; + + controller.send(false, () => {}); + + expect(controller.$http.get).not.toHaveBeenCalled(); + }); + + it(`should not perform an HTTP query if company is required and not specified`, () => { + spyOn(controller.$http, 'get'); controller.$.sampleType.selection = { hasCompany: true, code: 'MyReport' }; - controller.clientSample = { - clientFk: 101, - companyFk: 442 + clientId: 101, + recipient: 'client@email.com' }; - const params = { + controller.send(false, () => {}); + + expect(controller.$http.get).not.toHaveBeenCalled(); + }); + + it(`should perform an HTTP query without passing companyId param`, () => { + controller.$.sampleType.selection = { + hasCompany: false, + code: 'MyReport' + }; + controller.clientSample = { clientId: 101, + recipient: 'client@email.com' + }; + + const serializedParams = $httpParamSerializer(controller.clientSample); + $httpBackend.expect('GET', `email/MyReport?${serializedParams}`).respond(true); + controller.send(false, () => {}); + $httpBackend.flush(); + }); + + it(`should perform an HTTP query passing companyId param`, () => { + controller.$.sampleType.selection = { + hasCompany: true, + code: 'MyReport' + }; + controller.clientSample = { + clientId: 101, + recipient: 'client@email.com', companyId: 442 }; - const serializedParams = $httpParamSerializer(params); - $httpBackend.when('GET', `email/MyReport?${serializedParams}`).respond(true); - $httpBackend.expect('GET', `email/MyReport?${serializedParams}`); - controller.sendSample(); + const serializedParams = $httpParamSerializer(controller.clientSample); + $httpBackend.expect('GET', `email/MyReport?${serializedParams}`).respond(true); + controller.send(false, () => {}); $httpBackend.flush(); + }); + }); + + describe('showPreview()', () => { + it(`should open a sample preview`, () => { + spyOn(controller.$.showPreview, 'show'); + + controller.send = (isPreview, cb) => { + cb({ + data: '
' + }); + }; + controller.showPreview(); + + expect(controller.$.showPreview.show).toHaveBeenCalledWith(); + }); + }); + + describe('sendSample()', () => { + it(`should perform a query (GET) and call go() method`, () => { + spyOn(controller.$state, 'go'); + + controller.send = (isPreview, cb) => { + cb({ + data: true + }); + }; + controller.sendSample(); expect(controller.$state.go).toHaveBeenCalledWith('client.card.sample.index'); }); diff --git a/modules/client/front/sample/create/locale/es.yml b/modules/client/front/sample/create/locale/es.yml index d1ef82c0ee..6828e3e489 100644 --- a/modules/client/front/sample/create/locale/es.yml +++ b/modules/client/front/sample/create/locale/es.yml @@ -1,3 +1,5 @@ Choose a sample: Selecciona una plantilla Choose a company: Selecciona una empresa -Recipient: Destinatario \ No newline at end of file +Email cannot be blank: Debes introducir un email +Recipient: Destinatario +Its only used when sample is sent: Se utiliza únicamente cuando se envía la plantilla \ No newline at end of file From bfb8c5e138600242f17f2664092005e159b3b61c Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 18 Feb 2020 12:51:29 +0100 Subject: [PATCH 23/55] route.basicData validations --- loopback/locale/es.json | 3 ++- modules/route/back/models/route.js | 17 +++++++++++++++++ modules/route/front/basic-data/index.js | 6 ++++-- modules/route/front/basic-data/locale/es.yml | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 64fabd5226..7577c5349a 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -126,5 +126,6 @@ "MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} (#{{clientId}})]({{{url}}})", "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})", "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", - "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto" + "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", + "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000" } \ No newline at end of file diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index 4dd9f3dc02..6d93cfe405 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -5,4 +5,21 @@ module.exports = Self => { require('../methods/route/guessPriority')(Self); require('../methods/route/updateVolume')(Self); require('../methods/route/getDeliveryPoint')(Self); + + Self.validate('kmStart', validateDistance, { + message: 'Distance must be lesser than 1000' + }); + + Self.validate('kmEnd', validateDistance, { + message: 'Distance must be lesser than 1000' + }); + + function validateDistance(err) { + const routeTotalKm = this.kmEnd - this.kmStart; + const routeMaxKm = 1000; + if ( routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd) + err(); + } }; + + diff --git a/modules/route/front/basic-data/index.js b/modules/route/front/basic-data/index.js index 810fd75112..d4a481dc5f 100644 --- a/modules/route/front/basic-data/index.js +++ b/modules/route/front/basic-data/index.js @@ -1,8 +1,10 @@ import ngModule from '../module'; class Controller { - constructor($scope) { + constructor($scope, vnApp, $translate) { this.$ = $scope; + this.vnApp = vnApp; + this.$translate = $translate; } onSubmit() { @@ -11,7 +13,7 @@ class Controller { }); } } -Controller.$inject = ['$scope']; +Controller.$inject = ['$scope', 'vnApp', '$translate']; ngModule.component('vnRouteBasicData', { template: require('./index.html'), diff --git a/modules/route/front/basic-data/locale/es.yml b/modules/route/front/basic-data/locale/es.yml index 442a4fa828..f0414b5b15 100644 --- a/modules/route/front/basic-data/locale/es.yml +++ b/modules/route/front/basic-data/locale/es.yml @@ -2,4 +2,4 @@ Date finished: Fecha fin Date started: Fecha inicio Km start: Km de inicio Km end: Km de fin -Description: Descripción \ No newline at end of file +Description: Descripción From 774185e52e3ff7098e11ac8233bb75956f631a87 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 19 Feb 2020 10:04:29 +0100 Subject: [PATCH 24/55] #2120 e2e path agency.basicData --- e2e/helpers/selectors.js | 12 +++ e2e/paths/11-agency/01_basic-data.spec.js | 103 ++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 e2e/paths/11-agency/01_basic-data.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 63d40f9d5b..24b341a8c5 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -772,5 +772,17 @@ export default { uploadIcon: 'vn-travel-thermograph-create vn-icon[icon="cloud_upload"]', createdThermograph: 'vn-travel-thermograph-index vn-tbody > vn-tr', upload: 'vn-travel-thermograph-create button[type=submit]' + }, + agencyBasicData: { + name: 'vn-zone-basic-data vn-textfield[ng-model="$ctrl.zone.name"]', + agency: 'vn-zone-basic-data vn-autocomplete[ng-model="$ctrl.zone.agencyModeFk"]', + maxVolume: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.m3Max"]', + travelingDays: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.travelingDays"]', + closing: 'vn-zone-basic-data vn-input-time[ng-model="$ctrl.zone.hour"]', + price: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.price"]', + bonus: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.bonus"]', + inflation: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.inflation"]', + volumetric: 'vn-zone-basic-data vn-check[ng-model="$ctrl.zone.isVolumetric"]', + saveButton: 'vn-zone-basic-data vn-submit > button', } }; diff --git a/e2e/paths/11-agency/01_basic-data.spec.js b/e2e/paths/11-agency/01_basic-data.spec.js new file mode 100644 index 0000000000..43369aeab4 --- /dev/null +++ b/e2e/paths/11-agency/01_basic-data.spec.js @@ -0,0 +1,103 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Agency basic data path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('deliveryBoss', 'zone'); // turns up the agency module name and route aint the same lol + await page.accessToSearchResult('10'); + await page.accessToSection('zone.card.basicData'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the basic data section', async() => { + let url = await page.expectURL('#!/zone/10/basic-data'); + + expect(url).toBe(true); + }); + + it('should edit de form and then save', async() => { + await page.clearInput(selectors.agencyBasicData.name); + await page.write(selectors.agencyBasicData.name, 'Brimstone teleportation'); + await page.autocompleteSearch(selectors.agencyBasicData.agency, 'Quantum break device'); + await page.write(selectors.agencyBasicData.maxVolume, '10'); + await page.clearInput(selectors.agencyBasicData.travelingDays); + await page.write(selectors.agencyBasicData.travelingDays, '1'); + await page.clearInput(selectors.agencyBasicData.closing); + await page.type(selectors.agencyBasicData.closing, '2100'); + await page.clearInput(selectors.agencyBasicData.price); + await page.write(selectors.agencyBasicData.price, '999'); + await page.clearInput(selectors.agencyBasicData.bonus); + await page.write(selectors.agencyBasicData.bonus, '100'); + await page.clearInput(selectors.agencyBasicData.inflation); + await page.write(selectors.agencyBasicData.inflation, '200'); + await page.waitToClick(selectors.agencyBasicData.volumetric); + await page.waitToClick(selectors.agencyBasicData.saveButton); + }); + + it('should reload the section', async() => { + await page.reloadSection('zone.card.basicData'); + let url = await page.expectURL('#!/zone/10/basic-data'); + + expect(url).toBe(true); + }); + + it('should confirm the name was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.name, 'value'); + + expect(result).toEqual('Brimstone teleportation'); + }); + + it('should confirm the agency was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.agency, 'value'); + + expect(result).toEqual('Quantum break device'); + }); + + it('should confirm the max volume was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.maxVolume, 'value'); + + expect(result).toEqual('10'); + }); + + it('should confirm the traveling days were updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.travelingDays, 'value'); + + expect(result).toEqual('1'); + }); + + it('should confirm the closing hour was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.closing, 'value'); + + expect(result).toEqual('21:00'); + }); + + it('should confirm the price was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.price, 'value'); + + expect(result).toEqual('999'); + }); + + it('should confirm the bonus was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.bonus, 'value'); + + expect(result).toEqual('100'); + }); + + it('should confirm the inflation was updated', async() => { + const result = await page.waitToGetProperty(selectors.agencyBasicData.inflation, 'value'); + + expect(result).toEqual('200'); + }); + + it('should confirm the volumetric checkbox was checked', async() => { + await page.waitForClassPresent(selectors.agencyBasicData.volumetric, 'checked'); + }); +}); From c9fd48b0cde98f46ed289abeea7d31e93345386b Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 19 Feb 2020 11:57:39 +0100 Subject: [PATCH 25/55] 2112 - Catalog improvements --- e2e/helpers/selectors.js | 6 +- .../front/catalog-search-panel/index.html | 9 +- modules/order/front/catalog/index.html | 26 ++++- modules/order/front/catalog/index.js | 82 ++++++++++++++-- modules/order/front/catalog/index.spec.js | 97 ++++++++++++++----- modules/order/front/prices-popover/index.js | 24 ----- modules/order/front/routes.json | 2 +- 7 files changed, 176 insertions(+), 70 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 42480dafdf..451aaf7f7b 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -620,9 +620,9 @@ export default { orderCatalog: { plantRealmButton: 'vn-order-catalog > vn-side-menu vn-icon[icon="icon-plant"]', type: 'vn-autocomplete[data="$ctrl.itemTypes"]', - itemId: 'vn-order-catalog > vn-side-menu vn-textfield[ng-model="$ctrl.itemId"]', - itemTagValue: 'vn-order-catalog > vn-side-menu vn-datalist[ng-model="$ctrl.value"]', - openTagSearch: 'vn-order-catalog > vn-side-menu > div > vn-vertical > vn-datalist[ng-model="$ctrl.value"] .append i', + itemId: 'vn-order-catalog > vn-side-menu vn-textfield[vn-id="itemId"]', + itemTagValue: 'vn-order-catalog > vn-side-menu vn-datalist[vn-id="search"]', + openTagSearch: 'vn-order-catalog > vn-side-menu > div > vn-vertical > vn-datalist[vn-id="search"] .append i', tag: 'vn-order-catalog-search-panel vn-autocomplete[ng-model="filter.tagFk"]', tagValue: 'vn-order-catalog-search-panel vn-textfield[ng-model="filter.value"]', searchTagButton: 'vn-order-catalog-search-panel button[type=submit]', diff --git a/modules/order/front/catalog-search-panel/index.html b/modules/order/front/catalog-search-panel/index.html index 3bd0ba3e2a..d32ecaafac 100644 --- a/modules/order/front/catalog-search-panel/index.html +++ b/modules/order/front/catalog-search-panel/index.html @@ -1,13 +1,15 @@
-
+ + value-field="id" + required="true"> {{name}} @@ -15,7 +17,8 @@ + ng-model="filter.value" + required="true"> diff --git a/modules/order/front/catalog/index.html b/modules/order/front/catalog/index.html index 37767e81bb..7131d6a6e2 100644 --- a/modules/order/front/catalog/index.html +++ b/modules/order/front/catalog/index.html @@ -77,10 +77,9 @@
- + label="Item id"> @@ -89,7 +88,6 @@
+ + Id: {{$ctrl.itemId}} + - {{::tag.value}} +
+ + + {{::tag.tagSelection.name}} + + : + + + "{{::tag.value}}" + +
\ No newline at end of file diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index ff14c592b5..87dff29e24 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -10,7 +10,7 @@ class Controller { this.$compile = $compile; this.$transitions = $transitions; this.itemTypes = []; - this.tags = []; + this._tags = []; // Static autocomplete data this.orderWays = [ @@ -52,11 +52,17 @@ class Controller { if (!value) return; this.$.$applyAsync(() => { + if (this.$stateParams.itemId) + this.itemId = parseInt(this.$stateParams.itemId); + if (this.$stateParams.categoryId) - this.categoryId = this.$stateParams.categoryId; + this.categoryId = parseInt(this.$stateParams.categoryId); if (this.$stateParams.typeId) - this.typeId = this.$stateParams.typeId; + this.typeId = parseInt(this.$stateParams.typeId); + + if (this.$stateParams.tags) + this.tags = JSON.parse(this.$stateParams.tags); }); } @@ -109,6 +115,30 @@ class Controller { this.applyFilters(); } + get itemId() { + return this._itemId; + } + + set itemId(value) { + this._itemId = value; + + this.updateStateParams(); + this.applyFilters(); + } + + get tags() { + return this._tags; + } + + set tags(value) { + this._tags = value; + + this.updateStateParams(); + + if (value.length) + this.applyFilters(); + } + /** * Get order way ASC/DESC */ @@ -169,23 +199,36 @@ class Controller { this.itemTypes = res.data); } + /** + * Search by item id filter + * @param {object} event + */ onSearchById(event) { - const hasValue = this.tags.length > 0 || this.itemId || this.typeId; - if (event.key === 'Enter' && hasValue) - this.applyFilters(); + const value = this.$.itemId.value; + if (event.key === 'Enter' && value) { + this.itemId = value; + this.$.itemId.value = null; + } } + /** + * Search by tag value + * @param {object} event + */ onSearchByTag(event) { - if (event.key !== 'Enter' || !this.value) return; + const value = this.$.search.value; + if (event.key !== 'Enter' || !value) return; this.tags.push({ - value: this.value, + value: value, }); this.$.search.value = null; + this.updateStateParams(); this.applyFilters(); } remove(index) { this.tags.splice(index, 1); + this.updateStateParams(); if (this.tags.length >= 0 || this.itemId || this.typeId) this.applyFilters(); @@ -225,6 +268,7 @@ class Controller { onPanelSubmit(filter) { this.$.popover.hide(); this.tags.push(filter); + this.updateStateParams(); this.applyFilters(); } @@ -242,6 +286,28 @@ class Controller { params.typeId = this.typeId; else params.typeId = undefined; + if (this.itemId) + params.itemId = this.itemId; + else params.itemId = undefined; + + if (this.tags.length) { + const tags = []; + for (let tag of this.tags) { + const tagParam = {value: tag.value}; + + if (tag.tagSelection) { + tagParam.tagFk = tag.tagFk; + tagParam.tagSelection = { + name: tag.tagSelection.name + }; + } + + tags.push(tagParam); + } + + params.tags = JSON.stringify(tags); + } else params.tags = undefined; + this.$state.go(this.$state.current.name, params); } diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js index 01da618009..e2d2d0aff0 100644 --- a/modules/order/front/catalog/index.spec.js +++ b/modules/order/front/catalog/index.spec.js @@ -15,6 +15,7 @@ describe('Order', () => { $scope = $rootScope.$new(); $scope.model = crudModel; $scope.search = {}; + $scope.itemId = {}; $state = _$state_; $state.params.categoryId = 1; $state.params.typeId = 2; @@ -37,8 +38,9 @@ describe('Order', () => { describe('items() setter', () => { it(`should return an object with order params`, () => { - spyOn(controller, 'buildTagsFilter'); - spyOn(controller, 'buildOrderFilter').and.callThrough(); + jest.spyOn(controller, 'buildTagsFilter'); + jest.spyOn(controller, 'buildOrderFilter'); + const expectedResult = [{field: 'showOrder, price', name: 'Color and price'}]; const items = [{id: 1, name: 'My Item', tags: [ {tagFk: 4, name: 'Length'}, @@ -55,14 +57,16 @@ describe('Order', () => { describe('categoryId() setter', () => { it(`should set category property to null, call updateStateParams() method and not call applyFilters()`, () => { - spyOn(controller, 'updateStateParams'); + jest.spyOn(controller, 'updateStateParams'); + controller.categoryId = null; expect(controller.updateStateParams).toHaveBeenCalledWith(); }); it(`should set category property and then call updateStateParams() and applyFilters() methods`, () => { - spyOn(controller, 'updateStateParams'); + jest.spyOn(controller, 'updateStateParams'); + controller.categoryId = 2; expect(controller.updateStateParams).toHaveBeenCalledWith(); @@ -87,8 +91,9 @@ describe('Order', () => { describe('typeId() setter', () => { it(`should set type property to null, call updateStateParams() method and not call applyFilters()`, () => { - spyOn(controller, 'updateStateParams'); - spyOn(controller, 'applyFilters'); + jest.spyOn(controller, 'updateStateParams'); + jest.spyOn(controller, 'applyFilters'); + controller.typeId = null; expect(controller.updateStateParams).toHaveBeenCalledWith(); @@ -96,8 +101,9 @@ describe('Order', () => { }); it(`should set category property and then call updateStateParams() and applyFilters() methods`, () => { - spyOn(controller, 'updateStateParams'); - spyOn(controller, 'applyFilters'); + jest.spyOn(controller, 'updateStateParams'); + jest.spyOn(controller, 'applyFilters'); + controller.typeId = 2; expect(controller.updateStateParams).toHaveBeenCalledWith(); @@ -105,21 +111,46 @@ describe('Order', () => { }); }); + describe('itemId() setter', () => { + it(`should set itemId property and then call updateStateParams() and applyFilters() methods`, () => { + jest.spyOn(controller, 'updateStateParams'); + jest.spyOn(controller, 'applyFilters'); + + controller.itemId = 1; + + expect(controller.updateStateParams).toHaveBeenCalledWith(); + expect(controller.applyFilters).toHaveBeenCalledWith(); + }); + }); + + describe('tags() setter', () => { + it(`should set tags property and then call updateStateParams() and applyFilters() methods`, () => { + jest.spyOn(controller, 'updateStateParams'); + jest.spyOn(controller, 'applyFilters'); + + controller.tags = [{tagFk: 11, value: 'Brown'}]; + + expect(controller.updateStateParams).toHaveBeenCalledWith(); + expect(controller.applyFilters).toHaveBeenCalledWith(); + }); + }); + describe('onSearchByTag()', () => { it(`should not add a new tag if the event key code doesn't equals to 'Enter'`, () => { - spyOn(controller, 'applyFilters'); + jest.spyOn(controller, 'applyFilters'); + controller.order = {id: 4}; - controller.value = 'Color'; + controller.$.search.value = 'Brown'; controller.onSearchByTag({key: 'Tab'}); expect(controller.applyFilters).not.toHaveBeenCalledWith(); }); it(`should add a new tag if the event key code equals to 'Enter' an then call applyFilters()`, () => { - spyOn(controller, 'applyFilters'); - controller.order = {id: 4}; - controller.value = 'Color'; + jest.spyOn(controller, 'applyFilters'); + controller.order = {id: 4}; + controller.$.search.value = 'Brown'; controller.onSearchByTag({key: 'Enter'}); expect(controller.applyFilters).toHaveBeenCalledWith(); @@ -128,17 +159,18 @@ describe('Order', () => { describe('onSearchById()', () => { it(`should not filter by id if the event key code doesn't equals to 'Enter'`, () => { - spyOn(controller, 'applyFilters'); - controller.itemId = 1; + jest.spyOn(controller, 'applyFilters'); + + controller.$.itemId.value = 1; controller.onSearchById({key: 'Tab'}); expect(controller.applyFilters).not.toHaveBeenCalledWith(); }); it(`should filter by id if the event key code equals to 'Enter' an then call applyFilters()`, () => { - spyOn(controller, 'applyFilters'); - controller.itemId = 1; + jest.spyOn(controller, 'applyFilters'); + controller.$.itemId.value = 1; controller.onSearchById({key: 'Enter'}); expect(controller.applyFilters).toHaveBeenCalledWith(); @@ -147,14 +179,14 @@ describe('Order', () => { describe('applyFilters()', () => { it(`should call model applyFilter() method with a new filter`, () => { - let model = controller.$.model; - spyOn(model, 'applyFilter'); + jest.spyOn(controller.$.model, 'applyFilter'); + controller._categoryId = 2; controller._typeId = 4; controller.applyFilters(); - expect(model.applyFilter).toHaveBeenCalledWith( + expect(controller.$.model.applyFilter).toHaveBeenCalledWith( {where: {categoryFk: 2, typeFk: 4}}, {orderFk: 4, orderBy: controller.getOrderBy(), tags: []}); }); @@ -162,7 +194,8 @@ describe('Order', () => { describe('remove()', () => { it(`should remove a tag from tags property`, () => { - spyOn(controller, 'applyFilters'); + jest.spyOn(controller, 'applyFilters'); + controller.tags = [{tagFk: 1, value: 'Blue'}, {tagFk: 2, value: '70'}]; controller.remove(0); @@ -172,7 +205,8 @@ describe('Order', () => { }); it(`should remove a tag from tags property and call applyFilters() if there's no more tags`, () => { - spyOn(controller, 'applyFilters'); + jest.spyOn(controller, 'applyFilters'); + controller._categoryId = 1; controller._typeId = 1; controller.tags = [{tagFk: 1, value: 'Blue'}]; @@ -185,10 +219,19 @@ describe('Order', () => { describe('updateStateParams()', () => { it(`should call state go() method passing category and type state params`, () => { - spyOn(controller.$state, 'go'); + jest.spyOn(controller.$state, 'go'); + controller._categoryId = 2; controller._typeId = 4; - let result = {categoryId: 2, typeId: 4}; + controller._itemId = 1; + controller._tags = [ + {tagFk: 11, value: 'Precission', tagSelection: {name: 'Category'}} + ]; + const tags = JSON.stringify([{ + value: 'Precission', + tagFk: 11, tagSelection: {name: 'Category'}} + ]); + let result = {categoryId: 2, typeId: 4, itemId: 1, tags: tags}; controller.updateStateParams(); expect(controller.$state.go).toHaveBeenCalledWith('my.current.state', result); @@ -212,13 +255,15 @@ describe('Order', () => { describe('applyOrder()', () => { it(`should apply order param to model calling getOrderBy()`, () => { + jest.spyOn(controller, 'getOrderBy'); + jest.spyOn(controller.$.model, 'addFilter'); + controller.field = 'relevancy DESC, name'; controller.way = 'ASC'; controller._categoryId = 1; controller._typeId = 1; let expectedOrder = {orderBy: controller.getOrderBy()}; - spyOn(controller, 'getOrderBy').and.callThrough(); - spyOn(controller.$.model, 'addFilter'); + controller.applyOrder(); expect(controller.getOrderBy).toHaveBeenCalledWith(); diff --git a/modules/order/front/prices-popover/index.js b/modules/order/front/prices-popover/index.js index 2df8bea151..b732f2090a 100644 --- a/modules/order/front/prices-popover/index.js +++ b/modules/order/front/prices-popover/index.js @@ -73,30 +73,6 @@ class Controller extends Component { addQuantity(price) { if (this.total + price.grouping <= this.max) price.quantity += price.grouping; - - this.validate(); - } - - validate() { - /* - this.$timeout(() => { - this.calculateTotal(); - let inputs = this.$element[0].querySelectorAll('vn-input-number[name="quantity"] div.infix:not(.validated)'); - - inputs.forEach(input => { - if (this.total > this.item.available) - input.classList.add('invalid'); - else - input.classList.remove('invalid'); - }); - let wrongInputs = this.$element[0].querySelectorAll('vn-input-number[name="quantity"] div.infix.invalid'); - - if (wrongInputs.length > 0) - this.$element[0].querySelector('vn-vertical.prices').classList.add('invalid'); - else - this.$element[0].querySelector('vn-vertical.prices').classList.remove('invalid'); - }); - */ } getFilledLines() { diff --git a/modules/order/front/routes.json b/modules/order/front/routes.json index 789870fd1e..b607aef9db 100644 --- a/modules/order/front/routes.json +++ b/modules/order/front/routes.json @@ -41,7 +41,7 @@ "order": "$ctrl.order" } }, { - "url": "/catalog?categoryId&typeId", + "url": "/catalog?categoryId&typeId&itemId&tags", "state": "order.card.catalog", "component": "vn-order-catalog", "description": "Catalog", From 9e435e9553284fab80e403a193a40e9f3855ed73 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 19 Feb 2020 12:34:33 +0100 Subject: [PATCH 26/55] Some changes --- modules/order/front/catalog/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index 87dff29e24..e0ed611755 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -278,18 +278,19 @@ class Controller { updateStateParams() { const params = {}; + params.categoryId = undefined; if (this.categoryId) params.categoryId = this.categoryId; - else params.categoryId = undefined; + params.typeId = undefined; if (this.typeId) params.typeId = this.typeId; - else params.typeId = undefined; + params.itemId = undefined; if (this.itemId) params.itemId = this.itemId; - else params.itemId = undefined; + params.tags = undefined; if (this.tags.length) { const tags = []; for (let tag of this.tags) { @@ -306,7 +307,7 @@ class Controller { } params.tags = JSON.stringify(tags); - } else params.tags = undefined; + } this.$state.go(this.$state.current.name, params); } From 095a9f71633a70c64960efd4fe88f0b947f899b3 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 20 Feb 2020 07:37:50 +0100 Subject: [PATCH 27/55] #2119 e2e item.request --- e2e/paths/04-item/13_request.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e/paths/04-item/13_request.spec.js b/e2e/paths/04-item/13_request.spec.js index 9e53e300ae..adb7e52786 100644 --- a/e2e/paths/04-item/13_request.spec.js +++ b/e2e/paths/04-item/13_request.spec.js @@ -1,7 +1,8 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -describe('Item request path', () => { +// #2119 e2e item.request +xdescribe('Item request path', () => { let browser; let page; beforeAll(async() => { From aecfe2b8a917de749643b46490f275898b7f38ac Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 20 Feb 2020 09:31:09 +0100 Subject: [PATCH 28/55] report entry-order --- db/dump/fixtures.sql | 26 ++-- .../reports/entry-order/assets/css/import.js | 9 ++ .../reports/entry-order/assets/css/style.css | 6 + .../reports/entry-order/entry-order.html | 140 ++++++++++++++++++ .../reports/entry-order/entry-order.js | 80 ++++++++++ .../reports/entry-order/locale/en.yml | 0 .../reports/entry-order/locale/es.yml | 16 ++ 7 files changed, 264 insertions(+), 13 deletions(-) create mode 100644 print/templates/reports/entry-order/assets/css/import.js create mode 100644 print/templates/reports/entry-order/assets/css/style.css create mode 100644 print/templates/reports/entry-order/entry-order.html create mode 100755 print/templates/reports/entry-order/entry-order.js create mode 100644 print/templates/reports/entry-order/locale/en.yml create mode 100644 print/templates/reports/entry-order/locale/es.yml diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index f7d5d94f1c..7ef68f3a06 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -35,7 +35,7 @@ INSERT INTO `vn`.`packagingConfig`(`upperGap`) UPDATE `account`.`role` SET id = 100 WHERE id = 0; INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`, `lang`) - SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'EN' + SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'en' FROM `account`.`role` WHERE id <> 20 ORDER BY id; @@ -55,18 +55,18 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`) VALUES - (101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'ES'), - (102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'EN'), - (103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'FR'), - (104, 'TonyStark', 'Tony Stark', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'TonyStark@mydomain.com', 'ES'), - (105, 'MaxEisenhardt', 'Max Eisenhardt', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'MaxEisenhardt@mydomain.com', 'PT'), - (106, 'DavidCharlesHaller', 'David Charles Haller', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'DavidCharlesHaller@mydomain.com', 'EN'), - (107, 'HankPym', 'Hank Pym', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'HankPym@mydomain.com', 'EN'), - (108, 'CharlesXavier', 'Charles Xavier', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'CharlesXavier@mydomain.com', 'EN'), - (109, 'BruceBanner', 'Bruce Banner', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'BruceBanner@mydomain.com', 'EN'), - (110, 'JessicaJones', 'Jessica Jones', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'JessicaJones@mydomain.com', 'EN'), - (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'EN'), - (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'EN'); + (101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'es'), + (102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'en'), + (103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'fr'), + (104, 'TonyStark', 'Tony Stark', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'TonyStark@mydomain.com', 'es'), + (105, 'MaxEisenhardt', 'Max Eisenhardt', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt'), + (106, 'DavidCharlesHaller', 'David Charles Haller', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en'), + (107, 'HankPym', 'Hank Pym', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'HankPym@mydomain.com', 'en'), + (108, 'CharlesXavier', 'Charles Xavier', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'CharlesXavier@mydomain.com', 'en'), + (109, 'BruceBanner', 'Bruce Banner', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'BruceBanner@mydomain.com', 'en'), + (110, 'JessicaJones', 'Jessica Jones', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'JessicaJones@mydomain.com', 'en'), + (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en'), + (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en'); INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`) VALUES diff --git a/print/templates/reports/entry-order/assets/css/import.js b/print/templates/reports/entry-order/assets/css/import.js new file mode 100644 index 0000000000..fd8796c2bf --- /dev/null +++ b/print/templates/reports/entry-order/assets/css/import.js @@ -0,0 +1,9 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/spacing.css`, + `${appPath}/common/css/misc.css`, + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css new file mode 100644 index 0000000000..4215e71811 --- /dev/null +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -0,0 +1,6 @@ + + +h3 { + font-weight: 100; + color: #555 +} \ 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 new file mode 100644 index 0000000000..170351cec9 --- /dev/null +++ b/print/templates/reports/entry-order/entry-order.html @@ -0,0 +1,140 @@ + + + + + + + + + +
+ +
+
+ + +
+
+ +
+
+
+
+
+
+

{{$t('title')}}

+ + + + + + + + + + + + + + + +
{{$t('entryId')}}{{entry.id}}
{{$t('date')}}{{entry.landed | date('%d-%m-%Y')}}
{{$t('ref')}}{{entry.ref}}
+
+
+
+
+
+
{{$t('supplierData')}}
+
+

{{supplier.name}}

+
+ {{supplier.street}} +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
{{$t('boxes')}}{{$t('packing')}}{{$t('concept')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}
+ {{$t('total')}} + {{getTotal() | currency('EUR', locale)}}
+ +
+
+
+
+

{{$t('notes')}}

+
+ {{entry.notes}} +
+
+
+
+
+
+
+ +
+
+ + +
+
+
+ + \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.js b/print/templates/reports/entry-order/entry-order.js new file mode 100755 index 0000000000..6317871e4b --- /dev/null +++ b/print/templates/reports/entry-order/entry-order.js @@ -0,0 +1,80 @@ +const db = require(`${appPath}/core/database`); +const Component = require(`${appPath}/core/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); + +module.exports = { + name: 'entry-order', + async serverPrefetch() { + this.supplier = await this.fetchSupplier(this.entryId); + this.entry = await this.fetchEntry(this.entryId); + this.buys = await this.fetchBuys(this.entryId); + + if (!this.entry) + throw new Error('Something went wrong'); + }, + data() { + return {totalBalance: 0.00}; + }, + methods: { + fetchSupplier(entryId) { + return db.findOne( + `SELECT + s.name, + s.street + FROM supplier s + JOIN entry e ON e.supplierFk = s.id + WHERE e.id = ?`, [entryId]); + }, + fetchEntry(entryId) { + return db.findOne( + `SELECT + e.id, + e.ref, + e.notes, + c.code companyCode, + t.landed + FROM entry e + JOIN travel t ON t.id = e.travelFk + JOIN company c ON c.id = e.companyFk + WHERE e.id = ?`, [entryId]); + }, + fetchBuys(entryId) { + return db.rawSql( + `SELECT + b.itemFk, + b.quantity, + b.buyingValue, + b.stickers box, + b.packing, + i.name itemName, + i.tag5, + i.value5, + i.tag6, + i.value6, + i.tag7, + i.value7 + FROM buy b + JOIN item i ON i.id = b.itemFk + WHERE b.entryFk = ?`, [entryId]); + }, + getTotal() { + let total = 0.00; + this.buys.forEach(buy => { + total += buy.quantity * buy.buyingValue; + }); + + return total; + } + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() + }, + props: { + entryId: { + type: String, + required: true + } + } +}; diff --git a/print/templates/reports/entry-order/locale/en.yml b/print/templates/reports/entry-order/locale/en.yml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/print/templates/reports/entry-order/locale/es.yml b/print/templates/reports/entry-order/locale/es.yml new file mode 100644 index 0000000000..dd4861f9de --- /dev/null +++ b/print/templates/reports/entry-order/locale/es.yml @@ -0,0 +1,16 @@ +title: Pedido +supplierName: Proveedor +supplierStreet: Dirección +entryId: Pedido nº +date: Fecha +ref: Referencia +boxes: Cajas +packing: U/C +quantity: Cantidad +price: Precio +amount: Importe +concept: Descripción +total: Total +entry: Entrada {0} +supplierData: Datos del proveedor +notes: Notas \ No newline at end of file From 587653fb40be0053f68d8064bc767fb5c1108a1a Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 20 Feb 2020 09:31:44 +0100 Subject: [PATCH 29/55] #2119 e2e item.request --- db/dump/fixtures.sql | 2 +- e2e/helpers/selectors.js | 3 ++- e2e/paths/04-item/13_request.spec.js | 7 +++---- .../back/methods/ticket-request/specs/filter.spec.js | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index f7d5d94f1c..fc509b39c6 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1530,7 +1530,7 @@ INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `attenderFk VALUES (1, 'Ranged weapon longbow 2m', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), (2, 'Melee weapon combat first 15cm', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (3, 'Melee weapon heavy shield 1x0.5m', 18, 35, 20, 4, 3.06, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (3, 'Melee weapon heavy shield 1x0.5m', 18, 35, 20, NULL, 3.06, NULL, NULL, 23, CURDATE()), (4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, CURDATE()), (5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, CURDATE()); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 1e6a30bb5e..aa808688bd 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -254,8 +254,9 @@ export default { firstRequestItemID: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td-editable:nth-child(7)', firstRequestQuantity: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td-editable:nth-child(8)', firstRequestConcept: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(9)', + secondRequestStatus: 'vn-item-request vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(10)', firstRequestStatus: 'vn-item-request vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(10)', - firstRequestDecline: 'vn-item-request vn-tbody > vn-tr:nth-child(1) vn-icon-button[icon="thumb_down"]', + secondRequestDecline: 'vn-item-request vn-tbody > vn-tr:nth-child(1) vn-icon-button[icon="thumb_down"]', declineReason: 'vn-textarea[ng-model="$ctrl.denyObservation"]', acceptDeclineReason: 'button[response="accept"]', diff --git a/e2e/paths/04-item/13_request.spec.js b/e2e/paths/04-item/13_request.spec.js index adb7e52786..d6aecbb48e 100644 --- a/e2e/paths/04-item/13_request.spec.js +++ b/e2e/paths/04-item/13_request.spec.js @@ -1,8 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -// #2119 e2e item.request -xdescribe('Item request path', () => { +describe('Item request path', () => { let browser; let page; beforeAll(async() => { @@ -37,8 +36,8 @@ xdescribe('Item request path', () => { expect(status).toContain('Aceptada'); }); - it('should now click on the first declain request icon then type the reason', async() => { - await page.waitToClick(selectors.itemRequest.firstRequestDecline); + 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.waitToClick(selectors.itemRequest.acceptDeclineReason); await page.waitForContentLoaded(); diff --git a/modules/ticket/back/methods/ticket-request/specs/filter.spec.js b/modules/ticket/back/methods/ticket-request/specs/filter.spec.js index 329688866b..175bf9c1a3 100644 --- a/modules/ticket/back/methods/ticket-request/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/filter.spec.js @@ -1,12 +1,12 @@ const app = require('vn-loopback/server/server'); describe('ticket-request filter()', () => { - it('should return all ticket requests', async() => { + it('should now return all ticket requests', async() => { let ctx = {req: {accessToken: {userId: 9}}, args: {}}; let result = await app.models.TicketRequest.filter(ctx); - expect(result.length).toEqual(2); + expect(result.length).toEqual(3); }); it('should return the ticket request matching a generic search value which is the ticket ID', async() => { @@ -42,7 +42,7 @@ describe('ticket-request filter()', () => { let result = await app.models.TicketRequest.filter(ctx); let requestId = result[0].id; - expect(requestId).toEqual(4); + expect(requestId).toEqual(3); }); it('should return the ticket request matching the isOk triple-state', async() => { @@ -51,7 +51,7 @@ describe('ticket-request filter()', () => { let result = await app.models.TicketRequest.filter(ctx); let requestId = result[0].id; - expect(requestId).toEqual(4); + expect(requestId).toEqual(3); }); it('should return the ticket request matching the client ID', async() => { @@ -69,7 +69,7 @@ describe('ticket-request filter()', () => { let result = await app.models.TicketRequest.filter(ctx); let requestId = result[0].id; - expect(requestId).toEqual(4); + expect(requestId).toEqual(3); }); it('should return the ticket request matching the salesPerson ID', async() => { @@ -78,6 +78,6 @@ describe('ticket-request filter()', () => { let result = await app.models.TicketRequest.filter(ctx); let requestId = result[0].id; - expect(requestId).toEqual(4); + expect(requestId).toEqual(3); }); }); From 5e1f31ebdd3093453065cd770711839f49addee8 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 20 Feb 2020 09:32:47 +0100 Subject: [PATCH 30/55] hotfix #2135 - Don't enable inputs disabled by ACL directive --- front/core/components/button/index.js | 4 +++- front/core/directives/http-click.js | 7 +++++-- front/core/directives/http-submit.js | 8 ++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/front/core/components/button/index.js b/front/core/components/button/index.js index 96d68c23b1..e8c9988014 100644 --- a/front/core/components/button/index.js +++ b/front/core/components/button/index.js @@ -29,8 +29,10 @@ export default class Button extends FormInput { } onClick(event) { - if (this.disabled) + if (this.disabled) { + event.preventDefault(); event.stopImmediatePropagation(); + } } } Button.$inject = ['$element', '$scope']; diff --git a/front/core/directives/http-click.js b/front/core/directives/http-click.js index 5e69d81d1d..9f8426cef2 100644 --- a/front/core/directives/http-click.js +++ b/front/core/directives/http-click.js @@ -14,10 +14,13 @@ export function directive($parse) { const cb = $parse($attrs.vnHttpClick); const element = $element[0]; $element.on('click', () => { - element.$ctrl.disabled = true; + const controller = element.$ctrl; + controller.$oldDisabled = field.$ctrl.disabled; + controller.disabled = true; cb($scope).finally(() => { - element.$ctrl.disabled = false; + if (!controller.$oldDisabled) + controller.disabled = false; }); }); } diff --git a/front/core/directives/http-submit.js b/front/core/directives/http-submit.js index 0cf17866e8..3d93f02200 100644 --- a/front/core/directives/http-submit.js +++ b/front/core/directives/http-submit.js @@ -19,12 +19,16 @@ export function directive($parse) { const fields = angular.element(elements); angular.forEach(fields, field => { - field.$ctrl.disabled = true; + const controller = field.$ctrl; + controller.$oldDisabled = controller.disabled; + controller.disabled = true; }); cb($scope).finally(() => { angular.forEach(fields, field => { - field.$ctrl.disabled = false; + const controller = field.$ctrl; + if (!controller.$oldDisabled) + controller.disabled = false; }); }); }); From 17523a220778c8bb54743e2425624e1e54aeb33d Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 20 Feb 2020 09:32:47 +0100 Subject: [PATCH 31/55] hotfix #2135 - Don't enable inputs disabled by ACL directive --- front/core/components/button/index.js | 4 +++- front/core/directives/http-click.js | 7 +++++-- front/core/directives/http-submit.js | 8 ++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/front/core/components/button/index.js b/front/core/components/button/index.js index 17710967a0..86cfc21368 100644 --- a/front/core/components/button/index.js +++ b/front/core/components/button/index.js @@ -26,8 +26,10 @@ export default class Button extends FormInput { } onClick(event) { - if (this.disabled) + if (this.disabled) { + event.preventDefault(); event.stopImmediatePropagation(); + } } } Button.$inject = ['$element', '$scope']; diff --git a/front/core/directives/http-click.js b/front/core/directives/http-click.js index 5e69d81d1d..9f8426cef2 100644 --- a/front/core/directives/http-click.js +++ b/front/core/directives/http-click.js @@ -14,10 +14,13 @@ export function directive($parse) { const cb = $parse($attrs.vnHttpClick); const element = $element[0]; $element.on('click', () => { - element.$ctrl.disabled = true; + const controller = element.$ctrl; + controller.$oldDisabled = field.$ctrl.disabled; + controller.disabled = true; cb($scope).finally(() => { - element.$ctrl.disabled = false; + if (!controller.$oldDisabled) + controller.disabled = false; }); }); } diff --git a/front/core/directives/http-submit.js b/front/core/directives/http-submit.js index 0cf17866e8..3d93f02200 100644 --- a/front/core/directives/http-submit.js +++ b/front/core/directives/http-submit.js @@ -19,12 +19,16 @@ export function directive($parse) { const fields = angular.element(elements); angular.forEach(fields, field => { - field.$ctrl.disabled = true; + const controller = field.$ctrl; + controller.$oldDisabled = controller.disabled; + controller.disabled = true; }); cb($scope).finally(() => { angular.forEach(fields, field => { - field.$ctrl.disabled = false; + const controller = field.$ctrl; + if (!controller.$oldDisabled) + controller.disabled = false; }); }); }); From 64e4593156b61fb5e0239bc75d539cf75a193af7 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 20 Feb 2020 10:46:43 +0100 Subject: [PATCH 32/55] Renamed version number --- db/changes/{10141-kings => 10142-kings}/00-ACL.sql | 0 db/changes/{10141-kings => 10142-kings}/01-customsAgent.sql | 0 db/changes/{10141-kings => 10142-kings}/02-incoterms.sql | 0 db/changes/{10141-kings => 10142-kings}/03-address.sql | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename db/changes/{10141-kings => 10142-kings}/00-ACL.sql (100%) rename db/changes/{10141-kings => 10142-kings}/01-customsAgent.sql (100%) rename db/changes/{10141-kings => 10142-kings}/02-incoterms.sql (100%) rename db/changes/{10141-kings => 10142-kings}/03-address.sql (100%) diff --git a/db/changes/10141-kings/00-ACL.sql b/db/changes/10142-kings/00-ACL.sql similarity index 100% rename from db/changes/10141-kings/00-ACL.sql rename to db/changes/10142-kings/00-ACL.sql diff --git a/db/changes/10141-kings/01-customsAgent.sql b/db/changes/10142-kings/01-customsAgent.sql similarity index 100% rename from db/changes/10141-kings/01-customsAgent.sql rename to db/changes/10142-kings/01-customsAgent.sql diff --git a/db/changes/10141-kings/02-incoterms.sql b/db/changes/10142-kings/02-incoterms.sql similarity index 100% rename from db/changes/10141-kings/02-incoterms.sql rename to db/changes/10142-kings/02-incoterms.sql diff --git a/db/changes/10141-kings/03-address.sql b/db/changes/10142-kings/03-address.sql similarity index 100% rename from db/changes/10141-kings/03-address.sql rename to db/changes/10142-kings/03-address.sql From 4c1ee5ad4a3c00c574bbd97199a60e5ed17d2a03 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 20 Feb 2020 10:57:06 +0100 Subject: [PATCH 33/55] http-click fix --- front/core/directives/http-click.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/directives/http-click.js b/front/core/directives/http-click.js index 9f8426cef2..4fd9322896 100644 --- a/front/core/directives/http-click.js +++ b/front/core/directives/http-click.js @@ -15,7 +15,7 @@ export function directive($parse) { const element = $element[0]; $element.on('click', () => { const controller = element.$ctrl; - controller.$oldDisabled = field.$ctrl.disabled; + controller.$oldDisabled = controller.disabled; controller.disabled = true; cb($scope).finally(() => { From 2f089681df8b64698c3d3508604f2bda82ae7ffc Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 20 Feb 2020 12:52:05 +0100 Subject: [PATCH 34/55] Don't throw error if no salesPerson is assigned --- modules/ticket/back/methods/ticket/updateDiscount.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 66b4d6f95f..8777a60fca 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -108,8 +108,10 @@ module.exports = Self => { await Promise.all(promises); - query = `call vn.manaSpellersRequery(?)`; - await Self.rawSql(query, [salesPersonId], options); + if (salesPersonId) { + const query = `call vn.manaSpellersRequery(?)`; + await Self.rawSql(query, [salesPersonId], options); + } await tx.commit(); } catch (error) { From a8137c8a6b650bbae9c99cabeac052a8a4f91571 Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 20 Feb 2020 15:15:50 +0100 Subject: [PATCH 35/55] zoneClosure 3 --- db/changes/10141-zoneDoCalc/00-ticket.sql | 18 +--- .../01-ticketCreateWithUser.sql | 96 +++++++++++++++++++ .../01-ticket_componentUpdate.sql | 82 ++++++++++++++++ .../10141-zoneDoCalc/01-ticket_doCalc.sql | 56 ----------- .../01-zoneClosure_recalc.sql | 49 ++++++++++ .../10141-zoneDoCalc/02-insertPastTickets.sql | 8 +- .../03-zone_geShippedWarehouse.sql | 6 +- db/dump/fixtures.sql | 2 + modules/agency/back/model-config.json | 2 +- .../{zone-calc-ticket.js => zone-closure.js} | 10 +- ...one-calc-ticket.json => zone-closure.json} | 12 ++- 11 files changed, 255 insertions(+), 86 deletions(-) create mode 100644 db/changes/10141-zoneDoCalc/01-ticketCreateWithUser.sql create mode 100644 db/changes/10141-zoneDoCalc/01-ticket_componentUpdate.sql delete mode 100644 db/changes/10141-zoneDoCalc/01-ticket_doCalc.sql create mode 100644 db/changes/10141-zoneDoCalc/01-zoneClosure_recalc.sql rename modules/agency/back/models/{zone-calc-ticket.js => zone-closure.js} (61%) rename modules/agency/back/models/{zone-calc-ticket.json => zone-closure.json} (62%) diff --git a/db/changes/10141-zoneDoCalc/00-ticket.sql b/db/changes/10141-zoneDoCalc/00-ticket.sql index a756a11afe..fa091f111a 100644 --- a/db/changes/10141-zoneDoCalc/00-ticket.sql +++ b/db/changes/10141-zoneDoCalc/00-ticket.sql @@ -1,19 +1,3 @@ ALTER TABLE `vn`.`ticket` ADD COLUMN `zonePrice` DECIMAL(10,2) NULL DEFAULT NULL AFTER `collectionFk`, -ADD COLUMN `zoneBonus` DECIMAL(10,2) NULL DEFAULT NULL AFTER `zonePrice`, -ADD COLUMN `zoneClosure` TIME NULL AFTER `zoneBonus`; - -CREATE TABLE `vn`.`zoneCalcTicket` ( - `zoneFk` int(11) NOT NULL PRIMARY KEY, - CONSTRAINT `zoneCalcTicketfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `vn`.`zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - -DROP EVENT IF EXISTS vn.`zone_doCalc`; -CREATE DEFINER=`root`@`%` EVENT vn.`zone_doCalc` - ON SCHEDULE EVERY 15 SECOND STARTS '2020-01-31 11:32:30' - ON COMPLETION PRESERVE ENABLE - DO CALL util.procNoOverlap('vn.zone_doCalc'); - -DROP TABLE `vn`.`zoneConfig`; - -DROP procedure IF EXISTS vn.`zoneClosure_recalc`; \ No newline at end of file +ADD COLUMN `zoneBonus` DECIMAL(10,2) NULL DEFAULT NULL AFTER `zonePrice`; diff --git a/db/changes/10141-zoneDoCalc/01-ticketCreateWithUser.sql b/db/changes/10141-zoneDoCalc/01-ticketCreateWithUser.sql new file mode 100644 index 0000000000..867cd1c0da --- /dev/null +++ b/db/changes/10141-zoneDoCalc/01-ticketCreateWithUser.sql @@ -0,0 +1,96 @@ +USE `vn`; +DROP procedure IF EXISTS `ticketCreateWithUser`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `ticketCreateWithUser`( + vClientId INT + ,vShipped DATE + ,vWarehouseFk INT + ,vCompanyFk INT + ,vAddressFk INT + ,vAgencyModeFk INT + ,vRouteFk INT + ,vlanded DATE + ,vUserId INT + ,OUT vNewTicket INT) +BEGIN + + DECLARE vZoneFk INT; + DECLARE vPrice DECIMAL(10,2); + DECLARE vBonus DECIMAL(10,2); + + IF vClientId IS NULL THEN + CALL util.throw ('CLIENT_NOT_ESPECIFIED'); + END IF; + + IF NOT vAddressFk OR vAddressFk IS NULL THEN + SELECT id INTO vAddressFk + FROM address + WHERE clientFk = vClientId AND isDefaultAddress; + END IF; + + IF vAgencyModeFk IS NOT NULL THEN + + CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); + + SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus + FROM tmp.zoneGetShipped + WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; + + IF vZoneFk IS NULL OR vZoneFk = 0 THEN + CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS'); + END IF; + END IF; + INSERT INTO ticket ( + clientFk, + shipped, + addressFk, + agencyModeFk, + nickname, + warehouseFk, + routeFk, + companyFk, + landed, + zoneFk, + zonePrice, + zoneBonus + ) + SELECT + vClientId, + vShipped, + a.id, + vAgencyModeFk, + a.nickname, + vWarehouseFk, + IF(vRouteFk,vRouteFk,NULL), + vCompanyFk, + vlanded, + vZoneFk, + vPrice, + vBonus + FROM address a + JOIN agencyMode am ON am.id = a.agencyModeFk + WHERE a.id = vAddressFk; + + SET vNewTicket = LAST_INSERT_ID(); + + INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) + SELECT vNewTicket, ao.observationTypeFk, ao.description + FROM addressObservation ao + JOIN address a ON a.id = ao.addressFk + WHERE a.id = vAddressFk; + + INSERT INTO vn.ticketLog + SET originFk = vNewTicket, userFk = vUserId, `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket); + + IF (SELECT ct.isCreatedAsServed FROM vn.clientType ct JOIN vn.client c ON c.typeFk = ct.code WHERE c.id = vClientId ) <> FALSE THEN + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT id, vNewTicket, getWorker() + FROM state + WHERE `code` = 'DELIVERED'; + END IF; +END$$ + +DELIMITER ; + diff --git a/db/changes/10141-zoneDoCalc/01-ticket_componentUpdate.sql b/db/changes/10141-zoneDoCalc/01-ticket_componentUpdate.sql new file mode 100644 index 0000000000..14ff6f484e --- /dev/null +++ b/db/changes/10141-zoneDoCalc/01-ticket_componentUpdate.sql @@ -0,0 +1,82 @@ +USE `vn`; +DROP procedure IF EXISTS `ticket_componentUpdate`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_componentUpdate`( + vTicketFk INT, + vClientFk INT, + vAgencyModeFk INT, + vAddressFk INT, + vZoneFk INT, + vWarehouseFk TINYINT, + vCompanyFk SMALLINT, + vShipped DATETIME, + vLanded DATE, + vIsDeleted BOOLEAN, + vHasToBeUnrouted BOOLEAN, + vOption INT) +BEGIN + DECLARE vPrice DECIMAL(10,2); + DECLARE vBonus DECIMAL(10,2); + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN + + UPDATE ticket t + JOIN address a ON a.id = vAddressFk + SET t.nickname = a.nickname + WHERE t.id = vTicketFk; + + END IF; + + CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); + + SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus + FROM tmp.zoneGetShipped + WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; + + UPDATE ticket t + SET + t.clientFk = vClientFk, + t.agencyModeFk = vAgencyModeFk, + t.addressFk = vAddressFk, + t.zoneFk = vZoneFk, + t.zonePrice = vPrice, + t.zoneBonus = vBonus, + t.warehouseFk = vWarehouseFk, + t.companyFk = vCompanyFk, + t.landed = vLanded, + t.shipped = vShipped, + t.isDeleted = vIsDeleted + WHERE + t.id = vTicketFk; + + IF vHasToBeUnrouted THEN + UPDATE ticket t SET t.routeFk = NULL + WHERE t.id = vTicketFk; + END IF; + + IF vOption <> 8 THEN + DROP TEMPORARY TABLE IF EXISTS tmp.sale; + CREATE TEMPORARY TABLE tmp.sale + (PRIMARY KEY (saleFk)) + ENGINE = MEMORY + SELECT id AS saleFk, vWarehouseFk warehouseFk + FROM sale s WHERE s.ticketFk = vTicketFk; + + CALL ticketComponentUpdateSale (vOption); + + DROP TEMPORARY TABLE tmp.sale; + END IF; + COMMIT; +END$$ + +DELIMITER ; + diff --git a/db/changes/10141-zoneDoCalc/01-ticket_doCalc.sql b/db/changes/10141-zoneDoCalc/01-ticket_doCalc.sql deleted file mode 100644 index d7538ff84e..0000000000 --- a/db/changes/10141-zoneDoCalc/01-ticket_doCalc.sql +++ /dev/null @@ -1,56 +0,0 @@ -USE `vn`; -DROP procedure IF EXISTS `zone_doCalc`; - -DELIMITER $$ -USE `vn`$$ -CREATE DEFINER=`root`@`%` PROCEDURE `zone_doCalc`() -proc: BEGIN -/** - * Updates ticket fields related with zone - */ - DECLARE vDone BOOL; - DECLARE vTicketFk INT; - DECLARE vShipped DATE; - DECLARE vZoneFk INT; - - DECLARE cCur CURSOR FOR - SELECT t.id, t.shipped, t.zoneFk - FROM zoneCalcTicket zct - JOIN ticket t ON t.zoneFk = zct.zoneFk - WHERE shipped >= CURDATE(); - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - OPEN cCur; - - myLoop: LOOP - SET vDone = FALSE; - FETCH cCur INTO vTicketFk, vShipped, vZoneFk; - - IF vDone THEN - LEAVE myLoop; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tmp.zone; - CREATE TEMPORARY TABLE tmp.zone - (INDEX (id)) - ENGINE = MEMORY - SELECT vZoneFk id; - - CALL zone_getOptionsForShipment(vShipped, TRUE); - - UPDATE ticket t - LEFT JOIN tmp.zoneOption zo ON TRUE - SET zonePrice = zo.price, zoneBonus = zo.bonus, zoneClosure = zo.`hour` - WHERE t.id = vTicketFk; - - END LOOP; - - CLOSE cCur; - - DELETE FROM zoneCalcTicket; -END$$ - -DELIMITER ; - diff --git a/db/changes/10141-zoneDoCalc/01-zoneClosure_recalc.sql b/db/changes/10141-zoneDoCalc/01-zoneClosure_recalc.sql new file mode 100644 index 0000000000..b7dbf675ad --- /dev/null +++ b/db/changes/10141-zoneDoCalc/01-zoneClosure_recalc.sql @@ -0,0 +1,49 @@ +USE `vn`; +DROP procedure IF EXISTS `zoneClosure_recalc`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `zoneClosure_recalc`() +proc: BEGIN +/** + * Recalculates the delivery time (hour) for every zone in days + scope in future + */ + DECLARE vScope INT; + DECLARE vCounter INT DEFAULT 0; + DECLARE vShipped DATE DEFAULT CURDATE(); + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK('vn.zoneClosure_recalc'); + RESIGNAL; + END; + + IF NOT GET_LOCK('vn.zoneClosure_recalc', 0) THEN + LEAVE proc; + END IF; + + SELECT scope INTO vScope + FROM zoneConfig; + + DROP TEMPORARY TABLE IF EXISTS tmp.zone; + CREATE TEMPORARY TABLE tmp.zone + (INDEX (id)) + ENGINE = MEMORY + SELECT id FROM zone; + + TRUNCATE TABLE zoneClosure; + + WHILE vCounter <= vScope DO + CALL zone_getOptionsForShipment(vShipped, TRUE); + INSERT INTO zoneClosure(zoneFk, dated, `hour`) + SELECT zoneFk, vShipped, `hour` FROM tmp.zoneOption; + + SET vCounter = vCounter + 1; + SET vShipped = TIMESTAMPADD(DAY, 1, vShipped); + END WHILE; + + DROP TEMPORARY TABLE tmp.zone; + DO RELEASE_LOCK('vn.zoneClosure_recalc'); +END$$ + +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10141-zoneDoCalc/02-insertPastTickets.sql b/db/changes/10141-zoneDoCalc/02-insertPastTickets.sql index 4314e5d7d9..864bf04c65 100644 --- a/db/changes/10141-zoneDoCalc/02-insertPastTickets.sql +++ b/db/changes/10141-zoneDoCalc/02-insertPastTickets.sql @@ -7,6 +7,7 @@ CREATE DEFINER=`root`@`%` PROCEDURE `zone_doCalcInitialize`() proc: BEGIN /** * Initialize ticket + * si en 01-07-20 aun esta este proc, kkear */ DECLARE vDone BOOL; DECLARE vTicketFk INT; @@ -16,7 +17,7 @@ proc: BEGIN DECLARE cCur CURSOR FOR SELECT t.id, t.landed, t.zoneFk FROM ticket t - WHERE (zonePrice IS NULL OR zoneBonus IS NULL OR zoneClosure IS NULL) + WHERE (zonePrice IS NULL OR zoneBonus IS NULL) AND landed >= '2019-01-01' AND shipped >= '2019-01-01' GROUP BY landed, zoneFk; @@ -43,12 +44,12 @@ proc: BEGIN UPDATE ticket t LEFT JOIN tmp.zoneOption zo ON TRUE - SET zonePrice = zo.price, zoneBonus = zo.bonus, zoneClosure = zo.`hour` + SET zonePrice = zo.price, zoneBonus = zo.bonus WHERE t.zoneFk = vZoneFk AND landed = vLanded; UPDATE ticket t LEFT JOIN vn.zone z ON z.id = t.zoneFk - SET zonePrice = z.price, zoneBonus = z.bonus, zoneClosure = z.`hour` + SET zonePrice = z.price, zoneBonus = z.bonus WHERE t.zonePrice IS NULL AND z.id = vZoneFk AND landed >= '2019-01-01' AND shipped >= '2019-01-01'; @@ -56,7 +57,6 @@ proc: BEGIN CLOSE cCur; - DELETE FROM zoneCalcTicket; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/changes/10141-zoneDoCalc/03-zone_geShippedWarehouse.sql b/db/changes/10141-zoneDoCalc/03-zone_geShippedWarehouse.sql index 14d5d8cd9a..b4605ec042 100644 --- a/db/changes/10141-zoneDoCalc/03-zone_geShippedWarehouse.sql +++ b/db/changes/10141-zoneDoCalc/03-zone_geShippedWarehouse.sql @@ -6,7 +6,7 @@ USE `vn`$$ CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) BEGIN /** - * Devuelve la mínima fecha de envío para cada warehouse + * Devuelve la mínima fecha de envío para cada warehouse * * @param vLanded La fecha de recepcion * @param vAddressFk Id del consignatario @@ -25,7 +25,9 @@ BEGIN TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped, zo.`hour`, zw.warehouseFk, - z.agencyModeFk + z.agencyModeFk, + zo.price, + zo.bonus FROM tmp.zoneOption zo JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk JOIN zone z ON z.id = zo.zoneFk diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 87b915ec00..67db4dd779 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -497,6 +497,8 @@ INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) (11, 11, 5), (12, 12, 4), (13, 13, 5); + +INSERT INTO `vn`.`zoneConfig` (`scope`) VALUES ('1'); INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`) VALUES diff --git a/modules/agency/back/model-config.json b/modules/agency/back/model-config.json index c9a49ffe9b..7638e3f6c5 100644 --- a/modules/agency/back/model-config.json +++ b/modules/agency/back/model-config.json @@ -11,7 +11,7 @@ "Zone": { "dataSource": "vn" }, - "ZoneCalcTicket": { + "ZoneClosure": { "dataSource": "vn" }, "ZoneEvent": { diff --git a/modules/agency/back/models/zone-calc-ticket.js b/modules/agency/back/models/zone-closure.js similarity index 61% rename from modules/agency/back/models/zone-calc-ticket.js rename to modules/agency/back/models/zone-closure.js index c3633e8f42..d25d6f7074 100644 --- a/modules/agency/back/models/zone-calc-ticket.js +++ b/modules/agency/back/models/zone-closure.js @@ -1,6 +1,5 @@ const app = require('vn-loopback/server/server'); - module.exports = Self => { app.on('started', function() { let models = ['Zone', 'ZoneEvent', 'ZoneExclusion']; @@ -14,10 +13,13 @@ module.exports = Self => { async function doCalc(ctx) { try { - await Self.create({zoneFk: ctx.instance.zoneFk || ctx.instance.id}); + await Self.rawSql(` + CREATE EVENT zoneClosure_doRecalc + ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 15 SECOND + DO CALL zoneClosure_recalc; + `); } catch (err) { - if (err.code != 'ER_DUP_ENTRY') - throw err; + if (err.code != 'ER_EVENT_ALREADY_EXISTS') throw err; } } }); diff --git a/modules/agency/back/models/zone-calc-ticket.json b/modules/agency/back/models/zone-closure.json similarity index 62% rename from modules/agency/back/models/zone-calc-ticket.json rename to modules/agency/back/models/zone-closure.json index 5083d08eda..8953748389 100644 --- a/modules/agency/back/models/zone-calc-ticket.json +++ b/modules/agency/back/models/zone-closure.json @@ -1,15 +1,23 @@ { - "name": "ZoneCalcTicket", + "name": "ZoneClosure", "base": "VnModel", "options": { "mysql": { - "table": "zoneCalcTicket" + "table": "zoneClosure" } }, "properties": { "zoneFk": { "id": true, "type": "Number" + }, + "dated": { + "type": "Date", + "required": true + }, + "hour": { + "type": "date", + "required": true } }, "relations": { From d018d9d536e886993ac26808d6ead66b1fe5d1bd Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 21 Feb 2020 07:44:20 +0100 Subject: [PATCH 36/55] fonts --- front/core/styles/icons/salixfont.css | 6 ++++++ front/core/styles/icons/salixfont.svg | 2 ++ front/core/styles/icons/salixfont.ttf | Bin 27668 -> 29868 bytes front/core/styles/icons/salixfont.woff | Bin 27744 -> 29944 bytes 4 files changed, 8 insertions(+) diff --git a/front/core/styles/icons/salixfont.css b/front/core/styles/icons/salixfont.css index 64f2776ea0..505fb8520e 100644 --- a/front/core/styles/icons/salixfont.css +++ b/front/core/styles/icons/salixfont.css @@ -23,6 +23,12 @@ -moz-osx-font-smoothing: grayscale; } +.icon-net:before { + content: "\e95b"; +} +.icon-anonymous:before { + content: "\e95c"; +} .icon-buyrequest:before { content: "\e914"; } diff --git a/front/core/styles/icons/salixfont.svg b/front/core/styles/icons/salixfont.svg index 2c13f601bd..7cd1af528d 100644 --- a/front/core/styles/icons/salixfont.svg +++ b/front/core/styles/icons/salixfont.svg @@ -98,4 +98,6 @@ + + \ No newline at end of file diff --git a/front/core/styles/icons/salixfont.ttf b/front/core/styles/icons/salixfont.ttf index 7a6ad2721937d8b4c55af2aab19a3dfa22ba4c22..08a36a48ba00ae23f523cc473aff246dd4a0c945 100644 GIT binary patch delta 2547 zcmZ8jOKcm*8J^i$&TyAI(nw3~niL-^Qsjz^sI0`7s|t>4)l!_;sRbK#4v8BzvHXZ1 zYOORj;9!j+=*c~_X$|y}OOMSVfO{|s19g!Ay%Z?WQ<9?SAwYowMIR`F^k7T-?u zE{D4_^FQYQzwhV2{K-f3y}#0!P(nzK+#!ra-#GpB!ss}UvGWk$S6;okvE_gB51$f3 zOIV+|uyJDxPldI9W-na1wfXxejXz?2laOogUp&9@+M&$#e-W}Z1Nq=0HpB;J1?yL^ zp1yc>`{u15Y`pv0uf9#lce7CV@ao3REfO2w!}@nv2iG>Po3pt!d0{^-FPed)*adHT}*6LftuF6=(ueZ(HKhvb*!x8zUcGn%Cp zx=2sbO&Zgm(qGWu&`;<;4a=w*vqs-IYCLb8FlAxdk1Qd`Y?<++VHr*WMR-fLXnBilpf%a7>J0^4?MrojC=@_Gen;205B4O z{4w4POL3B9h3+Ld3qmU%1=NKt!V!=yy4NGK&uv_E=@A>&Ln6k~}a+gw^>w*L6GDYzKpD)gSa9hg*5w)5t4&r($d1oTawdJIG^7mAOcQ1R4Mz>F$%cw~Ogxsd$ zx$soA&YTpwoU~P(yRsZ=8$`NJ=*yk z8G0ShiRDA-V4{L68W)2B4tLhOy(gCIGH~7UCS`3(b@W0%FVO?)_JkD*&n2?}QWI5>k2k0wE>2tf_ zWKbc&3z126Eo8Z0Q!MiZmo+7L>#K{=3jr70l}MY930th|f>M_4m{LxFZi9&+T*gmG z*S#3`ft9Q{V#Mmy#Pt|NYl;J@g6E)-QoMv+6`a)tg8jR?7}^C#mj`GAL`ZbMY)A&L zwXR9nIWj}elkbqX$j=FJlNO8q*F_)kbeq8YeBtMKTPNM1Ht*J z`@K6ve*wZV5@wcN8kDdoc8i6>1(1xwLyxh>#j|VA{%~z|?bE{3Mb2edC@+?ZGs+!j zq8Wsj>Oq+a4s?XUxgB`z*Xu!*&9+-Fw$Ord;$F1!OcbrKqjWR+`ZG~y^#~Pr?%dfW zxPhABYxQE>Ew0>MZJ%zH`(+H(c8zoO)oGk(p=asehR{DrL)4E2IGp0z`I#`e!HW%B zW^7(@i;L6EMYq6%;&PK`wFwhw5MEQ3GJ3Cb%=dU1d<$0|KH5oRN}rw8_;v2+Tyd8; z2^HvYF>bRlOaEQbf3onMK5^^M-x^)|jO0wcOFp?V@$3C3{=VEdP4)rSSz_p2T(Dt} zb{`R9638E$X5uLk?cFv~PvrjYg*RwctLcq*wl6($23LkJCi)x3_Wh;HAJP8;ISE%x delta 308 zcmZ4Ul5xrn#(D-u1_lOhh6V;^1_S?KeItG$wpyUb9w1Ig&P^;354-e`fq_v5$PY1DmajvSW&=G%XpZ9A(F05!}j$S*DdIur=9zf9cW&KNa`(VH=9vkzlnnkvX2KpempoVcWN6`TRuv|RjK?Yf{9Mj~9CBmEE I7wu&P0PHkRK>z>% diff --git a/front/core/styles/icons/salixfont.woff b/front/core/styles/icons/salixfont.woff index 0e6d9a21a9ba5a148f072d8a8888067e0cc5f283..325a1bc2d042d645d6fe16c72087b875f3117e4e 100644 GIT binary patch delta 2544 zcmZ8jOKcm*8Q$4h&TyAI^hitYiWDC!QskPnsIJ79p&E)R#ZsKuiG>(-4v7mju`D}& zwNmRCP_RZ(6g{Mez^Kt)a_O--6mSngVW2KzAjcLxIVpk^2vDGxK2QYlL6-W>uB4!XouU}icscB>bq;qO}-~RLG zm)15F?E#+C`&(YRdV3wTN1As1H){X!Y2z;&7uVj~r(2KT-Fb<;diOMWfxLSE7i4ukD(vm-J)}GIf%aSNBkfb| z3z8-kGDpskbrO-ElV6iRkWa|JbW^YCQ+i)t)L+og>96Tm^i54mwMqR1>Gzt!G~qSI zvxHBRV4e);Nq+!ZpcwT;XpVHTW(VL6q0npAm1snU72;vJiqVHLEXb8e9xLa1u42v( z6FnT^B1`ftR`F(CWfOvMffYyKK?w_@VJ@EpqykaFDU-7&dk>{iXfQkg-J;L!9l%%Mup@j0Kow+d6r=6di)^M1aIIv6S^Lf9ezF8 z1noFkuYsTvi``yqv7#UeR2&geKq`=Nn7st zC<~UEGgD``L*hag`A|C8C>U_yOa9Nfu4SZe)14T8?(Vgj;chS$0a8W591BAWs6HQ(YE;0~M0mEO*S?JtHfE z>dcmG)RL1bjP^LW4sqyPS!QLZA%U$)A92gf3%g)iVBDqM65IGibWd!H>M~GU1UKRJ8vXuS;DkaCoQn#E^ zJwQ1J3|3AwgWzPjG#b~J(E6nnry-4$Dr=gVM=VEDYjFu3qri-i2UUf)9J5g@j+1QC zCuxR)p(T#CTc<145d*D4X!!?A(BT;>T$>mGhmEkDq~^(mxR#Po@}Dp|g8+@rYh{*U zdR!bkZ;HbImGGcK5h`f7FHc#H1=CM&xl@jz)7CVjmOwU!+54(xI$c%Dy6S7cW6Lzx zd*~XsfiZ1m;+y?(!J5*Tpn-z^ROHj%MO32d;<@_hgR}jKu zR>4l8L;M#*gQ#9eGp{CT>Z@ATBxkK}&V?`fj59|dZ8pL!zN#8ZnwD({kw>|8%Kcyg zKOxokeAEM0qGI!`*{Sgx5eltJ>c2v8leNTH^`<13S@rcFz>tc?$YD}xasD@%Z#XyWFU9BEL(wiOhV*xez z@ovB{!U)CC!R&0-)O#ZrzuIEr5EBfu4w9I1<-@k(OHy|7#VQN~XK?x7VZn1E@fFh&uFk{S7{@luQKU-N|`MmIrB4Z*bl;=vt zqtY3ryy*v*>wcMX26VX2nB}|eH|u_tPPJRFv@n7){9d^9Oc*ZFMY0|~`%Ktbo+tdy zojZFPE+~!vt$H!)7MI>xZok|r_sdwa?dTWk%aibDVrHq|23J2xo!3wLa8B^q{UtY; z&Wa67q%2l(igT0AIj6w<;zE<9l?vq;5N=bHQi|3&>A9?odUHn{U+g3?CHKzq;+xD? zx#B9|2_0xNK5Ees6J?G6e&H|J%#w-i~1; of7fD>6ORizd5Q}Jpcdz delta 332 zcmezIlJUU}MzL~#H#Y`G1|Y~uVBiMRA`Fa^AC`zs)Df<)P0md$U|?X(07`^_uz1*| zhv|vMAhA6_J_i&Fq~}zo0mY6mFr=w~a7A%dVMc0V3Ijv>3!oY^5Eh^Pa%TomkbxmX z0muicV^Co~!XlHATT%fOa{=nF0pY?{?%bUGWS}~`%mYA0V4VJ=nJYK30%&no15iu> zjB6PW=OyN*0>u^pHO>R!xbU0q1^LA#K>s*Q{Nv9UHQ9&Jn=xwh4937TRggb{IFNth z)p&lJuMFHQKmi7ZTeg=L!|4BiC(kO77ytYJ4+{$ From bf4e0d09c5c3a52f870586776610b883d335f1e4 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 21 Feb 2020 08:37:37 +0100 Subject: [PATCH 37/55] Get phone from address and client --- .../back/methods/client/createAddress.js | 26 +++++++------- .../back/methods/client/updateAddress.js | 24 ++++++------- .../back/methods/client/updateFiscalData.js | 36 +++++++++---------- modules/client/front/descriptor/index.js | 5 +-- modules/ticket/front/card/index.js | 4 ++- modules/ticket/front/descriptor/index.js | 4 ++- modules/ticket/front/sale/index.js | 5 ++- 7 files changed, 56 insertions(+), 48 deletions(-) diff --git a/modules/client/back/methods/client/createAddress.js b/modules/client/back/methods/client/createAddress.js index 0319fc386d..1a086b124c 100644 --- a/modules/client/back/methods/client/createAddress.js +++ b/modules/client/back/methods/client/createAddress.js @@ -5,60 +5,60 @@ module.exports = function(Self) { description: 'Creates client address updating default address', accepts: [{ arg: 'id', - type: 'Number', + type: 'number', description: 'The client id', http: {source: 'path'} }, { arg: 'nickname', - type: 'String', + type: 'string', required: true }, { arg: 'city', - type: 'String', + type: 'string', required: true }, { arg: 'street', - type: 'String', + type: 'string', required: true }, { arg: 'phone', - type: 'String' + type: 'string' }, { arg: 'mobile', - type: 'String' + type: 'string' }, { arg: 'postalCode', - type: 'String' + type: 'string' }, { arg: 'provinceId', - type: 'Number' + type: 'number' }, { arg: 'agencyModeId', - type: 'Number' + type: 'number' }, { arg: 'incotermsId', - type: 'String' + type: 'string' }, { arg: 'customsAgentId', - type: 'Number' + type: 'number' }, { arg: 'isActive', - type: 'Boolean' + type: 'boolean' }, { arg: 'isDefaultAddress', - type: 'Boolean' + type: 'boolean' }], returns: { root: true, diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index b9270600fe..aa0a7d178f 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -10,55 +10,55 @@ module.exports = function(Self) { }, { arg: 'clientId', - type: 'Number', + type: ['number', 'null'], description: 'The client id', http: {source: 'path'} }, { arg: 'addressId', - type: 'Number', + type: ['number', 'null'], description: 'The address id', http: {source: 'path'} }, { arg: 'nickname', - type: 'String' + type: ['string'] }, { arg: 'city', - type: 'String' + type: ['string'] }, { arg: 'street', - type: 'String' + type: ['string'] }, { arg: 'phone', - type: 'String' + type: 'any' }, { arg: 'mobile', - type: 'String' + type: 'any' }, { arg: 'postalCode', - type: 'String' + type: 'any' }, { arg: 'provinceFk', - type: 'Number' + type: 'any' }, { arg: 'agencyModeFk', - type: 'Number' + type: 'any' }, { arg: 'incotermsFk', - type: 'String' + type: 'any' }, { arg: 'customsAgentFk', - type: 'Number' + type: 'any' }, { arg: 'isActive', diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index 4bc6fda9b6..f16b0ef2b5 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -17,75 +17,75 @@ module.exports = Self => { }, { arg: 'socialName', - type: 'String' + type: 'string' }, { arg: 'fi', - type: 'String' + type: 'string' }, { arg: 'street', - type: 'String' + type: 'string' }, { arg: 'postcode', - type: 'String' + type: 'string' }, { arg: 'city', - type: 'String' + type: 'string' }, { arg: 'countryFk', - type: 'Number' + type: 'number' }, { arg: 'provinceFk', - type: 'Number' + type: 'number' }, { arg: 'hasToInvoiceByAddress', - type: 'Boolean' + type: 'boolean' }, { arg: 'hasToInvoice', - type: 'Boolean' + type: 'boolean' }, { arg: 'isActive', - type: 'Boolean' + type: 'boolean' }, { arg: 'isFreezed', - type: 'Boolean' + type: 'boolean' }, { arg: 'isVies', - type: 'Boolean' + type: 'boolean' }, { arg: 'isToBeMailed', - type: 'Boolean' + type: 'boolean' }, { arg: 'isEqualizated', - type: 'Boolean' + type: 'boolean' }, { arg: 'isTaxDataVerified', - type: 'Boolean' + type: 'boolean' }, { arg: 'isTaxDataChecked', - type: 'Boolean' + type: 'boolean' }, { arg: 'despiteOfClient', - type: 'Number' + type: 'number' }], returns: { arg: 'res', - type: 'String', + type: 'string', root: true }, http: { diff --git a/modules/client/front/descriptor/index.js b/modules/client/front/descriptor/index.js index 3ef1e76162..95754b4df9 100644 --- a/modules/client/front/descriptor/index.js +++ b/modules/client/front/descriptor/index.js @@ -55,10 +55,11 @@ class Controller extends Component { } showSMSDialog() { - const phone = this.$params.phone || this.client.phone; + const client = this.client; + const phone = this.$params.phone || client.mobile || client.phone; const message = this.$params.message || ''; this.newSMS = { - destinationFk: this.client.id, + destinationFk: client.id, destination: phone, message: message }; diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js index 131968d658..3872259a92 100644 --- a/modules/ticket/front/card/index.js +++ b/modules/ticket/front/card/index.js @@ -27,7 +27,9 @@ class Controller extends ModuleCard { 'isFreezed', 'isTaxDataChecked', 'credit', - 'email' + 'email', + 'phone', + 'mobile' ], include: { relation: 'salesPerson', diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index 10da4cca95..d804a2eb23 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -241,7 +241,9 @@ class Controller extends Component { showSMSDialog() { const address = this.ticket.address; - const phone = this.$params.phone || address.mobile; + const client = this.ticket.client; + const phone = this.$params.phone || address.mobile || address.phone || + client.mobile || client.phone; const message = this.$params.message || this.$translate.instant('SMSPayment'); this.newSMS = { destinationFk: this.ticket.clientFk, diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index d0854c9962..1ecb6fe417 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -431,6 +431,9 @@ class Controller { showSMSDialog() { const address = this.ticket.address; + const client = this.ticket.client; + const phone = address.mobile || address.phone || + client.mobile || client.phone; const sales = this.checkedLines(); const items = sales.map(sale => { return `${sale.quantity} ${sale.concept}`; @@ -443,7 +446,7 @@ class Controller { }; this.newSMS = { destinationFk: this.ticket.clientFk, - destination: address.mobile || null, + destination: phone, message: this.$translate.instant('SMSAvailability', params) }; this.$scope.sms.open(); From 2dbde24a990a5fffed4f449debc2004dce6393ad Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 21 Feb 2020 09:00:13 +0100 Subject: [PATCH 38/55] Requested changes --- .../client/back/methods/client/updateAddress.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index aa0a7d178f..db8ed38d6a 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -10,27 +10,27 @@ module.exports = function(Self) { }, { arg: 'clientId', - type: ['number', 'null'], + type: 'number', description: 'The client id', http: {source: 'path'} }, { arg: 'addressId', - type: ['number', 'null'], + type: 'number', description: 'The address id', http: {source: 'path'} }, { arg: 'nickname', - type: ['string'] + type: 'string' }, { arg: 'city', - type: ['string'] + type: 'string' }, { arg: 'street', - type: ['string'] + type: 'string' }, { arg: 'phone', @@ -62,11 +62,11 @@ module.exports = function(Self) { }, { arg: 'isActive', - type: 'Boolean' + type: 'boolean' }, { arg: 'isEqualizated', - type: 'Boolean' + type: 'boolean' }], returns: { root: true, From 773963e7abab876e31b39cce4ba53875e015792f Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 21 Feb 2020 10:03:08 +0100 Subject: [PATCH 39/55] update entry filter --- modules/entry/back/methods/entry/filter.js | 12 ++++++++++++ modules/entry/front/search-panel/index.html | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index 93e9558a96..ba9b021f50 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -68,6 +68,14 @@ module.exports = Self => { type: 'Number', description: 'The currency id to filter', http: {source: 'query'} + }, { + arg: 'from', + type: 'Date', + description: `The from date filter` + }, { + arg: 'to', + type: 'Date', + description: `The to date filter` } ], returns: { @@ -91,6 +99,10 @@ module.exports = Self => { return {[param]: {like: `%${value}%`}}; case 'created': return {'e.created': {gte: value}}; + case 'from': + return {'t.landed': {gte: value}}; + case 'to': + return {'t.landed': {lte: value}}; case 'id': case 'isBooked': case 'isConfirmed': diff --git a/modules/entry/front/search-panel/index.html b/modules/entry/front/search-panel/index.html index d648edcddc..a3daa8f0f7 100644 --- a/modules/entry/front/search-panel/index.html +++ b/modules/entry/front/search-panel/index.html @@ -54,6 +54,18 @@ ng-model="filter.created"> + + + + + + Date: Fri, 21 Feb 2020 12:48:34 +0100 Subject: [PATCH 40/55] entry summary and descriptor --- db/dump/fixtures.sql | 8 +- modules/entry/back/methods/entry/getEntry.js | 76 ++++++++ .../back/methods/entry/specs/getEntry.spec.js | 31 ++++ modules/entry/back/models/entry.js | 1 + modules/entry/back/models/entry.json | 3 + modules/entry/front/card/index.js | 29 ++- modules/entry/front/descriptor/index.html | 16 +- modules/entry/front/descriptor/index.js | 42 +++++ modules/entry/front/descriptor/locale/es.yml | 2 + modules/entry/front/index/index.html | 8 +- modules/entry/front/summary/index.html | 174 +++++------------- modules/entry/front/summary/index.js | 33 +--- modules/entry/front/summary/index.spec.js | 98 ++-------- modules/entry/front/summary/locale/es.yml | 2 + modules/entry/front/summary/style.scss | 2 +- 15 files changed, 283 insertions(+), 242 deletions(-) create mode 100644 modules/entry/back/methods/entry/getEntry.js create mode 100644 modules/entry/back/methods/entry/specs/getEntry.spec.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index f7d5d94f1c..5d2eb871d2 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1101,11 +1101,11 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`) (104, 500), (105, 5000); -INSERT INTO `vn`.`supplier`(`id`, `name`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`) +INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`) VALUES - (1, 'Plants SL', 4000000001, 1, 'A11111111', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1), - (2, 'Flower King', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2), - (442, 'Verdnatura Levante SL', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2); + (1, 'Plants SL', 'Plants nick', 4000000001, 1, 'A11111111', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1), + (2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2), + (442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2); INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`) VALUES diff --git a/modules/entry/back/methods/entry/getEntry.js b/modules/entry/back/methods/entry/getEntry.js new file mode 100644 index 0000000000..008ee8148f --- /dev/null +++ b/modules/entry/back/methods/entry/getEntry.js @@ -0,0 +1,76 @@ +module.exports = Self => { + Self.remoteMethod('getEntry', { + description: 'Returns an entry', + accessType: 'READ', + accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: `/:id/getEntry`, + verb: 'GET' + } + }); + + Self.getEntry = async id => { + let filter = { + where: {id: id}, + include: [ + { + relation: 'supplier', + scope: { + fields: ['id', 'nickname'] + } + }, + { + relation: 'travel', + scope: { + fields: ['id', 'name', 'shipped', 'landed', 'agencyFk', 'warehouseOutFk', 'warehouseInFk'], + include: [ + { + relation: 'agency', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseOut', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseIn', + scope: { + fields: ['name'] + } + } + ] + } + }, + { + relation: 'currency', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'company', + scope: { + fields: ['id', 'code'] + } + } + ], + }; + + let entry = await Self.app.models.Entry.findOne(filter); + return entry; + }; +}; diff --git a/modules/entry/back/methods/entry/specs/getEntry.spec.js b/modules/entry/back/methods/entry/specs/getEntry.spec.js new file mode 100644 index 0000000000..4baf64543f --- /dev/null +++ b/modules/entry/back/methods/entry/specs/getEntry.spec.js @@ -0,0 +1,31 @@ +const app = require('vn-loopback/server/server'); + +describe('travel getEntry()', () => { + const entryId = 1; + it('should check the entry contains the id', async() => { + const entry = await app.models.Entry.getEntry(entryId); + + expect(entry.id).toEqual(1); + }); + + it('should check the entry contains the supplier name', async() => { + const entry = await app.models.Entry.getEntry(entryId); + const supplierName = entry.supplier().nickname; + + expect(supplierName).toEqual('Plants nick'); + }); + + it('should check the entry contains the receiver warehouse name', async() => { + const entry = await app.models.Entry.getEntry(entryId); + const receiverWarehouseName = entry.travel().warehouseIn().name; + + expect(receiverWarehouseName).toEqual('Warehouse One'); + }); + + it('should check the entry contains the company code', async() => { + const entry = await app.models.Entry.getEntry(entryId); + const companyCode = entry.company().code; + + expect(companyCode).toEqual('VNL'); + }); +}); diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 4034b7e0aa..b1f71b4bd3 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -1,4 +1,5 @@ module.exports = Self => { require('../methods/entry/filter')(Self); + require('../methods/entry/getEntry')(Self); }; diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index a2eef4cd22..c2a7d7c42f 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -39,6 +39,9 @@ "commission": { "type": "Number" }, + "isOrdered": { + "type": "Boolean" + }, "created": { "type": "date" }, diff --git a/modules/entry/front/card/index.js b/modules/entry/front/card/index.js index 62fed7db04..83f47c83d9 100644 --- a/modules/entry/front/card/index.js +++ b/modules/entry/front/card/index.js @@ -11,11 +11,34 @@ class Controller extends ModuleCard { fields: ['id', 'code'] } }, { - relation: 'travel' + relation: 'travel', + scope: { + fields: ['id', 'landed', 'agencyFk', 'warehouseOutFk'], + include: [ + { + relation: 'agency', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseOut', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseIn', + scope: { + fields: ['name'] + } + } + ] + } }, { relation: 'supplier', scope: { - fields: ['id', 'name'] + fields: ['id', 'nickname'] } }, { relation: 'currency' @@ -27,7 +50,7 @@ class Controller extends ModuleCard { } } -ngModule.component('vnEntry Card', { +ngModule.component('vnEntryCard', { template: require('./index.html'), controller: Controller }); diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html index 372479c799..5cb655dc3f 100644 --- a/modules/entry/front/descriptor/index.html +++ b/modules/entry/front/descriptor/index.html @@ -13,9 +13,21 @@ - + + + + + + + + + diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js index a9f5cd6796..e3c00f9ad4 100644 --- a/modules/entry/front/descriptor/index.js +++ b/modules/entry/front/descriptor/index.js @@ -4,6 +4,48 @@ class Controller { constructor($scope) { this.$ = $scope; } + get entry() { + return this._entry; + } + + set entry(value) { + this._entry = value; + if (!value) return; + + const date = value.travel.landed; + let to = new Date(date); + let from = new Date(date); + to.setDate(to.getDate() + 10); + + to.setHours(0, 0, 0, 0); + + from.setDate(from.getDate() - 10); + from.setHours(0, 0, 0, 0); + + let links = { + btnOne: { + icon: 'local_airport', + state: `travel.index({q: '{"agencyFk": ${value.travel.agencyFk}}'})`, + tooltip: 'All travels with current agency' + }}; + + links.btnTwo = { + icon: 'icon-entry', + state: `entry.index({q: '{"supplierFk": ${value.supplierFk}, "to": "${to}", "from": "${from}"}'})`, + tooltip: 'All entries with current supplier' + }; + + + this._quicklinks = links; + } + + get quicklinks() { + return this._quicklinks; + } + + set quicklinks(value = {}) { + this._quicklinks = Object.assign(value, this._quicklinks); + } } Controller.$inject = ['$scope']; diff --git a/modules/entry/front/descriptor/locale/es.yml b/modules/entry/front/descriptor/locale/es.yml index e5b926f1df..6789a1281f 100644 --- a/modules/entry/front/descriptor/locale/es.yml +++ b/modules/entry/front/descriptor/locale/es.yml @@ -1 +1,3 @@ Reference: Referencia +All travels with current agency: Todos los envios con la agencia actual +All entries with current supplier: Todas las entradas con el proveedor actual \ No newline at end of file diff --git a/modules/entry/front/index/index.html b/modules/entry/front/index/index.html index f0f5404899..60bbe46d54 100644 --- a/modules/entry/front/index/index.html +++ b/modules/entry/front/index/index.html @@ -16,7 +16,7 @@ - + Id Landed Reference @@ -33,18 +33,18 @@ - + + icon="icon-anonymous"> + icon="icon-net"> {{::entry.id}} diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index 5397c72ca2..771eaaf7ab 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -1,140 +1,68 @@ -
{{$ctrl.travelData.id}} - {{$ctrl.travelData.ref}}
+
Entrada #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}}
- + - + - - - - - + - + - - + + + value="{{$ctrl.entryData.travel.agency.name}}"> - + - + - + + + - -

Entries

- - - - Confirmed - Entry Id - Supplier - Reference - HB - Freight - Package - CC - Pallet - m3 - - - - - - - - - - {{entry.id}} - {{entry.supplierName}} - {{entry.ref}} - {{entry.hb}} - {{entry.freightValue | currency: 'EUR': 2}} - {{entry.packageValue | currency: 'EUR': 2}} - {{entry.cc}} - {{entry.pallet}} - {{entry.m3}} - - - - - - - - - - - - - - - {{$ctrl.total('hb')}} - {{$ctrl.total('freightValue') | currency: 'EUR': 2}} - {{$ctrl.total('packageValue') | currency: 'EUR': 2}} - {{$ctrl.total('cc')}} - {{$ctrl.total('pallet')}} - {{$ctrl.total('m3')}} - - - - -
- -

Thermographs

- - - - Code - Temperature - State - Destination - Created - - - - - {{thermograph.thermographFk}} - {{thermograph.temperature}} - {{thermograph.result}} - {{thermograph.warehouse.name}} - {{thermograph.created | date: 'dd/MM/yyyy'}} - - - -
+ + + + + + + + + + + + + +
- - - - \ No newline at end of file diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js index be17feb29b..260715490f 100644 --- a/modules/entry/front/summary/index.js +++ b/modules/entry/front/summary/index.js @@ -5,7 +5,6 @@ import Component from 'core/lib/component'; class Controller extends Component { constructor($element, $, $httpParamSerializer) { super($element, $); - this.entries = []; this.$httpParamSerializer = $httpParamSerializer; } @@ -16,33 +15,15 @@ class Controller extends Component { set entry(value) { this._entry = value; - // if (value && value.id) { - // this.getTravel(); - // this.getEntries(); - // this.getThermographs(); - // } + if (value && value.id) + this.getEntry(); } - // getTravel() { - // return this.$http.get(`/api/Travels/${this.travel.id}/getTravel`).then(response => { - // this.travelData = response.data; - // }); - // } - - // getEntries() { - // return this.$http.get(`/api/Travels/${this.travel.id}/getEntries`).then(response => { - // this.entries = response.data; - // }); - // } - - // total(field) { - // let total = 0; - - // for (let entry of this.entries) - // total += entry[field]; - - // return total; - // } + getEntry() { + return this.$http.get(`/api/Entries/${this.entry.id}/getEntry`).then(response => { + this.entryData = response.data; + }); + } } Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; diff --git a/modules/entry/front/summary/index.spec.js b/modules/entry/front/summary/index.spec.js index 5411d8a0d3..9a8971b52f 100644 --- a/modules/entry/front/summary/index.spec.js +++ b/modules/entry/front/summary/index.spec.js @@ -1,108 +1,48 @@ import './index'; -describe('component vnTravelSummary', () => { +describe('component vnEntrySummary', () => { let controller; let $httpBackend; let $scope; let $element; - let $httpParamSerializer; - beforeEach(angular.mock.module('travel', $translateProvider => { + beforeEach(angular.mock.module('entry', $translateProvider => { $translateProvider.translations('en', {}); })); beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; $scope = $rootScope.$new(); - $element = angular.element(``); - controller = $componentController('vnTravelSummary', {$element, $scope}); + $element = angular.element(``); + controller = $componentController('vnEntrySummary', {$element, $scope}); })); - describe('travel setter/getter', () => { - it('should return the travel', () => { - controller.travel = {id: null}; + describe('entry setter/getter', () => { + it('should return the entry', () => { + controller.entry = {id: 1}; - expect(controller.travel).toEqual(jasmine.any(Object)); + expect(controller.entry).toEqual(jasmine.any(Object)); }); - it('should return the travel and then call both getTravel() and getEntries()', () => { - spyOn(controller, 'getTravel'); - spyOn(controller, 'getEntries'); - spyOn(controller, 'getThermographs'); - controller.travel = {id: 99}; + it('should return the entry and then call getEntry()', () => { + spyOn(controller, 'getEntry'); + controller.entry = {id: 99}; - - expect(controller._travel.id).toEqual(99); - expect(controller.getTravel).toHaveBeenCalledWith(); - expect(controller.getEntries).toHaveBeenCalledWith(); - expect(controller.getThermographs).toHaveBeenCalledWith(); + expect(controller._entry.id).toEqual(99); + expect(controller.getEntry).toHaveBeenCalledWith(); }); }); - describe('getTravel()', () => { + describe('getEntry()', () => { it('should perform a get and then store data on the controller', () => { - controller._travel = {id: 999}; + controller._entry = {id: 999}; - const query = `/api/Travels/${controller._travel.id}/getTravel`; - $httpBackend.expectGET(query).respond('I am the travelData'); - controller.getTravel(); + const query = `/api/Entries/${controller._entry.id}/getEntry`; + $httpBackend.expectGET(query).respond('I am the entryData'); + controller.getEntry(); $httpBackend.flush(); - expect(controller.travelData).toEqual('I am the travelData'); - }); - }); - - describe('getEntries()', () => { - it('should call the getEntries method to get the entries data', () => { - controller._travel = {id: 999}; - - const query = `/api/Travels/${controller._travel.id}/getEntries`; - $httpBackend.expectGET(query).respond('I am the entries'); - controller.getEntries(); - $httpBackend.flush(); - - expect(controller.entries).toEqual('I am the entries'); - }); - }); - - describe('getThermographs()', () => { - it('should call the getThermographs method to get the thermographs', () => { - controller._travel = {id: 2}; - const params = { - filter: { - include: { - relation: 'warehouse', - scope: { - fields: ['id', 'name'] - } - }, - where: { - travelFk: controller._travel.id - } - } - }; - const serializedParams = $httpParamSerializer(params); - const query = `TravelThermographs?${serializedParams}`; - $httpBackend.expectGET(query).respond('I am the thermographs'); - controller.getThermographs(); - $httpBackend.flush(); - - expect(controller.travelThermographs).toEqual('I am the thermographs'); - }); - }); - - describe('total()', () => { - it('should calculate the total amount of a given property for every row', () => { - controller.entries = [ - {id: 1, freightValue: 1, packageValue: 2, cc: 0.01}, - {id: 2, freightValue: 1, packageValue: 2, cc: 0.01}, - {id: 3, freightValue: 1, packageValue: 2, cc: 0.01} - ]; - - expect(controller.total('freightValue')).toEqual(3); - expect(controller.total('packageValue')).toEqual(6); - expect(controller.total('cc')).toEqual(0.03); + expect(controller.entryData).toEqual('I am the entryData'); }); }); }); diff --git a/modules/entry/front/summary/locale/es.yml b/modules/entry/front/summary/locale/es.yml index e69de29bb2..528c388303 100644 --- a/modules/entry/front/summary/locale/es.yml +++ b/modules/entry/front/summary/locale/es.yml @@ -0,0 +1,2 @@ +Inventory: Inventario +Virtual: Redada \ No newline at end of file diff --git a/modules/entry/front/summary/style.scss b/modules/entry/front/summary/style.scss index 922b36ad8f..8887e15b92 100644 --- a/modules/entry/front/summary/style.scss +++ b/modules/entry/front/summary/style.scss @@ -1,7 +1,7 @@ @import "variables"; -vn-travel-summary .summary { +vn-entry-summary .summary { max-width: $width-lg; vn-icon[icon=insert_drive_file]{ From 1908f454c10cb8695a05fdf5739ba676e6226e33 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 21 Feb 2020 14:50:51 +0100 Subject: [PATCH 41/55] worker dms index --- modules/worker/front/dms/index/index.html | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/modules/worker/front/dms/index/index.html b/modules/worker/front/dms/index/index.html index 7859a50a4d..2deffecf69 100644 --- a/modules/worker/front/dms/index/index.html +++ b/modules/worker/front/dms/index/index.html @@ -16,13 +16,10 @@ Id - Type - Order Reference Description Original File - Employee Created @@ -32,17 +29,6 @@ {{::document.dmsFk}} - - - {{::document.dms.dmsType.name}} - - - - - {{::document.dms.hardCopyNumber}} - - {{::document.dms.reference}} @@ -64,12 +50,6 @@ href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}">{{::document.dms.file}}
- - - {{::document.dms.worker.user.nickname | dashIfEmpty}} - - {{::document.dms.created | date:'dd/MM/yyyy HH:mm'}} From 005adc252d31cc2309c1bb6b742054fa0d53e130 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 24 Feb 2020 08:05:26 +0100 Subject: [PATCH 42/55] worker dms index --- modules/worker/front/dms/index/index.html | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/modules/worker/front/dms/index/index.html b/modules/worker/front/dms/index/index.html index 7859a50a4d..2deffecf69 100644 --- a/modules/worker/front/dms/index/index.html +++ b/modules/worker/front/dms/index/index.html @@ -16,13 +16,10 @@ Id - Type - Order Reference Description Original File - Employee Created @@ -32,17 +29,6 @@ {{::document.dmsFk}} - - - {{::document.dms.dmsType.name}} - - - - - {{::document.dms.hardCopyNumber}} - - {{::document.dms.reference}} @@ -64,12 +50,6 @@ href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}">{{::document.dms.file}} - - - {{::document.dms.worker.user.nickname | dashIfEmpty}} - - {{::document.dms.created | date:'dd/MM/yyyy HH:mm'}} From c48da59314f64ed0729745f317d26c46949d8e3d Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 24 Feb 2020 08:44:43 +0100 Subject: [PATCH 43/55] report entry-order --- print/templates/reports/entry-order/entry-order.html | 6 ++++++ print/templates/reports/entry-order/entry-order.js | 7 ++++++- print/templates/reports/entry-order/locale/es.yml | 6 +++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index 170351cec9..cbb0de0d5c 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -48,6 +48,12 @@
{{supplier.street}}
+
+ {{supplier.postCode}}, {{supplier.city}}, ({{supplier.province}}) +
+
+ {{supplier.nif}} +
diff --git a/print/templates/reports/entry-order/entry-order.js b/print/templates/reports/entry-order/entry-order.js index 6317871e4b..55492fbafa 100755 --- a/print/templates/reports/entry-order/entry-order.js +++ b/print/templates/reports/entry-order/entry-order.js @@ -21,9 +21,14 @@ module.exports = { return db.findOne( `SELECT s.name, - s.street + s.street, + s.nif, + s.postCode, + s.city, + p.name province FROM supplier s JOIN entry e ON e.supplierFk = s.id + LEFT JOIN province p ON p.id = s.provinceFk WHERE e.id = ?`, [entryId]); }, fetchEntry(entryId) { diff --git a/print/templates/reports/entry-order/locale/es.yml b/print/templates/reports/entry-order/locale/es.yml index dd4861f9de..3c29d6401c 100644 --- a/print/templates/reports/entry-order/locale/es.yml +++ b/print/templates/reports/entry-order/locale/es.yml @@ -1,11 +1,11 @@ title: Pedido supplierName: Proveedor supplierStreet: Dirección -entryId: Pedido nº +entryId: Referencia interna date: Fecha -ref: Referencia +ref: Nº Factura boxes: Cajas -packing: U/C +packing: U/C quantity: Cantidad price: Precio amount: Importe From 0a4adedcdb123cf84c932acfe6388102093b5f15 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 24 Feb 2020 09:47:26 +0100 Subject: [PATCH 44/55] client descriptor translates --- modules/client/front/descriptor/index.html | 4 ++-- modules/client/front/descriptor/locale/es.yml | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index 30777bcda1..b5673b7832 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -83,7 +83,7 @@ vn-id="from" vn-one ng-model="$ctrl.from" - label="From hour" + label="date" vn-focus>
@@ -93,7 +93,7 @@ vn-id="to" vn-one ng-model="$ctrl.to" - label="To date"> + label="date"> diff --git a/modules/client/front/descriptor/locale/es.yml b/modules/client/front/descriptor/locale/es.yml index 293191ec59..cf8d32b1a4 100644 --- a/modules/client/front/descriptor/locale/es.yml +++ b/modules/client/front/descriptor/locale/es.yml @@ -1,2 +1,5 @@ Simple ticket: Ticket simple -Send consumer report: Enviar informe de consumo \ No newline at end of file +Send consumer report: Enviar informe de consumo +From date: Fecha desde +To date: Fecha hasta +date: fecha \ No newline at end of file From d0c2f88a7755224a2954f4401bd3460cbffbc8dc Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 24 Feb 2020 12:08:53 +0100 Subject: [PATCH 45/55] 2126 - Search by client name --- .../back/methods/ticket-weekly/filter.js | 3 +- .../ticket-weekly/specs/filter.spec.js | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 modules/ticket/back/methods/ticket-weekly/specs/filter.spec.js diff --git a/modules/ticket/back/methods/ticket-weekly/filter.js b/modules/ticket/back/methods/ticket-weekly/filter.js index d249242a9a..925dcdfac6 100644 --- a/modules/ticket/back/methods/ticket-weekly/filter.js +++ b/modules/ticket/back/methods/ticket-weekly/filter.js @@ -38,7 +38,8 @@ module.exports = Self => { case 'search': return {or: [ {'t.id': value}, - {'c.id': value} + {'c.id': value}, + {'c.name': {like: `%${value}%`}} ]}; } }); diff --git a/modules/ticket/back/methods/ticket-weekly/specs/filter.spec.js b/modules/ticket/back/methods/ticket-weekly/specs/filter.spec.js new file mode 100644 index 0000000000..14729b094d --- /dev/null +++ b/modules/ticket/back/methods/ticket-weekly/specs/filter.spec.js @@ -0,0 +1,41 @@ +const app = require('vn-loopback/server/server'); + +describe('ticket-weekly filter()', () => { + const authUserId = 9; + it('should return the tickets matching the filter', async() => { + const ctx = {req: {accessToken: {userId: authUserId}}, args: {}}; + const filter = {order: 'id DESC'}; + const result = await app.models.TicketWeekly.filter(ctx, filter); + const firstRow = result[0]; + + expect(firstRow.ticketFk).toEqual(1); + }); + + it('should return the ticket with id one', async() => { + const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 2}}; + const filter = {}; + const result = await app.models.TicketWeekly.filter(ctx, filter); + const firstRow = result[0]; + + expect(firstRow.ticketFk).toEqual(2); + }); + + it('should return the ticket matching the client name', async() => { + const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'bruce'}}; + const filter = {}; + const result = await app.models.TicketWeekly.filter(ctx, filter); + const firstRow = result[0]; + + expect(firstRow.clientName).toEqual('Bruce Wayne'); + }); + + it('should return the ticket matching the client id', async() => { + const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 101}}; + const filter = {}; + const result = await app.models.TicketWeekly.filter(ctx, filter); + const firstRow = result[0]; + + expect(firstRow.clientFk).toEqual(101); + expect(firstRow.clientName).toEqual('Bruce Wayne'); + }); +}); From 832089de790ff1f753fbc2e905bab456731e12fb Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 24 Feb 2020 12:20:53 +0100 Subject: [PATCH 46/55] entry descriptor, add more options to view entry report --- modules/entry/front/descriptor/index.html | 11 +++++- modules/entry/front/descriptor/index.js | 30 ++++++++++++++--- modules/entry/front/descriptor/index.spec.js | 35 ++++++++++++++++++++ modules/entry/front/descriptor/locale/es.yml | 3 +- 4 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 modules/entry/front/descriptor/index.spec.js diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html index 5cb655dc3f..cd4057c43a 100644 --- a/modules/entry/front/descriptor/index.html +++ b/modules/entry/front/descriptor/index.html @@ -6,7 +6,16 @@ - + +
diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js index e3c00f9ad4..2c8ec9adeb 100644 --- a/modules/entry/front/descriptor/index.js +++ b/modules/entry/front/descriptor/index.js @@ -1,9 +1,20 @@ import ngModule from '../module'; +import Component from 'core/lib/component'; -class Controller { - constructor($scope) { - this.$ = $scope; +class Controller extends Component { + constructor($element, $, $httpParamSerializer, vnConfig) { + super($element, $); + this.vnConfig = vnConfig; + this.$httpParamSerializer = $httpParamSerializer; + this.moreOptions = [ + {name: 'Show entry report', callback: this.showEntryReport} + ]; } + + onMoreChange(callback) { + callback.call(this); + } + get entry() { return this._entry; } @@ -35,7 +46,6 @@ class Controller { tooltip: 'All entries with current supplier' }; - this._quicklinks = links; } @@ -46,9 +56,19 @@ class Controller { set quicklinks(value = {}) { this._quicklinks = Object.assign(value, this._quicklinks); } + + showEntryReport() { + const params = { + clientId: this.vnConfig.storage.currentUserWorkerId, + entryId: this.entry.id + }; + const serializedParams = this.$httpParamSerializer(params); + let url = `api/report/entry-order?${serializedParams}`; + window.open(url); + } } -Controller.$inject = ['$scope']; +Controller.$inject = ['$element', '$scope', '$httpParamSerializer', 'vnConfig']; ngModule.component('vnEntryDescriptor', { template: require('./index.html'), diff --git a/modules/entry/front/descriptor/index.spec.js b/modules/entry/front/descriptor/index.spec.js new file mode 100644 index 0000000000..a63abc0f1b --- /dev/null +++ b/modules/entry/front/descriptor/index.spec.js @@ -0,0 +1,35 @@ +import './index.js'; + +describe('Entry Component vnEntryDescriptor', () => { + let $httpParamSerializer; + let controller; + let $element; + + beforeEach(ngModule('entry')); + + beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope, _$httpParamSerializer_) => { + $httpParamSerializer = _$httpParamSerializer_; + $element = angular.element(``); + controller = $componentController('vnEntryDescriptor', {$element}); + controller._entry = {id: 2}; + controller.vnConfig.storage = {currentUserWorkerId: 9}; + controller.cardReload = ()=> { + return true; + }; + })); + + describe('showEntryReport()', () => { + it('should open a new window showing a delivery note PDF document', () => { + const params = { + clientId: controller.vnConfig.storage.currentUserWorkerId, + entryId: controller.entry.id + }; + const serializedParams = $httpParamSerializer(params); + let expectedPath = `api/report/entry-order?${serializedParams}`; + spyOn(window, 'open'); + controller.showEntryReport(); + + expect(window.open).toHaveBeenCalledWith(expectedPath); + }); + }); +}); diff --git a/modules/entry/front/descriptor/locale/es.yml b/modules/entry/front/descriptor/locale/es.yml index 6789a1281f..5e1eb25c2d 100644 --- a/modules/entry/front/descriptor/locale/es.yml +++ b/modules/entry/front/descriptor/locale/es.yml @@ -1,3 +1,4 @@ Reference: Referencia All travels with current agency: Todos los envios con la agencia actual -All entries with current supplier: Todas las entradas con el proveedor actual \ No newline at end of file +All entries with current supplier: Todas las entradas con el proveedor actual +Show entry report: Ver informe del pedido \ No newline at end of file From 415316d7d05f8b6b3c480a8d52b10c4909651e35 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 24 Feb 2020 13:28:59 +0100 Subject: [PATCH 47/55] 2081 - Fix ticket search by order id --- modules/ticket/back/methods/ticket/filter.js | 34 ++++++++-------- .../back/methods/ticket/specs/filter.spec.js | 40 +++++++++++-------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 5fea43fbd3..fa3067c176 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -96,7 +96,8 @@ module.exports = Self => { }); Self.filter = async(ctx, filter) => { - let conn = Self.dataSource.connector; + const conn = Self.dataSource.connector; + const args = ctx.args; let worker = await Self.app.models.Worker.findOne({ where: {userFk: ctx.req.accessToken.userId}, @@ -107,13 +108,13 @@ module.exports = Self => { let teamIds = []; - if (worker.collegues().length && ctx.args.myTeam) { + if (worker.collegues().length && args.myTeam) { worker.collegues().forEach(collegue => { teamIds.push(collegue.collegueFk); }); } - if (ctx.args.mine || (worker.collegues().length === 0 && ctx.args.myTeam)) { + if (args.mine || (worker.collegues().length === 0 && args.myTeam)) { worker = await Self.app.models.Worker.findOne({ fields: ['id'], where: {userFk: ctx.req.accessToken.userId} @@ -121,23 +122,14 @@ module.exports = Self => { teamIds = [worker && worker.id]; } - if (ctx.args && (ctx.args.mine || ctx.args.myTeam)) - ctx.args.teamIds = teamIds; + if (ctx.args && (args.mine || args.myTeam)) + args.teamIds = teamIds; - if (ctx.args && ctx.args.to) { - const dateTo = ctx.args.to; + if (ctx.args && args.to) { + const dateTo = args.to; dateTo.setHours(23, 59, 0, 0); } - let orderTickets = []; - if (ctx.args && ctx.args.orderFk) { - let ticketsToSearch = await Self.app.models.OrderTicket.find({where: {orderFk: ctx.args.orderFk}}); - ticketsToSearch.forEach(ticket => { - orderTickets.push(ticket.ticketFk); - }); - ctx.args.search = orderTickets; - } - let where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': @@ -215,6 +207,14 @@ module.exports = Self => { LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN account.user u ON u.id = wk.userFk`); + + if (args.orderFk) { + stmt.merge({ + sql: `JOIN orderTicket ot ON ot.ticketFk = t.id AND ot.orderFk = ?`, + params: [args.orderFk] + }); + } + stmt.merge(conn.makeSuffix(filter)); stmts.push(stmt); @@ -249,7 +249,7 @@ module.exports = Self => { let hasProblem; let range; let hasWhere; - switch (ctx.args.problems) { + switch (args.problems) { case true: condition = `or`; hasProblem = true; diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 7e5e1c1263..656f99d65d 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -2,39 +2,45 @@ const app = require('vn-loopback/server/server'); describe('ticket filter()', () => { it('should return the tickets matching the filter', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {}}; - - let filter = {order: 'id DESC'}; - let result = await app.models.Ticket.filter(ctx, filter); - let ticketId = result[0].id; + const ctx = {req: {accessToken: {userId: 9}}, args: {}}; + const filter = {order: 'id DESC'}; + const result = await app.models.Ticket.filter(ctx, filter); + const ticketId = result[0].id; expect(ticketId).toEqual(24); }); it('should return the tickets matching the problems on true', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {problems: true}}; - - let filter = {}; - let result = await app.models.Ticket.filter(ctx, filter); + const ctx = {req: {accessToken: {userId: 9}}, args: {problems: true}}; + const filter = {}; + const result = await app.models.Ticket.filter(ctx, filter); expect(result.length).toEqual(4); }); it('should return the tickets matching the problems on false', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {problems: false}}; - - let filter = {}; - let result = await app.models.Ticket.filter(ctx, filter); + const ctx = {req: {accessToken: {userId: 9}}, args: {problems: false}}; + const filter = {}; + const result = await app.models.Ticket.filter(ctx, filter); expect(result.length).toEqual(20); }); it('should return the tickets matching the problems on null', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {problems: null}}; - - let filter = {}; - let result = await app.models.Ticket.filter(ctx, filter); + const ctx = {req: {accessToken: {userId: 9}}, args: {problems: null}}; + const filter = {}; + const result = await app.models.Ticket.filter(ctx, filter); expect(result.length).toEqual(24); }); + + it('should return the tickets matching the orderId 11', async() => { + const ctx = {req: {accessToken: {userId: 9}}, args: {orderFk: 11}}; + const filter = {}; + const result = await app.models.Ticket.filter(ctx, filter); + const firstRow = result[0]; + + expect(result.length).toEqual(1); + expect(firstRow.ticketFk).toEqual(11); + }); }); From ad1e08ec70402dc2f3238b4aa7cff44d036a5e85 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 24 Feb 2020 14:29:48 +0100 Subject: [PATCH 48/55] 2134 - Irem request load error --- modules/item/front/request/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/front/request/index.html b/modules/item/front/request/index.html index 3216e05e16..20da8946dd 100644 --- a/modules/item/front/request/index.html +++ b/modules/item/front/request/index.html @@ -1,4 +1,4 @@ - Date: Mon, 24 Feb 2020 14:34:36 +0100 Subject: [PATCH 49/55] entry summary e2e --- e2e/helpers/selectors.js | 5 ++++ e2e/paths/12-entry/01_summary.spec.js | 43 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 e2e/paths/12-entry/01_summary.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 873e7c0b5d..0e36fbcb66 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -799,5 +799,10 @@ export default { inflation: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.inflation"]', volumetric: 'vn-zone-basic-data vn-check[ng-model="$ctrl.zone.isVolumetric"]', saveButton: 'vn-zone-basic-data vn-submit > button', + }, + entrySummary: { + header: 'vn-entry-summary > vn-card > h5', + reference: 'vn-entry-summary vn-label-value[label="Reference"]', + confirmed: 'vn-entry-summary vn-check[label="Confirmed"]', } }; diff --git a/e2e/paths/12-entry/01_summary.spec.js b/e2e/paths/12-entry/01_summary.spec.js new file mode 100644 index 0000000000..39b12b8402 --- /dev/null +++ b/e2e/paths/12-entry/01_summary.spec.js @@ -0,0 +1,43 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Entry summary path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('buyer', 'entry'); + await page.waitToClick('vn-entry-index vn-tbody > a:nth-child(2)'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the second entry summary section', async() => { + let url = await page.expectURL('#!/entry/2/summary'); + + expect(url).toBe(true); + }); + + it(`should display details from the entry on the header`, async() => { + await page.waitForTextInElement(selectors.entrySummary.header, 'The king'); + const result = await page.waitToGetProperty(selectors.entrySummary.header, 'innerText'); + + expect(result).toContain('The king'); + }); + + it('should display some entry details like the reference', async() => { + const result = await page.waitToGetProperty(selectors.entrySummary.reference, 'innerText'); + + expect(result).toContain('Movement 2'); + }); + + it('should display other entry details like the confirmed', async() => { + const result = await page.checkboxState(selectors.entrySummary.confirmed, 'innerText'); + + expect(result).toContain('unchecked'); + }); +}); From e7cdc58fad540f107f8cadc7be405dd8cd2a6e12 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 25 Feb 2020 07:51:16 +0100 Subject: [PATCH 50/55] translates --- modules/client/front/descriptor/index.html | 9 +++------ modules/client/front/descriptor/locale/es.yml | 3 +-- modules/entry/front/descriptor/index.js | 3 ++- modules/entry/front/summary/index.html | 2 +- modules/entry/front/summary/locale/es.yml | 3 ++- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index b5673b7832..d8e035942e 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -77,23 +77,20 @@
- From date + Send consumer report
-
- To date -
+ label="To date">
diff --git a/modules/client/front/descriptor/locale/es.yml b/modules/client/front/descriptor/locale/es.yml index cf8d32b1a4..88720ab444 100644 --- a/modules/client/front/descriptor/locale/es.yml +++ b/modules/client/front/descriptor/locale/es.yml @@ -1,5 +1,4 @@ Simple ticket: Ticket simple Send consumer report: Enviar informe de consumo From date: Fecha desde -To date: Fecha hasta -date: fecha \ No newline at end of file +To date: Fecha hasta \ No newline at end of file diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js index 2c8ec9adeb..8f51308f29 100644 --- a/modules/entry/front/descriptor/index.js +++ b/modules/entry/front/descriptor/index.js @@ -73,7 +73,8 @@ Controller.$inject = ['$element', '$scope', '$httpParamSerializer', 'vnConfig']; ngModule.component('vnEntryDescriptor', { template: require('./index.html'), bindings: { - entry: '<' + entry: '<', + quicklinks: '<' }, require: { card: '^?vnEntryCard' diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index 771eaaf7ab..af9eae30cf 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -1,5 +1,5 @@ -
Entrada #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}}
+
Entry #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}}
Date: Tue, 25 Feb 2020 08:08:13 +0100 Subject: [PATCH 51/55] 2138 - Added field m3Max to zoneEvent --- .../10160-postValentineDay/00-zoneEvent.sql | 2 + front/module-import.js | 2 +- front/salix/locale/es.yml | 2 +- jest-front.js | 2 +- modules/agency/front/module.js | 3 -- .../agency/getAgenciesWithWarehouse.js | 0 .../back/methods/agency/getLanded.js | 0 .../back/methods/agency/getShipped.js | 0 .../back/methods/agency/landsThatDay.js | 0 .../specs/getAgenciesWithWarehouse.spec.js | 0 .../methods/agency/specs/getLanded.spec.js | 0 .../methods/agency/specs/getShipped.spec.js | 0 .../methods/agency/specs/landsThatDay.spec.js | 0 .../back/methods/zone/clone.js | 0 .../back/methods/zone/getEvents.js | 0 .../back/methods/zone/getLeaves.js | 0 .../back/methods/zone/specs/clone.spec.js | 0 .../back/methods/zone/toggleIsIncluded.js | 0 .../{agency => zone}/back/model-config.json | 0 .../back/models/agency-mode.json | 0 .../{agency => zone}/back/models/agency.js | 0 .../{agency => zone}/back/models/agency.json | 0 .../back/models/delivery-method.json | 0 .../back/models/zone-closure.js | 0 .../back/models/zone-closure.json | 0 .../back/models/zone-event.js | 0 .../back/models/zone-event.json | 3 ++ .../back/models/zone-exclusion.json | 0 .../back/models/zone-geo.json | 0 .../back/models/zone-included.json | 0 .../back/models/zone-warehouse.json | 0 modules/{agency => zone}/back/models/zone.js | 0 .../{agency => zone}/back/models/zone.json | 0 .../front/basic-data/index.html | 0 .../front/basic-data/index.js | 0 .../front/calendar/index.html | 0 .../{agency => zone}/front/calendar/index.js | 0 .../front/calendar/style.scss | 0 .../{agency => zone}/front/card/index.html | 0 modules/{agency => zone}/front/card/index.js | 0 .../{agency => zone}/front/card/index.spec.js | 2 +- .../{agency => zone}/front/create/index.html | 0 .../{agency => zone}/front/create/index.js | 0 .../front/create/index.spec.js | 2 +- .../front/create/locale/es.yml | 0 .../front/delivery-days/index.html | 0 .../front/delivery-days/index.js | 0 .../front/delivery-days/style.scss | 0 .../front/descriptor/index.html | 0 .../front/descriptor/index.js | 0 .../{agency => zone}/front/events/index.html | 50 ++++++++++++------- .../{agency => zone}/front/events/index.js | 0 .../front/events/locale/es.yml | 0 modules/{agency => zone}/front/index.js | 0 .../{agency => zone}/front/index/index.html | 0 modules/{agency => zone}/front/index/index.js | 0 .../front/index/index.spec.js | 2 +- .../front/index/locale/es.yml | 0 modules/{agency => zone}/front/locale/es.yml | 0 .../front/location/index.html | 0 .../{agency => zone}/front/location/index.js | 0 .../front/location/style.scss | 0 .../{agency => zone}/front/main/index.html | 0 modules/{agency => zone}/front/main/index.js | 0 modules/zone/front/module.js | 3 ++ modules/{agency => zone}/front/routes.json | 8 +-- .../front/search-panel/index.html | 0 .../front/search-panel/index.js | 0 .../{agency => zone}/front/summary/index.html | 0 .../{agency => zone}/front/summary/index.js | 0 .../front/summary/index.spec.js | 2 +- .../front/warehouses/index.html | 0 .../front/warehouses/index.js | 0 73 files changed, 51 insertions(+), 32 deletions(-) create mode 100644 db/changes/10160-postValentineDay/00-zoneEvent.sql delete mode 100644 modules/agency/front/module.js rename modules/{agency => zone}/back/methods/agency/getAgenciesWithWarehouse.js (100%) rename modules/{agency => zone}/back/methods/agency/getLanded.js (100%) rename modules/{agency => zone}/back/methods/agency/getShipped.js (100%) rename modules/{agency => zone}/back/methods/agency/landsThatDay.js (100%) rename modules/{agency => zone}/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js (100%) rename modules/{agency => zone}/back/methods/agency/specs/getLanded.spec.js (100%) rename modules/{agency => zone}/back/methods/agency/specs/getShipped.spec.js (100%) rename modules/{agency => zone}/back/methods/agency/specs/landsThatDay.spec.js (100%) rename modules/{agency => zone}/back/methods/zone/clone.js (100%) rename modules/{agency => zone}/back/methods/zone/getEvents.js (100%) rename modules/{agency => zone}/back/methods/zone/getLeaves.js (100%) rename modules/{agency => zone}/back/methods/zone/specs/clone.spec.js (100%) rename modules/{agency => zone}/back/methods/zone/toggleIsIncluded.js (100%) rename modules/{agency => zone}/back/model-config.json (100%) rename modules/{agency => zone}/back/models/agency-mode.json (100%) rename modules/{agency => zone}/back/models/agency.js (100%) rename modules/{agency => zone}/back/models/agency.json (100%) rename modules/{agency => zone}/back/models/delivery-method.json (100%) rename modules/{agency => zone}/back/models/zone-closure.js (100%) rename modules/{agency => zone}/back/models/zone-closure.json (100%) rename modules/{agency => zone}/back/models/zone-event.js (100%) rename modules/{agency => zone}/back/models/zone-event.json (94%) rename modules/{agency => zone}/back/models/zone-exclusion.json (100%) rename modules/{agency => zone}/back/models/zone-geo.json (100%) rename modules/{agency => zone}/back/models/zone-included.json (100%) rename modules/{agency => zone}/back/models/zone-warehouse.json (100%) rename modules/{agency => zone}/back/models/zone.js (100%) rename modules/{agency => zone}/back/models/zone.json (100%) rename modules/{agency => zone}/front/basic-data/index.html (100%) rename modules/{agency => zone}/front/basic-data/index.js (100%) rename modules/{agency => zone}/front/calendar/index.html (100%) rename modules/{agency => zone}/front/calendar/index.js (100%) rename modules/{agency => zone}/front/calendar/style.scss (100%) rename modules/{agency => zone}/front/card/index.html (100%) rename modules/{agency => zone}/front/card/index.js (100%) rename modules/{agency => zone}/front/card/index.spec.js (95%) rename modules/{agency => zone}/front/create/index.html (100%) rename modules/{agency => zone}/front/create/index.js (100%) rename modules/{agency => zone}/front/create/index.spec.js (96%) rename modules/{agency => zone}/front/create/locale/es.yml (100%) rename modules/{agency => zone}/front/delivery-days/index.html (100%) rename modules/{agency => zone}/front/delivery-days/index.js (100%) rename modules/{agency => zone}/front/delivery-days/style.scss (100%) rename modules/{agency => zone}/front/descriptor/index.html (100%) rename modules/{agency => zone}/front/descriptor/index.js (100%) rename modules/{agency => zone}/front/events/index.html (82%) rename modules/{agency => zone}/front/events/index.js (100%) rename modules/{agency => zone}/front/events/locale/es.yml (100%) rename modules/{agency => zone}/front/index.js (100%) rename modules/{agency => zone}/front/index/index.html (100%) rename modules/{agency => zone}/front/index/index.js (100%) rename modules/{agency => zone}/front/index/index.spec.js (96%) rename modules/{agency => zone}/front/index/locale/es.yml (100%) rename modules/{agency => zone}/front/locale/es.yml (100%) rename modules/{agency => zone}/front/location/index.html (100%) rename modules/{agency => zone}/front/location/index.js (100%) rename modules/{agency => zone}/front/location/style.scss (100%) rename modules/{agency => zone}/front/main/index.html (100%) rename modules/{agency => zone}/front/main/index.js (100%) create mode 100644 modules/zone/front/module.js rename modules/{agency => zone}/front/routes.json (94%) rename modules/{agency => zone}/front/search-panel/index.html (100%) rename modules/{agency => zone}/front/search-panel/index.js (100%) rename modules/{agency => zone}/front/summary/index.html (100%) rename modules/{agency => zone}/front/summary/index.js (100%) rename modules/{agency => zone}/front/summary/index.spec.js (98%) rename modules/{agency => zone}/front/warehouses/index.html (100%) rename modules/{agency => zone}/front/warehouses/index.js (100%) diff --git a/db/changes/10160-postValentineDay/00-zoneEvent.sql b/db/changes/10160-postValentineDay/00-zoneEvent.sql new file mode 100644 index 0000000000..1554afbec1 --- /dev/null +++ b/db/changes/10160-postValentineDay/00-zoneEvent.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn`.`zoneEvent` +ADD COLUMN m3Max DECIMAL(10,2) UNSIGNED NULL DEFAULT NULL AFTER bonus; \ No newline at end of file diff --git a/front/module-import.js b/front/module-import.js index 0bfe7f8cac..dd1692c18e 100755 --- a/front/module-import.js +++ b/front/module-import.js @@ -12,7 +12,7 @@ export default function moduleImport(moduleName) { case 'ticket' : return import('ticket/front'); case 'order' : return import('order/front'); case 'claim' : return import('claim/front'); - case 'agency' : return import('agency/front'); + case 'zone' : return import('zone/front'); case 'travel' : return import('travel/front'); case 'worker' : return import('worker/front'); case 'invoiceOut' : return import('invoiceOut/front'); diff --git a/front/salix/locale/es.yml b/front/salix/locale/es.yml index 34e1a24879..3ce39af8dc 100644 --- a/front/salix/locale/es.yml +++ b/front/salix/locale/es.yml @@ -32,7 +32,7 @@ Remove: Quitar # Modules -Agencies: Agencias +Zones: Zonas Claims: Reclamaciones Clients: Clientes Items: Artículos diff --git a/jest-front.js b/jest-front.js index 40c0e52fcf..5d6c342c0b 100644 --- a/jest-front.js +++ b/jest-front.js @@ -2,7 +2,7 @@ import 'angular'; import 'angular-mocks'; import core from './front/core/module.js'; import './front/salix/components/app/app.js'; -import './modules/agency/front/module.js'; +import './modules/zone/front/module.js'; import './modules/claim/front/module.js'; import './modules/client/front/module.js'; import './modules/invoiceOut/front/module.js'; diff --git a/modules/agency/front/module.js b/modules/agency/front/module.js deleted file mode 100644 index cf38d7fe96..0000000000 --- a/modules/agency/front/module.js +++ /dev/null @@ -1,3 +0,0 @@ -import {ng} from 'core/vendor'; - -export default ng.module('agency', ['vnCore']); diff --git a/modules/agency/back/methods/agency/getAgenciesWithWarehouse.js b/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js similarity index 100% rename from modules/agency/back/methods/agency/getAgenciesWithWarehouse.js rename to modules/zone/back/methods/agency/getAgenciesWithWarehouse.js diff --git a/modules/agency/back/methods/agency/getLanded.js b/modules/zone/back/methods/agency/getLanded.js similarity index 100% rename from modules/agency/back/methods/agency/getLanded.js rename to modules/zone/back/methods/agency/getLanded.js diff --git a/modules/agency/back/methods/agency/getShipped.js b/modules/zone/back/methods/agency/getShipped.js similarity index 100% rename from modules/agency/back/methods/agency/getShipped.js rename to modules/zone/back/methods/agency/getShipped.js diff --git a/modules/agency/back/methods/agency/landsThatDay.js b/modules/zone/back/methods/agency/landsThatDay.js similarity index 100% rename from modules/agency/back/methods/agency/landsThatDay.js rename to modules/zone/back/methods/agency/landsThatDay.js diff --git a/modules/agency/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js b/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js similarity index 100% rename from modules/agency/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js rename to modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js diff --git a/modules/agency/back/methods/agency/specs/getLanded.spec.js b/modules/zone/back/methods/agency/specs/getLanded.spec.js similarity index 100% rename from modules/agency/back/methods/agency/specs/getLanded.spec.js rename to modules/zone/back/methods/agency/specs/getLanded.spec.js diff --git a/modules/agency/back/methods/agency/specs/getShipped.spec.js b/modules/zone/back/methods/agency/specs/getShipped.spec.js similarity index 100% rename from modules/agency/back/methods/agency/specs/getShipped.spec.js rename to modules/zone/back/methods/agency/specs/getShipped.spec.js diff --git a/modules/agency/back/methods/agency/specs/landsThatDay.spec.js b/modules/zone/back/methods/agency/specs/landsThatDay.spec.js similarity index 100% rename from modules/agency/back/methods/agency/specs/landsThatDay.spec.js rename to modules/zone/back/methods/agency/specs/landsThatDay.spec.js diff --git a/modules/agency/back/methods/zone/clone.js b/modules/zone/back/methods/zone/clone.js similarity index 100% rename from modules/agency/back/methods/zone/clone.js rename to modules/zone/back/methods/zone/clone.js diff --git a/modules/agency/back/methods/zone/getEvents.js b/modules/zone/back/methods/zone/getEvents.js similarity index 100% rename from modules/agency/back/methods/zone/getEvents.js rename to modules/zone/back/methods/zone/getEvents.js diff --git a/modules/agency/back/methods/zone/getLeaves.js b/modules/zone/back/methods/zone/getLeaves.js similarity index 100% rename from modules/agency/back/methods/zone/getLeaves.js rename to modules/zone/back/methods/zone/getLeaves.js diff --git a/modules/agency/back/methods/zone/specs/clone.spec.js b/modules/zone/back/methods/zone/specs/clone.spec.js similarity index 100% rename from modules/agency/back/methods/zone/specs/clone.spec.js rename to modules/zone/back/methods/zone/specs/clone.spec.js diff --git a/modules/agency/back/methods/zone/toggleIsIncluded.js b/modules/zone/back/methods/zone/toggleIsIncluded.js similarity index 100% rename from modules/agency/back/methods/zone/toggleIsIncluded.js rename to modules/zone/back/methods/zone/toggleIsIncluded.js diff --git a/modules/agency/back/model-config.json b/modules/zone/back/model-config.json similarity index 100% rename from modules/agency/back/model-config.json rename to modules/zone/back/model-config.json diff --git a/modules/agency/back/models/agency-mode.json b/modules/zone/back/models/agency-mode.json similarity index 100% rename from modules/agency/back/models/agency-mode.json rename to modules/zone/back/models/agency-mode.json diff --git a/modules/agency/back/models/agency.js b/modules/zone/back/models/agency.js similarity index 100% rename from modules/agency/back/models/agency.js rename to modules/zone/back/models/agency.js diff --git a/modules/agency/back/models/agency.json b/modules/zone/back/models/agency.json similarity index 100% rename from modules/agency/back/models/agency.json rename to modules/zone/back/models/agency.json diff --git a/modules/agency/back/models/delivery-method.json b/modules/zone/back/models/delivery-method.json similarity index 100% rename from modules/agency/back/models/delivery-method.json rename to modules/zone/back/models/delivery-method.json diff --git a/modules/agency/back/models/zone-closure.js b/modules/zone/back/models/zone-closure.js similarity index 100% rename from modules/agency/back/models/zone-closure.js rename to modules/zone/back/models/zone-closure.js diff --git a/modules/agency/back/models/zone-closure.json b/modules/zone/back/models/zone-closure.json similarity index 100% rename from modules/agency/back/models/zone-closure.json rename to modules/zone/back/models/zone-closure.json diff --git a/modules/agency/back/models/zone-event.js b/modules/zone/back/models/zone-event.js similarity index 100% rename from modules/agency/back/models/zone-event.js rename to modules/zone/back/models/zone-event.js diff --git a/modules/agency/back/models/zone-event.json b/modules/zone/back/models/zone-event.json similarity index 94% rename from modules/agency/back/models/zone-event.json rename to modules/zone/back/models/zone-event.json index 0d46b1fe26..9ac1007b52 100644 --- a/modules/agency/back/models/zone-event.json +++ b/modules/zone/back/models/zone-event.json @@ -41,6 +41,9 @@ }, "bonus": { "type": "Number" + }, + "m3Max": { + "type": "Number" } }, "relations": { diff --git a/modules/agency/back/models/zone-exclusion.json b/modules/zone/back/models/zone-exclusion.json similarity index 100% rename from modules/agency/back/models/zone-exclusion.json rename to modules/zone/back/models/zone-exclusion.json diff --git a/modules/agency/back/models/zone-geo.json b/modules/zone/back/models/zone-geo.json similarity index 100% rename from modules/agency/back/models/zone-geo.json rename to modules/zone/back/models/zone-geo.json diff --git a/modules/agency/back/models/zone-included.json b/modules/zone/back/models/zone-included.json similarity index 100% rename from modules/agency/back/models/zone-included.json rename to modules/zone/back/models/zone-included.json diff --git a/modules/agency/back/models/zone-warehouse.json b/modules/zone/back/models/zone-warehouse.json similarity index 100% rename from modules/agency/back/models/zone-warehouse.json rename to modules/zone/back/models/zone-warehouse.json diff --git a/modules/agency/back/models/zone.js b/modules/zone/back/models/zone.js similarity index 100% rename from modules/agency/back/models/zone.js rename to modules/zone/back/models/zone.js diff --git a/modules/agency/back/models/zone.json b/modules/zone/back/models/zone.json similarity index 100% rename from modules/agency/back/models/zone.json rename to modules/zone/back/models/zone.json diff --git a/modules/agency/front/basic-data/index.html b/modules/zone/front/basic-data/index.html similarity index 100% rename from modules/agency/front/basic-data/index.html rename to modules/zone/front/basic-data/index.html diff --git a/modules/agency/front/basic-data/index.js b/modules/zone/front/basic-data/index.js similarity index 100% rename from modules/agency/front/basic-data/index.js rename to modules/zone/front/basic-data/index.js diff --git a/modules/agency/front/calendar/index.html b/modules/zone/front/calendar/index.html similarity index 100% rename from modules/agency/front/calendar/index.html rename to modules/zone/front/calendar/index.html diff --git a/modules/agency/front/calendar/index.js b/modules/zone/front/calendar/index.js similarity index 100% rename from modules/agency/front/calendar/index.js rename to modules/zone/front/calendar/index.js diff --git a/modules/agency/front/calendar/style.scss b/modules/zone/front/calendar/style.scss similarity index 100% rename from modules/agency/front/calendar/style.scss rename to modules/zone/front/calendar/style.scss diff --git a/modules/agency/front/card/index.html b/modules/zone/front/card/index.html similarity index 100% rename from modules/agency/front/card/index.html rename to modules/zone/front/card/index.html diff --git a/modules/agency/front/card/index.js b/modules/zone/front/card/index.js similarity index 100% rename from modules/agency/front/card/index.js rename to modules/zone/front/card/index.js diff --git a/modules/agency/front/card/index.spec.js b/modules/zone/front/card/index.spec.js similarity index 95% rename from modules/agency/front/card/index.spec.js rename to modules/zone/front/card/index.spec.js index cc53fe9467..48970ce6ba 100644 --- a/modules/agency/front/card/index.spec.js +++ b/modules/zone/front/card/index.spec.js @@ -5,7 +5,7 @@ describe('Agency Component vnZoneCard', () => { let $httpBackend; let data = {id: 1, name: 'fooName'}; - beforeEach(ngModule('agency')); + beforeEach(ngModule('zone')); beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $stateParams) => { $httpBackend = _$httpBackend_; diff --git a/modules/agency/front/create/index.html b/modules/zone/front/create/index.html similarity index 100% rename from modules/agency/front/create/index.html rename to modules/zone/front/create/index.html diff --git a/modules/agency/front/create/index.js b/modules/zone/front/create/index.js similarity index 100% rename from modules/agency/front/create/index.js rename to modules/zone/front/create/index.js diff --git a/modules/agency/front/create/index.spec.js b/modules/zone/front/create/index.spec.js similarity index 96% rename from modules/agency/front/create/index.spec.js rename to modules/zone/front/create/index.spec.js index 5b2a022f8d..5041e50950 100644 --- a/modules/agency/front/create/index.spec.js +++ b/modules/zone/front/create/index.spec.js @@ -6,7 +6,7 @@ describe('Agency Component vnZoneCreate', () => { let $state; let controller; - beforeEach(ngModule('agency')); + beforeEach(ngModule('zone')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_) => { $scope = $rootScope.$new(); diff --git a/modules/agency/front/create/locale/es.yml b/modules/zone/front/create/locale/es.yml similarity index 100% rename from modules/agency/front/create/locale/es.yml rename to modules/zone/front/create/locale/es.yml diff --git a/modules/agency/front/delivery-days/index.html b/modules/zone/front/delivery-days/index.html similarity index 100% rename from modules/agency/front/delivery-days/index.html rename to modules/zone/front/delivery-days/index.html diff --git a/modules/agency/front/delivery-days/index.js b/modules/zone/front/delivery-days/index.js similarity index 100% rename from modules/agency/front/delivery-days/index.js rename to modules/zone/front/delivery-days/index.js diff --git a/modules/agency/front/delivery-days/style.scss b/modules/zone/front/delivery-days/style.scss similarity index 100% rename from modules/agency/front/delivery-days/style.scss rename to modules/zone/front/delivery-days/style.scss diff --git a/modules/agency/front/descriptor/index.html b/modules/zone/front/descriptor/index.html similarity index 100% rename from modules/agency/front/descriptor/index.html rename to modules/zone/front/descriptor/index.html diff --git a/modules/agency/front/descriptor/index.js b/modules/zone/front/descriptor/index.js similarity index 100% rename from modules/agency/front/descriptor/index.js rename to modules/zone/front/descriptor/index.js diff --git a/modules/agency/front/events/index.html b/modules/zone/front/events/index.html similarity index 82% rename from modules/agency/front/events/index.html rename to modules/zone/front/events/index.html index 693b24a855..0df58287f1 100644 --- a/modules/agency/front/events/index.html +++ b/modules/zone/front/events/index.html @@ -75,6 +75,10 @@ label="Bonus" value="{{::row.bonus | currency:'EUR':2}}"> + + - - + + + + + + + + + + + + - - - - diff --git a/modules/agency/front/events/index.js b/modules/zone/front/events/index.js similarity index 100% rename from modules/agency/front/events/index.js rename to modules/zone/front/events/index.js diff --git a/modules/agency/front/events/locale/es.yml b/modules/zone/front/events/locale/es.yml similarity index 100% rename from modules/agency/front/events/locale/es.yml rename to modules/zone/front/events/locale/es.yml diff --git a/modules/agency/front/index.js b/modules/zone/front/index.js similarity index 100% rename from modules/agency/front/index.js rename to modules/zone/front/index.js diff --git a/modules/agency/front/index/index.html b/modules/zone/front/index/index.html similarity index 100% rename from modules/agency/front/index/index.html rename to modules/zone/front/index/index.html diff --git a/modules/agency/front/index/index.js b/modules/zone/front/index/index.js similarity index 100% rename from modules/agency/front/index/index.js rename to modules/zone/front/index/index.js diff --git a/modules/agency/front/index/index.spec.js b/modules/zone/front/index/index.spec.js similarity index 96% rename from modules/agency/front/index/index.spec.js rename to modules/zone/front/index/index.spec.js index cf2fdfab57..04fc599b7c 100644 --- a/modules/agency/front/index/index.spec.js +++ b/modules/zone/front/index/index.spec.js @@ -4,7 +4,7 @@ describe('Agency Component vnZoneIndex', () => { let $componentController; let controller; - beforeEach(ngModule('agency')); + beforeEach(ngModule('zone')); beforeEach(angular.mock.inject(_$componentController_ => { $componentController = _$componentController_; diff --git a/modules/agency/front/index/locale/es.yml b/modules/zone/front/index/locale/es.yml similarity index 100% rename from modules/agency/front/index/locale/es.yml rename to modules/zone/front/index/locale/es.yml diff --git a/modules/agency/front/locale/es.yml b/modules/zone/front/locale/es.yml similarity index 100% rename from modules/agency/front/locale/es.yml rename to modules/zone/front/locale/es.yml diff --git a/modules/agency/front/location/index.html b/modules/zone/front/location/index.html similarity index 100% rename from modules/agency/front/location/index.html rename to modules/zone/front/location/index.html diff --git a/modules/agency/front/location/index.js b/modules/zone/front/location/index.js similarity index 100% rename from modules/agency/front/location/index.js rename to modules/zone/front/location/index.js diff --git a/modules/agency/front/location/style.scss b/modules/zone/front/location/style.scss similarity index 100% rename from modules/agency/front/location/style.scss rename to modules/zone/front/location/style.scss diff --git a/modules/agency/front/main/index.html b/modules/zone/front/main/index.html similarity index 100% rename from modules/agency/front/main/index.html rename to modules/zone/front/main/index.html diff --git a/modules/agency/front/main/index.js b/modules/zone/front/main/index.js similarity index 100% rename from modules/agency/front/main/index.js rename to modules/zone/front/main/index.js diff --git a/modules/zone/front/module.js b/modules/zone/front/module.js new file mode 100644 index 0000000000..08a427e044 --- /dev/null +++ b/modules/zone/front/module.js @@ -0,0 +1,3 @@ +import {ng} from 'core/vendor'; + +export default ng.module('zone', ['vnCore']); diff --git a/modules/agency/front/routes.json b/modules/zone/front/routes.json similarity index 94% rename from modules/agency/front/routes.json rename to modules/zone/front/routes.json index 7c5b1338d0..857b4b0a4b 100644 --- a/modules/agency/front/routes.json +++ b/modules/zone/front/routes.json @@ -1,12 +1,12 @@ { - "module": "agency", - "name": "Agencies", - "icon" : "icon-delivery", + "module": "zone", + "name": "Zones", + "icon" : "location_on", "validations" : true, "dependencies": ["worker"], "menus": { "main": [ - {"state": "zone.index", "icon": "icon-delivery"}, + {"state": "zone.index", "icon": "location_on"}, {"state": "zone.deliveryDays", "icon": "today"} ], "card": [ diff --git a/modules/agency/front/search-panel/index.html b/modules/zone/front/search-panel/index.html similarity index 100% rename from modules/agency/front/search-panel/index.html rename to modules/zone/front/search-panel/index.html diff --git a/modules/agency/front/search-panel/index.js b/modules/zone/front/search-panel/index.js similarity index 100% rename from modules/agency/front/search-panel/index.js rename to modules/zone/front/search-panel/index.js diff --git a/modules/agency/front/summary/index.html b/modules/zone/front/summary/index.html similarity index 100% rename from modules/agency/front/summary/index.html rename to modules/zone/front/summary/index.html diff --git a/modules/agency/front/summary/index.js b/modules/zone/front/summary/index.js similarity index 100% rename from modules/agency/front/summary/index.js rename to modules/zone/front/summary/index.js diff --git a/modules/agency/front/summary/index.spec.js b/modules/zone/front/summary/index.spec.js similarity index 98% rename from modules/agency/front/summary/index.spec.js rename to modules/zone/front/summary/index.spec.js index d0f99dbb2e..03faf4cfdf 100644 --- a/modules/agency/front/summary/index.spec.js +++ b/modules/zone/front/summary/index.spec.js @@ -7,7 +7,7 @@ describe('component vnZoneSummary', () => { let $httpBackend; let $httpParamSerializer; - beforeEach(ngModule('agency')); + beforeEach(ngModule('zone')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; diff --git a/modules/agency/front/warehouses/index.html b/modules/zone/front/warehouses/index.html similarity index 100% rename from modules/agency/front/warehouses/index.html rename to modules/zone/front/warehouses/index.html diff --git a/modules/agency/front/warehouses/index.js b/modules/zone/front/warehouses/index.js similarity index 100% rename from modules/agency/front/warehouses/index.js rename to modules/zone/front/warehouses/index.js From 04bdd6d20a1a23c528a66f52d98d7558363aa882 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 25 Feb 2020 08:24:54 +0100 Subject: [PATCH 52/55] Updated e2e --- e2e/helpers/selectors.js | 2 +- e2e/paths/11-agency/01_basic-data.spec.js | 103 ---------------------- e2e/paths/11-zone/01_basic-data.spec.js | 103 ++++++++++++++++++++++ 3 files changed, 104 insertions(+), 104 deletions(-) delete mode 100644 e2e/paths/11-agency/01_basic-data.spec.js create mode 100644 e2e/paths/11-zone/01_basic-data.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 873e7c0b5d..1f1ab4b26b 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -788,7 +788,7 @@ export default { createdThermograph: 'vn-travel-thermograph-index vn-tbody > vn-tr', upload: 'vn-travel-thermograph-create button[type=submit]' }, - agencyBasicData: { + zoneBasicData: { name: 'vn-zone-basic-data vn-textfield[ng-model="$ctrl.zone.name"]', agency: 'vn-zone-basic-data vn-autocomplete[ng-model="$ctrl.zone.agencyModeFk"]', maxVolume: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.m3Max"]', diff --git a/e2e/paths/11-agency/01_basic-data.spec.js b/e2e/paths/11-agency/01_basic-data.spec.js deleted file mode 100644 index 43369aeab4..0000000000 --- a/e2e/paths/11-agency/01_basic-data.spec.js +++ /dev/null @@ -1,103 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Agency basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('deliveryBoss', 'zone'); // turns up the agency module name and route aint the same lol - await page.accessToSearchResult('10'); - await page.accessToSection('zone.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the basic data section', async() => { - let url = await page.expectURL('#!/zone/10/basic-data'); - - expect(url).toBe(true); - }); - - it('should edit de form and then save', async() => { - await page.clearInput(selectors.agencyBasicData.name); - await page.write(selectors.agencyBasicData.name, 'Brimstone teleportation'); - await page.autocompleteSearch(selectors.agencyBasicData.agency, 'Quantum break device'); - await page.write(selectors.agencyBasicData.maxVolume, '10'); - await page.clearInput(selectors.agencyBasicData.travelingDays); - await page.write(selectors.agencyBasicData.travelingDays, '1'); - await page.clearInput(selectors.agencyBasicData.closing); - await page.type(selectors.agencyBasicData.closing, '2100'); - await page.clearInput(selectors.agencyBasicData.price); - await page.write(selectors.agencyBasicData.price, '999'); - await page.clearInput(selectors.agencyBasicData.bonus); - await page.write(selectors.agencyBasicData.bonus, '100'); - await page.clearInput(selectors.agencyBasicData.inflation); - await page.write(selectors.agencyBasicData.inflation, '200'); - await page.waitToClick(selectors.agencyBasicData.volumetric); - await page.waitToClick(selectors.agencyBasicData.saveButton); - }); - - it('should reload the section', async() => { - await page.reloadSection('zone.card.basicData'); - let url = await page.expectURL('#!/zone/10/basic-data'); - - expect(url).toBe(true); - }); - - it('should confirm the name was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.name, 'value'); - - expect(result).toEqual('Brimstone teleportation'); - }); - - it('should confirm the agency was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.agency, 'value'); - - expect(result).toEqual('Quantum break device'); - }); - - it('should confirm the max volume was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.maxVolume, 'value'); - - expect(result).toEqual('10'); - }); - - it('should confirm the traveling days were updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.travelingDays, 'value'); - - expect(result).toEqual('1'); - }); - - it('should confirm the closing hour was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.closing, 'value'); - - expect(result).toEqual('21:00'); - }); - - it('should confirm the price was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.price, 'value'); - - expect(result).toEqual('999'); - }); - - it('should confirm the bonus was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.bonus, 'value'); - - expect(result).toEqual('100'); - }); - - it('should confirm the inflation was updated', async() => { - const result = await page.waitToGetProperty(selectors.agencyBasicData.inflation, 'value'); - - expect(result).toEqual('200'); - }); - - it('should confirm the volumetric checkbox was checked', async() => { - await page.waitForClassPresent(selectors.agencyBasicData.volumetric, 'checked'); - }); -}); diff --git a/e2e/paths/11-zone/01_basic-data.spec.js b/e2e/paths/11-zone/01_basic-data.spec.js new file mode 100644 index 0000000000..211c0beb57 --- /dev/null +++ b/e2e/paths/11-zone/01_basic-data.spec.js @@ -0,0 +1,103 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Zone basic data path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('deliveryBoss', 'zone'); // turns up the zone module name and route aint the same lol + await page.accessToSearchResult('10'); + await page.accessToSection('zone.card.basicData'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the basic data section', async() => { + let url = await page.expectURL('#!/zone/10/basic-data'); + + expect(url).toBe(true); + }); + + it('should edit de form and then save', async() => { + await page.clearInput(selectors.zoneBasicData.name); + await page.write(selectors.zoneBasicData.name, 'Brimstone teleportation'); + await page.autocompleteSearch(selectors.zoneBasicData.agency, 'Quantum break device'); + await page.write(selectors.zoneBasicData.maxVolume, '10'); + await page.clearInput(selectors.zoneBasicData.travelingDays); + await page.write(selectors.zoneBasicData.travelingDays, '1'); + await page.clearInput(selectors.zoneBasicData.closing); + await page.type(selectors.zoneBasicData.closing, '2100'); + await page.clearInput(selectors.zoneBasicData.price); + await page.write(selectors.zoneBasicData.price, '999'); + await page.clearInput(selectors.zoneBasicData.bonus); + await page.write(selectors.zoneBasicData.bonus, '100'); + await page.clearInput(selectors.zoneBasicData.inflation); + await page.write(selectors.zoneBasicData.inflation, '200'); + await page.waitToClick(selectors.zoneBasicData.volumetric); + await page.waitToClick(selectors.zoneBasicData.saveButton); + }); + + it('should reload the section', async() => { + await page.reloadSection('zone.card.basicData'); + let url = await page.expectURL('#!/zone/10/basic-data'); + + expect(url).toBe(true); + }); + + it('should confirm the name was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.name, 'value'); + + expect(result).toEqual('Brimstone teleportation'); + }); + + it('should confirm the agency was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.agency, 'value'); + + expect(result).toEqual('Quantum break device'); + }); + + it('should confirm the max volume was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.maxVolume, 'value'); + + expect(result).toEqual('10'); + }); + + it('should confirm the traveling days were updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.travelingDays, 'value'); + + expect(result).toEqual('1'); + }); + + it('should confirm the closing hour was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.closing, 'value'); + + expect(result).toEqual('21:00'); + }); + + it('should confirm the price was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.price, 'value'); + + expect(result).toEqual('999'); + }); + + it('should confirm the bonus was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.bonus, 'value'); + + expect(result).toEqual('100'); + }); + + it('should confirm the inflation was updated', async() => { + const result = await page.waitToGetProperty(selectors.zoneBasicData.inflation, 'value'); + + expect(result).toEqual('200'); + }); + + it('should confirm the volumetric checkbox was checked', async() => { + await page.waitForClassPresent(selectors.zoneBasicData.volumetric, 'checked'); + }); +}); From 70b0143f0a1705dff024aeba58a4ba6ea7365577 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 25 Feb 2020 08:53:09 +0100 Subject: [PATCH 53/55] Renamed sql version --- .../00-zoneEvent.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/{10160-postValentineDay => 10161-postValentineDay}/00-zoneEvent.sql (100%) diff --git a/db/changes/10160-postValentineDay/00-zoneEvent.sql b/db/changes/10161-postValentineDay/00-zoneEvent.sql similarity index 100% rename from db/changes/10160-postValentineDay/00-zoneEvent.sql rename to db/changes/10161-postValentineDay/00-zoneEvent.sql From b37e8da4109ffbd8752d944e90b7f7b72fb8ebdc Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 25 Feb 2020 10:39:21 +0100 Subject: [PATCH 54/55] fix test --- modules/client/front/balance/index/index.spec.js | 6 ------ .../back/methods/entry/specs/getEntry.spec.js | 2 +- modules/entry/front/summary/index.js | 4 ++-- modules/entry/front/summary/index.spec.js | 16 +++++++++------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/modules/client/front/balance/index/index.spec.js b/modules/client/front/balance/index/index.spec.js index e10f903d03..e044b7979e 100644 --- a/modules/client/front/balance/index/index.spec.js +++ b/modules/client/front/balance/index/index.spec.js @@ -44,12 +44,6 @@ describe('Client', () => { }); describe('company setter/getter', () => { - it('should return the company', () => { - controller.companyId = null; - - expect(controller._companyId).toEqual(jasmine.any(Object)); - }); - it('should return the company and then call getData()', () => { spyOn(controller, 'getData'); controller.companyId = 442; diff --git a/modules/entry/back/methods/entry/specs/getEntry.spec.js b/modules/entry/back/methods/entry/specs/getEntry.spec.js index 4baf64543f..3791a3703d 100644 --- a/modules/entry/back/methods/entry/specs/getEntry.spec.js +++ b/modules/entry/back/methods/entry/specs/getEntry.spec.js @@ -5,7 +5,7 @@ describe('travel getEntry()', () => { it('should check the entry contains the id', async() => { const entry = await app.models.Entry.getEntry(entryId); - expect(entry.id).toEqual(1); + expect(entry.id).toEqual(entryId); }); it('should check the entry contains the supplier name', async() => { diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js index 260715490f..3b26907d71 100644 --- a/modules/entry/front/summary/index.js +++ b/modules/entry/front/summary/index.js @@ -16,10 +16,10 @@ class Controller extends Component { this._entry = value; if (value && value.id) - this.getEntry(); + this.getEntryData(); } - getEntry() { + getEntryData() { return this.$http.get(`/api/Entries/${this.entry.id}/getEntry`).then(response => { this.entryData = response.data; }); diff --git a/modules/entry/front/summary/index.spec.js b/modules/entry/front/summary/index.spec.js index 9a8971b52f..ea4a5a7c11 100644 --- a/modules/entry/front/summary/index.spec.js +++ b/modules/entry/front/summary/index.spec.js @@ -18,28 +18,30 @@ describe('component vnEntrySummary', () => { })); describe('entry setter/getter', () => { - it('should return the entry', () => { + it('should check if value.id is defined', () => { + spyOn(controller, 'getEntryData'); + controller.entry = {id: 1}; - expect(controller.entry).toEqual(jasmine.any(Object)); + expect(controller.getEntryData).toHaveBeenCalledWith(); }); - it('should return the entry and then call getEntry()', () => { - spyOn(controller, 'getEntry'); + it('should return the entry and then call getEntryData()', () => { + spyOn(controller, 'getEntryData'); controller.entry = {id: 99}; expect(controller._entry.id).toEqual(99); - expect(controller.getEntry).toHaveBeenCalledWith(); + expect(controller.getEntryData).toHaveBeenCalledWith(); }); }); - describe('getEntry()', () => { + describe('getEntryData()', () => { it('should perform a get and then store data on the controller', () => { controller._entry = {id: 999}; const query = `/api/Entries/${controller._entry.id}/getEntry`; $httpBackend.expectGET(query).respond('I am the entryData'); - controller.getEntry(); + controller.getEntryData(); $httpBackend.flush(); expect(controller.entryData).toEqual('I am the entryData'); From bbba294b7976bb5fe04864925b6e4b0c6f6548bb Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 25 Feb 2020 11:44:46 +0100 Subject: [PATCH 55/55] fix test --- modules/travel/front/summary/index.spec.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/travel/front/summary/index.spec.js b/modules/travel/front/summary/index.spec.js index 5411d8a0d3..593d2cfcc7 100644 --- a/modules/travel/front/summary/index.spec.js +++ b/modules/travel/front/summary/index.spec.js @@ -20,12 +20,6 @@ describe('component vnTravelSummary', () => { })); describe('travel setter/getter', () => { - it('should return the travel', () => { - controller.travel = {id: null}; - - expect(controller.travel).toEqual(jasmine.any(Object)); - }); - it('should return the travel and then call both getTravel() and getEntries()', () => { spyOn(controller, 'getTravel'); spyOn(controller, 'getEntries');