From 256206ace43bfe46805b01e6b0184fd1017e0618 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 20 Oct 2020 09:44:44 +0200 Subject: [PATCH 01/20] supplier summary dscriptor and card --- .../claim/back/methods/claim/getSummary.js | 4 +- modules/client/back/models/pay-method.json | 52 ++++++------- .../back/methods/supplier/getSummary.js | 74 +++++++++++++++++++ modules/supplier/back/model-config.json | 3 + modules/supplier/back/models/pay-dem.json | 19 +++++ modules/supplier/back/models/supplier.js | 1 + modules/supplier/back/models/supplier.json | 31 ++++++++ modules/supplier/front/card/index.html | 5 ++ modules/supplier/front/card/index.js | 42 +++++++++++ modules/supplier/front/descriptor/index.html | 14 ++++ modules/supplier/front/descriptor/index.js | 33 +++++++++ .../supplier/front/descriptor/index.spec.js | 43 +++++++++++ .../supplier/front/descriptor/locale/es.yml | 1 + modules/supplier/front/index.js | 3 + modules/supplier/front/routes.json | 14 ++++ modules/supplier/front/summary/index.html | 74 +++++++++++++++++++ modules/supplier/front/summary/index.js | 44 +++++++++++ modules/supplier/front/summary/index.spec.js | 52 +++++++++++++ modules/supplier/front/summary/locale/es.yml | 0 modules/supplier/front/summary/style.scss | 7 ++ 20 files changed, 488 insertions(+), 28 deletions(-) create mode 100644 modules/supplier/back/methods/supplier/getSummary.js create mode 100644 modules/supplier/back/models/pay-dem.json create mode 100644 modules/supplier/front/card/index.html create mode 100644 modules/supplier/front/card/index.js create mode 100644 modules/supplier/front/descriptor/index.html create mode 100644 modules/supplier/front/descriptor/index.js create mode 100644 modules/supplier/front/descriptor/index.spec.js create mode 100644 modules/supplier/front/descriptor/locale/es.yml create mode 100644 modules/supplier/front/summary/index.html create mode 100644 modules/supplier/front/summary/index.js create mode 100644 modules/supplier/front/summary/index.spec.js create mode 100644 modules/supplier/front/summary/locale/es.yml create mode 100644 modules/supplier/front/summary/style.scss diff --git a/modules/claim/back/methods/claim/getSummary.js b/modules/claim/back/methods/claim/getSummary.js index fce4caecf..9b04d29a9 100644 --- a/modules/claim/back/methods/claim/getSummary.js +++ b/modules/claim/back/methods/claim/getSummary.js @@ -1,12 +1,12 @@ module.exports = Self => { Self.remoteMethod('getSummary', { - description: 'Updates the item taxes', + description: 'Return the claim summary', accessType: 'READ', accepts: [{ arg: 'id', type: 'number', required: true, - description: 'The item id', + description: 'The claim id', http: {source: 'path'} }], returns: { diff --git a/modules/client/back/models/pay-method.json b/modules/client/back/models/pay-method.json index ceb08bfbe..152544c01 100644 --- a/modules/client/back/models/pay-method.json +++ b/modules/client/back/models/pay-method.json @@ -1,29 +1,29 @@ { - "name": "PayMethod", - "base": "VnModel", - "options": { - "mysql": { - "table": "payMethod" + "name": "PayMethod", + "base": "VnModel", + "options": { + "mysql": { + "table": "payMethod" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string", + "required": true + }, + "graceDays": { + "type": "string" + }, + "outstandingDebt": { + "type": "Number" + }, + "ibanRequired": { + "type": "boolean" + } } - }, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" - }, - "name": { - "type": "string", - "required": true - }, - "graceDays": { - "type": "string" - }, - "outstandingDebt": { - "type": "Number" - }, - "ibanRequired": { - "type": "boolean" - } - } } diff --git a/modules/supplier/back/methods/supplier/getSummary.js b/modules/supplier/back/methods/supplier/getSummary.js new file mode 100644 index 000000000..fb1fa9f01 --- /dev/null +++ b/modules/supplier/back/methods/supplier/getSummary.js @@ -0,0 +1,74 @@ +module.exports = Self => { + Self.remoteMethod('getSummary', { + description: 'Returns the supplier summary', + accessType: 'READ', + accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'The supplier id', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: `/:id/getSummary`, + verb: 'GET' + } + }); + Self.getSummary = async id => { + let filter = { + where: {id: id}, + fields: [ + 'id', + 'name', + 'nickname', + 'isOfficial', + 'isActive', + 'note', + 'nif', + 'street', + 'city', + 'postCode', + 'provinceFk', + 'countryFk', + 'payMethodFk', + 'payDemFk', + 'payDay', + 'account', + 'isFarmer', + ], + include: [ + { + relation: 'province', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'country', + scope: { + fields: ['id', 'name', 'code'] + } + }, + { + relation: 'payMethod', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'payDem', + scope: { + fields: ['id', 'payDem'] + } + } + ] + }; + + let supplier = await Self.app.models.Supplier.findOne(filter); + return supplier; + }; +}; diff --git a/modules/supplier/back/model-config.json b/modules/supplier/back/model-config.json index 899e3c38a..9c2f8f391 100644 --- a/modules/supplier/back/model-config.json +++ b/modules/supplier/back/model-config.json @@ -1,5 +1,8 @@ { "Supplier": { "dataSource": "vn" + }, + "PayDem": { + "dataSource": "vn" } } diff --git a/modules/supplier/back/models/pay-dem.json b/modules/supplier/back/models/pay-dem.json new file mode 100644 index 000000000..f214f3e3a --- /dev/null +++ b/modules/supplier/back/models/pay-dem.json @@ -0,0 +1,19 @@ +{ + "name": "PayDem", + "base": "VnModel", + "options": { + "mysql": { + "table": "payDem" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "payDem": { + "type": "Number" + } + } +} diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 953df5106..d3c32b814 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -1,3 +1,4 @@ module.exports = Self => { require('../methods/supplier/filter')(Self); + require('../methods/supplier/getSummary')(Self); }; diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json index 41fc9c45c..3c87e4381 100644 --- a/modules/supplier/back/models/supplier.json +++ b/modules/supplier/back/models/supplier.json @@ -45,6 +45,12 @@ "isActive": { "type": "Boolean" }, + "isOfficial": { + "type": "Boolean" + }, + "note": { + "type": "String" + }, "street": { "type": "String" }, @@ -63,10 +69,35 @@ "payDemFk": { "type": "Number" }, + "payDay": { + "type": "Number" + }, "nickname": { "type": "String" } }, + "relations": { + "payMethod": { + "type": "belongsTo", + "model": "PayMethod", + "foreignKey": "payMethodFk" + }, + "payDem": { + "type": "belongsTo", + "model": "PayDem", + "foreignKey": "payDemFk" + }, + "province": { + "type": "belongsTo", + "model": "Province", + "foreignKey": "provinceFk" + }, + "country": { + "type": "belongsTo", + "model": "Country", + "foreignKey": "countryFk" + } + }, "acls": [ { "accessType": "READ", diff --git a/modules/supplier/front/card/index.html b/modules/supplier/front/card/index.html new file mode 100644 index 000000000..11908bce0 --- /dev/null +++ b/modules/supplier/front/card/index.html @@ -0,0 +1,5 @@ + + + + + diff --git a/modules/supplier/front/card/index.js b/modules/supplier/front/card/index.js new file mode 100644 index 000000000..77fd091a5 --- /dev/null +++ b/modules/supplier/front/card/index.js @@ -0,0 +1,42 @@ +import ngModule from '../module'; +import ModuleCard from 'salix/components/module-card'; + +class Controller extends ModuleCard { + reload() { + let filter = { + include: [ + { + relation: 'province', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'country', + scope: { + fields: ['id', 'name', 'code'] + } + }, + { + relation: 'payMethod', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'payDem', + scope: { + fields: ['id', 'payDem'] + } + } + ] + }; + this.$http.get(`Suppliers/${this.$params.id}`, {filter}) + .then(response => this.supplier = response.data); + } +} + +ngModule.vnComponent('vnSupplierCard', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/supplier/front/descriptor/index.html b/modules/supplier/front/descriptor/index.html new file mode 100644 index 000000000..1ab95b529 --- /dev/null +++ b/modules/supplier/front/descriptor/index.html @@ -0,0 +1,14 @@ + + +
+ + + + +
+
+
diff --git a/modules/supplier/front/descriptor/index.js b/modules/supplier/front/descriptor/index.js new file mode 100644 index 000000000..676a15418 --- /dev/null +++ b/modules/supplier/front/descriptor/index.js @@ -0,0 +1,33 @@ +import ngModule from '../module'; +import Descriptor from 'salix/components/descriptor'; + +class Controller extends Descriptor { + get supplier() { + return this.entity; + } + + set supplier(value) { + this.entity = value; + } + loadData() { + const filter = { + fields: [ + 'id', + 'name', + 'nickname', + 'nif' + ] + }; + + return this.getData(`Suppliers/${this.id}`, {filter}) + .then(res => this.entity = res.data); + } +} + +ngModule.vnComponent('vnSupplierDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + supplier: '<' + } +}); diff --git a/modules/supplier/front/descriptor/index.spec.js b/modules/supplier/front/descriptor/index.spec.js new file mode 100644 index 000000000..84defea3b --- /dev/null +++ b/modules/supplier/front/descriptor/index.spec.js @@ -0,0 +1,43 @@ +import './index.js'; + +describe('Entry Component vnEntryDescriptor', () => { + let $httpBackend; + let controller; + const entry = {id: 2}; + + beforeEach(ngModule('entry')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnEntryDescriptor', {$element: null}, {entry}); + })); + + describe('showEntryReport()', () => { + it('should open a new window showing a delivery note PDF document', () => { + jest.spyOn(controller.vnReport, 'show'); + + window.open = jasmine.createSpy('open'); + const params = { + clientId: controller.vnConfig.storage.currentUserWorkerId, + entryId: entry.id + }; + controller.showEntryReport(); + + expect(controller.vnReport.show).toHaveBeenCalledWith('entry-order', params); + }); + }); + + describe('loadData()', () => { + it('should perform ask for the entry', () => { + let query = `Entries/${entry.id}`; + jest.spyOn(controller, 'getData'); + + $httpBackend.expectGET(query).respond(); + controller.loadData(); + $httpBackend.flush(); + + expect(controller.getData).toHaveBeenCalledTimes(1); + expect(controller.getData).toHaveBeenCalledWith(query, jasmine.any(Object)); + }); + }); +}); diff --git a/modules/supplier/front/descriptor/locale/es.yml b/modules/supplier/front/descriptor/locale/es.yml new file mode 100644 index 000000000..ac3c202a0 --- /dev/null +++ b/modules/supplier/front/descriptor/locale/es.yml @@ -0,0 +1 @@ +Tax number: NIF / CIF \ No newline at end of file diff --git a/modules/supplier/front/index.js b/modules/supplier/front/index.js index cb25b3b8c..daf19e606 100644 --- a/modules/supplier/front/index.js +++ b/modules/supplier/front/index.js @@ -3,3 +3,6 @@ export * from './module'; import './main'; import './index/'; import './search-panel'; +import './summary'; +import './card'; +import './descriptor'; diff --git a/modules/supplier/front/routes.json b/modules/supplier/front/routes.json index 21f1ceb26..78ae46985 100644 --- a/modules/supplier/front/routes.json +++ b/modules/supplier/front/routes.json @@ -2,6 +2,7 @@ "module": "supplier", "name": "Suppliers", "icon" : "icon-supplier", + "dependencies": ["client", "item"], "validations" : true, "menus": { "main": [ @@ -22,6 +23,19 @@ "state": "supplier.index", "component": "vn-supplier-index", "description": "Suppliers" + }, { + "url": "/:id", + "state": "supplier.card", + "abstract": true, + "component": "vn-supplier-card" + }, { + "url": "/summary", + "state": "supplier.card.summary", + "component": "vn-supplier-summary", + "description": "Summary", + "params": { + "supplier": "$ctrl.supplier" + } } ] } \ No newline at end of file diff --git a/modules/supplier/front/summary/index.html b/modules/supplier/front/summary/index.html new file mode 100644 index 000000000..a05470cea --- /dev/null +++ b/modules/supplier/front/summary/index.html @@ -0,0 +1,74 @@ + +
{{$ctrl.summary.name}} - {{$ctrl.summary.id}}
+ + +

Basic data

+ + + + + + + + + + +
+ +

Fiscal address

+ + + + + + + + + + + + + + +
+ +

Billing data

+ + + + + + + + + + +
+
+
+ + \ No newline at end of file diff --git a/modules/supplier/front/summary/index.js b/modules/supplier/front/summary/index.js new file mode 100644 index 000000000..f201127da --- /dev/null +++ b/modules/supplier/front/summary/index.js @@ -0,0 +1,44 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; +import './style.scss'; + +class Controller extends Section { + $onChanges() { + if (!this.supplier) + return; + + this.getSummary(); + } + + getSummary() { + this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => { + this.summary = response.data; + }); + } + + // sumRisk() { + // let total = 0; + // this.summary.clientRisks.forEach(risk => { + // total += risk.amount; + // }); + // return total; + // } + + // claimRate(priceIncreasing) { + // if (priceIncreasing) + // return priceIncreasing * 100; + // } + + // claimingRate(rate) { + // if (rate) + // return rate * 100; + // } +} + +ngModule.vnComponent('vnSupplierSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + supplier: '<' + } +}); diff --git a/modules/supplier/front/summary/index.spec.js b/modules/supplier/front/summary/index.spec.js new file mode 100644 index 000000000..05491267c --- /dev/null +++ b/modules/supplier/front/summary/index.spec.js @@ -0,0 +1,52 @@ +import './index'; + +describe('Client', () => { + describe('Component vnClientSummary', () => { + let controller; + let $httpBackend; + let $scope; + + beforeEach(ngModule('client')); + + beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { + $httpBackend = _$httpBackend_; + $scope = $rootScope.$new(); + const $element = angular.element(''); + controller = $componentController('vnClientSummary', {$element, $scope}); + controller.client = {id: 101}; + })); + + describe('$onChanges()', () => { + it('should perform a GET query and then define the summary property', () => { + let res = {name: 'Superman', classifications: []}; + + jest.spyOn(controller, 'sumRisk').mockReturnThis(); + $httpBackend.expect('GET', `Clients/101/summary`).respond(200, res); + + controller.$onChanges(); + $httpBackend.flush(); + + expect(controller.summary).toBeDefined(); + expect(controller.summary.name).toEqual('Superman'); + }); + }); + + describe('sumRisk()', () => { + it('should sum property amount of an array', () => { + controller.summary = { + clientRisks: [{ + companyFk: 442, + amount: 100 + }, + { + companyFk: 567, + amount: 200 + }]}; + + let result = controller.sumRisk(); + + expect(result).toEqual(300); + }); + }); + }); +}); diff --git a/modules/supplier/front/summary/locale/es.yml b/modules/supplier/front/summary/locale/es.yml new file mode 100644 index 000000000..e69de29bb diff --git a/modules/supplier/front/summary/style.scss b/modules/supplier/front/summary/style.scss new file mode 100644 index 000000000..1520659d2 --- /dev/null +++ b/modules/supplier/front/summary/style.scss @@ -0,0 +1,7 @@ +@import "variables"; + +vn-client-summary { + .alert span { + color: $color-alert !important + } +} \ No newline at end of file From fe2f12cd8f13c61b68cd3eab234f498dcfc4cf6c Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 22 Oct 2020 09:35:11 +0200 Subject: [PATCH 02/20] first test step --- db/changes/10250-octoberFest/00-supplier.sql | 2 + db/dump/fixtures.sql | 8 +-- modules/client/front/fiscal-data/index.js | 2 +- .../supplier/back/methods/supplier/filter.js | 7 ++- .../back/methods/supplier/getSummary.js | 2 +- .../back/methods/supplier/isAClient.js | 26 ++++++++ .../methods/supplier/specs/getSummary.spec.js | 28 +++++++++ modules/supplier/back/models/supplier.js | 1 + modules/supplier/front/descriptor/index.html | 45 +++++++++++++- modules/supplier/front/descriptor/index.js | 59 ++++++++++++++++++- modules/supplier/front/main/index.html | 2 +- .../supplier/front/search-panel/index.html | 2 +- modules/supplier/front/summary/index.html | 2 +- modules/supplier/front/summary/index.js | 18 ------ modules/supplier/front/summary/locale/es.yml | 0 15 files changed, 174 insertions(+), 30 deletions(-) create mode 100644 db/changes/10250-octoberFest/00-supplier.sql create mode 100644 modules/supplier/back/methods/supplier/isAClient.js create mode 100644 modules/supplier/back/methods/supplier/specs/getSummary.spec.js delete mode 100644 modules/supplier/front/summary/locale/es.yml diff --git a/db/changes/10250-octoberFest/00-supplier.sql b/db/changes/10250-octoberFest/00-supplier.sql new file mode 100644 index 000000000..7a5daa92f --- /dev/null +++ b/db/changes/10250-octoberFest/00-supplier.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn`.`supplier` +ADD COLUMN `email` VARCHAR(45) NULL AFTER `isTrucker`; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0bee9cf65..e1881a12f 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1208,11 +1208,11 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`) (104, 500), (105, 5000); -INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `phone`, `payDay`) +INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `phone`, `payDay`, `email`) VALUES - (1, 'Plants SL', 'Plants nick', 4000000001, 1, 'A11111111', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 123456789, 15), - (2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2, 987654321, 10), - (442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 987123654, 15); + (1, 'Plants SL', 'Plants nick', 4000000001, 1, '06089160W', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 123456789, 15, 'supplier_one@gmail.es'), + (2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2, 987654321, 10, 'supplier_two@gmail.es'), + (442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 987123654, 15, 'supplier_three@gmail.es'); INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`) VALUES diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index 58b22537c..6fb88140c 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -35,7 +35,7 @@ export default class Controller extends Section { const $t = this.$translate.instant; const filter = encodeURIComponent(JSON.stringify(filterObj)); - const query = `Clients/findOne?filter=${filter}`; + const query = `Clients/find?filter=${filter}`; this.$http.get(query).then(res => { const params = {clientId: res.data.id}; const question = $t('Found a client with this phone or email', params, null, null, 'sanitizeParameters'); diff --git a/modules/supplier/back/methods/supplier/filter.js b/modules/supplier/back/methods/supplier/filter.js index 3eddda294..b1e7d3884 100644 --- a/modules/supplier/back/methods/supplier/filter.js +++ b/modules/supplier/back/methods/supplier/filter.js @@ -60,7 +60,12 @@ module.exports = Self => { let where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': - return {'s.id': value}; + return {or: [ + {'s.id': value}, + {'s.name': {like: `%${value}%`}}, + {'s.nickname': {like: `%${value}%`}} + ]}; + // return {'s.id': value}; case 'nickname': param = `s.${param}`; return {[param]: {like: `%${value}%`}}; diff --git a/modules/supplier/back/methods/supplier/getSummary.js b/modules/supplier/back/methods/supplier/getSummary.js index fb1fa9f01..24a592acf 100644 --- a/modules/supplier/back/methods/supplier/getSummary.js +++ b/modules/supplier/back/methods/supplier/getSummary.js @@ -50,7 +50,7 @@ module.exports = Self => { { relation: 'country', scope: { - fields: ['id', 'name', 'code'] + fields: ['id', 'country', 'code'] } }, { diff --git a/modules/supplier/back/methods/supplier/isAClient.js b/modules/supplier/back/methods/supplier/isAClient.js new file mode 100644 index 000000000..ec3bfe3dc --- /dev/null +++ b/modules/supplier/back/methods/supplier/isAClient.js @@ -0,0 +1,26 @@ +module.exports = Self => { + Self.remoteMethod('isAClient', { + description: 'Returns the supplier summary', + accessType: 'READ', + accepts: { + arg: 'nif', + type: 'string', + required: true, + description: 'The supplier nif', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: `/:nif/isAClient`, + verb: 'GET' + } + }); + Self.isAClient = async nif => { + const client = await Self.app.models.Client.findOne({where: {fi: nif}}); + console.log('client', client); + return client; + }; +}; diff --git a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js new file mode 100644 index 000000000..58a1e0854 --- /dev/null +++ b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js @@ -0,0 +1,28 @@ +const app = require('vn-loopback/server/server'); + +describe('Supplier getSummary()', () => { + // it('should return the supplier matching "search"', async() => { + // let ctx = { + // args: { + // search: 1 + // } + // }; + + // let result = await app.models.Supplier.filter(ctx); + + // expect(result.length).toEqual(1); + // expect(result[0].id).toEqual(1); + // }); + + // it('should return the supplier matching the province', async() => { + // let ctx = { + // args: { + // provinceFk: 1 + // } + // }; + + // let result = await app.models.Supplier.filter(ctx); + + // expect(result.length).toEqual(2); + // }); +}); diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index d3c32b814..8d77d612b 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -1,4 +1,5 @@ module.exports = Self => { require('../methods/supplier/filter')(Self); require('../methods/supplier/getSummary')(Self); + require('../methods/supplier/isAClient')(Self); }; diff --git a/modules/supplier/front/descriptor/index.html b/modules/supplier/front/descriptor/index.html index 1ab95b529..53d27ed91 100644 --- a/modules/supplier/front/descriptor/index.html +++ b/modules/supplier/front/descriptor/index.html @@ -8,7 +8,50 @@ - + + + + + + + + + + +
+ + + + +
+ diff --git a/modules/supplier/front/descriptor/index.js b/modules/supplier/front/descriptor/index.js index 676a15418..7d4ee750e 100644 --- a/modules/supplier/front/descriptor/index.js +++ b/modules/supplier/front/descriptor/index.js @@ -8,14 +8,71 @@ class Controller extends Descriptor { set supplier(value) { this.entity = value; + this.iSupplierAClient(); } + + get entryFilter() { + if (!this.supplier) return null; + + const date = new Date(); + date.setHours(0, 0, 0, 0); + + const from = new Date(date.getTime()); + from.setDate(from.getDate() - 10); + + const to = new Date(date.getTime()); + to.setDate(to.getDate() + 10); + + return JSON.stringify({ + supplierFk: this.supplier.id, + from, + to + }); + } + iSupplierAClient() { + if (!this.supplier) return; + + const filter = { + where: {fi: this.supplier.nif} + }; + this.$http.get('Clients/findOne', {filter}).then(res => { + if (res.data) + this.isAClient = res.data; + }).catch(error => { + return this.isAClient = false; + }); + // this.$http.get(`Suppliers/${this.supplier.nif}/isAClient`).then(res => { + // this.isAClient = res.data; + // }); + } + loadData() { const filter = { fields: [ 'id', 'name', 'nickname', - 'nif' + 'nif', + 'payMethodFk', + 'payDemFk', + 'payDay', + 'isActive', + 'isOfficial', + 'account' + ], + include: [ + { + relation: 'payMethod', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'payDem', + scope: { + fields: ['id', 'payDem'] + } + } ] }; diff --git a/modules/supplier/front/main/index.html b/modules/supplier/front/main/index.html index 2278087c2..5df346690 100644 --- a/modules/supplier/front/main/index.html +++ b/modules/supplier/front/main/index.html @@ -8,7 +8,7 @@ diff --git a/modules/supplier/front/search-panel/index.html b/modules/supplier/front/search-panel/index.html index 5ad5e6e3a..f5b3962e0 100644 --- a/modules/supplier/front/search-panel/index.html +++ b/modules/supplier/front/search-panel/index.html @@ -5,7 +5,7 @@ vn-one label="General search" ng-model="filter.search" - info="Search suppliers by id" + info="Search suppliers by id name or alias" vn-focus> diff --git a/modules/supplier/front/summary/index.html b/modules/supplier/front/summary/index.html index a05470cea..0df489bfb 100644 --- a/modules/supplier/front/summary/index.html +++ b/modules/supplier/front/summary/index.html @@ -38,7 +38,7 @@ value="{{$ctrl.summary.city}}"> + value="{{$ctrl.summary.postCode}}"> diff --git a/modules/supplier/front/summary/index.js b/modules/supplier/front/summary/index.js index f201127da..0cbe70785 100644 --- a/modules/supplier/front/summary/index.js +++ b/modules/supplier/front/summary/index.js @@ -15,24 +15,6 @@ class Controller extends Section { this.summary = response.data; }); } - - // sumRisk() { - // let total = 0; - // this.summary.clientRisks.forEach(risk => { - // total += risk.amount; - // }); - // return total; - // } - - // claimRate(priceIncreasing) { - // if (priceIncreasing) - // return priceIncreasing * 100; - // } - - // claimingRate(rate) { - // if (rate) - // return rate * 100; - // } } ngModule.vnComponent('vnSupplierSummary', { diff --git a/modules/supplier/front/summary/locale/es.yml b/modules/supplier/front/summary/locale/es.yml deleted file mode 100644 index e69de29bb..000000000 From e3757e9191dcd2fdbd46074bf9af0789bf96f93e Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 22 Oct 2020 13:00:11 +0200 Subject: [PATCH 03/20] changes supplier models --- modules/client/back/models/client.json | 6 +++ .../back/methods/supplier/isAClient.js | 1 - modules/supplier/back/models/supplier.json | 8 +++- modules/supplier/front/card/index.js | 6 +++ modules/supplier/front/descriptor/index.js | 39 +++++++++++-------- 5 files changed, 42 insertions(+), 18 deletions(-) diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index 631fce3aa..d39470359 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -186,6 +186,12 @@ "model": "BankEntity", "foreignKey": "bankEntityFk" }, + "supplier": { + "type": "belongsTo", + "model": "Supplier", + "foreignKey": "fi", + "primaryKey": "nif" + }, "defaulters": { "type": "hasMany", "model": "Defaulter", diff --git a/modules/supplier/back/methods/supplier/isAClient.js b/modules/supplier/back/methods/supplier/isAClient.js index ec3bfe3dc..d200d0c84 100644 --- a/modules/supplier/back/methods/supplier/isAClient.js +++ b/modules/supplier/back/methods/supplier/isAClient.js @@ -20,7 +20,6 @@ module.exports = Self => { }); Self.isAClient = async nif => { const client = await Self.app.models.Client.findOne({where: {fi: nif}}); - console.log('client', client); return client; }; }; diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json index 3c87e4381..8c8952f8f 100644 --- a/modules/supplier/back/models/supplier.json +++ b/modules/supplier/back/models/supplier.json @@ -96,7 +96,13 @@ "type": "belongsTo", "model": "Country", "foreignKey": "countryFk" - } + }, + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "fi", + "primaryKey": "nif" + } }, "acls": [ { diff --git a/modules/supplier/front/card/index.js b/modules/supplier/front/card/index.js index 77fd091a5..613b99cc9 100644 --- a/modules/supplier/front/card/index.js +++ b/modules/supplier/front/card/index.js @@ -28,6 +28,12 @@ class Controller extends ModuleCard { scope: { fields: ['id', 'payDem'] } + }, + { + relation: 'client', + scope: { + fields: ['id', 'fi'] + } } ] }; diff --git a/modules/supplier/front/descriptor/index.js b/modules/supplier/front/descriptor/index.js index 7d4ee750e..90e94b1a3 100644 --- a/modules/supplier/front/descriptor/index.js +++ b/modules/supplier/front/descriptor/index.js @@ -8,7 +8,8 @@ class Controller extends Descriptor { set supplier(value) { this.entity = value; - this.iSupplierAClient(); + console.log('this.entity', this.entity); + // this.iSupplierAClient(); } get entryFilter() { @@ -29,22 +30,22 @@ class Controller extends Descriptor { to }); } - iSupplierAClient() { - if (!this.supplier) return; + // iSupplierAClient() { + // if (!this.supplier) return; - const filter = { - where: {fi: this.supplier.nif} - }; - this.$http.get('Clients/findOne', {filter}).then(res => { - if (res.data) - this.isAClient = res.data; - }).catch(error => { - return this.isAClient = false; - }); - // this.$http.get(`Suppliers/${this.supplier.nif}/isAClient`).then(res => { - // this.isAClient = res.data; - // }); - } + // const filter = { + // where: {fi: this.supplier.nif} + // }; + // this.$http.get('Clients/findOne', {filter}).then(res => { + // if (res.data) + // this.isAClient = res.data; + // }).catch(error => { + // return this.isAClient = false; + // }); + // // this.$http.get(`Suppliers/${this.supplier.nif}/isAClient`).then(res => { + // // this.isAClient = res.data; + // // }); + // } loadData() { const filter = { @@ -72,6 +73,12 @@ class Controller extends Descriptor { scope: { fields: ['id', 'payDem'] } + }, + { + relation: 'client', + scope: { + fields: ['id', 'fi'] + } } ] }; From 5ba439d9bfbda9c95c9d73943dedc48af1da88d2 Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 26 Oct 2020 08:13:13 +0100 Subject: [PATCH 04/20] 2524 - Added search by socialName --- modules/client/front/main/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/front/main/index.js b/modules/client/front/main/index.js index cae95c1dd..61cde8b22 100644 --- a/modules/client/front/main/index.js +++ b/modules/client/front/main/index.js @@ -7,7 +7,7 @@ export default class Client extends ModuleMain { case 'search': return /^\d+$/.test(value) ? {id: value} - : {name: {like: `%${value}%`}}; + : {or: [{name: {like: `%${value}%`}}, {socialName: {like: `%${value}%`}}]}; case 'phone': return { or: [ From 58168e78ab343c39e14cbf2ea6f34fe95a7c94f7 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 26 Oct 2020 08:38:43 +0100 Subject: [PATCH 05/20] test, translate and supplier searpanel, summary --- db/changes/10250-octoberFest/00-supplier.sql | 2 - db/dump/fixtures.sql | 8 +-- .../methods/claim/specs/updateClaim.spec.js | 2 +- modules/client/back/models/client.json | 6 -- .../client/front/balance/create/index.spec.js | 4 +- modules/order/front/index/index.spec.js | 2 +- .../back/methods/supplier/isAClient.js | 25 ------- .../methods/supplier/specs/getSummary.spec.js | 38 +++++----- modules/supplier/back/models/supplier.js | 1 - modules/supplier/back/models/supplier.json | 4 +- modules/supplier/front/descriptor/index.html | 4 +- modules/supplier/front/descriptor/index.js | 22 +----- .../supplier/front/descriptor/index.spec.js | 69 ++++++++++++------- .../supplier/front/descriptor/locale/es.yml | 4 +- modules/supplier/front/main/index.html | 2 +- .../supplier/front/search-panel/index.html | 2 +- .../supplier/front/search-panel/locale/es.yml | 3 +- modules/supplier/front/summary/index.html | 4 +- modules/supplier/front/summary/index.js | 2 +- modules/supplier/front/summary/index.spec.js | 44 ++++-------- modules/supplier/front/summary/locale/es.yml | 5 ++ 21 files changed, 105 insertions(+), 148 deletions(-) delete mode 100644 db/changes/10250-octoberFest/00-supplier.sql delete mode 100644 modules/supplier/back/methods/supplier/isAClient.js create mode 100644 modules/supplier/front/summary/locale/es.yml diff --git a/db/changes/10250-octoberFest/00-supplier.sql b/db/changes/10250-octoberFest/00-supplier.sql deleted file mode 100644 index 7a5daa92f..000000000 --- a/db/changes/10250-octoberFest/00-supplier.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `vn`.`supplier` -ADD COLUMN `email` VARCHAR(45) NULL AFTER `isTrucker`; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index e1881a12f..c36e8d8cf 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1208,11 +1208,11 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`) (104, 500), (105, 5000); -INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `phone`, `payDay`, `email`) +INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`) VALUES - (1, 'Plants SL', 'Plants nick', 4000000001, 1, '06089160W', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 123456789, 15, 'supplier_one@gmail.es'), - (2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2, 987654321, 10, 'supplier_two@gmail.es'), - (442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 987123654, 15, 'supplier_three@gmail.es'); + (1, 'Plants SL', 'Plants nick', 4000000001, 1, '06089160W', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15), + (2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2, 10), + (442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15); INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`) VALUES diff --git a/modules/claim/back/methods/claim/specs/updateClaim.spec.js b/modules/claim/back/methods/claim/specs/updateClaim.spec.js index f1ee99eac..2a36bab9b 100644 --- a/modules/claim/back/methods/claim/specs/updateClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/updateClaim.spec.js @@ -56,7 +56,7 @@ describe('Update Claim', () => { hasToPickUp: false } }; - await app.models.Claim.updateClaim(ctx, newClaim.id,); + await app.models.Claim.updateClaim(ctx, newClaim.id); let updatedClaim = await app.models.Claim.findById(newClaim.id); diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index d39470359..631fce3aa 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -186,12 +186,6 @@ "model": "BankEntity", "foreignKey": "bankEntityFk" }, - "supplier": { - "type": "belongsTo", - "model": "Supplier", - "foreignKey": "fi", - "primaryKey": "nif" - }, "defaulters": { "type": "hasMany", "model": "Defaulter", diff --git a/modules/client/front/balance/create/index.spec.js b/modules/client/front/balance/create/index.spec.js index 11fdb1040..9f85387c8 100644 --- a/modules/client/front/balance/create/index.spec.js +++ b/modules/client/front/balance/create/index.spec.js @@ -51,7 +51,7 @@ describe('Client', () => { } }; const serializedParams = $httpParamSerializer({filter}); - $httpBackend.expect('GET', `ClientRisks?${serializedParams}`,).respond([{amount: 20}]); + $httpBackend.expect('GET', `ClientRisks?${serializedParams}`).respond([{amount: 20}]); controller.getAmountPaid(); $httpBackend.flush(); @@ -65,7 +65,7 @@ describe('Client', () => { controller.$params = {id: 101}; - $httpBackend.expect('POST', `Receipts`,).respond({id: 1}); + $httpBackend.expect('POST', `Receipts`).respond({id: 1}); controller.responseHandler('accept'); $httpBackend.flush(); diff --git a/modules/order/front/index/index.spec.js b/modules/order/front/index/index.spec.js index 2e538f3c7..5b85b3333 100644 --- a/modules/order/front/index/index.spec.js +++ b/modules/order/front/index/index.spec.js @@ -18,7 +18,7 @@ describe('Component vnOrderIndex', () => { beforeEach(ngModule('order')); - beforeEach(inject(($componentController, _$window_,) => { + beforeEach(inject(($componentController, _$window_) => { $window = _$window_; const $element = angular.element(''); controller = $componentController('vnOrderIndex', {$element}); diff --git a/modules/supplier/back/methods/supplier/isAClient.js b/modules/supplier/back/methods/supplier/isAClient.js deleted file mode 100644 index d200d0c84..000000000 --- a/modules/supplier/back/methods/supplier/isAClient.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('isAClient', { - description: 'Returns the supplier summary', - accessType: 'READ', - accepts: { - arg: 'nif', - type: 'string', - required: true, - description: 'The supplier nif', - http: {source: 'path'} - }, - returns: { - type: 'object', - root: true - }, - http: { - path: `/:nif/isAClient`, - verb: 'GET' - } - }); - Self.isAClient = async nif => { - const client = await Self.app.models.Client.findOne({where: {fi: nif}}); - return client; - }; -}; diff --git a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js index 58a1e0854..73feba9ad 100644 --- a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js +++ b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js @@ -1,28 +1,28 @@ const app = require('vn-loopback/server/server'); describe('Supplier getSummary()', () => { - // it('should return the supplier matching "search"', async() => { - // let ctx = { - // args: { - // search: 1 - // } - // }; + it('should return a summary object containing data from one supplier', async() => { + const supplier = await app.models.Supplier.getSummary(1); - // let result = await app.models.Supplier.filter(ctx); + expect(supplier.id).toEqual(1); + expect(supplier.name).toEqual('Plants SL'); + expect(supplier.nif).toEqual('06089160W'); + }); - // expect(result.length).toEqual(1); - // expect(result[0].id).toEqual(1); - // }); + it(`should return a summary object containing it's supplier country`, async() => { + const supplier = await app.models.Supplier.getSummary(1); + const country = supplier.country(); - // it('should return the supplier matching the province', async() => { - // let ctx = { - // args: { - // provinceFk: 1 - // } - // }; + expect(country.id).toEqual(1); + expect(country.code).toEqual('ES'); + }); - // let result = await app.models.Supplier.filter(ctx); + it(`should return a summary object containing it's billing data`, async() => { + const supplier = await app.models.Supplier.getSummary(1); + const payMethod = supplier.payMethod(); - // expect(result.length).toEqual(2); - // }); + expect(supplier.account).toEqual(4000000001); + expect(supplier.payDay).toEqual(15); + expect(payMethod.name).toEqual('PayMethod one'); + }); }); diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 8d77d612b..d3c32b814 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -1,5 +1,4 @@ module.exports = Self => { require('../methods/supplier/filter')(Self); require('../methods/supplier/getSummary')(Self); - require('../methods/supplier/isAClient')(Self); }; diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json index 8c8952f8f..b4f5b5318 100644 --- a/modules/supplier/back/models/supplier.json +++ b/modules/supplier/back/models/supplier.json @@ -100,8 +100,8 @@ "client": { "type": "belongsTo", "model": "Client", - "foreignKey": "fi", - "primaryKey": "nif" + "foreignKey": "nif", + "primaryKey": "fi" } }, "acls": [ diff --git a/modules/supplier/front/descriptor/index.html b/modules/supplier/front/descriptor/index.html index 53d27ed91..470d984f2 100644 --- a/modules/supplier/front/descriptor/index.html +++ b/modules/supplier/front/descriptor/index.html @@ -44,9 +44,9 @@
diff --git a/modules/supplier/front/descriptor/index.js b/modules/supplier/front/descriptor/index.js index 90e94b1a3..42513a56a 100644 --- a/modules/supplier/front/descriptor/index.js +++ b/modules/supplier/front/descriptor/index.js @@ -8,8 +8,6 @@ class Controller extends Descriptor { set supplier(value) { this.entity = value; - console.log('this.entity', this.entity); - // this.iSupplierAClient(); } get entryFilter() { @@ -30,22 +28,6 @@ class Controller extends Descriptor { to }); } - // iSupplierAClient() { - // if (!this.supplier) return; - - // const filter = { - // where: {fi: this.supplier.nif} - // }; - // this.$http.get('Clients/findOne', {filter}).then(res => { - // if (res.data) - // this.isAClient = res.data; - // }).catch(error => { - // return this.isAClient = false; - // }); - // // this.$http.get(`Suppliers/${this.supplier.nif}/isAClient`).then(res => { - // // this.isAClient = res.data; - // // }); - // } loadData() { const filter = { @@ -83,8 +65,8 @@ class Controller extends Descriptor { ] }; - return this.getData(`Suppliers/${this.id}`, {filter}) - .then(res => this.entity = res.data); + return this.getData(`Suppliers/${this.supplier.id}`, {filter}) + .then(res => this.supplier = res.data); } } diff --git a/modules/supplier/front/descriptor/index.spec.js b/modules/supplier/front/descriptor/index.spec.js index 84defea3b..58f0fac86 100644 --- a/modules/supplier/front/descriptor/index.spec.js +++ b/modules/supplier/front/descriptor/index.spec.js @@ -1,43 +1,64 @@ import './index.js'; -describe('Entry Component vnEntryDescriptor', () => { +describe('Supplier Component vnSupplierDescriptor', () => { let $httpBackend; let controller; - const entry = {id: 2}; + let $httpParamSerializer; + const supplier = {id: 1}; - beforeEach(ngModule('entry')); + beforeEach(ngModule('supplier')); - beforeEach(inject(($componentController, _$httpBackend_) => { + beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; - controller = $componentController('vnEntryDescriptor', {$element: null}, {entry}); + $httpParamSerializer = _$httpParamSerializer_; + controller = $componentController('vnSupplierDescriptor', {$element: null}, {supplier}); })); - describe('showEntryReport()', () => { - it('should open a new window showing a delivery note PDF document', () => { - jest.spyOn(controller.vnReport, 'show'); - - window.open = jasmine.createSpy('open'); - const params = { - clientId: controller.vnConfig.storage.currentUserWorkerId, - entryId: entry.id - }; - controller.showEntryReport(); - - expect(controller.vnReport.show).toHaveBeenCalledWith('entry-order', params); - }); - }); - describe('loadData()', () => { - it('should perform ask for the entry', () => { - let query = `Entries/${entry.id}`; + it('should perform ask for the supplier', () => { + const filter = { + fields: [ + 'id', + 'name', + 'nickname', + 'nif', + 'payMethodFk', + 'payDemFk', + 'payDay', + 'isActive', + 'isOfficial', + 'account' + ], + include: [ + { + relation: 'payMethod', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'payDem', + scope: { + fields: ['id', 'payDem'] + } + }, + { + relation: 'client', + scope: { + fields: ['id', 'fi'] + } + } + ] + }; + const serializedParams = $httpParamSerializer({filter}); + let query = `Suppliers/${controller.supplier.id}?${serializedParams}`; jest.spyOn(controller, 'getData'); - $httpBackend.expectGET(query).respond(); + $httpBackend.expect('GET', query).respond({id: 1}); controller.loadData(); $httpBackend.flush(); expect(controller.getData).toHaveBeenCalledTimes(1); - expect(controller.getData).toHaveBeenCalledWith(query, jasmine.any(Object)); }); }); }); diff --git a/modules/supplier/front/descriptor/locale/es.yml b/modules/supplier/front/descriptor/locale/es.yml index ac3c202a0..f803a21e1 100644 --- a/modules/supplier/front/descriptor/locale/es.yml +++ b/modules/supplier/front/descriptor/locale/es.yml @@ -1 +1,3 @@ -Tax number: NIF / CIF \ No newline at end of file +Tax number: NIF / CIF +All entries with current supplier: Todas las entradas con el proveedor actual +Go to client: Ir al cliente \ No newline at end of file diff --git a/modules/supplier/front/main/index.html b/modules/supplier/front/main/index.html index 5df346690..7d7f92cf0 100644 --- a/modules/supplier/front/main/index.html +++ b/modules/supplier/front/main/index.html @@ -8,7 +8,7 @@ diff --git a/modules/supplier/front/search-panel/index.html b/modules/supplier/front/search-panel/index.html index f5b3962e0..161c8a98c 100644 --- a/modules/supplier/front/search-panel/index.html +++ b/modules/supplier/front/search-panel/index.html @@ -5,7 +5,7 @@ vn-one label="General search" ng-model="filter.search" - info="Search suppliers by id name or alias" + info="Search suppliers by id, name or alias" vn-focus> diff --git a/modules/supplier/front/search-panel/locale/es.yml b/modules/supplier/front/search-panel/locale/es.yml index 4d2cb82f3..964e7a8d9 100644 --- a/modules/supplier/front/search-panel/locale/es.yml +++ b/modules/supplier/front/search-panel/locale/es.yml @@ -1,3 +1,4 @@ Province: Provincia Country: País -Tax number: Nif \ No newline at end of file +Tax number: Nif +Search suppliers by id, name or alias: Busca proveedores por el id, el nombre o el alias \ No newline at end of file diff --git a/modules/supplier/front/summary/index.html b/modules/supplier/front/summary/index.html index 0df489bfb..c22a32f91 100644 --- a/modules/supplier/front/summary/index.html +++ b/modules/supplier/front/summary/index.html @@ -6,7 +6,7 @@ -
- { + return this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => { this.summary = response.data; }); } diff --git a/modules/supplier/front/summary/index.spec.js b/modules/supplier/front/summary/index.spec.js index 05491267c..aa44cd14f 100644 --- a/modules/supplier/front/summary/index.spec.js +++ b/modules/supplier/front/summary/index.spec.js @@ -1,51 +1,31 @@ import './index'; -describe('Client', () => { - describe('Component vnClientSummary', () => { +describe('Supplier', () => { + describe('Component vnSupplierSummary', () => { let controller; let $httpBackend; let $scope; - beforeEach(ngModule('client')); + beforeEach(ngModule('supplier')); beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnClientSummary', {$element, $scope}); - controller.client = {id: 101}; + const $element = angular.element(''); + controller = $componentController('vnSupplierSummary', {$element, $scope}); })); - describe('$onChanges()', () => { - it('should perform a GET query and then define the summary property', () => { - let res = {name: 'Superman', classifications: []}; + describe('getSummary()', () => { + it('should perform a get asking for the supplier data', () => { + controller.supplier = {id: 1}; - jest.spyOn(controller, 'sumRisk').mockReturnThis(); - $httpBackend.expect('GET', `Clients/101/summary`).respond(200, res); + const query = `Suppliers/${controller.supplier.id}/getSummary`; - controller.$onChanges(); + $httpBackend.expectGET(query).respond({id: 1}); + controller.getSummary(); $httpBackend.flush(); - expect(controller.summary).toBeDefined(); - expect(controller.summary.name).toEqual('Superman'); - }); - }); - - describe('sumRisk()', () => { - it('should sum property amount of an array', () => { - controller.summary = { - clientRisks: [{ - companyFk: 442, - amount: 100 - }, - { - companyFk: 567, - amount: 200 - }]}; - - let result = controller.sumRisk(); - - expect(result).toEqual(300); + expect(controller.summary).toEqual({id: 1}); }); }); }); diff --git a/modules/supplier/front/summary/locale/es.yml b/modules/supplier/front/summary/locale/es.yml new file mode 100644 index 000000000..b367ebb35 --- /dev/null +++ b/modules/supplier/front/summary/locale/es.yml @@ -0,0 +1,5 @@ +Is official: Es oficial +Country: País +Tax number: Nif +Search suppliers by id, name or alias: Busca proveedores por el id, el nombre o el alias +Is Farmer: Es agrícola \ No newline at end of file From d06d935c70239d6ef40d1be270f2d6b5a2f650d0 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 26 Oct 2020 08:43:08 +0100 Subject: [PATCH 06/20] fix client fiscal data --- modules/client/front/fiscal-data/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index 6fb88140c..58b22537c 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -35,7 +35,7 @@ export default class Controller extends Section { const $t = this.$translate.instant; const filter = encodeURIComponent(JSON.stringify(filterObj)); - const query = `Clients/find?filter=${filter}`; + const query = `Clients/findOne?filter=${filter}`; this.$http.get(query).then(res => { const params = {clientId: res.data.id}; const question = $t('Found a client with this phone or email', params, null, null, 'sanitizeParameters'); From 3675f7ed348390a0e231899febc96b820c660a2f Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 26 Oct 2020 12:16:57 +0100 Subject: [PATCH 07/20] 2511 - Changed salesAssitant role to claimManager --- db/changes/10240-allSaints/00-ACL.sql | 5 +++++ db/changes/10240-allSaints/00-claimState.sql | 3 +++ db/dump/dumpedFixtures.sql | 2 +- db/dump/fixtures.sql | 6 +++--- e2e/paths/06-claim/01_basic_data.spec.js | 6 +++--- e2e/paths/06-claim/02_development.spec.js | 4 ++-- e2e/paths/06-claim/04_claim_action.spec.js | 2 +- e2e/paths/06-claim/06_descriptor.spec.js | 4 ++-- loopback/locale/en.json | 3 ++- .../importToNewRefundTicket.spec.js | 4 ++-- modules/claim/back/methods/claim/isEditable.js | 8 +++----- .../back/methods/claim/specs/isEditable.spec.js | 10 +++++----- .../back/methods/claim/specs/updateClaim.spec.js | 14 +++++++------- modules/claim/back/methods/claim/updateClaim.js | 4 ++-- modules/claim/front/basic-data/index.html | 3 ++- modules/claim/front/basic-data/index.js | 2 +- modules/claim/front/descriptor/index.html | 2 +- modules/claim/front/detail/index.js | 4 ++-- modules/claim/front/development/index.js | 2 +- modules/claim/front/routes.json | 4 ++-- modules/claim/front/summary/index.html | 2 +- 21 files changed, 51 insertions(+), 43 deletions(-) create mode 100644 db/changes/10240-allSaints/00-claimState.sql diff --git a/db/changes/10240-allSaints/00-ACL.sql b/db/changes/10240-allSaints/00-ACL.sql index 60882e308..332c7677e 100644 --- a/db/changes/10240-allSaints/00-ACL.sql +++ b/db/changes/10240-allSaints/00-ACL.sql @@ -1,3 +1,8 @@ UPDATE `salix`.`ACL` SET `principalId` = 'deliveryBoss' WHERE (`id` = '194'); +UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '97'); +UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '100'); +UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '103'); +UPDATE `salix`.`ACL` SET `principalId` = 'claimManager' WHERE (`id` = '202'); + INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Town', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Province', '*', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'); diff --git a/db/changes/10240-allSaints/00-claimState.sql b/db/changes/10240-allSaints/00-claimState.sql new file mode 100644 index 000000000..64ec0f30d --- /dev/null +++ b/db/changes/10240-allSaints/00-claimState.sql @@ -0,0 +1,3 @@ +UPDATE `vn`.`claimState` SET `roleFk` = '72' WHERE (`id` = '3'); +UPDATE `vn`.`claimState` SET `roleFk` = '72' WHERE (`id` = '4'); +UPDATE `vn`.`claimState` SET `roleFk` = '72' WHERE (`id` = '5'); \ No newline at end of file diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index ffbece93b..70e5d9b83 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -61,7 +61,7 @@ USE `account`; LOCK TABLES `role` WRITE; /*!40000 ALTER TABLE `role` DISABLE KEYS */; -INSERT INTO `role` VALUES (0,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2018-04-23 14:33:59'),(1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',0,'2018-02-26 15:28:23','2019-01-21 12:57:21'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'),(70,'trainee','Alumno de prácticas',1,'2020-03-04 11:00:25','2020-03-04 11:00:25'),(71,'checker','Rol de revisor con privilegios de itemPicker',1,'2020-10-02 10:50:07','2020-10-02 10:50:07'),(72,'claim','Personal de reclamaciones',1,'2020-10-13 10:01:32','2020-10-13 10:01:32'); +INSERT INTO `role` VALUES (0,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2018-04-23 14:33:59'),(1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',0,'2018-02-26 15:28:23','2019-01-21 12:57:21'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'),(70,'trainee','Alumno de prácticas',1,'2020-03-04 11:00:25','2020-03-04 11:00:25'),(71,'checker','Rol de revisor con privilegios de itemPicker',1,'2020-10-02 10:50:07','2020-10-02 10:50:07'),(72,'claimManager','Personal de reclamaciones',1,'2020-10-13 10:01:32','2020-10-13 10:01:32'); /*!40000 ALTER TABLE `role` ENABLE KEYS */; UNLOCK TABLES; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0bee9cf65..b995863ba 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1534,9 +1534,9 @@ INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`) VALUES ( 1, 'pending', 'Pendiente', 1, 1), ( 2, 'managed', 'Gestionado', 1, 5), - ( 3, 'resolved', 'Resuelto', 21, 7), - ( 4, 'canceled', 'Anulado', 1, 6), - ( 5, 'disputed', 'Cuestionado', 21, 3), + ( 3, 'resolved', 'Resuelto', 72, 7), + ( 4, 'canceled', 'Anulado', 72, 6), + ( 5, 'disputed', 'Cuestionado', 72, 3), ( 6, 'mana', 'Mana', 1, 4), ( 7, 'inProgress', 'En Curso', 1, 2); diff --git a/e2e/paths/06-claim/01_basic_data.spec.js b/e2e/paths/06-claim/01_basic_data.spec.js index dd55d0053..4b60b2689 100644 --- a/e2e/paths/06-claim/01_basic_data.spec.js +++ b/e2e/paths/06-claim/01_basic_data.spec.js @@ -14,8 +14,8 @@ describe('Claim edit basic data path', () => { await browser.close(); }); - it(`should log in as salesAssistant then reach basic data of the target claim`, async() => { - await page.loginAndModule('salesAssistant', 'claim'); + it(`should log in as claimManager then reach basic data of the target claim`, async() => { + await page.loginAndModule('claimManager', 'claim'); await page.accessToSearchResult('1'); await page.accessToSection('claim.card.basicData'); }); @@ -30,7 +30,7 @@ describe('Claim edit basic data path', () => { expect(message.type).toBe('success'); }); - it(`should have been redirected to the next section of claims as the role is salesAssistant`, async() => { + it(`should have been redirected to the next section of claims as the role is claimManager`, async() => { await page.waitForState('claim.card.detail'); }); diff --git a/e2e/paths/06-claim/02_development.spec.js b/e2e/paths/06-claim/02_development.spec.js index 8efae48d4..545ec340b 100644 --- a/e2e/paths/06-claim/02_development.spec.js +++ b/e2e/paths/06-claim/02_development.spec.js @@ -8,7 +8,7 @@ describe('Claim development', () => { beforeAll(async() => { browser = await getBrowser(); page = browser.page; - await page.loginAndModule('salesAssistant', 'claim'); + await page.loginAndModule('claimManager', 'claim'); await page.accessToSearchResult('1'); await page.accessToSection('claim.card.development'); }); @@ -31,7 +31,7 @@ describe('Claim development', () => { expect(message.type).toBe('success'); }); - it(`should redirect to the next section of claims as the role is salesAssistant`, async() => { + it(`should redirect to the next section of claims as the role is claimManager`, async() => { await page.waitForState('claim.card.action'); }); diff --git a/e2e/paths/06-claim/04_claim_action.spec.js b/e2e/paths/06-claim/04_claim_action.spec.js index e7ab8638c..710dc1809 100644 --- a/e2e/paths/06-claim/04_claim_action.spec.js +++ b/e2e/paths/06-claim/04_claim_action.spec.js @@ -8,7 +8,7 @@ describe('Claim action path', () => { beforeAll(async() => { browser = await getBrowser(); page = browser.page; - await page.loginAndModule('administrative', 'claim'); + await page.loginAndModule('claimManager', 'claim'); await page.accessToSearchResult('2'); await page.accessToSection('claim.card.action'); }); diff --git a/e2e/paths/06-claim/06_descriptor.spec.js b/e2e/paths/06-claim/06_descriptor.spec.js index 43d046d62..63db37731 100644 --- a/e2e/paths/06-claim/06_descriptor.spec.js +++ b/e2e/paths/06-claim/06_descriptor.spec.js @@ -26,8 +26,8 @@ describe('claim Descriptor path', () => { await page.waitForSelector(selectors.claimDescriptor.moreMenuDeleteClaim, {hidden: true}); }); - it(`should log in as salesAssistant and navigate to the target claim`, async() => { - await page.loginAndModule('salesAssistant', 'claim'); + it(`should log in as claimManager and navigate to the target claim`, async() => { + await page.loginAndModule('claimManager', 'claim'); await page.accessToSearchResult(claimId); await page.waitForState('claim.card.summary'); }); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 498635832..0ab85fc48 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -80,5 +80,6 @@ "shipped": "Shipped", "landed": "Landed", "addressFk": "Address", - "companyFk": "Company" + "companyFk": "Company", + "The grade must be similar to the last one": "The grade must be similar to the last one" } \ No newline at end of file diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js index 226a07917..8c013c172 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js @@ -2,13 +2,13 @@ const app = require('vn-loopback/server/server'); const LoopBackContext = require('loopback-context'); describe('claimBeginning', () => { - const salesAssistantId = 21; + const claimManagerId = 72; let ticket; let refundTicketSales; let salesInsertedInClaimEnd; const activeCtx = { - accessToken: {userId: salesAssistantId}, + accessToken: {userId: claimManagerId}, }; const ctx = {req: activeCtx}; diff --git a/modules/claim/back/methods/claim/isEditable.js b/modules/claim/back/methods/claim/isEditable.js index 2e9991584..ce68153b5 100644 --- a/modules/claim/back/methods/claim/isEditable.js +++ b/modules/claim/back/methods/claim/isEditable.js @@ -21,10 +21,8 @@ module.exports = Self => { Self.isEditable = async(ctx, id) => { const userId = ctx.req.accessToken.userId; - - const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant'); - - let claim = await Self.app.models.Claim.findById(id, { + const isClaimManager = await Self.app.models.Account.hasRole(userId, 'claimManager'); + const claim = await Self.app.models.Claim.findById(id, { fields: ['claimStateFk'], include: [{ relation: 'claimState' @@ -33,7 +31,7 @@ module.exports = Self => { const isClaimResolved = claim && claim.claimState().code == 'resolved'; - if (!claim || (isClaimResolved && !isSalesAssistant)) + if (!claim || (isClaimResolved && !isClaimManager)) return false; return true; diff --git a/modules/claim/back/methods/claim/specs/isEditable.spec.js b/modules/claim/back/methods/claim/specs/isEditable.spec.js index ca419de4c..19436e16f 100644 --- a/modules/claim/back/methods/claim/specs/isEditable.spec.js +++ b/modules/claim/back/methods/claim/specs/isEditable.spec.js @@ -2,9 +2,9 @@ const app = require('vn-loopback/server/server'); describe('claim isEditable()', () => { const salesPerdonId = 18; - const salesAssistantId = 21; + const claimManagerId = 72; it('should return false if the given claim does not exist', async() => { - let ctx = {req: {accessToken: {userId: salesAssistantId}}}; + let ctx = {req: {accessToken: {userId: claimManagerId}}}; let result = await app.models.Claim.isEditable(ctx, 99999); expect(result).toEqual(false); @@ -17,14 +17,14 @@ describe('claim isEditable()', () => { expect(result).toEqual(false); }); - it('should be able to edit a resolved claim for a salesAssistant', async() => { - let ctx = {req: {accessToken: {userId: salesAssistantId}}}; + it('should be able to edit a resolved claim for a claimManager', async() => { + let ctx = {req: {accessToken: {userId: claimManagerId}}}; let result = await app.models.Claim.isEditable(ctx, 4); expect(result).toEqual(true); }); - it('should be able to edit a claim for a salesAssistant', async() => { + it('should be able to edit a claim for a claimManager', async() => { let ctx = {req: {accessToken: {userId: salesPerdonId}}}; let result = await app.models.Claim.isEditable(ctx, 1); diff --git a/modules/claim/back/methods/claim/specs/updateClaim.spec.js b/modules/claim/back/methods/claim/specs/updateClaim.spec.js index f1ee99eac..7588595bc 100644 --- a/modules/claim/back/methods/claim/specs/updateClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/updateClaim.spec.js @@ -42,17 +42,17 @@ describe('Update Claim', () => { it(`should success to update the claim within privileges `, async() => { let newClaim = await app.models.Claim.create(originalData); - const correctState = 4; - const salesPersonId = 18; + const canceledState = 4; + const claimManagerId = 72; const ctx = { req: { accessToken: { - userId: salesPersonId + userId: claimManagerId } }, args: { observation: 'valid observation', - claimStateFk: correctState, + claimStateFk: canceledState, hasToPickUp: false } }; @@ -66,15 +66,15 @@ describe('Update Claim', () => { await app.models.Claim.destroyById(newClaim.id); }); - it('should change some sensible fields as salesAssistant', async() => { + it('should change some sensible fields as claimManager', async() => { let newClaim = await app.models.Claim.create(originalData); const chatModel = app.models.Chat; spyOn(chatModel, 'sendCheckingPresence').and.callThrough(); - const salesAssistantId = 21; + const claimManagerId = 72; const ctx = { req: { - accessToken: {userId: salesAssistantId}, + accessToken: {userId: claimManagerId}, headers: {origin: 'http://localhost'} }, args: { diff --git a/modules/claim/back/methods/claim/updateClaim.js b/modules/claim/back/methods/claim/updateClaim.js index c2c97d925..6c16b5737 100644 --- a/modules/claim/back/methods/claim/updateClaim.js +++ b/modules/claim/back/methods/claim/updateClaim.js @@ -60,9 +60,9 @@ module.exports = Self => { if (args.claimStateFk) { const canUpdate = await canChangeState(ctx, claim.claimStateFk); const hasRights = await canChangeState(ctx, args.claimStateFk); - const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant'); + const isClaimManager = await models.Account.hasRole(userId, 'claimManager'); - if (!canUpdate || !hasRights || changedHasToPickUp && !isSalesAssistant) + if (!canUpdate || !hasRights || changedHasToPickUp && !isClaimManager) throw new UserError(`You don't have enough privileges to change that field`); } delete args.ctx; diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html index 226794903..d2338bcc3 100644 --- a/modules/claim/front/basic-data/index.html +++ b/modules/claim/front/basic-data/index.html @@ -56,7 +56,8 @@ class="vn-mr-md" label="Pick up" ng-model="$ctrl.claim.hasToPickUp" - vn-acl="salesAssistant"> + vn-acl="claimManager" + info="When checked will notify to the salesPerson"> diff --git a/modules/claim/front/basic-data/index.js b/modules/claim/front/basic-data/index.js index 9fa3bdf4d..818012bb9 100644 --- a/modules/claim/front/basic-data/index.js +++ b/modules/claim/front/basic-data/index.js @@ -5,7 +5,7 @@ import './style.scss'; class Controller extends Section { onSubmit() { this.$.watcher.submit().then(() => { - if (this.aclService.hasAny(['salesAssistant'])) + if (this.aclService.hasAny(['claimManager'])) this.$state.go('claim.card.detail'); }); } diff --git a/modules/claim/front/descriptor/index.html b/modules/claim/front/descriptor/index.html index d6fb75ac5..1337c6242 100644 --- a/modules/claim/front/descriptor/index.html +++ b/modules/claim/front/descriptor/index.html @@ -13,7 +13,7 @@ Send Pickup order + vn-acl="claimManager"> From 15a906af2488f775b1cc65b9083096402308ae54 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 27 Oct 2020 08:45:34 +0100 Subject: [PATCH 08/20] link zone in ticket summary --- modules/ticket/front/summary/index.html | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index 676a5b0b8..924ad6d6d 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -28,8 +28,12 @@ - + + + {{$ctrl.summary.zone.name}} + @@ -247,3 +251,6 @@ + + \ No newline at end of file From 3d86e5989054473dde883c9f769464549acceaf8 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 27 Oct 2020 12:02:49 +0100 Subject: [PATCH 09/20] #2540 - Added entry descriptor popover to referenced places --- modules/item/front/diary/index.html | 8 ++++++-- modules/item/front/diary/index.js | 8 +++++--- modules/item/front/routes.json | 2 +- modules/travel/front/routes.json | 2 +- modules/travel/front/summary/index.html | 16 ++++++++++++---- modules/travel/front/summary/locale/es.yml | 2 +- modules/zone/front/events/index.html | 4 ++-- 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html index 080cc0f36..b8572dcff 100644 --- a/modules/item/front/diary/index.html +++ b/modules/item/front/diary/index.html @@ -55,8 +55,8 @@ - {{::sale.origin | dashIfEmpty}} @@ -94,3 +94,7 @@ + + + diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js index 953d203e8..bf04fabe9 100644 --- a/modules/item/front/diary/index.js +++ b/modules/item/front/diary/index.js @@ -58,10 +58,12 @@ class Controller extends Section { this.$anchorScroll(); } - showTicketDescriptor(event, sale) { - if (!sale.isTicket) return; + showDescriptor(event, sale) { + let descriptor = 'entryDescriptor'; + if (sale.isTicket) + descriptor = 'ticketDescriptor'; - this.$.ticketDescriptor.show(event.target, sale.origin); + this.$[descriptor].show(event.target, sale.origin); } } diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 2aab4301e..d3bde0205 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -3,7 +3,7 @@ "name": "Items", "icon": "icon-item", "validations" : true, - "dependencies": ["worker", "client", "ticket"], + "dependencies": ["worker", "client", "ticket", "entry"], "menus": { "main": [ {"state": "item.index", "icon": "icon-item"}, diff --git a/modules/travel/front/routes.json b/modules/travel/front/routes.json index b802aaa4a..5fa43fd1d 100644 --- a/modules/travel/front/routes.json +++ b/modules/travel/front/routes.json @@ -3,7 +3,7 @@ "name": "Travels", "icon": "local_airport", "validations": true, - "dependencies": ["worker"], + "dependencies": ["worker", "entry"], "menus": { "main": [ {"state": "travel.index", "icon": "local_airport"} diff --git a/modules/travel/front/summary/index.html b/modules/travel/front/summary/index.html index 12dbded4e..7e055a0f1 100644 --- a/modules/travel/front/summary/index.html +++ b/modules/travel/front/summary/index.html @@ -41,7 +41,7 @@ value="{{$ctrl.travelData.ref}}"> Package CC Pallet - m3 + @@ -75,7 +75,12 @@ disabled="true"> - {{entry.id}} + + + {{entry.id}} + + {{entry.supplierName}} {{entry.ref}} {{entry.hb}} @@ -141,4 +146,7 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/travel/front/summary/locale/es.yml b/modules/travel/front/summary/locale/es.yml index c82508dfc..8d2e7e78c 100644 --- a/modules/travel/front/summary/locale/es.yml +++ b/modules/travel/front/summary/locale/es.yml @@ -9,7 +9,7 @@ Received: Recibida Agency: Agencia Entries: Entradas Confirmed: Confirmada -Entry Id: Entrada Id +Entry Id: Id entrada Supplier: Proveedor Pallet: Pallet Freight: Porte diff --git a/modules/zone/front/events/index.html b/modules/zone/front/events/index.html index eea24a132..d48b5f0d8 100644 --- a/modules/zone/front/events/index.html +++ b/modules/zone/front/events/index.html @@ -73,7 +73,7 @@ value="{{::row.bonus | currency:'EUR':2}}"> @@ -166,7 +166,7 @@ From c0dddba3c43221508265036d4e20ec1edaba9605 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 27 Oct 2020 12:15:05 +0100 Subject: [PATCH 10/20] Added translation --- loopback/locale/en.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 498635832..49b605326 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -73,6 +73,7 @@ "I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})", "I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})", "Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "The grade must be similar to the last one": "The grade must be similar to the last one", "agencyModeFk": "Agency", "clientFk": "Client", "zoneFk": "Zone", @@ -80,5 +81,5 @@ "shipped": "Shipped", "landed": "Landed", "addressFk": "Address", - "companyFk": "Company" + "companyFk": "Company", } \ No newline at end of file From a45bd0987bce98328303511a05499b7ef4f456e7 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 27 Oct 2020 12:33:43 +0100 Subject: [PATCH 11/20] Removed comma --- loopback/locale/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 49b605326..3dfb73833 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -81,5 +81,5 @@ "shipped": "Shipped", "landed": "Landed", "addressFk": "Address", - "companyFk": "Company", + "companyFk": "Company" } \ No newline at end of file From 665d46dec313c62df841bf6e3a888387f3b78888 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 27 Oct 2020 12:44:46 +0100 Subject: [PATCH 12/20] fix translate --- modules/supplier/front/descriptor/index.html | 2 +- modules/supplier/front/descriptor/locale/es.yml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/supplier/front/descriptor/index.html b/modules/supplier/front/descriptor/index.html index 470d984f2..405f2da21 100644 --- a/modules/supplier/front/descriptor/index.html +++ b/modules/supplier/front/descriptor/index.html @@ -29,7 +29,7 @@ ng-class="{bright: $ctrl.supplier.isActive == false}"> diff --git a/modules/supplier/front/descriptor/locale/es.yml b/modules/supplier/front/descriptor/locale/es.yml index f803a21e1..be1f4e9fe 100644 --- a/modules/supplier/front/descriptor/locale/es.yml +++ b/modules/supplier/front/descriptor/locale/es.yml @@ -1,3 +1,5 @@ Tax number: NIF / CIF All entries with current supplier: Todas las entradas con el proveedor actual -Go to client: Ir al cliente \ No newline at end of file +Go to client: Ir al cliente +Supplier official: Proveedor oficial +Supplier inactive: Proveedor inactivo \ No newline at end of file From 770b6a30bbf04810abaf0251fc1e950c896a5bb5 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 27 Oct 2020 14:35:04 +0100 Subject: [PATCH 13/20] Added unit test --- modules/item/front/diary/index.spec.js | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/item/front/diary/index.spec.js b/modules/item/front/diary/index.spec.js index 52608cde3..988914978 100644 --- a/modules/item/front/diary/index.spec.js +++ b/modules/item/front/diary/index.spec.js @@ -60,6 +60,34 @@ describe('Item', () => { expect(controller.$anchorScroll).toHaveBeenCalledWith(); }); }); + + describe('showDescriptor ()', () => { + it('should call to the entryDescriptor show() method', () => { + controller.$.entryDescriptor = {}; + controller.$.entryDescriptor.show = jest.fn(); + + const $event = new Event('click'); + const target = document.createElement('div'); + target.dispatchEvent($event); + const data = {id: 1, origin: 1}; + controller.showDescriptor($event, data); + + expect(controller.$.entryDescriptor.show).toHaveBeenCalledWith($event.target, data.origin); + }); + + it('should call to the ticketDescriptor show() method', () => { + controller.$.ticketDescriptor = {}; + controller.$.ticketDescriptor.show = jest.fn(); + + const $event = new Event('click'); + const target = document.createElement('div'); + target.dispatchEvent($event); + const data = {id: 1, origin: 1, isTicket: true}; + controller.showDescriptor($event, data); + + expect(controller.$.ticketDescriptor.show).toHaveBeenCalledWith($event.target, data.origin); + }); + }); }); }); From 343358c2311a57469735111bc4ced11ed44f925f Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 27 Oct 2020 14:42:43 +0100 Subject: [PATCH 14/20] Updated translations --- loopback/locale/en.json | 3 +-- modules/claim/front/basic-data/locale/es.yml | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 0ab85fc48..498635832 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -80,6 +80,5 @@ "shipped": "Shipped", "landed": "Landed", "addressFk": "Address", - "companyFk": "Company", - "The grade must be similar to the last one": "The grade must be similar to the last one" + "companyFk": "Company" } \ No newline at end of file diff --git a/modules/claim/front/basic-data/locale/es.yml b/modules/claim/front/basic-data/locale/es.yml index d6bae25f6..174eb4b62 100644 --- a/modules/claim/front/basic-data/locale/es.yml +++ b/modules/claim/front/basic-data/locale/es.yml @@ -4,4 +4,5 @@ Is paid with mana: Cargado al maná Responsability: Responsabilidad Company: Empresa Sales/Client: Comercial/Cliente -Pick up: Recoger \ No newline at end of file +Pick up: Recoger +When checked will notify a pickup to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial \ No newline at end of file From 109fcb3ca4fe68af87af466e14c20153e071659d Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 28 Oct 2020 09:57:39 +0100 Subject: [PATCH 15/20] 2532 - Added icon taxDataChecked on ticket index --- modules/ticket/front/index/index.html | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index 902d1f5a4..6d63ccc81 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -14,6 +14,7 @@ + Id Salesperson Date @@ -40,27 +41,36 @@ + + + + From a4c57d7618292dfce2dbc665c18b1e7113ba89b6 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 28 Oct 2020 12:29:50 +0100 Subject: [PATCH 16/20] e2e path for supplier summary and descriptor --- e2e/helpers/selectors.js | 11 +++ .../01_summary_and_descriptor.spec.js | 84 +++++++++++++++++++ gulpfile.js | 3 + modules/supplier/front/summary/index.html | 2 +- 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 e2e/paths/13-supplier/01_summary_and_descriptor.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 8cea46964..06235cbfd 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -901,5 +901,16 @@ export default { newEntryTravel: 'vn-entry-create vn-autocomplete[ng-model="$ctrl.entry.travelFk"]', newEntryCompany: 'vn-entry-create vn-autocomplete[ng-model="$ctrl.entry.companyFk"]', saveNewEntry: 'vn-entry-create button[type="submit"]' + }, + supplierSummary: { + header: 'vn-supplier-summary > vn-card > h5', + basicDataId: 'vn-supplier-summary vn-label-value[label="Id"]', + fiscalAddressTaxNumber: 'vn-supplier-summary vn-label-value[label="Tax number"]', + billingDataPayMethod: 'vn-supplier-summary vn-label-value[label="Pay method"]' + }, + supplierDescriptor: { + alias: 'vn-supplier-descriptor vn-label-value[label="Alias"]', + clientButton: 'vn-supplier-descriptor vn-icon[icon="person"]', + entriesButton: 'vn-supplier-descriptor vn-icon[icon="icon-entry"]', } }; diff --git a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js new file mode 100644 index 000000000..953a9ee28 --- /dev/null +++ b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js @@ -0,0 +1,84 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Supplier descriptor path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('administrative', 'supplier'); + await page.accessToSearchResult('1'); + }); + + afterAll(async() => { + await browser.close(); + }); + + // summary + it('should reach the second entry summary section', async() => { + await page.waitForState('supplier.card.summary'); + }); + + it(`should confirm there's data on the summary header`, async() => { + const result = await page.waitToGetProperty(selectors.supplierSummary.header, 'innerText'); + + expect(result).toContain('Plants SL - 1'); + }); + + it(`should confirm there's data on the summary basic data`, async() => { + const result = await page.waitToGetProperty(selectors.supplierSummary.basicDataId, 'innerText'); + + expect(result).toContain('Id 1'); + }); + + it(`should confirm there's data on the summary fiscal address`, async() => { + const result = await page.waitToGetProperty(selectors.supplierSummary.fiscalAddressTaxNumber, 'innerText'); + + expect(result).toContain('Tax number 06089160W'); + }); + + it(`should confirm there's data on the summary fiscal pay method`, async() => { + const result = await page.waitToGetProperty(selectors.supplierSummary.billingDataPayMethod, 'innerText'); + + expect(result).toContain('Pay method PayMethod one'); + }); + + // descriptor + it(`should confirm there's data on the descriptor`, async() => { + const result = await page.waitToGetProperty(selectors.supplierDescriptor.alias, 'innerText'); + + expect(result).toContain('Plants nick'); + }); + + it(`should navigate to the supplier's client summary using the icon client button`, async() => { + await page.waitToClick(selectors.supplierDescriptor.clientButton); + await page.waitForState('client.card.summary'); + }); + + it(`should navigate back to the supplier`, async() => { + await page.waitToClick(selectors.globalItems.homeButton); + await page.waitForState('home'); + await page.selectModule('supplier'); + await page.accessToSearchResult('1'); + await page.waitForState('supplier.card.summary'); + }); + + it(`should navigate to the supplier's entries`, async() => { + await page.waitToClick(selectors.supplierDescriptor.entriesButton); + await page.waitForState('entry.index'); + }); + + it(`should navigate back to suppliers but a different one this time`, async() => { + await page.waitToClick(selectors.globalItems.homeButton); + await page.waitForState('home'); + await page.selectModule('supplier'); + await page.accessToSearchResult('2'); + await page.waitForState('supplier.card.summary'); + }); + + it(`should check the client button isn't present since this supplier should not be a client`, async() => { + await page.waitForSelector(selectors.supplierDescriptor.clientButton, {hidden: true}); + }); +}); diff --git a/gulpfile.js b/gulpfile.js index 6bd2b3542..61459c3fd 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -162,6 +162,9 @@ function e2eSingleRun() { `${__dirname}/e2e/paths/08*/*[sS]pec.js`, `${__dirname}/e2e/paths/09*/*[sS]pec.js`, `${__dirname}/e2e/paths/10*/*[sS]pec.js`, + `${__dirname}/e2e/paths/11*/*[sS]pec.js`, + `${__dirname}/e2e/paths/12*/*[sS]pec.js`, + `${__dirname}/e2e/paths/13*/*[sS]pec.js`, `${__dirname}/e2e/paths/**/*[sS]pec.js` ]; diff --git a/modules/supplier/front/summary/index.html b/modules/supplier/front/summary/index.html index c22a32f91..be6a027a6 100644 --- a/modules/supplier/front/summary/index.html +++ b/modules/supplier/front/summary/index.html @@ -28,7 +28,7 @@ - Date: Thu, 29 Oct 2020 07:44:04 +0100 Subject: [PATCH 17/20] cr changes --- modules/supplier/back/methods/supplier/filter.js | 1 - .../supplier/back/methods/supplier/specs/getSummary.spec.js | 6 +++--- modules/supplier/front/descriptor/index.html | 4 ++-- modules/supplier/front/descriptor/locale/es.yml | 4 ++-- modules/supplier/front/search-panel/locale/es.yml | 4 ++-- modules/supplier/front/summary/locale/es.yml | 4 ++-- modules/supplier/front/summary/style.scss | 2 +- 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/modules/supplier/back/methods/supplier/filter.js b/modules/supplier/back/methods/supplier/filter.js index b1e7d3884..3500afacd 100644 --- a/modules/supplier/back/methods/supplier/filter.js +++ b/modules/supplier/back/methods/supplier/filter.js @@ -65,7 +65,6 @@ module.exports = Self => { {'s.name': {like: `%${value}%`}}, {'s.nickname': {like: `%${value}%`}} ]}; - // return {'s.id': value}; case 'nickname': param = `s.${param}`; return {[param]: {like: `%${value}%`}}; diff --git a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js index 73feba9ad..7179e2d77 100644 --- a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js +++ b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js @@ -7,9 +7,11 @@ describe('Supplier getSummary()', () => { expect(supplier.id).toEqual(1); expect(supplier.name).toEqual('Plants SL'); expect(supplier.nif).toEqual('06089160W'); + expect(supplier.account).toEqual(4000000001); + expect(supplier.payDay).toEqual(15); }); - it(`should return a summary object containing it's supplier country`, async() => { + it(`should return a summary object containing it's supplier country relation`, async() => { const supplier = await app.models.Supplier.getSummary(1); const country = supplier.country(); @@ -21,8 +23,6 @@ describe('Supplier getSummary()', () => { const supplier = await app.models.Supplier.getSummary(1); const payMethod = supplier.payMethod(); - expect(supplier.account).toEqual(4000000001); - expect(supplier.payDay).toEqual(15); expect(payMethod.name).toEqual('PayMethod one'); }); }); diff --git a/modules/supplier/front/descriptor/index.html b/modules/supplier/front/descriptor/index.html index 405f2da21..5e7225e1c 100644 --- a/modules/supplier/front/descriptor/index.html +++ b/modules/supplier/front/descriptor/index.html @@ -24,12 +24,12 @@
diff --git a/modules/supplier/front/descriptor/locale/es.yml b/modules/supplier/front/descriptor/locale/es.yml index be1f4e9fe..c92a917c7 100644 --- a/modules/supplier/front/descriptor/locale/es.yml +++ b/modules/supplier/front/descriptor/locale/es.yml @@ -1,5 +1,5 @@ Tax number: NIF / CIF All entries with current supplier: Todas las entradas con el proveedor actual Go to client: Ir al cliente -Supplier official: Proveedor oficial -Supplier inactive: Proveedor inactivo \ No newline at end of file +Official supplier: Proveedor oficial +Inactive supplier: Proveedor inactivo \ No newline at end of file diff --git a/modules/supplier/front/search-panel/locale/es.yml b/modules/supplier/front/search-panel/locale/es.yml index 964e7a8d9..77253a4ef 100644 --- a/modules/supplier/front/search-panel/locale/es.yml +++ b/modules/supplier/front/search-panel/locale/es.yml @@ -1,4 +1,4 @@ Province: Provincia Country: País -Tax number: Nif -Search suppliers by id, name or alias: Busca proveedores por el id, el nombre o el alias \ No newline at end of file +Tax number: NIF / CIF +Search suppliers by id, name or alias: Busca proveedores por id, nombre o alias \ No newline at end of file diff --git a/modules/supplier/front/summary/locale/es.yml b/modules/supplier/front/summary/locale/es.yml index b367ebb35..abdb4d1c7 100644 --- a/modules/supplier/front/summary/locale/es.yml +++ b/modules/supplier/front/summary/locale/es.yml @@ -1,5 +1,5 @@ Is official: Es oficial Country: País -Tax number: Nif -Search suppliers by id, name or alias: Busca proveedores por el id, el nombre o el alias +Tax number: NIF / CIF +Search suppliers by id, name or alias: Busca proveedores por id, nombre o alias Is Farmer: Es agrícola \ No newline at end of file diff --git a/modules/supplier/front/summary/style.scss b/modules/supplier/front/summary/style.scss index 1520659d2..1eb6b2323 100644 --- a/modules/supplier/front/summary/style.scss +++ b/modules/supplier/front/summary/style.scss @@ -2,6 +2,6 @@ vn-client-summary { .alert span { - color: $color-alert !important + color: $color-alert } } \ No newline at end of file From 403d4b9118bb3f23eae84510cb6ed33448e6a388 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 29 Oct 2020 08:17:06 +0100 Subject: [PATCH 18/20] cr changes --- modules/supplier/back/methods/supplier/specs/getSummary.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js index 7179e2d77..42e89afd4 100644 --- a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js +++ b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js @@ -19,7 +19,7 @@ describe('Supplier getSummary()', () => { expect(country.code).toEqual('ES'); }); - it(`should return a summary object containing it's billing data`, async() => { + it(`should return a summary object containing it's billing data relation`, async() => { const supplier = await app.models.Supplier.getSummary(1); const payMethod = supplier.payMethod(); From 42d16d02583ee7878f5f2a3faaf6528b9bb9e798 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 29 Oct 2020 11:09:58 +0100 Subject: [PATCH 19/20] ticket component refactor --- modules/ticket/back/models/ticket.json | 6 ++++ modules/ticket/front/card/index.js | 3 ++ modules/ticket/front/component/index.html | 30 ++++++++++++++++++-- modules/ticket/front/component/index.js | 10 ++++++- modules/ticket/front/component/index.spec.js | 5 +++- modules/ticket/front/component/locale/es.yml | 6 +++- 6 files changed, 54 insertions(+), 6 deletions(-) diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json index ca4668b3a..2bb86312d 100644 --- a/modules/ticket/back/models/ticket.json +++ b/modules/ticket/back/models/ticket.json @@ -48,6 +48,12 @@ }, "zoneFk": { "type": "Number" + }, + "zonePrice": { + "type": "Number" + }, + "zoneBonus": { + "type": "Number" } }, "relations": { diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js index 44fc3e48b..6e38039e2 100644 --- a/modules/ticket/front/card/index.js +++ b/modules/ticket/front/card/index.js @@ -15,6 +15,9 @@ class Controller extends ModuleCard { relation: 'warehouse', scope: {fields: ['name']} }, + { + relation: 'zone', + }, { relation: 'invoiceOut', scope: {fields: ['id']} diff --git a/modules/ticket/front/component/index.html b/modules/ticket/front/component/index.html index fb8af3219..c9b506bc9 100644 --- a/modules/ticket/front/component/index.html +++ b/modules/ticket/front/component/index.html @@ -76,11 +76,35 @@
-
Theorical cost
-
Price {{$ctrl.theoricalCost | currency: 'EUR': 2}}
+
Zone breakdown
+
Zone price {{$ctrl.ticket.zonePrice | currency: 'EUR': 2}}
+
Zone bonus {{$ctrl.ticket.zoneBonus | currency: 'EUR': 2}}
+
Zone + + {{$ctrl.ticket.zone.name | dashIfEmpty}} + +
+
+ Volume {{$ctrl.ticketVolume}} +
+
+ Packages {{$ctrl.ticket.packages}} +
+
+
+
Theorical cost
+
Price total {{$ctrl.theoricalCost | currency: 'EUR': 2}}
- \ No newline at end of file + + + + + diff --git a/modules/ticket/front/component/index.js b/modules/ticket/front/component/index.js index 7557bfba6..2a5988719 100644 --- a/modules/ticket/front/component/index.js +++ b/modules/ticket/front/component/index.js @@ -37,9 +37,10 @@ class Controller extends Section { this._ticket = value; if (!value) return; - this.getTheoricalCost(); this.getComponentsSum(); + if (this.ticket.zone.isVolumetric) + this.getTicketVolume(); } base() { @@ -76,6 +77,13 @@ class Controller extends Section { this.$http.get(`Tickets/${this.ticket.id}/getComponentsSum`) .then(res => this.componentsList = res.data); } + + getTicketVolume() { + if (!this.ticket) return; + + this.$http.get(`Tickets/${this.ticket.id}/getVolume`) + .then(res => this.ticketVolume = res.data[0].volume); + } } ngModule.vnComponent('vnTicketComponents', { diff --git a/modules/ticket/front/component/index.spec.js b/modules/ticket/front/component/index.spec.js index 053248c2c..acd757578 100644 --- a/modules/ticket/front/component/index.spec.js +++ b/modules/ticket/front/component/index.spec.js @@ -89,7 +89,10 @@ describe('ticket', () => { jest.spyOn(controller, 'getComponentsSum'); controller._ticket = undefined; controller.ticket = { - id: 7 + id: 7, + zone: { + isVolumetric: false + } }; expect(controller.ticket).toBeDefined(); diff --git a/modules/ticket/front/component/locale/es.yml b/modules/ticket/front/component/locale/es.yml index 57dcf64e0..af07811b8 100644 --- a/modules/ticket/front/component/locale/es.yml +++ b/modules/ticket/front/component/locale/es.yml @@ -1,2 +1,6 @@ Theorical cost: Porte teorico -Total without VAT: Total sin IVA \ No newline at end of file +Total without VAT: Total sin IVA +Zone bonus: Bonificación +Zone price: Precio de la zona +Price total: Precio total +Zone breakdown: Desglose zona \ No newline at end of file From 551feed16fec95f06f4f78dda347840518d5a435 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 29 Oct 2020 11:46:37 +0100 Subject: [PATCH 20/20] fix translate --- modules/ticket/front/component/index.html | 4 ++-- modules/ticket/front/component/locale/es.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/ticket/front/component/index.html b/modules/ticket/front/component/index.html index c9b506bc9..f47521e4d 100644 --- a/modules/ticket/front/component/index.html +++ b/modules/ticket/front/component/index.html @@ -77,8 +77,8 @@
Zone breakdown
-
Zone price {{$ctrl.ticket.zonePrice | currency: 'EUR': 2}}
-
Zone bonus {{$ctrl.ticket.zoneBonus | currency: 'EUR': 2}}
+
Price {{$ctrl.ticket.zonePrice | currency: 'EUR': 2}}
+
Bonus {{$ctrl.ticket.zoneBonus | currency: 'EUR': 2}}
Zone