From 87e1caa4eb53ac07840755ae1057b5966e5861e6 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 15 May 2023 10:43:06 +0200 Subject: [PATCH 01/80] refs #5334 department seccion --- .../front/department/basic-data/index.html | 101 +++++++++++++++++ .../front/department/basic-data/index.js | 27 +++++ .../front/department/basic-data/locale/es.yml | 9 ++ .../front/department/{ => index}/index.html | 3 +- .../front/department/{ => index}/index.js | 2 +- modules/worker/front/department/routes.json | 103 ++++++++++++++++++ .../front/department/summary/index.html | 73 +++++++++++++ .../worker/front/department/summary/index.js | 74 +++++++++++++ .../front/department/summary/locale/es.yml | 4 + modules/worker/front/index.js | 2 +- modules/worker/front/routes.json | 2 +- 11 files changed, 396 insertions(+), 4 deletions(-) create mode 100644 modules/worker/front/department/basic-data/index.html create mode 100644 modules/worker/front/department/basic-data/index.js create mode 100644 modules/worker/front/department/basic-data/locale/es.yml rename modules/worker/front/department/{ => index}/index.html (93%) rename modules/worker/front/department/{ => index}/index.js (98%) create mode 100644 modules/worker/front/department/routes.json create mode 100644 modules/worker/front/department/summary/index.html create mode 100644 modules/worker/front/department/summary/index.js create mode 100644 modules/worker/front/department/summary/locale/es.yml diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html new file mode 100644 index 000000000..d89d88f2e --- /dev/null +++ b/modules/worker/front/department/basic-data/index.html @@ -0,0 +1,101 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/modules/worker/front/department/basic-data/index.js b/modules/worker/front/department/basic-data/index.js new file mode 100644 index 000000000..ea75d7b97 --- /dev/null +++ b/modules/worker/front/department/basic-data/index.js @@ -0,0 +1,27 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +class Controller extends Section { + constructor($element, $) { + super($element, $); + this.maritalStatus = [ + {code: 'M', name: this.$t('Married')}, + {code: 'S', name: this.$t('Single')} + ]; + } + onSubmit() { + return this.$.watcher.submit() + .then(() => this.card.reload()); + } +} + +ngModule.vnComponent('vnWorkerBasicData', { + template: require('./index.html'), + controller: Controller, + bindings: { + worker: '<' + }, + require: { + card: '^vnWorkerCard' + } +}); diff --git a/modules/worker/front/department/basic-data/locale/es.yml b/modules/worker/front/department/basic-data/locale/es.yml new file mode 100644 index 000000000..edf08de90 --- /dev/null +++ b/modules/worker/front/department/basic-data/locale/es.yml @@ -0,0 +1,9 @@ +Marital status: Estado civil +Origin country: País origen +Education level: Nivel educación +SSN: NSS +Married: Casado/a +Single: Soltero/a +Business phone: Teléfono de empresa +Mobile extension: Extensión móvil +Locker: Taquilla diff --git a/modules/worker/front/department/index.html b/modules/worker/front/department/index/index.html similarity index 93% rename from modules/worker/front/department/index.html rename to modules/worker/front/department/index/index.html index df8630104..9afa90e13 100644 --- a/modules/worker/front/department/index.html +++ b/modules/worker/front/department/index/index.html @@ -12,7 +12,8 @@ sort-func="$ctrl.onSort($a, $b)" on-drop="$ctrl.onDrop($dropped, $dragged)" on-drag-start="$ctrl.onDragStart(item)" - on-drag-end="$ctrl.onDragEnd(item)"> + on-drag-end="$ctrl.onDragEnd(item)" + ui-sref="department.card.summary(item)"> {{::item.name}} diff --git a/modules/worker/front/department/index.js b/modules/worker/front/department/index/index.js similarity index 98% rename from modules/worker/front/department/index.js rename to modules/worker/front/department/index/index.js index 15904a963..178299362 100644 --- a/modules/worker/front/department/index.js +++ b/modules/worker/front/department/index/index.js @@ -1,4 +1,4 @@ -import ngModule from '../module'; +import ngModule from '../../module'; import Section from 'salix/components/section'; class Controller extends Section { diff --git a/modules/worker/front/department/routes.json b/modules/worker/front/department/routes.json new file mode 100644 index 000000000..f6fd46367 --- /dev/null +++ b/modules/worker/front/department/routes.json @@ -0,0 +1,103 @@ +{ + "module": "deparment", + "name": "Departments", + "icon" : "work", + "validations" : true, + "dependencies": ["account"], + "menus": { + "main": [ + {"state": "deparment.index", "icon": "icon-worker"} + ], + "card": [ + {"state": "department.card.basicData", "icon": "settings"}, + { + "icon": "icon-wiki", + "external":true, + "url": "http://wiki.verdnatura.es", + "description": "Wikipedia" + }, + {"state": "worker.card.workerLog", "icon": "history"} + ] + }, + "routes": [ + { + "url": "/worker", + "state": "worker", + "abstract": true, + "component": "vn-worker", + "description": "Workers" + }, { + "url": "/index?q", + "state": "worker.index", + "component": "vn-worker-index", + "description": "Workers" + }, { + "url" : "/summary", + "state": "worker.card.summary", + "component": "vn-worker-summary", + "description": "Summary", + "params": { + "worker": "$ctrl.worker" + } + }, { + "url": "/:id", + "state": "worker.card", + "component": "vn-worker-card", + "abstract": true, + "description": "Detail" + }, { + "url": "/basic-data", + "state": "worker.card.basicData", + "component": "vn-worker-basic-data", + "description": "Basic data", + "params": { + "worker": "$ctrl.worker" + }, + "acl": ["hr"] + }, { + "url" : "/log", + "state": "worker.card.workerLog", + "component": "vn-worker-log", + "description": "Log", + "acl": ["salesAssistant"] + }, { + "url": "/index", + "state": "worker.card.note.index", + "component": "vn-worker-note", + "description": "Notes", + "params": { + "worker": "$ctrl.worker" + }, + "acl": ["hr"] + }, { + "url": "/create", + "state": "worker.card.note.create", + "component": "vn-note-worker-create", + "description": "New note" + }, + { + "url": "/index", + "state": "worker.card.dms.index", + "component": "vn-worker-dms-index", + "description": "My documentation", + "acl": ["employee"] + }, + { + "url": "/create", + "state": "worker.card.dms.create", + "component": "vn-worker-dms-create", + "description": "Upload file", + "params": { + "worker": "$ctrl.worker" + }, + "acl": ["hr"] + }, + { + "url": "/create", + "state": "worker.create", + "component": "vn-worker-create", + "description": "New worker", + "acl": ["hr"] + } + ] +} diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html new file mode 100644 index 000000000..de8710a6d --- /dev/null +++ b/modules/worker/front/department/summary/index.html @@ -0,0 +1,73 @@ + +
+ + + + {{worker.firstName}} {{worker.lastName}} +
+ + +

+ + Basic data + +

+

+ Basic data +

+ + + + + + + + + {{::worker.boss.nickname}} + + + + + + + + + + +
+ +

User data

+ + + + + + + + +
+
+
+ + diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js new file mode 100644 index 000000000..c2ad107d5 --- /dev/null +++ b/modules/worker/front/department/summary/index.js @@ -0,0 +1,74 @@ +import ngModule from '../module'; +import Summary from 'salix/components/summary'; + +class Controller extends Summary { + get worker() { + return this._worker; + } + + set worker(value) { + this._worker = value; + this.$.worker = null; + if (!value) return; + + const query = `Workers/${value.id}`; + const filter = { + include: [ + { + relation: 'user', + scope: { + fields: ['name', 'roleFk'], + include: [{ + relation: 'role', + scope: { + fields: ['name'] + } + }, + { + relation: 'emailUser', + scope: { + fields: ['email'] + } + }] + } + }, + { + relation: 'client', + scope: {fields: ['fi', 'phone']} + }, + { + relation: 'boss', + scope: {fields: ['id', 'nickname']} + }, + { + relation: 'sip', + scope: {fields: ['extension']} + }, + { + relation: 'department', + scope: { + include: { + relation: 'department' + } + } + } + ] + }; + + this.$http.get(query, {params: {filter}}).then(res => { + this.$.worker = res.data; + }); + } + + get isHr() { + return this.aclService.hasAny(['hr']); + } +} + +ngModule.vnComponent('vnWorkerSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + worker: '<' + } +}); diff --git a/modules/worker/front/department/summary/locale/es.yml b/modules/worker/front/department/summary/locale/es.yml new file mode 100644 index 000000000..fb9d2e2ca --- /dev/null +++ b/modules/worker/front/department/summary/locale/es.yml @@ -0,0 +1,4 @@ +Business phone: Teléfono de empresa +Personal phone: Teléfono personal +Mobile extension: Extensión móvil +Locker: Taquilla diff --git a/modules/worker/front/index.js b/modules/worker/front/index.js index 8fad2c0df..605ec9dde 100644 --- a/modules/worker/front/index.js +++ b/modules/worker/front/index.js @@ -11,7 +11,7 @@ import './search-panel'; import './basic-data'; import './pbx'; import './pda'; -import './department'; +import './department/index'; import './calendar'; import './time-control'; import './log'; diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 25a0ffbcf..6817d0cef 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -118,7 +118,7 @@ "worker": "$ctrl.worker" } }, { - "url" : "/department", + "url" : "/department/department", "state": "worker.department", "component": "vn-worker-department", "description": "Departments", From 598067f75724482cf10962afb513c18235f13444 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 15 May 2023 13:15:33 +0200 Subject: [PATCH 02/80] refs #5334 routes --- front/salix/components/left-menu/left-menu.js | 2 +- modules/worker/back/models/department.json | 12 ++ .../worker/front/department/card/index.html | 5 + modules/worker/front/department/card/index.js | 29 +++++ .../front/department/descriptor/index.html | 90 +++++++++++++++ .../front/department/descriptor/index.js | 104 ++++++++++++++++++ .../front/department/descriptor/index.spec.js | 26 +++++ .../worker/front/department/index/index.html | 2 +- .../worker/front/department/index/index.js | 2 +- .../worker/front/department/main/index.html | 18 +++ modules/worker/front/department/main/index.js | 9 ++ modules/worker/front/department/routes.json | 103 ----------------- .../front/department/summary/index.html | 44 ++++---- .../worker/front/department/summary/index.js | 52 ++------- modules/worker/front/routes.json | 28 ++++- 15 files changed, 351 insertions(+), 175 deletions(-) create mode 100644 modules/worker/front/department/card/index.html create mode 100644 modules/worker/front/department/card/index.js create mode 100644 modules/worker/front/department/descriptor/index.html create mode 100644 modules/worker/front/department/descriptor/index.js create mode 100644 modules/worker/front/department/descriptor/index.spec.js create mode 100644 modules/worker/front/department/main/index.html create mode 100644 modules/worker/front/department/main/index.js delete mode 100644 modules/worker/front/department/routes.json diff --git a/front/salix/components/left-menu/left-menu.js b/front/salix/components/left-menu/left-menu.js index da545b291..6bec61775 100644 --- a/front/salix/components/left-menu/left-menu.js +++ b/front/salix/components/left-menu/left-menu.js @@ -45,7 +45,7 @@ export default class LeftMenu { if (acl && !this.aclService.hasAny(acl)) continue; } - + console.log(state, item); let myItem = { icon: item.icon, description: item.description || state.description, diff --git a/modules/worker/back/models/department.json b/modules/worker/back/models/department.json index c3f627e93..7d8d61d73 100644 --- a/modules/worker/back/models/department.json +++ b/modules/worker/back/models/department.json @@ -38,5 +38,17 @@ "hasToMistake": { "type": "number" } + }, + "relations": { + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "clientFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + } } } diff --git a/modules/worker/front/department/card/index.html b/modules/worker/front/department/card/index.html new file mode 100644 index 000000000..cc1ad59e4 --- /dev/null +++ b/modules/worker/front/department/card/index.html @@ -0,0 +1,5 @@ + + + + + diff --git a/modules/worker/front/department/card/index.js b/modules/worker/front/department/card/index.js new file mode 100644 index 000000000..288c1a8c3 --- /dev/null +++ b/modules/worker/front/department/card/index.js @@ -0,0 +1,29 @@ +import ngModule from '../module'; +import ModuleCard from 'salix/components/module-card'; + +class Controller extends ModuleCard { + reload() { + const filter = { + fields: ['chatName', 'notificationEmail'], + include: [ + { + relation: 'client', + scope: {fields: ['name']} + }, + { + relation: 'worker', + scope: {fields: ['name']} + } + + ] + }; + + this.$http.get(`Departments/${this.$params.id}`, {filter}) + .then(res => this.department = res.data); + } +} + +ngModule.vnComponent('vnWorkerDepartmentCard', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html new file mode 100644 index 000000000..564c2d4da --- /dev/null +++ b/modules/worker/front/department/descriptor/index.html @@ -0,0 +1,90 @@ + + \ No newline at end of file diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js new file mode 100644 index 000000000..af57643b7 --- /dev/null +++ b/modules/worker/front/department/descriptor/index.js @@ -0,0 +1,104 @@ +import ngModule from '../module'; +import Descriptor from 'salix/components/descriptor'; + +class Controller extends Descriptor { + constructor($element, $, $rootScope) { + super($element, $); + this.$rootScope = $rootScope; + } + + // get worker() { + // return this.entity; + // } + + // set worker(value) { + // this.entity = value; + + // if (value) + // this.getIsExcluded(); + // } + + // get excluded() { + // return this.entity.excluded; + // } + + // set excluded(value) { + // this.entity.excluded = value; + // } + + // getIsExcluded() { + // this.$http.get(`workerDisableExcludeds/${this.entity.id}/exists`).then(data => { + // this.excluded = data.data.exists; + // }); + // } + + // handleExcluded() { + // if (this.excluded) { + // this.$http.delete(`workerDisableExcludeds/${this.entity.id}`); + // this.excluded = false; + // } else { + // this.$http.post(`workerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date}); + // this.excluded = true; + // } + // } + + // loadData() { + // const filter = { + // include: [ + // { + // relation: 'user', + // scope: { + // fields: ['name'], + // include: { + // relation: 'emailUser', + // scope: { + // fields: ['email'] + // } + // } + // } + // }, { + // relation: 'client', + // scope: { + // fields: ['fi'] + // } + // }, { + // relation: 'sip', + // scope: { + // fields: ['extension'] + // } + // }, { + // relation: 'department', + // scope: { + // include: { + // relation: 'department' + // } + // } + // } + // ] + // }; + + // return this.getData(`Workers/${this.id}`, {filter}) + // .then(res => this.entity = res.data); + // } + + // onUploadResponse() { + // const timestamp = Date.vnNew().getTime(); + // const src = this.$rootScope.imagePath('user', '520x520', this.worker.id); + // const zoomSrc = this.$rootScope.imagePath('user', '1600x1600', this.worker.id); + // const newSrc = `${src}&t=${timestamp}`; + // const newZoomSrc = `${zoomSrc}&t=${timestamp}`; + + // this.$.photo.setAttribute('src', newSrc); + // this.$.photo.setAttribute('zoom-image', newZoomSrc); + // } +} + +Controller.$inject = ['$element', '$scope', '$rootScope']; + +ngModule.vnComponent('vnWorkerDepartmentDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + worker: '<' + } +}); diff --git a/modules/worker/front/department/descriptor/index.spec.js b/modules/worker/front/department/descriptor/index.spec.js new file mode 100644 index 000000000..dfb800415 --- /dev/null +++ b/modules/worker/front/department/descriptor/index.spec.js @@ -0,0 +1,26 @@ +import './index.js'; + +describe('vnWorkerDescriptor', () => { + let controller; + let $httpBackend; + + beforeEach(ngModule('worker')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnWorkerDescriptor', {$element: null}); + })); + + describe('loadData()', () => { + it(`should perform a get query to store the worker data into the controller`, () => { + const id = 1; + const response = 'foo'; + + $httpBackend.expectRoute('GET', `Workers/${id}`).respond(response); + controller.id = id; + $httpBackend.flush(); + + expect(controller.worker).toEqual(response); + }); + }); +}); diff --git a/modules/worker/front/department/index/index.html b/modules/worker/front/department/index/index.html index 9afa90e13..894583213 100644 --- a/modules/worker/front/department/index/index.html +++ b/modules/worker/front/department/index/index.html @@ -13,7 +13,7 @@ on-drop="$ctrl.onDrop($dropped, $dragged)" on-drag-start="$ctrl.onDragStart(item)" on-drag-end="$ctrl.onDragEnd(item)" - ui-sref="department.card.summary(item)"> + ng-click="department.card.summary($item)"> {{::item.name}} diff --git a/modules/worker/front/department/index/index.js b/modules/worker/front/department/index/index.js index 178299362..6b7ab18da 100644 --- a/modules/worker/front/department/index/index.js +++ b/modules/worker/front/department/index/index.js @@ -77,7 +77,7 @@ class Controller extends Section { } } -ngModule.vnComponent('vnWorkerDepartment', { +ngModule.vnComponent('vnWorkerDepartmentIndex', { template: require('./index.html'), controller: Controller }); diff --git a/modules/worker/front/department/main/index.html b/modules/worker/front/department/main/index.html new file mode 100644 index 000000000..3ab993e83 --- /dev/null +++ b/modules/worker/front/department/main/index.html @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/modules/worker/front/department/main/index.js b/modules/worker/front/department/main/index.js new file mode 100644 index 000000000..75110f749 --- /dev/null +++ b/modules/worker/front/department/main/index.js @@ -0,0 +1,9 @@ +import ngModule from '../module'; +import ModuleMain from 'salix/components/module-main'; + +export default class Worker extends ModuleMain {} + +ngModule.vnComponent('vnWorkerDepartment', { + controller: Worker, + template: require('./index.html') +}); diff --git a/modules/worker/front/department/routes.json b/modules/worker/front/department/routes.json deleted file mode 100644 index f6fd46367..000000000 --- a/modules/worker/front/department/routes.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "module": "deparment", - "name": "Departments", - "icon" : "work", - "validations" : true, - "dependencies": ["account"], - "menus": { - "main": [ - {"state": "deparment.index", "icon": "icon-worker"} - ], - "card": [ - {"state": "department.card.basicData", "icon": "settings"}, - { - "icon": "icon-wiki", - "external":true, - "url": "http://wiki.verdnatura.es", - "description": "Wikipedia" - }, - {"state": "worker.card.workerLog", "icon": "history"} - ] - }, - "routes": [ - { - "url": "/worker", - "state": "worker", - "abstract": true, - "component": "vn-worker", - "description": "Workers" - }, { - "url": "/index?q", - "state": "worker.index", - "component": "vn-worker-index", - "description": "Workers" - }, { - "url" : "/summary", - "state": "worker.card.summary", - "component": "vn-worker-summary", - "description": "Summary", - "params": { - "worker": "$ctrl.worker" - } - }, { - "url": "/:id", - "state": "worker.card", - "component": "vn-worker-card", - "abstract": true, - "description": "Detail" - }, { - "url": "/basic-data", - "state": "worker.card.basicData", - "component": "vn-worker-basic-data", - "description": "Basic data", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, { - "url" : "/log", - "state": "worker.card.workerLog", - "component": "vn-worker-log", - "description": "Log", - "acl": ["salesAssistant"] - }, { - "url": "/index", - "state": "worker.card.note.index", - "component": "vn-worker-note", - "description": "Notes", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, { - "url": "/create", - "state": "worker.card.note.create", - "component": "vn-note-worker-create", - "description": "New note" - }, - { - "url": "/index", - "state": "worker.card.dms.index", - "component": "vn-worker-dms-index", - "description": "My documentation", - "acl": ["employee"] - }, - { - "url": "/create", - "state": "worker.card.dms.create", - "component": "vn-worker-dms-create", - "description": "Upload file", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, - { - "url": "/create", - "state": "worker.create", - "component": "vn-worker-create", - "description": "New worker", - "acl": ["hr"] - } - ] -} diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html index de8710a6d..3cffe2f71 100644 --- a/modules/worker/front/department/summary/index.html +++ b/modules/worker/front/department/summary/index.html @@ -1,18 +1,18 @@
- - {{worker.firstName}} {{worker.lastName}} + {{department.name}}

+ ui-sref="department.card.basicData({id:$ctrl.department.id})"> Basic data

@@ -21,34 +21,28 @@ ng-show="!$ctrl.isHr"> Basic data - + - + - + + label="Boss:"> {{::worker.boss.nickname}} - + - - - - - +
@@ -68,6 +62,6 @@
- - + + diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js index c2ad107d5..ede559d18 100644 --- a/modules/worker/front/department/summary/index.js +++ b/modules/worker/front/department/summary/index.js @@ -2,56 +2,28 @@ import ngModule from '../module'; import Summary from 'salix/components/summary'; class Controller extends Summary { - get worker() { - return this._worker; + get department() { + return this._department; } - set worker(value) { - this._worker = value; - this.$.worker = null; + set department(value) { + this._department = value; + this.$.department = null; if (!value) return; - const query = `Workers/${value.id}`; + const query = `Departments/${value.id}`; const filter = { + fields: ['chatName', 'notificationEmail'], include: [ - { - relation: 'user', - scope: { - fields: ['name', 'roleFk'], - include: [{ - relation: 'role', - scope: { - fields: ['name'] - } - }, - { - relation: 'emailUser', - scope: { - fields: ['email'] - } - }] - } - }, { relation: 'client', - scope: {fields: ['fi', 'phone']} + scope: {fields: ['name']} }, { - relation: 'boss', - scope: {fields: ['id', 'nickname']} - }, - { - relation: 'sip', - scope: {fields: ['extension']} - }, - { - relation: 'department', - scope: { - include: { - relation: 'department' - } - } + relation: 'worker', + scope: {fields: ['name']} } + ] }; @@ -65,7 +37,7 @@ class Controller extends Summary { } } -ngModule.vnComponent('vnWorkerSummary', { +ngModule.vnComponent('vnDepartmentSummary', { template: require('./index.html'), controller: Controller, bindings: { diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 6817d0cef..34a8a14e3 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -7,7 +7,7 @@ "menus": { "main": [ {"state": "worker.index", "icon": "icon-worker"}, - {"state": "worker.department", "icon": "work"} + {"state": "worker.department.index", "icon": "work"} ], "card": [ {"state": "worker.card.basicData", "icon": "settings"}, @@ -118,11 +118,31 @@ "worker": "$ctrl.worker" } }, { - "url" : "/department/department", + "url": "/department", "state": "worker.department", - "component": "vn-worker-department", - "description": "Departments", + "abstract": true, + "description":"Departments", + "component": "ui-view" + }, { + "url": "/:id", + "state": "worker.department.card", + "component": "vn-worker-department-card", + "abstract": true, + "description": "Detail" + }, { + "url" : "/index", + "state": "worker.department.index", + "component": "vn-worker-department-index", + "description": "Department", "acl": ["hr"] + }, { + "url" : "/summary", + "state": "worker.department.card.summary", + "component": "vn-worker-department-summary", + "description": "Summary", + "params": { + "department": "$ctrl.department" + } }, { "url": "/dms", "state": "worker.card.dms", From 071849065a41af6d26a25111009ed31b4acdc8e1 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 15 May 2023 13:55:35 +0200 Subject: [PATCH 03/80] refs #5334 fix main --- modules/worker/front/department/index.js | 8 ++++++++ modules/worker/front/department/main/index.js | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 modules/worker/front/department/index.js diff --git a/modules/worker/front/department/index.js b/modules/worker/front/department/index.js new file mode 100644 index 000000000..5dcbe4097 --- /dev/null +++ b/modules/worker/front/department/index.js @@ -0,0 +1,8 @@ +import './main'; +import './index/'; +import './summary'; +import './card'; +import './descriptor'; +import './create'; +import './basic-data'; +import './search-panel'; diff --git a/modules/worker/front/department/main/index.js b/modules/worker/front/department/main/index.js index 75110f749..246f8fe49 100644 --- a/modules/worker/front/department/main/index.js +++ b/modules/worker/front/department/main/index.js @@ -1,9 +1,9 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class Worker extends ModuleMain {} +export default class Department extends ModuleMain {} ngModule.vnComponent('vnWorkerDepartment', { - controller: Worker, + controller: Department, template: require('./index.html') }); From 443821b5c20a0c2b51879d62ec1230144bb9969f Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 15 May 2023 13:59:54 +0200 Subject: [PATCH 04/80] refs #5334 ?q --- modules/worker/front/routes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 34a8a14e3..50245b571 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -118,7 +118,7 @@ "worker": "$ctrl.worker" } }, { - "url": "/department", + "url": "/department?q", "state": "worker.department", "abstract": true, "description":"Departments", From fd4d04756a218a8a2f3bfe7e93c6b9b7592ea219 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 16 May 2023 08:54:54 +0200 Subject: [PATCH 05/80] refs #5334 routes index fix --- front/salix/components/left-menu/left-menu.js | 1 - modules/worker/front/department/basic-data/index.js | 2 +- modules/worker/front/department/card/index.js | 2 +- modules/worker/front/department/descriptor/index.js | 2 +- modules/worker/front/department/index.js | 4 ++-- modules/worker/front/department/main/index.js | 2 +- modules/worker/front/department/summary/index.js | 2 +- modules/worker/front/index.js | 2 +- modules/worker/front/routes.json | 6 ------ 9 files changed, 8 insertions(+), 15 deletions(-) diff --git a/front/salix/components/left-menu/left-menu.js b/front/salix/components/left-menu/left-menu.js index 6bec61775..a0392ccce 100644 --- a/front/salix/components/left-menu/left-menu.js +++ b/front/salix/components/left-menu/left-menu.js @@ -45,7 +45,6 @@ export default class LeftMenu { if (acl && !this.aclService.hasAny(acl)) continue; } - console.log(state, item); let myItem = { icon: item.icon, description: item.description || state.description, diff --git a/modules/worker/front/department/basic-data/index.js b/modules/worker/front/department/basic-data/index.js index ea75d7b97..1f2dd848c 100644 --- a/modules/worker/front/department/basic-data/index.js +++ b/modules/worker/front/department/basic-data/index.js @@ -1,4 +1,4 @@ -import ngModule from '../module'; +import ngModule from '../../module'; import Section from 'salix/components/section'; class Controller extends Section { diff --git a/modules/worker/front/department/card/index.js b/modules/worker/front/department/card/index.js index 288c1a8c3..c7bf32569 100644 --- a/modules/worker/front/department/card/index.js +++ b/modules/worker/front/department/card/index.js @@ -1,4 +1,4 @@ -import ngModule from '../module'; +import ngModule from '../../module'; import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js index af57643b7..12ec396a6 100644 --- a/modules/worker/front/department/descriptor/index.js +++ b/modules/worker/front/department/descriptor/index.js @@ -1,4 +1,4 @@ -import ngModule from '../module'; +import ngModule from '../../module'; import Descriptor from 'salix/components/descriptor'; class Controller extends Descriptor { diff --git a/modules/worker/front/department/index.js b/modules/worker/front/department/index.js index 5dcbe4097..3e4db6106 100644 --- a/modules/worker/front/department/index.js +++ b/modules/worker/front/department/index.js @@ -3,6 +3,6 @@ import './index/'; import './summary'; import './card'; import './descriptor'; -import './create'; +// import './create'; import './basic-data'; -import './search-panel'; +// import './search-panel'; diff --git a/modules/worker/front/department/main/index.js b/modules/worker/front/department/main/index.js index 246f8fe49..3fda47246 100644 --- a/modules/worker/front/department/main/index.js +++ b/modules/worker/front/department/main/index.js @@ -1,4 +1,4 @@ -import ngModule from '../module'; +import ngModule from '../../module'; import ModuleMain from 'salix/components/module-main'; export default class Department extends ModuleMain {} diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js index ede559d18..cef13c479 100644 --- a/modules/worker/front/department/summary/index.js +++ b/modules/worker/front/department/summary/index.js @@ -1,4 +1,4 @@ -import ngModule from '../module'; +import ngModule from '../../module'; import Summary from 'salix/components/summary'; class Controller extends Summary { diff --git a/modules/worker/front/index.js b/modules/worker/front/index.js index 605ec9dde..8fad2c0df 100644 --- a/modules/worker/front/index.js +++ b/modules/worker/front/index.js @@ -11,7 +11,7 @@ import './search-panel'; import './basic-data'; import './pbx'; import './pda'; -import './department/index'; +import './department'; import './calendar'; import './time-control'; import './log'; diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 50245b571..3f4f1977d 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -129,12 +129,6 @@ "component": "vn-worker-department-card", "abstract": true, "description": "Detail" - }, { - "url" : "/index", - "state": "worker.department.index", - "component": "vn-worker-department-index", - "description": "Department", - "acl": ["hr"] }, { "url" : "/summary", "state": "worker.department.card.summary", From 612d0a2dfbd25173a1f471f4735c49f1abd1b063 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 16 May 2023 09:52:48 +0200 Subject: [PATCH 06/80] refs #5334 fix index --- modules/worker/front/routes.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 3f4f1977d..50245b571 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -129,6 +129,12 @@ "component": "vn-worker-department-card", "abstract": true, "description": "Detail" + }, { + "url" : "/index", + "state": "worker.department.index", + "component": "vn-worker-department-index", + "description": "Department", + "acl": ["hr"] }, { "url" : "/summary", "state": "worker.department.card.summary", From 3dcdbe022361f09e234ed534f04fabe034194f77 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 16 May 2023 11:41:42 +0200 Subject: [PATCH 07/80] refs #5334 summary basic data --- .../front/department/basic-data/index.html | 88 ++++++++----------- .../front/department/basic-data/locale/es.yml | 22 +++-- .../worker/front/department/index/index.html | 2 +- .../front/department/summary/index.html | 36 ++++++-- .../front/department/summary/locale/es.yml | 15 +++- 5 files changed, 89 insertions(+), 74 deletions(-) diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html index d89d88f2e..0b381b2f1 100644 --- a/modules/worker/front/department/basic-data/index.html +++ b/modules/worker/front/department/basic-data/index.html @@ -1,7 +1,7 @@ - + @@ -12,78 +12,62 @@ - - - - - - - - - - - - + label="Boss department" + ng-model="$ctrl.department.workerFk"> + + - - + + + + + + + + + + diff --git a/modules/worker/front/department/basic-data/locale/es.yml b/modules/worker/front/department/basic-data/locale/es.yml index edf08de90..ea80cfed1 100644 --- a/modules/worker/front/department/basic-data/locale/es.yml +++ b/modules/worker/front/department/basic-data/locale/es.yml @@ -1,9 +1,13 @@ -Marital status: Estado civil -Origin country: País origen -Education level: Nivel educación -SSN: NSS -Married: Casado/a -Single: Soltero/a -Business phone: Teléfono de empresa -Mobile extension: Extensión móvil -Locker: Taquilla +Name: Nombre +Code: Código +Chat: Chat +Email: Email +Boss department: Jefe del departamento +Self-consumption customer: Cliente autoconsumo +Telecommutes: Teletrabaja +Notificate errors: Notificar errores +Is on production: Pertenece a producción +Fill in days without physical check-ins: Rellenar fichadas +Send check-ins by email: Enviar fichadas por email +Save: Guardar +Undo changes: Deshacer cambios diff --git a/modules/worker/front/department/index/index.html b/modules/worker/front/department/index/index.html index 894583213..ad802542c 100644 --- a/modules/worker/front/department/index/index.html +++ b/modules/worker/front/department/index/index.html @@ -13,7 +13,7 @@ on-drop="$ctrl.onDrop($dropped, $dragged)" on-drag-start="$ctrl.onDragStart(item)" on-drag-end="$ctrl.onDragEnd(item)" - ng-click="department.card.summary($item)"> + ng-click="worker.department.card.summary($item)"> {{::item.name}} diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html index 3cffe2f71..3ed5a310e 100644 --- a/modules/worker/front/department/summary/index.html +++ b/modules/worker/front/department/summary/index.html @@ -2,7 +2,7 @@
@@ -21,17 +21,17 @@ ng-show="!$ctrl.isHr"> Basic data
- - - + label="Boss department"> @@ -41,11 +41,31 @@ - - + + + + + + + + + + + Date: Tue, 16 May 2023 12:12:25 +0200 Subject: [PATCH 08/80] refs #5334 fix summary route --- .../front/department/descriptor/index.html | 20 ++++--------------- .../worker/front/department/main/index.html | 4 +++- modules/worker/front/routes.json | 13 +++--------- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html index 564c2d4da..05230bd09 100644 --- a/modules/worker/front/department/descriptor/index.html +++ b/modules/worker/front/department/descriptor/index.html @@ -1,19 +1,7 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/modules/worker/front/department/main/index.html b/modules/worker/front/department/main/index.html index 3ab993e83..2aebd0f4d 100644 --- a/modules/worker/front/department/main/index.html +++ b/modules/worker/front/department/main/index.html @@ -15,4 +15,6 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 50245b571..89cafc6e2 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -7,7 +7,7 @@ "menus": { "main": [ {"state": "worker.index", "icon": "icon-worker"}, - {"state": "worker.department.index", "icon": "work"} + {"state": "worker.department", "icon": "work"} ], "card": [ {"state": "worker.card.basicData", "icon": "settings"}, @@ -120,22 +120,15 @@ }, { "url": "/department?q", "state": "worker.department", - "abstract": true, "description":"Departments", - "component": "ui-view" + "component": "vn-worker-department" }, { "url": "/:id", "state": "worker.department.card", "component": "vn-worker-department-card", "abstract": true, "description": "Detail" - }, { - "url" : "/index", - "state": "worker.department.index", - "component": "vn-worker-department-index", - "description": "Department", - "acl": ["hr"] - }, { + }, { "url" : "/summary", "state": "worker.department.card.summary", "component": "vn-worker-department-summary", From 9f9963af5679edcae918134b20031dad4e54035c Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 16 May 2023 13:10:26 +0200 Subject: [PATCH 09/80] refs #5334 descriptor --- .../front/department/descriptor/index.html | 53 ++------ .../front/department/descriptor/index.js | 125 ++++++------------ 2 files changed, 53 insertions(+), 125 deletions(-) diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html index 05230bd09..0fa80da50 100644 --- a/modules/worker/front/department/descriptor/index.html +++ b/modules/worker/front/department/descriptor/index.html @@ -7,63 +7,30 @@ ng-click="$ctrl.handleExcluded()" translate ng-if="!$ctrl.excluded"> - Click to exclude the user from getting disabled - - - Click to allow the user to be disabled + Delete +

{{worker.department.name}}

+

{{worker.department.id}}

+ label="Chat" + value="{{$ctrl.worker.department.chatName}}"> + value="{{$ctrl.worker.department.emailNotification}}"> + label="Self-consumption customer" + value="{{$ctrl.worker.department.clientFK}}"> - - + label="Boss department" + value="{{$ctrl.worker.department.workerFk}}">
-
- - -
-
diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js index 12ec396a6..937f4c351 100644 --- a/modules/worker/front/department/descriptor/index.js +++ b/modules/worker/front/department/descriptor/index.js @@ -7,90 +7,51 @@ class Controller extends Descriptor { this.$rootScope = $rootScope; } - // get worker() { - // return this.entity; - // } + get department() { + return this.entity; + } - // set worker(value) { - // this.entity = value; + set department(value) { + this.entity = value; + } + loadData() { + const filter = { + include: [ + { + relation: 'user', + scope: { + fields: ['name'], + include: { + relation: 'emailUser', + scope: { + fields: ['email'] + } + } + } + }, { + relation: 'client', + scope: { + fields: ['fi'] + } + }, { + relation: 'sip', + scope: { + fields: ['extension'] + } + }, { + relation: 'department', + scope: { + include: { + relation: 'department' + } + } + } + ] + }; - // if (value) - // this.getIsExcluded(); - // } - - // get excluded() { - // return this.entity.excluded; - // } - - // set excluded(value) { - // this.entity.excluded = value; - // } - - // getIsExcluded() { - // this.$http.get(`workerDisableExcludeds/${this.entity.id}/exists`).then(data => { - // this.excluded = data.data.exists; - // }); - // } - - // handleExcluded() { - // if (this.excluded) { - // this.$http.delete(`workerDisableExcludeds/${this.entity.id}`); - // this.excluded = false; - // } else { - // this.$http.post(`workerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date}); - // this.excluded = true; - // } - // } - - // loadData() { - // const filter = { - // include: [ - // { - // relation: 'user', - // scope: { - // fields: ['name'], - // include: { - // relation: 'emailUser', - // scope: { - // fields: ['email'] - // } - // } - // } - // }, { - // relation: 'client', - // scope: { - // fields: ['fi'] - // } - // }, { - // relation: 'sip', - // scope: { - // fields: ['extension'] - // } - // }, { - // relation: 'department', - // scope: { - // include: { - // relation: 'department' - // } - // } - // } - // ] - // }; - - // return this.getData(`Workers/${this.id}`, {filter}) - // .then(res => this.entity = res.data); - // } - - // onUploadResponse() { - // const timestamp = Date.vnNew().getTime(); - // const src = this.$rootScope.imagePath('user', '520x520', this.worker.id); - // const zoomSrc = this.$rootScope.imagePath('user', '1600x1600', this.worker.id); - // const newSrc = `${src}&t=${timestamp}`; - // const newZoomSrc = `${zoomSrc}&t=${timestamp}`; - - // this.$.photo.setAttribute('src', newSrc); - // this.$.photo.setAttribute('zoom-image', newZoomSrc); - // } + return this.getData(`Workers/${this.id}`, {filter}) + .then(res => this.entity = res.data); + } } Controller.$inject = ['$element', '$scope', '$rootScope']; From 5c9ee21cfce621f02cb01a4c84bc3cf2a9e2d236 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 16 May 2023 14:00:05 +0200 Subject: [PATCH 10/80] refs #5334 department.card --- modules/worker/front/department/card/index.html | 2 +- modules/worker/front/routes.json | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/worker/front/department/card/index.html b/modules/worker/front/department/card/index.html index cc1ad59e4..b9ae1a87b 100644 --- a/modules/worker/front/department/card/index.html +++ b/modules/worker/front/department/card/index.html @@ -1,5 +1,5 @@ - + diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 89cafc6e2..4314a6401 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -24,6 +24,8 @@ "description": "Wikipedia" }, {"state": "worker.card.workerLog", "icon": "history"} + ], "department": [ + {"state": "worker.deparment.card.basicData", "icon": "settings"} ] }, "keybindings": [ @@ -136,6 +138,14 @@ "params": { "department": "$ctrl.department" } + }, { + "url": "/basic-data", + "state": "worker.deparment.card.basicData", + "component": "vn-worker-department-basic-data", + "description": "Basic data", + "params": { + "department": "$ctrl.department" + } }, { "url": "/dms", "state": "worker.card.dms", From f63dd0f9a383f10a838e5cd31badf6f4127bf014 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 17 May 2023 09:05:28 +0200 Subject: [PATCH 11/80] refs #5334 datos --- modules/worker/front/department/card/index.html | 2 +- modules/worker/front/department/card/index.js | 3 ++- modules/worker/front/routes.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/worker/front/department/card/index.html b/modules/worker/front/department/card/index.html index b9ae1a87b..032939600 100644 --- a/modules/worker/front/department/card/index.html +++ b/modules/worker/front/department/card/index.html @@ -1,5 +1,5 @@ - + diff --git a/modules/worker/front/department/card/index.js b/modules/worker/front/department/card/index.js index c7bf32569..9b1ccf08d 100644 --- a/modules/worker/front/department/card/index.js +++ b/modules/worker/front/department/card/index.js @@ -4,7 +4,8 @@ import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { reload() { const filter = { - fields: ['chatName', 'notificationEmail'], + fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', + 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'], include: [ { relation: 'client', diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 4314a6401..a24cf9722 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -25,7 +25,7 @@ }, {"state": "worker.card.workerLog", "icon": "history"} ], "department": [ - {"state": "worker.deparment.card.basicData", "icon": "settings"} + {"state": "worker.department.card.basicData", "icon": "settings"} ] }, "keybindings": [ From adafd7444b3363ea752a6808fcae843a47fcca51 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 17 May 2023 10:04:44 +0200 Subject: [PATCH 12/80] refs #5334 worker-department --- modules/worker/front/department/card/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/front/department/card/index.html b/modules/worker/front/department/card/index.html index 032939600..b9ae1a87b 100644 --- a/modules/worker/front/department/card/index.html +++ b/modules/worker/front/department/card/index.html @@ -1,5 +1,5 @@ - + From 10e085ca1b1952651814f93b0b68641891372b6b Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 26 May 2023 11:43:51 +0200 Subject: [PATCH 13/80] refs #5334 link department --- modules/worker/front/department/index/index.html | 9 ++++++--- modules/worker/front/department/summary/index.js | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/worker/front/department/index/index.html b/modules/worker/front/department/index/index.html index ad802542c..259f4b8f0 100644 --- a/modules/worker/front/department/index/index.html +++ b/modules/worker/front/department/index/index.html @@ -12,9 +12,12 @@ sort-func="$ctrl.onSort($a, $b)" on-drop="$ctrl.onDrop($dropped, $dragged)" on-drag-start="$ctrl.onDragStart(item)" - on-drag-end="$ctrl.onDragEnd(item)" - ng-click="worker.department.card.summary($item)"> - {{::item.name}} + on-drag-end="$ctrl.onDragEnd(item)"> + + {{::item.name}} + diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js index cef13c479..51d5aa969 100644 --- a/modules/worker/front/department/summary/index.js +++ b/modules/worker/front/department/summary/index.js @@ -37,7 +37,7 @@ class Controller extends Summary { } } -ngModule.vnComponent('vnDepartmentSummary', { +ngModule.vnComponent('vnWorkerDepartmentSummary', { template: require('./index.html'), controller: Controller, bindings: { From 2b06c628766ecb95aab894857636fb6b3a0e1c59 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 26 May 2023 12:21:15 +0200 Subject: [PATCH 14/80] refs #5334 left-menu --- front/salix/components/left-menu/left-menu.js | 3 +++ modules/worker/front/department/basic-data/index.js | 5 +---- modules/worker/front/department/main/index.html | 5 +---- modules/worker/front/routes.json | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/front/salix/components/left-menu/left-menu.js b/front/salix/components/left-menu/left-menu.js index a0392ccce..4a9bcc8e3 100644 --- a/front/salix/components/left-menu/left-menu.js +++ b/front/salix/components/left-menu/left-menu.js @@ -45,6 +45,9 @@ export default class LeftMenu { if (acl && !this.aclService.hasAny(acl)) continue; } + console.log('MyItem:', item); + console.log('MyState:', state); + console.log(item.description, state.description); let myItem = { icon: item.icon, description: item.description || state.description, diff --git a/modules/worker/front/department/basic-data/index.js b/modules/worker/front/department/basic-data/index.js index 1f2dd848c..d9b60c683 100644 --- a/modules/worker/front/department/basic-data/index.js +++ b/modules/worker/front/department/basic-data/index.js @@ -15,13 +15,10 @@ class Controller extends Section { } } -ngModule.vnComponent('vnWorkerBasicData', { +ngModule.vnComponent('vnWorkerDepartmentBasicData', { template: require('./index.html'), controller: Controller, bindings: { worker: '<' - }, - require: { - card: '^vnWorkerCard' } }); diff --git a/modules/worker/front/department/main/index.html b/modules/worker/front/department/main/index.html index 2aebd0f4d..ee260b516 100644 --- a/modules/worker/front/department/main/index.html +++ b/modules/worker/front/department/main/index.html @@ -12,9 +12,6 @@ model="model"> - - - - \ No newline at end of file + diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index a24cf9722..41d09ba4f 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -122,8 +122,8 @@ }, { "url": "/department?q", "state": "worker.department", - "description":"Departments", - "component": "vn-worker-department" + "component": "vn-worker-department", + "description":"Departments" }, { "url": "/:id", "state": "worker.department.card", From 07898043521091c33445e35b96064bbdb4985aa2 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 26 May 2023 12:58:03 +0200 Subject: [PATCH 15/80] refs #5334 fix basic-data --- front/salix/components/left-menu/left-menu.js | 4 +--- .../front/department/descriptor/index.html | 18 +++++++++--------- modules/worker/front/department/index.js | 2 +- .../worker/front/department/main/index.html | 3 ++- modules/worker/front/routes.json | 16 ++++++++++------ 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/front/salix/components/left-menu/left-menu.js b/front/salix/components/left-menu/left-menu.js index 4a9bcc8e3..da545b291 100644 --- a/front/salix/components/left-menu/left-menu.js +++ b/front/salix/components/left-menu/left-menu.js @@ -45,9 +45,7 @@ export default class LeftMenu { if (acl && !this.aclService.hasAny(acl)) continue; } - console.log('MyItem:', item); - console.log('MyState:', state); - console.log(item.description, state.description); + let myItem = { icon: item.icon, description: item.description || state.description, diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html index 0fa80da50..28433e612 100644 --- a/modules/worker/front/department/descriptor/index.html +++ b/modules/worker/front/department/descriptor/index.html @@ -1,7 +1,7 @@ + base-state="worker.department"> {{worker.department.id}}

@@ -39,7 +39,7 @@ - + Date: Fri, 26 May 2023 13:25:49 +0200 Subject: [PATCH 17/80] refs #5334 fix checks basic-data --- modules/worker/front/department/basic-data/index.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html index 0b381b2f1..2406080bf 100644 --- a/modules/worker/front/department/basic-data/index.html +++ b/modules/worker/front/department/basic-data/index.html @@ -48,6 +48,7 @@ ng-model="$ctrl.department.clientFk"> + @@ -60,14 +61,19 @@ label="Is on production" ng-model="$ctrl.department.isProduction"> + + + + + From ceaaece0071108b1096d16eb190be039d781e2b8 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 26 May 2023 14:08:37 +0200 Subject: [PATCH 18/80] refs #5334 label-value --- .../front/department/basic-data/index.js | 4 --- .../front/department/descriptor/index.js | 32 +++++-------------- .../front/department/summary/index.html | 18 ++++------- .../worker/front/department/summary/index.js | 7 ++-- 4 files changed, 20 insertions(+), 41 deletions(-) diff --git a/modules/worker/front/department/basic-data/index.js b/modules/worker/front/department/basic-data/index.js index d9b60c683..d5f988141 100644 --- a/modules/worker/front/department/basic-data/index.js +++ b/modules/worker/front/department/basic-data/index.js @@ -4,10 +4,6 @@ import Section from 'salix/components/section'; class Controller extends Section { constructor($element, $) { super($element, $); - this.maritalStatus = [ - {code: 'M', name: this.$t('Married')}, - {code: 'S', name: this.$t('Single')} - ]; } onSubmit() { return this.$.watcher.submit() diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js index 937f4c351..eb6489826 100644 --- a/modules/worker/front/department/descriptor/index.js +++ b/modules/worker/front/department/descriptor/index.js @@ -16,35 +16,19 @@ class Controller extends Descriptor { } loadData() { const filter = { + fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', + 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'], include: [ { - relation: 'user', - scope: { - fields: ['name'], - include: { - relation: 'emailUser', - scope: { - fields: ['email'] - } - } - } - }, { relation: 'client', - scope: { - fields: ['fi'] - } - }, { - relation: 'sip', - scope: { - fields: ['extension'] - } + scope: {fields: ['name']} + }, + { + relation: 'worker', + scope: {fields: ['name']} }, { relation: 'department', - scope: { - include: { - relation: 'department' - } - } + scope: {fields: ['name']} } ] }; diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html index 6b7ded649..979f01dc0 100644 --- a/modules/worker/front/department/summary/index.html +++ b/modules/worker/front/department/summary/index.html @@ -2,9 +2,9 @@
- + {{department.name}}
@@ -12,7 +12,7 @@

+ ui-sref="department.card.basicData({id:$ctrl.worker.department.id})"> Basic data

@@ -24,21 +24,17 @@ - - - {{::worker.boss.nickname}} - + label="Boss department" + value="{{$ctrl.worker.department.workerFk}}"> - Date: Fri, 26 May 2023 14:23:34 +0200 Subject: [PATCH 19/80] refs #5334 fix hasToSendMail --- modules/worker/front/department/card/index.js | 2 +- modules/worker/front/department/descriptor/index.js | 2 +- modules/worker/front/department/summary/index.js | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/worker/front/department/card/index.js b/modules/worker/front/department/card/index.js index 9b1ccf08d..72b0876a0 100644 --- a/modules/worker/front/department/card/index.js +++ b/modules/worker/front/department/card/index.js @@ -5,7 +5,7 @@ class Controller extends ModuleCard { reload() { const filter = { fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', - 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'], + 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'], include: [ { relation: 'client', diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js index eb6489826..31a37e338 100644 --- a/modules/worker/front/department/descriptor/index.js +++ b/modules/worker/front/department/descriptor/index.js @@ -17,7 +17,7 @@ class Controller extends Descriptor { loadData() { const filter = { fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', - 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'], + 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'], include: [ { relation: 'client', diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js index f40214be5..3c78e329f 100644 --- a/modules/worker/front/department/summary/index.js +++ b/modules/worker/front/department/summary/index.js @@ -14,7 +14,7 @@ class Controller extends Summary { const query = `Departments/${value.id}`; const filter = { fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', - 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'], + 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'], include: [ { relation: 'client', @@ -30,9 +30,10 @@ class Controller extends Summary { ] }; - this.$http.get(query, {params: {filter}}).then(res => { - this.$.worker = res.data; - }); + this.$http.get(query, {params: {filter}}) + .then(res => { + this.$.department = res.data; + }); } get isHr() { From 2a78a912eb9d1cf3d1a95761c8155043371976c2 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 26 May 2023 14:35:12 +0200 Subject: [PATCH 20/80] refs #5334 worker.department --- modules/worker/front/department/summary/index.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html index 979f01dc0..850b1e9f4 100644 --- a/modules/worker/front/department/summary/index.html +++ b/modules/worker/front/department/summary/index.html @@ -22,23 +22,23 @@ Basic data + value="{{worker.department.department.name}}"> + value="{{worker.department.department.code}}"> + value="{{worker.department.department.chat}}"> + value="{{$ctrl.worker.department.department.workerFk}}"> + value="{{worker.department.department.notificationEmail}}"> + value="{{worker.department.department.workerFk}}">
From f4e877dadad25ce9e07a6da01de34b7c62495032 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 29 May 2023 14:46:39 +0200 Subject: [PATCH 21/80] refs #5334 refactor summary --- .../front/department/basic-data/index.js | 12 +----- .../worker/front/department/summary/index.js | 40 ++++++------------- 2 files changed, 15 insertions(+), 37 deletions(-) diff --git a/modules/worker/front/department/basic-data/index.js b/modules/worker/front/department/basic-data/index.js index d5f988141..31f50ee85 100644 --- a/modules/worker/front/department/basic-data/index.js +++ b/modules/worker/front/department/basic-data/index.js @@ -1,20 +1,12 @@ import ngModule from '../../module'; import Section from 'salix/components/section'; -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - onSubmit() { - return this.$.watcher.submit() - .then(() => this.card.reload()); - } -} +export default class Controller extends Section {} ngModule.vnComponent('vnWorkerDepartmentBasicData', { template: require('./index.html'), controller: Controller, bindings: { - worker: '<' + department: '<' } }); diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js index 3c78e329f..4897c27a2 100644 --- a/modules/worker/front/department/summary/index.js +++ b/modules/worker/front/department/summary/index.js @@ -1,39 +1,25 @@ import ngModule from '../../module'; -import Summary from 'salix/components/summary'; - -class Controller extends Summary { - get department() { - return this._department; - } +import Component from 'core/lib/component'; +class Controller extends Component { set department(value) { this._department = value; - this.$.department = null; + this.$.summary = null; if (!value) return; - const query = `Departments/${value.id}`; const filter = { - fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', - 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'], include: [ - { - relation: 'client', - scope: {fields: ['name']} - }, - { - relation: 'worker', - scope: {fields: ['name']} - }, { - relation: 'department', - scope: {fields: ['name']} - } + {relation: 'client'}, + {relation: 'worker'}, + {relation: 'department'} ] }; - this.$http.get(query, {params: {filter}}) - .then(res => { - this.$.department = res.data; - }); + this.$http.get(`Departments/${value.id}`, {filter}) + .then(res => this.$.summary = res.data); + } + get department() { + return this._department; } get isHr() { @@ -41,10 +27,10 @@ class Controller extends Summary { } } -ngModule.vnComponent('vnWorkerDepartmentSummary', { +ngModule.component('vnWorkerDepartmentSummary', { template: require('./index.html'), controller: Controller, bindings: { - worker: '<' + department: '<' } }); From 2d6f0bb2ce10e5847c42145a93f5846e9395a011 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 29 May 2023 15:27:50 +0200 Subject: [PATCH 22/80] refs #5334 front fix --- modules/worker/back/models/department.json | 3 +- .../front/department/summary/index.html | 33 ++++++++----------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/modules/worker/back/models/department.json b/modules/worker/back/models/department.json index 7d8d61d73..855124620 100644 --- a/modules/worker/back/models/department.json +++ b/modules/worker/back/models/department.json @@ -9,7 +9,8 @@ "properties": { "id": { "id": true, - "type": "number" + "type": "number", + "description": "Identifier" }, "code": { "type": "string" diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html index 850b1e9f4..6950ea7c1 100644 --- a/modules/worker/front/department/summary/index.html +++ b/modules/worker/front/department/summary/index.html @@ -1,18 +1,11 @@ -
- - - - {{department.name}} + {{summary.name}}

+ ui-sref="department.card.basicData({id:$ctrl.summary.id})"> Basic data

@@ -22,45 +15,45 @@ Basic data + value="{{summary.name}}"> + value="{{summary.code}}"> + value="{{summary.chat}}"> + value="{{$summary.workerFk}}"> + value="{{summary.notificationEmail}}"> + value="{{summary.workerFk}}">
+ ng-model="$ctrl.summary.isTeleworking"> + ng-model="$ctrl.summary.hasToMistake"> + ng-model="$ctrl.summary.isProduction"> + ng-model="$ctrl.summary.hasToRefill"> + ng-model="$ctrl.summary.hasToSendMail">
From d9a64211de6f1f46ebdbe5f63b6ba453ddf60a32 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 May 2023 09:16:02 +0200 Subject: [PATCH 23/80] refs #5334 fix descriptor, basic-data, summary --- modules/worker/back/models/department.json | 5 ++++- .../front/department/basic-data/index.html | 3 +-- .../front/department/descriptor/index.html | 12 ++++++------ .../front/department/descriptor/index.js | 7 ++----- .../worker/front/department/summary/index.html | 18 ++++++++++++------ .../worker/front/department/summary/index.js | 3 +-- modules/worker/front/routes.json | 5 ++--- 7 files changed, 28 insertions(+), 25 deletions(-) diff --git a/modules/worker/back/models/department.json b/modules/worker/back/models/department.json index 855124620..37ec3a3a1 100644 --- a/modules/worker/back/models/department.json +++ b/modules/worker/back/models/department.json @@ -8,8 +8,8 @@ }, "properties": { "id": { - "id": true, "type": "number", + "id": true, "description": "Identifier" }, "code": { @@ -38,6 +38,9 @@ }, "hasToMistake": { "type": "number" + }, + "isTeleworking": { + "type": "boolean" } }, "relations": { diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html index 2406080bf..9b82f4ec6 100644 --- a/modules/worker/front/department/basic-data/index.html +++ b/modules/worker/front/department/basic-data/index.html @@ -1,9 +1,8 @@ - + url="Departments">
diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html index 28433e612..8ac078968 100644 --- a/modules/worker/front/department/descriptor/index.html +++ b/modules/worker/front/department/descriptor/index.html @@ -11,24 +11,24 @@ -

{{worker.department.name}}

-

{{worker.department.id}}

+

{{department}}

+

{{department.id}}

+ value="{{$ctrl.department.chatName}}"> + value="{{$ctrl.department.emailNotification}}"> + value="{{$ctrl.department.clientFK}}"> + value="{{$ctrl.department.workerFk}}">
diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js index 31a37e338..3a7c2b5fe 100644 --- a/modules/worker/front/department/descriptor/index.js +++ b/modules/worker/front/department/descriptor/index.js @@ -26,14 +26,11 @@ class Controller extends Descriptor { { relation: 'worker', scope: {fields: ['name']} - }, { - relation: 'department', - scope: {fields: ['name']} } ] }; - return this.getData(`Workers/${this.id}`, {filter}) + return this.getData(`Departments/${this.id}`, {filter}) .then(res => this.entity = res.data); } } @@ -44,6 +41,6 @@ ngModule.vnComponent('vnWorkerDepartmentDescriptor', { template: require('./index.html'), controller: Controller, bindings: { - worker: '<' + department: '<' } }); diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html index 6950ea7c1..2750cd28e 100644 --- a/modules/worker/front/department/summary/index.html +++ b/modules/worker/front/department/summary/index.html @@ -1,4 +1,5 @@ +
{{summary.name}}
@@ -21,7 +22,7 @@ value="{{summary.code}}"> + value="{{summary.chatName}}"> + ng-model="summary.isTeleworking" + disabled="true"> + ng-model="summary.hasToMistake" + disabled="true"> + ng-model="summary.isProduction" + disabled="true"> + ng-model="summary.hasToRefill" + disabled="true"> + ng-model="summary.hasToSendMail" + disabled="true"> diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js index 4897c27a2..6fbffc852 100644 --- a/modules/worker/front/department/summary/index.js +++ b/modules/worker/front/department/summary/index.js @@ -10,8 +10,7 @@ class Controller extends Component { const filter = { include: [ {relation: 'client'}, - {relation: 'worker'}, - {relation: 'department'} + {relation: 'worker'} ] }; diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index ccba0551a..7ac692391 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -146,9 +146,8 @@ "component": "vn-worker-department-basic-data", "description": "Basic data", "params": { - "item-type": "$ctrl.itemType" - }, - "acl": ["buyer"] + "department": "$ctrl.department" + } }, { "url": "/dms", From 107d8d1edd808f2873ddadd502374ee9382d1fe3 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 May 2023 10:13:49 +0200 Subject: [PATCH 24/80] refs #5334 model y vista --- modules/worker/back/models/department.json | 9 +++++++++ modules/worker/front/department/basic-data/index.html | 2 +- modules/worker/front/department/summary/index.html | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/models/department.json b/modules/worker/back/models/department.json index 37ec3a3a1..edeba74f7 100644 --- a/modules/worker/back/models/department.json +++ b/modules/worker/back/models/department.json @@ -41,6 +41,15 @@ }, "isTeleworking": { "type": "boolean" + }, + "hasToRefill": { + "type": "boolean" + }, + "hasToSendMail": { + "type": "boolean" + }, + "isProduction": { + "type": "boolean" } }, "relations": { diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html index 9b82f4ec6..ef5760be2 100644 --- a/modules/worker/front/department/basic-data/index.html +++ b/modules/worker/front/department/basic-data/index.html @@ -4,7 +4,7 @@ form="form" url="Departments"> - + diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html index 2750cd28e..9bb517383 100644 --- a/modules/worker/front/department/summary/index.html +++ b/modules/worker/front/department/summary/index.html @@ -6,7 +6,7 @@

+ ui-sref="worker.department.card.basicData({id:summary.id})"> Basic data

From 2778858705602d729f28c7060bb36f031915afb3 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 May 2023 10:27:49 +0200 Subject: [PATCH 25/80] refs #5334 search-panel --- modules/worker/front/department/index.js | 2 +- .../front/department/search-panel/index.html | 22 +++++++++++++++++++ .../front/department/search-panel/index.js | 7 ++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 modules/worker/front/department/search-panel/index.html create mode 100644 modules/worker/front/department/search-panel/index.js diff --git a/modules/worker/front/department/index.js b/modules/worker/front/department/index.js index 2553e2865..9becdd5e5 100644 --- a/modules/worker/front/department/index.js +++ b/modules/worker/front/department/index.js @@ -5,4 +5,4 @@ import './card'; import './descriptor'; import './basic-data'; // import './create'; -// import './search-panel'; +import './search-panel'; diff --git a/modules/worker/front/department/search-panel/index.html b/modules/worker/front/department/search-panel/index.html new file mode 100644 index 000000000..4aa762900 --- /dev/null +++ b/modules/worker/front/department/search-panel/index.html @@ -0,0 +1,22 @@ +
+ + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/worker/front/department/search-panel/index.js b/modules/worker/front/department/search-panel/index.js new file mode 100644 index 000000000..95a6a55ca --- /dev/null +++ b/modules/worker/front/department/search-panel/index.js @@ -0,0 +1,7 @@ +import ngModule from '../../module'; +import SearchPanel from 'core/components/searchbar/search-panel'; + +ngModule.component('vnWorkerDepartmentSearchPanel', { + template: require('./index.html'), + controller: SearchPanel +}); From cf632040e731d3674281040cd0333b8f5331fca0 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 May 2023 11:48:39 +0200 Subject: [PATCH 26/80] refs #5334 workFk, clientFk --- modules/worker/front/department/summary/index.html | 4 ++-- modules/worker/front/department/summary/index.js | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html index 9bb517383..4cc8a4617 100644 --- a/modules/worker/front/department/summary/index.html +++ b/modules/worker/front/department/summary/index.html @@ -26,13 +26,13 @@
+ value="{{summary.worker.firstName}} {{summary.worker.lastName}}"> + value="{{summary.client.name}}"> diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js index 6fbffc852..25dca6341 100644 --- a/modules/worker/front/department/summary/index.js +++ b/modules/worker/front/department/summary/index.js @@ -8,9 +8,19 @@ class Controller extends Component { if (!value) return; const filter = { + fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', + 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'], include: [ - {relation: 'client'}, - {relation: 'worker'} + {relation: 'client', + scope: { + fields: ['id', 'name'] + }}, + { + relation: 'worker', + scope: { + fields: ['id', 'firstName', 'lastName'] + } + } ] }; From e26eedb51cdd0b88b056aff532e410150cda7da7 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 May 2023 11:54:14 +0200 Subject: [PATCH 27/80] refs #5334 descriptor wprkerFk clientFk --- modules/worker/front/department/card/index.js | 13 +++++----- .../front/department/descriptor/index.html | 4 +-- .../front/department/descriptor/index.js | 12 +++++---- .../front/department/descriptor/index.spec.js | 26 ------------------- 4 files changed, 16 insertions(+), 39 deletions(-) delete mode 100644 modules/worker/front/department/descriptor/index.spec.js diff --git a/modules/worker/front/department/card/index.js b/modules/worker/front/department/card/index.js index 72b0876a0..93a39dd44 100644 --- a/modules/worker/front/department/card/index.js +++ b/modules/worker/front/department/card/index.js @@ -7,15 +7,16 @@ class Controller extends ModuleCard { fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'], include: [ - { - relation: 'client', - scope: {fields: ['name']} - }, + {relation: 'client', + scope: { + fields: ['id', 'name'] + }}, { relation: 'worker', - scope: {fields: ['name']} + scope: { + fields: ['id', 'firstName', 'lastName'] + } } - ] }; diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html index 8ac078968..78aaf45b7 100644 --- a/modules/worker/front/department/descriptor/index.html +++ b/modules/worker/front/department/descriptor/index.html @@ -24,11 +24,11 @@ + value="{{$ctrl.department.client.name}}"> + value="{{$ctrl.department.worker.firstName}} {{$ctrl.department.worker.secondName}}"> diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js index 3a7c2b5fe..46764751c 100644 --- a/modules/worker/front/department/descriptor/index.js +++ b/modules/worker/front/department/descriptor/index.js @@ -19,13 +19,15 @@ class Controller extends Descriptor { fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'], include: [ - { - relation: 'client', - scope: {fields: ['name']} - }, + {relation: 'client', + scope: { + fields: ['id', 'name'] + }}, { relation: 'worker', - scope: {fields: ['name']} + scope: { + fields: ['id', 'firstName', 'lastName'] + } } ] }; diff --git a/modules/worker/front/department/descriptor/index.spec.js b/modules/worker/front/department/descriptor/index.spec.js deleted file mode 100644 index dfb800415..000000000 --- a/modules/worker/front/department/descriptor/index.spec.js +++ /dev/null @@ -1,26 +0,0 @@ -import './index.js'; - -describe('vnWorkerDescriptor', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnWorkerDescriptor', {$element: null}); - })); - - describe('loadData()', () => { - it(`should perform a get query to store the worker data into the controller`, () => { - const id = 1; - const response = 'foo'; - - $httpBackend.expectRoute('GET', `Workers/${id}`).respond(response); - controller.id = id; - $httpBackend.flush(); - - expect(controller.worker).toEqual(response); - }); - }); -}); From e7d25a6cf3fe5dfec42bcd1be76223bae6496e57 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 May 2023 12:08:45 +0200 Subject: [PATCH 28/80] refs #5334 filter --- .../worker/back/methods/department/filter.js | 90 +++++++++++++++++++ modules/worker/front/department/index.js | 1 - .../worker/front/department/summary/index.js | 2 +- 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 modules/worker/back/methods/department/filter.js diff --git a/modules/worker/back/methods/department/filter.js b/modules/worker/back/methods/department/filter.js new file mode 100644 index 000000000..4c6eb3e69 --- /dev/null +++ b/modules/worker/back/methods/department/filter.js @@ -0,0 +1,90 @@ + +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +const buildFilter = require('vn-loopback/util/filter').buildFilter; +const mergeFilters = require('vn-loopback/util/filter').mergeFilters; + +module.exports = Self => { + Self.remoteMethodCtx('filter', { + description: 'Find all instances of the model matched by filter from the data source.', + accessType: 'READ', + accepts: [ + { + arg: 'filter', + type: 'Object', + description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', + http: {source: 'query'} + }, + { + arg: 'search', + type: 'String', + description: `If it's and integer searchs by id, otherwise it searchs by name`, + http: {source: 'query'} + }, + { + arg: 'id', + type: 'Integer', + description: 'The department id', + http: {source: 'query'} + }, + { + arg: 'code', + type: 'String', + description: 'The department code', + http: {source: 'query'} + }, + { + arg: 'name', + type: 'String', + description: 'The department name', + http: {source: 'query'} + } + ], + returns: { + type: ['Object'], + root: true + }, + http: { + path: `/filter`, + verb: 'GET' + } + }); + + Self.filter = async(ctx, filter) => { + let conn = Self.dataSource.connector; + + let where = buildFilter(ctx.args, (param, value) => { + switch (param) { + case 'search': + return /^\d+$/.test(value) + ? {'d.id': value} + : {or: [ + {'d.code': {like: `%${value}%`}}, + {'d.name': {like: `%${value}%`}} + ]}; + case 'id': + return {'d.id': value}; + case 'code': + return {'d.code': value}; + case 'name': + return {'d.name': {like: `%${value}%`}}; + } + }); + + filter = mergeFilters(ctx.args.filter, {where}); + + let stmts = []; + let stmt; + + stmt = new ParameterizedSQL( + `SELECT id, code, name + FROM department;` + ); + + stmt.merge(conn.makeSuffix(filter)); + let itemsIndex = stmts.push(stmt) - 1; + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await conn.executeStmt(sql); + return itemsIndex === 0 ? result : result[itemsIndex]; + }; +}; diff --git a/modules/worker/front/department/index.js b/modules/worker/front/department/index.js index 9becdd5e5..71846f77c 100644 --- a/modules/worker/front/department/index.js +++ b/modules/worker/front/department/index.js @@ -4,5 +4,4 @@ import './summary'; import './card'; import './descriptor'; import './basic-data'; -// import './create'; import './search-panel'; diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js index 25dca6341..45e3f6d2d 100644 --- a/modules/worker/front/department/summary/index.js +++ b/modules/worker/front/department/summary/index.js @@ -9,7 +9,7 @@ class Controller extends Component { const filter = { fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', - 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'], + 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'], include: [ {relation: 'client', scope: { From 45085cccc87ecbc248220e65d64c3bcf15fcb075 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 May 2023 12:54:51 +0200 Subject: [PATCH 29/80] refs #5334 fix search-panel --- modules/worker/back/methods/department/filter.js | 2 +- modules/worker/back/models/department.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/worker/back/methods/department/filter.js b/modules/worker/back/methods/department/filter.js index 4c6eb3e69..232d30eed 100644 --- a/modules/worker/back/methods/department/filter.js +++ b/modules/worker/back/methods/department/filter.js @@ -77,7 +77,7 @@ module.exports = Self => { stmt = new ParameterizedSQL( `SELECT id, code, name - FROM department;` + FROM department d` ); stmt.merge(conn.makeSuffix(filter)); diff --git a/modules/worker/back/models/department.js b/modules/worker/back/models/department.js index 5a927fc64..061564a18 100644 --- a/modules/worker/back/models/department.js +++ b/modules/worker/back/models/department.js @@ -3,4 +3,5 @@ module.exports = Self => { require('../methods/department/createChild')(Self); require('../methods/department/removeChild')(Self); require('../methods/department/moveChild')(Self); + require('../methods/department/filter')(Self); }; From 8860c77147ed4a056885e125a3d941bfa407450e Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 May 2023 13:21:57 +0200 Subject: [PATCH 30/80] refs #5334 fix descriptor --- .../front/department/descriptor/index.html | 16 ++++++++++------ .../worker/front/department/descriptor/index.js | 13 +++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html index 78aaf45b7..1ae279ccc 100644 --- a/modules/worker/front/department/descriptor/index.html +++ b/modules/worker/front/department/descriptor/index.html @@ -3,16 +3,15 @@ description="$ctrl.department.name" base-state="worker.department"> - + Delete -

{{department}}

-

{{department.id}}

+ + - + + + + + + diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js index 8aea255a2..ef1b370b5 100644 --- a/front/salix/components/log/index.js +++ b/front/salix/components/log/index.js @@ -64,47 +64,29 @@ export default class Controller extends Section { set logs(value) { this._logs = value; if (!value) return; - const empty = {}; const validations = window.validations; - const castJsonValue = this.castJsonValue; - for (const log of value) { - const notDelete = log.action != 'delete'; - const olds = (notDelete ? log.oldInstance : null) || empty; - const vals = (notDelete ? log.newInstance : log.oldInstance) || empty; + const oldValues = log.oldInstance || empty; + const newValues = log.newInstance || empty; const locale = validations[log.changedModel]?.locale || empty; log.changedModelI18n = firstUpper(locale.name) || log.changedModel; - let props = Object.keys(olds).concat(Object.keys(vals)); + let props = Object.keys(oldValues).concat(Object.keys(newValues)); props = [...new Set(props)]; log.props = []; for (const prop of props) { - if (prop.endsWith('$')) continue; log.props.push({ name: prop, nameI18n: firstUpper(locale.columns?.[prop]) || prop, - old: getVal(olds, prop), - val: getVal(vals, prop) + old: this.castJsonValue(oldValues[prop]), + new: this.castJsonValue(newValues[prop]) }); } log.props.sort( (a, b) => a.nameI18n.localeCompare(b.nameI18n)); } - - function getVal(vals, prop) { - let val, id; - const showProp = `${prop}$`; - - if (vals[showProp] != null) { - val = vals[showProp]; - id = vals[prop]; - } else - val = vals[prop]; - - return {val: castJsonValue(val), id}; - } } get models() { @@ -131,6 +113,10 @@ export default class Controller extends Section { : value; } + mainVal(prop, action) { + return action == 'delete' ? prop.old : prop.new; + } + relativeDate(dateVal) { if (dateVal == null) return ''; const date = new Date(dateVal); @@ -164,15 +150,14 @@ export default class Controller extends Section { if (value == null || value == '') return null; switch (prop) { case 'search': - const or = []; - if (/^\s*[0-9]+\s*$/.test(value)) - return {changedModelId: value.trim()}; + if (/^[0-9]+$/.test(value)) + return {changedModelId: value}; else return {changedModelValue: {like: `%${value}%`}}; case 'changes': return {or: [ - {oldJson: {like: `%${value}%`}}, - {newJson: {like: `%${value}%`}}, + {oldInstance: {like: `%${value}%`}}, + {newInstance: {like: `%${value}%`}}, {description: {like: `%${value}%`}} ]}; case 'who': @@ -221,14 +206,6 @@ export default class Controller extends Section { return this.$.model.applyFilter(lbFilter); } - filterByEntity(log) { - this.$.filter = { - who: 'all', - search: log.changedModelId, - changedModel: log.changedModel - }; - } - searchUser(search) { if (/^[0-9]+$/.test(search)) { return {id: search}; @@ -261,12 +238,3 @@ ngModule.vnComponent('vnLog', { url: '@' } }); - -ngModule.component('vnLogValue', { - template: - '' + - ' #{{::$ctrl.val.id}}', - bindings: { - val: ' vn-icon { - @extend %clickable-light; - vertical-align: middle; - padding: 2px; - margin: -2px; - font-size: 18px; - color: $color-font-secondary; - float: right; - display: none; - - @include mobile { - display: initial; - } - } & > .model-value { font-style: italic; } @@ -121,9 +107,6 @@ vn-log { font-size: .9rem; } } - &:hover > .model > vn-icon { - display: initial; - } } } .changes { @@ -161,7 +144,3 @@ vn-log { } } } -vn-log-value > .id-value { - font-size: .9rem; - color: $color-font-secondary; -} diff --git a/front/salix/components/login/index.js b/front/salix/components/login/index.js index 8e8f08244..150e896a1 100644 --- a/front/salix/components/login/index.js +++ b/front/salix/components/login/index.js @@ -5,11 +5,10 @@ import './style.scss'; * A simple login form. */ export default class Controller { - constructor($, $element, $state, vnAuth) { + constructor($, $element, vnAuth) { Object.assign(this, { $, $element, - $state, vnAuth, user: localStorage.getItem('lastUser'), remember: true @@ -23,15 +22,11 @@ export default class Controller { localStorage.setItem('lastUser', this.user); this.loading = false; }) - .catch(req => { + .catch(err => { this.loading = false; this.password = ''; this.focusUser(); - const err = req.data?.error; - if (err?.code == 'passExpired') - this.$state.go('change-password', err.details.token); - - throw req; + throw err; }); } @@ -40,7 +35,7 @@ export default class Controller { this.$.userField.focus(); } } -Controller.$inject = ['$scope', '$element', '$state', 'vnAuth']; +Controller.$inject = ['$scope', '$element', 'vnAuth']; ngModule.vnComponent('vnLogin', { template: require('./index.html'), diff --git a/front/salix/components/outLayout/style.scss b/front/salix/components/outLayout/style.scss index a95b75835..aa94fefb3 100644 --- a/front/salix/components/outLayout/style.scss +++ b/front/salix/components/outLayout/style.scss @@ -64,25 +64,4 @@ vn-out-layout{ a{ color: $color-primary; } - - .footer { - margin-top: 32px; - text-align: center; - position: relative; - & > .vn-submit { - display: block; - - & > input { - display: block; - width: 100%; - } - } - & > .spinner-wrapper { - position: absolute; - width: 0; - top: 3px; - right: -8px; - overflow: visible; - } - } } diff --git a/front/salix/components/recover-password/index.js b/front/salix/components/recover-password/index.js index 5ffc305f9..e91169588 100644 --- a/front/salix/components/recover-password/index.js +++ b/front/salix/components/recover-password/index.js @@ -1,4 +1,5 @@ import ngModule from '../../module'; +import './style.scss'; export default class Controller { constructor($scope, $element, $http, vnApp, $translate, $state) { diff --git a/front/salix/components/recover-password/style.scss b/front/salix/components/recover-password/style.scss new file mode 100644 index 000000000..d3c6f594e --- /dev/null +++ b/front/salix/components/recover-password/style.scss @@ -0,0 +1,24 @@ +@import "variables"; + +vn-recover-password{ + .footer { + margin-top: 32px; + text-align: center; + position: relative; + & > .vn-submit { + display: block; + + & > input { + display: block; + width: 100%; + } + } + & > .spinner-wrapper { + position: absolute; + width: 0; + top: 3px; + right: -8px; + overflow: visible; + } + } +} diff --git a/front/salix/components/reset-password/index.js b/front/salix/components/reset-password/index.js index c0a10cc52..a3ca03237 100644 --- a/front/salix/components/reset-password/index.js +++ b/front/salix/components/reset-password/index.js @@ -1,5 +1,5 @@ import ngModule from '../../module'; -const UserError = require('vn-loopback/util/user-error'); +import './style.scss'; export default class Controller { constructor($scope, $element, $http, vnApp, $translate, $state, $location) { diff --git a/front/salix/components/reset-password/style.scss b/front/salix/components/reset-password/style.scss new file mode 100644 index 000000000..87e4adc8c --- /dev/null +++ b/front/salix/components/reset-password/style.scss @@ -0,0 +1,24 @@ +@import "variables"; + +vn-reset-password{ + .footer { + margin-top: 32px; + text-align: center; + position: relative; + & > .vn-submit { + display: block; + + & > input { + display: block; + width: 100%; + } + } + & > .spinner-wrapper { + position: absolute; + width: 0; + top: 3px; + right: -8px; + overflow: visible; + } + } +} diff --git a/front/salix/components/user-popover/index.js b/front/salix/components/user-popover/index.js index 1d88137ff..6cc47db7d 100644 --- a/front/salix/components/user-popover/index.js +++ b/front/salix/components/user-popover/index.js @@ -20,6 +20,8 @@ class Controller { name: config.languages[code] ? config.languages[code] : code }); } + + vnConfig.initialize(); } set lang(value) { diff --git a/front/salix/routes.js b/front/salix/routes.js index 675da719a..f32c143ef 100644 --- a/front/salix/routes.js +++ b/front/salix/routes.js @@ -10,9 +10,6 @@ function config($stateProvider, $urlRouterProvider) { .state('layout', { abstract: true, template: '', - resolve: { - config: ['vnConfig', vnConfig => vnConfig.initialize()] - } }) .state('outLayout', { abstract: true, @@ -36,12 +33,6 @@ function config($stateProvider, $urlRouterProvider) { description: 'Reset password', template: '' }) - .state('change-password', { - parent: 'outLayout', - url: '/change-password?id&userId', - description: 'Change password', - template: '' - }) .state('home', { parent: 'layout', url: '/', diff --git a/front/salix/styles/misc.scss b/front/salix/styles/misc.scss index 9b2829d0b..02bfd9f17 100644 --- a/front/salix/styles/misc.scss +++ b/front/salix/styles/misc.scss @@ -1,4 +1,5 @@ -@import "./util"; +@import "./variables"; +@import "./effects"; form vn-horizontal { align-items: center; @@ -21,10 +22,10 @@ form vn-horizontal { } } - @include mobile { + @media screen and (max-width: $mobile-width) { flex-direction: column; align-items: initial; - + & > * { &, &:first-child, diff --git a/loopback/common/models/log.json b/loopback/common/models/log.json index 6d246371c..54046f072 100644 --- a/loopback/common/models/log.json +++ b/loopback/common/models/log.json @@ -1,61 +1,4 @@ { - "name": "Log", - "base": "VnModel", - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "oldJson": { - "type": "String", - "mysql": {"columnName": "oldInstance"} - }, - "newJson": { - "type": "String", - "mysql": {"columnName": "newInstance"} - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] - } + "name": "Log", + "base": "VnModel" } diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index f92e1ea09..f469e893a 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -1,7 +1,6 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const UserError = require('vn-loopback/util/user-error'); -const utils = require('loopback/lib/utils'); module.exports = function(Self) { Self.ParameterizedSQL = ParameterizedSQL; @@ -165,21 +164,23 @@ module.exports = function(Self) { function rewriteMethod(methodName) { const realMethod = this[methodName]; - return function(...args) { - let cb; - const lastArg = args[args.length - 1]; - if (lastArg instanceof Function) { - cb = lastArg; - args.pop(); - } else - cb = utils.createPromiseCallback(); + return async(data, options, cb) => { + if (options instanceof Function) { + cb = options; + options = null; + } - args.push(function(err, res) { - if (err) err = replaceErr(err, replaceErrFunc); - cb(err, res); - }); - realMethod.apply(this, args); - return cb.promise; + try { + const result = await realMethod.call(this, data, options); + + if (cb) cb(null, result); + else return result; + } catch (err) { + let myErr = replaceErr(err, replaceErrFunc); + if (cb) cb(myErr); + else + throw myErr; + } }; } @@ -195,48 +196,8 @@ module.exports = function(Self) { /* * Shortcut to VnMySQL.executeP() */ - async rawSql(query, params, options) { - const userId = options?.userId; - const connector = this.dataSource.connector; - let conn; - let res; - const opts = Object.assign({}, options); - - try { - if (userId) { - conn = await new Promise((resolve, reject) => { - connector.client.getConnection(function(err, conn) { - if (err) - reject(err); - else - resolve(conn); - }); - }); - - const opts = Object.assign({}, options); - if (!opts.transaction) { - opts.transaction = { - connection: conn, - connector - }; - } - - await connector.executeP( - 'CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?))', - [userId], opts - ); - } - - res = await connector.executeP(query, params, opts); - - if (userId) { - await connector.executeP('CALL account.myUser_logout()', null, opts); - } - } finally { - if (conn) conn.release(); - } - - return res; + rawSql(query, params, options, cb) { + return this.dataSource.connector.executeP(query, params, options, cb); }, /* diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 43ff4b86a..14ffffeb5 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -172,8 +172,6 @@ "Comment added to client": "Comment added to client", "This ticket is already a refund": "This ticket is already a refund", "A claim with that sale already exists": "A claim with that sale already exists", - "Pass expired": "The password has expired, change it from Salix", "Can't transfer claimed sales": "Can't transfer claimed sales", - "Invalid quantity": "Invalid quantity", - "Failed to upload delivery note": "Error to upload delivery note {{id}}" + "Invalid quantity": "Invalid quantity" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 7e2701f95..d88a4ebc9 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -77,13 +77,14 @@ "This ticket can not be modified": "Este ticket no puede ser modificado", "The introduced hour already exists": "Esta hora ya ha sido introducida", "INFINITE_LOOP": "Existe una dependencia entre dos Jefes", + "The sales of the current ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas", "The sales of the receiver ticket can't be modified": "Las lineas del ticket al que envias no pueden ser modificadas", "NO_AGENCY_AVAILABLE": "No hay una zona de reparto disponible con estos parámetros", "ERROR_PAST_SHIPMENT": "No puedes seleccionar una fecha de envío en pasado", "The current ticket can't be modified": "El ticket actual no puede ser modificado", "The current claim can't be modified": "La reclamación actual no puede ser modificada", "The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas", - "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", + "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", "Please select at least one sale": "Por favor selecciona al menos una linea", "All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket", "NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", @@ -258,7 +259,7 @@ "App name does not exist": "El nombre de aplicación no es válido", "Try again": "Vuelve a intentarlo", "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", - "Failed to upload delivery note": "Error al subir albarán {{id}}", + "Failed to upload file": "Error al subir archivo", "The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe", "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar", "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo", @@ -290,7 +291,6 @@ "isTaxDataChecked": "Datos comprobados", "comercialId": "Id comercial", "comercialName": "Comercial", - "Pass expired": "La contraseña ha caducado, cambiela desde Salix", "Invalid NIF for VIES": "Invalid NIF for VIES", "Ticket does not exist": "Este ticket no existe", "Ticket is already signed": "Este ticket ya ha sido firmado" diff --git a/modules/account/back/locale/role-inherit/en.yml b/modules/account/back/locale/role-inherit/en.yml index 8422ecdce..760881325 100644 --- a/modules/account/back/locale/role-inherit/en.yml +++ b/modules/account/back/locale/role-inherit/en.yml @@ -1,5 +1,4 @@ name: subrole columns: - id: id role: rol inheritsFrom: inherits diff --git a/modules/account/back/locale/role-inherit/es.yml b/modules/account/back/locale/role-inherit/es.yml index 10381628c..c352c6ff2 100644 --- a/modules/account/back/locale/role-inherit/es.yml +++ b/modules/account/back/locale/role-inherit/es.yml @@ -1,5 +1,4 @@ name: subrol columns: - id: id role: rol inheritsFrom: hereda diff --git a/modules/account/back/methods/account/change-password.js b/modules/account/back/methods/account/change-password.js index c6f08a232..549508ffa 100644 --- a/modules/account/back/methods/account/change-password.js +++ b/modules/account/back/methods/account/change-password.js @@ -28,6 +28,8 @@ module.exports = Self => { }); Self.changePassword = async function(id, oldPassword, newPassword) { - await Self.app.models.VnUser.changePassword(id, oldPassword, newPassword); + await Self.rawSql(`CALL account.user_changePassword(?, ?, ?)`, + [id, oldPassword, newPassword]); + await Self.app.models.Account.syncById(id, newPassword); }; }; diff --git a/modules/account/back/methods/account/set-password.js b/modules/account/back/methods/account/set-password.js index 010197e0d..b4204d103 100644 --- a/modules/account/back/methods/account/set-password.js +++ b/modules/account/back/methods/account/set-password.js @@ -22,6 +22,8 @@ module.exports = Self => { }); Self.setPassword = async function(id, newPassword) { - await Self.app.models.VnUser.setPassword(id, newPassword); + await Self.rawSql(`CALL account.user_setPassword(?, ?)`, + [id, newPassword]); + await Self.app.models.Account.syncById(id, newPassword); }; }; diff --git a/modules/account/back/methods/account/specs/change-password.spec.js b/modules/account/back/methods/account/specs/change-password.spec.js index 0fd6ecbd5..17fadb3c6 100644 --- a/modules/account/back/methods/account/specs/change-password.spec.js +++ b/modules/account/back/methods/account/specs/change-password.spec.js @@ -2,21 +2,11 @@ const {models} = require('vn-loopback/server/server'); describe('account changePassword()', () => { it('should throw an error when old password is wrong', async() => { - let error; - try { - await models.Account.changePassword(1, 'wrongPassword', 'nightmare.9999'); - } catch (e) { - error = e.message; - } + let err; + await models.Account.changePassword(1, 'wrongPassword', 'nightmare.9999') + .catch(error => err = error.sqlMessage); - expect(error).toContain('Invalid current password'); - }); - - it('should change password', async() => { - try { - await models.Account.changePassword(70, 'nightmare', 'nightmare.9999'); - } catch (e) { - expect(e).toBeUndefined(); - } + expect(err).toBeDefined(); + expect(err).toEqual('Invalid password'); }); }); diff --git a/modules/account/back/methods/account/sync-by-id.js b/modules/account/back/methods/account/sync-by-id.js index e1c631395..538bc09bd 100644 --- a/modules/account/back/methods/account/sync-by-id.js +++ b/modules/account/back/methods/account/sync-by-id.js @@ -24,8 +24,8 @@ module.exports = Self => { } }); - Self.syncById = async function(id, password, force, options) { - let user = await Self.app.models.VnUser.findById(id, {fields: ['name']}, options); - await Self.sync(user.name, password, force, options); + Self.syncById = async function(id, password, force) { + let user = await Self.app.models.VnUser.findById(id, {fields: ['name']}); + await Self.sync(user.name, password, force); }; }; diff --git a/modules/account/back/methods/account/sync.js b/modules/account/back/methods/account/sync.js index a5befc22c..8668be343 100644 --- a/modules/account/back/methods/account/sync.js +++ b/modules/account/back/methods/account/sync.js @@ -24,22 +24,17 @@ module.exports = Self => { } }); - Self.sync = async function(userName, password, force, options) { - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - + Self.sync = async function(userName, password, force) { const models = Self.app.models; const user = await models.VnUser.findOne({ fields: ['id'], where: {name: userName} - }, myOptions); - const isSync = !await models.UserSync.exists(userName, myOptions); + }); + const isSync = !await models.UserSync.exists(userName); if (!force && isSync && user) return; await models.AccountConfig.syncUser(userName, password); - await models.UserSync.destroyById(userName, myOptions); + await models.UserSync.destroyById(userName); }; }; diff --git a/modules/account/back/models/account-config.js b/modules/account/back/models/account-config.js index 0db699b99..5c9d92f1e 100644 --- a/modules/account/back/models/account-config.js +++ b/modules/account/back/models/account-config.js @@ -1,5 +1,5 @@ -const models = require('vn-loopback/server/server').models; +const app = require('vn-loopback/server/server'); module.exports = Self => { Object.assign(Self, { @@ -63,7 +63,7 @@ module.exports = Self => { Object.assign(Self.prototype, { async synchronizerInit() { - let mailConfig = await models.MailConfig.findOne({ + let mailConfig = await app.models.MailConfig.findOne({ fields: ['domain'] }); @@ -91,6 +91,8 @@ module.exports = Self => { }, async synchronizerSyncUser(userName, password, syncGroups) { + let $ = app.models; + if (!userName) return; userName = userName.toLowerCase(); @@ -98,7 +100,7 @@ module.exports = Self => { if (['administrator', 'root'].indexOf(userName) >= 0) return; - let user = await models.VnUser.findOne({ + let user = await $.VnUser.findOne({ where: {name: userName}, fields: [ 'id', @@ -109,7 +111,7 @@ module.exports = Self => { 'sync', 'active', 'created', - 'password', + 'bcryptPassword', 'updated' ], include: [ @@ -136,7 +138,7 @@ module.exports = Self => { }; if (user) { - let exists = await models.Account.exists(user.id); + let exists = await $.Account.exists(user.id); Object.assign(info, { hasAccount: user.active && exists, corporateMail: `${userName}@${this.domain}`, @@ -171,6 +173,30 @@ module.exports = Self => { async synchronizerSyncRoles() { for (let synchronizer of this.synchronizers) await synchronizer.syncRoles(); + }, + + async syncUser(userName, info, password) { + if (info.user && password) + await app.models.VnUser.setPassword(info.user.id, password); + }, + + async getUsers(usersToSync) { + let accounts = await app.models.Account.find({ + fields: ['id'], + include: { + relation: 'user', + scope: { + fields: ['name'], + where: {active: true} + } + } + }); + + for (let account of accounts) { + let user = account.user(); + if (!user) continue; + usersToSync.add(user.name); + } } }); }; diff --git a/modules/account/back/models/account-config.json b/modules/account/back/models/account-config.json index a2a405610..1c643ac38 100644 --- a/modules/account/back/models/account-config.json +++ b/modules/account/back/models/account-config.json @@ -6,6 +6,9 @@ "table": "account.accountConfig" } }, + "mixins": { + "AccountSynchronizer": {} + }, "properties": { "id": { "type": "number", diff --git a/modules/account/back/models/role-log.json b/modules/account/back/models/role-log.json index 324000b68..510e98b68 100644 --- a/modules/account/back/models/role-log.json +++ b/modules/account/back/models/role-log.json @@ -5,5 +5,54 @@ "mysql": { "table": "account.roleLog" } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "number" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/account/back/models/user-log.json b/modules/account/back/models/user-log.json index 8c0234aca..c5aa08e05 100644 --- a/modules/account/back/models/user-log.json +++ b/modules/account/back/models/user-log.json @@ -5,5 +5,54 @@ "mysql": { "table": "account.userLog" } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "number" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/account/front/accounts/index.js b/modules/account/front/accounts/index.js index 0e78ab8d6..7a341b0b0 100644 --- a/modules/account/front/accounts/index.js +++ b/modules/account/front/accounts/index.js @@ -5,7 +5,8 @@ import UserError from 'core/lib/user-error'; export default class Controller extends Section { onSynchronizeAll() { this.vnApp.showSuccess(this.$t('Synchronizing in the background')); - this.$http.patch(`Accounts/syncAll`); + this.$http.patch(`Accounts/syncAll`) + .then(() => this.vnApp.showSuccess(this.$t('Users synchronized!'))); } onUserSync() { diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js index cdf3fc2c3..83043f012 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js @@ -63,7 +63,7 @@ module.exports = Self => { }; let tx; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/claim/back/models/claim-log.json b/modules/claim/back/models/claim-log.json index 2c061b08f..9f28af63e 100644 --- a/modules/claim/back/models/claim-log.json +++ b/modules/claim/back/models/claim-log.json @@ -5,5 +5,54 @@ "mysql": { "table": "claimLog" } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "number" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/client/back/methods/client/confirmTransaction.js b/modules/client/back/methods/client/confirmTransaction.js index fcb33c4ca..a1969d6fd 100644 --- a/modules/client/back/methods/client/confirmTransaction.js +++ b/modules/client/back/methods/client/confirmTransaction.js @@ -23,7 +23,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; let tx; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/consumptionSendQueued.js b/modules/client/back/methods/client/consumptionSendQueued.js index a7081c550..07b5fb57b 100644 --- a/modules/client/back/methods/client/consumptionSendQueued.js +++ b/modules/client/back/methods/client/consumptionSendQueued.js @@ -1,7 +1,7 @@ const {Email} = require('vn-print'); module.exports = Self => { - Self.remoteMethodCtx('consumptionSendQueued', { + Self.remoteMethod('consumptionSendQueued', { description: 'Send all queued invoices', accessType: 'WRITE', accepts: [], @@ -15,7 +15,7 @@ module.exports = Self => { } }); - Self.consumptionSendQueued = async ctx => { + Self.consumptionSendQueued = async() => { const queues = await Self.rawSql(` SELECT id, @@ -68,7 +68,7 @@ module.exports = Self => { SET status = 'printed', printed = ? WHERE id = ?`, - [Date.vnNew(), queue.id], {userId: ctx.req.accessToken.userId}); + [Date.vnNew(), queue.id]); } catch (error) { await Self.rawSql(` UPDATE clientConsumptionQueue diff --git a/modules/client/back/methods/client/createReceipt.js b/modules/client/back/methods/client/createReceipt.js index b70b9bbe0..cb032270a 100644 --- a/modules/client/back/methods/client/createReceipt.js +++ b/modules/client/back/methods/client/createReceipt.js @@ -55,7 +55,7 @@ module.exports = function(Self) { date.setHours(0, 0, 0, 0); let tx; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/filter.js b/modules/client/back/methods/client/filter.js index 3bf29501b..1ae569fd3 100644 --- a/modules/client/back/methods/client/filter.js +++ b/modules/client/back/methods/client/filter.js @@ -72,7 +72,7 @@ module.exports = Self => { Self.filter = async(ctx, filter, options) => { const conn = Self.dataSource.connector; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; const postalCode = []; const args = ctx.args; @@ -120,7 +120,7 @@ module.exports = Self => { const stmts = []; const stmt = new ParameterizedSQL( - `SELECT + `SELECT DISTINCT c.id, c.name, c.fi, diff --git a/modules/client/back/methods/client/getCard.js b/modules/client/back/methods/client/getCard.js index 10e6f7adf..48840b036 100644 --- a/modules/client/back/methods/client/getCard.js +++ b/modules/client/back/methods/client/getCard.js @@ -1,5 +1,5 @@ module.exports = function(Self) { - Self.remoteMethodCtx('getCard', { + Self.remoteMethod('getCard', { description: 'Get client basic data and debt', accepts: { arg: 'id', @@ -18,8 +18,8 @@ module.exports = function(Self) { } }); - Self.getCard = async(ctx, id, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; + Self.getCard = async(id, options) => { + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/getDebt.js b/modules/client/back/methods/client/getDebt.js index 6ed59684b..859746083 100644 --- a/modules/client/back/methods/client/getDebt.js +++ b/modules/client/back/methods/client/getDebt.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('getDebt', { + Self.remoteMethod('getDebt', { description: 'Returns the boolean debt of a client', accessType: 'READ', accepts: [{ @@ -19,8 +19,8 @@ module.exports = Self => { } }); - Self.getDebt = async(ctx, clientFk, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; + Self.getDebt = async(clientFk, options) => { + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/specs/getCard.spec.js b/modules/client/back/methods/client/specs/getCard.spec.js index 962e0a2d4..e713c9883 100644 --- a/modules/client/back/methods/client/specs/getCard.spec.js +++ b/modules/client/back/methods/client/specs/getCard.spec.js @@ -5,11 +5,10 @@ describe('Client getCard()', () => { const tx = await models.Client.beginTransaction({}); try { - const ctx = {req: {accessToken: {userId: 9}}}; const options = {transaction: tx}; const id = 1101; - const result = await models.Client.getCard(ctx, id, options); + const result = await models.Client.getCard(id, options); expect(result.id).toEqual(id); expect(result.name).toEqual('Bruce Wayne'); diff --git a/modules/client/back/methods/client/specs/getDebt.spec.js b/modules/client/back/methods/client/specs/getDebt.spec.js index b3b5286c0..471d45a6d 100644 --- a/modules/client/back/methods/client/specs/getDebt.spec.js +++ b/modules/client/back/methods/client/specs/getDebt.spec.js @@ -3,12 +3,11 @@ const models = require('vn-loopback/server/server').models; describe('client getDebt()', () => { it('should return the client debt', async() => { const tx = await models.Client.beginTransaction({}); - const ctx = {req: {accessToken: {userId: 9}}}; try { const options = {transaction: tx}; - const result = await models.Client.getDebt(ctx, 1101, options); + const result = await models.Client.getDebt(1101, options); expect(result.debt).toEqual(jasmine.any(Number)); diff --git a/modules/client/back/methods/client/specs/summary.spec.js b/modules/client/back/methods/client/specs/summary.spec.js index 227f4c398..f2d576e39 100644 --- a/modules/client/back/methods/client/specs/summary.spec.js +++ b/modules/client/back/methods/client/specs/summary.spec.js @@ -1,7 +1,6 @@ const models = require('vn-loopback/server/server').models; describe('client summary()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; it('should return a summary object containing data', async() => { const clientId = 1101; const tx = await models.Client.beginTransaction({}); @@ -9,7 +8,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(ctx, clientId, options); + const result = await models.Client.summary(clientId, options); expect(result.id).toEqual(clientId); expect(result.name).toEqual('Bruce Wayne'); @@ -28,7 +27,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(ctx, clientId, options); + const result = await models.Client.summary(clientId, options); expect(result.mana.mana).toEqual(0.34); @@ -46,7 +45,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(ctx, clientId, options); + const result = await models.Client.summary(clientId, options); expect(result.debt.debt).toEqual(jasmine.any(Number)); @@ -64,7 +63,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(ctx, clientId, options); + const result = await models.Client.summary(clientId, options); expect(result.averageInvoiced.invoiced).toEqual(1500); @@ -82,7 +81,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(ctx, clientId, options); + const result = await models.Client.summary(clientId, options); expect(result.totalGreuge).toEqual(203.71); @@ -100,7 +99,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(ctx, clientId, options); + const result = await models.Client.summary(clientId, options); expect(result.recovery).toEqual(null); @@ -118,7 +117,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(ctx, clientId, options); + const result = await models.Client.summary(clientId, options); expect(result.recovery.id).toEqual(3); await tx.rollback(); diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js index 8de887b47..7dab1f68b 100644 --- a/modules/client/back/methods/client/summary.js +++ b/modules/client/back/methods/client/summary.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('summary', { + Self.remoteMethod('summary', { description: 'Returns a client summary', accessType: 'READ', accepts: [{ @@ -19,7 +19,7 @@ module.exports = Self => { } }); - Self.summary = async(ctx, clientFk, options) => { + Self.summary = async(clientFk, options) => { const models = Self.app.models; const myOptions = {}; @@ -28,7 +28,7 @@ module.exports = Self => { const summaryObj = await getSummary(models.Client, clientFk, myOptions); summaryObj.mana = await models.Client.getMana(clientFk, myOptions); - summaryObj.debt = await models.Client.getDebt(ctx, clientFk, myOptions); + summaryObj.debt = await models.Client.getDebt(clientFk, myOptions); summaryObj.averageInvoiced = await models.Client.getAverageInvoiced(clientFk, myOptions); summaryObj.totalGreuge = await models.Greuge.sumAmount(clientFk, myOptions); summaryObj.recovery = await getRecoveries(models.Recovery, clientFk, myOptions); diff --git a/modules/client/back/methods/tpv-transaction/end.js b/modules/client/back/methods/tpv-transaction/end.js index 3233f482f..5a757aa48 100644 --- a/modules/client/back/methods/tpv-transaction/end.js +++ b/modules/client/back/methods/tpv-transaction/end.js @@ -34,6 +34,6 @@ module.exports = Self => { 'CALL hedera.tpvTransaction_end(?, ?)', [ orderId, status - ], {userId}); + ]); }; }; diff --git a/modules/client/back/methods/tpv-transaction/start.js b/modules/client/back/methods/tpv-transaction/start.js index 178c56d76..ea6ed05eb 100644 --- a/modules/client/back/methods/tpv-transaction/start.js +++ b/modules/client/back/methods/tpv-transaction/start.js @@ -40,7 +40,7 @@ module.exports = Self => { amount, companyId, userId - ], {userId}); + ]); if (!row) throw new UserError('Transaction error'); diff --git a/modules/client/back/models/client-log.json b/modules/client/back/models/client-log.json index c0e69df35..316dbe972 100644 --- a/modules/client/back/models/client-log.json +++ b/modules/client/back/models/client-log.json @@ -5,5 +5,54 @@ "mysql": { "table": "clientLog" } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "number" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/client/front/credit-management/index.html b/modules/client/front/credit-management/index.html index b9064ff69..d7456fd06 100644 --- a/modules/client/front/credit-management/index.html +++ b/modules/client/front/credit-management/index.html @@ -68,7 +68,7 @@ {{::clientInforma.rating}} - {{::clientInforma.recommendedCredit | currency: 'EUR': 2}} + {{::clientInforma.recommendedCredit}} diff --git a/modules/entry/back/methods/entry/importBuys.js b/modules/entry/back/methods/entry/importBuys.js index 1e6f01a5e..fdc6b058e 100644 --- a/modules/entry/back/methods/entry/importBuys.js +++ b/modules/entry/back/methods/entry/importBuys.js @@ -46,7 +46,7 @@ module.exports = Self => { const args = ctx.args; const models = Self.app.models; let tx; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); @@ -79,7 +79,7 @@ module.exports = Self => { ], myOptions); const buyUltimate = await Self.rawSql(` - SELECT * + SELECT * FROM tmp.buyUltimate WHERE warehouseFk = ? `, [travel.warehouseInFk], myOptions); diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json index ca4472c8c..ad5a9063e 100644 --- a/modules/entry/back/model-config.json +++ b/modules/entry/back/model-config.json @@ -5,9 +5,6 @@ "Buy": { "dataSource": "vn" }, - "BuyConfig": { - "dataSource": "vn" - }, "ItemMatchProperties": { "dataSource": "vn" }, diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json index af205533f..379e55427 100644 --- a/modules/entry/back/models/buy.json +++ b/modules/entry/back/models/buy.json @@ -39,9 +39,6 @@ "packageValue": { "type": "number" }, - "price1": { - "type": "number" - }, "price2": { "type": "number" }, @@ -50,44 +47,7 @@ }, "weight": { "type": "number" - }, - "printedStickers": { - "type": "number" - }, - "dispatched": { - "type": "number" - }, - "isIgnored": { - "type": "boolean" - }, - "containerFk": { - "type": "number" - }, - "location": { - "type": "number" - }, - "minPrice": { - "type": "number" - }, - "isChecked": { - "type": "boolean" - }, - "isPickedOff": { - "type": "boolean" - }, - "created": { - "type": "date" - }, - "ektFk": { - "type": "number" - }, - "itemOriginalFk": { - "type": "number" - }, - "editorFk": { - "type": "number" } - }, "relations": { "entry": { @@ -104,16 +64,6 @@ "type": "belongsTo", "model": "Packaging", "foreignKey": "packageFk" - }, - "worker": { - "type": "belongsTo", - "model": "Worker", - "foreignKey": "workerFk" - }, - "delivery": { - "type": "belongsTo", - "model": "Delivery", - "foreignKey": "deliveryFk" } } } diff --git a/modules/entry/back/models/entry-log.json b/modules/entry/back/models/entry-log.json index ac4d803d1..b4370e3bc 100644 --- a/modules/entry/back/models/entry-log.json +++ b/modules/entry/back/models/entry-log.json @@ -5,5 +5,54 @@ "mysql": { "table": "entryLog" } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "string" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 0eabd70ee..1980f964c 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -8,8 +8,6 @@ module.exports = Self => { require('../methods/entry/importBuysPreview')(Self); require('../methods/entry/lastItemBuys')(Self); require('../methods/entry/entryOrderPdf')(Self); - require('../methods/entry/addFromPackaging')(Self); - require('../methods/entry/addFromBuy')(Self); Self.observe('before save', async function(ctx, options) { if (ctx.isNewInstance) return; diff --git a/modules/invoiceIn/back/methods/invoice-in/toBook.js b/modules/invoiceIn/back/methods/invoice-in/toBook.js index 778742911..588d53f1f 100644 --- a/modules/invoiceIn/back/methods/invoice-in/toBook.js +++ b/modules/invoiceIn/back/methods/invoice-in/toBook.js @@ -21,7 +21,7 @@ module.exports = Self => { Self.toBook = async(ctx, id, options) => { let tx; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); @@ -32,7 +32,7 @@ module.exports = Self => { } try { - await Self.rawSql(`CALL vn.invoiceIn_booking(?)`, [id], myOptions); + await Self.rawSql(`CALL vn.invoiceInBookingMain(?)`, [id], myOptions); if (tx) await tx.commit(); } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/invoiceIn/back/models/invoice-in-log.json b/modules/invoiceIn/back/models/invoice-in-log.json index 43ebb4c55..70892d0f9 100644 --- a/modules/invoiceIn/back/models/invoice-in-log.json +++ b/modules/invoiceIn/back/models/invoice-in-log.json @@ -5,5 +5,57 @@ "mysql": { "table": "invoiceInLog" } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "string" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": [ + "creationDate DESC", + "id DESC" + ] } } diff --git a/modules/invoiceOut/back/methods/invoiceOut/book.js b/modules/invoiceOut/back/methods/invoiceOut/book.js index af5633ff2..7aa0eac1f 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/book.js +++ b/modules/invoiceOut/back/methods/invoiceOut/book.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethodCtx('book', { + Self.remoteMethod('book', { description: 'Book an invoiceOut', accessType: 'WRITE', accepts: { @@ -20,10 +20,10 @@ module.exports = Self => { } }); - Self.book = async(ctx, ref, options) => { + Self.book = async(ref, options) => { const models = Self.app.models; let tx; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js index 63b00fe38..f18b0c682 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js @@ -36,7 +36,7 @@ module.exports = Self => { Self.clientsToInvoice = async(ctx, clientId, invoiceDate, maxShipped, companyFk, options) => { let tx; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js index 18e6903d6..a458aa18e 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js @@ -51,7 +51,7 @@ module.exports = Self => { const args = ctx.args; let tx; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js index 421cbaea1..c8f8a6778 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js @@ -50,7 +50,7 @@ module.exports = Self => { Self.invoiceClient = async(ctx, options) => { const args = ctx.args; const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/invoiceOut/back/methods/invoiceOut/refund.js b/modules/invoiceOut/back/methods/invoiceOut/refund.js index 1b7ccc1e4..ad480dc7d 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/refund.js +++ b/modules/invoiceOut/back/methods/invoiceOut/refund.js @@ -1,20 +1,12 @@ module.exports = Self => { - Self.remoteMethodCtx('refund', { + Self.remoteMethod('refund', { description: 'Create refund tickets with sales and services if provided', accessType: 'WRITE', - accepts: [ - { - arg: 'ref', - type: 'string', - description: 'The invoice reference', - required: true - }, - { - arg: 'withWarehouse', - type: 'boolean', - required: true - } - ], + accepts: [{ + arg: 'ref', + type: 'string', + description: 'The invoice reference' + }], returns: { type: ['number'], root: true @@ -25,7 +17,7 @@ module.exports = Self => { } }); - Self.refund = async(ctx, ref, withWarehouse, options) => { + Self.refund = async(ref, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -43,7 +35,7 @@ module.exports = Self => { const tickets = await models.Ticket.find(filter, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); - const refundedTickets = await models.Ticket.refund(ctx, ticketsIds, withWarehouse, myOptions); + const refundedTickets = await models.Ticket.refund(ticketsIds, myOptions); if (tx) await tx.commit(); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js index 3af7542ca..ee72f2218 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js @@ -1,7 +1,6 @@ const models = require('vn-loopback/server/server').models; describe('invoiceOut book()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; const invoiceOutId = 5; it('should update the booked property', async() => { @@ -13,7 +12,7 @@ describe('invoiceOut book()', () => { const bookedDate = originalInvoiceOut.booked; const invoiceOutRef = originalInvoiceOut.ref; - await models.InvoiceOut.book(ctx, invoiceOutRef, options); + await models.InvoiceOut.book(invoiceOutRef, options); const updatedInvoiceOut = await models.InvoiceOut.findById(invoiceOutId, {}, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js index 072fcc12c..35f2b4023 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js @@ -3,8 +3,6 @@ const LoopBackContext = require('loopback-context'); describe('InvoiceOut refund()', () => { const userId = 5; - const ctx = {req: {accessToken: userId}}; - const withWarehouse = true; const activeCtx = { accessToken: {userId: userId}, }; @@ -17,7 +15,7 @@ describe('InvoiceOut refund()', () => { const options = {transaction: tx}; try { - const result = await models.InvoiceOut.refund(ctx, 'T1111111', withWarehouse, options); + const result = await models.InvoiceOut.refund('T1111111', options); expect(result).toBeDefined(); diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index 106f8e3cc..389fcf81b 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -76,27 +76,14 @@ translate> Show CITES letter - - Refund... - - - - with warehouse - - - without warehouse - - - + Refund @@ -110,7 +97,12 @@ on-accept="$ctrl.bookInvoiceOut()" question="Are you sure you want to book this invoice?"> - + + @@ -156,4 +148,4 @@ - + \ No newline at end of file diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js index 38c3c9434..57ea653a8 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.js +++ b/modules/invoiceOut/front/descriptor-menu/index.js @@ -114,9 +114,9 @@ class Controller extends Section { }); } - refundInvoiceOut(withWarehouse) { + refundInvoiceOut() { const query = 'InvoiceOuts/refund'; - const params = {ref: this.invoiceOut.ref, withWarehouse: withWarehouse}; + const params = {ref: this.invoiceOut.ref}; this.$http.post(query, params).then(res => { const refundTicket = res.data; this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { diff --git a/modules/invoiceOut/front/descriptor-menu/locale/es.yml b/modules/invoiceOut/front/descriptor-menu/locale/es.yml index 393efd58c..df0ba57cf 100644 --- a/modules/invoiceOut/front/descriptor-menu/locale/es.yml +++ b/modules/invoiceOut/front/descriptor-menu/locale/es.yml @@ -13,11 +13,10 @@ InvoiceOut deleted: Factura eliminada Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura? Are you sure you want to clone this invoice?: Estas seguro de clonar esta factura? InvoiceOut booked: Factura asentada -Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? +Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? Are you sure you want to refund this invoice?: Estas seguro de querer abonar esta factura? Create a single ticket with all the content of the current invoice: Crear un ticket unico con todo el contenido de la factura actual Regenerate PDF invoice: Regenerar PDF factura The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado The email can't be empty: El correo no puede estar vacío The following refund tickets have been created: "Se han creado los siguientes tickets de abono: {{ticketIds}}" -Refund...: Abono... diff --git a/modules/invoiceOut/front/global-invoicing/index.html b/modules/invoiceOut/front/global-invoicing/index.html index 3f0a10650..6d5b16329 100644 --- a/modules/invoiceOut/front/global-invoicing/index.html +++ b/modules/invoiceOut/front/global-invoicing/index.html @@ -118,8 +118,7 @@ label="Company" show-field="code" value-field="id" - ng-model="$ctrl.companyFk" - on-change="$ctrl.getInvoiceDate(value)"> + ng-model="$ctrl.companyFk"> { - this.companyFk = res.data.companyFk; - this.getInvoiceDate(this.companyFk); - }); - } - - getInvoiceDate(companyFk) { - const params = { companyFk: companyFk }; - this.fetchInvoiceDate(params); - } - - fetchInvoiceDate(params) { - this.$http.get('InvoiceOuts/getInvoiceDate', { params }) - .then(res => { - this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null; - this.invoiceDate = this.minInvoicingDate; - }); - } + .then(res => { + this.companyFk = res.data.companyFk; + const params = { + companyFk: this.companyFk + }; + return this.$http.get('InvoiceOuts/getInvoiceDate', {params}); + }) + .then(res => { + this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null; + this.invoiceDate = this.minInvoicingDate; + }); + } stopInvoicing() { this.status = 'stopping'; @@ -48,7 +42,7 @@ class Controller extends Section { throw new UserError('Invoice date and the max date should be filled'); if (this.invoiceDate < this.maxShipped) throw new UserError('Invoice date can\'t be less than max date'); - if (this.minInvoicingDate && this.invoiceDate.getTime() < this.minInvoicingDate.getTime()) + if (this.invoiceDate.getTime() < this.minInvoicingDate.getTime()) throw new UserError('Exists an invoice with a previous date'); if (!this.companyFk) throw new UserError('Choose a valid company'); diff --git a/modules/invoiceOut/front/negative-bases/index.js b/modules/invoiceOut/front/negative-bases/index.js index f60668b20..1a838507c 100644 --- a/modules/invoiceOut/front/negative-bases/index.js +++ b/modules/invoiceOut/front/negative-bases/index.js @@ -19,8 +19,7 @@ export default class Controller extends Section { this.smartTableOptions = { activeButtons: { search: true, - }, - columns: [ + }, columns: [ { field: 'isActive', searchable: false diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index d4e2d0f74..5751b0a04 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('getBalance', { + Self.remoteMethod('getBalance', { description: 'Returns the ', accessType: 'READ', accepts: [{ @@ -19,8 +19,8 @@ module.exports = Self => { } }); - Self.getBalance = async(ctx, filter, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; + Self.getBalance = async(filter, options) => { + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/item/back/methods/item/new.js b/modules/item/back/methods/item/new.js index c82e2a6b1..d066f2c9f 100644 --- a/modules/item/back/methods/item/new.js +++ b/modules/item/back/methods/item/new.js @@ -1,7 +1,7 @@ let UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethodCtx('new', { + Self.remoteMethod('new', { description: 'returns the created item', accessType: 'WRITE', accepts: [{ @@ -19,9 +19,9 @@ module.exports = Self => { } }); - Self.new = async(ctx, params, options) => { + Self.new = async(params, options) => { const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/item/back/methods/item/specs/getBalance.spec.js b/modules/item/back/methods/item/specs/getBalance.spec.js index e013d8956..1ffd3c302 100644 --- a/modules/item/back/methods/item/specs/getBalance.spec.js +++ b/modules/item/back/methods/item/specs/getBalance.spec.js @@ -2,7 +2,6 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('item getBalance()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; it('should return the balance lines of a client type loses in which one has highlighted true', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; @@ -26,7 +25,7 @@ describe('item getBalance()', () => { date: null } }; - const results = await models.Item.getBalance(ctx, filter, options); + const results = await models.Item.getBalance(filter, options); const result = results.find(element => element.clientType == 'loses'); @@ -60,8 +59,8 @@ describe('item getBalance()', () => { } }; - const firstItemBalance = await models.Item.getBalance(ctx, firstFilter, options); - const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options); + const firstItemBalance = await models.Item.getBalance(firstFilter, options); + const secondItemBalance = await models.Item.getBalance(secondFilter, options); expect(firstItemBalance[9].claimFk).toEqual(null); expect(secondItemBalance[5].claimFk).toEqual(2); diff --git a/modules/item/back/methods/item/specs/new.spec.js b/modules/item/back/methods/item/specs/new.spec.js index 2ffaf87a5..a1c741649 100644 --- a/modules/item/back/methods/item/specs/new.spec.js +++ b/modules/item/back/methods/item/specs/new.spec.js @@ -2,7 +2,6 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('item new()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; beforeAll(async() => { const activeCtx = { accessToken: {userId: 9}, @@ -31,7 +30,7 @@ describe('item new()', () => { tag: 1 }; - let item = await models.Item.new(ctx, itemParams, options); + let item = await models.Item.new(itemParams, options); let itemType = await models.ItemType.findById(item.typeFk, options); diff --git a/modules/item/back/models/item-log.json b/modules/item/back/models/item-log.json index 8b8534d11..19c132187 100644 --- a/modules/item/back/models/item-log.json +++ b/modules/item/back/models/item-log.json @@ -5,5 +5,54 @@ "mysql": { "table": "itemLog" } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "number" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/item/front/fixed-price/index.js b/modules/item/front/fixed-price/index.js index fe6788e9c..a39cd6602 100644 --- a/modules/item/front/fixed-price/index.js +++ b/modules/item/front/fixed-price/index.js @@ -13,6 +13,7 @@ export default class Controller extends Section { activeButtons: { search: true }, + defaultSearch: true, columns: [ { field: 'warehouseFk', diff --git a/modules/order/back/methods/order-row/addToOrder.js b/modules/order/back/methods/order-row/addToOrder.js index 0bf65ef1f..639fa8be7 100644 --- a/modules/order/back/methods/order-row/addToOrder.js +++ b/modules/order/back/methods/order-row/addToOrder.js @@ -1,7 +1,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethodCtx('addToOrder', { + Self.remoteMethod('addToOrder', { description: 'Creates rows (lines) for a order', accessType: 'WRITE', accepts: [{ @@ -21,8 +21,8 @@ module.exports = Self => { } }); - Self.addToOrder = async(ctx, params, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; + Self.addToOrder = async(params, options) => { + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/order/back/methods/order-row/specs/addToOrder.spec.js b/modules/order/back/methods/order-row/specs/addToOrder.spec.js index 96544a1a9..d902a1062 100644 --- a/modules/order/back/methods/order-row/specs/addToOrder.spec.js +++ b/modules/order/back/methods/order-row/specs/addToOrder.spec.js @@ -1,7 +1,6 @@ const models = require('vn-loopback/server/server').models; describe('order addToOrder()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; const orderId = 8; it('should add a row to a given order', async() => { const tx = await models.Order.beginTransaction({}); @@ -22,7 +21,7 @@ describe('order addToOrder()', () => { }] }; - await models.OrderRow.addToOrder(ctx, params, options); + await models.OrderRow.addToOrder(params, options); const modifiedRows = await models.OrderRow.find({where: {orderFk: orderId}}, options); diff --git a/modules/order/back/methods/order/confirm.js b/modules/order/back/methods/order/confirm.js index 5fdab29b3..52acc8648 100644 --- a/modules/order/back/methods/order/confirm.js +++ b/modules/order/back/methods/order/confirm.js @@ -23,7 +23,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const query = `CALL hedera.order_confirmWithUser(?, ?)`; - const response = await Self.rawSql(query, [orderFk, userId], {userId}); + const response = await Self.rawSql(query, [orderFk, userId]); return response; }; diff --git a/modules/order/back/methods/order/new.js b/modules/order/back/methods/order/new.js index d65b18e12..147859dcc 100644 --- a/modules/order/back/methods/order/new.js +++ b/modules/order/back/methods/order/new.js @@ -1,7 +1,7 @@ let UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethodCtx('new', { + Self.remoteMethod('new', { description: 'Create a new order and returns the new ID', accessType: 'WRITE', accepts: [ @@ -32,8 +32,8 @@ module.exports = Self => { } }); - Self.new = async(ctx, landed, addressId, agencyModeId, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; + Self.new = async(landed, addressId, agencyModeId, options) => { + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/order/back/methods/order/newFromTicket.js b/modules/order/back/methods/order/newFromTicket.js index 3614d8e32..e0578ff9a 100644 --- a/modules/order/back/methods/order/newFromTicket.js +++ b/modules/order/back/methods/order/newFromTicket.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('newFromTicket', { + Self.remoteMethod('newFromTicket', { description: 'Create a new order and returns the new ID', accessType: 'WRITE', accepts: [{ @@ -18,7 +18,7 @@ module.exports = Self => { } }); - Self.newFromTicket = async(ctx, ticketFk, options) => { + Self.newFromTicket = async(ticketFk, options) => { const myOptions = {}; let tx; @@ -39,7 +39,7 @@ module.exports = Self => { const addressFk = ticket.addressFk; const agencyModeFk = ticket.agencyModeFk; - const orderID = await Self.app.models.Order.new(ctx, landed, addressFk, agencyModeFk, myOptions); + const orderID = await Self.app.models.Order.new(landed, addressFk, agencyModeFk, myOptions); if (tx) await tx.commit(); diff --git a/modules/order/back/methods/order/specs/new.spec.js b/modules/order/back/methods/order/specs/new.spec.js index c43527f66..f11367579 100644 --- a/modules/order/back/methods/order/specs/new.spec.js +++ b/modules/order/back/methods/order/specs/new.spec.js @@ -2,7 +2,6 @@ const models = require('vn-loopback/server/server').models; const UserError = require('vn-loopback/util/user-error'); describe('order new()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; it('should throw an error if the client isnt active', async() => { const tx = await models.Order.beginTransaction({}); @@ -14,7 +13,7 @@ describe('order new()', () => { const addressFk = 6; const agencyModeFk = 1; - await models.Order.new(ctx, landed, addressFk, agencyModeFk, options); + await models.Order.new(landed, addressFk, agencyModeFk, options); await tx.rollback(); } catch (e) { @@ -35,7 +34,7 @@ describe('order new()', () => { const addressFk = 121; const agencyModeFk = 1; - orderId = await models.Order.new(ctx, landed, addressFk, agencyModeFk, options); + orderId = await models.Order.new(landed, addressFk, agencyModeFk, options); const highestOrderIdInFixtures = 3; diff --git a/modules/order/back/methods/order/specs/newFromTicket.spec.js b/modules/order/back/methods/order/specs/newFromTicket.spec.js index c509552fe..6f18d1751 100644 --- a/modules/order/back/methods/order/specs/newFromTicket.spec.js +++ b/modules/order/back/methods/order/specs/newFromTicket.spec.js @@ -1,7 +1,6 @@ const models = require('vn-loopback/server/server').models; describe('order newFromTicket()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; it('should create a new order from an existing ticket', async() => { const tx = await models.Order.beginTransaction({}); @@ -10,7 +9,7 @@ describe('order newFromTicket()', () => { const ticketId = 11; - const orderId = await models.Order.newFromTicket(ctx, ticketId, options); + const orderId = await models.Order.newFromTicket(ticketId, options); const highestOrderIdInFixtures = 3; diff --git a/modules/order/front/catalog-search-panel/index.js b/modules/order/front/catalog-search-panel/index.js index 21c0c50fa..ed0af1d6e 100644 --- a/modules/order/front/catalog-search-panel/index.js +++ b/modules/order/front/catalog-search-panel/index.js @@ -23,7 +23,7 @@ class Controller extends SearchPanel { addValue() { this.filter.values.push({}); - setTimeout(() => this.parentPopover.relocate()); + setTimeout(() => this.popover.relocate()); } changeTag() { @@ -36,7 +36,7 @@ ngModule.vnComponent('vnOrderCatalogSearchPanel', { controller: Controller, bindings: { onSubmit: '&?', - parentPopover: ' @@ -31,7 +31,7 @@ label="Category"> - - @@ -104,20 +104,20 @@ on-close="$ctrl.onPopoverClose()">
- + class="colored"> Id: {{$ctrl.itemId}} - {{$ctrl.itemName}}
- + class="colored"> {{category.selection.name}} - + class="colored"> {{type.selection.name}} + class="colored">
{{::tagGroup.tagSelection.name}}: @@ -163,4 +163,4 @@
- + \ No newline at end of file diff --git a/modules/route/back/methods/agency-term/createInvoiceIn.js b/modules/route/back/methods/agency-term/createInvoiceIn.js index 5a8430e49..836655bd3 100644 --- a/modules/route/back/methods/agency-term/createInvoiceIn.js +++ b/modules/route/back/methods/agency-term/createInvoiceIn.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('createInvoiceIn', { + Self.remoteMethod('createInvoiceIn', { description: 'Creates an invoiceIn from one or more agency terms', accessType: 'WRITE', accepts: [{ @@ -24,11 +24,11 @@ module.exports = Self => { } }); - Self.createInvoiceIn = async(ctx, rows, dms, options) => { + Self.createInvoiceIn = async(rows, dms, options) => { const models = Self.app.models; let tx; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js b/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js index d3a0755ef..628c5fb9a 100644 --- a/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js +++ b/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js @@ -2,7 +2,6 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('AgencyTerm createInvoiceIn()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; beforeAll(async() => { const activeCtx = { accessToken: {userId: 9}, @@ -43,7 +42,7 @@ describe('AgencyTerm createInvoiceIn()', () => { const oldInvoiceInDueDay = await models.InvoiceInDueDay.findById(invoiceInDueDayId, null, options); const oldInvoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options); - await models.AgencyTerm.createInvoiceIn(ctx, rows, dms, options); + await models.AgencyTerm.createInvoiceIn(rows, dms, options); const [newInvoiceIn] = await models.InvoiceIn.rawSql('SELECT MAX(id) id FROM invoiceIn', null, options); diff --git a/modules/route/back/methods/route/guessPriority.js b/modules/route/back/methods/route/guessPriority.js index 67b68aa89..eab9f3473 100644 --- a/modules/route/back/methods/route/guessPriority.js +++ b/modules/route/back/methods/route/guessPriority.js @@ -26,7 +26,7 @@ module.exports = Self => { const tx = await Self.beginTransaction({}); try { - let options = {transaction: tx, userId}; + let options = {transaction: tx}; const priority = await Self.rawSql(query, [id], options); diff --git a/modules/route/back/methods/route/updateVolume.js b/modules/route/back/methods/route/updateVolume.js index cdced3882..f3b8da130 100644 --- a/modules/route/back/methods/route/updateVolume.js +++ b/modules/route/back/methods/route/updateVolume.js @@ -24,7 +24,7 @@ module.exports = Self => { const models = Self.app.models; let tx; - const myOptions = {userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/route/back/models/route-log.json b/modules/route/back/models/route-log.json index 63c233bdd..93f570593 100644 --- a/modules/route/back/models/route-log.json +++ b/modules/route/back/models/route-log.json @@ -5,5 +5,54 @@ "mysql": { "table": "routeLog" } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "number" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/route/front/index/index.html b/modules/route/front/index/index.html index 9384af6be..7a64a9aff 100644 --- a/modules/route/front/index/index.html +++ b/modules/route/front/index/index.html @@ -1,26 +1,11 @@ - - - - - -
-
@@ -50,7 +35,7 @@ - @@ -67,19 +52,19 @@ Vehicle - Date + Date - + - Description + Description - Hour started + Hour started - Hour finished + Hour finished @@ -89,7 +74,7 @@ class="clickable vn-tr search-result" ng-attr-id="{{::route.id}}" vn-droppable="$ctrl.onDrop($event)"> - @@ -98,7 +83,7 @@ - + - - - + @@ -171,7 +156,7 @@ - +
@@ -186,7 +171,7 @@ route="$ctrl.routeSelected"> - - @@ -225,4 +210,4 @@ - + \ No newline at end of file diff --git a/modules/shelving/back/models/sector.json b/modules/shelving/back/models/sector.json index 47d66bd8d..0dc502cd0 100644 --- a/modules/shelving/back/models/sector.json +++ b/modules/shelving/back/models/sector.json @@ -56,7 +56,7 @@ "type": "number", "required": false }, - "mainPrinterFk": { + "printerFk": { "type": "number", "required": false }, @@ -69,4 +69,4 @@ "required": true } } -} +} \ No newline at end of file diff --git a/modules/shelving/back/models/shelving-log.json b/modules/shelving/back/models/shelving-log.json index 03a5dda1a..e8245f770 100644 --- a/modules/shelving/back/models/shelving-log.json +++ b/modules/shelving/back/models/shelving-log.json @@ -1,9 +1,58 @@ { - "name": "ShelvingLog", + "name": "ShelvingLog", "base": "Log", - "options": { - "mysql": { - "table": "shelvingLog" + "options": { + "mysql": { + "table": "shelvingLog" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "number" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/supplier/back/models/supplier-log.json b/modules/supplier/back/models/supplier-log.json index 1fe4752a0..86fa2e54a 100644 --- a/modules/supplier/back/models/supplier-log.json +++ b/modules/supplier/back/models/supplier-log.json @@ -5,5 +5,54 @@ "mysql": { "table": "supplierLog" } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "string" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 9c78e8590..e113e5d59 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -11,7 +11,6 @@ module.exports = Self => { require('../methods/supplier/campaignMetricsPdf')(Self); require('../methods/supplier/campaignMetricsEmail')(Self); require('../methods/supplier/newSupplier')(Self); - require('../methods/supplier/getItemsPackaging')(Self); Self.validatesPresenceOf('name', { message: 'The social name cannot be empty' diff --git a/modules/ticket/back/locale/ticket-request/en.yml b/modules/ticket/back/locale/ticket-request/en.yml index fc9210501..f381e0c9d 100644 --- a/modules/ticket/back/locale/ticket-request/en.yml +++ b/modules/ticket/back/locale/ticket-request/en.yml @@ -2,17 +2,14 @@ name: request columns: id: id description: description - buyerCode: buyer + created: created quantity: quantity price: price - itemFk: item - clientFk: client - response: response - total: total - buyed: buyed - saleFk: sale - created: created isOk: ok - requesterFk: requester - attenderFk: attender + response: response + saleFk: sale ticketFk: ticket + attenderFk: attender + requesterFk: requester + itemFk: item + diff --git a/modules/ticket/back/locale/ticket-request/es.yml b/modules/ticket/back/locale/ticket-request/es.yml index fd89ddf60..5504448bf 100644 --- a/modules/ticket/back/locale/ticket-request/es.yml +++ b/modules/ticket/back/locale/ticket-request/es.yml @@ -1,18 +1,15 @@ -name: petición +name: peticion columns: id: id description: descripción - buyerCode: comprador + created: creado quantity: cantidad price: precio - itemFk: artículo - clientFk: cliente - response: respuesta - total: total - buyed: comprado - saleFk: línea - created: creado isOk: ok - requesterFk: solicitante - attenderFk: asistente + response: respuesta + saleFk: línea ticketFk: ticket + attenderFk: asistente + requesterFk: solicitante + itemFk: artículo + diff --git a/modules/ticket/back/methods/expedition/filter.js b/modules/ticket/back/methods/expedition/filter.js index 43be14349..fcf0bd1b3 100644 --- a/modules/ticket/back/methods/expedition/filter.js +++ b/modules/ticket/back/methods/expedition/filter.js @@ -24,46 +24,40 @@ module.exports = Self => { Self.filter = async(filter, options) => { const myOptions = {}; - const conn = Self.dataSource.connector; if (typeof options == 'object') Object.assign(myOptions, options); const stmt = new ParameterizedSQL( - `SELECT * - FROM ( - SELECT - e.id, - e.ticketFk, - e.freightItemFk, - e.workerFk, - i1.name packageItemName, - e.counter, - i2.name freightItemName, - u.name userName, - e.created, - e.externalId, - i3.name packagingName, - i3.id packagingItemFk, - e.packagingFk, - es.workerFk expeditionScanWorkerFk, - su.name scannerUserName, - es.scanned, - est.description state - FROM vn.expedition e - LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk - INNER JOIN vn.item i1 ON i1.id = e.freightItemFk - LEFT JOIN vn.packaging p ON p.id = e.packagingFk - LEFT JOIN vn.item i3 ON i3.id = p.itemFk - LEFT JOIN vn.item i2 ON i2.id = p.itemFk - LEFT JOIN account.user u ON u.id = e.workerFk - LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id - LEFT JOIN account.user su ON su.id = es.workerFk - ) e + `SELECT + e.id, + e.ticketFk, + e.freightItemFk, + e.workerFk, + i1.name packageItemName, + e.counter, + i2.name freightItemName, + u.name userName, + e.created, + e.externalId, + i3.name packagingName, + i3.id packagingItemFk, + e.packagingFk, + es.workerFk expeditionScanWorkerFk, + su.name scannerUserName, + es.scanned, + est.description state + FROM vn.expedition e + LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk + INNER JOIN vn.item i1 ON i1.id = e.freightItemFk + LEFT JOIN vn.packaging p ON p.id = e.packagingFk + LEFT JOIN vn.item i3 ON i3.id = p.itemFk + LEFT JOIN vn.item i2 ON i2.id = p.itemFk + LEFT JOIN account.user u ON u.id = e.workerFk + LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id + LEFT JOIN account.user su ON su.id = es.workerFk `); - stmt.merge(conn.makeWhere(filter.where)); - stmt.merge(conn.makeOrderBy(filter.order)); - stmt.merge(conn.makeLimit(filter)); + stmt.merge(Self.buildSuffix(filter, 'e')); return Self.rawStmt(stmt, myOptions); }; diff --git a/modules/ticket/back/methods/expedition/specs/filter.spec.js b/modules/ticket/back/methods/expedition/specs/filter.spec.js index 4da1ba352..f643462cc 100644 --- a/modules/ticket/back/methods/expedition/specs/filter.spec.js +++ b/modules/ticket/back/methods/expedition/specs/filter.spec.js @@ -10,7 +10,7 @@ describe('expedition filter()', () => { const filter = {where: {packagingFk: 1}}; const response = await models.Expedition.filter(filter, options); - expect(response.length).toBeGreaterThan(-1); + expect(response.length).toBeGreaterThan(1); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/methods/sale/recalculatePrice.js b/modules/ticket/back/methods/sale/recalculatePrice.js index fd3d6aa9b..2c8e6768b 100644 --- a/modules/ticket/back/methods/sale/recalculatePrice.js +++ b/modules/ticket/back/methods/sale/recalculatePrice.js @@ -23,7 +23,7 @@ module.exports = Self => { Self.recalculatePrice = async(ctx, sales, options) => { const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index 7abcedd90..18ccee976 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('refund', { + Self.remoteMethod('refund', { description: 'Create refund tickets with sales and services if provided', accessType: 'WRITE', accepts: [ @@ -11,11 +11,6 @@ module.exports = Self => { { arg: 'servicesIds', type: ['number'] - }, - { - arg: 'withWarehouse', - type: 'boolean', - required: true } ], returns: { @@ -28,9 +23,9 @@ module.exports = Self => { } }); - Self.refund = async(ctx, salesIds, servicesIds, withWarehouse, options) => { + Self.refund = async(salesIds, servicesIds, options) => { const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') @@ -70,7 +65,7 @@ module.exports = Self => { const now = Date.vnNew(); const [firstTicketId] = ticketsIds; - const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions); + const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, myOptions); for (const sale of sales) { const createdSale = await models.Sale.create({ @@ -118,7 +113,7 @@ module.exports = Self => { } }; - async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) { + async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, myOptions) { const models = Self.app.models; const filter = {include: {relation: 'address'}}; @@ -130,7 +125,7 @@ module.exports = Self => { addressFk: ticket.address().id, agencyModeFk: refundAgencyMode.id, nickname: ticket.address().nickname, - warehouseFk: withWarehouse ? ticket.warehouseFk : null, + warehouseFk: ticket.warehouseFk, companyFk: ticket.companyFk, landed: now, zoneFk: refoundZoneId diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js index b81f7f84d..83b3755e2 100644 --- a/modules/ticket/back/methods/sale/specs/refund.spec.js +++ b/modules/ticket/back/methods/sale/specs/refund.spec.js @@ -3,12 +3,11 @@ const LoopBackContext = require('loopback-context'); describe('Sale refund()', () => { const userId = 5; - const ctx = {req: {accessToken: userId}}; const activeCtx = { - accessToken: {userId}, + accessToken: {userId: userId}, }; + const servicesIds = [3]; - const withWarehouse = true; beforeEach(() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ @@ -23,7 +22,7 @@ describe('Sale refund()', () => { try { const options = {transaction: tx}; - const refundedTicket = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, options); + const refundedTicket = await models.Sale.refund(salesIds, servicesIds, options); expect(refundedTicket).toBeDefined(); @@ -41,7 +40,7 @@ describe('Sale refund()', () => { try { const options = {transaction: tx}; - const ticket = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, options); + const ticket = await models.Sale.refund(salesIds, servicesIds, options); const refundedTicket = await models.Ticket.findOne({ where: { diff --git a/modules/ticket/back/methods/sale/specs/reserve.spec.js b/modules/ticket/back/methods/sale/specs/reserve.spec.js index 7ba5999b3..259cb8cd5 100644 --- a/modules/ticket/back/methods/sale/specs/reserve.spec.js +++ b/modules/ticket/back/methods/sale/specs/reserve.spec.js @@ -52,7 +52,7 @@ describe('sale reserve()', () => { try { const options = {transaction: tx}; - originalTicketSales = await models.Ticket.getSales(ctx, 11, options); + originalTicketSales = await models.Ticket.getSales(11, options); expect(originalTicketSales[0].reserved).toEqual(false); expect(originalTicketSales[1].reserved).toEqual(false); @@ -63,7 +63,7 @@ describe('sale reserve()', () => { await models.Sale.reserve(ctx, ticketId, sales, reserved, options); - const reservedTicketSales = await models.Ticket.getSales(ctx, ticketId, options); + const reservedTicketSales = await models.Ticket.getSales(ticketId, options); expect(reservedTicketSales[0].reserved).toEqual(true); expect(reservedTicketSales[1].reserved).toEqual(true); diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index 649395da6..505de5180 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -31,7 +31,7 @@ module.exports = Self => { Self.updatePrice = async(ctx, id, newPrice, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/sale/usesMana.js b/modules/ticket/back/methods/sale/usesMana.js index 75d8cdda7..3f55293bf 100644 --- a/modules/ticket/back/methods/sale/usesMana.js +++ b/modules/ticket/back/methods/sale/usesMana.js @@ -22,7 +22,7 @@ module.exports = Self => { Object.assign(myOptions, options); const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions); - const departments = await models.Department.getLeaves(ctx, salesDepartment.id, null, myOptions); + const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions); const workerDepartment = await models.WorkerDepartment.findById(userId, null, myOptions); if (!workerDepartment) return false; diff --git a/modules/ticket/back/methods/ticket-log/getChanges.js b/modules/ticket/back/methods/ticket-log/getChanges.js index 1b74ec1d7..7a6de49e8 100644 --- a/modules/ticket/back/methods/ticket-log/getChanges.js +++ b/modules/ticket/back/methods/ticket-log/getChanges.js @@ -61,15 +61,15 @@ module.exports = Self => { const oldQuantity = log.oldInstance.quantity; const newQuantity = log.newInstance?.quantity || 0; - if (oldQuantity > newQuantity) { - const changeMessage = $t('Change quantity', { - concept: log.changedModelValue, - oldQuantity: oldQuantity || 0, - newQuantity: newQuantity || 0, - }); - changes.push(changeMessage); + if (oldQuantity || newQuantity) { + const changeMessage = $t('Change quantity', { + concept: log.changedModelValue, + oldQuantity: oldQuantity || 0, + newQuantity: newQuantity || 0, + }); + changes.push(changeMessage); } - } + } return changes.join('\n'); }; diff --git a/modules/ticket/back/methods/ticket-log/specs/getChanges.spec.js b/modules/ticket/back/methods/ticket-log/specs/getChanges.spec.js index 04f42f7be..c0f7dde0e 100644 --- a/modules/ticket/back/methods/ticket-log/specs/getChanges.spec.js +++ b/modules/ticket/back/methods/ticket-log/specs/getChanges.spec.js @@ -7,7 +7,7 @@ describe('ticketLog getChanges()', () => { return value; }; it('should return the changes in the sales of a ticket', async() => { - const ticketId = 16; + const ticketId = 7; const changues = await models.TicketLog.getChanges(ctx, ticketId); diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index 2061ca355..f7f7fbc2a 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -34,7 +34,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; const $t = ctx.req.__; // $translate - const myOptions = {userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/addSale.js b/modules/ticket/back/methods/ticket/addSale.js index 85b0510ae..37d97b2c7 100644 --- a/modules/ticket/back/methods/ticket/addSale.js +++ b/modules/ticket/back/methods/ticket/addSale.js @@ -35,7 +35,7 @@ module.exports = Self => { Self.addSale = async(ctx, id, itemId, quantity, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 660c16893..6690126b9 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); const closure = require('./closure'); module.exports = Self => { - Self.remoteMethodCtx('closeAll', { + Self.remoteMethod('closeAll', { description: 'Makes the closure process from all warehouses', accessType: 'WRITE', accepts: [], @@ -16,7 +16,7 @@ module.exports = Self => { } }); - Self.closeAll = async ctx => { + Self.closeAll = async() => { const toDate = Date.vnNew(); toDate.setHours(0, 0, 0, 0); toDate.setDate(toDate.getDate() - 1); @@ -59,7 +59,7 @@ module.exports = Self => { GROUP BY t.id `, [toDate, toDate]); - await closure(ctx, Self, tickets); + await closure(Self, tickets); await Self.rawSql(` UPDATE ticket t @@ -73,7 +73,7 @@ module.exports = Self => { AND util.dayEnd(?) AND al.code NOT IN('DELIVERED','PACKED') AND t.routeFk - AND z.name LIKE '%MADRID%'`, [toDate, toDate], {userId: ctx.req.accessToken.userId}); + AND z.name LIKE '%MADRID%'`, [toDate, toDate]); return { message: 'Success' diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index eee5e28e2..9b3355d6c 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -4,14 +4,13 @@ const smtp = require('vn-print/core/smtp'); const config = require('vn-print/core/config'); const storage = require('vn-print/core/storage'); -module.exports = async function(ctx, Self, tickets, reqArgs = {}) { - const userId = ctx.req.accessToken.userId; +module.exports = async function(Self, tickets, reqArgs = {}) { if (tickets.length == 0) return; const failedtickets = []; for (const ticket of tickets) { try { - await Self.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id], {userId}); + await Self.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id]); const [invoiceOut] = await Self.rawSql(` SELECT io.id, io.ref, io.serial, cny.code companyCode, io.issued @@ -53,7 +52,7 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { fileName: fileName }); - await Self.rawSql('UPDATE invoiceOut SET hasPdf = true WHERE id = ?', [invoiceOut.id], {userId}); + await Self.rawSql('UPDATE invoiceOut SET hasPdf = true WHERE id = ?', [invoiceOut.id]); if (isToBeMailed) { const invoiceAttachment = { @@ -92,7 +91,7 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { // Incoterms authorization const [{firstOrder}] = await Self.rawSql(` SELECT COUNT(*) as firstOrder - FROM ticket t + FROM ticket t JOIN client c ON c.id = t.clientFk WHERE t.clientFk = ? AND NOT t.isDeleted @@ -112,14 +111,14 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { await email.send(); const [sample] = await Self.rawSql( - `SELECT id - FROM sample + `SELECT id + FROM sample WHERE code = 'incoterms-authorization' `); await Self.rawSql(` INSERT INTO clientSample (clientFk, typeFk, companyFk) VALUES(?, ?, ?) - `, [ticket.clientFk, sample.id, ticket.companyFk], {userId}); + `, [ticket.clientFk, sample.id, ticket.companyFk]); } } catch (error) { // Domain not found @@ -153,23 +152,23 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { async function invalidEmail(ticket) { await Self.rawSql(`UPDATE client SET email = NULL WHERE id = ?`, [ ticket.clientFk - ], {userId}); + ]); const oldInstance = `{"email": "${ticket.recipient}"}`; const newInstance = `{"email": ""}`; await Self.rawSql(` - INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance) + INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance) VALUES (?, NULL, 'UPDATE', 'Client', ?, ?)`, [ ticket.clientFk, oldInstance, newInstance - ], {userId}); + ]); - const body = `No se ha podido enviar el albarán ${ticket.id} - al cliente ${ticket.clientFk} - ${ticket.clientName} - porque la dirección de email "${ticket.recipient}" no es correcta + const body = `No se ha podido enviar el albarán ${ticket.id} + al cliente ${ticket.clientFk} - ${ticket.clientName} + porque la dirección de email "${ticket.recipient}" no es correcta o no está disponible.

- Para evitar que se repita este error, se ha eliminado la dirección de email de la ficha del cliente. + Para evitar que se repita este error, se ha eliminado la dirección de email de la ficha del cliente. Actualiza la dirección de email con una correcta.`; smtp.send({ diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index a8b631d7c..dac8e4f52 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -101,7 +101,7 @@ module.exports = Self => { Self.componentUpdate = async(ctx, options) => { const args = ctx.args; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/getSales.js b/modules/ticket/back/methods/ticket/getSales.js index e721d90ae..321e8e24e 100644 --- a/modules/ticket/back/methods/ticket/getSales.js +++ b/modules/ticket/back/methods/ticket/getSales.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethodCtx('getSales', { + Self.remoteMethod('getSales', { description: 'New filter', accessType: 'READ', accepts: [{ @@ -20,10 +20,10 @@ module.exports = Self => { } }); - Self.getSales = async(ctx, id, options) => { + Self.getSales = async(id, options) => { const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index ee82b874f..d8ec5eb9a 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -28,7 +28,7 @@ module.exports = function(Self) { const date = Date.vnNew(); date.setHours(0, 0, 0, 0); - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index b461fb26d..5f7cf3cb6 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -59,9 +59,9 @@ module.exports = Self => { Self.new = async(ctx, options) => { const args = ctx.args; - const userId = ctx.req.accessToken.userId; + const myUserId = ctx.req.accessToken.userId; const models = Self.app.models; - const myOptions = {userId}; + const myOptions = {}; let tx; if (typeof options == 'object') @@ -123,7 +123,7 @@ module.exports = Self => { args.routeId || null, args.landed, true, - userId + myUserId ], myOptions); const ticket = await models.Ticket.findById(result[1][0].newTicketId, null, myOptions); diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index 42a71f1c8..27fdb9160 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -60,7 +60,7 @@ module.exports = Self => { Self.priceDifference = async(ctx, options) => { const args = ctx.args; const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/recalculateComponents.js b/modules/ticket/back/methods/ticket/recalculateComponents.js index eb9c8a72e..5b9e8e5dc 100644 --- a/modules/ticket/back/methods/ticket/recalculateComponents.js +++ b/modules/ticket/back/methods/ticket/recalculateComponents.js @@ -21,7 +21,7 @@ module.exports = Self => { }); Self.recalculateComponents = async(ctx, id, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/refund.js b/modules/ticket/back/methods/ticket/refund.js index c99b6aa83..91f48cfd6 100644 --- a/modules/ticket/back/methods/ticket/refund.js +++ b/modules/ticket/back/methods/ticket/refund.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('refund', { + Self.remoteMethod('refund', { description: 'Create refund tickets with all their sales and services', accessType: 'WRITE', accepts: [ @@ -7,11 +7,6 @@ module.exports = Self => { arg: 'ticketsIds', type: ['number'], required: true - }, - { - arg: 'withWarehouse', - type: 'boolean', - required: true } ], returns: { @@ -24,7 +19,7 @@ module.exports = Self => { } }); - Self.refund = async(ctx, ticketsIds, withWarehouse, options) => { + Self.refund = async(ticketsIds, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -46,7 +41,7 @@ module.exports = Self => { const services = await models.TicketService.find(filter, myOptions); const servicesIds = services.map(service => service.id); - const refundedTickets = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, myOptions); + const refundedTickets = await models.Sale.refund(salesIds, servicesIds, myOptions); if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index 55d2e3281..b8f9d5ced 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -31,7 +31,7 @@ module.exports = Self => { Self.saveSign = async(ctx, tickets, location, signedTime, options) => { const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; let dms; let gestDocCreated = false; diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index 7cc300547..228e2e765 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -24,7 +24,7 @@ module.exports = Self => { Self.setDeleted = async(ctx, id, options) => { const models = Self.app.models; const $t = ctx.req.__; // $translate - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/specs/getSales.spec.js b/modules/ticket/back/methods/ticket/specs/getSales.spec.js index 7c0a67d45..b9f78e40b 100644 --- a/modules/ticket/back/methods/ticket/specs/getSales.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getSales.spec.js @@ -1,14 +1,13 @@ const models = require('vn-loopback/server/server').models; describe('ticket getSales()', () => { - const ctx = {req: {accessToken: 9}}; it('should return the sales of a ticket', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; - const sales = await models.Ticket.getSales(ctx, 16, options); + const sales = await models.Ticket.getSales(16, options); expect(sales.length).toEqual(4); expect(sales[0].item).toBeDefined(); diff --git a/modules/ticket/back/methods/ticket/specs/summary.spec.js b/modules/ticket/back/methods/ticket/specs/summary.spec.js index 2c4aedf1e..5d2991b0a 100644 --- a/modules/ticket/back/methods/ticket/specs/summary.spec.js +++ b/modules/ticket/back/methods/ticket/specs/summary.spec.js @@ -1,14 +1,13 @@ const models = require('vn-loopback/server/server').models; describe('ticket summary()', () => { - const ctx = {req: {accessToken: 9}}; it('should return a summary object containing data from 1 ticket', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; - const result = await models.Ticket.summary(ctx, 1, options); + const result = await models.Ticket.summary(1, options); expect(result.id).toEqual(1); expect(result.nickname).toEqual('Bat cave'); @@ -26,7 +25,7 @@ describe('ticket summary()', () => { try { const options = {transaction: tx}; - const result = await models.Ticket.summary(ctx, 1, options); + const result = await models.Ticket.summary(1, options); expect(result.sales.length).toEqual(4); @@ -43,7 +42,7 @@ describe('ticket summary()', () => { try { const options = {transaction: tx}; - const result = await models.Ticket.summary(ctx, 1, options); + const result = await models.Ticket.summary(1, options); expect(result.totalWithoutVat).toEqual(jasmine.any(Number)); @@ -60,7 +59,7 @@ describe('ticket summary()', () => { try { const options = {transaction: tx}; - const result = await models.Ticket.summary(ctx, 1, options); + const result = await models.Ticket.summary(1, options); expect(result.totalWithVat).toEqual(jasmine.any(Number)); diff --git a/modules/ticket/back/methods/ticket/specs/transferSales.spec.js b/modules/ticket/back/methods/ticket/specs/transferSales.spec.js index 562688917..270aae2f8 100644 --- a/modules/ticket/back/methods/ticket/specs/transferSales.spec.js +++ b/modules/ticket/back/methods/ticket/specs/transferSales.spec.js @@ -67,7 +67,7 @@ describe('sale transferSales()', () => { const ticketId = 11; const receiverTicketId = null; - const sales = await models.Ticket.getSales(ctx, ticketId, options); + const sales = await models.Ticket.getSales(ticketId, options); await models.Ticket.transferSales(ctx, ticketId, receiverTicketId, sales, options); @@ -89,7 +89,7 @@ describe('sale transferSales()', () => { const formerTicketId = 22; let createdTicketId = undefined; - let formerTicketSales = await models.Ticket.getSales(ctx, formerTicketId, options); + let formerTicketSales = await models.Ticket.getSales(formerTicketId, options); expect(formerTicketSales.length).toEqual(2); @@ -98,8 +98,8 @@ describe('sale transferSales()', () => { createdTicketId = createdTicket.id; - formerTicketSales = await models.Ticket.getSales(ctx, formerTicketId, options); - let createdTicketSales = await models.Ticket.getSales(ctx, createdTicketId, options); + formerTicketSales = await models.Ticket.getSales(formerTicketId, options); + let createdTicketSales = await models.Ticket.getSales(createdTicketId, options); expect(formerTicketSales.length).toEqual(0); expect(createdTicketSales.length).toEqual(2); @@ -120,7 +120,7 @@ describe('sale transferSales()', () => { const options = {transaction: tx}; const currentTicketId = 22; - const currentTicketSales = await models.Ticket.getSales(ctx, currentTicketId, options); + const currentTicketSales = await models.Ticket.getSales(currentTicketId, options); const receiverTicketId = undefined; @@ -147,7 +147,7 @@ describe('sale transferSales()', () => { const formerTicketId = 22; let createdTicketId = undefined; - let formerTicketSales = await models.Ticket.getSales(ctx, formerTicketId, options); + let formerTicketSales = await models.Ticket.getSales(formerTicketId, options); const completeSaleId = formerTicketSales[1].id; let partialSaleTotalQuantity = formerTicketSales[0].quantity; @@ -161,8 +161,8 @@ describe('sale transferSales()', () => { createdTicketId = createdTicket.id; - formerTicketSales = await models.Ticket.getSales(ctx, formerTicketId, options); - createdTicketSales = await models.Ticket.getSales(ctx, createdTicketId, options); + formerTicketSales = await models.Ticket.getSales(formerTicketId, options); + createdTicketSales = await models.Ticket.getSales(createdTicketId, options); const [createdPartialSale] = createdTicketSales.filter(sale => { return sale.id != completeSaleId; diff --git a/modules/ticket/back/methods/ticket/summary.js b/modules/ticket/back/methods/ticket/summary.js index 1ce91e1b2..a57968fc1 100644 --- a/modules/ticket/back/methods/ticket/summary.js +++ b/modules/ticket/back/methods/ticket/summary.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('summary', { + Self.remoteMethod('summary', { description: 'Returns a ticket summary', accessType: 'READ', accepts: [{ @@ -19,7 +19,7 @@ module.exports = Self => { } }); - Self.summary = async(ctx, ticketFk, options) => { + Self.summary = async(ticketFk, options) => { const models = Self.app.models; const myOptions = {}; @@ -28,7 +28,7 @@ module.exports = Self => { const summaryObj = await getTicketData(Self, ticketFk, myOptions); - summaryObj.sales = await models.Ticket.getSales(ctx, ticketFk, myOptions); + summaryObj.sales = await models.Ticket.getSales(ticketFk, myOptions); summaryObj.packagings = await models.TicketPackaging.find({ where: {ticketFk: ticketFk}, diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 01ada49d0..5737e628f 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -36,7 +36,7 @@ module.exports = Self => { Self.transferSales = async(ctx, id, ticketId, sales, options) => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; - const myOptions = {userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 6feeafa1a..4b31c0ce4 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -44,7 +44,7 @@ module.exports = Self => { Self.updateDiscount = async(ctx, id, salesIds, newDiscount, manaCode, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json index 3c7e12eea..bee01a875 100644 --- a/modules/ticket/back/model-config.json +++ b/modules/ticket/back/model-config.json @@ -100,8 +100,5 @@ }, "TicketConfig": { "dataSource": "vn" - }, - "PackingSiteAdvanced": { - "dataSource": "vn" } } diff --git a/modules/ticket/back/models/ticket-log.json b/modules/ticket/back/models/ticket-log.json index d5d1e5520..df04348da 100644 --- a/modules/ticket/back/models/ticket-log.json +++ b/modules/ticket/back/models/ticket-log.json @@ -1,9 +1,58 @@ { - "name": "TicketLog", + "name": "TicketLog", "base": "Log", - "options": { - "mysql": { - "table": "ticketLog" + "options": { + "mysql": { + "table": "ticketLog" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "number" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index e6f16c965..c937fe2ac 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -150,7 +150,7 @@ {{::ticket.futureIpt | dashIfEmpty}} + class="chip {{ticket.classColor}}"> {{::ticket.futureState | dashIfEmpty}} diff --git a/modules/ticket/front/advance/index.js b/modules/ticket/front/advance/index.js index 0cec41227..7b8008426 100644 --- a/modules/ticket/front/advance/index.js +++ b/modules/ticket/front/advance/index.js @@ -102,6 +102,13 @@ export default class Controller extends Section { return checkedLines; } + stateColor(state) { + if (state === 'OK') + return 'success'; + else if (state === 'Libre') + return 'notice'; + } + dateRange(value) { const minHour = new Date(value); minHour.setHours(0, 0, 0, 0); diff --git a/modules/ticket/front/advance/index.spec.js b/modules/ticket/front/advance/index.spec.js index da8614ca5..6874f914b 100644 --- a/modules/ticket/front/advance/index.spec.js +++ b/modules/ticket/front/advance/index.spec.js @@ -61,6 +61,24 @@ describe('Component vnTicketAdvance', () => { }); }); + describe('stateColor()', () => { + it('should return success to the OK tickets', () => { + const ok = controller.stateColor(controller.$.model.data[0].state); + const notOk = controller.stateColor(controller.$.model.data[1].state); + + expect(ok).toEqual('success'); + expect(notOk).not.toEqual('success'); + }); + + it('should return success to the FREE tickets', () => { + const notFree = controller.stateColor(controller.$.model.data[0].state); + const free = controller.stateColor(controller.$.model.data[1].state); + + expect(free).toEqual('notice'); + expect(notFree).not.toEqual('notice'); + }); + }); + describe('dateRange()', () => { it('should return two dates with the hours at the start and end of the given date', () => { const now = Date.vnNew(); diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index afa5db41a..c2ebc3e3a 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -141,27 +141,12 @@ translate> Recalculate components - - Refund all... - - - - with warehouse - - - without warehouse - - - + Refund all @@ -334,6 +319,14 @@ message="Recalculate components"> + + + + this.vnApp.showSuccess(this.$t('Data saved!'))); } - refund(withWarehouse) { - const params = {ticketsIds: [this.id], withWarehouse: withWarehouse}; + async refund() { + const params = {ticketsIds: [this.id]}; const query = 'Tickets/refund'; - return this.$http.post(query, params) - .then(res => { - const refundTicket = res.data; - this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { - ticketId: refundTicket.id - })); - this.$state.go('ticket.card.sale', {id: refundTicket.id}); - }); + return this.$http.post(query, params).then(res => { + const refundTicket = res.data; + this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { + ticketId: refundTicket.id + })); + this.$state.go('ticket.card.sale', {id: refundTicket.id}); + }); } onSmsSend(sms) { @@ -326,8 +325,14 @@ class Controller extends Section { if (!force) return this.$.pdfToTablet.show(); - return this.$http.post(`Docuwares/upload`, {fileCabinet: 'deliveryNote', ticketIds: [this.id]}) + return this.$http.post(`Docuwares/${this.id}/upload`, {fileCabinet: 'deliveryNote'}) .then(() => { + this.$.balanceCreate.amountPaid = this.ticket.totalWithVat; + this.$.balanceCreate.clientFk = this.ticket.clientFk; + this.$.balanceCreate.description = 'Albaran: '; + this.$.balanceCreate.description += this.ticket.id; + + this.$.balanceCreate.show(); this.vnApp.showSuccess(this.$t('PDF sent!')); }); } diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 0aef956db..5d27acff1 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -304,15 +304,17 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { expect(controller.$.pdfToTablet.show).toHaveBeenCalled(); }); - it('should make a query', () => { + it('should make a query and show balance create', () => { controller.$.balanceCreate = {show: () => {}}; + jest.spyOn(controller.$.balanceCreate, 'show'); jest.spyOn(controller.vnApp, 'showSuccess'); - $httpBackend.whenPOST(`Docuwares/upload`).respond(true); + $httpBackend.whenPOST(`Docuwares/${ticket.id}/upload`).respond(true); controller.uploadDocuware(true); $httpBackend.flush(); expect(controller.vnApp.showSuccess).toHaveBeenCalled(); + expect(controller.$.balanceCreate.show).toHaveBeenCalled(); }); }); diff --git a/modules/ticket/front/descriptor-menu/locale/es.yml b/modules/ticket/front/descriptor-menu/locale/es.yml index 3830523cf..b51637524 100644 --- a/modules/ticket/front/descriptor-menu/locale/es.yml +++ b/modules/ticket/front/descriptor-menu/locale/es.yml @@ -10,9 +10,7 @@ Send CSV: Enviar CSV Send CSV Delivery Note: Enviar albarán en CSV Send PDF Delivery Note: Enviar albarán en PDF Show Proforma: Ver proforma -Refund all...: Abonar todo... -with warehouse: con almacén -without warehouse: sin almacén +Refund all: Abonar todo Invoice sent: Factura enviada The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}" Transfer client: Transferir cliente @@ -20,4 +18,3 @@ SMS Notify changes: SMS Notificar cambios PDF sent!: ¡PDF enviado! Already exist signed delivery note: Ya existe albarán de entrega firmado Are you sure you want to replace this delivery note?: ¿Seguro que quieres reemplazar este albarán de entrega? -Create a single ticket with all the content of the current ticket: Crea un ticket único con todo el contenido del ticket actual diff --git a/modules/ticket/front/descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml index 3da013467..d921b5dc2 100644 --- a/modules/ticket/front/descriptor/locale/es.yml +++ b/modules/ticket/front/descriptor/locale/es.yml @@ -23,4 +23,4 @@ Restore ticket: Restaurar ticket You are going to restore this ticket: Vas a restaurar este ticket Are you sure you want to restore this ticket?: ¿Seguro que quieres restaurar el ticket? Are you sure you want to refund all?: ¿Seguro que quieres abonar todo? -Send changes: "Verdnatura:\rPedido {{ticketId}}\r{{changes}}" +Send changes: "Verdnatura le recuerda:\rPedido {{ticketId}} día {{created | date: 'dd/MM/yyyy'}}\r{{changes}}" diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 831b8ef7e..447411f3a 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -7,12 +7,10 @@ order="created DESC" auto-load="true"> - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - Expedition - - Item - - Name - - Package Type - - Counter - - externalId - - Created - - State -
- - - {{expedition.id}} - - {{expedition.packagingItemFk}} - - {{::expedition.packageItemName}}{{::expedition.freightItemName}}{{::expedition.counter}}{{::expedition.externalId}}{{::expedition.created | date:'dd/MM/yyyy HH:mm'}}{{::expedition.state}} - - -
-
-
-
+ + +

Subtotal {{$ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

+

VAT {{$ctrl.ticket.totalWithVat - $ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

+

Total {{$ctrl.ticket.totalWithVat | currency: 'EUR':2}}

+
+ + + + + + + + + Expedition + Item + Name + Package type + Counter + externalId + Created + State + + + + + + + + + + {{expedition.id}} + + + {{expedition.packagingFk}} + + + {{::expedition.packageItemName}} + {{::expedition.freightItemName}} + {{::expedition.counter}} + {{::expedition.externalId}} + {{::expedition.created | date:'dd/MM/yyyy HH:mm'}} + {{::expedition.state}} + + + + + + + + + {{::ticket.futureIpt | dashIfEmpty}} + class="chip {{ticket.classColor}}"> {{::ticket.futureState}} diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index d6e230ebe..1e18ce284 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -9,7 +9,7 @@ - @@ -33,7 +33,7 @@ class="clickable vn-tr search-result" ui-sref="ticket.card.summary({id: {{::ticket.id}}})"> - @@ -109,7 +109,7 @@ class="link"> {{::ticket.refFk}} - {{ticket.state}} @@ -132,8 +132,8 @@
- - - - - - Filter by selection - Exclude selection - Remove filter - Remove all filters - Copy value @@ -241,4 +241,4 @@ on-accept="$ctrl.makeInvoice()" question="{{$ctrl.confirmationMessage}}" message="Invoice selected tickets"> - + \ No newline at end of file diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 55229eabb..42332ccc8 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -9,23 +9,28 @@ export default class Controller extends Section { this.vnReport = vnReport; } - sendDocuware() { + setDelivered() { const checkedTickets = this.checked; - let ticketIds = []; + let ids = []; for (let ticket of checkedTickets) - ticketIds.push(ticket.id); + ids.push(ticket.id); - return this.$http.post(`Docuwares/upload`, {fileCabinet: 'deliveryNote', ticketIds}) - .then(res => { - let state = res.data; - for (let ticket of checkedTickets) { - ticket.stateFk = state.id; - ticket.state = state.name; - ticket.alertLevel = state.alertLevel; - ticket.alertLevelCode = state.code; - } - }); + this.$http.post('TicketTrackings/setDelivered', ids).then(res => { + let state = res.data; + for (let ticket of checkedTickets) { + ticket.stateFk = state.id; + ticket.state = state.name; + ticket.alertLevel = state.alertLevel; + ticket.alertLevelCode = state.code; + } + this.openDeliveryNotes(ids); + }); + } + + openDeliveryNotes(ids) { + for (let id of ids) + this.vnReport.show(`Tickets/${id}/delivery-note-pdf`); } openBalanceDialog() { diff --git a/modules/ticket/front/index/index.spec.js b/modules/ticket/front/index/index.spec.js index 951c6aa09..5046387b0 100644 --- a/modules/ticket/front/index/index.spec.js +++ b/modules/ticket/front/index/index.spec.js @@ -12,14 +12,12 @@ describe('Component vnTicketIndex', () => { id: 2, clientFk: 1, checked: true, - totalWithVat: 20.5, - stateFk: 1 + totalWithVat: 20.5 }, { id: 3, clientFk: 1, checked: true, - totalWithVat: 30, - stateFk: 1 + totalWithVat: 30 }]; beforeEach(ngModule('ticket')); @@ -88,16 +86,18 @@ describe('Component vnTicketIndex', () => { }); }); - describe('sendDocuware()', () => { - it('should perform a post to sendDocuware and change tickets state', () => { + describe('setDelivered()/openDeliveryNotes()', () => { + it('should perform a post to setDelivered and open tabs with the delivery notes', () => { controller.$.model = {data: tickets, refresh: () => {}}; - const newState = {id: 2}; - $httpBackend.expect('POST', 'Docuwares/upload').respond({id: newState.id}); - controller.sendDocuware(); + $window.open = jest.fn(); + + $httpBackend.expect('POST', 'TicketTrackings/setDelivered').respond('ok'); + controller.setDelivered(); $httpBackend.flush(); - expect(controller.$.model.data[1].stateFk).toEqual(newState.id); + expect($window.open).toHaveBeenCalledWith(`api/Tickets/${tickets[1].id}/delivery-note-pdf`); + expect($window.open).toHaveBeenCalledWith(`api/Tickets/${tickets[2].id}/delivery-note-pdf`); }); }); diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index f50ef10a5..7d14a4fa3 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -529,28 +529,11 @@ ng-if="$ctrl.isEditable && $ctrl.hasReserves()"> Unmark as reserved - - Refund... - - - - with warehouse - - - without warehouse - - - - + + Refund + diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 88a59e605..72dfb0329 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -520,12 +520,13 @@ class Controller extends Section { }); } - createRefund(withWarehouse) { + createRefund() { const sales = this.selectedValidSales(); if (!sales) return; const salesIds = sales.map(sale => sale.id); - const params = {salesIds: salesIds, withWarehouse: withWarehouse}; + + const params = {salesIds: salesIds}; const query = 'Sales/refund'; this.$http.post(query, params).then(res => { const refundTicket = res.data; diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml index 0b1fd84ea..6eb558a56 100644 --- a/modules/ticket/front/sale/locale/es.yml +++ b/modules/ticket/front/sale/locale/es.yml @@ -36,10 +36,10 @@ Warehouse: Almacen Agency: Agencia Shipped: F. envio Packaging: Encajado -Refund...: Abono... +Refund: Abono Promotion mana: Maná promoción Claim mana: Maná reclamación History: Historial Do you want to continue?: ¿Desea continuar? Claim out of time: Reclamación fuera de plazo -Do you want to create a claim?: ¿Quieres crear una reclamación? +Do you want to create a claim?: ¿Quieres crear una reclamación? \ No newline at end of file diff --git a/modules/travel/back/methods/thermograph/createThermograph.js b/modules/travel/back/methods/thermograph/createThermograph.js index 243e2129f..75d967628 100644 --- a/modules/travel/back/methods/thermograph/createThermograph.js +++ b/modules/travel/back/methods/thermograph/createThermograph.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('createThermograph', { + Self.remoteMethod('createThermograph', { description: 'Creates a new thermograph', accessType: 'WRITE', accepts: [{ @@ -36,10 +36,10 @@ module.exports = Self => { } }); - Self.createThermograph = async(ctx, thermographId, model, temperatureFk, warehouseId, options) => { + Self.createThermograph = async(thermographId, model, temperatureFk, warehouseId, options) => { const models = Self.app.models; let tx; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; const date = Date.vnNew(); if (typeof options == 'object') diff --git a/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js b/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js index 90855bf81..32014e303 100644 --- a/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js +++ b/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js @@ -5,7 +5,6 @@ describe('Termograph createThermograph()', () => { const model = 'DISPOSABLE'; const temperatureFk = 'COOL'; const warehouseId = 1; - const ctx = {req: {accessToken: {userId: 9}}}; it(`should create a thermograph which is saved in both thermograph and travelThermograph`, async() => { const tx = await models.Thermograph.beginTransaction({}); @@ -13,7 +12,7 @@ describe('Termograph createThermograph()', () => { try { const options = {transaction: tx}; - const createdThermograph = await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options); + const createdThermograph = await models.Thermograph.createThermograph(thermographId, model, temperatureFk, warehouseId, options); expect(createdThermograph.id).toEqual(thermographId); expect(createdThermograph.model).toEqual(model); @@ -38,8 +37,8 @@ describe('Termograph createThermograph()', () => { try { const options = {transaction: tx}; - await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options); - await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options); + await models.Thermograph.createThermograph(thermographId, model, temperatureFk, warehouseId, options); + await models.Thermograph.createThermograph(thermographId, model, temperatureFk, warehouseId, options); await tx.rollback(); } catch (e) { diff --git a/modules/travel/back/methods/travel/deleteThermograph.js b/modules/travel/back/methods/travel/deleteThermograph.js index d22fc8b29..ba541c560 100644 --- a/modules/travel/back/methods/travel/deleteThermograph.js +++ b/modules/travel/back/methods/travel/deleteThermograph.js @@ -26,9 +26,9 @@ module.exports = Self => { await models.Dms.removeFile(ctx, travelThermograph.dmsFk); await Self.rawSql(` - UPDATE travelThermograph - SET travelFk = NULL, dmsFk = NULL - WHERE id = ?`, [id], {userId}); + UPDATE travelThermograph + SET travelFk = NULL, dmsFk = NULL + WHERE id = ?`, [id]); const oldInstance = { travelFk: travelThermograph.travelFk, diff --git a/modules/travel/back/model-config.json b/modules/travel/back/model-config.json index ed5c071b3..34321ba78 100644 --- a/modules/travel/back/model-config.json +++ b/modules/travel/back/model-config.json @@ -14,9 +14,6 @@ "TravelThermograph": { "dataSource": "vn" }, - "TravelConfig": { - "dataSource": "vn" - }, "Temperature": { "dataSource": "vn" } diff --git a/modules/travel/back/models/travel-log.json b/modules/travel/back/models/travel-log.json index e01d57943..e781c2948 100644 --- a/modules/travel/back/models/travel-log.json +++ b/modules/travel/back/models/travel-log.json @@ -5,5 +5,54 @@ "mysql": { "table": "travelLog" } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "string" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/worker/back/methods/worker-time-control/addTimeEntry.js b/modules/worker/back/methods/worker-time-control/addTimeEntry.js index cc652fb90..bcc96985f 100644 --- a/modules/worker/back/methods/worker-time-control/addTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/addTimeEntry.js @@ -33,15 +33,15 @@ module.exports = Self => { Self.addTimeEntry = async(ctx, workerId, options) => { const models = Self.app.models; const args = ctx.args; - const userId = ctx.req.accessToken.userId; - const myOptions = {userId}; + const currentUserId = ctx.req.accessToken.userId; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); const isSubordinate = await models.Worker.isSubordinate(ctx, workerId, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - const isHimself = userId == workerId; + const isHimself = currentUserId == workerId; if (!isSubordinate || (isSubordinate && isHimself && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); diff --git a/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js b/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js index 8f9541596..80482901f 100644 --- a/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js @@ -22,10 +22,10 @@ module.exports = Self => { }); Self.deleteTimeEntry = async(ctx, id, options) => { - const userId = ctx.req.accessToken.userId; + const currentUserId = ctx.req.accessToken.userId; const models = Self.app.models; - const myOptions = {userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); @@ -33,7 +33,7 @@ module.exports = Self => { const targetTimeEntry = await Self.findById(id, null, myOptions); const isSubordinate = await models.Worker.isSubordinate(ctx, targetTimeEntry.userFk, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - const isHimself = userId == targetTimeEntry.userFk; + const isHimself = currentUserId == targetTimeEntry.userFk; if (isSubordinate === false || (isSubordinate && isHimself && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index ab5e56a77..3d57ebbbd 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -33,7 +33,7 @@ module.exports = Self => { const conn = Self.dataSource.connector; const args = ctx.args; let tx; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index 27acc98ab..398411118 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -119,7 +119,7 @@ module.exports = Self => { Self.new = async(ctx, options) => { const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; + const myOptions = {}; const args = ctx.args; let tx; diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index b2804c203..44f6e9b09 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -36,7 +36,6 @@ describe('Worker new', () => { payMethodFk: 1, roleFk: 1 }; - const req = {accessToken: {userId: 9}}; it('should return error if personal mail already exists', async() => { const user = await models.VnUser.findById(employeeId, {fields: ['email']}); @@ -47,8 +46,7 @@ describe('Worker new', () => { try { const options = {transaction: tx}; const ctx = { - args: Object.assign({}, defaultWorker, {email: user.email}), - req + args: Object.assign({}, defaultWorker, {email: user.email}) }; await models.Worker.new(ctx, options); @@ -71,8 +69,7 @@ describe('Worker new', () => { try { const options = {transaction: tx}; const ctx = { - args: Object.assign({}, defaultWorker, {code: worker.code}), - req + args: Object.assign({}, defaultWorker, {code: worker.code}) }; await models.Worker.new(ctx, options); @@ -95,8 +92,7 @@ describe('Worker new', () => { try { const options = {transaction: tx}; const ctx = { - args: Object.assign({}, defaultWorker, {fi: worker.fi}), - req + args: Object.assign({}, defaultWorker, {fi: worker.fi}) }; await models.Worker.new(ctx, options); @@ -123,8 +119,7 @@ describe('Worker new', () => { try { const options = {transaction: tx}; const ctx = { - args: Object.assign({}, defaultWorker, {payMethodFk: payMethodIbanRequired.id}), - req + args: Object.assign({}, defaultWorker, {payMethodFk: payMethodIbanRequired.id}) }; await models.Worker.new(ctx, options); @@ -138,7 +133,7 @@ describe('Worker new', () => { }); it('should create a new worker', async() => { - const newWorker = await models.Worker.new({args: defaultWorker, req}); + const newWorker = await models.Worker.new({args: defaultWorker}); await models.Worker.destroyById(newWorker.id); await models.Address.destroyAll({clientFk: newWorker.id}); @@ -160,8 +155,7 @@ describe('Worker new', () => { { fi: client.fi, email: client.email - }), - req + }) }; const newWorker = await models.Worker.new(newWorkerData); diff --git a/modules/worker/back/models/device-production-log.json b/modules/worker/back/models/device-production-log.json index b87fe5e6b..71c54a9c1 100644 --- a/modules/worker/back/models/device-production-log.json +++ b/modules/worker/back/models/device-production-log.json @@ -1,14 +1,55 @@ { - "name": "DeviceProductionLog", - "base": "Log", - "options": { - "mysql": { - "table": "deviceProductionLog" - } - }, - "properties": { + "name": "DeviceProductionLog", + "base": "Log", + "options": { + "mysql": { + "table": "deviceProductionLog" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, "deviceProduction": { "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "created": { + "type": "date" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "changedModel": { + "type": "string" + }, + "changedModelId": { + "type": "number" } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["created DESC", "id DESC"] } } diff --git a/modules/worker/back/models/operator.json b/modules/worker/back/models/operator.json index 9433a0fd5..db8a8c451 100644 --- a/modules/worker/back/models/operator.json +++ b/modules/worker/back/models/operator.json @@ -27,10 +27,10 @@ "type": "number", "required": true }, - "sectorFk": { + "sectorFk ": { "type": "number" }, - "labelerFk": { + "labelerFk ": { "type": "number" } }, @@ -41,4 +41,4 @@ "foreignKey": "sectorFk" } } -} +} \ No newline at end of file diff --git a/modules/worker/back/models/worker-log.json b/modules/worker/back/models/worker-log.json index 1ca1ac5ff..6eb8b75be 100644 --- a/modules/worker/back/models/worker-log.json +++ b/modules/worker/back/models/worker-log.json @@ -5,5 +5,54 @@ "mysql": { "table": "workerLog" } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "string" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/zone/back/locale/zone-event/en.yml b/modules/zone/back/locale/zone-event/en.yml index 1988c1239..2d6ef39ab 100644 --- a/modules/zone/back/locale/zone-event/en.yml +++ b/modules/zone/back/locale/zone-event/en.yml @@ -1,14 +1,14 @@ -name: event +name: zone event columns: id: id zoneFk: zone type: type dated: dated - started: starts - ended: ends + started: started + ended: ended weekDays: week days hour: hour travelingDays: traveling days price: price bonus: bonus - m3Max: max. m3 + m3Max: max m3 diff --git a/modules/zone/back/locale/zone-event/es.yml b/modules/zone/back/locale/zone-event/es.yml index 5092cc933..9bc8db9fe 100644 --- a/modules/zone/back/locale/zone-event/es.yml +++ b/modules/zone/back/locale/zone-event/es.yml @@ -1,11 +1,11 @@ -name: evento +name: evento zona columns: id: id zoneFk: zona type: tipo dated: fecha - started: empieza - ended: termina + started: comenzado + ended: terminado weekDays: días semana hour: hora travelingDays: días de viaje diff --git a/modules/zone/back/locale/zone-exclusion/en.yml b/modules/zone/back/locale/zone-exclusion/en.yml index 6a2383b87..4389d8b93 100644 --- a/modules/zone/back/locale/zone-exclusion/en.yml +++ b/modules/zone/back/locale/zone-exclusion/en.yml @@ -1,5 +1,5 @@ -name: exclusion +name: zone exclusion columns: id: id - dated: date + dated: dated zoneFk: zone diff --git a/modules/zone/back/locale/zone-exclusion/es.yml b/modules/zone/back/locale/zone-exclusion/es.yml index 35102a670..4e59cba46 100644 --- a/modules/zone/back/locale/zone-exclusion/es.yml +++ b/modules/zone/back/locale/zone-exclusion/es.yml @@ -1,4 +1,4 @@ -name: exclusión +name: zone exclusion columns: id: id dated: fecha diff --git a/modules/zone/back/locale/zone-included/en.yml b/modules/zone/back/locale/zone-included/en.yml index 65e4faac6..0e44989e9 100644 --- a/modules/zone/back/locale/zone-included/en.yml +++ b/modules/zone/back/locale/zone-included/en.yml @@ -1,7 +1,5 @@ -name: inclusion +name: zone included columns: id: id dated: dated zoneFk: zone - isIncluded: incluida - geoFk: localización diff --git a/modules/zone/back/locale/zone-included/es.yml b/modules/zone/back/locale/zone-included/es.yml index bd48cdbe5..30a89373a 100644 --- a/modules/zone/back/locale/zone-included/es.yml +++ b/modules/zone/back/locale/zone-included/es.yml @@ -1,7 +1,5 @@ -name: inclusión +name: zona incluida columns: id: id dated: fecha zoneFk: zona - isIncluded: incluida - geoFk: localización diff --git a/modules/zone/back/locale/zone-warehouse/en.yml b/modules/zone/back/locale/zone-warehouse/en.yml index 6caa3de1b..b9c4f7609 100644 --- a/modules/zone/back/locale/zone-warehouse/en.yml +++ b/modules/zone/back/locale/zone-warehouse/en.yml @@ -1,4 +1,4 @@ -name: warehouse +name: zone warehouse columns: id: id warehouseFk: warehouse diff --git a/modules/zone/back/locale/zone-warehouse/es.yml b/modules/zone/back/locale/zone-warehouse/es.yml index caf0d8f1a..ec8dec2dd 100644 --- a/modules/zone/back/locale/zone-warehouse/es.yml +++ b/modules/zone/back/locale/zone-warehouse/es.yml @@ -1,4 +1,4 @@ -name: almacén +name: almacén zona columns: id: id warehouseFk: almacén diff --git a/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js b/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js index c8ab4f67c..846ad6a3d 100644 --- a/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js +++ b/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('getAgenciesWithWarehouse', { + Self.remoteMethod('getAgenciesWithWarehouse', { description: 'Returns a list of agencies that can land a shipment on a day for an address and a warehouse', accepts: [ { @@ -28,8 +28,8 @@ module.exports = Self => { } }); - Self.getAgenciesWithWarehouse = async(ctx, addressFk, landed, warehouseFk, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; + Self.getAgenciesWithWarehouse = async(addressFk, landed, warehouseFk, options) => { + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/agency/landsThatDay.js b/modules/zone/back/methods/agency/landsThatDay.js index 4d73e4d08..b7f13ddda 100644 --- a/modules/zone/back/methods/agency/landsThatDay.js +++ b/modules/zone/back/methods/agency/landsThatDay.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('landsThatDay', { + Self.remoteMethod('landsThatDay', { description: 'Returns a list of agencies that can land a shipment on a day for an address', accepts: [ { @@ -22,8 +22,8 @@ module.exports = Self => { } }); - Self.landsThatDay = async(ctx, addressFk, landed, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; + Self.landsThatDay = async(addressFk, landed, options) => { + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js b/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js index f760559cb..4f79b2315 100644 --- a/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js +++ b/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js @@ -2,7 +2,6 @@ const app = require('vn-loopback/server/server'); describe('Agency getAgenciesWithWarehouse()', () => { const today = Date.vnNew(); - const ctx = {req: {accessToken: {userId: 9}}}; it('should return the agencies that can handle the given delivery request', async() => { const tx = await app.models.Zone.beginTransaction({}); @@ -10,7 +9,7 @@ describe('Agency getAgenciesWithWarehouse()', () => { const options = {transaction: tx}; const addressId = 101; - const agencies = await app.models.Agency.getAgenciesWithWarehouse(ctx, addressId, today, 1, options); + const agencies = await app.models.Agency.getAgenciesWithWarehouse(addressId, today, 1, options); expect(agencies.length).toEqual(3); expect(agencies[0].agencyMode).toEqual('inhouse pickup'); @@ -31,7 +30,7 @@ describe('Agency getAgenciesWithWarehouse()', () => { const options = {transaction: tx}; const addressId = 101; - const agencies = await app.models.Agency.getAgenciesWithWarehouse(ctx, addressId, null, 1, options); + const agencies = await app.models.Agency.getAgenciesWithWarehouse(addressId, null, 1, options); expect(agencies.length).toEqual(0); diff --git a/modules/zone/back/methods/agency/specs/landsThatDay.spec.js b/modules/zone/back/methods/agency/specs/landsThatDay.spec.js index 1ec675071..4bde37984 100644 --- a/modules/zone/back/methods/agency/specs/landsThatDay.spec.js +++ b/modules/zone/back/methods/agency/specs/landsThatDay.spec.js @@ -1,7 +1,6 @@ const {models} = require('vn-loopback/server/server'); describe('Agency landsThatDay()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; const today = Date.vnNew(); it('should return a list of agencies that can land a shipment on a day for an address', async() => { const tx = await models.Agency.beginTransaction({}); @@ -9,7 +8,7 @@ describe('Agency landsThatDay()', () => { try { const options = {transaction: tx}; - const agencies = await models.Agency.landsThatDay(ctx, 101, today, options); + const agencies = await models.Agency.landsThatDay(101, today, options); expect(agencies.length).toBeGreaterThanOrEqual(3); diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index bcfb91e3d..e3846132b 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -26,7 +26,7 @@ module.exports = Self => { today.setHours(0, 0, 0, 0); let tx; - const myOptions = {userId}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/zone/getEvents.js b/modules/zone/back/methods/zone/getEvents.js index 03fb31438..a8ee8bb7b 100644 --- a/modules/zone/back/methods/zone/getEvents.js +++ b/modules/zone/back/methods/zone/getEvents.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethodCtx('getEvents', { + Self.remoteMethod('getEvents', { description: 'Returns delivery days for a postcode', accepts: [ { @@ -25,8 +25,8 @@ module.exports = Self => { } }); - Self.getEvents = async(ctx, geoFk, agencyModeFk, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; + Self.getEvents = async(geoFk, agencyModeFk, options) => { + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/zone/getLeaves.js b/modules/zone/back/methods/zone/getLeaves.js index a6db3b711..680d5ba22 100644 --- a/modules/zone/back/methods/zone/getLeaves.js +++ b/modules/zone/back/methods/zone/getLeaves.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethodCtx('getLeaves', { + Self.remoteMethod('getLeaves', { description: 'Returns the nodes for a zone', accepts: [ { @@ -31,9 +31,8 @@ module.exports = Self => { } }); - Self.getLeaves = async(ctx, id, parentId = null, search, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; - + Self.getLeaves = async(id, parentId = null, search, options) => { + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/zone/getUpcomingDeliveries.js b/modules/zone/back/methods/zone/getUpcomingDeliveries.js index e8b7e7636..2a1c39ed6 100644 --- a/modules/zone/back/methods/zone/getUpcomingDeliveries.js +++ b/modules/zone/back/methods/zone/getUpcomingDeliveries.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('getUpcomingDeliveries', { + Self.remoteMethod('getUpcomingDeliveries', { description: 'Returns the upcomings deliveries', accessType: 'READ', accepts: [], @@ -13,8 +13,8 @@ module.exports = Self => { } }); - Self.getUpcomingDeliveries = async(ctx, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; + Self.getUpcomingDeliveries = async options => { + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/zone/specs/getEvents.spec.js b/modules/zone/back/methods/zone/specs/getEvents.spec.js index c1dee3e0f..d1c51baff 100644 --- a/modules/zone/back/methods/zone/specs/getEvents.spec.js +++ b/modules/zone/back/methods/zone/specs/getEvents.spec.js @@ -1,14 +1,13 @@ const models = require('vn-loopback/server/server').models; describe('zone getEvents()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; it('should return all events for the specified geo and agency mode', async() => { const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await models.Zone.getEvents(ctx, 20, 1, options); + let result = await models.Zone.getEvents(20, 1, options); expect(result.events.length).toEqual(10); diff --git a/modules/zone/back/methods/zone/specs/getLeaves.spec.js b/modules/zone/back/methods/zone/specs/getLeaves.spec.js index 9342a0b50..db7359671 100644 --- a/modules/zone/back/methods/zone/specs/getLeaves.spec.js +++ b/modules/zone/back/methods/zone/specs/getLeaves.spec.js @@ -1,14 +1,13 @@ const models = require('vn-loopback/server/server').models; describe('zone getLeaves()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; it('should return the country and the childs containing the search value', async() => { const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await models.Zone.getLeaves(ctx, 1, null, '46000', options); + let result = await models.Zone.getLeaves(1, null, '46000', options); expect(result.length).toEqual(1); diff --git a/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js b/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js index fe542fbf3..acef079f6 100644 --- a/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js +++ b/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js @@ -1,13 +1,12 @@ const models = require('vn-loopback/server/server').models; describe('zone getUpcomingDeliveries()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; it('should check returns data', async() => { const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await models.Zone.getUpcomingDeliveries(ctx, options); + let result = await models.Zone.getUpcomingDeliveries(options); const firstResultLines = result[0].lines; const secondResultLines = result[1].lines; diff --git a/modules/zone/back/models/zone-log.json b/modules/zone/back/models/zone-log.json index 403966ddd..72dd305b2 100644 --- a/modules/zone/back/models/zone-log.json +++ b/modules/zone/back/models/zone-log.json @@ -5,5 +5,54 @@ "mysql": { "table": "zoneLog" } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "string" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] } } diff --git a/package-lock.json b/package-lock.json index c190065b0..a224c4bb3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "salix-back", - "version": "23.26.01", + "version": "23.22.01", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "salix-back", - "version": "23.24.01", + "version": "23.22.01", "license": "GPL-3.0", "dependencies": { "axios": "^1.2.2", diff --git a/package.json b/package.json index 4358c86a7..f1b3daca3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.26.01", + "version": "23.24.01", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", diff --git a/webpack.config.js b/webpack.config.js index a102b838e..7a94b993d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,7 +9,7 @@ let mode = env == 'development' ? env : 'production'; let baseConfig = { entry: {salix: 'salix'}, - mode, + mode: mode, output: { path: path.join(__dirname, 'dist'), publicPath: '/' From 4537344790b93e304293c29ecfc81f158240d20a Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 20 Jun 2023 08:20:13 +0200 Subject: [PATCH 51/80] merge --- .eslintrc.yml | 4 +- CHANGELOG.md | 19 +- Dockerfile | 4 +- Jenkinsfile | 8 +- README.md | 4 +- back/methods/collection/newCollection.js | 12 +- back/methods/docuware/specs/upload.spec.js | 5 +- back/methods/docuware/upload.js | 234 ++++++------ back/methods/edi/updateData.js | 350 +++++++++--------- back/methods/vn-user/recover-password.js | 1 + back/methods/vn-user/signIn.js | 29 +- back/models/vn-user.js | 77 ++++ back/models/vn-user.json | 13 +- db/Dockerfile | 32 +- db/docker/docker-temp-stop.sh | 0 db/dump/dumpedFixtures.sql | 32 ++ db/dump/fixtures.sql | 60 ++- db/dump/mockDate.sql | 19 +- db/dump/structure.sql | 326 +++++++++------- db/export-data.sh | 1 + e2e/helpers/selectors.js | 40 +- ..._smartTable_searchBar_integrations.spec.js | 9 +- e2e/paths/02-client/21_defaulter.spec.js | 2 +- e2e/paths/04-item/01_summary.spec.js | 6 +- e2e/paths/04-item/10_item_log.spec.js | 2 +- e2e/paths/04-item/13_fixedPrice.spec.js | 3 +- .../05-ticket/01-sale/02_edit_sale.spec.js | 18 +- .../05-ticket/02_expeditions_and_log.spec.js | 2 +- e2e/paths/05-ticket/09_weekly.spec.js | 6 +- e2e/paths/05-ticket/20_moveExpedition.spec.js | 4 +- e2e/paths/05-ticket/21_future.spec.js | 122 +++--- e2e/paths/05-ticket/22_advance.spec.js | 77 ++-- e2e/paths/06-claim/05_summary.spec.js | 6 +- front/core/components/smart-table/index.js | 2 + front/core/services/auth.js | 6 +- front/core/styles/util.scss | 7 + front/core/styles/variables.scss | 2 - front/salix/components/background/style.scss | 4 +- front/salix/components/index.js | 1 + front/salix/components/layout/style.scss | 4 +- front/salix/components/log/index.html | 101 ++--- front/salix/components/log/index.js | 58 ++- front/salix/components/log/locale/es.yml | 6 + front/salix/components/log/style.scss | 27 +- front/salix/components/login/index.js | 13 +- front/salix/components/outLayout/style.scss | 21 ++ .../components/recover-password/index.js | 1 - .../salix/components/reset-password/index.js | 2 +- front/salix/components/user-popover/index.js | 2 - front/salix/routes.js | 9 + front/salix/styles/misc.scss | 7 +- loopback/common/models/log.json | 61 ++- loopback/common/models/vn-model.js | 75 +++- loopback/locale/en.json | 4 +- loopback/locale/es.json | 6 +- .../account/back/locale/role-inherit/en.yml | 1 + .../account/back/locale/role-inherit/es.yml | 1 + .../back/methods/account/change-password.js | 4 +- .../back/methods/account/set-password.js | 4 +- .../account/specs/change-password.spec.js | 20 +- .../back/methods/account/sync-by-id.js | 6 +- modules/account/back/methods/account/sync.js | 13 +- modules/account/back/models/account-config.js | 36 +- .../account/back/models/account-config.json | 3 - modules/account/back/models/role-log.json | 49 --- modules/account/back/models/user-log.json | 49 --- modules/account/front/accounts/index.js | 3 +- .../importToNewRefundTicket.js | 2 +- modules/claim/back/models/claim-log.json | 49 --- .../back/methods/client/confirmTransaction.js | 2 +- .../methods/client/consumptionSendQueued.js | 6 +- .../back/methods/client/createReceipt.js | 2 +- modules/client/back/methods/client/filter.js | 4 +- modules/client/back/methods/client/getCard.js | 6 +- modules/client/back/methods/client/getDebt.js | 6 +- .../back/methods/client/specs/getCard.spec.js | 3 +- .../back/methods/client/specs/getDebt.spec.js | 3 +- .../back/methods/client/specs/summary.spec.js | 15 +- modules/client/back/methods/client/summary.js | 6 +- .../back/methods/tpv-transaction/end.js | 2 +- .../back/methods/tpv-transaction/start.js | 2 +- modules/client/back/models/client-log.json | 49 --- .../client/front/credit-management/index.html | 2 +- .../entry/back/methods/entry/importBuys.js | 4 +- modules/entry/back/model-config.json | 3 + modules/entry/back/models/buy.json | 50 +++ modules/entry/back/models/entry-log.json | 49 --- modules/entry/back/models/entry.js | 2 + .../back/methods/invoice-in/toBook.js | 4 +- .../invoiceIn/back/models/invoice-in-log.json | 52 --- .../back/methods/invoiceOut/book.js | 6 +- .../methods/invoiceOut/clientsToInvoice.js | 2 +- .../methods/invoiceOut/createManualInvoice.js | 2 +- .../back/methods/invoiceOut/invoiceClient.js | 2 +- .../back/methods/invoiceOut/refund.js | 24 +- .../methods/invoiceOut/specs/book.spec.js | 3 +- .../methods/invoiceOut/specs/refund.spec.js | 4 +- .../front/descriptor-menu/index.html | 30 +- .../invoiceOut/front/descriptor-menu/index.js | 4 +- .../front/descriptor-menu/locale/es.yml | 3 +- .../front/global-invoicing/index.html | 3 +- .../front/global-invoicing/index.js | 36 +- .../invoiceOut/front/negative-bases/index.js | 3 +- modules/item/back/methods/item/getBalance.js | 6 +- modules/item/back/methods/item/new.js | 6 +- .../methods/item/specs/getBalance.spec.js | 7 +- .../item/back/methods/item/specs/new.spec.js | 3 +- modules/item/back/models/item-log.json | 49 --- modules/item/front/fixed-price/index.js | 1 - .../back/methods/order-row/addToOrder.js | 6 +- .../order-row/specs/addToOrder.spec.js | 3 +- modules/order/back/methods/order/confirm.js | 2 +- modules/order/back/methods/order/new.js | 6 +- .../order/back/methods/order/newFromTicket.js | 6 +- .../back/methods/order/specs/new.spec.js | 5 +- .../methods/order/specs/newFromTicket.spec.js | 3 +- .../order/front/catalog-search-panel/index.js | 4 +- modules/order/front/catalog/index.html | 26 +- .../methods/agency-term/createInvoiceIn.js | 6 +- .../agency-term/specs/createInvoiceIn.spec.js | 3 +- .../route/back/methods/route/guessPriority.js | 2 +- .../route/back/methods/route/updateVolume.js | 2 +- modules/route/back/models/route-log.json | 49 --- modules/route/front/index/index.html | 55 ++- modules/shelving/back/models/sector.json | 4 +- .../shelving/back/models/shelving-log.json | 57 +-- .../supplier/back/models/supplier-log.json | 49 --- modules/supplier/back/models/supplier.js | 1 + .../ticket/back/locale/ticket-request/en.yml | 19 +- .../ticket/back/locale/ticket-request/es.yml | 21 +- .../ticket/back/methods/expedition/filter.js | 62 ++-- .../methods/expedition/specs/filter.spec.js | 2 +- .../back/methods/sale/recalculatePrice.js | 2 +- modules/ticket/back/methods/sale/refund.js | 17 +- .../back/methods/sale/specs/refund.spec.js | 9 +- .../back/methods/sale/specs/reserve.spec.js | 4 +- .../ticket/back/methods/sale/updatePrice.js | 2 +- modules/ticket/back/methods/sale/usesMana.js | 2 +- .../back/methods/ticket-log/getChanges.js | 16 +- .../ticket-log/specs/getChanges.spec.js | 2 +- .../back/methods/ticket-request/confirm.js | 2 +- modules/ticket/back/methods/ticket/addSale.js | 2 +- .../ticket/back/methods/ticket/closeAll.js | 8 +- modules/ticket/back/methods/ticket/closure.js | 29 +- .../back/methods/ticket/componentUpdate.js | 2 +- .../ticket/back/methods/ticket/getSales.js | 6 +- .../ticket/back/methods/ticket/makeInvoice.js | 2 +- modules/ticket/back/methods/ticket/new.js | 6 +- .../back/methods/ticket/priceDifference.js | 2 +- .../methods/ticket/recalculateComponents.js | 2 +- modules/ticket/back/methods/ticket/refund.js | 11 +- .../ticket/back/methods/ticket/saveSign.js | 2 +- .../ticket/back/methods/ticket/setDeleted.js | 2 +- .../methods/ticket/specs/getSales.spec.js | 3 +- .../back/methods/ticket/specs/summary.spec.js | 9 +- .../ticket/specs/transferSales.spec.js | 16 +- modules/ticket/back/methods/ticket/summary.js | 6 +- .../back/methods/ticket/transferSales.js | 2 +- .../back/methods/ticket/updateDiscount.js | 2 +- modules/ticket/back/model-config.json | 3 + modules/ticket/back/models/ticket-log.json | 57 +-- modules/ticket/front/advance/index.html | 2 +- modules/ticket/front/advance/index.js | 7 - modules/ticket/front/advance/index.spec.js | 18 - .../ticket/front/descriptor-menu/index.html | 29 +- modules/ticket/front/descriptor-menu/index.js | 27 +- .../front/descriptor-menu/index.spec.js | 6 +- .../front/descriptor-menu/locale/es.yml | 5 +- modules/ticket/front/descriptor/locale/es.yml | 2 +- modules/ticket/front/expedition/index.html | 140 +++---- modules/ticket/front/expedition/index.js | 24 ++ modules/ticket/front/future/index.html | 2 +- modules/ticket/front/index/index.html | 42 +-- modules/ticket/front/index/index.js | 31 +- modules/ticket/front/index/index.spec.js | 20 +- modules/ticket/front/sale/index.html | 31 +- modules/ticket/front/sale/index.js | 5 +- modules/ticket/front/sale/locale/es.yml | 4 +- .../methods/thermograph/createThermograph.js | 6 +- .../specs/createThermograph.spec.js | 7 +- .../back/methods/travel/deleteThermograph.js | 6 +- modules/travel/back/model-config.json | 3 + modules/travel/back/models/travel-log.json | 49 --- .../back/methods/department/getLeaves.js | 7 +- .../worker-time-control/addTimeEntry.js | 6 +- .../worker-time-control/deleteTimeEntry.js | 6 +- .../methods/worker-time-control/sendMail.js | 2 +- modules/worker/back/methods/worker/new.js | 2 +- .../back/methods/worker/specs/new.spec.js | 18 +- .../back/models/device-production-log.json | 59 +-- modules/worker/back/models/operator.json | 6 +- modules/worker/back/models/worker-log.json | 49 --- modules/zone/back/locale/zone-event/en.yml | 8 +- modules/zone/back/locale/zone-event/es.yml | 6 +- .../zone/back/locale/zone-exclusion/en.yml | 4 +- .../zone/back/locale/zone-exclusion/es.yml | 2 +- modules/zone/back/locale/zone-included/en.yml | 4 +- modules/zone/back/locale/zone-included/es.yml | 4 +- .../zone/back/locale/zone-warehouse/en.yml | 2 +- .../zone/back/locale/zone-warehouse/es.yml | 2 +- .../agency/getAgenciesWithWarehouse.js | 6 +- .../zone/back/methods/agency/landsThatDay.js | 6 +- .../specs/getAgenciesWithWarehouse.spec.js | 5 +- .../methods/agency/specs/landsThatDay.spec.js | 3 +- modules/zone/back/methods/zone/deleteZone.js | 2 +- modules/zone/back/methods/zone/getEvents.js | 6 +- modules/zone/back/methods/zone/getLeaves.js | 7 +- .../methods/zone/getUpcomingDeliveries.js | 6 +- .../back/methods/zone/specs/getEvents.spec.js | 3 +- .../back/methods/zone/specs/getLeaves.spec.js | 3 +- .../zone/specs/getUpcomingDeliveries.spec.js | 3 +- modules/zone/back/models/zone-log.json | 49 --- package-lock.json | 4 +- package.json | 2 +- webpack.config.js | 2 +- 215 files changed, 1929 insertions(+), 2104 deletions(-) mode change 100755 => 100644 db/docker/docker-temp-stop.sh diff --git a/.eslintrc.yml b/.eslintrc.yml index 13fc2b140..ee20324ff 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,6 +1,6 @@ extends: [eslint:recommended, google, plugin:jasmine/recommended] parserOptions: - ecmaVersion: 2018 + ecmaVersion: 2020 sourceType: "module" plugins: - jasmine @@ -35,4 +35,4 @@ rules: space-in-parens: ["error", "never"] jasmine/no-focused-tests: 0 jasmine/prefer-toHaveBeenCalledWith: 0 - arrow-spacing: ["error", { "before": true, "after": true }] \ No newline at end of file + arrow-spacing: ["error", { "before": true, "after": true }] diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e9d004b0..8967a1633 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,28 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [2324.01] - 2023-06-08 +## [2326.01] - 2023-06-29 ### Added ### Changed + +### Fixed - +## [2324.01] - 2023-06-15 + +### Added +- (Tickets -> Abono) Al abonar permite crear el ticket abono con almacén o sin almmacén +- (General -> Desplegables) Mejorada eficiencia de carga de datos +- (General -> Históricos) Ahora, ademas de los ids, se muestra la descripión de los atributos +- (General -> Históricos) Botón para hacer más ágil mostrar sólo los cambios en un registro +- (General -> Históricos) Filtro por cambios + +### Changed +- (General -> Permisos) Mejorada seguridad +- (General -> Históricos) Elementos de la interfaz reorganizados para hacerla más ágil e intuitiva + ### Fixed - @@ -26,7 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - (Trabajadores -> Nuevo trabajador) Los clientes se crean sin 'TR' pero se añade tipo de negocio 'Trabajador' - +- (Tickets -> Expediciones) Interfaz mejorada y contador añadido ### Fixed - (Tickets -> Líneas) Se permite hacer split de líneas al mismo ticket - (Tickets -> Cambiar estado) Ahora muestra la lista completa de todos los estados diff --git a/Dockerfile b/Dockerfile index ee87cd0d0..e1173ad73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,9 +11,9 @@ RUN apt-get update \ ca-certificates \ gnupg2 \ graphicsmagick \ - && curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \ + && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ && apt-get install -y --no-install-recommends nodejs \ - && npm install -g npm@8.19.2 + && npm install -g npm@9.6.6 # Puppeteer diff --git a/Jenkinsfile b/Jenkinsfile index 5f329ee61..cf9b8cd67 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,7 +39,7 @@ pipeline { NODE_ENV = "" } steps { - nodejs('node-v14') { + nodejs('node-v20') { sh 'npm install --no-audit --prefer-offline' sh 'gulp install --ci' } @@ -57,14 +57,14 @@ pipeline { parallel { stage('Frontend') { steps { - nodejs('node-v14') { + nodejs('node-v20') { sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=2' } } } stage('Backend') { steps { - nodejs('node-v14') { + nodejs('node-v20') { sh 'npm run test:back:ci' } } @@ -80,7 +80,7 @@ pipeline { CREDENTIALS = credentials('docker-registry') } steps { - nodejs('node-v14') { + nodejs('node-v20') { sh 'gulp build' } diff --git a/README.md b/README.md index f73a8551b..59f5dbcf7 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Salix is also the scientific name of a beautifull tree! :) Required applications. -* Node.js = 14.x LTS +* Node.js >= 16.x LTS * Docker * Git @@ -71,7 +71,7 @@ $ npm run test:e2e Open Visual Studio Code, press Ctrl+P and paste the following commands. -In Visual Studio Code we use the ESLint extension. +In Visual Studio Code we use the ESLint extension. ``` ext install dbaeumer.vscode-eslint ``` diff --git a/back/methods/collection/newCollection.js b/back/methods/collection/newCollection.js index 31e419b67..2be9f8b0e 100644 --- a/back/methods/collection/newCollection.js +++ b/back/methods/collection/newCollection.js @@ -30,11 +30,11 @@ module.exports = Self => { Self.newCollection = async(ctx, collectionFk, sectorFk, vWagons) => { let query = ''; + const userId = ctx.req.accessToken.userId; if (!collectionFk) { - const userId = ctx.req.accessToken.userId; query = `CALL vn.collectionTrain_newBeta(?,?,?)`; - const [result] = await Self.rawSql(query, [sectorFk, vWagons, userId]); + const [result] = await Self.rawSql(query, [sectorFk, vWagons, userId], {userId}); if (result.length == 0) throw new Error(`No collections for today`); @@ -42,16 +42,16 @@ module.exports = Self => { } query = `CALL vn.collectionTicket_get(?)`; - const [tickets] = await Self.rawSql(query, [collectionFk]); + const [tickets] = await Self.rawSql(query, [collectionFk], {userId}); query = `CALL vn.collectionSale_get(?)`; - const [sales] = await Self.rawSql(query, [collectionFk]); + const [sales] = await Self.rawSql(query, [collectionFk], {userId}); query = `CALL vn.collectionPlacement_get(?)`; - const [placements] = await Self.rawSql(query, [collectionFk]); + const [placements] = await Self.rawSql(query, [collectionFk], {userId}); query = `CALL vn.collectionSticker_print(?,?)`; - await Self.rawSql(query, [collectionFk, sectorFk]); + await Self.rawSql(query, [collectionFk, sectorFk], {userId}); return makeCollection(tickets, sales, placements, collectionFk); }; diff --git a/back/methods/docuware/specs/upload.spec.js b/back/methods/docuware/specs/upload.spec.js index 7ac873e95..3b8c55a50 100644 --- a/back/methods/docuware/specs/upload.spec.js +++ b/back/methods/docuware/specs/upload.spec.js @@ -2,8 +2,9 @@ const models = require('vn-loopback/server/server').models; describe('docuware upload()', () => { const userId = 9; - const ticketId = 10; + const ticketIds = [10]; const ctx = { + args: {ticketIds}, req: { getLocale: () => { return 'en'; @@ -27,7 +28,7 @@ describe('docuware upload()', () => { let error; try { - await models.Docuware.upload(ctx, ticketId, fileCabinetName); + await models.Docuware.upload(ctx, ticketIds, fileCabinetName); } catch (e) { error = e.message; } diff --git a/back/methods/docuware/upload.js b/back/methods/docuware/upload.js index ea9ee3622..096301e56 100644 --- a/back/methods/docuware/upload.js +++ b/back/methods/docuware/upload.js @@ -3,34 +3,34 @@ const axios = require('axios'); module.exports = Self => { Self.remoteMethodCtx('upload', { - description: 'Upload an docuware PDF', + description: 'Upload docuware PDFs', accessType: 'WRITE', accepts: [ { - arg: 'id', - type: 'number', - description: 'The ticket id', - http: {source: 'path'} + arg: 'ticketIds', + type: ['number'], + description: 'The ticket ids', + required: true }, { arg: 'fileCabinet', type: 'string', - description: 'The file cabinet' - }, - { - arg: 'dialog', - type: 'string', - description: 'The dialog' + description: 'The file cabinet', + required: true } ], - returns: [], + returns: { + type: 'object', + root: true + }, http: { - path: `/:id/upload`, + path: `/upload`, verb: 'POST' } }); - Self.upload = async function(ctx, id, fileCabinet) { + Self.upload = async function(ctx, ticketIds, fileCabinet) { + delete ctx.args.ticketIds; const models = Self.app.models; const action = 'store'; @@ -38,104 +38,114 @@ module.exports = Self => { const fileCabinetId = await Self.getFileCabinet(fileCabinet); const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId); - // get delivery note - const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, { - id, - type: 'deliveryNote' - }); - - // get ticket data - const ticket = await models.Ticket.findById(id, { - include: [{ - relation: 'client', - scope: { - fields: ['id', 'socialName', 'fi'] - } - }] - }); - - // upload file - const templateJson = { - 'Fields': [ - { - 'FieldName': 'N__ALBAR_N', - 'ItemElementName': 'string', - 'Item': id, - }, - { - 'FieldName': 'CIF_PROVEEDOR', - 'ItemElementName': 'string', - 'Item': ticket.client().fi, - }, - { - 'FieldName': 'CODIGO_PROVEEDOR', - 'ItemElementName': 'string', - 'Item': ticket.client().id, - }, - { - 'FieldName': 'NOMBRE_PROVEEDOR', - 'ItemElementName': 'string', - 'Item': ticket.client().socialName, - }, - { - 'FieldName': 'FECHA_FACTURA', - 'ItemElementName': 'date', - 'Item': ticket.shipped, - }, - { - 'FieldName': 'TOTAL_FACTURA', - 'ItemElementName': 'Decimal', - 'Item': ticket.totalWithVat, - }, - { - 'FieldName': 'ESTADO', - 'ItemElementName': 'string', - 'Item': 'Pendiente procesar', - }, - { - 'FieldName': 'FIRMA_', - 'ItemElementName': 'string', - 'Item': 'Si', - }, - { - 'FieldName': 'FILTRO_TABLET', - 'ItemElementName': 'string', - 'Item': 'Tablet1', - } - ] - }; - - if (process.env.NODE_ENV != 'production') - throw new UserError('Action not allowed on the test environment'); - - // delete old - const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false); - if (docuwareFile) { - const deleteJson = { - 'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}] - }; - const deleteUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents/${docuwareFile.id}/Fields`; - await axios.put(deleteUri, deleteJson, options.headers); - } - - const uploadUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`; - const FormData = require('form-data'); - const data = new FormData(); - - data.append('document', JSON.stringify(templateJson), 'schema.json'); - data.append('file[]', deliveryNote[0], 'file.pdf'); - const uploadOptions = { - headers: { - 'Content-Type': 'multipart/form-data', - 'X-File-ModifiedDate': Date.vnNew(), - 'Cookie': options.headers.headers.Cookie, - ...data.getHeaders() - }, - }; - - return await axios.post(uploadUri, data, uploadOptions) - .catch(() => { - throw new UserError('Failed to upload file'); + const uploaded = []; + for (id of ticketIds) { + // get delivery note + ctx.args.id = id; + const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, { + id, + type: 'deliveryNote' }); + // get ticket data + const ticket = await models.Ticket.findById(id, { + include: [{ + relation: 'client', + scope: { + fields: ['id', 'name', 'fi'] + } + }] + }); + + // upload file + const templateJson = { + 'Fields': [ + { + 'FieldName': 'N__ALBAR_N', + 'ItemElementName': 'string', + 'Item': id, + }, + { + 'FieldName': 'CIF_PROVEEDOR', + 'ItemElementName': 'string', + 'Item': ticket.client().fi, + }, + { + 'FieldName': 'CODIGO_PROVEEDOR', + 'ItemElementName': 'string', + 'Item': ticket.client().id, + }, + { + 'FieldName': 'NOMBRE_PROVEEDOR', + 'ItemElementName': 'string', + 'Item': ticket.client().name + ' - ' + id, + }, + { + 'FieldName': 'FECHA_FACTURA', + 'ItemElementName': 'date', + 'Item': ticket.shipped, + }, + { + 'FieldName': 'TOTAL_FACTURA', + 'ItemElementName': 'Decimal', + 'Item': ticket.totalWithVat, + }, + { + 'FieldName': 'ESTADO', + 'ItemElementName': 'string', + 'Item': 'Pendiente procesar', + }, + { + 'FieldName': 'FIRMA_', + 'ItemElementName': 'string', + 'Item': 'Si', + }, + { + 'FieldName': 'FILTRO_TABLET', + 'ItemElementName': 'string', + 'Item': 'Tablet1', + } + ] + }; + + if (process.env.NODE_ENV != 'production') + throw new UserError('Action not allowed on the test environment'); + + // delete old + const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false); + if (docuwareFile) { + const deleteJson = { + 'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}] + }; + const deleteUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents/${docuwareFile.id}/Fields`; + await axios.put(deleteUri, deleteJson, options.headers); + } + + const uploadUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`; + const FormData = require('form-data'); + const data = new FormData(); + + data.append('document', JSON.stringify(templateJson), 'schema.json'); + data.append('file[]', deliveryNote[0], 'file.pdf'); + const uploadOptions = { + headers: { + 'Content-Type': 'multipart/form-data', + 'X-File-ModifiedDate': Date.vnNew(), + 'Cookie': options.headers.headers.Cookie, + ...data.getHeaders() + }, + }; + + try { + await axios.post(uploadUri, data, uploadOptions); + } catch (err) { + const $t = ctx.req.__; + const message = $t('Failed to upload delivery note', {id}); + if (uploaded.length) + await models.TicketTracking.setDelivered(ctx, uploaded); + throw new UserError(message); + } + uploaded.push(id); + } + return models.TicketTracking.setDelivered(ctx, ticketIds); }; }; diff --git a/back/methods/edi/updateData.js b/back/methods/edi/updateData.js index 1057be39b..10c81a795 100644 --- a/back/methods/edi/updateData.js +++ b/back/methods/edi/updateData.js @@ -3,237 +3,237 @@ const path = require('path'); const fs = require('fs-extra'); module.exports = Self => { - Self.remoteMethodCtx('updateData', { - description: 'Updates schema data from external provider', - accessType: 'WRITE', - returns: { - type: 'object', - root: true - }, - http: { - path: `/updateData`, - verb: 'POST' - } - }); + Self.remoteMethodCtx('updateData', { + description: 'Updates schema data from external provider', + accessType: 'WRITE', + returns: { + type: 'object', + root: true + }, + http: { + path: `/updateData`, + verb: 'POST' + } + }); - Self.updateData = async() => { - const models = Self.app.models; + Self.updateData = async ctx => { + const models = Self.app.models; - // Get files checksum - const tx = await Self.beginTransaction({}); + // Get files checksum + const tx = await Self.beginTransaction({}); - try { - const options = {transaction: tx}; - const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options); + try { + const options = {transaction: tx, userId: ctx.req.accessToken.userId}; + const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options); - const updatableFiles = []; - for (const file of files) { - const fileChecksum = await getChecksum(file); + const updatableFiles = []; + for (const file of files) { + const fileChecksum = await getChecksum(file); - if (file.checksum != fileChecksum) { - updatableFiles.push({ - name: file.name, - checksum: fileChecksum - }); - } else - console.debug(`File already updated, skipping...`); - } + if (file.checksum != fileChecksum) { + updatableFiles.push({ + name: file.name, + checksum: fileChecksum + }); + } else + console.debug(`File already updated, skipping...`); + } - if (updatableFiles.length === 0) - return false; + if (updatableFiles.length === 0) + return false; - // Download files - const container = await models.TempContainer.container('edi'); - const tempPath = path.join(container.client.root, container.name); + // Download files + const container = await models.TempContainer.container('edi'); + const tempPath = path.join(container.client.root, container.name); - let remoteFile; - let tempDir; - let tempFile; + let remoteFile; + let tempDir; + let tempFile; - const fileNames = updatableFiles.map(file => file.name); + const fileNames = updatableFiles.map(file => file.name); - const tables = await Self.rawSql(` + const tables = await Self.rawSql(` SELECT fileName, toTable, file FROM edi.tableConfig WHERE file IN (?)`, [fileNames], options); - for (const table of tables) { - const fileName = table.file; + for (const table of tables) { + const fileName = table.file; - remoteFile = `codes/${fileName}.ZIP`; - tempDir = `${tempPath}/${fileName}`; - tempFile = `${tempPath}/${fileName}.zip`; + remoteFile = `codes/${fileName}.ZIP`; + tempDir = `${tempPath}/${fileName}`; + tempFile = `${tempPath}/${fileName}.zip`; - try { - await fs.readFile(tempFile); - } catch (error) { - if (error.code === 'ENOENT') { - console.debug(`Downloading file ${fileName}...`); - const downloadOutput = await downloadFile(remoteFile, tempFile); - if (downloadOutput.error) - continue; - } - } + try { + await fs.readFile(tempFile); + } catch (error) { + if (error.code === 'ENOENT') { + console.debug(`Downloading file ${fileName}...`); + const downloadOutput = await downloadFile(remoteFile, tempFile); + if (downloadOutput.error) + continue; + } + } - await extractFile(fileName, tempFile, tempDir); + await extractFile(fileName, tempFile, tempDir); - console.debug(`Updating table ${table.toTable}...`); - await dumpData(tempDir, table, options); - } + console.debug(`Updating table ${table.toTable}...`); + await dumpData(tempDir, table, options); + } - // Update files checksum - for (const file of updatableFiles) { - console.log(`Updating file ${file.name} checksum...`); - await Self.rawSql(` + // Update files checksum + for (const file of updatableFiles) { + console.log(`Updating file ${file.name} checksum...`); + await Self.rawSql(` UPDATE edi.fileConfig SET checksum = ? WHERE name = ?`, - [file.checksum, file.name], options); - } + [file.checksum, file.name], options); + } - await tx.commit(); + await tx.commit(); - // Clean files - try { - console.debug(`Cleaning files...`); - await fs.remove(tempPath); - } catch (error) { - if (error.code !== 'ENOENT') - throw e; - } + // Clean files + try { + console.debug(`Cleaning files...`); + await fs.remove(tempPath); + } catch (error) { + if (error.code !== 'ENOENT') + throw e; + } - return true; - } catch (error) { - await tx.rollback(); - throw error; - } - }; + return true; + } catch (error) { + await tx.rollback(); + throw error; + } + }; - let ftpClient; - async function getFtpClient() { - if (!ftpClient) { - const [ftpConfig] = await Self.rawSql('SELECT host, user, password FROM edi.ftpConfig'); - console.debug(`Openning FTP connection to ${ftpConfig.host}...\n`); + let ftpClient; + async function getFtpClient() { + if (!ftpClient) { + const [ftpConfig] = await Self.rawSql('SELECT host, user, password FROM edi.ftpConfig'); + console.debug(`Openning FTP connection to ${ftpConfig.host}...\n`); - const FtpClient = require('ftps'); + const FtpClient = require('ftps'); - ftpClient = new FtpClient({ - host: ftpConfig.host, - username: ftpConfig.user, - password: ftpConfig.password, - procotol: 'ftp', - additionalLftpCommands: 'set ssl:verify-certificate no' - }); - } + ftpClient = new FtpClient({ + host: ftpConfig.host, + username: ftpConfig.user, + password: ftpConfig.password, + procotol: 'ftp', + additionalLftpCommands: 'set ssl:verify-certificate no' + }); + } - return ftpClient; - } + return ftpClient; + } - async function getChecksum(file) { - const ftpClient = await getFtpClient(); - console.debug(`Checking checksum for file ${file.name}...`); + async function getChecksum(file) { + const ftpClient = await getFtpClient(); + console.debug(`Checking checksum for file ${file.name}...`); - ftpClient.cat(`codes/${file.name}.TXT`); + ftpClient.cat(`codes/${file.name}.TXT`); - const response = await new Promise((resolve, reject) => { - ftpClient.exec((err, response) => { - if (err || response.error) { - console.debug(`Error downloading checksum file... ${response.error}`); - return reject(err); - } + const response = await new Promise((resolve, reject) => { + ftpClient.exec((err, response) => { + if (err || response.error) { + console.debug(`Error downloading checksum file... ${response.error}`); + return reject(err); + } - resolve(response); - }); - }); + resolve(response); + }); + }); - if (response && response.data) { - const fileContents = response.data; - const rows = fileContents.split('\n'); - const row = rows[4]; - const columns = row.split(/\s+/); + if (response && response.data) { + const fileContents = response.data; + const rows = fileContents.split('\n'); + const row = rows[4]; + const columns = row.split(/\s+/); - let fileChecksum; - if (file.keyValue) - fileChecksum = columns[1]; + let fileChecksum; + if (file.keyValue) + fileChecksum = columns[1]; - if (!file.keyValue) - fileChecksum = columns[0]; + if (!file.keyValue) + fileChecksum = columns[0]; - return fileChecksum; - } - } + return fileChecksum; + } + } - async function downloadFile(remoteFile, tempFile) { - const ftpClient = await getFtpClient(); + async function downloadFile(remoteFile, tempFile) { + const ftpClient = await getFtpClient(); - ftpClient.get(remoteFile, tempFile); + ftpClient.get(remoteFile, tempFile); - return new Promise((resolve, reject) => { - ftpClient.exec((err, response) => { - if (err || response.error) { - console.debug(`Error downloading file... ${response.error}`); - return reject(err); - } + return new Promise((resolve, reject) => { + ftpClient.exec((err, response) => { + if (err || response.error) { + console.debug(`Error downloading file... ${response.error}`); + return reject(err); + } - resolve(response); - }); - }); - } + resolve(response); + }); + }); + } - async function extractFile(fileName, tempFile, tempDir) { - const JSZip = require('jszip'); + async function extractFile(fileName, tempFile, tempDir) { + const JSZip = require('jszip'); - try { - await fs.mkdir(tempDir); - console.debug(`Extracting file ${fileName}...`); - } catch (error) { - if (error.code !== 'EEXIST') - throw e; - } + try { + await fs.mkdir(tempDir); + console.debug(`Extracting file ${fileName}...`); + } catch (error) { + if (error.code !== 'EEXIST') + throw e; + } - const fileStream = await fs.readFile(tempFile); - if (fileStream) { - const zip = new JSZip(); - const zipContents = await zip.loadAsync(fileStream); + const fileStream = await fs.readFile(tempFile); + if (fileStream) { + const zip = new JSZip(); + const zipContents = await zip.loadAsync(fileStream); - if (!zipContents) return; + if (!zipContents) return; - const fileNames = Object.keys(zipContents.files); + const fileNames = Object.keys(zipContents.files); - for (const fileName of fileNames) { - const fileContent = await zip.file(fileName).async('nodebuffer'); - const dest = path.join(tempDir, fileName); - await fs.writeFile(dest, fileContent); - } - } - } + for (const fileName of fileNames) { + const fileContent = await zip.file(fileName).async('nodebuffer'); + const dest = path.join(tempDir, fileName); + await fs.writeFile(dest, fileContent); + } + } + } - async function dumpData(tempDir, table, options) { - const toTable = table.toTable; - const baseName = table.fileName; + async function dumpData(tempDir, table, options) { + const toTable = table.toTable; + const baseName = table.fileName; - console.log(`Emptying table ${toTable}...`); - const tableName = `edi.${toTable}`; - await Self.rawSql(`DELETE FROM ??`, [tableName]); + console.log(`Emptying table ${toTable}...`); + const tableName = `edi.${toTable}`; + await Self.rawSql(`DELETE FROM ??`, [tableName]); - const dirFiles = await fs.readdir(tempDir); - const files = dirFiles.filter(file => file.startsWith(baseName)); + const dirFiles = await fs.readdir(tempDir); + const files = dirFiles.filter(file => file.startsWith(baseName)); - for (const file of files) { - console.log(`Dumping data from file ${file}...`); + for (const file of files) { + console.log(`Dumping data from file ${file}...`); - const templatePath = path.join(__dirname, `./sql/${toTable}.sql`); - const sqlTemplate = await fs.readFile(templatePath, 'utf8'); - const filePath = path.join(tempDir, file); + const templatePath = path.join(__dirname, `./sql/${toTable}.sql`); + const sqlTemplate = await fs.readFile(templatePath, 'utf8'); + const filePath = path.join(tempDir, file); - await Self.rawSql(sqlTemplate, [filePath], options); - await Self.rawSql(` + await Self.rawSql(sqlTemplate, [filePath], options); + await Self.rawSql(` UPDATE edi.tableConfig SET updated = ? WHERE fileName = ? `, [Date.vnNew(), baseName], options); - } + } - console.log(`Updated table ${toTable}\n`); - } + console.log(`Updated table ${toTable}\n`); + } }; diff --git a/back/methods/vn-user/recover-password.js b/back/methods/vn-user/recover-password.js index 34f5dd545..b87bb14d4 100644 --- a/back/methods/vn-user/recover-password.js +++ b/back/methods/vn-user/recover-password.js @@ -24,6 +24,7 @@ module.exports = Self => { fields: ['email'], where: {name: user} }); + if (!account) return; user = account.email; } diff --git a/back/methods/vn-user/signIn.js b/back/methods/vn-user/signIn.js index da3172ae4..6615cb5f1 100644 --- a/back/methods/vn-user/signIn.js +++ b/back/methods/vn-user/signIn.js @@ -27,33 +27,46 @@ module.exports = Self => { }); Self.signIn = async function(user, password) { - let models = Self.app.models; + const models = Self.app.models; + const usesEmail = user.indexOf('@') !== -1; let token; - let usesEmail = user.indexOf('@') !== -1; - let userInfo = usesEmail + const userInfo = usesEmail ? {email: user} : {username: user}; - let instance = await Self.findOne({ + const instance = await Self.findOne({ fields: ['username', 'password'], where: userInfo }); - let where = usesEmail + const where = usesEmail ? {email: user} : {name: user}; - let vnUser = await Self.findOne({ - fields: ['active'], + const vnUser = await Self.findOne({ + fields: ['id', 'active', 'passExpired'], where }); - let validCredentials = instance + const today = Date.vnNew(); + today.setHours(0, 0, 0, 0); + + const validCredentials = instance && await instance.hasPassword(password); if (validCredentials) { if (!vnUser.active) throw new UserError('User disabled'); + if (vnUser.passExpired && vnUser.passExpired.getTime() <= today.getTime()) { + const changePasswordToken = await models.AccessToken.create({ + scopes: ['change-password'], + userId: vnUser.id + }); + const err = new UserError('Pass expired', 'passExpired'); + err.details = {token: changePasswordToken}; + throw err; + } + try { await models.Account.sync(instance.username, password); } catch (err) { diff --git a/back/models/vn-user.js b/back/models/vn-user.js index 84ba11794..fb3279353 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -107,4 +107,81 @@ module.exports = function(Self) { return email.send(); }); + + const _setPassword = Self.prototype.setPassword; + Self.prototype.setPassword = async function(newPassword, options, cb) { + if (cb === undefined && typeof options === 'function') { + cb = options; + options = undefined; + } + + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + options = myOptions; + + try { + await Self.rawSql(`CALL account.user_checkPassword(?)`, [newPassword], options); + await _setPassword.call(this, newPassword, options); + await this.updateAttribute('passExpired', null, options); + await Self.app.models.Account.sync(this.name, newPassword, null, options); + tx && await tx.commit(); + cb && cb(); + } catch (err) { + tx && await tx.rollback(); + if (cb) cb(err); else throw err; + } + }; + + Self.sharedClass._methods.find(method => method.name == 'changePassword') + .accessScopes = ['change-password']; + + // FIXME: https://redmine.verdnatura.es/issues/5761 + // Self.afterRemote('prototype.patchAttributes', async(ctx, instance) => { + // if (!ctx.args || !ctx.args.data.email) return; + + // const loopBackContext = LoopBackContext.getCurrentContext(); + // const httpCtx = {req: loopBackContext.active}; + // const httpRequest = httpCtx.req.http.req; + // const headers = httpRequest.headers; + // const origin = headers.origin; + // const url = origin.split(':'); + + // class Mailer { + // async send(verifyOptions, cb) { + // const params = { + // url: verifyOptions.verifyHref, + // recipient: verifyOptions.to, + // lang: ctx.req.getLocale() + // }; + + // const email = new Email('email-verify', params); + // email.send(); + + // cb(null, verifyOptions.to); + // } + // } + + // const options = { + // type: 'email', + // to: instance.email, + // from: {}, + // redirect: `${origin}/#!/account/${instance.id}/basic-data?emailConfirmed`, + // template: false, + // mailer: new Mailer, + // host: url[1].split('/')[2], + // port: url[2], + // protocol: url[0], + // user: Self + // }; + + // await instance.verify(options); + // }); }; diff --git a/back/models/vn-user.json b/back/models/vn-user.json index 17efc8ce6..8486e29b8 100644 --- a/back/models/vn-user.json +++ b/back/models/vn-user.json @@ -25,10 +25,7 @@ }, "password": { "type": "string", - "required": true, - "mysql": { - "columnName": "bcryptPassword" - } + "required": true }, "roleFk": { "type": "number", @@ -42,9 +39,6 @@ "lang": { "type": "string" }, - "bcryptPassword": { - "type": "string" - }, "active": { "type": "boolean" }, @@ -62,7 +56,10 @@ }, "hasGrant": { "type": "boolean" - } + }, + "passExpired": { + "type": "date" + } }, "relations": { "role": { diff --git a/db/Dockerfile b/db/Dockerfile index 053fbcee6..448b8b03a 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -1,26 +1,18 @@ -FROM mariadb:10.7.5 +FROM mariadb:10.7.7 ENV MYSQL_ROOT_PASSWORD root ENV TZ Europe/Madrid ARG MOCKDATE=2001-01-01 11:00:00 ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update \ - && apt-get install -y --no-install-recommends curl ca-certificates \ - && curl -sL https://apt.verdnatura.es/conf/verdnatura.gpg | apt-key add - \ - && echo "deb http://apt.verdnatura.es/ jessie main" > /etc/apt/sources.list.d/vn.list \ - && apt-get update \ - && apt-get install -y vn-mariadb \ - && apt-get purge -y --auto-remove curl ca-certificates \ - && rm -rf /var/lib/apt/lists/* - COPY docker/docker.cnf /etc/mysql/conf.d/ COPY \ + docker/docker-start.sh \ docker/docker-init.sh \ - docker/docker-temp-start.sh \ docker/docker-temp-stop.sh \ docker/docker-dump.sh \ - docker/docker-start.sh \ + docker/docker-structure.sh \ + docker/docker-fixtures.sh \ /usr/local/bin/ RUN mkdir /mysql-data \ @@ -31,26 +23,16 @@ WORKDIR /docker-boot COPY \ import-changes.sh \ config.ini \ - dump/mysqlPlugins.sql \ dump/structure.sql \ dump/mockDate.sql \ dump/dumpedFixtures.sql \ ./ -RUN gosu mysql docker-init.sh \ - && docker-dump.sh mysqlPlugins \ - && docker-dump.sh structure \ - && sed -i -e 's/@mockDate/'"$MOCKDATE"'/g' mockDate.sql \ - && docker-dump.sh mockDate \ - && docker-dump.sh dumpedFixtures \ - && gosu mysql docker-temp-stop.sh - +RUN sed -i -e 's/@mockDate/'"$MOCKDATE"'/g' mockDate.sql \ + && gosu mysql docker-structure.sh COPY changes ./changes COPY dump/fixtures.sql ./ ARG STAMP=unknown -RUN gosu mysql docker-temp-start.sh \ - && ./import-changes.sh \ - && docker-dump.sh fixtures \ - && gosu mysql docker-temp-stop.sh +RUN gosu mysql docker-fixtures.sh RUN echo "[INFO] -> Import finished" \ && rm -rf /docker-boot diff --git a/db/docker/docker-temp-stop.sh b/db/docker/docker-temp-stop.sh old mode 100755 new mode 100644 diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index abb5516f7..2513972db 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -782,6 +782,38 @@ USE `sage`; -- Dumping data for table `TiposIva` -- +LOCK TABLES `taxType` WRITE; +/*!40000 ALTER TABLE `taxType` DISABLE KEYS */; +INSERT INTO `sage`.`taxType` (id, code, isIntracommunity) VALUES + (2, NULL, 0), + (4, 'national4', 0), + (5, NULL, 0), + (6, NULL, 1), + (7, NULL, 1), + (8, NULL, 1), + (10, 'national10', 0), + (11, NULL, 0), + (16, 'CEEServices21', 1), + (18, NULL, 0), + (20, 'national0', 0), + (21, 'national21', 0), + (22, 'import10', 0), + (26, NULL, 0), + (90, 'import21', 0), + (91, NULL, 0), + (92, NULL, 0), + (93, NULL, 0), + (94, NULL, 0), + (100, NULL, 0), + (108, NULL, 0), + (109, NULL, 0), + (110, NULL, 1), + (111, NULL, 0), + (112, NULL, 0), + (113, 'ISP21', 0), + (114, NULL, 0), + (115, 'import4', 0); + LOCK TABLES `TiposIva` WRITE; /*!40000 ALTER TABLE `TiposIva` DISABLE KEYS */; INSERT INTO `TiposIva` VALUES (2,0,'Operaciones no sujetas',0.0000000000,0.0000000000,0.0000000000,'','4770000020','','','','','','','95B21A93-5910-489D-83BB-C32788C9B19D','','','','','','','','','',0,0),(4,0,'I.V.A. 4%',0.0000000000,4.0000000000,0.0000000000,'4720000004','4770000004','','6310000000','','','','','9E6160D5-984E-4643-ACBC-1EBC3BF73360','','','','','','','','','',0,0),(5,0,'I.V.A. 4% y R.E. 0.5%',0.0000000000,4.0000000000,0.5000000000,'','4770000504','4770000405','','','','','','DBEFA562-63FB-4FFC-8171-64F0C6F065FF','','','','','','','','','',0,0),(6,0,'H.P. IVA 4% CEE',0.0000000000,4.0000000000,0.0000000000,'4721000004','4771000004','','','','','','','DD0ECBA8-2EF5-425E-911B-623580BADA77','','','','','','','','','',0,1),(7,0,'H.P. IVA 10% CEE',0.0000000000,10.0000000000,0.0000000000,'4721000011','4771000010','','','','','','','593208CD-6F28-4489-B6EC-907AD689EAC9','','','','','','','','','',0,1),(8,0,'H.P. IVA 21% CEE',0.0000000000,21.0000000000,0.0000000000,'4721000021','4771000021','','','','','','','27061852-9BC1-4C4F-9B6E-69970E208F23','','','','','','','','','',0,1),(10,0,'I.V.A. 10% Nacional',0.0000000000,10.0000000000,0.0000000000,'4720000011','4770000010','','6290000553','','','','','828A9D6F-5C01-4C3A-918A-B2E4482830D3','','','','','','','','','',0,0),(11,0,'I.V.A. 10% y R.E. 1,4%',0.0000000000,10.0000000000,1.4000000000,'','4770000101','4770000110','','','','','','C1F2D910-83A1-4191-A76C-8B3D7AB98348','','','','','','','','','',0,0),(16,0,'I.V.A. Adqui. servicios CEE',0.0000000000,21.0000000000,0.0000000000,'4721000015','4771000016','','','','','','','E3EDE961-CE8F-41D4-9E6C-D8BCD32275A1','','','','','','','','','',0,1),(18,0,'H.P. Iva Importación 0% ISP',0.0000000000,0.0000000000,0.0000000000,'4720000005','4770000005','','','','','','','27AD4158-2349-49C2-B53A-A4E0EFAC5D09','','','','','','','','','',0,0),(20,0,'I.V.A 0% Nacional',0.0000000000,0.0000000000,0.0000000000,'4720000000','','','','','','','','B90B0FBD-E513-4F04-9721-C873504E08DF','','','','','','','','','',0,0),(21,0,'I.V.A. 21%',0.0000000000,21.0000000000,0.0000000000,'4720000021','4770000021','4770000000','','','','','','BA8C4E28-DCFA-4F7B-AE4F-CA044626B55E','','','','','','','','','',0,0),(22,0,'IVA 10% importaciones',0.0000000000,10.0000000000,0.0000000000,'4722000010','','','','','','','','540450A8-4B41-4607-96D1-E7F296FB6933','','','','','','','','','',0,0),(26,0,'I.V.A. 21% y R.E. 5,2%',0.0000000000,21.0000000000,5.2000000000,'4720000021','4770000215','4770000521','631000000','','','','','2BC0765F-7739-49AE-A5F0-28B648B81677','','','','','','','','','',0,0),(90,0,'IVA 21% importaciones',0.0000000000,21.0000000000,0.0000000000,'4722000021','','','','','','','','EB675F91-5FF2-4E26-A31E-EEB674125945','','','','','','','','','',0,0),(91,0,'IVA 0% importaciones',0.0000000000,0.0000000000,0.0000000000,'4723000000','','','','','','','','5E5EFA56-2A99-4D54-A16B-5D818274CA18','','','','','','','','','',0,0),(92,0,'8.5% comp. ganadera o pesquera',0.0000000000,8.5000000000,0.0000000000,'4720000000','4770000000','477000000','631000000','','','','','','','','','','','','','','',0,0),(93,0,'12% com. agrícola o forestal',0.0000000000,12.0000000000,0.0000000000,'4720000012','','','','','','','','267B1DDB-247F-4A71-AB95-3349FEFC5F92','','','','','','','','','',0,0),(94,0,'10,5% com. ganadera o pesquera',0.0000000000,10.5000000000,0.0000000000,'4770000000','4720000000','631000000','477000000','','','','','','','','','','','','','','',0,0),(100,0,'HP IVA SOPORTADO 5%',0.0000000000,5.0000000000,0.0000000000,'4720000055','','','','','','','','3AD36CB2-4172-4CC9-9F87-2BF2B56AAC80','','','','','','','','','',0,0),(108,0,'I.V.A. 8%',0.0000000000,8.0000000000,0.0000000000,'4720000000','4770000000','477000000','631000000','','','','','','','','','','','','','','',0,0),(109,0,'I.V.A. 8% y R.E. 1%',0.0000000000,8.0000000000,1.0000000000,'4720000000','4770000000','477000000','631000000','','','','','','','','','','','','','','',0,0),(110,0,'HP IVA Devengado Exento CEE',0.0000000000,0.0000000000,0.0000000000,'','4771000000','','','','','','','C605BC32-E161-42FD-83F3-3A66B1FBE399','','','','','','','','','',0,1),(111,0,'H.P. Iva Devengado Exento Ser',0.0000000000,0.0000000000,0.0000000000,'','4771000001','','','','','','','F1AEC4DC-AFE5-498E-A713-2648FFB6DA32','','','','','','','','','',0,0),(112,0,'H.P. IVA Devengado en exportac',0.0000000000,0.0000000000,0.0000000000,'','4770000002','','','','','','','F980AE74-BF75-4F4C-927F-0CCCE0DB8D15','','','','','','','','','',0,0),(113,0,'HP DEVENGADO 21 ISP ',0.0000000000,21.0000000000,0.0000000000,'4720000006','4770000006','','','','','','','728D7A76-E936-438C-AF05-3CA38FE16EA5','','','','','','','','','',0,0),(114,0,'HP.IVA NO DEDUCIBLE 10%',0.0000000000,0.0000000000,0.0000000000,'4720000026','','','','','','','','','','','','','','','','','',0,0),(115,0,'H.P. IVA Soportado Impor 4% ',0.0000000000,4.0000000000,0.0000000000,'4722000004','','','','','','','','','','','','','','','','','',0,0); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 15fa96a79..3f4433fa1 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -71,8 +71,8 @@ INSERT INTO `account`.`roleConfig`(`id`, `mysqlPassword`, `rolePrefix`, `userPre CALL `account`.`role_sync`; -INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`, `lang`, `image`, `bcryptPassword`) - SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2' +INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `role`,`active`,`email`, `lang`, `image`, `password`) + SELECT id, name, CONCAT(name, 'Nick'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2' FROM `account`.`role` WHERE id <> 20 ORDER BY id; @@ -98,20 +98,24 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` VALUES (1, 978, 1, 0, 2000, 9, 0); -INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `bcryptPassword`, `password`,`role`,`active`,`email`,`lang`, `image`) +INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`) VALUES - (1101, 'BruceWayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1102, 'PetterParker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1103, 'ClarkKent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1104, 'TonyStark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'TonyStark@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1105, 'MaxEisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1106, 'DavidCharlesHaller', 'David Charles Haller', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1107, 'HankPym', 'Hank Pym', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'HankPym@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1108, 'CharlesXavier', 'Charles Xavier', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'CharlesXavier@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1109, 'BruceBanner', 'Bruce Banner', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'BruceBanner@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1110, 'JessicaJones', 'Jessica Jones', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'JessicaJones@mydomain.com', 'en', NULL), - (1111, 'Missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en', NULL), - (1112, 'Trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en', NULL); + (1101, 'BruceWayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1102, 'PetterParker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1103, 'ClarkKent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1104, 'TonyStark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1105, 'MaxEisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1106, 'DavidCharlesHaller', 'David Charles Haller', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1107, 'HankPym', 'Hank Pym', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'HankPym@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1108, 'CharlesXavier', 'Charles Xavier', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'CharlesXavier@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1109, 'BruceBanner', 'Bruce Banner', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'BruceBanner@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1110, 'JessicaJones', 'Jessica Jones', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'JessicaJones@mydomain.com', 'en', NULL), + (1111, 'Missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL), + (1112, 'Trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL); + +UPDATE account.`user` + SET passExpired = DATE_SUB(util.VN_CURDATE(), INTERVAL 1 YEAR) + WHERE name = 'maintenance'; INSERT INTO `account`.`mailAlias`(`id`, `alias`, `description`, `isPublic`) VALUES @@ -179,6 +183,8 @@ INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAd (2, 'printer2', 'path2', 1, 1 , NULL), (4, 'printer4', 'path4', 0, NULL, '10.1.10.4'); +UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1; + INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`, `sectorFk`, `labelerFk`) VALUES (1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106, NULL, NULL), @@ -905,7 +911,7 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`, `weightByPiece`) VALUES - (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0, 15,3), + (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'EMB', 0, NULL, 'V', 0, 15,3), (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0, 10,2), (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, 5,5), (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL), @@ -2729,7 +2735,9 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) VALUES (1, 'print-email', 'notification fixture one'), (2, 'invoice-electronic', 'A electronic invoice has been generated'), - (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'); + (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'), + (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'), + (5, 'modified-entry', 'An entry has been modified'); INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES @@ -2783,7 +2791,9 @@ INSERT INTO `vn`.`ticketLog` (`originFk`, userFk, `action`, changedModel, oldIns (7, 18, 'update', 'Sale', '{"quantity":1}', '{"quantity":10}', 1, NULL), (7, 18, 'update', 'Ticket', '{"quantity":1,"concept":"Chest ammo box"}', '{"quantity":10,"concept":"Chest ammo box"}', 1, NULL), (7, 18, 'update', 'Sale', '{"price":3}', '{"price":5}', 1, NULL), - (7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 1x0.5m de '5' a '10'"); + (7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 1x0.5m de '5' a '10'"), + (16, 9, 'update', 'Sale', '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', '{"quantity":8,"concept":"Shield", "price": 10.5, "itemFk": 1}' , 5689, 'Shield'); + INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedModel, changedModelId, changedModelValue, oldInstance, newInstance, description) VALUES @@ -2797,7 +2807,6 @@ INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedM (1, 18, 'select', '2000-12-27 03:40:30', 'Ticket', 45, NULL , NULL, NULL, NULL), (1, 18, 'insert', '2000-04-10 09:40:15', 'Sale', 5689, 'Shield' , NULL, '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', NULL), (1, 18, 'insert', '1999-05-09 10:00:00', 'Ticket', 45, 'Super Man' , NULL, '{"id":45,"clientFk":8608,"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","addressFk":48637,"isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"created":"2023-05-16T11:42:56.000Z","isBlocked":false,"hasPriority":false,"companyFk":442,"agencyModeFk":639,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}', NULL); - INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`) VALUES (0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all'); @@ -2886,6 +2895,17 @@ INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`) (2, 1, 50, 2), (3, 1, 0, 3); +INSERT INTO `vn`.`travelConfig` (`id`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `companyFk`) + VALUES + (1, 1, 1, 1, 442); +INSERT INTO `vn`.`buyConfig` (`id`, `monthsAgo`) + VALUES + (1, 6); - +INSERT INTO `vn`.`invoiceInSerial` (`code`, `description`, `cplusTerIdNifFk`, `taxAreaFk`) + VALUES + ('C', 'Asgard', 1, 'WORLD'), + ('E', 'Midgard', 1, 'CEE'), + ('R', 'Jotunheim', 1, 'NATIONAL'), + ('W', 'Vanaheim', 1, 'WORLD'); diff --git a/db/dump/mockDate.sql b/db/dump/mockDate.sql index 2b4c33d74..5d4d0c351 100644 --- a/db/dump/mockDate.sql +++ b/db/dump/mockDate.sql @@ -1,30 +1,19 @@ -DROP FUNCTION IF EXISTS `util`.`mockTime`; DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTime`() RETURNS datetime + +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTime`() RETURNS datetime DETERMINISTIC BEGIN RETURN CONVERT_TZ('@mockDate', 'utc', 'Europe/Madrid'); END$$ -DELIMITER ; -DROP FUNCTION IF EXISTS `util`.`mockUtcTime`; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`mockUtcTime`() RETURNS datetime +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`mockUtcTime`() RETURNS datetime DETERMINISTIC BEGIN RETURN CONVERT_TZ('@mockDate', 'utc', 'Europe/Madrid'); END$$ -DELIMITER ; -DROP FUNCTION IF EXISTS `util`.`mockTimeBase`; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTimeBase`(vIsUtc BOOL) RETURNS datetime +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTimeBase`(vIsUtc BOOL) RETURNS datetime DETERMINISTIC BEGIN RETURN CONVERT_TZ('@mockDate', 'utc', 'Europe/Madrid'); diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 3ce7f7bb5..b07e88fde 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -15620,6 +15620,18 @@ CREATE TABLE `ClavesOperacion` ( -- -- Table structure for table `Municipios` -- +DROP TABLE IF EXISTS `taxType`; + +CREATE TABLE `taxType` ( + id INT(11) NOT NULL, + code VARCHAR(25) DEFAULT NULL NULL, + isIntracommunity TINYINT(1) DEFAULT FALSE NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `taxType_UN` (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Coincidencia del id con Sage.TiposIVA.CodigoIva(propia de Sage), en ningún caso vincular mediate FK'; + +ALTER TABLE `sage`.`taxType` ADD CONSTRAINT taxType_PK PRIMARY KEY IF NOT EXISTS (id); +ALTER TABLE `sage`.`taxType` ADD CONSTRAINT taxType_UN UNIQUE KEY IF NOT EXISTS (code); DROP TABLE IF EXISTS `Municipios`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -22074,12 +22086,14 @@ CREATE TABLE `autonomy` ( `name` varchar(100) NOT NULL, `countryFk` mediumint(8) unsigned NOT NULL, `geoFk` int(11) DEFAULT NULL, + `isUeeMember` tinyint(1) DEFAULT NULL, + `hasDailyInvoice` tinyint(4) DEFAULT NULL, PRIMARY KEY (`id`), KEY `autonomy_FK` (`countryFk`), KEY `autonomy_FK_1` (`geoFk`), CONSTRAINT `autonomy_FK` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `autonomy_FK_1` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Comunidades autónomas o su equivalente en otros paises. Agrupación de provincias, en una categoria inferior a country.'; +) ENGINE=InnoDB AUTO_INCREMENT=109 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Comunidades autónomas o su equivalente en otros paises. Agrupación de provincias, en una categoria inferior a country.'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -28805,7 +28819,10 @@ CREATE TABLE `expence` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; - +ALTER TABLE `vn`.`expence` + ADD code VARCHAR(25) DEFAULT NULL NULL; +ALTER TABLE `vn`.`expence` + ADD CONSTRAINT expence_UN UNIQUE KEY IF NOT EXISTS (code); -- -- Table structure for table `farming` -- @@ -57317,7 +57334,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `invoiceInBookingMain` */; +/*!50003 DROP PROCEDURE IF EXISTS `invoiceIn_booking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -57326,28 +57343,71 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; + + + DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInBookingMain`(vInvoiceInId INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`(vSelf INT) BEGIN - DECLARE vTotalAmount,vTotalAmountDivisa DECIMAL(10,2); - DECLARE vBookNumber,vSerialNumber INT; - DECLARE vRate DECIMAL(10,4); + DECLARE vBookNumber INT; - CALL invoiceInBookingCommon(vInvoiceInId,vSerialNumber); - - SELECT SUM(iit.taxableBase * IF( i.serial= 'R' AND ti.Iva <> 'HP DEVENGADO 21 ISP', 1 +(ti.PorcentajeIva/100),1)), - SUM(iit.foreignValue * IF( i.serial= 'R', 1 + (ti.PorcentajeIva/100),1)), - iit.taxableBase/iit.foreignValue - INTO vTotalAmount, vTotalAmountDivisa, vRate - FROM newInvoiceIn i - JOIN invoiceInTax iit ON iit.invoiceInFk = i.id - LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk; + DROP TEMPORARY TABLE IF EXISTS tInvoiceIn; + CREATE TEMPORARY TABLE tInvoiceIn + ENGINE = MEMORY + SELECT ii.bookEntried, + iit.foreignValue, + ii.companyFk, + ii.expenceFkDeductible, + iit.taxableBase, + ii.serial, + ii.issued, + ii.operated, + ii.supplierRef, + ii.cplusTrascendency472Fk, + ii.cplusTaxBreakFk, + ii.cplusSubjectOpFk, + ii.cplusInvoiceType472Fk, + ii.cplusRectificationTypeFk, + ii.booked, + IFNULL(a.isUeeMember, c.isUeeMember) isUeeMember, + (c.id = cc.id) isSameCountry, + s.account supplierAccount, + s.name supplierName, + s.nif, + iit.taxTypeSageFk, + tt.code taxCode, + ti.Iva, + ti.CuentaIvaSoportado, + ti.PorcentajeIva, + ti.CuentaIvaRepercutido, + ttr.ClaveOperacionDefecto, + iis.cplusTerIdNifFk, + cit.id invoicesCount, + e.code, + e.isWithheld, + e.id expenceFk, + e.name expenceName + FROM invoiceIn ii + JOIN supplier s ON s.id = ii.supplierFk + LEFT JOIN province p ON p.id = s.provinceFk + LEFT JOIN autonomy a ON a.id = p.autonomyFk + JOIN country c ON c.id = s.countryFk + JOIN supplier sc ON sc.id = ii.companyFk + JOIN country cc ON cc.id = sc.countryFk + JOIN invoiceInSerial iis ON iis.code = ii.serial + JOIN cplusInvoiceType472 cit ON cit.id = ii.cplusInvoiceType472Fk + LEFT JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id + LEFT JOIN sage.TiposTransacciones ttr ON ttr.CodigoTransaccion = iit.transactionTypeSageFk + LEFT JOIN expence e ON e.id = iit.expenceFk + LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk + LEFT JOIN sage.taxType tt ON tt.id = ti.CodigoIva + WHERE ii.id = vSelf; CALL vn.ledger_next(vBookNumber); -- Apunte del proveedor - - INSERT INTO XDiario(ASIEN, + INSERT INTO XDiario( + ASIEN, FECHA, SUBCTA, EUROHABER, @@ -57356,24 +57416,30 @@ BEGIN HABERME, NFACTICK, CLAVE, - empresa_id - ) + empresa_id) SELECT - vBookNumber, - n.bookEntried, - s.supplierAccount, - vTotalAmount EUROHABER, - n.conceptWithSupplier, - vRate, - vTotalAmountDivisa, - n.invoicesCount, - vInvoiceInId, - n.companyFk - FROM newInvoiceIn n - JOIN newSupplier s; + vBookNumber ASIEN, + tii.bookEntried FECHA, + tii.supplierAccount SUBCTA, + SUM(tii.taxableBase * + IF(tii.serial= 'R' AND ((tii.taxCode IS NULL OR tii.taxCode <> 'ISP21') + AND tii.taxTypeSageFk IS NOT NULL), + 1 + (tii.PorcentajeIva / 100), + 1)) EUROHABER, + CONCAT('s/fra', + RIGHT(tii.supplierRef, 8), + ':', + LEFT(tii.supplierName, 10)) CONCEPTO, + CAST(tii.taxableBase / tii.foreignValue AS DECIMAL (10,4)) CAMBIO, + SUM(tii.foreignValue * IF(tii.serial = 'R', 1 + (tii.PorcentajeIva / 100), 1)) HABERME, + tii.invoicesCount NFACTICK, + vSelf CLAVE, + tii.companyFk empresa_id + FROM tInvoiceIn tii; -- Línea de Gastos - INSERT INTO XDiario ( ASIEN, + INSERT INTO XDiario( + ASIEN, FECHA, SUBCTA, CONTRA, @@ -57384,30 +57450,29 @@ BEGIN DEBEME, HABERME, NFACTICK, - empresa_id - ) + empresa_id) SELECT vBookNumber ASIEN, - n.bookEntried FECHA, - IF(e.isWithheld , LPAD(RIGHT(s.supplierAccount,5),10,iit.expenceFk),iit.expenceFk) SUBCTA, - s.supplierAccount CONTRA, - IF(e.isWithheld AND iit.taxableBase < 0, NULL, ROUND(SUM(iit.taxableBase),2)) EURODEBE, - IF(e.isWithheld AND iit.taxableBase < 0,ROUND(SUM(-iit.taxableBase),2),NULL) EUROHABER, - n.conceptWithSupplier CONCEPTO, - vRate, - IF(e.isWithheld,NULL,ABS(ROUND(SUM(iit.foreignValue),2))) DEBEME, - IF(e.isWithheld,ABS(ROUND(SUM(iit.foreignValue),2)),NULL) HABERME, - n.invoicesCount NFACTICK, - n.companyFk empresa_id - FROM newInvoiceIn n - JOIN newSupplier s - JOIN invoiceInTax iit ON iit.invoiceInFk = n.id - JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = iit.expenceFk - WHERE e.name != 'Suplidos Transitarios nacionales' - GROUP BY iit.expenceFk; + tii.bookEntried FECHA, + IF(tii.isWithheld, LPAD(RIGHT(tii.supplierAccount, 5), 10, tii.expenceFk),tii.expenceFk) SUBCTA, + tii.supplierAccount CONTRA, + IF(tii.isWithheld AND tii.taxableBase < 0, NULL, ROUND(SUM(tii.taxableBase),2)) EURODEBE, + IF(tii.isWithheld AND tii.taxableBase < 0, ROUND(SUM(-tii.taxableBase), 2), NULL) EUROHABER, + CONCAT('s/fra', + RIGHT(tii.supplierRef, 8), + ':', + LEFT(tii.supplierName, 10)) CONCEPTO, + CAST(tii.taxableBase / tii.foreignValue AS DECIMAL (10, 4)) CAMBIO, + IF(tii.isWithheld, NULL,ABS(ROUND(SUM(tii.foreignValue), 2))) DEBEME, + IF(tii.isWithheld, ABS(ROUND(SUM(tii.foreignValue), 2)) ,NULL) HABERME, + tii.invoicesCount NFACTICK, + tii.companyFk empresa_id + FROM tInvoiceIn tii + WHERE tii.code IS NULL OR tii.code <> 'suplido' + GROUP BY tii.expenceFk; -- Líneas de IVA - - INSERT INTO XDiario( ASIEN, + INSERT INTO XDiario( + ASIEN, FECHA, SUBCTA, CONTRA, @@ -57434,56 +57499,50 @@ BEGIN TERNIF, TERNOM, FECREGCON, - empresa_id - ) + empresa_id) SELECT vBookNumber ASIEN, - n.bookEntried FECHA, - IF(n.expenceFkDeductible>0, n.expenceFkDeductible, ti.CuentaIvaSoportado) SUBCTA, - s.supplierAccount CONTRA, - SUM(ROUND(ti.PorcentajeIva * it.taxableBase / 100 /* + 0.0001*/ , 2)) EURODEBE, - SUM(it.taxableBase) BASEEURO, - GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO, - vSerialNumber FACTURA, - ti.PorcentajeIva IVA, - IF(isUeeMember AND eWithheld.id IS NULL,'','*') AUXILIAR, - n.serial SERIE, - ttr.ClaveOperacionDefecto, - n.issued FECHA_EX, - n.operated FECHA_OP, - n.invoicesCount NFACTICK, - n.supplierRef FACTURAEX, + tii.bookEntried FECHA, + IF(tii.expenceFkDeductible>0, tii.expenceFkDeductible, tii.CuentaIvaSoportado) SUBCTA, + tii.supplierAccount CONTRA, + SUM(ROUND(tii.PorcentajeIva * tii.taxableBase / 100, 2)) EURODEBE, + SUM(tii.taxableBase) BASEEURO, + GROUP_CONCAT(DISTINCT tii.expenceName SEPARATOR ', ') CONCEPTO, + vSelf FACTURA, + tii.PorcentajeIva IVA, + IF(tii.isUeeMember AND eWithheld.id IS NULL, '', '*') AUXILIAR, + tii.serial SERIE, + tii.ClaveOperacionDefecto, + tii.issued FECHA_EX, + tii.operated FECHA_OP, + tii.invoicesCount NFACTICK, + tii.supplierRef FACTURAEX, TRUE L340, - (isSameCountry OR NOT isUeeMember) LRECT349, - n.cplusTrascendency472Fk TIPOCLAVE, - n.cplusTaxBreakFk TIPOEXENCI, - n.cplusSubjectOpFk TIPONOSUJE, - n.cplusInvoiceType472Fk TIPOFACT, - n.cplusRectificationTypeFk TIPORECTIF, - iis.cplusTerIdNifFk TERIDNIF, - s.nif AS TERNIF, - s.name AS TERNOM, - n.booked FECREGCON, - n.companyFk - FROM newInvoiceIn n - JOIN newSupplier s - JOIN invoiceInTax it ON n.id = it.invoiceInFk - JOIN sage.TiposIva ti ON ti.CodigoIva = it.taxTypeSageFk - JOIN sage.TiposTransacciones ttr ON ttr.CodigoTransaccion = it.transactionTypeSageFk - JOIN invoiceInSerial iis ON iis.code = n.serial - JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = it.expenceFk + (tii.isSameCountry OR NOT tii.isUeeMember) LRECT349, + tii.cplusTrascendency472Fk TIPOCLAVE, + tii.cplusTaxBreakFk TIPOEXENCI, + tii.cplusSubjectOpFk TIPONOSUJE, + tii.cplusInvoiceType472Fk TIPOFACT, + tii.cplusRectificationTypeFk TIPORECTIF, + tii.cplusTerIdNifFk TERIDNIF, + tii.nif TERNIF, + tii.supplierName TERNOM, + tii.booked FECREGCON, + tii.companyFk + FROM tInvoiceIn tii LEFT JOIN ( - SELECT eWithheld.id - FROM invoiceInTax hold - JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld - WHERE hold.invoiceInFk = vInvoiceInId LIMIT 1 + SELECT e.id + FROM tInvoiceIn tii + JOIN expence e ON e.id = tii.expenceFk + WHERE e.isWithheld + LIMIT 1 ) eWithheld ON TRUE - WHERE it.taxTypeSageFk IS NOT NULL - AND it.taxTypeSageFk NOT IN (22, 90) - GROUP BY ti.PorcentajeIva, e.id; + WHERE tii.taxTypeSageFk IS NOT NULL + AND (tii.taxCode IS NULL OR tii.taxCode NOT IN ('import10', 'import21')) + GROUP BY tii.PorcentajeIva, tii.expenceFk; -- Línea iva inversor sujeto pasivo - - INSERT INTO XDiario( ASIEN, + INSERT INTO XDiario( + ASIEN, FECHA, SUBCTA, CONTRA, @@ -57509,50 +57568,43 @@ BEGIN TERIDNIF, TERNIF, TERNOM, - empresa_id - ) + empresa_id) SELECT vBookNumber ASIEN, - n.bookEntried FECHA, - ti.CuentaIvaRepercutido SUBCTA, - s.supplierAccount CONTRA, - SUM(ROUND(ti.PorcentajeIva * it.taxableBase / 100,2)) EUROHABER, - ROUND(SUM(it.taxableBase),2) BASEEURO, - GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO, - vSerialNumber FACTURA, - ti.PorcentajeIva IVA, + tii.bookEntried FECHA, + tii.CuentaIvaRepercutido SUBCTA, + tii.supplierAccount CONTRA, + SUM(ROUND(tii.PorcentajeIva * tii.taxableBase / 100,2)) EUROHABER, + ROUND(SUM(tii.taxableBase),2) BASEEURO, + GROUP_CONCAT(DISTINCT tii.expenceName SEPARATOR ', ') CONCEPTO, + vSelf FACTURA, + tii.PorcentajeIva IVA, '*' AUXILIAR, - n.serial SERIE, - ttr.ClaveOperacionDefecto, - n.issued FECHA_EX, - n.operated FECHA_OP, - n.invoicesCount NFACTICK, - n.supplierRef FACTURAEX, + tii.serial SERIE, + tii.ClaveOperacionDefecto, + tii.issued FECHA_EX, + tii.operated FECHA_OP, + tii.invoicesCount NFACTICK, + tii.supplierRef FACTURAEX, FALSE L340, - (isSameCountry OR NOT isUeeMember) LRECT349, + (tii.isSameCountry OR NOT tii.isUeeMember) LRECT349, 1 TIPOCLAVE, - n.cplusTaxBreakFk TIPOEXENCI, - n.cplusSubjectOpFk TIPONOSUJE, - n.cplusInvoiceType472Fk TIPOFACT, - n.cplusRectificationTypeFk TIPORECTIF, - iis.cplusTerIdNifFk TERIDNIF, - s.nif AS TERNIF, - s.name AS TERNOM, - n.companyFk - FROM newInvoiceIn n - JOIN newSupplier s - JOIN invoiceInTax it ON n.id = it.invoiceInFk - JOIN sage.TiposIva ti ON ti.CodigoIva = it.taxTypeSageFk - JOIN sage.TiposTransacciones ttr ON ttr.CodigoTransaccion = it.transactionTypeSageFk - JOIN invoiceInSerial iis ON iis.code = n.serial - JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = it.expenceFk - WHERE ti.Iva = 'HP DEVENGADO 21 ISP' OR MID(s.account, 4, 1) = '1' - GROUP BY ti.PorcentajeIva, e.id; + tii.cplusTaxBreakFk TIPOEXENCI, + tii.cplusSubjectOpFk TIPONOSUJE, + tii.cplusInvoiceType472Fk TIPOFACT, + tii.cplusRectificationTypeFk TIPORECTIF, + tii.cplusTerIdNifFk TERIDNIF, + tii.nif TERNIF, + tii.supplierName TERNOM, + tii.companyFk + FROM tInvoiceIn tii + WHERE tii.taxCode = 'ISP21' OR MID(tii.supplierAccount, 4, 1) = '1' + AND tii.taxTypeSageFk IS NOT NULL + GROUP BY tii.PorcentajeIva, tii.expenceFk; -- Actualización del registro original UPDATE invoiceIn ii - JOIN newInvoiceIn ni ON ii.id = ni.id - SET ii.serialNumber = vSerialNumber, - ii.isBooked = TRUE; + SET ii.isBooked = TRUE + WHERE ii.id = vSelf; -- Problemas derivados de la precisión en los decimales al calcular los impuestos UPDATE XDiario @@ -57569,8 +57621,12 @@ BEGIN ORDER BY id DESC LIMIT 1; + DROP TEMPORARY TABLE tInvoiceIn; END ;; DELIMITER ; + + + /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; diff --git a/db/export-data.sh b/db/export-data.sh index 2288c1c62..1df4db030 100755 --- a/db/export-data.sh +++ b/db/export-data.sh @@ -110,5 +110,6 @@ TABLES=( TiposIva TiposTransacciones TiposRetencion + taxType ) dump_tables ${TABLES[@]} diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 2f979aa4b..5ef7e7f19 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -311,9 +311,9 @@ export default { }, clientDefaulter: { anyClient: 'vn-client-defaulter tbody > tr', - firstClientName: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(2) > span', - firstSalesPersonName: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(3) > span', - firstObservation: 'vn-client-defaulter tbody > tr:nth-child(1) > td:nth-child(8) > vn-textarea[ng-model="defaulter.observation"]', + firstClientName: 'vn-client-defaulter tbody > tr:nth-child(2) > td:nth-child(2) > span', + firstSalesPersonName: 'vn-client-defaulter tbody > tr:nth-child(2) > td:nth-child(3) > span', + firstObservation: 'vn-client-defaulter tbody > tr:nth-child(2) > td:nth-child(8) > vn-textarea[ng-model="defaulter.observation"]', allDefaulterCheckbox: 'vn-client-defaulter thead vn-multi-check', addObservationButton: 'vn-client-defaulter vn-button[icon="icon-notes"]', observation: '.vn-dialog.shown vn-textarea[ng-model="$ctrl.defaulter.observation"]', @@ -334,15 +334,15 @@ export default { }, itemsIndex: { createItemButton: `vn-float-button`, - firstSearchResult: 'vn-item-index tbody tr:nth-child(1)', + firstSearchResult: 'vn-item-index tbody tr:nth-child(2)', searchResult: 'vn-item-index tbody tr:not(.empty-rows)', - firstResultPreviewButton: 'vn-item-index tbody > :nth-child(1) .buttons > [icon="preview"]', + firstResultPreviewButton: 'vn-item-index tbody > :nth-child(2) .buttons > [icon="preview"]', searchResultCloneButton: 'vn-item-index .buttons > [icon="icon-clone"]', acceptClonationAlertButton: '.vn-confirm.shown [response="accept"]', closeItemSummaryPreview: '.vn-popup.shown', shownColumns: 'vn-item-index vn-button[id="shownColumns"]', shownColumnsList: '.vn-popover.shown .content', - firstItemImage: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(1) > img', + firstItemImage: 'vn-item-index tbody > tr:nth-child(2) > td:nth-child(1) > img', firstItemImageTd: 'vn-item-index smart-table tr:nth-child(1) td:nth-child(1)', firstItemId: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(2)', idCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Identifier"]', @@ -523,11 +523,11 @@ export default { searchResultDate: 'vn-ticket-summary [label=Landed] span', topbarSearch: 'vn-searchbar', moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]', - fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(4)', - fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)', + fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)', + fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(6)', weeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr', - firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) vn-icon-button[icon="delete"]', - firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) [ng-model="weekly.agencyModeFk"]', + firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(2) vn-icon-button[icon="delete"]', + firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(2) [ng-model="weekly.agencyModeFk"]', acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]' }, createTicketView: { @@ -572,15 +572,15 @@ export default { submitNotesButton: 'button[type=submit]' }, ticketExpedition: { - firstSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(1) vn-check[ng-model="expedition.checked"]', - thirdSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(3) vn-check[ng-model="expedition.checked"]', - deleteExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="delete"]', - moveExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="keyboard_arrow_down"]', + firstSaleCheckbox: 'vn-ticket-expedition tr:nth-child(2) vn-check[ng-model="expedition.checked"]', + thirdSaleCheckbox: 'vn-ticket-expedition tr:nth-child(4) vn-check[ng-model="expedition.checked"]', + deleteExpeditionButton: 'vn-ticket-expedition slot-actions > vn-button[icon="delete"]', + moveExpeditionButton: 'vn-ticket-expedition slot-actions > vn-button[icon="keyboard_arrow_down"]', moreMenuWithoutRoute: 'vn-item[name="withoutRoute"]', moreMenuWithRoute: 'vn-item[name="withRoute"]', newRouteId: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newRoute"]', saveButton: '.vn-dialog.shown [response="accept"]', - expeditionRow: 'vn-ticket-expedition vn-table vn-tbody > vn-tr' + expeditionRow: 'vn-ticket-expedition table tbody > tr' }, ticketSales: { setOk: 'vn-ticket-sale vn-tool-bar > vn-button[label="Ok"] > button', @@ -595,6 +595,8 @@ export default { moreMenuUpdateDiscount: 'vn-item[name="discount"]', moreMenuRecalculatePrice: 'vn-item[name="calculatePrice"]', moreMenuRefund: 'vn-item[name="refund"]', + refundWithWarehouse: 'vn-item[name="refundWithWarehouse"]', + refundWithoutWarehouse: 'vn-item[name="refundWithoutWarehouse"]', moreMenuUpdateDiscountInput: 'vn-input-number[ng-model="$ctrl.edit.discount"] input', transferQuantityInput: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable > span > text', transferQuantityCell: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable', @@ -710,7 +712,7 @@ export default { problems: 'vn-check[label="With problems"]', tableButtonSearch: 'vn-button[vn-tooltip="Search"]', moveButton: 'vn-button[vn-tooltip="Future tickets"]', - firstCheck: 'tbody > tr:nth-child(1) > td > vn-check', + firstCheck: 'tbody > tr:nth-child(2) > td > vn-check', multiCheck: 'vn-multi-check', tableId: 'vn-textfield[name="id"]', tableFutureId: 'vn-textfield[name="futureId"]', @@ -734,7 +736,7 @@ export default { tableButtonSearch: 'vn-button[vn-tooltip="Search"]', moveButton: 'vn-button[vn-tooltip="Advance tickets"]', acceptButton: '.vn-confirm.shown button[response="accept"]', - firstCheck: 'tbody > tr:nth-child(1) > td > vn-check', + firstCheck: 'tbody > tr:nth-child(2) > td > vn-check', tableId: 'vn-textfield[name="id"]', tableFutureId: 'vn-textfield[name="futureId"]', tableLiters: 'vn-textfield[name="liters"]', @@ -808,7 +810,7 @@ export default { claimAction: { importClaimButton: 'vn-claim-action vn-button[label="Import claim"]', anyLine: 'vn-claim-action vn-tbody > vn-tr', - firstDeleteLine: 'vn-claim-action tr:nth-child(1) vn-icon-button[icon="delete"]', + firstDeleteLine: 'vn-claim-action tr:nth-child(2) vn-icon-button[icon="delete"]', isPaidWithManaCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.isChargedToMana"]' }, ordersIndex: { @@ -1233,7 +1235,7 @@ export default { addTagButton: 'vn-icon-button[vn-tooltip="Add tag"]', itemTagInput: 'vn-autocomplete[ng-model="itemTag.tagFk"]', itemTagValueInput: 'vn-autocomplete[ng-model="itemTag.value"]', - firstBuy: 'vn-entry-latest-buys tbody > tr:nth-child(1)', + firstBuy: 'vn-entry-latest-buys tbody > tr:nth-child(2)', allBuysCheckBox: 'vn-entry-latest-buys thead vn-check', secondBuyCheckBox: 'vn-entry-latest-buys tbody tr:nth-child(2) vn-check[ng-model="buy.checked"]', editBuysButton: 'vn-entry-latest-buys vn-button[icon="edit"]', diff --git a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js index c4f091d1f..9c37ce9ba 100644 --- a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js +++ b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js @@ -19,15 +19,14 @@ describe('SmartTable SearchBar integration', () => { await page.waitToClick(selectors.itemsIndex.openAdvancedSearchButton); await page.autocompleteSearch(selectors.itemsIndex.advancedSearchItemType, 'Anthurium'); await page.waitToClick(selectors.itemsIndex.advancedSearchButton); - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 3); + await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4); await page.reload({ waitUntil: 'networkidle2' }); - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 3); + await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4); - await page.waitToClick(selectors.itemsIndex.advancedSmartTableButton); await page.write(selectors.itemsIndex.advancedSmartTableGrouping, '1'); await page.keyboard.press('Enter'); await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2); @@ -36,7 +35,7 @@ describe('SmartTable SearchBar integration', () => { waitUntil: 'networkidle2' }); - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2); + await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1); }); it('should filter in section without smart-table and search in searchBar go to zone section', async() => { @@ -64,6 +63,6 @@ describe('SmartTable SearchBar integration', () => { await page.reload({ waitUntil: 'networkidle2' }); - await page.waitForTextInField(selectors.itemFixedPrice.firstItemID, '13'); + await page.waitForTextInField(selectors.itemFixedPrice.firstItemID, '3'); }); }); diff --git a/e2e/paths/02-client/21_defaulter.spec.js b/e2e/paths/02-client/21_defaulter.spec.js index 97e62abef..2bb3d6254 100644 --- a/e2e/paths/02-client/21_defaulter.spec.js +++ b/e2e/paths/02-client/21_defaulter.spec.js @@ -19,7 +19,7 @@ describe('Client defaulter path', () => { it('should count the amount of clients in the turns section', async() => { const result = await page.countElement(selectors.clientDefaulter.anyClient); - expect(result).toEqual(5); + expect(result).toEqual(6); }); it('should check contain expected client', async() => { diff --git a/e2e/paths/04-item/01_summary.spec.js b/e2e/paths/04-item/01_summary.spec.js index e24fa6a9f..e09ecb778 100644 --- a/e2e/paths/04-item/01_summary.spec.js +++ b/e2e/paths/04-item/01_summary.spec.js @@ -18,11 +18,11 @@ describe('Item summary path', () => { await page.doSearch('Ranged weapon'); const resultsCount = await page.countElement(selectors.itemsIndex.searchResult); - await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon'); + await page.waitForTextInElement(selectors.itemsIndex.firstSearchResult, 'Ranged weapon'); await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); const isVisible = await page.isVisible(selectors.itemSummary.basicData); - expect(resultsCount).toBe(3); + expect(resultsCount).toBe(4); expect(isVisible).toBeTruthy(); }); @@ -66,7 +66,7 @@ describe('Item summary path', () => { await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); await page.waitForSelector(selectors.itemSummary.basicData, {visible: true}); - expect(resultsCount).toBe(2); + expect(resultsCount).toBe(3); }); it(`should now check the item summary preview shows fields from basic data`, async() => { diff --git a/e2e/paths/04-item/10_item_log.spec.js b/e2e/paths/04-item/10_item_log.spec.js index dc467044d..c88fbd337 100644 --- a/e2e/paths/04-item/10_item_log.spec.js +++ b/e2e/paths/04-item/10_item_log.spec.js @@ -18,7 +18,7 @@ describe('Item log path', () => { await page.doSearch('Knowledge artifact'); const nResults = await page.countElement(selectors.itemsIndex.searchResult); - expect(nResults).toEqual(0); + expect(nResults).toEqual(1); }); it('should access to the create item view by clicking the create floating button', async() => { diff --git a/e2e/paths/04-item/13_fixedPrice.spec.js b/e2e/paths/04-item/13_fixedPrice.spec.js index 37c4401b0..f36138e18 100644 --- a/e2e/paths/04-item/13_fixedPrice.spec.js +++ b/e2e/paths/04-item/13_fixedPrice.spec.js @@ -88,7 +88,8 @@ describe('Item fixed prices path', () => { it('should reload the section and check the created price has the expected ID', async() => { await page.goto(`http://localhost:5000/#!/item/fixed-price`); - + await page.autocompleteSearch($.warehouseFilter, 'Warehouse one'); + await page.click($.chip); const result = await page.waitToGetProperty($.fourthItemID, 'value'); expect(result).toContain('13'); diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 2c9646708..6264073f6 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -220,14 +220,25 @@ describe('Ticket Edit sale path', () => { it('should log in as salesAssistant and navigate to ticket sales', async() => { await page.loginAndModule('salesAssistant', 'ticket'); - await page.accessToSearchResult('16'); + await page.accessToSearchResult('17'); await page.accessToSection('ticket.card.sale'); }); - it('should select the third sale and create a refund', async() => { + it('should select the first sale and create a refund with warehouse', async() => { await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenuRefund); + await page.waitToClick(selectors.ticketSales.refundWithWarehouse); + await page.waitForSnackbar(); + await page.waitForState('ticket.card.sale'); + }); + + it('should select the first sale and create a refund without warehouse', async() => { + await page.accessToSearchResult('18'); + await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); + await page.waitToClick(selectors.ticketSales.moreMenu); + await page.waitToClick(selectors.ticketSales.moreMenuRefund); + await page.waitToClick(selectors.ticketSales.refundWithoutWarehouse); await page.waitForSnackbar(); await page.waitForState('ticket.card.sale'); }); @@ -246,7 +257,6 @@ describe('Ticket Edit sale path', () => { it('should select the third sale and create a claim of it', async() => { await page.accessToSearchResult('16'); await page.accessToSection('ticket.card.sale'); - await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox); await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim); @@ -316,7 +326,7 @@ describe('Ticket Edit sale path', () => { it('should confirm the transfered quantity is the correct one', async() => { const result = await page.waitToGetProperty(selectors.ticketSales.secondSaleQuantityCell, 'innerText'); - expect(result).toContain('10'); + expect(result).toContain('20'); }); it('should go back to the original ticket sales section', async() => { diff --git a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js index edccd5561..b97576940 100644 --- a/e2e/paths/05-ticket/02_expeditions_and_log.spec.js +++ b/e2e/paths/05-ticket/02_expeditions_and_log.spec.js @@ -27,6 +27,6 @@ describe('Ticket expeditions and log path', () => { const result = await page .countElement(selectors.ticketExpedition.expeditionRow); - expect(result).toEqual(3); + expect(result).toEqual(4); }); }); diff --git a/e2e/paths/05-ticket/09_weekly.spec.js b/e2e/paths/05-ticket/09_weekly.spec.js index 0ba57aa9d..a9cce2ead 100644 --- a/e2e/paths/05-ticket/09_weekly.spec.js +++ b/e2e/paths/05-ticket/09_weekly.spec.js @@ -19,7 +19,7 @@ describe('Ticket descriptor path', () => { it('should count the amount of tickets in the turns section', async() => { const result = await page.countElement(selectors.ticketsIndex.weeklyTicket); - expect(result).toEqual(6); + expect(result).toEqual(7); }); it('should go back to the ticket index then search and access a ticket summary', async() => { @@ -89,7 +89,7 @@ describe('Ticket descriptor path', () => { await page.doSearch('11'); const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); - expect(nResults).toEqual(1); + expect(nResults).toEqual(2); }); it('should delete the weekly ticket 11', async() => { @@ -104,7 +104,7 @@ describe('Ticket descriptor path', () => { await page.doSearch(); const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); - expect(nResults).toEqual(6); + expect(nResults).toEqual(7); }); it('should update the agency then remove it afterwards', async() => { diff --git a/e2e/paths/05-ticket/20_moveExpedition.spec.js b/e2e/paths/05-ticket/20_moveExpedition.spec.js index cf1c5ded3..ae23c9c99 100644 --- a/e2e/paths/05-ticket/20_moveExpedition.spec.js +++ b/e2e/paths/05-ticket/20_moveExpedition.spec.js @@ -29,7 +29,7 @@ describe('Ticket expeditions', () => { const result = await page .countElement(selectors.ticketExpedition.expeditionRow); - expect(result).toEqual(1); + expect(result).toEqual(2); }); it(`should move one expedition to new ticket with route`, async() => { @@ -45,6 +45,6 @@ describe('Ticket expeditions', () => { const result = await page .countElement(selectors.ticketExpedition.expeditionRow); - expect(result).toEqual(1); + expect(result).toEqual(2); }); }); diff --git a/e2e/paths/05-ticket/21_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js index 82525c1db..7b7d478f7 100644 --- a/e2e/paths/05-ticket/21_future.spec.js +++ b/e2e/paths/05-ticket/21_future.spec.js @@ -1,8 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -// 'https:// redmine.verdnatura.es/issues/5642' -xdescribe('Ticket Future path', () => { +describe('Ticket Future path', () => { let browser; let page; let httpRequest; @@ -22,7 +21,7 @@ xdescribe('Ticket Future path', () => { await browser.close(); }); - it('should show errors snackbar because of the required data', async() => { + it('should search with required data, check three last tickets and move to the future', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.warehouseFk); await page.waitToClick(selectors.ticketFuture.submit); @@ -43,69 +42,58 @@ xdescribe('Ticket Future path', () => { message = await page.waitForSnackbar(); expect(message.text).toContain('originDated is a required argument'); + + await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + await page.waitToClick(selectors.ticketFuture.submit); + + expect(httpRequest).toBeDefined(); + + await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + + await page.autocompleteSearch(selectors.ticketFuture.ipt, 'H'); + await page.waitToClick(selectors.ticketFuture.submit); + + expect(httpRequest).toContain('ipt=H'); + + await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + + await page.clearInput(selectors.ticketFuture.ipt); + + await page.autocompleteSearch(selectors.ticketFuture.futureIpt, 'H'); + await page.waitToClick(selectors.ticketFuture.submit); + + expect(httpRequest).toContain('futureIpt=H'); + + await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + + await page.clearInput(selectors.ticketFuture.futureIpt); + + await page.autocompleteSearch(selectors.ticketFuture.state, 'Free'); + await page.waitToClick(selectors.ticketFuture.submit); + + expect(httpRequest).toContain('state=FREE'); + + await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + + await page.clearInput(selectors.ticketFuture.state); + + await page.autocompleteSearch(selectors.ticketFuture.futureState, 'Free'); + await page.waitToClick(selectors.ticketFuture.submit); + + expect(httpRequest).toContain('futureState=FREE'); + + await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + await page.clearInput(selectors.ticketFuture.state); + await page.clearInput(selectors.ticketFuture.futureState); + await page.waitToClick(selectors.ticketFuture.submit); + + await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 5); + await page.waitToClick(selectors.ticketFuture.multiCheck); + await page.waitToClick(selectors.ticketFuture.firstCheck); + await page.waitToClick(selectors.ticketFuture.moveButton); + await page.waitToClick(selectors.globalItems.acceptButton); + message = await page.waitForSnackbar(); + + expect(message.text).toContain('Tickets moved successfully!'); }); - - // it('should search with the required data', async() => { - // await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - // await page.waitToClick(selectors.ticketFuture.submit); - - // expect(httpRequest).toBeDefined(); - // }); - - // it('should search with the origin IPT', async() => { - // await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - - // await page.autocompleteSearch(selectors.ticketFuture.ipt, 'H'); - // await page.waitToClick(selectors.ticketFuture.submit); - - // expect(httpRequest).toContain('ipt=H'); - // }); - - // it('should search with the destination IPT', async() => { - // await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - - // await page.clearInput(selectors.ticketFuture.ipt); - - // await page.autocompleteSearch(selectors.ticketFuture.futureIpt, 'H'); - // await page.waitToClick(selectors.ticketFuture.submit); - - // expect(httpRequest).toContain('futureIpt=H'); - // }); - - // it('should search with the origin grouped state', async() => { - // await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - - // await page.clearInput(selectors.ticketFuture.futureIpt); - - // await page.autocompleteSearch(selectors.ticketFuture.state, 'Free'); - // await page.waitToClick(selectors.ticketFuture.submit); - - // expect(httpRequest).toContain('state=FREE'); - // }); - - // it('should search with the destination grouped state', async() => { - // await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - - // await page.clearInput(selectors.ticketFuture.state); - - // await page.autocompleteSearch(selectors.ticketFuture.futureState, 'Free'); - // await page.waitToClick(selectors.ticketFuture.submit); - - // expect(httpRequest).toContain('futureState=FREE'); - - // await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - // await page.clearInput(selectors.ticketFuture.futureState); - // await page.waitToClick(selectors.ticketFuture.submit); - // }); - - // it('should check the three last tickets and move to the future', async() => { - // await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 4); - // await page.waitToClick(selectors.ticketFuture.multiCheck); - // await page.waitToClick(selectors.ticketFuture.firstCheck); - // await page.waitToClick(selectors.ticketFuture.moveButton); - // await page.waitToClick(selectors.globalItems.acceptButton); - // const message = await page.waitForSnackbar(); - - // expect(message.text).toContain('Tickets moved successfully!'); - // }); }); diff --git a/e2e/paths/05-ticket/22_advance.spec.js b/e2e/paths/05-ticket/22_advance.spec.js index f27120b3b..0e5b5e0c3 100644 --- a/e2e/paths/05-ticket/22_advance.spec.js +++ b/e2e/paths/05-ticket/22_advance.spec.js @@ -1,8 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -// 'https:// redmine.verdnatura.es/issues/5642' -xdescribe('Ticket Advance path', () => { +describe('Ticket Advance path', () => { let browser; let page; let httpRequest; @@ -22,7 +21,7 @@ xdescribe('Ticket Advance path', () => { await browser.close(); }); - it('should show errors snackbar because of the required data', async() => { + it('should search with the required data, check the first ticket and move to the present', async() => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.clearInput(selectors.ticketAdvance.warehouseFk); @@ -44,45 +43,37 @@ xdescribe('Ticket Advance path', () => { message = await page.waitForSnackbar(); expect(message.text).toContain('dateFuture is a required argument'); + + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.waitToClick(selectors.ticketAdvance.submit); + + expect(httpRequest).toBeDefined(); + + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'H'); + await page.waitToClick(selectors.ticketAdvance.submit); + + expect(httpRequest).toContain('futureIpt=H'); + + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.clearInput(selectors.ticketAdvance.futureIpt); + await page.waitToClick(selectors.ticketAdvance.submit); + + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'H'); + await page.waitToClick(selectors.ticketAdvance.submit); + + expect(httpRequest).toContain('ipt=H'); + + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.clearInput(selectors.ticketAdvance.ipt); + await page.waitToClick(selectors.ticketAdvance.submit); + + await page.waitToClick(selectors.ticketAdvance.firstCheck); + await page.waitToClick(selectors.ticketAdvance.moveButton); + await page.waitToClick(selectors.ticketAdvance.acceptButton); + message = await page.waitForSnackbar(); + + expect(message.text).toContain('Tickets moved successfully!'); }); - - // it('should search with the required data', async() => { - // await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - // await page.waitToClick(selectors.ticketAdvance.submit); - - // expect(httpRequest).toBeDefined(); - // }); - - // it('should search with the origin IPT', async() => { - // await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - // await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'H'); - // await page.waitToClick(selectors.ticketAdvance.submit); - - // expect(httpRequest).toContain('futureIpt=H'); - - // await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - // await page.clearInput(selectors.ticketAdvance.futureIpt); - // await page.waitToClick(selectors.ticketAdvance.submit); - // }); - - // it('should search with the destination IPT', async() => { - // await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - // await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'H'); - // await page.waitToClick(selectors.ticketAdvance.submit); - - // expect(httpRequest).toContain('ipt=H'); - - // await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - // await page.clearInput(selectors.ticketAdvance.ipt); - // await page.waitToClick(selectors.ticketAdvance.submit); - // }); - - // it('should check the first ticket and move to the present', async() => { - // await page.waitToClick(selectors.ticketAdvance.firstCheck); - // await page.waitToClick(selectors.ticketAdvance.moveButton); - // await page.waitToClick(selectors.ticketAdvance.acceptButton); - // const message = await page.waitForSnackbar(); - - // expect(message.text).toContain('Tickets moved successfully!'); - // }); }); diff --git a/e2e/paths/06-claim/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js index 9656ea656..1333ed01a 100644 --- a/e2e/paths/06-claim/05_summary.spec.js +++ b/e2e/paths/06-claim/05_summary.spec.js @@ -49,7 +49,11 @@ describe('Claim summary path', () => { }); it(`should click on the first sale ID making the item descriptor visible`, async() => { - await page.waitToClick(selectors.claimSummary.firstSaleItemId); + const firstItem = selectors.claimSummary.firstSaleItemId; + await page.evaluate(selectors => { + document.querySelector(selectors).scrollIntoView(); + }, firstItem); + await page.click(firstItem); await page.waitImgLoad(selectors.claimSummary.firstSaleDescriptorImage); const visible = await page.isVisible(selectors.claimSummary.itemDescriptorPopover); diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index b2380a62f..c3b927c62 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -40,6 +40,8 @@ export default class SmartTable extends Component { this._options = options; if (!options) return; + options.defaultSearch = true; + if (options.defaultSearch) this.displaySearch(); diff --git a/front/core/services/auth.js b/front/core/services/auth.js index 0b89a8e88..41cd27f03 100644 --- a/front/core/services/auth.js +++ b/front/core/services/auth.js @@ -24,7 +24,7 @@ export default class Auth { initialize() { let criteria = { to: state => { - const outLayout = ['login', 'recover-password', 'reset-password']; + const outLayout = ['login', 'recover-password', 'reset-password', 'change-password']; return !outLayout.some(ol => ol == state.name); } }; @@ -59,8 +59,8 @@ export default class Auth { password: password || undefined }; - return this.$http.post('VnUsers/signIn', params).then( - json => this.onLoginOk(json, remember)); + return this.$http.post('VnUsers/signIn', params) + .then(json => this.onLoginOk(json, remember)); } onLoginOk(json, remember) { diff --git a/front/core/styles/util.scss b/front/core/styles/util.scss index 95a523ff4..8c345ddcc 100644 --- a/front/core/styles/util.scss +++ b/front/core/styles/util.scss @@ -1,4 +1,11 @@ +@import "./variables"; +@import "./effects"; +@mixin mobile { + @media screen and (max-width: $mobile-width) { + @content; + } +} @mixin browser($browser) { html[data-browser*="#{$browser}"] & { @content; diff --git a/front/core/styles/variables.scss b/front/core/styles/variables.scss index bcc9fab66..0a74c8277 100644 --- a/front/core/styles/variables.scss +++ b/front/core/styles/variables.scss @@ -1,5 +1,3 @@ -@import "./util"; - $font-size: 11pt; $menu-width: 256px; $topbar-height: 56px; diff --git a/front/salix/components/background/style.scss b/front/salix/components/background/style.scss index c75b69c52..5bc56683e 100644 --- a/front/salix/components/background/style.scss +++ b/front/salix/components/background/style.scss @@ -1,4 +1,4 @@ -@import "variables"; +@import "util"; @keyframes fadein { from { @@ -16,7 +16,7 @@ vn-background { background-color: black; z-index: 14; - @media screen and (max-width: $mobile-width) { + @include mobile { &.shown { display: block; opacity: .3; diff --git a/front/salix/components/index.js b/front/salix/components/index.js index 8f5724862..0999d9aca 100644 --- a/front/salix/components/index.js +++ b/front/salix/components/index.js @@ -9,6 +9,7 @@ import './login'; import './outLayout'; import './recover-password'; import './reset-password'; +import './change-password'; import './module-card'; import './module-main'; import './side-menu/side-menu'; diff --git a/front/salix/components/layout/style.scss b/front/salix/components/layout/style.scss index 612366228..fa3e8f918 100644 --- a/front/salix/components/layout/style.scss +++ b/front/salix/components/layout/style.scss @@ -1,4 +1,4 @@ -@import "effects"; +@import "util"; vn-layout { & > vn-topbar { @@ -134,7 +134,7 @@ vn-layout { border-radius: 50%; } } - @media screen and (max-width: $mobile-width) { + @include mobile { & > vn-topbar { & > .start > .logo { display: none; diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html index d5675975b..8b33c811b 100644 --- a/front/salix/components/log/index.html +++ b/front/salix/components/log/index.html @@ -16,7 +16,7 @@ + class="vn-w-sm vn-px-sm vn-pb-xl">
-
- - - {{::$ctrl.relativeDate(log.creationDate)}} -
+
+ {{::$ctrl.relativeDate(log.creationDate)}} + + +
-
+
#{{::log.changedModelId}} - {{::log.changedModelValue}} + + + {{::log.changedModelValue}}
{{::prop.nameI18n}}: - , + ,
{{::prop.nameI18n}}: - + - ← + ←
@@ -96,10 +99,36 @@
+ +
+ + + + + + + + + label="Changes" + ng-model="filter.changes"> - - - - - - - - -
diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js index ef1b370b5..8aea255a2 100644 --- a/front/salix/components/log/index.js +++ b/front/salix/components/log/index.js @@ -64,29 +64,47 @@ export default class Controller extends Section { set logs(value) { this._logs = value; if (!value) return; + const empty = {}; const validations = window.validations; + const castJsonValue = this.castJsonValue; + for (const log of value) { - const oldValues = log.oldInstance || empty; - const newValues = log.newInstance || empty; + const notDelete = log.action != 'delete'; + const olds = (notDelete ? log.oldInstance : null) || empty; + const vals = (notDelete ? log.newInstance : log.oldInstance) || empty; const locale = validations[log.changedModel]?.locale || empty; log.changedModelI18n = firstUpper(locale.name) || log.changedModel; - let props = Object.keys(oldValues).concat(Object.keys(newValues)); + let props = Object.keys(olds).concat(Object.keys(vals)); props = [...new Set(props)]; log.props = []; for (const prop of props) { + if (prop.endsWith('$')) continue; log.props.push({ name: prop, nameI18n: firstUpper(locale.columns?.[prop]) || prop, - old: this.castJsonValue(oldValues[prop]), - new: this.castJsonValue(newValues[prop]) + old: getVal(olds, prop), + val: getVal(vals, prop) }); } log.props.sort( (a, b) => a.nameI18n.localeCompare(b.nameI18n)); } + + function getVal(vals, prop) { + let val, id; + const showProp = `${prop}$`; + + if (vals[showProp] != null) { + val = vals[showProp]; + id = vals[prop]; + } else + val = vals[prop]; + + return {val: castJsonValue(val), id}; + } } get models() { @@ -113,10 +131,6 @@ export default class Controller extends Section { : value; } - mainVal(prop, action) { - return action == 'delete' ? prop.old : prop.new; - } - relativeDate(dateVal) { if (dateVal == null) return ''; const date = new Date(dateVal); @@ -150,14 +164,15 @@ export default class Controller extends Section { if (value == null || value == '') return null; switch (prop) { case 'search': - if (/^[0-9]+$/.test(value)) - return {changedModelId: value}; + const or = []; + if (/^\s*[0-9]+\s*$/.test(value)) + return {changedModelId: value.trim()}; else return {changedModelValue: {like: `%${value}%`}}; case 'changes': return {or: [ - {oldInstance: {like: `%${value}%`}}, - {newInstance: {like: `%${value}%`}}, + {oldJson: {like: `%${value}%`}}, + {newJson: {like: `%${value}%`}}, {description: {like: `%${value}%`}} ]}; case 'who': @@ -206,6 +221,14 @@ export default class Controller extends Section { return this.$.model.applyFilter(lbFilter); } + filterByEntity(log) { + this.$.filter = { + who: 'all', + search: log.changedModelId, + changedModel: log.changedModel + }; + } + searchUser(search) { if (/^[0-9]+$/.test(search)) { return {id: search}; @@ -238,3 +261,12 @@ ngModule.vnComponent('vnLog', { url: '@' } }); + +ngModule.component('vnLogValue', { + template: + '' + + ' #{{::$ctrl.val.id}}', + bindings: { + val: ' vn-icon { + @extend %clickable-light; + vertical-align: middle; + padding: 2px; + margin: -2px; + font-size: 18px; + color: $color-font-secondary; + float: right; + display: none; + + @include mobile { + display: initial; + } + } & > .model-value { font-style: italic; } @@ -107,6 +121,9 @@ vn-log { font-size: .9rem; } } + &:hover > .model > vn-icon { + display: initial; + } } } .changes { @@ -144,3 +161,7 @@ vn-log { } } } +vn-log-value > .id-value { + font-size: .9rem; + color: $color-font-secondary; +} diff --git a/front/salix/components/login/index.js b/front/salix/components/login/index.js index 150e896a1..8e8f08244 100644 --- a/front/salix/components/login/index.js +++ b/front/salix/components/login/index.js @@ -5,10 +5,11 @@ import './style.scss'; * A simple login form. */ export default class Controller { - constructor($, $element, vnAuth) { + constructor($, $element, $state, vnAuth) { Object.assign(this, { $, $element, + $state, vnAuth, user: localStorage.getItem('lastUser'), remember: true @@ -22,11 +23,15 @@ export default class Controller { localStorage.setItem('lastUser', this.user); this.loading = false; }) - .catch(err => { + .catch(req => { this.loading = false; this.password = ''; this.focusUser(); - throw err; + const err = req.data?.error; + if (err?.code == 'passExpired') + this.$state.go('change-password', err.details.token); + + throw req; }); } @@ -35,7 +40,7 @@ export default class Controller { this.$.userField.focus(); } } -Controller.$inject = ['$scope', '$element', 'vnAuth']; +Controller.$inject = ['$scope', '$element', '$state', 'vnAuth']; ngModule.vnComponent('vnLogin', { template: require('./index.html'), diff --git a/front/salix/components/outLayout/style.scss b/front/salix/components/outLayout/style.scss index aa94fefb3..a95b75835 100644 --- a/front/salix/components/outLayout/style.scss +++ b/front/salix/components/outLayout/style.scss @@ -64,4 +64,25 @@ vn-out-layout{ a{ color: $color-primary; } + + .footer { + margin-top: 32px; + text-align: center; + position: relative; + & > .vn-submit { + display: block; + + & > input { + display: block; + width: 100%; + } + } + & > .spinner-wrapper { + position: absolute; + width: 0; + top: 3px; + right: -8px; + overflow: visible; + } + } } diff --git a/front/salix/components/recover-password/index.js b/front/salix/components/recover-password/index.js index e91169588..5ffc305f9 100644 --- a/front/salix/components/recover-password/index.js +++ b/front/salix/components/recover-password/index.js @@ -1,5 +1,4 @@ import ngModule from '../../module'; -import './style.scss'; export default class Controller { constructor($scope, $element, $http, vnApp, $translate, $state) { diff --git a/front/salix/components/reset-password/index.js b/front/salix/components/reset-password/index.js index a3ca03237..c0a10cc52 100644 --- a/front/salix/components/reset-password/index.js +++ b/front/salix/components/reset-password/index.js @@ -1,5 +1,5 @@ import ngModule from '../../module'; -import './style.scss'; +const UserError = require('vn-loopback/util/user-error'); export default class Controller { constructor($scope, $element, $http, vnApp, $translate, $state, $location) { diff --git a/front/salix/components/user-popover/index.js b/front/salix/components/user-popover/index.js index 6cc47db7d..1d88137ff 100644 --- a/front/salix/components/user-popover/index.js +++ b/front/salix/components/user-popover/index.js @@ -20,8 +20,6 @@ class Controller { name: config.languages[code] ? config.languages[code] : code }); } - - vnConfig.initialize(); } set lang(value) { diff --git a/front/salix/routes.js b/front/salix/routes.js index f32c143ef..675da719a 100644 --- a/front/salix/routes.js +++ b/front/salix/routes.js @@ -10,6 +10,9 @@ function config($stateProvider, $urlRouterProvider) { .state('layout', { abstract: true, template: '', + resolve: { + config: ['vnConfig', vnConfig => vnConfig.initialize()] + } }) .state('outLayout', { abstract: true, @@ -33,6 +36,12 @@ function config($stateProvider, $urlRouterProvider) { description: 'Reset password', template: '' }) + .state('change-password', { + parent: 'outLayout', + url: '/change-password?id&userId', + description: 'Change password', + template: '' + }) .state('home', { parent: 'layout', url: '/', diff --git a/front/salix/styles/misc.scss b/front/salix/styles/misc.scss index 02bfd9f17..9b2829d0b 100644 --- a/front/salix/styles/misc.scss +++ b/front/salix/styles/misc.scss @@ -1,5 +1,4 @@ -@import "./variables"; -@import "./effects"; +@import "./util"; form vn-horizontal { align-items: center; @@ -22,10 +21,10 @@ form vn-horizontal { } } - @media screen and (max-width: $mobile-width) { + @include mobile { flex-direction: column; align-items: initial; - + & > * { &, &:first-child, diff --git a/loopback/common/models/log.json b/loopback/common/models/log.json index 54046f072..6d246371c 100644 --- a/loopback/common/models/log.json +++ b/loopback/common/models/log.json @@ -1,4 +1,61 @@ { - "name": "Log", - "base": "VnModel" + "name": "Log", + "base": "VnModel", + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "oldJson": { + "type": "String", + "mysql": {"columnName": "oldInstance"} + }, + "newJson": { + "type": "String", + "mysql": {"columnName": "newInstance"} + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "string" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] + } } diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index f469e893a..f92e1ea09 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -1,6 +1,7 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const UserError = require('vn-loopback/util/user-error'); +const utils = require('loopback/lib/utils'); module.exports = function(Self) { Self.ParameterizedSQL = ParameterizedSQL; @@ -164,23 +165,21 @@ module.exports = function(Self) { function rewriteMethod(methodName) { const realMethod = this[methodName]; - return async(data, options, cb) => { - if (options instanceof Function) { - cb = options; - options = null; - } + return function(...args) { + let cb; + const lastArg = args[args.length - 1]; + if (lastArg instanceof Function) { + cb = lastArg; + args.pop(); + } else + cb = utils.createPromiseCallback(); - try { - const result = await realMethod.call(this, data, options); - - if (cb) cb(null, result); - else return result; - } catch (err) { - let myErr = replaceErr(err, replaceErrFunc); - if (cb) cb(myErr); - else - throw myErr; - } + args.push(function(err, res) { + if (err) err = replaceErr(err, replaceErrFunc); + cb(err, res); + }); + realMethod.apply(this, args); + return cb.promise; }; } @@ -196,8 +195,48 @@ module.exports = function(Self) { /* * Shortcut to VnMySQL.executeP() */ - rawSql(query, params, options, cb) { - return this.dataSource.connector.executeP(query, params, options, cb); + async rawSql(query, params, options) { + const userId = options?.userId; + const connector = this.dataSource.connector; + let conn; + let res; + const opts = Object.assign({}, options); + + try { + if (userId) { + conn = await new Promise((resolve, reject) => { + connector.client.getConnection(function(err, conn) { + if (err) + reject(err); + else + resolve(conn); + }); + }); + + const opts = Object.assign({}, options); + if (!opts.transaction) { + opts.transaction = { + connection: conn, + connector + }; + } + + await connector.executeP( + 'CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?))', + [userId], opts + ); + } + + res = await connector.executeP(query, params, opts); + + if (userId) { + await connector.executeP('CALL account.myUser_logout()', null, opts); + } + } finally { + if (conn) conn.release(); + } + + return res; }, /* diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 14ffffeb5..43ff4b86a 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -172,6 +172,8 @@ "Comment added to client": "Comment added to client", "This ticket is already a refund": "This ticket is already a refund", "A claim with that sale already exists": "A claim with that sale already exists", + "Pass expired": "The password has expired, change it from Salix", "Can't transfer claimed sales": "Can't transfer claimed sales", - "Invalid quantity": "Invalid quantity" + "Invalid quantity": "Invalid quantity", + "Failed to upload delivery note": "Error to upload delivery note {{id}}" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d88a4ebc9..7e2701f95 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -77,14 +77,13 @@ "This ticket can not be modified": "Este ticket no puede ser modificado", "The introduced hour already exists": "Esta hora ya ha sido introducida", "INFINITE_LOOP": "Existe una dependencia entre dos Jefes", - "The sales of the current ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas", "The sales of the receiver ticket can't be modified": "Las lineas del ticket al que envias no pueden ser modificadas", "NO_AGENCY_AVAILABLE": "No hay una zona de reparto disponible con estos parámetros", "ERROR_PAST_SHIPMENT": "No puedes seleccionar una fecha de envío en pasado", "The current ticket can't be modified": "El ticket actual no puede ser modificado", "The current claim can't be modified": "La reclamación actual no puede ser modificada", "The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas", - "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", + "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", "Please select at least one sale": "Por favor selecciona al menos una linea", "All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket", "NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", @@ -259,7 +258,7 @@ "App name does not exist": "El nombre de aplicación no es válido", "Try again": "Vuelve a intentarlo", "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", - "Failed to upload file": "Error al subir archivo", + "Failed to upload delivery note": "Error al subir albarán {{id}}", "The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe", "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar", "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo", @@ -291,6 +290,7 @@ "isTaxDataChecked": "Datos comprobados", "comercialId": "Id comercial", "comercialName": "Comercial", + "Pass expired": "La contraseña ha caducado, cambiela desde Salix", "Invalid NIF for VIES": "Invalid NIF for VIES", "Ticket does not exist": "Este ticket no existe", "Ticket is already signed": "Este ticket ya ha sido firmado" diff --git a/modules/account/back/locale/role-inherit/en.yml b/modules/account/back/locale/role-inherit/en.yml index 760881325..8422ecdce 100644 --- a/modules/account/back/locale/role-inherit/en.yml +++ b/modules/account/back/locale/role-inherit/en.yml @@ -1,4 +1,5 @@ name: subrole columns: + id: id role: rol inheritsFrom: inherits diff --git a/modules/account/back/locale/role-inherit/es.yml b/modules/account/back/locale/role-inherit/es.yml index c352c6ff2..10381628c 100644 --- a/modules/account/back/locale/role-inherit/es.yml +++ b/modules/account/back/locale/role-inherit/es.yml @@ -1,4 +1,5 @@ name: subrol columns: + id: id role: rol inheritsFrom: hereda diff --git a/modules/account/back/methods/account/change-password.js b/modules/account/back/methods/account/change-password.js index 549508ffa..c6f08a232 100644 --- a/modules/account/back/methods/account/change-password.js +++ b/modules/account/back/methods/account/change-password.js @@ -28,8 +28,6 @@ module.exports = Self => { }); Self.changePassword = async function(id, oldPassword, newPassword) { - await Self.rawSql(`CALL account.user_changePassword(?, ?, ?)`, - [id, oldPassword, newPassword]); - await Self.app.models.Account.syncById(id, newPassword); + await Self.app.models.VnUser.changePassword(id, oldPassword, newPassword); }; }; diff --git a/modules/account/back/methods/account/set-password.js b/modules/account/back/methods/account/set-password.js index b4204d103..010197e0d 100644 --- a/modules/account/back/methods/account/set-password.js +++ b/modules/account/back/methods/account/set-password.js @@ -22,8 +22,6 @@ module.exports = Self => { }); Self.setPassword = async function(id, newPassword) { - await Self.rawSql(`CALL account.user_setPassword(?, ?)`, - [id, newPassword]); - await Self.app.models.Account.syncById(id, newPassword); + await Self.app.models.VnUser.setPassword(id, newPassword); }; }; diff --git a/modules/account/back/methods/account/specs/change-password.spec.js b/modules/account/back/methods/account/specs/change-password.spec.js index 17fadb3c6..0fd6ecbd5 100644 --- a/modules/account/back/methods/account/specs/change-password.spec.js +++ b/modules/account/back/methods/account/specs/change-password.spec.js @@ -2,11 +2,21 @@ const {models} = require('vn-loopback/server/server'); describe('account changePassword()', () => { it('should throw an error when old password is wrong', async() => { - let err; - await models.Account.changePassword(1, 'wrongPassword', 'nightmare.9999') - .catch(error => err = error.sqlMessage); + let error; + try { + await models.Account.changePassword(1, 'wrongPassword', 'nightmare.9999'); + } catch (e) { + error = e.message; + } - expect(err).toBeDefined(); - expect(err).toEqual('Invalid password'); + expect(error).toContain('Invalid current password'); + }); + + it('should change password', async() => { + try { + await models.Account.changePassword(70, 'nightmare', 'nightmare.9999'); + } catch (e) { + expect(e).toBeUndefined(); + } }); }); diff --git a/modules/account/back/methods/account/sync-by-id.js b/modules/account/back/methods/account/sync-by-id.js index 538bc09bd..e1c631395 100644 --- a/modules/account/back/methods/account/sync-by-id.js +++ b/modules/account/back/methods/account/sync-by-id.js @@ -24,8 +24,8 @@ module.exports = Self => { } }); - Self.syncById = async function(id, password, force) { - let user = await Self.app.models.VnUser.findById(id, {fields: ['name']}); - await Self.sync(user.name, password, force); + Self.syncById = async function(id, password, force, options) { + let user = await Self.app.models.VnUser.findById(id, {fields: ['name']}, options); + await Self.sync(user.name, password, force, options); }; }; diff --git a/modules/account/back/methods/account/sync.js b/modules/account/back/methods/account/sync.js index 8668be343..a5befc22c 100644 --- a/modules/account/back/methods/account/sync.js +++ b/modules/account/back/methods/account/sync.js @@ -24,17 +24,22 @@ module.exports = Self => { } }); - Self.sync = async function(userName, password, force) { + Self.sync = async function(userName, password, force, options) { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + const models = Self.app.models; const user = await models.VnUser.findOne({ fields: ['id'], where: {name: userName} - }); - const isSync = !await models.UserSync.exists(userName); + }, myOptions); + const isSync = !await models.UserSync.exists(userName, myOptions); if (!force && isSync && user) return; await models.AccountConfig.syncUser(userName, password); - await models.UserSync.destroyById(userName); + await models.UserSync.destroyById(userName, myOptions); }; }; diff --git a/modules/account/back/models/account-config.js b/modules/account/back/models/account-config.js index 5c9d92f1e..0db699b99 100644 --- a/modules/account/back/models/account-config.js +++ b/modules/account/back/models/account-config.js @@ -1,5 +1,5 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; module.exports = Self => { Object.assign(Self, { @@ -63,7 +63,7 @@ module.exports = Self => { Object.assign(Self.prototype, { async synchronizerInit() { - let mailConfig = await app.models.MailConfig.findOne({ + let mailConfig = await models.MailConfig.findOne({ fields: ['domain'] }); @@ -91,8 +91,6 @@ module.exports = Self => { }, async synchronizerSyncUser(userName, password, syncGroups) { - let $ = app.models; - if (!userName) return; userName = userName.toLowerCase(); @@ -100,7 +98,7 @@ module.exports = Self => { if (['administrator', 'root'].indexOf(userName) >= 0) return; - let user = await $.VnUser.findOne({ + let user = await models.VnUser.findOne({ where: {name: userName}, fields: [ 'id', @@ -111,7 +109,7 @@ module.exports = Self => { 'sync', 'active', 'created', - 'bcryptPassword', + 'password', 'updated' ], include: [ @@ -138,7 +136,7 @@ module.exports = Self => { }; if (user) { - let exists = await $.Account.exists(user.id); + let exists = await models.Account.exists(user.id); Object.assign(info, { hasAccount: user.active && exists, corporateMail: `${userName}@${this.domain}`, @@ -173,30 +171,6 @@ module.exports = Self => { async synchronizerSyncRoles() { for (let synchronizer of this.synchronizers) await synchronizer.syncRoles(); - }, - - async syncUser(userName, info, password) { - if (info.user && password) - await app.models.VnUser.setPassword(info.user.id, password); - }, - - async getUsers(usersToSync) { - let accounts = await app.models.Account.find({ - fields: ['id'], - include: { - relation: 'user', - scope: { - fields: ['name'], - where: {active: true} - } - } - }); - - for (let account of accounts) { - let user = account.user(); - if (!user) continue; - usersToSync.add(user.name); - } } }); }; diff --git a/modules/account/back/models/account-config.json b/modules/account/back/models/account-config.json index 1c643ac38..a2a405610 100644 --- a/modules/account/back/models/account-config.json +++ b/modules/account/back/models/account-config.json @@ -6,9 +6,6 @@ "table": "account.accountConfig" } }, - "mixins": { - "AccountSynchronizer": {} - }, "properties": { "id": { "type": "number", diff --git a/modules/account/back/models/role-log.json b/modules/account/back/models/role-log.json index 510e98b68..324000b68 100644 --- a/modules/account/back/models/role-log.json +++ b/modules/account/back/models/role-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "account.roleLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "Account", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/account/back/models/user-log.json b/modules/account/back/models/user-log.json index c5aa08e05..8c0234aca 100644 --- a/modules/account/back/models/user-log.json +++ b/modules/account/back/models/user-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "account.userLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/account/front/accounts/index.js b/modules/account/front/accounts/index.js index 7a341b0b0..0e78ab8d6 100644 --- a/modules/account/front/accounts/index.js +++ b/modules/account/front/accounts/index.js @@ -5,8 +5,7 @@ import UserError from 'core/lib/user-error'; export default class Controller extends Section { onSynchronizeAll() { this.vnApp.showSuccess(this.$t('Synchronizing in the background')); - this.$http.patch(`Accounts/syncAll`) - .then(() => this.vnApp.showSuccess(this.$t('Users synchronized!'))); + this.$http.patch(`Accounts/syncAll`); } onUserSync() { diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js index 83043f012..cdf3fc2c3 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js @@ -63,7 +63,7 @@ module.exports = Self => { }; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/claim/back/models/claim-log.json b/modules/claim/back/models/claim-log.json index 9f28af63e..2c061b08f 100644 --- a/modules/claim/back/models/claim-log.json +++ b/modules/claim/back/models/claim-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "claimLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/client/back/methods/client/confirmTransaction.js b/modules/client/back/methods/client/confirmTransaction.js index a1969d6fd..fcb33c4ca 100644 --- a/modules/client/back/methods/client/confirmTransaction.js +++ b/modules/client/back/methods/client/confirmTransaction.js @@ -23,7 +23,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/consumptionSendQueued.js b/modules/client/back/methods/client/consumptionSendQueued.js index 07b5fb57b..a7081c550 100644 --- a/modules/client/back/methods/client/consumptionSendQueued.js +++ b/modules/client/back/methods/client/consumptionSendQueued.js @@ -1,7 +1,7 @@ const {Email} = require('vn-print'); module.exports = Self => { - Self.remoteMethod('consumptionSendQueued', { + Self.remoteMethodCtx('consumptionSendQueued', { description: 'Send all queued invoices', accessType: 'WRITE', accepts: [], @@ -15,7 +15,7 @@ module.exports = Self => { } }); - Self.consumptionSendQueued = async() => { + Self.consumptionSendQueued = async ctx => { const queues = await Self.rawSql(` SELECT id, @@ -68,7 +68,7 @@ module.exports = Self => { SET status = 'printed', printed = ? WHERE id = ?`, - [Date.vnNew(), queue.id]); + [Date.vnNew(), queue.id], {userId: ctx.req.accessToken.userId}); } catch (error) { await Self.rawSql(` UPDATE clientConsumptionQueue diff --git a/modules/client/back/methods/client/createReceipt.js b/modules/client/back/methods/client/createReceipt.js index cb032270a..b70b9bbe0 100644 --- a/modules/client/back/methods/client/createReceipt.js +++ b/modules/client/back/methods/client/createReceipt.js @@ -55,7 +55,7 @@ module.exports = function(Self) { date.setHours(0, 0, 0, 0); let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/filter.js b/modules/client/back/methods/client/filter.js index 1ae569fd3..3bf29501b 100644 --- a/modules/client/back/methods/client/filter.js +++ b/modules/client/back/methods/client/filter.js @@ -72,7 +72,7 @@ module.exports = Self => { Self.filter = async(ctx, filter, options) => { const conn = Self.dataSource.connector; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; const postalCode = []; const args = ctx.args; @@ -120,7 +120,7 @@ module.exports = Self => { const stmts = []; const stmt = new ParameterizedSQL( - `SELECT + `SELECT DISTINCT c.id, c.name, c.fi, diff --git a/modules/client/back/methods/client/getCard.js b/modules/client/back/methods/client/getCard.js index 48840b036..10e6f7adf 100644 --- a/modules/client/back/methods/client/getCard.js +++ b/modules/client/back/methods/client/getCard.js @@ -1,5 +1,5 @@ module.exports = function(Self) { - Self.remoteMethod('getCard', { + Self.remoteMethodCtx('getCard', { description: 'Get client basic data and debt', accepts: { arg: 'id', @@ -18,8 +18,8 @@ module.exports = function(Self) { } }); - Self.getCard = async(id, options) => { - const myOptions = {}; + Self.getCard = async(ctx, id, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/getDebt.js b/modules/client/back/methods/client/getDebt.js index 859746083..6ed59684b 100644 --- a/modules/client/back/methods/client/getDebt.js +++ b/modules/client/back/methods/client/getDebt.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('getDebt', { + Self.remoteMethodCtx('getDebt', { description: 'Returns the boolean debt of a client', accessType: 'READ', accepts: [{ @@ -19,8 +19,8 @@ module.exports = Self => { } }); - Self.getDebt = async(clientFk, options) => { - const myOptions = {}; + Self.getDebt = async(ctx, clientFk, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/specs/getCard.spec.js b/modules/client/back/methods/client/specs/getCard.spec.js index e713c9883..962e0a2d4 100644 --- a/modules/client/back/methods/client/specs/getCard.spec.js +++ b/modules/client/back/methods/client/specs/getCard.spec.js @@ -5,10 +5,11 @@ describe('Client getCard()', () => { const tx = await models.Client.beginTransaction({}); try { + const ctx = {req: {accessToken: {userId: 9}}}; const options = {transaction: tx}; const id = 1101; - const result = await models.Client.getCard(id, options); + const result = await models.Client.getCard(ctx, id, options); expect(result.id).toEqual(id); expect(result.name).toEqual('Bruce Wayne'); diff --git a/modules/client/back/methods/client/specs/getDebt.spec.js b/modules/client/back/methods/client/specs/getDebt.spec.js index 471d45a6d..b3b5286c0 100644 --- a/modules/client/back/methods/client/specs/getDebt.spec.js +++ b/modules/client/back/methods/client/specs/getDebt.spec.js @@ -3,11 +3,12 @@ const models = require('vn-loopback/server/server').models; describe('client getDebt()', () => { it('should return the client debt', async() => { const tx = await models.Client.beginTransaction({}); + const ctx = {req: {accessToken: {userId: 9}}}; try { const options = {transaction: tx}; - const result = await models.Client.getDebt(1101, options); + const result = await models.Client.getDebt(ctx, 1101, options); expect(result.debt).toEqual(jasmine.any(Number)); diff --git a/modules/client/back/methods/client/specs/summary.spec.js b/modules/client/back/methods/client/specs/summary.spec.js index f2d576e39..227f4c398 100644 --- a/modules/client/back/methods/client/specs/summary.spec.js +++ b/modules/client/back/methods/client/specs/summary.spec.js @@ -1,6 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('client summary()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should return a summary object containing data', async() => { const clientId = 1101; const tx = await models.Client.beginTransaction({}); @@ -8,7 +9,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.id).toEqual(clientId); expect(result.name).toEqual('Bruce Wayne'); @@ -27,7 +28,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.mana.mana).toEqual(0.34); @@ -45,7 +46,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.debt.debt).toEqual(jasmine.any(Number)); @@ -63,7 +64,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.averageInvoiced.invoiced).toEqual(1500); @@ -81,7 +82,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.totalGreuge).toEqual(203.71); @@ -99,7 +100,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.recovery).toEqual(null); @@ -117,7 +118,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.recovery.id).toEqual(3); await tx.rollback(); diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js index 7dab1f68b..8de887b47 100644 --- a/modules/client/back/methods/client/summary.js +++ b/modules/client/back/methods/client/summary.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('summary', { + Self.remoteMethodCtx('summary', { description: 'Returns a client summary', accessType: 'READ', accepts: [{ @@ -19,7 +19,7 @@ module.exports = Self => { } }); - Self.summary = async(clientFk, options) => { + Self.summary = async(ctx, clientFk, options) => { const models = Self.app.models; const myOptions = {}; @@ -28,7 +28,7 @@ module.exports = Self => { const summaryObj = await getSummary(models.Client, clientFk, myOptions); summaryObj.mana = await models.Client.getMana(clientFk, myOptions); - summaryObj.debt = await models.Client.getDebt(clientFk, myOptions); + summaryObj.debt = await models.Client.getDebt(ctx, clientFk, myOptions); summaryObj.averageInvoiced = await models.Client.getAverageInvoiced(clientFk, myOptions); summaryObj.totalGreuge = await models.Greuge.sumAmount(clientFk, myOptions); summaryObj.recovery = await getRecoveries(models.Recovery, clientFk, myOptions); diff --git a/modules/client/back/methods/tpv-transaction/end.js b/modules/client/back/methods/tpv-transaction/end.js index 5a757aa48..3233f482f 100644 --- a/modules/client/back/methods/tpv-transaction/end.js +++ b/modules/client/back/methods/tpv-transaction/end.js @@ -34,6 +34,6 @@ module.exports = Self => { 'CALL hedera.tpvTransaction_end(?, ?)', [ orderId, status - ]); + ], {userId}); }; }; diff --git a/modules/client/back/methods/tpv-transaction/start.js b/modules/client/back/methods/tpv-transaction/start.js index ea6ed05eb..178c56d76 100644 --- a/modules/client/back/methods/tpv-transaction/start.js +++ b/modules/client/back/methods/tpv-transaction/start.js @@ -40,7 +40,7 @@ module.exports = Self => { amount, companyId, userId - ]); + ], {userId}); if (!row) throw new UserError('Transaction error'); diff --git a/modules/client/back/models/client-log.json b/modules/client/back/models/client-log.json index 316dbe972..c0e69df35 100644 --- a/modules/client/back/models/client-log.json +++ b/modules/client/back/models/client-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "clientLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/client/front/credit-management/index.html b/modules/client/front/credit-management/index.html index d7456fd06..b9064ff69 100644 --- a/modules/client/front/credit-management/index.html +++ b/modules/client/front/credit-management/index.html @@ -68,7 +68,7 @@ {{::clientInforma.rating}} - {{::clientInforma.recommendedCredit}} + {{::clientInforma.recommendedCredit | currency: 'EUR': 2}} diff --git a/modules/entry/back/methods/entry/importBuys.js b/modules/entry/back/methods/entry/importBuys.js index fdc6b058e..1e6f01a5e 100644 --- a/modules/entry/back/methods/entry/importBuys.js +++ b/modules/entry/back/methods/entry/importBuys.js @@ -46,7 +46,7 @@ module.exports = Self => { const args = ctx.args; const models = Self.app.models; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); @@ -79,7 +79,7 @@ module.exports = Self => { ], myOptions); const buyUltimate = await Self.rawSql(` - SELECT * + SELECT * FROM tmp.buyUltimate WHERE warehouseFk = ? `, [travel.warehouseInFk], myOptions); diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json index ad5a9063e..ca4472c8c 100644 --- a/modules/entry/back/model-config.json +++ b/modules/entry/back/model-config.json @@ -5,6 +5,9 @@ "Buy": { "dataSource": "vn" }, + "BuyConfig": { + "dataSource": "vn" + }, "ItemMatchProperties": { "dataSource": "vn" }, diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json index 379e55427..af205533f 100644 --- a/modules/entry/back/models/buy.json +++ b/modules/entry/back/models/buy.json @@ -39,6 +39,9 @@ "packageValue": { "type": "number" }, + "price1": { + "type": "number" + }, "price2": { "type": "number" }, @@ -47,7 +50,44 @@ }, "weight": { "type": "number" + }, + "printedStickers": { + "type": "number" + }, + "dispatched": { + "type": "number" + }, + "isIgnored": { + "type": "boolean" + }, + "containerFk": { + "type": "number" + }, + "location": { + "type": "number" + }, + "minPrice": { + "type": "number" + }, + "isChecked": { + "type": "boolean" + }, + "isPickedOff": { + "type": "boolean" + }, + "created": { + "type": "date" + }, + "ektFk": { + "type": "number" + }, + "itemOriginalFk": { + "type": "number" + }, + "editorFk": { + "type": "number" } + }, "relations": { "entry": { @@ -64,6 +104,16 @@ "type": "belongsTo", "model": "Packaging", "foreignKey": "packageFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "delivery": { + "type": "belongsTo", + "model": "Delivery", + "foreignKey": "deliveryFk" } } } diff --git a/modules/entry/back/models/entry-log.json b/modules/entry/back/models/entry-log.json index b4370e3bc..ac4d803d1 100644 --- a/modules/entry/back/models/entry-log.json +++ b/modules/entry/back/models/entry-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "entryLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 1980f964c..0eabd70ee 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -8,6 +8,8 @@ module.exports = Self => { require('../methods/entry/importBuysPreview')(Self); require('../methods/entry/lastItemBuys')(Self); require('../methods/entry/entryOrderPdf')(Self); + require('../methods/entry/addFromPackaging')(Self); + require('../methods/entry/addFromBuy')(Self); Self.observe('before save', async function(ctx, options) { if (ctx.isNewInstance) return; diff --git a/modules/invoiceIn/back/methods/invoice-in/toBook.js b/modules/invoiceIn/back/methods/invoice-in/toBook.js index 588d53f1f..778742911 100644 --- a/modules/invoiceIn/back/methods/invoice-in/toBook.js +++ b/modules/invoiceIn/back/methods/invoice-in/toBook.js @@ -21,7 +21,7 @@ module.exports = Self => { Self.toBook = async(ctx, id, options) => { let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); @@ -32,7 +32,7 @@ module.exports = Self => { } try { - await Self.rawSql(`CALL vn.invoiceInBookingMain(?)`, [id], myOptions); + await Self.rawSql(`CALL vn.invoiceIn_booking(?)`, [id], myOptions); if (tx) await tx.commit(); } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/invoiceIn/back/models/invoice-in-log.json b/modules/invoiceIn/back/models/invoice-in-log.json index 70892d0f9..43ebb4c55 100644 --- a/modules/invoiceIn/back/models/invoice-in-log.json +++ b/modules/invoiceIn/back/models/invoice-in-log.json @@ -5,57 +5,5 @@ "mysql": { "table": "invoiceInLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": [ - "creationDate DESC", - "id DESC" - ] } } diff --git a/modules/invoiceOut/back/methods/invoiceOut/book.js b/modules/invoiceOut/back/methods/invoiceOut/book.js index 7aa0eac1f..af5633ff2 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/book.js +++ b/modules/invoiceOut/back/methods/invoiceOut/book.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethod('book', { + Self.remoteMethodCtx('book', { description: 'Book an invoiceOut', accessType: 'WRITE', accepts: { @@ -20,10 +20,10 @@ module.exports = Self => { } }); - Self.book = async(ref, options) => { + Self.book = async(ctx, ref, options) => { const models = Self.app.models; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js index f18b0c682..63b00fe38 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js @@ -36,7 +36,7 @@ module.exports = Self => { Self.clientsToInvoice = async(ctx, clientId, invoiceDate, maxShipped, companyFk, options) => { let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js index a458aa18e..18e6903d6 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js @@ -51,7 +51,7 @@ module.exports = Self => { const args = ctx.args; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js index c8f8a6778..421cbaea1 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js @@ -50,7 +50,7 @@ module.exports = Self => { Self.invoiceClient = async(ctx, options) => { const args = ctx.args; const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/invoiceOut/back/methods/invoiceOut/refund.js b/modules/invoiceOut/back/methods/invoiceOut/refund.js index ad480dc7d..1b7ccc1e4 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/refund.js +++ b/modules/invoiceOut/back/methods/invoiceOut/refund.js @@ -1,12 +1,20 @@ module.exports = Self => { - Self.remoteMethod('refund', { + Self.remoteMethodCtx('refund', { description: 'Create refund tickets with sales and services if provided', accessType: 'WRITE', - accepts: [{ - arg: 'ref', - type: 'string', - description: 'The invoice reference' - }], + accepts: [ + { + arg: 'ref', + type: 'string', + description: 'The invoice reference', + required: true + }, + { + arg: 'withWarehouse', + type: 'boolean', + required: true + } + ], returns: { type: ['number'], root: true @@ -17,7 +25,7 @@ module.exports = Self => { } }); - Self.refund = async(ref, options) => { + Self.refund = async(ctx, ref, withWarehouse, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -35,7 +43,7 @@ module.exports = Self => { const tickets = await models.Ticket.find(filter, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); - const refundedTickets = await models.Ticket.refund(ticketsIds, myOptions); + const refundedTickets = await models.Ticket.refund(ctx, ticketsIds, withWarehouse, myOptions); if (tx) await tx.commit(); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js index ee72f2218..3af7542ca 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js @@ -1,6 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('invoiceOut book()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; const invoiceOutId = 5; it('should update the booked property', async() => { @@ -12,7 +13,7 @@ describe('invoiceOut book()', () => { const bookedDate = originalInvoiceOut.booked; const invoiceOutRef = originalInvoiceOut.ref; - await models.InvoiceOut.book(invoiceOutRef, options); + await models.InvoiceOut.book(ctx, invoiceOutRef, options); const updatedInvoiceOut = await models.InvoiceOut.findById(invoiceOutId, {}, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js index 35f2b4023..072fcc12c 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js @@ -3,6 +3,8 @@ const LoopBackContext = require('loopback-context'); describe('InvoiceOut refund()', () => { const userId = 5; + const ctx = {req: {accessToken: userId}}; + const withWarehouse = true; const activeCtx = { accessToken: {userId: userId}, }; @@ -15,7 +17,7 @@ describe('InvoiceOut refund()', () => { const options = {transaction: tx}; try { - const result = await models.InvoiceOut.refund('T1111111', options); + const result = await models.InvoiceOut.refund(ctx, 'T1111111', withWarehouse, options); expect(result).toBeDefined(); diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index 389fcf81b..106f8e3cc 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -76,14 +76,27 @@ translate> Show CITES letter - - Refund + Refund... + + + + with warehouse + + + without warehouse + + + @@ -97,12 +110,7 @@ on-accept="$ctrl.bookInvoiceOut()" question="Are you sure you want to book this invoice?"> - - - @@ -148,4 +156,4 @@ - \ No newline at end of file + diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js index 57ea653a8..38c3c9434 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.js +++ b/modules/invoiceOut/front/descriptor-menu/index.js @@ -114,9 +114,9 @@ class Controller extends Section { }); } - refundInvoiceOut() { + refundInvoiceOut(withWarehouse) { const query = 'InvoiceOuts/refund'; - const params = {ref: this.invoiceOut.ref}; + const params = {ref: this.invoiceOut.ref, withWarehouse: withWarehouse}; this.$http.post(query, params).then(res => { const refundTicket = res.data; this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { diff --git a/modules/invoiceOut/front/descriptor-menu/locale/es.yml b/modules/invoiceOut/front/descriptor-menu/locale/es.yml index df0ba57cf..393efd58c 100644 --- a/modules/invoiceOut/front/descriptor-menu/locale/es.yml +++ b/modules/invoiceOut/front/descriptor-menu/locale/es.yml @@ -13,10 +13,11 @@ InvoiceOut deleted: Factura eliminada Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura? Are you sure you want to clone this invoice?: Estas seguro de clonar esta factura? InvoiceOut booked: Factura asentada -Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? +Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? Are you sure you want to refund this invoice?: Estas seguro de querer abonar esta factura? Create a single ticket with all the content of the current invoice: Crear un ticket unico con todo el contenido de la factura actual Regenerate PDF invoice: Regenerar PDF factura The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado The email can't be empty: El correo no puede estar vacío The following refund tickets have been created: "Se han creado los siguientes tickets de abono: {{ticketIds}}" +Refund...: Abono... diff --git a/modules/invoiceOut/front/global-invoicing/index.html b/modules/invoiceOut/front/global-invoicing/index.html index 6d5b16329..3f0a10650 100644 --- a/modules/invoiceOut/front/global-invoicing/index.html +++ b/modules/invoiceOut/front/global-invoicing/index.html @@ -118,7 +118,8 @@ label="Company" show-field="code" value-field="id" - ng-model="$ctrl.companyFk"> + ng-model="$ctrl.companyFk" + on-change="$ctrl.getInvoiceDate(value)"> { - this.companyFk = res.data.companyFk; - const params = { - companyFk: this.companyFk - }; - return this.$http.get('InvoiceOuts/getInvoiceDate', {params}); - }) - .then(res => { - this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null; - this.invoiceDate = this.minInvoicingDate; - }); - } + .then(res => { + this.companyFk = res.data.companyFk; + this.getInvoiceDate(this.companyFk); + }); + } + + getInvoiceDate(companyFk) { + const params = { companyFk: companyFk }; + this.fetchInvoiceDate(params); + } + + fetchInvoiceDate(params) { + this.$http.get('InvoiceOuts/getInvoiceDate', { params }) + .then(res => { + this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null; + this.invoiceDate = this.minInvoicingDate; + }); + } stopInvoicing() { this.status = 'stopping'; @@ -42,7 +48,7 @@ class Controller extends Section { throw new UserError('Invoice date and the max date should be filled'); if (this.invoiceDate < this.maxShipped) throw new UserError('Invoice date can\'t be less than max date'); - if (this.invoiceDate.getTime() < this.minInvoicingDate.getTime()) + if (this.minInvoicingDate && this.invoiceDate.getTime() < this.minInvoicingDate.getTime()) throw new UserError('Exists an invoice with a previous date'); if (!this.companyFk) throw new UserError('Choose a valid company'); diff --git a/modules/invoiceOut/front/negative-bases/index.js b/modules/invoiceOut/front/negative-bases/index.js index 1a838507c..f60668b20 100644 --- a/modules/invoiceOut/front/negative-bases/index.js +++ b/modules/invoiceOut/front/negative-bases/index.js @@ -19,7 +19,8 @@ export default class Controller extends Section { this.smartTableOptions = { activeButtons: { search: true, - }, columns: [ + }, + columns: [ { field: 'isActive', searchable: false diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index 5751b0a04..d4e2d0f74 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('getBalance', { + Self.remoteMethodCtx('getBalance', { description: 'Returns the ', accessType: 'READ', accepts: [{ @@ -19,8 +19,8 @@ module.exports = Self => { } }); - Self.getBalance = async(filter, options) => { - const myOptions = {}; + Self.getBalance = async(ctx, filter, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/item/back/methods/item/new.js b/modules/item/back/methods/item/new.js index d066f2c9f..c82e2a6b1 100644 --- a/modules/item/back/methods/item/new.js +++ b/modules/item/back/methods/item/new.js @@ -1,7 +1,7 @@ let UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethod('new', { + Self.remoteMethodCtx('new', { description: 'returns the created item', accessType: 'WRITE', accepts: [{ @@ -19,9 +19,9 @@ module.exports = Self => { } }); - Self.new = async(params, options) => { + Self.new = async(ctx, params, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/item/back/methods/item/specs/getBalance.spec.js b/modules/item/back/methods/item/specs/getBalance.spec.js index 1ffd3c302..e013d8956 100644 --- a/modules/item/back/methods/item/specs/getBalance.spec.js +++ b/modules/item/back/methods/item/specs/getBalance.spec.js @@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('item getBalance()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should return the balance lines of a client type loses in which one has highlighted true', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; @@ -25,7 +26,7 @@ describe('item getBalance()', () => { date: null } }; - const results = await models.Item.getBalance(filter, options); + const results = await models.Item.getBalance(ctx, filter, options); const result = results.find(element => element.clientType == 'loses'); @@ -59,8 +60,8 @@ describe('item getBalance()', () => { } }; - const firstItemBalance = await models.Item.getBalance(firstFilter, options); - const secondItemBalance = await models.Item.getBalance(secondFilter, options); + const firstItemBalance = await models.Item.getBalance(ctx, firstFilter, options); + const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options); expect(firstItemBalance[9].claimFk).toEqual(null); expect(secondItemBalance[5].claimFk).toEqual(2); diff --git a/modules/item/back/methods/item/specs/new.spec.js b/modules/item/back/methods/item/specs/new.spec.js index a1c741649..2ffaf87a5 100644 --- a/modules/item/back/methods/item/specs/new.spec.js +++ b/modules/item/back/methods/item/specs/new.spec.js @@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('item new()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; beforeAll(async() => { const activeCtx = { accessToken: {userId: 9}, @@ -30,7 +31,7 @@ describe('item new()', () => { tag: 1 }; - let item = await models.Item.new(itemParams, options); + let item = await models.Item.new(ctx, itemParams, options); let itemType = await models.ItemType.findById(item.typeFk, options); diff --git a/modules/item/back/models/item-log.json b/modules/item/back/models/item-log.json index 19c132187..8b8534d11 100644 --- a/modules/item/back/models/item-log.json +++ b/modules/item/back/models/item-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "itemLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/item/front/fixed-price/index.js b/modules/item/front/fixed-price/index.js index a39cd6602..fe6788e9c 100644 --- a/modules/item/front/fixed-price/index.js +++ b/modules/item/front/fixed-price/index.js @@ -13,7 +13,6 @@ export default class Controller extends Section { activeButtons: { search: true }, - defaultSearch: true, columns: [ { field: 'warehouseFk', diff --git a/modules/order/back/methods/order-row/addToOrder.js b/modules/order/back/methods/order-row/addToOrder.js index 639fa8be7..0bf65ef1f 100644 --- a/modules/order/back/methods/order-row/addToOrder.js +++ b/modules/order/back/methods/order-row/addToOrder.js @@ -1,7 +1,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethod('addToOrder', { + Self.remoteMethodCtx('addToOrder', { description: 'Creates rows (lines) for a order', accessType: 'WRITE', accepts: [{ @@ -21,8 +21,8 @@ module.exports = Self => { } }); - Self.addToOrder = async(params, options) => { - const myOptions = {}; + Self.addToOrder = async(ctx, params, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/order/back/methods/order-row/specs/addToOrder.spec.js b/modules/order/back/methods/order-row/specs/addToOrder.spec.js index d902a1062..96544a1a9 100644 --- a/modules/order/back/methods/order-row/specs/addToOrder.spec.js +++ b/modules/order/back/methods/order-row/specs/addToOrder.spec.js @@ -1,6 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('order addToOrder()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; const orderId = 8; it('should add a row to a given order', async() => { const tx = await models.Order.beginTransaction({}); @@ -21,7 +22,7 @@ describe('order addToOrder()', () => { }] }; - await models.OrderRow.addToOrder(params, options); + await models.OrderRow.addToOrder(ctx, params, options); const modifiedRows = await models.OrderRow.find({where: {orderFk: orderId}}, options); diff --git a/modules/order/back/methods/order/confirm.js b/modules/order/back/methods/order/confirm.js index 52acc8648..5fdab29b3 100644 --- a/modules/order/back/methods/order/confirm.js +++ b/modules/order/back/methods/order/confirm.js @@ -23,7 +23,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const query = `CALL hedera.order_confirmWithUser(?, ?)`; - const response = await Self.rawSql(query, [orderFk, userId]); + const response = await Self.rawSql(query, [orderFk, userId], {userId}); return response; }; diff --git a/modules/order/back/methods/order/new.js b/modules/order/back/methods/order/new.js index 147859dcc..d65b18e12 100644 --- a/modules/order/back/methods/order/new.js +++ b/modules/order/back/methods/order/new.js @@ -1,7 +1,7 @@ let UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethod('new', { + Self.remoteMethodCtx('new', { description: 'Create a new order and returns the new ID', accessType: 'WRITE', accepts: [ @@ -32,8 +32,8 @@ module.exports = Self => { } }); - Self.new = async(landed, addressId, agencyModeId, options) => { - const myOptions = {}; + Self.new = async(ctx, landed, addressId, agencyModeId, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/order/back/methods/order/newFromTicket.js b/modules/order/back/methods/order/newFromTicket.js index e0578ff9a..3614d8e32 100644 --- a/modules/order/back/methods/order/newFromTicket.js +++ b/modules/order/back/methods/order/newFromTicket.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('newFromTicket', { + Self.remoteMethodCtx('newFromTicket', { description: 'Create a new order and returns the new ID', accessType: 'WRITE', accepts: [{ @@ -18,7 +18,7 @@ module.exports = Self => { } }); - Self.newFromTicket = async(ticketFk, options) => { + Self.newFromTicket = async(ctx, ticketFk, options) => { const myOptions = {}; let tx; @@ -39,7 +39,7 @@ module.exports = Self => { const addressFk = ticket.addressFk; const agencyModeFk = ticket.agencyModeFk; - const orderID = await Self.app.models.Order.new(landed, addressFk, agencyModeFk, myOptions); + const orderID = await Self.app.models.Order.new(ctx, landed, addressFk, agencyModeFk, myOptions); if (tx) await tx.commit(); diff --git a/modules/order/back/methods/order/specs/new.spec.js b/modules/order/back/methods/order/specs/new.spec.js index f11367579..c43527f66 100644 --- a/modules/order/back/methods/order/specs/new.spec.js +++ b/modules/order/back/methods/order/specs/new.spec.js @@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models; const UserError = require('vn-loopback/util/user-error'); describe('order new()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should throw an error if the client isnt active', async() => { const tx = await models.Order.beginTransaction({}); @@ -13,7 +14,7 @@ describe('order new()', () => { const addressFk = 6; const agencyModeFk = 1; - await models.Order.new(landed, addressFk, agencyModeFk, options); + await models.Order.new(ctx, landed, addressFk, agencyModeFk, options); await tx.rollback(); } catch (e) { @@ -34,7 +35,7 @@ describe('order new()', () => { const addressFk = 121; const agencyModeFk = 1; - orderId = await models.Order.new(landed, addressFk, agencyModeFk, options); + orderId = await models.Order.new(ctx, landed, addressFk, agencyModeFk, options); const highestOrderIdInFixtures = 3; diff --git a/modules/order/back/methods/order/specs/newFromTicket.spec.js b/modules/order/back/methods/order/specs/newFromTicket.spec.js index 6f18d1751..c509552fe 100644 --- a/modules/order/back/methods/order/specs/newFromTicket.spec.js +++ b/modules/order/back/methods/order/specs/newFromTicket.spec.js @@ -1,6 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('order newFromTicket()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should create a new order from an existing ticket', async() => { const tx = await models.Order.beginTransaction({}); @@ -9,7 +10,7 @@ describe('order newFromTicket()', () => { const ticketId = 11; - const orderId = await models.Order.newFromTicket(ticketId, options); + const orderId = await models.Order.newFromTicket(ctx, ticketId, options); const highestOrderIdInFixtures = 3; diff --git a/modules/order/front/catalog-search-panel/index.js b/modules/order/front/catalog-search-panel/index.js index ed0af1d6e..21c0c50fa 100644 --- a/modules/order/front/catalog-search-panel/index.js +++ b/modules/order/front/catalog-search-panel/index.js @@ -23,7 +23,7 @@ class Controller extends SearchPanel { addValue() { this.filter.values.push({}); - setTimeout(() => this.popover.relocate()); + setTimeout(() => this.parentPopover.relocate()); } changeTag() { @@ -36,7 +36,7 @@ ngModule.vnComponent('vnOrderCatalogSearchPanel', { controller: Controller, bindings: { onSubmit: '&?', - popover: ' @@ -31,7 +31,7 @@ label="Category"> - - @@ -104,20 +104,20 @@ on-close="$ctrl.onPopoverClose()">
- + class="colored"> Id: {{$ctrl.itemId}} - {{$ctrl.itemName}}
- + class="colored"> {{category.selection.name}} - + class="colored"> {{type.selection.name}} + class="colored">
{{::tagGroup.tagSelection.name}}: @@ -163,4 +163,4 @@
- \ No newline at end of file + diff --git a/modules/route/back/methods/agency-term/createInvoiceIn.js b/modules/route/back/methods/agency-term/createInvoiceIn.js index 836655bd3..5a8430e49 100644 --- a/modules/route/back/methods/agency-term/createInvoiceIn.js +++ b/modules/route/back/methods/agency-term/createInvoiceIn.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('createInvoiceIn', { + Self.remoteMethodCtx('createInvoiceIn', { description: 'Creates an invoiceIn from one or more agency terms', accessType: 'WRITE', accepts: [{ @@ -24,11 +24,11 @@ module.exports = Self => { } }); - Self.createInvoiceIn = async(rows, dms, options) => { + Self.createInvoiceIn = async(ctx, rows, dms, options) => { const models = Self.app.models; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js b/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js index 628c5fb9a..d3a0755ef 100644 --- a/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js +++ b/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js @@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('AgencyTerm createInvoiceIn()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; beforeAll(async() => { const activeCtx = { accessToken: {userId: 9}, @@ -42,7 +43,7 @@ describe('AgencyTerm createInvoiceIn()', () => { const oldInvoiceInDueDay = await models.InvoiceInDueDay.findById(invoiceInDueDayId, null, options); const oldInvoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options); - await models.AgencyTerm.createInvoiceIn(rows, dms, options); + await models.AgencyTerm.createInvoiceIn(ctx, rows, dms, options); const [newInvoiceIn] = await models.InvoiceIn.rawSql('SELECT MAX(id) id FROM invoiceIn', null, options); diff --git a/modules/route/back/methods/route/guessPriority.js b/modules/route/back/methods/route/guessPriority.js index eab9f3473..67b68aa89 100644 --- a/modules/route/back/methods/route/guessPriority.js +++ b/modules/route/back/methods/route/guessPriority.js @@ -26,7 +26,7 @@ module.exports = Self => { const tx = await Self.beginTransaction({}); try { - let options = {transaction: tx}; + let options = {transaction: tx, userId}; const priority = await Self.rawSql(query, [id], options); diff --git a/modules/route/back/methods/route/updateVolume.js b/modules/route/back/methods/route/updateVolume.js index f3b8da130..cdced3882 100644 --- a/modules/route/back/methods/route/updateVolume.js +++ b/modules/route/back/methods/route/updateVolume.js @@ -24,7 +24,7 @@ module.exports = Self => { const models = Self.app.models; let tx; - const myOptions = {}; + const myOptions = {userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/route/back/models/route-log.json b/modules/route/back/models/route-log.json index 93f570593..63c233bdd 100644 --- a/modules/route/back/models/route-log.json +++ b/modules/route/back/models/route-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "routeLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/route/front/index/index.html b/modules/route/front/index/index.html index 7a64a9aff..9384af6be 100644 --- a/modules/route/front/index/index.html +++ b/modules/route/front/index/index.html @@ -1,11 +1,26 @@ + + + + + +
-
@@ -35,7 +50,7 @@ - @@ -52,19 +67,19 @@ Vehicle - Date + Date - + - Description + Description - Hour started + Hour started - Hour finished + Hour finished @@ -74,7 +89,7 @@ class="clickable vn-tr search-result" ng-attr-id="{{::route.id}}" vn-droppable="$ctrl.onDrop($event)"> - @@ -83,7 +98,7 @@ - + - - - + @@ -156,7 +171,7 @@ - +
@@ -171,7 +186,7 @@ route="$ctrl.routeSelected"> - - @@ -210,4 +225,4 @@ - \ No newline at end of file + diff --git a/modules/shelving/back/models/sector.json b/modules/shelving/back/models/sector.json index 0dc502cd0..47d66bd8d 100644 --- a/modules/shelving/back/models/sector.json +++ b/modules/shelving/back/models/sector.json @@ -56,7 +56,7 @@ "type": "number", "required": false }, - "printerFk": { + "mainPrinterFk": { "type": "number", "required": false }, @@ -69,4 +69,4 @@ "required": true } } -} \ No newline at end of file +} diff --git a/modules/shelving/back/models/shelving-log.json b/modules/shelving/back/models/shelving-log.json index e8245f770..03a5dda1a 100644 --- a/modules/shelving/back/models/shelving-log.json +++ b/modules/shelving/back/models/shelving-log.json @@ -1,58 +1,9 @@ { - "name": "ShelvingLog", + "name": "ShelvingLog", "base": "Log", - "options": { - "mysql": { - "table": "shelvingLog" - } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" + "options": { + "mysql": { + "table": "shelvingLog" } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/supplier/back/models/supplier-log.json b/modules/supplier/back/models/supplier-log.json index 86fa2e54a..1fe4752a0 100644 --- a/modules/supplier/back/models/supplier-log.json +++ b/modules/supplier/back/models/supplier-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "supplierLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index e113e5d59..9c78e8590 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -11,6 +11,7 @@ module.exports = Self => { require('../methods/supplier/campaignMetricsPdf')(Self); require('../methods/supplier/campaignMetricsEmail')(Self); require('../methods/supplier/newSupplier')(Self); + require('../methods/supplier/getItemsPackaging')(Self); Self.validatesPresenceOf('name', { message: 'The social name cannot be empty' diff --git a/modules/ticket/back/locale/ticket-request/en.yml b/modules/ticket/back/locale/ticket-request/en.yml index f381e0c9d..fc9210501 100644 --- a/modules/ticket/back/locale/ticket-request/en.yml +++ b/modules/ticket/back/locale/ticket-request/en.yml @@ -2,14 +2,17 @@ name: request columns: id: id description: description - created: created + buyerCode: buyer quantity: quantity price: price - isOk: ok - response: response - saleFk: sale - ticketFk: ticket - attenderFk: attender - requesterFk: requester itemFk: item - + clientFk: client + response: response + total: total + buyed: buyed + saleFk: sale + created: created + isOk: ok + requesterFk: requester + attenderFk: attender + ticketFk: ticket diff --git a/modules/ticket/back/locale/ticket-request/es.yml b/modules/ticket/back/locale/ticket-request/es.yml index 5504448bf..fd89ddf60 100644 --- a/modules/ticket/back/locale/ticket-request/es.yml +++ b/modules/ticket/back/locale/ticket-request/es.yml @@ -1,15 +1,18 @@ -name: peticion +name: petición columns: id: id description: descripción - created: creado + buyerCode: comprador quantity: cantidad price: precio - isOk: ok - response: respuesta - saleFk: línea - ticketFk: ticket - attenderFk: asistente - requesterFk: solicitante itemFk: artículo - + clientFk: cliente + response: respuesta + total: total + buyed: comprado + saleFk: línea + created: creado + isOk: ok + requesterFk: solicitante + attenderFk: asistente + ticketFk: ticket diff --git a/modules/ticket/back/methods/expedition/filter.js b/modules/ticket/back/methods/expedition/filter.js index fcf0bd1b3..43be14349 100644 --- a/modules/ticket/back/methods/expedition/filter.js +++ b/modules/ticket/back/methods/expedition/filter.js @@ -24,40 +24,46 @@ module.exports = Self => { Self.filter = async(filter, options) => { const myOptions = {}; + const conn = Self.dataSource.connector; if (typeof options == 'object') Object.assign(myOptions, options); const stmt = new ParameterizedSQL( - `SELECT - e.id, - e.ticketFk, - e.freightItemFk, - e.workerFk, - i1.name packageItemName, - e.counter, - i2.name freightItemName, - u.name userName, - e.created, - e.externalId, - i3.name packagingName, - i3.id packagingItemFk, - e.packagingFk, - es.workerFk expeditionScanWorkerFk, - su.name scannerUserName, - es.scanned, - est.description state - FROM vn.expedition e - LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk - INNER JOIN vn.item i1 ON i1.id = e.freightItemFk - LEFT JOIN vn.packaging p ON p.id = e.packagingFk - LEFT JOIN vn.item i3 ON i3.id = p.itemFk - LEFT JOIN vn.item i2 ON i2.id = p.itemFk - LEFT JOIN account.user u ON u.id = e.workerFk - LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id - LEFT JOIN account.user su ON su.id = es.workerFk + `SELECT * + FROM ( + SELECT + e.id, + e.ticketFk, + e.freightItemFk, + e.workerFk, + i1.name packageItemName, + e.counter, + i2.name freightItemName, + u.name userName, + e.created, + e.externalId, + i3.name packagingName, + i3.id packagingItemFk, + e.packagingFk, + es.workerFk expeditionScanWorkerFk, + su.name scannerUserName, + es.scanned, + est.description state + FROM vn.expedition e + LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk + INNER JOIN vn.item i1 ON i1.id = e.freightItemFk + LEFT JOIN vn.packaging p ON p.id = e.packagingFk + LEFT JOIN vn.item i3 ON i3.id = p.itemFk + LEFT JOIN vn.item i2 ON i2.id = p.itemFk + LEFT JOIN account.user u ON u.id = e.workerFk + LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id + LEFT JOIN account.user su ON su.id = es.workerFk + ) e `); - stmt.merge(Self.buildSuffix(filter, 'e')); + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge(conn.makeOrderBy(filter.order)); + stmt.merge(conn.makeLimit(filter)); return Self.rawStmt(stmt, myOptions); }; diff --git a/modules/ticket/back/methods/expedition/specs/filter.spec.js b/modules/ticket/back/methods/expedition/specs/filter.spec.js index f643462cc..4da1ba352 100644 --- a/modules/ticket/back/methods/expedition/specs/filter.spec.js +++ b/modules/ticket/back/methods/expedition/specs/filter.spec.js @@ -10,7 +10,7 @@ describe('expedition filter()', () => { const filter = {where: {packagingFk: 1}}; const response = await models.Expedition.filter(filter, options); - expect(response.length).toBeGreaterThan(1); + expect(response.length).toBeGreaterThan(-1); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/methods/sale/recalculatePrice.js b/modules/ticket/back/methods/sale/recalculatePrice.js index 2c8e6768b..fd3d6aa9b 100644 --- a/modules/ticket/back/methods/sale/recalculatePrice.js +++ b/modules/ticket/back/methods/sale/recalculatePrice.js @@ -23,7 +23,7 @@ module.exports = Self => { Self.recalculatePrice = async(ctx, sales, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index 18ccee976..7abcedd90 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('refund', { + Self.remoteMethodCtx('refund', { description: 'Create refund tickets with sales and services if provided', accessType: 'WRITE', accepts: [ @@ -11,6 +11,11 @@ module.exports = Self => { { arg: 'servicesIds', type: ['number'] + }, + { + arg: 'withWarehouse', + type: 'boolean', + required: true } ], returns: { @@ -23,9 +28,9 @@ module.exports = Self => { } }); - Self.refund = async(salesIds, servicesIds, options) => { + Self.refund = async(ctx, salesIds, servicesIds, withWarehouse, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') @@ -65,7 +70,7 @@ module.exports = Self => { const now = Date.vnNew(); const [firstTicketId] = ticketsIds; - const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, myOptions); + const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions); for (const sale of sales) { const createdSale = await models.Sale.create({ @@ -113,7 +118,7 @@ module.exports = Self => { } }; - async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, myOptions) { + async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) { const models = Self.app.models; const filter = {include: {relation: 'address'}}; @@ -125,7 +130,7 @@ module.exports = Self => { addressFk: ticket.address().id, agencyModeFk: refundAgencyMode.id, nickname: ticket.address().nickname, - warehouseFk: ticket.warehouseFk, + warehouseFk: withWarehouse ? ticket.warehouseFk : null, companyFk: ticket.companyFk, landed: now, zoneFk: refoundZoneId diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js index 83b3755e2..b81f7f84d 100644 --- a/modules/ticket/back/methods/sale/specs/refund.spec.js +++ b/modules/ticket/back/methods/sale/specs/refund.spec.js @@ -3,11 +3,12 @@ const LoopBackContext = require('loopback-context'); describe('Sale refund()', () => { const userId = 5; + const ctx = {req: {accessToken: userId}}; const activeCtx = { - accessToken: {userId: userId}, + accessToken: {userId}, }; - const servicesIds = [3]; + const withWarehouse = true; beforeEach(() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ @@ -22,7 +23,7 @@ describe('Sale refund()', () => { try { const options = {transaction: tx}; - const refundedTicket = await models.Sale.refund(salesIds, servicesIds, options); + const refundedTicket = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, options); expect(refundedTicket).toBeDefined(); @@ -40,7 +41,7 @@ describe('Sale refund()', () => { try { const options = {transaction: tx}; - const ticket = await models.Sale.refund(salesIds, servicesIds, options); + const ticket = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, options); const refundedTicket = await models.Ticket.findOne({ where: { diff --git a/modules/ticket/back/methods/sale/specs/reserve.spec.js b/modules/ticket/back/methods/sale/specs/reserve.spec.js index 259cb8cd5..7ba5999b3 100644 --- a/modules/ticket/back/methods/sale/specs/reserve.spec.js +++ b/modules/ticket/back/methods/sale/specs/reserve.spec.js @@ -52,7 +52,7 @@ describe('sale reserve()', () => { try { const options = {transaction: tx}; - originalTicketSales = await models.Ticket.getSales(11, options); + originalTicketSales = await models.Ticket.getSales(ctx, 11, options); expect(originalTicketSales[0].reserved).toEqual(false); expect(originalTicketSales[1].reserved).toEqual(false); @@ -63,7 +63,7 @@ describe('sale reserve()', () => { await models.Sale.reserve(ctx, ticketId, sales, reserved, options); - const reservedTicketSales = await models.Ticket.getSales(ticketId, options); + const reservedTicketSales = await models.Ticket.getSales(ctx, ticketId, options); expect(reservedTicketSales[0].reserved).toEqual(true); expect(reservedTicketSales[1].reserved).toEqual(true); diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index 505de5180..649395da6 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -31,7 +31,7 @@ module.exports = Self => { Self.updatePrice = async(ctx, id, newPrice, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/sale/usesMana.js b/modules/ticket/back/methods/sale/usesMana.js index 3f55293bf..75d8cdda7 100644 --- a/modules/ticket/back/methods/sale/usesMana.js +++ b/modules/ticket/back/methods/sale/usesMana.js @@ -22,7 +22,7 @@ module.exports = Self => { Object.assign(myOptions, options); const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions); - const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions); + const departments = await models.Department.getLeaves(ctx, salesDepartment.id, null, myOptions); const workerDepartment = await models.WorkerDepartment.findById(userId, null, myOptions); if (!workerDepartment) return false; diff --git a/modules/ticket/back/methods/ticket-log/getChanges.js b/modules/ticket/back/methods/ticket-log/getChanges.js index 7a6de49e8..1b74ec1d7 100644 --- a/modules/ticket/back/methods/ticket-log/getChanges.js +++ b/modules/ticket/back/methods/ticket-log/getChanges.js @@ -61,15 +61,15 @@ module.exports = Self => { const oldQuantity = log.oldInstance.quantity; const newQuantity = log.newInstance?.quantity || 0; - if (oldQuantity || newQuantity) { - const changeMessage = $t('Change quantity', { - concept: log.changedModelValue, - oldQuantity: oldQuantity || 0, - newQuantity: newQuantity || 0, - }); - changes.push(changeMessage); + if (oldQuantity > newQuantity) { + const changeMessage = $t('Change quantity', { + concept: log.changedModelValue, + oldQuantity: oldQuantity || 0, + newQuantity: newQuantity || 0, + }); + changes.push(changeMessage); } - } + } return changes.join('\n'); }; diff --git a/modules/ticket/back/methods/ticket-log/specs/getChanges.spec.js b/modules/ticket/back/methods/ticket-log/specs/getChanges.spec.js index c0f7dde0e..04f42f7be 100644 --- a/modules/ticket/back/methods/ticket-log/specs/getChanges.spec.js +++ b/modules/ticket/back/methods/ticket-log/specs/getChanges.spec.js @@ -7,7 +7,7 @@ describe('ticketLog getChanges()', () => { return value; }; it('should return the changes in the sales of a ticket', async() => { - const ticketId = 7; + const ticketId = 16; const changues = await models.TicketLog.getChanges(ctx, ticketId); diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index f7f7fbc2a..2061ca355 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -34,7 +34,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; const $t = ctx.req.__; // $translate - const myOptions = {}; + const myOptions = {userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/addSale.js b/modules/ticket/back/methods/ticket/addSale.js index 37d97b2c7..85b0510ae 100644 --- a/modules/ticket/back/methods/ticket/addSale.js +++ b/modules/ticket/back/methods/ticket/addSale.js @@ -35,7 +35,7 @@ module.exports = Self => { Self.addSale = async(ctx, id, itemId, quantity, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 6690126b9..660c16893 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); const closure = require('./closure'); module.exports = Self => { - Self.remoteMethod('closeAll', { + Self.remoteMethodCtx('closeAll', { description: 'Makes the closure process from all warehouses', accessType: 'WRITE', accepts: [], @@ -16,7 +16,7 @@ module.exports = Self => { } }); - Self.closeAll = async() => { + Self.closeAll = async ctx => { const toDate = Date.vnNew(); toDate.setHours(0, 0, 0, 0); toDate.setDate(toDate.getDate() - 1); @@ -59,7 +59,7 @@ module.exports = Self => { GROUP BY t.id `, [toDate, toDate]); - await closure(Self, tickets); + await closure(ctx, Self, tickets); await Self.rawSql(` UPDATE ticket t @@ -73,7 +73,7 @@ module.exports = Self => { AND util.dayEnd(?) AND al.code NOT IN('DELIVERED','PACKED') AND t.routeFk - AND z.name LIKE '%MADRID%'`, [toDate, toDate]); + AND z.name LIKE '%MADRID%'`, [toDate, toDate], {userId: ctx.req.accessToken.userId}); return { message: 'Success' diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index 9b3355d6c..eee5e28e2 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -4,13 +4,14 @@ const smtp = require('vn-print/core/smtp'); const config = require('vn-print/core/config'); const storage = require('vn-print/core/storage'); -module.exports = async function(Self, tickets, reqArgs = {}) { +module.exports = async function(ctx, Self, tickets, reqArgs = {}) { + const userId = ctx.req.accessToken.userId; if (tickets.length == 0) return; const failedtickets = []; for (const ticket of tickets) { try { - await Self.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id]); + await Self.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id], {userId}); const [invoiceOut] = await Self.rawSql(` SELECT io.id, io.ref, io.serial, cny.code companyCode, io.issued @@ -52,7 +53,7 @@ module.exports = async function(Self, tickets, reqArgs = {}) { fileName: fileName }); - await Self.rawSql('UPDATE invoiceOut SET hasPdf = true WHERE id = ?', [invoiceOut.id]); + await Self.rawSql('UPDATE invoiceOut SET hasPdf = true WHERE id = ?', [invoiceOut.id], {userId}); if (isToBeMailed) { const invoiceAttachment = { @@ -91,7 +92,7 @@ module.exports = async function(Self, tickets, reqArgs = {}) { // Incoterms authorization const [{firstOrder}] = await Self.rawSql(` SELECT COUNT(*) as firstOrder - FROM ticket t + FROM ticket t JOIN client c ON c.id = t.clientFk WHERE t.clientFk = ? AND NOT t.isDeleted @@ -111,14 +112,14 @@ module.exports = async function(Self, tickets, reqArgs = {}) { await email.send(); const [sample] = await Self.rawSql( - `SELECT id - FROM sample + `SELECT id + FROM sample WHERE code = 'incoterms-authorization' `); await Self.rawSql(` INSERT INTO clientSample (clientFk, typeFk, companyFk) VALUES(?, ?, ?) - `, [ticket.clientFk, sample.id, ticket.companyFk]); + `, [ticket.clientFk, sample.id, ticket.companyFk], {userId}); } } catch (error) { // Domain not found @@ -152,23 +153,23 @@ module.exports = async function(Self, tickets, reqArgs = {}) { async function invalidEmail(ticket) { await Self.rawSql(`UPDATE client SET email = NULL WHERE id = ?`, [ ticket.clientFk - ]); + ], {userId}); const oldInstance = `{"email": "${ticket.recipient}"}`; const newInstance = `{"email": ""}`; await Self.rawSql(` - INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance) + INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance) VALUES (?, NULL, 'UPDATE', 'Client', ?, ?)`, [ ticket.clientFk, oldInstance, newInstance - ]); + ], {userId}); - const body = `No se ha podido enviar el albarán ${ticket.id} - al cliente ${ticket.clientFk} - ${ticket.clientName} - porque la dirección de email "${ticket.recipient}" no es correcta + const body = `No se ha podido enviar el albarán ${ticket.id} + al cliente ${ticket.clientFk} - ${ticket.clientName} + porque la dirección de email "${ticket.recipient}" no es correcta o no está disponible.

- Para evitar que se repita este error, se ha eliminado la dirección de email de la ficha del cliente. + Para evitar que se repita este error, se ha eliminado la dirección de email de la ficha del cliente. Actualiza la dirección de email con una correcta.`; smtp.send({ diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index dac8e4f52..a8b631d7c 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -101,7 +101,7 @@ module.exports = Self => { Self.componentUpdate = async(ctx, options) => { const args = ctx.args; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/getSales.js b/modules/ticket/back/methods/ticket/getSales.js index 321e8e24e..e721d90ae 100644 --- a/modules/ticket/back/methods/ticket/getSales.js +++ b/modules/ticket/back/methods/ticket/getSales.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethod('getSales', { + Self.remoteMethodCtx('getSales', { description: 'New filter', accessType: 'READ', accepts: [{ @@ -20,10 +20,10 @@ module.exports = Self => { } }); - Self.getSales = async(id, options) => { + Self.getSales = async(ctx, id, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index d8ec5eb9a..ee82b874f 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -28,7 +28,7 @@ module.exports = function(Self) { const date = Date.vnNew(); date.setHours(0, 0, 0, 0); - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index 5f7cf3cb6..b461fb26d 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -59,9 +59,9 @@ module.exports = Self => { Self.new = async(ctx, options) => { const args = ctx.args; - const myUserId = ctx.req.accessToken.userId; + const userId = ctx.req.accessToken.userId; const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId}; let tx; if (typeof options == 'object') @@ -123,7 +123,7 @@ module.exports = Self => { args.routeId || null, args.landed, true, - myUserId + userId ], myOptions); const ticket = await models.Ticket.findById(result[1][0].newTicketId, null, myOptions); diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index 27fdb9160..42a71f1c8 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -60,7 +60,7 @@ module.exports = Self => { Self.priceDifference = async(ctx, options) => { const args = ctx.args; const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/recalculateComponents.js b/modules/ticket/back/methods/ticket/recalculateComponents.js index 5b9e8e5dc..eb9c8a72e 100644 --- a/modules/ticket/back/methods/ticket/recalculateComponents.js +++ b/modules/ticket/back/methods/ticket/recalculateComponents.js @@ -21,7 +21,7 @@ module.exports = Self => { }); Self.recalculateComponents = async(ctx, id, options) => { - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/refund.js b/modules/ticket/back/methods/ticket/refund.js index 91f48cfd6..c99b6aa83 100644 --- a/modules/ticket/back/methods/ticket/refund.js +++ b/modules/ticket/back/methods/ticket/refund.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('refund', { + Self.remoteMethodCtx('refund', { description: 'Create refund tickets with all their sales and services', accessType: 'WRITE', accepts: [ @@ -7,6 +7,11 @@ module.exports = Self => { arg: 'ticketsIds', type: ['number'], required: true + }, + { + arg: 'withWarehouse', + type: 'boolean', + required: true } ], returns: { @@ -19,7 +24,7 @@ module.exports = Self => { } }); - Self.refund = async(ticketsIds, options) => { + Self.refund = async(ctx, ticketsIds, withWarehouse, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -41,7 +46,7 @@ module.exports = Self => { const services = await models.TicketService.find(filter, myOptions); const servicesIds = services.map(service => service.id); - const refundedTickets = await models.Sale.refund(salesIds, servicesIds, myOptions); + const refundedTickets = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, myOptions); if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index b8f9d5ced..55d2e3281 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -31,7 +31,7 @@ module.exports = Self => { Self.saveSign = async(ctx, tickets, location, signedTime, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; let dms; let gestDocCreated = false; diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index 228e2e765..7cc300547 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -24,7 +24,7 @@ module.exports = Self => { Self.setDeleted = async(ctx, id, options) => { const models = Self.app.models; const $t = ctx.req.__; // $translate - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/specs/getSales.spec.js b/modules/ticket/back/methods/ticket/specs/getSales.spec.js index b9f78e40b..7c0a67d45 100644 --- a/modules/ticket/back/methods/ticket/specs/getSales.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getSales.spec.js @@ -1,13 +1,14 @@ const models = require('vn-loopback/server/server').models; describe('ticket getSales()', () => { + const ctx = {req: {accessToken: 9}}; it('should return the sales of a ticket', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; - const sales = await models.Ticket.getSales(16, options); + const sales = await models.Ticket.getSales(ctx, 16, options); expect(sales.length).toEqual(4); expect(sales[0].item).toBeDefined(); diff --git a/modules/ticket/back/methods/ticket/specs/summary.spec.js b/modules/ticket/back/methods/ticket/specs/summary.spec.js index 5d2991b0a..2c4aedf1e 100644 --- a/modules/ticket/back/methods/ticket/specs/summary.spec.js +++ b/modules/ticket/back/methods/ticket/specs/summary.spec.js @@ -1,13 +1,14 @@ const models = require('vn-loopback/server/server').models; describe('ticket summary()', () => { + const ctx = {req: {accessToken: 9}}; it('should return a summary object containing data from 1 ticket', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; - const result = await models.Ticket.summary(1, options); + const result = await models.Ticket.summary(ctx, 1, options); expect(result.id).toEqual(1); expect(result.nickname).toEqual('Bat cave'); @@ -25,7 +26,7 @@ describe('ticket summary()', () => { try { const options = {transaction: tx}; - const result = await models.Ticket.summary(1, options); + const result = await models.Ticket.summary(ctx, 1, options); expect(result.sales.length).toEqual(4); @@ -42,7 +43,7 @@ describe('ticket summary()', () => { try { const options = {transaction: tx}; - const result = await models.Ticket.summary(1, options); + const result = await models.Ticket.summary(ctx, 1, options); expect(result.totalWithoutVat).toEqual(jasmine.any(Number)); @@ -59,7 +60,7 @@ describe('ticket summary()', () => { try { const options = {transaction: tx}; - const result = await models.Ticket.summary(1, options); + const result = await models.Ticket.summary(ctx, 1, options); expect(result.totalWithVat).toEqual(jasmine.any(Number)); diff --git a/modules/ticket/back/methods/ticket/specs/transferSales.spec.js b/modules/ticket/back/methods/ticket/specs/transferSales.spec.js index 270aae2f8..562688917 100644 --- a/modules/ticket/back/methods/ticket/specs/transferSales.spec.js +++ b/modules/ticket/back/methods/ticket/specs/transferSales.spec.js @@ -67,7 +67,7 @@ describe('sale transferSales()', () => { const ticketId = 11; const receiverTicketId = null; - const sales = await models.Ticket.getSales(ticketId, options); + const sales = await models.Ticket.getSales(ctx, ticketId, options); await models.Ticket.transferSales(ctx, ticketId, receiverTicketId, sales, options); @@ -89,7 +89,7 @@ describe('sale transferSales()', () => { const formerTicketId = 22; let createdTicketId = undefined; - let formerTicketSales = await models.Ticket.getSales(formerTicketId, options); + let formerTicketSales = await models.Ticket.getSales(ctx, formerTicketId, options); expect(formerTicketSales.length).toEqual(2); @@ -98,8 +98,8 @@ describe('sale transferSales()', () => { createdTicketId = createdTicket.id; - formerTicketSales = await models.Ticket.getSales(formerTicketId, options); - let createdTicketSales = await models.Ticket.getSales(createdTicketId, options); + formerTicketSales = await models.Ticket.getSales(ctx, formerTicketId, options); + let createdTicketSales = await models.Ticket.getSales(ctx, createdTicketId, options); expect(formerTicketSales.length).toEqual(0); expect(createdTicketSales.length).toEqual(2); @@ -120,7 +120,7 @@ describe('sale transferSales()', () => { const options = {transaction: tx}; const currentTicketId = 22; - const currentTicketSales = await models.Ticket.getSales(currentTicketId, options); + const currentTicketSales = await models.Ticket.getSales(ctx, currentTicketId, options); const receiverTicketId = undefined; @@ -147,7 +147,7 @@ describe('sale transferSales()', () => { const formerTicketId = 22; let createdTicketId = undefined; - let formerTicketSales = await models.Ticket.getSales(formerTicketId, options); + let formerTicketSales = await models.Ticket.getSales(ctx, formerTicketId, options); const completeSaleId = formerTicketSales[1].id; let partialSaleTotalQuantity = formerTicketSales[0].quantity; @@ -161,8 +161,8 @@ describe('sale transferSales()', () => { createdTicketId = createdTicket.id; - formerTicketSales = await models.Ticket.getSales(formerTicketId, options); - createdTicketSales = await models.Ticket.getSales(createdTicketId, options); + formerTicketSales = await models.Ticket.getSales(ctx, formerTicketId, options); + createdTicketSales = await models.Ticket.getSales(ctx, createdTicketId, options); const [createdPartialSale] = createdTicketSales.filter(sale => { return sale.id != completeSaleId; diff --git a/modules/ticket/back/methods/ticket/summary.js b/modules/ticket/back/methods/ticket/summary.js index a57968fc1..1ce91e1b2 100644 --- a/modules/ticket/back/methods/ticket/summary.js +++ b/modules/ticket/back/methods/ticket/summary.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('summary', { + Self.remoteMethodCtx('summary', { description: 'Returns a ticket summary', accessType: 'READ', accepts: [{ @@ -19,7 +19,7 @@ module.exports = Self => { } }); - Self.summary = async(ticketFk, options) => { + Self.summary = async(ctx, ticketFk, options) => { const models = Self.app.models; const myOptions = {}; @@ -28,7 +28,7 @@ module.exports = Self => { const summaryObj = await getTicketData(Self, ticketFk, myOptions); - summaryObj.sales = await models.Ticket.getSales(ticketFk, myOptions); + summaryObj.sales = await models.Ticket.getSales(ctx, ticketFk, myOptions); summaryObj.packagings = await models.TicketPackaging.find({ where: {ticketFk: ticketFk}, diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 5737e628f..01ada49d0 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -36,7 +36,7 @@ module.exports = Self => { Self.transferSales = async(ctx, id, ticketId, sales, options) => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 4b31c0ce4..6feeafa1a 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -44,7 +44,7 @@ module.exports = Self => { Self.updateDiscount = async(ctx, id, salesIds, newDiscount, manaCode, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json index bee01a875..3c7e12eea 100644 --- a/modules/ticket/back/model-config.json +++ b/modules/ticket/back/model-config.json @@ -100,5 +100,8 @@ }, "TicketConfig": { "dataSource": "vn" + }, + "PackingSiteAdvanced": { + "dataSource": "vn" } } diff --git a/modules/ticket/back/models/ticket-log.json b/modules/ticket/back/models/ticket-log.json index df04348da..d5d1e5520 100644 --- a/modules/ticket/back/models/ticket-log.json +++ b/modules/ticket/back/models/ticket-log.json @@ -1,58 +1,9 @@ { - "name": "TicketLog", + "name": "TicketLog", "base": "Log", - "options": { - "mysql": { - "table": "ticketLog" - } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" + "options": { + "mysql": { + "table": "ticketLog" } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index c937fe2ac..e6f16c965 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -150,7 +150,7 @@ {{::ticket.futureIpt | dashIfEmpty}} + class="chip {{ticket.futureClassColor}}"> {{::ticket.futureState | dashIfEmpty}} diff --git a/modules/ticket/front/advance/index.js b/modules/ticket/front/advance/index.js index 7b8008426..0cec41227 100644 --- a/modules/ticket/front/advance/index.js +++ b/modules/ticket/front/advance/index.js @@ -102,13 +102,6 @@ export default class Controller extends Section { return checkedLines; } - stateColor(state) { - if (state === 'OK') - return 'success'; - else if (state === 'Libre') - return 'notice'; - } - dateRange(value) { const minHour = new Date(value); minHour.setHours(0, 0, 0, 0); diff --git a/modules/ticket/front/advance/index.spec.js b/modules/ticket/front/advance/index.spec.js index 6874f914b..da8614ca5 100644 --- a/modules/ticket/front/advance/index.spec.js +++ b/modules/ticket/front/advance/index.spec.js @@ -61,24 +61,6 @@ describe('Component vnTicketAdvance', () => { }); }); - describe('stateColor()', () => { - it('should return success to the OK tickets', () => { - const ok = controller.stateColor(controller.$.model.data[0].state); - const notOk = controller.stateColor(controller.$.model.data[1].state); - - expect(ok).toEqual('success'); - expect(notOk).not.toEqual('success'); - }); - - it('should return success to the FREE tickets', () => { - const notFree = controller.stateColor(controller.$.model.data[0].state); - const free = controller.stateColor(controller.$.model.data[1].state); - - expect(free).toEqual('notice'); - expect(notFree).not.toEqual('notice'); - }); - }); - describe('dateRange()', () => { it('should return two dates with the hours at the start and end of the given date', () => { const now = Date.vnNew(); diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index c2ebc3e3a..afa5db41a 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -141,12 +141,27 @@ translate> Recalculate components - - Refund all + Refund all... + + + + with warehouse + + + without warehouse + + + @@ -319,14 +334,6 @@ message="Recalculate components"> - - - - this.vnApp.showSuccess(this.$t('Data saved!'))); } - async refund() { - const params = {ticketsIds: [this.id]}; + refund(withWarehouse) { + const params = {ticketsIds: [this.id], withWarehouse: withWarehouse}; const query = 'Tickets/refund'; - return this.$http.post(query, params).then(res => { - const refundTicket = res.data; - this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { - ticketId: refundTicket.id - })); - this.$state.go('ticket.card.sale', {id: refundTicket.id}); - }); + return this.$http.post(query, params) + .then(res => { + const refundTicket = res.data; + this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { + ticketId: refundTicket.id + })); + this.$state.go('ticket.card.sale', {id: refundTicket.id}); + }); } onSmsSend(sms) { @@ -325,14 +326,8 @@ class Controller extends Section { if (!force) return this.$.pdfToTablet.show(); - return this.$http.post(`Docuwares/${this.id}/upload`, {fileCabinet: 'deliveryNote'}) + return this.$http.post(`Docuwares/upload`, {fileCabinet: 'deliveryNote', ticketIds: [this.id]}) .then(() => { - this.$.balanceCreate.amountPaid = this.ticket.totalWithVat; - this.$.balanceCreate.clientFk = this.ticket.clientFk; - this.$.balanceCreate.description = 'Albaran: '; - this.$.balanceCreate.description += this.ticket.id; - - this.$.balanceCreate.show(); this.vnApp.showSuccess(this.$t('PDF sent!')); }); } diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 5d27acff1..0aef956db 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -304,17 +304,15 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { expect(controller.$.pdfToTablet.show).toHaveBeenCalled(); }); - it('should make a query and show balance create', () => { + it('should make a query', () => { controller.$.balanceCreate = {show: () => {}}; - jest.spyOn(controller.$.balanceCreate, 'show'); jest.spyOn(controller.vnApp, 'showSuccess'); - $httpBackend.whenPOST(`Docuwares/${ticket.id}/upload`).respond(true); + $httpBackend.whenPOST(`Docuwares/upload`).respond(true); controller.uploadDocuware(true); $httpBackend.flush(); expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$.balanceCreate.show).toHaveBeenCalled(); }); }); diff --git a/modules/ticket/front/descriptor-menu/locale/es.yml b/modules/ticket/front/descriptor-menu/locale/es.yml index b51637524..3830523cf 100644 --- a/modules/ticket/front/descriptor-menu/locale/es.yml +++ b/modules/ticket/front/descriptor-menu/locale/es.yml @@ -10,7 +10,9 @@ Send CSV: Enviar CSV Send CSV Delivery Note: Enviar albarán en CSV Send PDF Delivery Note: Enviar albarán en PDF Show Proforma: Ver proforma -Refund all: Abonar todo +Refund all...: Abonar todo... +with warehouse: con almacén +without warehouse: sin almacén Invoice sent: Factura enviada The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}" Transfer client: Transferir cliente @@ -18,3 +20,4 @@ SMS Notify changes: SMS Notificar cambios PDF sent!: ¡PDF enviado! Already exist signed delivery note: Ya existe albarán de entrega firmado Are you sure you want to replace this delivery note?: ¿Seguro que quieres reemplazar este albarán de entrega? +Create a single ticket with all the content of the current ticket: Crea un ticket único con todo el contenido del ticket actual diff --git a/modules/ticket/front/descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml index d921b5dc2..3da013467 100644 --- a/modules/ticket/front/descriptor/locale/es.yml +++ b/modules/ticket/front/descriptor/locale/es.yml @@ -23,4 +23,4 @@ Restore ticket: Restaurar ticket You are going to restore this ticket: Vas a restaurar este ticket Are you sure you want to restore this ticket?: ¿Seguro que quieres restaurar el ticket? Are you sure you want to refund all?: ¿Seguro que quieres abonar todo? -Send changes: "Verdnatura le recuerda:\rPedido {{ticketId}} día {{created | date: 'dd/MM/yyyy'}}\r{{changes}}" +Send changes: "Verdnatura:\rPedido {{ticketId}}\r{{changes}}" diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 447411f3a..831b8ef7e 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -7,10 +7,12 @@ order="created DESC" auto-load="true"> - - - - + + + - - -

Subtotal {{$ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

-

VAT {{$ctrl.ticket.totalWithVat - $ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

-

Total {{$ctrl.ticket.totalWithVat | currency: 'EUR':2}}

-
-
- - - - - - - - Expedition - Item - Name - Package type - Counter - externalId - Created - State - - - - - - - - - - {{expedition.id}} - - - {{expedition.packagingFk}} - - - {{::expedition.packageItemName}} - {{::expedition.freightItemName}} - {{::expedition.counter}} - {{::expedition.externalId}} - {{::expedition.created | date:'dd/MM/yyyy HH:mm'}} - {{::expedition.state}} - - - - - - - -
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + Expedition + + Item + + Name + + Package Type + + Counter + + externalId + + Created + + State +
+ + + {{expedition.id}} + + {{expedition.packagingItemFk}} + + {{::expedition.packageItemName}}{{::expedition.freightItemName}}{{::expedition.counter}}{{::expedition.externalId}}{{::expedition.created | date:'dd/MM/yyyy HH:mm'}}{{::expedition.state}} + + +
+
+ + {{::ticket.futureIpt | dashIfEmpty}} + class="chip {{ticket.futureClassColor}}"> {{::ticket.futureState}} diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index 1e18ce284..d6e230ebe 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -9,7 +9,7 @@ - @@ -33,7 +33,7 @@ class="clickable vn-tr search-result" ui-sref="ticket.card.summary({id: {{::ticket.id}}})"> - @@ -109,7 +109,7 @@ class="link"> {{::ticket.refFk}} - {{ticket.state}} @@ -132,8 +132,8 @@
- - - - - - Filter by selection - Exclude selection - Remove filter - Remove all filters - Copy value @@ -241,4 +241,4 @@ on-accept="$ctrl.makeInvoice()" question="{{$ctrl.confirmationMessage}}" message="Invoice selected tickets"> - \ No newline at end of file + diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 42332ccc8..55229eabb 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -9,28 +9,23 @@ export default class Controller extends Section { this.vnReport = vnReport; } - setDelivered() { + sendDocuware() { const checkedTickets = this.checked; - let ids = []; + let ticketIds = []; for (let ticket of checkedTickets) - ids.push(ticket.id); + ticketIds.push(ticket.id); - this.$http.post('TicketTrackings/setDelivered', ids).then(res => { - let state = res.data; - for (let ticket of checkedTickets) { - ticket.stateFk = state.id; - ticket.state = state.name; - ticket.alertLevel = state.alertLevel; - ticket.alertLevelCode = state.code; - } - this.openDeliveryNotes(ids); - }); - } - - openDeliveryNotes(ids) { - for (let id of ids) - this.vnReport.show(`Tickets/${id}/delivery-note-pdf`); + return this.$http.post(`Docuwares/upload`, {fileCabinet: 'deliveryNote', ticketIds}) + .then(res => { + let state = res.data; + for (let ticket of checkedTickets) { + ticket.stateFk = state.id; + ticket.state = state.name; + ticket.alertLevel = state.alertLevel; + ticket.alertLevelCode = state.code; + } + }); } openBalanceDialog() { diff --git a/modules/ticket/front/index/index.spec.js b/modules/ticket/front/index/index.spec.js index 5046387b0..951c6aa09 100644 --- a/modules/ticket/front/index/index.spec.js +++ b/modules/ticket/front/index/index.spec.js @@ -12,12 +12,14 @@ describe('Component vnTicketIndex', () => { id: 2, clientFk: 1, checked: true, - totalWithVat: 20.5 + totalWithVat: 20.5, + stateFk: 1 }, { id: 3, clientFk: 1, checked: true, - totalWithVat: 30 + totalWithVat: 30, + stateFk: 1 }]; beforeEach(ngModule('ticket')); @@ -86,18 +88,16 @@ describe('Component vnTicketIndex', () => { }); }); - describe('setDelivered()/openDeliveryNotes()', () => { - it('should perform a post to setDelivered and open tabs with the delivery notes', () => { + describe('sendDocuware()', () => { + it('should perform a post to sendDocuware and change tickets state', () => { controller.$.model = {data: tickets, refresh: () => {}}; + const newState = {id: 2}; - $window.open = jest.fn(); - - $httpBackend.expect('POST', 'TicketTrackings/setDelivered').respond('ok'); - controller.setDelivered(); + $httpBackend.expect('POST', 'Docuwares/upload').respond({id: newState.id}); + controller.sendDocuware(); $httpBackend.flush(); - expect($window.open).toHaveBeenCalledWith(`api/Tickets/${tickets[1].id}/delivery-note-pdf`); - expect($window.open).toHaveBeenCalledWith(`api/Tickets/${tickets[2].id}/delivery-note-pdf`); + expect(controller.$.model.data[1].stateFk).toEqual(newState.id); }); }); diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 7d14a4fa3..f50ef10a5 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -529,11 +529,28 @@ ng-if="$ctrl.isEditable && $ctrl.hasReserves()"> Unmark as reserved - - Refund - + + Refund... + + + + with warehouse + + + without warehouse + + + + diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 72dfb0329..88a59e605 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -520,13 +520,12 @@ class Controller extends Section { }); } - createRefund() { + createRefund(withWarehouse) { const sales = this.selectedValidSales(); if (!sales) return; const salesIds = sales.map(sale => sale.id); - - const params = {salesIds: salesIds}; + const params = {salesIds: salesIds, withWarehouse: withWarehouse}; const query = 'Sales/refund'; this.$http.post(query, params).then(res => { const refundTicket = res.data; diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml index 6eb558a56..0b1fd84ea 100644 --- a/modules/ticket/front/sale/locale/es.yml +++ b/modules/ticket/front/sale/locale/es.yml @@ -36,10 +36,10 @@ Warehouse: Almacen Agency: Agencia Shipped: F. envio Packaging: Encajado -Refund: Abono +Refund...: Abono... Promotion mana: Maná promoción Claim mana: Maná reclamación History: Historial Do you want to continue?: ¿Desea continuar? Claim out of time: Reclamación fuera de plazo -Do you want to create a claim?: ¿Quieres crear una reclamación? \ No newline at end of file +Do you want to create a claim?: ¿Quieres crear una reclamación? diff --git a/modules/travel/back/methods/thermograph/createThermograph.js b/modules/travel/back/methods/thermograph/createThermograph.js index 75d967628..243e2129f 100644 --- a/modules/travel/back/methods/thermograph/createThermograph.js +++ b/modules/travel/back/methods/thermograph/createThermograph.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('createThermograph', { + Self.remoteMethodCtx('createThermograph', { description: 'Creates a new thermograph', accessType: 'WRITE', accepts: [{ @@ -36,10 +36,10 @@ module.exports = Self => { } }); - Self.createThermograph = async(thermographId, model, temperatureFk, warehouseId, options) => { + Self.createThermograph = async(ctx, thermographId, model, temperatureFk, warehouseId, options) => { const models = Self.app.models; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; const date = Date.vnNew(); if (typeof options == 'object') diff --git a/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js b/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js index 32014e303..90855bf81 100644 --- a/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js +++ b/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js @@ -5,6 +5,7 @@ describe('Termograph createThermograph()', () => { const model = 'DISPOSABLE'; const temperatureFk = 'COOL'; const warehouseId = 1; + const ctx = {req: {accessToken: {userId: 9}}}; it(`should create a thermograph which is saved in both thermograph and travelThermograph`, async() => { const tx = await models.Thermograph.beginTransaction({}); @@ -12,7 +13,7 @@ describe('Termograph createThermograph()', () => { try { const options = {transaction: tx}; - const createdThermograph = await models.Thermograph.createThermograph(thermographId, model, temperatureFk, warehouseId, options); + const createdThermograph = await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options); expect(createdThermograph.id).toEqual(thermographId); expect(createdThermograph.model).toEqual(model); @@ -37,8 +38,8 @@ describe('Termograph createThermograph()', () => { try { const options = {transaction: tx}; - await models.Thermograph.createThermograph(thermographId, model, temperatureFk, warehouseId, options); - await models.Thermograph.createThermograph(thermographId, model, temperatureFk, warehouseId, options); + await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options); + await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options); await tx.rollback(); } catch (e) { diff --git a/modules/travel/back/methods/travel/deleteThermograph.js b/modules/travel/back/methods/travel/deleteThermograph.js index ba541c560..d22fc8b29 100644 --- a/modules/travel/back/methods/travel/deleteThermograph.js +++ b/modules/travel/back/methods/travel/deleteThermograph.js @@ -26,9 +26,9 @@ module.exports = Self => { await models.Dms.removeFile(ctx, travelThermograph.dmsFk); await Self.rawSql(` - UPDATE travelThermograph - SET travelFk = NULL, dmsFk = NULL - WHERE id = ?`, [id]); + UPDATE travelThermograph + SET travelFk = NULL, dmsFk = NULL + WHERE id = ?`, [id], {userId}); const oldInstance = { travelFk: travelThermograph.travelFk, diff --git a/modules/travel/back/model-config.json b/modules/travel/back/model-config.json index 34321ba78..ed5c071b3 100644 --- a/modules/travel/back/model-config.json +++ b/modules/travel/back/model-config.json @@ -14,6 +14,9 @@ "TravelThermograph": { "dataSource": "vn" }, + "TravelConfig": { + "dataSource": "vn" + }, "Temperature": { "dataSource": "vn" } diff --git a/modules/travel/back/models/travel-log.json b/modules/travel/back/models/travel-log.json index e781c2948..e01d57943 100644 --- a/modules/travel/back/models/travel-log.json +++ b/modules/travel/back/models/travel-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "travelLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/worker/back/methods/department/getLeaves.js b/modules/worker/back/methods/department/getLeaves.js index 566bbffad..802a2d41d 100644 --- a/modules/worker/back/methods/department/getLeaves.js +++ b/modules/worker/back/methods/department/getLeaves.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('getLeaves', { + Self.remoteMethodCtx, ('getLeaves', { description: 'Returns the nodes for a department', accepts: [{ arg: 'parentId', @@ -20,10 +20,11 @@ module.exports = Self => { } }); - Self.getLeaves = async(parentId = null, search) => { + Self.getLeaves = async(ctx, parentId = null, search) => { let [res] = await Self.rawSql( `CALL department_getLeaves(?, ?)`, - [parentId, search] + [parentId, search], + {userId: ctx.req.accessToken.userId} ); let map = new Map(); diff --git a/modules/worker/back/methods/worker-time-control/addTimeEntry.js b/modules/worker/back/methods/worker-time-control/addTimeEntry.js index bcc96985f..cc652fb90 100644 --- a/modules/worker/back/methods/worker-time-control/addTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/addTimeEntry.js @@ -33,15 +33,15 @@ module.exports = Self => { Self.addTimeEntry = async(ctx, workerId, options) => { const models = Self.app.models; const args = ctx.args; - const currentUserId = ctx.req.accessToken.userId; - const myOptions = {}; + const userId = ctx.req.accessToken.userId; + const myOptions = {userId}; if (typeof options == 'object') Object.assign(myOptions, options); const isSubordinate = await models.Worker.isSubordinate(ctx, workerId, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - const isHimself = currentUserId == workerId; + const isHimself = userId == workerId; if (!isSubordinate || (isSubordinate && isHimself && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); diff --git a/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js b/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js index 80482901f..8f9541596 100644 --- a/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js @@ -22,10 +22,10 @@ module.exports = Self => { }); Self.deleteTimeEntry = async(ctx, id, options) => { - const currentUserId = ctx.req.accessToken.userId; + const userId = ctx.req.accessToken.userId; const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId}; if (typeof options == 'object') Object.assign(myOptions, options); @@ -33,7 +33,7 @@ module.exports = Self => { const targetTimeEntry = await Self.findById(id, null, myOptions); const isSubordinate = await models.Worker.isSubordinate(ctx, targetTimeEntry.userFk, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - const isHimself = currentUserId == targetTimeEntry.userFk; + const isHimself = userId == targetTimeEntry.userFk; if (isSubordinate === false || (isSubordinate && isHimself && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index 3d57ebbbd..ab5e56a77 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -33,7 +33,7 @@ module.exports = Self => { const conn = Self.dataSource.connector; const args = ctx.args; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index 398411118..27acc98ab 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -119,7 +119,7 @@ module.exports = Self => { Self.new = async(ctx, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; const args = ctx.args; let tx; diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index 44f6e9b09..b2804c203 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -36,6 +36,7 @@ describe('Worker new', () => { payMethodFk: 1, roleFk: 1 }; + const req = {accessToken: {userId: 9}}; it('should return error if personal mail already exists', async() => { const user = await models.VnUser.findById(employeeId, {fields: ['email']}); @@ -46,7 +47,8 @@ describe('Worker new', () => { try { const options = {transaction: tx}; const ctx = { - args: Object.assign({}, defaultWorker, {email: user.email}) + args: Object.assign({}, defaultWorker, {email: user.email}), + req }; await models.Worker.new(ctx, options); @@ -69,7 +71,8 @@ describe('Worker new', () => { try { const options = {transaction: tx}; const ctx = { - args: Object.assign({}, defaultWorker, {code: worker.code}) + args: Object.assign({}, defaultWorker, {code: worker.code}), + req }; await models.Worker.new(ctx, options); @@ -92,7 +95,8 @@ describe('Worker new', () => { try { const options = {transaction: tx}; const ctx = { - args: Object.assign({}, defaultWorker, {fi: worker.fi}) + args: Object.assign({}, defaultWorker, {fi: worker.fi}), + req }; await models.Worker.new(ctx, options); @@ -119,7 +123,8 @@ describe('Worker new', () => { try { const options = {transaction: tx}; const ctx = { - args: Object.assign({}, defaultWorker, {payMethodFk: payMethodIbanRequired.id}) + args: Object.assign({}, defaultWorker, {payMethodFk: payMethodIbanRequired.id}), + req }; await models.Worker.new(ctx, options); @@ -133,7 +138,7 @@ describe('Worker new', () => { }); it('should create a new worker', async() => { - const newWorker = await models.Worker.new({args: defaultWorker}); + const newWorker = await models.Worker.new({args: defaultWorker, req}); await models.Worker.destroyById(newWorker.id); await models.Address.destroyAll({clientFk: newWorker.id}); @@ -155,7 +160,8 @@ describe('Worker new', () => { { fi: client.fi, email: client.email - }) + }), + req }; const newWorker = await models.Worker.new(newWorkerData); diff --git a/modules/worker/back/models/device-production-log.json b/modules/worker/back/models/device-production-log.json index 71c54a9c1..b87fe5e6b 100644 --- a/modules/worker/back/models/device-production-log.json +++ b/modules/worker/back/models/device-production-log.json @@ -1,55 +1,14 @@ { - "name": "DeviceProductionLog", - "base": "Log", - "options": { - "mysql": { - "table": "deviceProductionLog" - } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "deviceProduction": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "created": { - "type": "date" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "changedModel": { - "type": "string" - }, - "changedModelId": { - "type": "number" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "Account", - "foreignKey": "userFk" + "name": "DeviceProductionLog", + "base": "Log", + "options": { + "mysql": { + "table": "deviceProductionLog" } }, - "scope": { - "order": ["created DESC", "id DESC"] + "properties": { + "deviceProduction": { + "type": "number" + } } } diff --git a/modules/worker/back/models/operator.json b/modules/worker/back/models/operator.json index db8a8c451..9433a0fd5 100644 --- a/modules/worker/back/models/operator.json +++ b/modules/worker/back/models/operator.json @@ -27,10 +27,10 @@ "type": "number", "required": true }, - "sectorFk ": { + "sectorFk": { "type": "number" }, - "labelerFk ": { + "labelerFk": { "type": "number" } }, @@ -41,4 +41,4 @@ "foreignKey": "sectorFk" } } -} \ No newline at end of file +} diff --git a/modules/worker/back/models/worker-log.json b/modules/worker/back/models/worker-log.json index 6eb8b75be..1ca1ac5ff 100644 --- a/modules/worker/back/models/worker-log.json +++ b/modules/worker/back/models/worker-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "workerLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/zone/back/locale/zone-event/en.yml b/modules/zone/back/locale/zone-event/en.yml index 2d6ef39ab..1988c1239 100644 --- a/modules/zone/back/locale/zone-event/en.yml +++ b/modules/zone/back/locale/zone-event/en.yml @@ -1,14 +1,14 @@ -name: zone event +name: event columns: id: id zoneFk: zone type: type dated: dated - started: started - ended: ended + started: starts + ended: ends weekDays: week days hour: hour travelingDays: traveling days price: price bonus: bonus - m3Max: max m3 + m3Max: max. m3 diff --git a/modules/zone/back/locale/zone-event/es.yml b/modules/zone/back/locale/zone-event/es.yml index 9bc8db9fe..5092cc933 100644 --- a/modules/zone/back/locale/zone-event/es.yml +++ b/modules/zone/back/locale/zone-event/es.yml @@ -1,11 +1,11 @@ -name: evento zona +name: evento columns: id: id zoneFk: zona type: tipo dated: fecha - started: comenzado - ended: terminado + started: empieza + ended: termina weekDays: días semana hour: hora travelingDays: días de viaje diff --git a/modules/zone/back/locale/zone-exclusion/en.yml b/modules/zone/back/locale/zone-exclusion/en.yml index 4389d8b93..6a2383b87 100644 --- a/modules/zone/back/locale/zone-exclusion/en.yml +++ b/modules/zone/back/locale/zone-exclusion/en.yml @@ -1,5 +1,5 @@ -name: zone exclusion +name: exclusion columns: id: id - dated: dated + dated: date zoneFk: zone diff --git a/modules/zone/back/locale/zone-exclusion/es.yml b/modules/zone/back/locale/zone-exclusion/es.yml index 4e59cba46..35102a670 100644 --- a/modules/zone/back/locale/zone-exclusion/es.yml +++ b/modules/zone/back/locale/zone-exclusion/es.yml @@ -1,4 +1,4 @@ -name: zone exclusion +name: exclusión columns: id: id dated: fecha diff --git a/modules/zone/back/locale/zone-included/en.yml b/modules/zone/back/locale/zone-included/en.yml index 0e44989e9..65e4faac6 100644 --- a/modules/zone/back/locale/zone-included/en.yml +++ b/modules/zone/back/locale/zone-included/en.yml @@ -1,5 +1,7 @@ -name: zone included +name: inclusion columns: id: id dated: dated zoneFk: zone + isIncluded: incluida + geoFk: localización diff --git a/modules/zone/back/locale/zone-included/es.yml b/modules/zone/back/locale/zone-included/es.yml index 30a89373a..bd48cdbe5 100644 --- a/modules/zone/back/locale/zone-included/es.yml +++ b/modules/zone/back/locale/zone-included/es.yml @@ -1,5 +1,7 @@ -name: zona incluida +name: inclusión columns: id: id dated: fecha zoneFk: zona + isIncluded: incluida + geoFk: localización diff --git a/modules/zone/back/locale/zone-warehouse/en.yml b/modules/zone/back/locale/zone-warehouse/en.yml index b9c4f7609..6caa3de1b 100644 --- a/modules/zone/back/locale/zone-warehouse/en.yml +++ b/modules/zone/back/locale/zone-warehouse/en.yml @@ -1,4 +1,4 @@ -name: zone warehouse +name: warehouse columns: id: id warehouseFk: warehouse diff --git a/modules/zone/back/locale/zone-warehouse/es.yml b/modules/zone/back/locale/zone-warehouse/es.yml index ec8dec2dd..caf0d8f1a 100644 --- a/modules/zone/back/locale/zone-warehouse/es.yml +++ b/modules/zone/back/locale/zone-warehouse/es.yml @@ -1,4 +1,4 @@ -name: almacén zona +name: almacén columns: id: id warehouseFk: almacén diff --git a/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js b/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js index 846ad6a3d..c8ab4f67c 100644 --- a/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js +++ b/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('getAgenciesWithWarehouse', { + Self.remoteMethodCtx('getAgenciesWithWarehouse', { description: 'Returns a list of agencies that can land a shipment on a day for an address and a warehouse', accepts: [ { @@ -28,8 +28,8 @@ module.exports = Self => { } }); - Self.getAgenciesWithWarehouse = async(addressFk, landed, warehouseFk, options) => { - const myOptions = {}; + Self.getAgenciesWithWarehouse = async(ctx, addressFk, landed, warehouseFk, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/agency/landsThatDay.js b/modules/zone/back/methods/agency/landsThatDay.js index b7f13ddda..4d73e4d08 100644 --- a/modules/zone/back/methods/agency/landsThatDay.js +++ b/modules/zone/back/methods/agency/landsThatDay.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('landsThatDay', { + Self.remoteMethodCtx('landsThatDay', { description: 'Returns a list of agencies that can land a shipment on a day for an address', accepts: [ { @@ -22,8 +22,8 @@ module.exports = Self => { } }); - Self.landsThatDay = async(addressFk, landed, options) => { - const myOptions = {}; + Self.landsThatDay = async(ctx, addressFk, landed, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js b/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js index 4f79b2315..f760559cb 100644 --- a/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js +++ b/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js @@ -2,6 +2,7 @@ const app = require('vn-loopback/server/server'); describe('Agency getAgenciesWithWarehouse()', () => { const today = Date.vnNew(); + const ctx = {req: {accessToken: {userId: 9}}}; it('should return the agencies that can handle the given delivery request', async() => { const tx = await app.models.Zone.beginTransaction({}); @@ -9,7 +10,7 @@ describe('Agency getAgenciesWithWarehouse()', () => { const options = {transaction: tx}; const addressId = 101; - const agencies = await app.models.Agency.getAgenciesWithWarehouse(addressId, today, 1, options); + const agencies = await app.models.Agency.getAgenciesWithWarehouse(ctx, addressId, today, 1, options); expect(agencies.length).toEqual(3); expect(agencies[0].agencyMode).toEqual('inhouse pickup'); @@ -30,7 +31,7 @@ describe('Agency getAgenciesWithWarehouse()', () => { const options = {transaction: tx}; const addressId = 101; - const agencies = await app.models.Agency.getAgenciesWithWarehouse(addressId, null, 1, options); + const agencies = await app.models.Agency.getAgenciesWithWarehouse(ctx, addressId, null, 1, options); expect(agencies.length).toEqual(0); diff --git a/modules/zone/back/methods/agency/specs/landsThatDay.spec.js b/modules/zone/back/methods/agency/specs/landsThatDay.spec.js index 4bde37984..1ec675071 100644 --- a/modules/zone/back/methods/agency/specs/landsThatDay.spec.js +++ b/modules/zone/back/methods/agency/specs/landsThatDay.spec.js @@ -1,6 +1,7 @@ const {models} = require('vn-loopback/server/server'); describe('Agency landsThatDay()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; const today = Date.vnNew(); it('should return a list of agencies that can land a shipment on a day for an address', async() => { const tx = await models.Agency.beginTransaction({}); @@ -8,7 +9,7 @@ describe('Agency landsThatDay()', () => { try { const options = {transaction: tx}; - const agencies = await models.Agency.landsThatDay(101, today, options); + const agencies = await models.Agency.landsThatDay(ctx, 101, today, options); expect(agencies.length).toBeGreaterThanOrEqual(3); diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index e3846132b..bcfb91e3d 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -26,7 +26,7 @@ module.exports = Self => { today.setHours(0, 0, 0, 0); let tx; - const myOptions = {}; + const myOptions = {userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/zone/getEvents.js b/modules/zone/back/methods/zone/getEvents.js index a8ee8bb7b..03fb31438 100644 --- a/modules/zone/back/methods/zone/getEvents.js +++ b/modules/zone/back/methods/zone/getEvents.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethod('getEvents', { + Self.remoteMethodCtx('getEvents', { description: 'Returns delivery days for a postcode', accepts: [ { @@ -25,8 +25,8 @@ module.exports = Self => { } }); - Self.getEvents = async(geoFk, agencyModeFk, options) => { - const myOptions = {}; + Self.getEvents = async(ctx, geoFk, agencyModeFk, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/zone/getLeaves.js b/modules/zone/back/methods/zone/getLeaves.js index 680d5ba22..a6db3b711 100644 --- a/modules/zone/back/methods/zone/getLeaves.js +++ b/modules/zone/back/methods/zone/getLeaves.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethod('getLeaves', { + Self.remoteMethodCtx('getLeaves', { description: 'Returns the nodes for a zone', accepts: [ { @@ -31,8 +31,9 @@ module.exports = Self => { } }); - Self.getLeaves = async(id, parentId = null, search, options) => { - const myOptions = {}; + Self.getLeaves = async(ctx, id, parentId = null, search, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; + if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/zone/getUpcomingDeliveries.js b/modules/zone/back/methods/zone/getUpcomingDeliveries.js index 2a1c39ed6..e8b7e7636 100644 --- a/modules/zone/back/methods/zone/getUpcomingDeliveries.js +++ b/modules/zone/back/methods/zone/getUpcomingDeliveries.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('getUpcomingDeliveries', { + Self.remoteMethodCtx('getUpcomingDeliveries', { description: 'Returns the upcomings deliveries', accessType: 'READ', accepts: [], @@ -13,8 +13,8 @@ module.exports = Self => { } }); - Self.getUpcomingDeliveries = async options => { - const myOptions = {}; + Self.getUpcomingDeliveries = async(ctx, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/zone/specs/getEvents.spec.js b/modules/zone/back/methods/zone/specs/getEvents.spec.js index d1c51baff..c1dee3e0f 100644 --- a/modules/zone/back/methods/zone/specs/getEvents.spec.js +++ b/modules/zone/back/methods/zone/specs/getEvents.spec.js @@ -1,13 +1,14 @@ const models = require('vn-loopback/server/server').models; describe('zone getEvents()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should return all events for the specified geo and agency mode', async() => { const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await models.Zone.getEvents(20, 1, options); + let result = await models.Zone.getEvents(ctx, 20, 1, options); expect(result.events.length).toEqual(10); diff --git a/modules/zone/back/methods/zone/specs/getLeaves.spec.js b/modules/zone/back/methods/zone/specs/getLeaves.spec.js index db7359671..9342a0b50 100644 --- a/modules/zone/back/methods/zone/specs/getLeaves.spec.js +++ b/modules/zone/back/methods/zone/specs/getLeaves.spec.js @@ -1,13 +1,14 @@ const models = require('vn-loopback/server/server').models; describe('zone getLeaves()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should return the country and the childs containing the search value', async() => { const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await models.Zone.getLeaves(1, null, '46000', options); + let result = await models.Zone.getLeaves(ctx, 1, null, '46000', options); expect(result.length).toEqual(1); diff --git a/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js b/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js index acef079f6..fe542fbf3 100644 --- a/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js +++ b/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js @@ -1,12 +1,13 @@ const models = require('vn-loopback/server/server').models; describe('zone getUpcomingDeliveries()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should check returns data', async() => { const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await models.Zone.getUpcomingDeliveries(options); + let result = await models.Zone.getUpcomingDeliveries(ctx, options); const firstResultLines = result[0].lines; const secondResultLines = result[1].lines; diff --git a/modules/zone/back/models/zone-log.json b/modules/zone/back/models/zone-log.json index 72dd305b2..403966ddd 100644 --- a/modules/zone/back/models/zone-log.json +++ b/modules/zone/back/models/zone-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "zoneLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/package-lock.json b/package-lock.json index a224c4bb3..c190065b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "salix-back", - "version": "23.22.01", + "version": "23.26.01", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "salix-back", - "version": "23.22.01", + "version": "23.24.01", "license": "GPL-3.0", "dependencies": { "axios": "^1.2.2", diff --git a/package.json b/package.json index f1b3daca3..4358c86a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.24.01", + "version": "23.26.01", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", diff --git a/webpack.config.js b/webpack.config.js index 7a94b993d..a102b838e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,7 +9,7 @@ let mode = env == 'development' ? env : 'production'; let baseConfig = { entry: {salix: 'salix'}, - mode: mode, + mode, output: { path: path.join(__dirname, 'dist'), publicPath: '/' From a155f846c21aa73b0a4d4445f533b9bb2037b4a1 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 20 Jun 2023 09:15:37 +0200 Subject: [PATCH 52/80] refs #5334 fix ctx --- modules/worker/back/methods/department/getLeaves.js | 9 +++++++-- .../back/methods/department/specs/getLeaves.spec.js | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/methods/department/getLeaves.js b/modules/worker/back/methods/department/getLeaves.js index 802a2d41d..bf7c83bb0 100644 --- a/modules/worker/back/methods/department/getLeaves.js +++ b/modules/worker/back/methods/department/getLeaves.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx, ('getLeaves', { + Self.remoteMethodCtx('getLeaves', { description: 'Returns the nodes for a department', accepts: [{ arg: 'parentId', @@ -21,10 +21,15 @@ module.exports = Self => { }); Self.getLeaves = async(ctx, parentId = null, search) => { + const myOptions = {userId: ctx.req.accessToken.userId}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + let [res] = await Self.rawSql( `CALL department_getLeaves(?, ?)`, [parentId, search], - {userId: ctx.req.accessToken.userId} + myOptions ); let map = new Map(); diff --git a/modules/worker/back/methods/department/specs/getLeaves.spec.js b/modules/worker/back/methods/department/specs/getLeaves.spec.js index 5972a9b4c..fb7c84ff4 100644 --- a/modules/worker/back/methods/department/specs/getLeaves.spec.js +++ b/modules/worker/back/methods/department/specs/getLeaves.spec.js @@ -1,8 +1,9 @@ const models = require('vn-loopback/server/server').models; describe('department getLeaves()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should return the department and the childs containing the search value', async() => { - let result = await models.Department.getLeaves(null, 'INFORMATICA'); + let result = await models.Department.getLeaves(ctx, null, 'INFORMATICA'); expect(result.length).toEqual(1); }); From c63df30e5caf5082a073e936c4ed6b3a2a99d8da Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 20 Jun 2023 09:19:20 +0200 Subject: [PATCH 53/80] refs #5334 fix back --- modules/worker/back/methods/department/getLeaves.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/worker/back/methods/department/getLeaves.js b/modules/worker/back/methods/department/getLeaves.js index bf7c83bb0..38ff2ef3e 100644 --- a/modules/worker/back/methods/department/getLeaves.js +++ b/modules/worker/back/methods/department/getLeaves.js @@ -21,15 +21,10 @@ module.exports = Self => { }); Self.getLeaves = async(ctx, parentId = null, search) => { - const myOptions = {userId: ctx.req.accessToken.userId}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - let [res] = await Self.rawSql( `CALL department_getLeaves(?, ?)`, [parentId, search], - myOptions + {userId: ctx.req.accessToken.userId} ); let map = new Map(); From e7419042505ea6259f0ee814a172131ea40ec744 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 20 Jun 2023 17:01:06 +0200 Subject: [PATCH 54/80] refs #5347 --- db/changes/232601/00-client_create.sql | 113 ++++++++++++++++++++++ modules/worker/back/methods/worker/new.js | 2 +- 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 db/changes/232601/00-client_create.sql diff --git a/db/changes/232601/00-client_create.sql b/db/changes/232601/00-client_create.sql new file mode 100644 index 000000000..9e2c55c40 --- /dev/null +++ b/db/changes/232601/00-client_create.sql @@ -0,0 +1,113 @@ +DROP PROCEDURE IF EXISTS vn.clientCreate; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_create`( + vFirstname VARCHAR(50), + vSurnames VARCHAR(50), + vFi VARCHAR(9), + vAddress TEXT, + vPostcode CHAR(5), + vCity VARCHAR(25), + vProvinceFk SMALLINT(5), + vCompanyFk SMALLINT(5), + vPhone VARCHAR(11), + vEmail VARCHAR(255), + vUserFk INT) +BEGIN +/** + * Create new client + * + * @params vFirstname firstName + * @params vSurnames surnames + * @params vFi company code from accounting transactions + * @params vAddress address + * @params vPostcode postCode + * @params vCity city + * @params vProvinceFk province + * @params vCompanyFk company in which he has become a client + * @params vPhone telephone number + * @params vEmail email address + * @params vUserFk user id + */ + DECLARE vPayMethodFk INT; + DECLARE vDueDay INT; + DECLARE vDefaultCredit DECIMAL(10, 2); + DECLARE vIsTaxDataChecked TINYINT(1); + DECLARE vHasCoreVnl BOOLEAN; + DECLARE vMandateTypeFk INT; + + SELECT payMethodFk, + dueDay, + credit, + isTaxDataChecked, + hasCoreVnl, + mandateTypeFk + INTO vPayMethodFk, + vDueDay, + vDefaultCredit, + vIsTaxDataChecked, + vHasCoreVnl, + vMandateTypeFk + FROM clientNewConfig; + + INSERT INTO `client` + SET id = vUserFk, + name = CONCAT(vFirstname, ' ', vSurnames), + street = vAddress, + fi = TRIM(vFi), + phone = vPhone, + email = vEmail, + provinceFk = vProvinceFk, + city = vCity, + postcode = vPostcode, + socialName = CONCAT(vSurnames, ' ', vFirstname), + payMethodFk = vPayMethodFk, + dueDay = vDueDay, + credit = vDefaultCredit, + isTaxDataChecked = vIsTaxDataChecked, + hasCoreVnl = vHasCoreVnl, + isEqualizated = FALSE + ON duplicate KEY UPDATE + payMethodFk = vPayMethodFk, + dueDay = vDueDay, + credit = vDefaultCredit, + isTaxDataChecked = vIsTaxDataChecked, + hasCoreVnl = vHasCoreVnl, + isActive = TRUE; + + INSERT INTO mandate (clientFk, companyFk, mandateTypeFk) + SELECT vUserFk, vCompanyFk, vMandateTypeFk + WHERE NOT EXISTS ( + SELECT 1 + FROM mandate + WHERE clientFk = vUserFk + AND companyFk = vCompanyFk + AND mandateTypeFk = vMandateTypeFk + ); +END$$ +DELIMITER ; + +CREATE TABLE IF NOT EXISTS vn.clientNewConfig ( + id int unsigned auto_increment NULL, + payMethodFk tinyint(3) unsigned NULL, + dueDay int unsigned NULL, + credit decimal(10, 2) NULL, + isTaxDataChecked tinyint(1) NULL, + hasCoreVnl boolean NULL, + mandateTypeFk smallint(5) NULL, + CONSTRAINT clientNewConfig_PK PRIMARY KEY (id), + CONSTRAINT clientNewConfigPayMethod_FK FOREIGN KEY (payMethodFk) REFERENCES vn.payMethod(id), + CONSTRAINT clientNewConfigMandateType_FK FOREIGN KEY (mandateTypeFk) REFERENCES vn.mandateType(id) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO vn.clientNewConfig + SET id = 1, + payMethodFk = 4, + dueDay = 5, + credit = 300.0, + isTaxDataChecked = 1, + hasCoreVnl = 1, + mandateTypeFk = 2; \ No newline at end of file diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index 27acc98ab..199a3be62 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -171,7 +171,7 @@ module.exports = Self => { throw new UserError(`That payment method requires an IBAN`); await models.Worker.rawSql( - 'CALL vn.clientCreate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + 'CALL vn.client_create(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [ args.firstName, args.lastNames, From 168d05a830b2311ea5cde4179d8682a30225924b Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 21 Jun 2023 13:07:04 +0200 Subject: [PATCH 55/80] refs #5334 fix errors --- .../front/department/basic-data/index.js | 3 +-- .../front/department/descriptor/index.js | 22 ------------------- modules/worker/front/department/main/index.js | 4 +--- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/modules/worker/front/department/basic-data/index.js b/modules/worker/front/department/basic-data/index.js index 31f50ee85..000ef0597 100644 --- a/modules/worker/front/department/basic-data/index.js +++ b/modules/worker/front/department/basic-data/index.js @@ -1,11 +1,10 @@ import ngModule from '../../module'; import Section from 'salix/components/section'; -export default class Controller extends Section {} ngModule.vnComponent('vnWorkerDepartmentBasicData', { template: require('./index.html'), - controller: Controller, + controller: Section, bindings: { department: '<' } diff --git a/modules/worker/front/department/descriptor/index.js b/modules/worker/front/department/descriptor/index.js index 388a7f776..5ab1059d9 100644 --- a/modules/worker/front/department/descriptor/index.js +++ b/modules/worker/front/department/descriptor/index.js @@ -32,28 +32,6 @@ class Controller extends Descriptor { this.vnApp.showSuccess(this.$t('Department deleted.')); }); } - - loadData() { - const filter = { - fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', - 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'], - include: [ - {relation: 'client', - scope: { - fields: ['id', 'name'] - }}, - { - relation: 'worker', - scope: { - fields: ['id', 'firstName', 'lastName'] - } - } - ] - }; - - return this.getData(`Departments/${this.id}`, {filter}) - .then(res => this.entity = res.data); - } } Controller.$inject = ['$element', '$scope', '$rootScope']; diff --git a/modules/worker/front/department/main/index.js b/modules/worker/front/department/main/index.js index 3fda47246..cbdf8689d 100644 --- a/modules/worker/front/department/main/index.js +++ b/modules/worker/front/department/main/index.js @@ -1,9 +1,7 @@ import ngModule from '../../module'; import ModuleMain from 'salix/components/module-main'; -export default class Department extends ModuleMain {} - ngModule.vnComponent('vnWorkerDepartment', { - controller: Department, + controller: ModuleMain, template: require('./index.html') }); From 27946c0062c2ee8b78046f85e3a1386a067a6894 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 22 Jun 2023 15:00:15 +0200 Subject: [PATCH 56/80] Refs #5347 --- db/changes/232601/00-client_create.sql | 54 +++++++++++--------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/db/changes/232601/00-client_create.sql b/db/changes/232601/00-client_create.sql index 9e2c55c40..e43eb7b38 100644 --- a/db/changes/232601/00-client_create.sql +++ b/db/changes/232601/00-client_create.sql @@ -36,19 +36,19 @@ BEGIN DECLARE vHasCoreVnl BOOLEAN; DECLARE vMandateTypeFk INT; - SELECT payMethodFk, - dueDay, - credit, - isTaxDataChecked, - hasCoreVnl, - mandateTypeFk + SELECT dafaultPayMethodFk, + defaultDueDay, + defaultCredit, + defaultIsTaxDataChecked, + defaultHasCoreVnl, + defaultMandateTypeFk INTO vPayMethodFk, vDueDay, vDefaultCredit, vIsTaxDataChecked, vHasCoreVnl, vMandateTypeFk - FROM clientNewConfig; + FROM clientConfig; INSERT INTO `client` SET id = vUserFk, @@ -78,7 +78,7 @@ BEGIN INSERT INTO mandate (clientFk, companyFk, mandateTypeFk) SELECT vUserFk, vCompanyFk, vMandateTypeFk WHERE NOT EXISTS ( - SELECT 1 + SELECT id FROM mandate WHERE clientFk = vUserFk AND companyFk = vCompanyFk @@ -87,27 +87,19 @@ BEGIN END$$ DELIMITER ; -CREATE TABLE IF NOT EXISTS vn.clientNewConfig ( - id int unsigned auto_increment NULL, - payMethodFk tinyint(3) unsigned NULL, - dueDay int unsigned NULL, - credit decimal(10, 2) NULL, - isTaxDataChecked tinyint(1) NULL, - hasCoreVnl boolean NULL, - mandateTypeFk smallint(5) NULL, - CONSTRAINT clientNewConfig_PK PRIMARY KEY (id), - CONSTRAINT clientNewConfigPayMethod_FK FOREIGN KEY (payMethodFk) REFERENCES vn.payMethod(id), - CONSTRAINT clientNewConfigMandateType_FK FOREIGN KEY (mandateTypeFk) REFERENCES vn.mandateType(id) -) -ENGINE=InnoDB -DEFAULT CHARSET=utf8mb3 -COLLATE=utf8mb3_unicode_ci; +ALTER TABLE vn.clientConfig ADD dafaultPayMethodFk tinyint(3) unsigned NULL; +ALTER TABLE vn.clientConfig ADD defaultDueDay int unsigned NULL; +ALTER TABLE vn.clientConfig ADD defaultCredit decimal(10, 2) NULL; +ALTER TABLE vn.clientConfig ADD defaultIsTaxDataChecked tinyint(1) NULL; +ALTER TABLE vn.clientConfig ADD defaultHasCoreVnl boolean NULL; +ALTER TABLE vn.clientConfig ADD defaultMandateTypeFk smallint(5) NULL; +ALTER TABLE vn.clientConfig ADD CONSTRAINT clientNewConfigPayMethod_FK FOREIGN KEY (dafaultPayMethodFk) REFERENCES vn.payMethod(id); +ALTER TABLE vn.clientConfig ADD CONSTRAINT clientNewConfigMandateType_FK FOREIGN KEY (defaultMandateTypeFk) REFERENCES vn.mandateType(id); -INSERT IGNORE INTO vn.clientNewConfig - SET id = 1, - payMethodFk = 4, - dueDay = 5, - credit = 300.0, - isTaxDataChecked = 1, - hasCoreVnl = 1, - mandateTypeFk = 2; \ No newline at end of file +UPDATE vn.clientConfig + SET dafaultPayMethodFk = 4, + defaultDueDay = 5, + defaultCredit = 300.0, + defaultIsTaxDataChecked = 1, + defaultHasCoreVnl = 1, + defaultMandateTypeFk = 2; \ No newline at end of file From 137e01e60cf963af22bf51489be5c74bc8ca5379 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 22 Jun 2023 15:00:59 +0200 Subject: [PATCH 57/80] refs #5334 fix acl, filter --- modules/worker/front/department/card/index.js | 7 ++++--- .../front/department/descriptor/index.html | 4 ++-- .../worker/front/department/summary/index.js | 21 +------------------ modules/worker/front/routes.json | 3 +-- 4 files changed, 8 insertions(+), 27 deletions(-) diff --git a/modules/worker/front/department/card/index.js b/modules/worker/front/department/card/index.js index 93a39dd44..cf0f3922d 100644 --- a/modules/worker/front/department/card/index.js +++ b/modules/worker/front/department/card/index.js @@ -7,11 +7,12 @@ class Controller extends ModuleCard { fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'], include: [ - {relation: 'client', + { + relation: 'client', scope: { fields: ['id', 'name'] - }}, - { + } + }, { relation: 'worker', scope: { fields: ['id', 'firstName', 'lastName'] diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html index 904643cc6..6b7ade66a 100644 --- a/modules/worker/front/department/descriptor/index.html +++ b/modules/worker/front/department/descriptor/index.html @@ -32,8 +32,8 @@ diff --git a/modules/worker/front/department/summary/index.js b/modules/worker/front/department/summary/index.js index 45e3f6d2d..574dfac35 100644 --- a/modules/worker/front/department/summary/index.js +++ b/modules/worker/front/department/summary/index.js @@ -6,26 +6,7 @@ class Controller extends Component { this._department = value; this.$.summary = null; if (!value) return; - - const filter = { - fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName', - 'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'], - include: [ - {relation: 'client', - scope: { - fields: ['id', 'name'] - }}, - { - relation: 'worker', - scope: { - fields: ['id', 'firstName', 'lastName'] - } - } - ] - }; - - this.$http.get(`Departments/${value.id}`, {filter}) - .then(res => this.$.summary = res.data); + this.$.summary = this.department; } get department() { return this._department; diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 1a266869e..7906b1f45 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -124,8 +124,7 @@ "url": "/department?q", "state": "worker.department", "component": "vn-worker-department", - "description":"Departments", - "acl":["hr"] + "description":"Departments" }, { "url": "/:id", "state": "worker.department.card", From beb173f6ce44fa06243cce24a3761e2188951977 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 22 Jun 2023 15:20:28 +0200 Subject: [PATCH 58/80] refs #5334 quit e2e no necesario --- modules/worker/front/department/card/index.js | 1 + .../front/department/descriptor/index.spec.js | 26 ------------------- 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 modules/worker/front/department/descriptor/index.spec.js diff --git a/modules/worker/front/department/card/index.js b/modules/worker/front/department/card/index.js index cf0f3922d..62ecf998b 100644 --- a/modules/worker/front/department/card/index.js +++ b/modules/worker/front/department/card/index.js @@ -19,6 +19,7 @@ class Controller extends ModuleCard { } } ] + }; this.$http.get(`Departments/${this.$params.id}`, {filter}) diff --git a/modules/worker/front/department/descriptor/index.spec.js b/modules/worker/front/department/descriptor/index.spec.js deleted file mode 100644 index 305ebcc18..000000000 --- a/modules/worker/front/department/descriptor/index.spec.js +++ /dev/null @@ -1,26 +0,0 @@ -import './index.js'; - -describe('vnWorkerDepartmentDescriptor', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnWorkerDepartmentDescriptor', {$element: null}); - })); - - describe('loadData()', () => { - it(`should perform a get query to store the department data into the controller`, () => { - const id = '31'; - const response = 'foo'; - - $httpBackend.expectRoute('GET', `Departments/${id}`).respond(response); - controller.id = id; - $httpBackend.flush(); - - expect(controller.department).toEqual(response); - }); - }); -}); From f6cc59eafb654ace68fc11f39962cba7ff69899d Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 22 Jun 2023 16:23:36 +0200 Subject: [PATCH 59/80] refs #5347 --- db/changes/232601/00-client_create.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/changes/232601/00-client_create.sql b/db/changes/232601/00-client_create.sql index e43eb7b38..d7e997045 100644 --- a/db/changes/232601/00-client_create.sql +++ b/db/changes/232601/00-client_create.sql @@ -42,12 +42,12 @@ BEGIN defaultIsTaxDataChecked, defaultHasCoreVnl, defaultMandateTypeFk - INTO vPayMethodFk, - vDueDay, - vDefaultCredit, - vIsTaxDataChecked, - vHasCoreVnl, - vMandateTypeFk + INTO vPayMethodFk, + vDueDay, + vDefaultCredit, + vIsTaxDataChecked, + vHasCoreVnl, + vMandateTypeFk FROM clientConfig; INSERT INTO `client` From f0fec2cdd63e3cac574be1c6d9c74f6209f98de9 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 22 Jun 2023 17:46:21 +0200 Subject: [PATCH 60/80] refs #5347 --- db/changes/232601/00-client_create.sql | 17 ----------------- db/changes/232601/00-client_create2.sql | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) create mode 100644 db/changes/232601/00-client_create2.sql diff --git a/db/changes/232601/00-client_create.sql b/db/changes/232601/00-client_create.sql index d7e997045..159ef99d6 100644 --- a/db/changes/232601/00-client_create.sql +++ b/db/changes/232601/00-client_create.sql @@ -86,20 +86,3 @@ BEGIN ); END$$ DELIMITER ; - -ALTER TABLE vn.clientConfig ADD dafaultPayMethodFk tinyint(3) unsigned NULL; -ALTER TABLE vn.clientConfig ADD defaultDueDay int unsigned NULL; -ALTER TABLE vn.clientConfig ADD defaultCredit decimal(10, 2) NULL; -ALTER TABLE vn.clientConfig ADD defaultIsTaxDataChecked tinyint(1) NULL; -ALTER TABLE vn.clientConfig ADD defaultHasCoreVnl boolean NULL; -ALTER TABLE vn.clientConfig ADD defaultMandateTypeFk smallint(5) NULL; -ALTER TABLE vn.clientConfig ADD CONSTRAINT clientNewConfigPayMethod_FK FOREIGN KEY (dafaultPayMethodFk) REFERENCES vn.payMethod(id); -ALTER TABLE vn.clientConfig ADD CONSTRAINT clientNewConfigMandateType_FK FOREIGN KEY (defaultMandateTypeFk) REFERENCES vn.mandateType(id); - -UPDATE vn.clientConfig - SET dafaultPayMethodFk = 4, - defaultDueDay = 5, - defaultCredit = 300.0, - defaultIsTaxDataChecked = 1, - defaultHasCoreVnl = 1, - defaultMandateTypeFk = 2; \ No newline at end of file diff --git a/db/changes/232601/00-client_create2.sql b/db/changes/232601/00-client_create2.sql new file mode 100644 index 000000000..48f669d37 --- /dev/null +++ b/db/changes/232601/00-client_create2.sql @@ -0,0 +1,17 @@ + +ALTER TABLE vn.clientConfig ADD dafaultPayMethodFk tinyint(3) unsigned NULL; +ALTER TABLE vn.clientConfig ADD defaultDueDay int unsigned NULL; +ALTER TABLE vn.clientConfig ADD defaultCredit decimal(10, 2) NULL; +ALTER TABLE vn.clientConfig ADD defaultIsTaxDataChecked tinyint(1) NULL; +ALTER TABLE vn.clientConfig ADD defaultHasCoreVnl boolean NULL; +ALTER TABLE vn.clientConfig ADD defaultMandateTypeFk smallint(5) NULL; +ALTER TABLE vn.clientConfig ADD CONSTRAINT clientNewConfigPayMethod_FK FOREIGN KEY (dafaultPayMethodFk) REFERENCES vn.payMethod(id); +ALTER TABLE vn.clientConfig ADD CONSTRAINT clientNewConfigMandateType_FK FOREIGN KEY (defaultMandateTypeFk) REFERENCES vn.mandateType(id); + +UPDATE vn.clientConfig + SET dafaultPayMethodFk = 4, + defaultDueDay = 5, + defaultCredit = 300.0, + defaultIsTaxDataChecked = 1, + defaultHasCoreVnl = 1, + defaultMandateTypeFk = 2; \ No newline at end of file From 203e80afa894d301c48415f3cbe5adc0dc57772b Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 22 Jun 2023 17:56:45 +0200 Subject: [PATCH 61/80] refs #5347 --- db/changes/232601/00-client_create.sql | 3 ++- db/changes/232601/00-client_create2.sql | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/db/changes/232601/00-client_create.sql b/db/changes/232601/00-client_create.sql index 159ef99d6..42dd353ba 100644 --- a/db/changes/232601/00-client_create.sql +++ b/db/changes/232601/00-client_create.sql @@ -12,7 +12,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_create`( vCompanyFk SMALLINT(5), vPhone VARCHAR(11), vEmail VARCHAR(255), - vUserFk INT) + vUserFk INT +) BEGIN /** * Create new client diff --git a/db/changes/232601/00-client_create2.sql b/db/changes/232601/00-client_create2.sql index 48f669d37..1191cc21c 100644 --- a/db/changes/232601/00-client_create2.sql +++ b/db/changes/232601/00-client_create2.sql @@ -1,3 +1,4 @@ +DROP PROCEDURE IF EXISTS vn.clientCreate; ALTER TABLE vn.clientConfig ADD dafaultPayMethodFk tinyint(3) unsigned NULL; ALTER TABLE vn.clientConfig ADD defaultDueDay int unsigned NULL; From 06437c9e80753e9eacf88cb191b5ffbc480715c6 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 28 Jun 2023 07:02:59 +0200 Subject: [PATCH 62/80] refs #5334 remove other --- db/docker/docker-temp-start.sh | 7 ------ db/dump/mysqlPlugins.sql | 4 ---- .../components/recover-password/style.scss | 24 ------------------- .../components/reset-password/style.scss | 24 ------------------- 4 files changed, 59 deletions(-) delete mode 100755 db/docker/docker-temp-start.sh delete mode 100644 db/dump/mysqlPlugins.sql delete mode 100644 front/salix/components/recover-password/style.scss delete mode 100644 front/salix/components/reset-password/style.scss diff --git a/db/docker/docker-temp-start.sh b/db/docker/docker-temp-start.sh deleted file mode 100755 index fc067102f..000000000 --- a/db/docker/docker-temp-start.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -. /usr/local/bin/docker-entrypoint.sh -CMD=mysqld - -docker_setup_env "$CMD" -docker_temp_server_start "$CMD" diff --git a/db/dump/mysqlPlugins.sql b/db/dump/mysqlPlugins.sql deleted file mode 100644 index c3b6f6ee4..000000000 --- a/db/dump/mysqlPlugins.sql +++ /dev/null @@ -1,4 +0,0 @@ - --- Import compiled functions -CREATE AGGREGATE FUNCTION minacum RETURNS INT SONAME 'minacum.so'; -CREATE AGGREGATE FUNCTION multimax RETURNS INT SONAME 'multimax.so'; diff --git a/front/salix/components/recover-password/style.scss b/front/salix/components/recover-password/style.scss deleted file mode 100644 index d3c6f594e..000000000 --- a/front/salix/components/recover-password/style.scss +++ /dev/null @@ -1,24 +0,0 @@ -@import "variables"; - -vn-recover-password{ - .footer { - margin-top: 32px; - text-align: center; - position: relative; - & > .vn-submit { - display: block; - - & > input { - display: block; - width: 100%; - } - } - & > .spinner-wrapper { - position: absolute; - width: 0; - top: 3px; - right: -8px; - overflow: visible; - } - } -} diff --git a/front/salix/components/reset-password/style.scss b/front/salix/components/reset-password/style.scss deleted file mode 100644 index 87e4adc8c..000000000 --- a/front/salix/components/reset-password/style.scss +++ /dev/null @@ -1,24 +0,0 @@ -@import "variables"; - -vn-reset-password{ - .footer { - margin-top: 32px; - text-align: center; - position: relative; - & > .vn-submit { - display: block; - - & > input { - display: block; - width: 100%; - } - } - & > .spinner-wrapper { - position: absolute; - width: 0; - top: 3px; - right: -8px; - overflow: visible; - } - } -} From f02019d64d9b0a0d11d07b9c4cf38f66a34bae34 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 28 Jun 2023 11:52:53 +0200 Subject: [PATCH 63/80] refs #5334 fix words --- modules/worker/front/department/basic-data/index.html | 2 +- modules/worker/front/department/descriptor/index.html | 2 +- modules/worker/front/department/summary/index.html | 2 +- modules/worker/front/department/summary/locale/es.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html index 9d5382569..374178768 100644 --- a/modules/worker/front/department/basic-data/index.html +++ b/modules/worker/front/department/basic-data/index.html @@ -57,7 +57,7 @@ + question="Are you sure you want to delete this department?"> diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html index 4cc8a4617..70ed020e0 100644 --- a/modules/worker/front/department/summary/index.html +++ b/modules/worker/front/department/summary/index.html @@ -37,7 +37,7 @@ diff --git a/modules/worker/front/department/summary/locale/es.yml b/modules/worker/front/department/summary/locale/es.yml index 7e9bdcd7b..6144efe1f 100644 --- a/modules/worker/front/department/summary/locale/es.yml +++ b/modules/worker/front/department/summary/locale/es.yml @@ -4,7 +4,7 @@ Chat: Chat Boss department: Jefe de departamento Email: Email Self-consumption customer: Cliente autoconsumo -Telecommutes: Teletrabaja +Teleworking: Teletrabaja Notificate errors: Notificar errores Is on production: Pertenece a producción Fill in days without physical check-ins: Rellenar fichadas From 6e52b3b968bf8546936a3cf1754b87177c2b3146 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 28 Jun 2023 14:07:37 +0200 Subject: [PATCH 64/80] refs #5347 --- db/changes/232601/00-client_create.sql | 12 ++++++------ db/changes/232601/00-client_create2.sql | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/db/changes/232601/00-client_create.sql b/db/changes/232601/00-client_create.sql index 42dd353ba..0728ba05e 100644 --- a/db/changes/232601/00-client_create.sql +++ b/db/changes/232601/00-client_create.sql @@ -37,18 +37,18 @@ BEGIN DECLARE vHasCoreVnl BOOLEAN; DECLARE vMandateTypeFk INT; - SELECT dafaultPayMethodFk, + SELECT defaultPayMethodFk, defaultDueDay, defaultCredit, defaultIsTaxDataChecked, defaultHasCoreVnl, defaultMandateTypeFk INTO vPayMethodFk, - vDueDay, - vDefaultCredit, - vIsTaxDataChecked, - vHasCoreVnl, - vMandateTypeFk + vDueDay, + vDefaultCredit, + vIsTaxDataChecked, + vHasCoreVnl, + vMandateTypeFk FROM clientConfig; INSERT INTO `client` diff --git a/db/changes/232601/00-client_create2.sql b/db/changes/232601/00-client_create2.sql index 1191cc21c..99e25fdc8 100644 --- a/db/changes/232601/00-client_create2.sql +++ b/db/changes/232601/00-client_create2.sql @@ -1,6 +1,6 @@ DROP PROCEDURE IF EXISTS vn.clientCreate; -ALTER TABLE vn.clientConfig ADD dafaultPayMethodFk tinyint(3) unsigned NULL; +ALTER TABLE vn.clientConfig ADD defaultPayMethodFk tinyint(3) unsigned NULL; ALTER TABLE vn.clientConfig ADD defaultDueDay int unsigned NULL; ALTER TABLE vn.clientConfig ADD defaultCredit decimal(10, 2) NULL; ALTER TABLE vn.clientConfig ADD defaultIsTaxDataChecked tinyint(1) NULL; @@ -10,7 +10,7 @@ ALTER TABLE vn.clientConfig ADD CONSTRAINT clientNewConfigPayMethod_FK FOREIGN K ALTER TABLE vn.clientConfig ADD CONSTRAINT clientNewConfigMandateType_FK FOREIGN KEY (defaultMandateTypeFk) REFERENCES vn.mandateType(id); UPDATE vn.clientConfig - SET dafaultPayMethodFk = 4, + SET defaultPayMethodFk = 4, defaultDueDay = 5, defaultCredit = 300.0, defaultIsTaxDataChecked = 1, From 9dc52b6011e06e6cf8ccec539ef2c5988dd8a4a6 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 29 Jun 2023 09:44:21 +0200 Subject: [PATCH 66/80] refs #5334 fix labels trad --- modules/worker/front/department/basic-data/index.html | 6 +++--- modules/worker/front/department/basic-data/locale/es.yml | 6 +++--- modules/worker/front/department/summary/index.html | 6 +++--- modules/worker/front/department/summary/locale/es.yml | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html index 374178768..5bc2d92ce 100644 --- a/modules/worker/front/department/basic-data/index.html +++ b/modules/worker/front/department/basic-data/index.html @@ -57,15 +57,15 @@ diff --git a/modules/worker/front/department/basic-data/locale/es.yml b/modules/worker/front/department/basic-data/locale/es.yml index ea80cfed1..e9c5574dd 100644 --- a/modules/worker/front/department/basic-data/locale/es.yml +++ b/modules/worker/front/department/basic-data/locale/es.yml @@ -5,9 +5,9 @@ Email: Email Boss department: Jefe del departamento Self-consumption customer: Cliente autoconsumo Telecommutes: Teletrabaja -Notificate errors: Notificar errores -Is on production: Pertenece a producción -Fill in days without physical check-ins: Rellenar fichadas +Notify on errors: Notificar errores +worksInProduction: Pertenece a producción +Fill in days without physical check-ins: Completar días sin registros físicos Send check-ins by email: Enviar fichadas por email Save: Guardar Undo changes: Deshacer cambios diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html index 70ed020e0..a6f06ade4 100644 --- a/modules/worker/front/department/summary/index.html +++ b/modules/worker/front/department/summary/index.html @@ -37,17 +37,17 @@ diff --git a/modules/worker/front/department/summary/locale/es.yml b/modules/worker/front/department/summary/locale/es.yml index 6144efe1f..c5cd53626 100644 --- a/modules/worker/front/department/summary/locale/es.yml +++ b/modules/worker/front/department/summary/locale/es.yml @@ -4,8 +4,8 @@ Chat: Chat Boss department: Jefe de departamento Email: Email Self-consumption customer: Cliente autoconsumo -Teleworking: Teletrabaja -Notificate errors: Notificar errores -Is on production: Pertenece a producción -Fill in days without physical check-ins: Rellenar fichadas +Telework: Teletrabaja +Notify on errors: Notificar errores +worksInProduction: Pertenece a producción +Fill in days without physical check-ins: Completar días sin registros físicos Send check-ins by email: Enviar fichadas por mail From be1c145d9a08d53d9c8170454c25d9b95bf7f126 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 29 Jun 2023 10:41:41 +0200 Subject: [PATCH 67/80] refs #5347 --- db/changes/232601/00-client_create.sql | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/db/changes/232601/00-client_create.sql b/db/changes/232601/00-client_create.sql index 0728ba05e..f31a8e348 100644 --- a/db/changes/232601/00-client_create.sql +++ b/db/changes/232601/00-client_create.sql @@ -76,14 +76,12 @@ BEGIN hasCoreVnl = vHasCoreVnl, isActive = TRUE; - INSERT INTO mandate (clientFk, companyFk, mandateTypeFk) - SELECT vUserFk, vCompanyFk, vMandateTypeFk - WHERE NOT EXISTS ( - SELECT id - FROM mandate - WHERE clientFk = vUserFk - AND companyFk = vCompanyFk - AND mandateTypeFk = vMandateTypeFk - ); + IF (SELECT COUNT(*) + FROM mandate + WHERE clientFk = vUserFk + AND companyFk = vCompanyFk + AND mandateTypeFk = vMandateTypeFk) = 0 THEN + INSERT INTO mandate (clientFk, companyFk, mandateTypeFk) + VALUES (vUserFk, vCompanyFk, vMandateTypeFk); END$$ DELIMITER ; From 6b4501146df3aec2bb14c07ee54cab37f5205065 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 30 Jun 2023 09:39:48 +0200 Subject: [PATCH 68/80] refs #5334 fix errors --- .../worker/front/department/basic-data/index.html | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html index 5bc2d92ce..8a8206d6d 100644 --- a/modules/worker/front/department/basic-data/index.html +++ b/modules/worker/front/department/basic-data/index.html @@ -4,6 +4,14 @@ form="form" url="Departments"> + + + +
@@ -55,7 +63,7 @@ label="Self-consumption customer"> - + @@ -67,8 +75,7 @@ - - + + From 83b096c2062f9c43f2e33a45904a1239000660a9 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 30 Jun 2023 09:40:12 +0200 Subject: [PATCH 69/80] refs #5334 fix errors --- modules/worker/back/models/department.js | 7 ++ .../front/department/basic-data/index.js | 1 - .../front/department/descriptor/index.html | 2 +- .../worker/front/department/main/index.html | 8 +++ .../front/department/summary/index.html | 68 +++++++++++-------- 5 files changed, 57 insertions(+), 29 deletions(-) diff --git a/modules/worker/back/models/department.js b/modules/worker/back/models/department.js index 5a927fc64..ff88a34d0 100644 --- a/modules/worker/back/models/department.js +++ b/modules/worker/back/models/department.js @@ -1,4 +1,11 @@ module.exports = Self => { + Self.validatesFormatOf('Email', { + message: 'Invalid email', + allowNull: true, + allowBlank: true, + with: /^[\W]*([\w+\-.%]+@[\w\-.]+\.[A-Za-z]{1,61}[\W]*,{1}[\W]*)*([\w+\-.%]+@[\w\-.]+\.[A-Za-z]{1,61})[\W]*$/ + }); + require('../methods/department/getLeaves')(Self); require('../methods/department/createChild')(Self); require('../methods/department/removeChild')(Self); diff --git a/modules/worker/front/department/basic-data/index.js b/modules/worker/front/department/basic-data/index.js index 000ef0597..e2df4804a 100644 --- a/modules/worker/front/department/basic-data/index.js +++ b/modules/worker/front/department/basic-data/index.js @@ -1,7 +1,6 @@ import ngModule from '../../module'; import Section from 'salix/components/section'; - ngModule.vnComponent('vnWorkerDepartmentBasicData', { template: require('./index.html'), controller: Section, diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html index 3ef8f1887..ec8aebdbe 100644 --- a/modules/worker/front/department/descriptor/index.html +++ b/modules/worker/front/department/descriptor/index.html @@ -33,7 +33,7 @@
+ icon="icon-worker">
diff --git a/modules/worker/front/department/main/index.html b/modules/worker/front/department/main/index.html index a1caef294..a272490ad 100644 --- a/modules/worker/front/department/main/index.html +++ b/modules/worker/front/department/main/index.html @@ -4,6 +4,14 @@ limit="20" order="id"> + + + + diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html index a6f06ade4..27654bd49 100644 --- a/modules/worker/front/department/summary/index.html +++ b/modules/worker/front/department/summary/index.html @@ -1,3 +1,11 @@ + + + +
{{summary.name}} @@ -34,34 +42,40 @@ + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - Date: Fri, 30 Jun 2023 13:52:46 +0200 Subject: [PATCH 70/80] refs #5334 basicData solve e2e --- e2e/helpers/selectors.js | 12 +- .../01-department/01_summary.spec.js | 3 +- loopback/locale/en.json | 7 +- .../front/department/basic-data/index.html | 51 +++++---- .../worker/front/department/index/index.html | 1 + .../front/department/summary/index.html | 103 +++++++++--------- .../front/department/summary/locale/es.yml | 1 + 7 files changed, 89 insertions(+), 89 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 6d10426a9..f45f60236 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -899,12 +899,12 @@ export default { }, departmentSummary: { header: 'vn-worker-department-summary h5', - name: 'vn-worker-department-summary vn-horizontal > vn-one > vn-label-value:nth-child(3) > section > span', - code: 'vn-worker-department-summary vn-horizontal > vn-one > vn-label-value:nth-child(4) > section > span', - chat: 'vn-worker-department-summary vn-horizontal > vn-one > vn-label-value:nth-child(5) > section > span', - bossDepartment: 'vn-worker-department-summary vn-horizontal > vn-one > vn-label-value:nth-child(6) > section > span', - email: 'vn-worker-department-summary vn-horizontal > vn-one > vn-label-value:nth-child(7) > section > span', - clientFk: 'vn-worker-department-summary vn-horizontal > vn-one > vn-label-value:nth-child(8) > section > span', + name: 'vn-worker-department-summary vn-horizontal > vn-vertical > vn-label-value:nth-child(1) > section > span', + code: 'vn-worker-department-summary vn-horizontal > vn-vertical > vn-label-value:nth-child(2) > section > span', + chat: 'vn-worker-department-summary vn-horizontal > vn-vertical > vn-label-value:nth-child(3) > section > span', + bossDepartment: 'vn-worker-department-summary vn-horizontal > vn-vertical > vn-label-value:nth-child(4) > section > span', + email: 'vn-worker-department-summary vn-horizontal > vn-vertical > vn-label-value:nth-child(5) > section > span', + clientFk: 'vn-worker-department-summary vn-horizontal > vn-vertical > vn-label-value:nth-child(6) > section > span', }, workerBasicData: { name: 'vn-worker-basic-data vn-textfield[ng-model="$ctrl.worker.firstName"]', diff --git a/e2e/paths/03-worker/01-department/01_summary.spec.js b/e2e/paths/03-worker/01-department/01_summary.spec.js index 094a184dd..de5b762e6 100644 --- a/e2e/paths/03-worker/01-department/01_summary.spec.js +++ b/e2e/paths/03-worker/01-department/01_summary.spec.js @@ -7,7 +7,7 @@ describe('department summary path', () => { beforeAll(async() => { browser = await getBrowser(); page = browser.page; - await page.loginAndModule('hr','worker'); + await page.loginAndModule('hr', 'worker'); await page.accessToSection('worker.department'); await page.doSearch('INFORMATICA'); await page.click(selectors.department.firstDepartment); @@ -18,7 +18,6 @@ describe('department summary path', () => { }); it('should reach the employee summary section and check all properties', async() => { - expect(await page.waitToGetProperty(selectors.departmentSummary.header, 'innerText')).toEqual('INFORMATICA'); expect(await page.getProperty(selectors.departmentSummary.name, 'innerText')).toEqual('INFORMATICA'); expect(await page.getProperty(selectors.departmentSummary.code, 'innerText')).toEqual('IT'); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 40df9a712..09069bc5e 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -175,6 +175,7 @@ "Pass expired": "The password has expired, change it from Salix", "Can't transfer claimed sales": "Can't transfer claimed sales", "Invalid quantity": "Invalid quantity", - "Failed to upload delivery note": "Error to upload delivery note {{id}}", - "Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address" -} + "Failed to upload delivery note": "Error to upload delivery note {{id}}", + "Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address", + "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 3": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 3" +} \ No newline at end of file diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html index 8a8206d6d..ad3dedcb3 100644 --- a/modules/worker/front/department/basic-data/index.html +++ b/modules/worker/front/department/basic-data/index.html @@ -63,32 +63,31 @@ label="Self-consumption customer"> - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/modules/worker/front/department/index/index.html b/modules/worker/front/department/index/index.html index 44a4363df..de77e40a1 100644 --- a/modules/worker/front/department/index/index.html +++ b/modules/worker/front/department/index/index.html @@ -22,6 +22,7 @@ on-drag-start="$ctrl.onDragStart(item)" on-drag-end="$ctrl.onDragEnd(item)"> {{::item.name}} diff --git a/modules/worker/front/department/summary/index.html b/modules/worker/front/department/summary/index.html index 27654bd49..9079b435a 100644 --- a/modules/worker/front/department/summary/index.html +++ b/modules/worker/front/department/summary/index.html @@ -23,58 +23,57 @@ ng-show="!$ctrl.isHr"> Basic data
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/modules/worker/front/department/summary/locale/es.yml b/modules/worker/front/department/summary/locale/es.yml index c5cd53626..31073aae8 100644 --- a/modules/worker/front/department/summary/locale/es.yml +++ b/modules/worker/front/department/summary/locale/es.yml @@ -9,3 +9,4 @@ Notify on errors: Notificar errores worksInProduction: Pertenece a producción Fill in days without physical check-ins: Completar días sin registros físicos Send check-ins by email: Enviar fichadas por mail +Are you sure you want to delete this department?: ¿Estás seguro de que quieres eliminar este departamento? From dc10c20fe3c93bef28e72023e48e79c044ee1e77 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 3 Jul 2023 07:29:58 +0200 Subject: [PATCH 71/80] refs #5334 email validate --- modules/worker/back/models/department.js | 7 ------- .../worker/front/department/basic-data/index.html | 14 +++++--------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/modules/worker/back/models/department.js b/modules/worker/back/models/department.js index ff88a34d0..5a927fc64 100644 --- a/modules/worker/back/models/department.js +++ b/modules/worker/back/models/department.js @@ -1,11 +1,4 @@ module.exports = Self => { - Self.validatesFormatOf('Email', { - message: 'Invalid email', - allowNull: true, - allowBlank: true, - with: /^[\W]*([\w+\-.%]+@[\w\-.]+\.[A-Za-z]{1,61}[\W]*,{1}[\W]*)*([\w+\-.%]+@[\w\-.]+\.[A-Za-z]{1,61})[\W]*$/ - }); - require('../methods/department/getLeaves')(Self); require('../methods/department/createChild')(Self); require('../methods/department/removeChild')(Self); diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html index ad3dedcb3..bb27ae080 100644 --- a/modules/worker/front/department/basic-data/index.html +++ b/modules/worker/front/department/basic-data/index.html @@ -20,15 +20,13 @@ vn-one label="Name" ng-model="$ctrl.department.name" - vn-name="Name" - rule> + vn-name="Name"> + vn-name="Code"> @@ -36,15 +34,13 @@ vn-one label="Chat" ng-model="$ctrl.department.chatName" - vn-name="Chat" - rule> + vn-name="Chat"> - + vn-name="Email"> From 5e683633126db46f06ab2eca83cd05c59672a0e7 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 3 Jul 2023 09:38:36 +0200 Subject: [PATCH 72/80] refs #5334 onsearch postlink --- modules/worker/front/department/index/index.js | 4 ++++ modules/worker/front/department/main/index.html | 8 -------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/worker/front/department/index/index.js b/modules/worker/front/department/index/index.js index 6d015768d..118e189e2 100644 --- a/modules/worker/front/department/index/index.js +++ b/modules/worker/front/department/index/index.js @@ -4,6 +4,10 @@ import Section from 'salix/components/section'; class Controller extends Section { $postLink() { this.$.treeview.fetch(); + if (this.$params.q) { + const search = JSON.parse(this.$params.q); + this.onSearch(search); + } } onSearch(params) { diff --git a/modules/worker/front/department/main/index.html b/modules/worker/front/department/main/index.html index a272490ad..a1caef294 100644 --- a/modules/worker/front/department/main/index.html +++ b/modules/worker/front/department/main/index.html @@ -4,14 +4,6 @@ limit="20" order="id"> - - - - From 983d028d06489032051c82eca04dca43f0c27a73 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 3 Jul 2023 13:58:40 +0200 Subject: [PATCH 73/80] refs #5334 popover y basic data --- modules/worker/front/department/basic-data/index.html | 5 +++-- modules/worker/front/department/descriptor/index.html | 2 +- modules/worker/front/department/summary/index.html | 11 +++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/worker/front/department/basic-data/index.html b/modules/worker/front/department/basic-data/index.html index bb27ae080..2d1e315d4 100644 --- a/modules/worker/front/department/basic-data/index.html +++ b/modules/worker/front/department/basic-data/index.html @@ -78,11 +78,12 @@ label="Fill in days without physical check-ins" ng-model="$ctrl.department.hasToRefill"> - + + - + diff --git a/modules/worker/front/department/descriptor/index.html b/modules/worker/front/department/descriptor/index.html index ec8aebdbe..d9f62353d 100644 --- a/modules/worker/front/department/descriptor/index.html +++ b/modules/worker/front/department/descriptor/index.html @@ -26,7 +26,7 @@ + value="{{$ctrl.department.worker.firstName}}">