From b45b0ff8260ee221da6902cd7cff4e557fd33533 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 20 Apr 2023 08:23:46 +0200 Subject: [PATCH 01/91] refs #5066 copy project from the other --- db/changes/231601/00-ACLgetVehiclesSorted.sql | 3 ++ .../back/methods/vehicle/getVehiclesSorted.js | 28 +++++++++++++++++++ modules/route/back/models/vehicle.js | 3 ++ modules/route/front/basic-data/index.html | 5 +++- modules/route/front/basic-data/index.js | 13 +++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 db/changes/231601/00-ACLgetVehiclesSorted.sql create mode 100644 modules/route/back/methods/vehicle/getVehiclesSorted.js create mode 100644 modules/route/back/models/vehicle.js diff --git a/db/changes/231601/00-ACLgetVehiclesSorted.sql b/db/changes/231601/00-ACLgetVehiclesSorted.sql new file mode 100644 index 000000000..5d3ec454d --- /dev/null +++ b/db/changes/231601/00-ACLgetVehiclesSorted.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`) + VALUES + ('Vehicle','getVehiclesSorted','WRITE','ALLOW','employee'); \ No newline at end of file diff --git a/modules/route/back/methods/vehicle/getVehiclesSorted.js b/modules/route/back/methods/vehicle/getVehiclesSorted.js new file mode 100644 index 000000000..b785e5dc8 --- /dev/null +++ b/modules/route/back/methods/vehicle/getVehiclesSorted.js @@ -0,0 +1,28 @@ +module.exports = Self => { + Self.remoteMethod('getVehiclesSorted', { + description: 'Sort the vehicles by a warehouse', + accessType: 'WRITE', + accepts: [{ + arg: 'warehouseFk', + type: 'number' + }], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/getVehiclesSorted`, + verb: `POST` + } + }); + + Self.getVehiclesSorted = async warehouseFk => { + const vehicles = await Self.rawSql(` + SELECT v.id, v.numberPlate, w.name + FROM vehicle v + JOIN warehouse w ON w.id = v.warehouseFk + ORDER BY v.warehouseFk = ? DESC, v.numberPlate ASC`, [warehouseFk]); + + return vehicles; + }; +}; diff --git a/modules/route/back/models/vehicle.js b/modules/route/back/models/vehicle.js new file mode 100644 index 000000000..459afe1c2 --- /dev/null +++ b/modules/route/back/models/vehicle.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/vehicle/getVehiclesSorted')(Self); +}; diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html index 831599ae8..9888a6859 100644 --- a/modules/route/front/basic-data/index.html +++ b/modules/route/front/basic-data/index.html @@ -24,10 +24,13 @@ + + {{numberPlate}} - {{name}} + diff --git a/modules/route/front/basic-data/index.js b/modules/route/front/basic-data/index.js index b8602ed12..80626e97e 100644 --- a/modules/route/front/basic-data/index.js +++ b/modules/route/front/basic-data/index.js @@ -7,6 +7,19 @@ class Controller extends Section { this.card.reload() ); } + constructor($element, $) { + super($element, $); + this.$http.get(`UserConfigs/getUserConfig`) + .then(res => { + if (res && res.data) { + this.$http.post(`Vehicles/getVehiclesSorted`, {warehouseFk: res.data.warehouseFk}) + .then(res => { + if (res && res.data) + this.vehicles = res.data; + }); + } + }); + } } ngModule.vnComponent('vnRouteBasicData', { From 16fdfa00fda86e5fe2cba3f57ec581f36d18152b Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 20 Apr 2023 09:09:48 +0200 Subject: [PATCH 02/91] refs #5066 e2e solve --- e2e/paths/08-route/02_basic_data.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/08-route/02_basic_data.spec.js b/e2e/paths/08-route/02_basic_data.spec.js index ff8361499..6132d5e23 100644 --- a/e2e/paths/08-route/02_basic_data.spec.js +++ b/e2e/paths/08-route/02_basic_data.spec.js @@ -46,7 +46,7 @@ describe('Route basic Data path', () => { it('should confirm the vehicle was edited', async() => { const vehicle = await page.waitToGetProperty(selectors.routeBasicData.vehicle, 'value'); - expect(vehicle).toEqual('1111-IMK'); + expect(vehicle).toEqual('1111-IMK - Warehouse One'); }); it('should confirm the km start was edited', async() => { From 237c83c6f551d7b8d188a0045c9be108eee3b2fa Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 20 Apr 2023 10:20:15 +0200 Subject: [PATCH 03/91] refs #5066 getVehicleSorted small mod --- modules/route/back/methods/vehicle/getVehiclesSorted.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/route/back/methods/vehicle/getVehiclesSorted.js b/modules/route/back/methods/vehicle/getVehiclesSorted.js index b785e5dc8..9dad8b80a 100644 --- a/modules/route/back/methods/vehicle/getVehiclesSorted.js +++ b/modules/route/back/methods/vehicle/getVehiclesSorted.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethod('getVehiclesSorted', { - description: 'Sort the vehicles by a warehouse', + description: 'Sort the vehicles by warehouse', accessType: 'WRITE', accepts: [{ arg: 'warehouseFk', From 91edc09057b9660fada62e4d243fa8836be12820 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 29 May 2023 10:24:37 +0200 Subject: [PATCH 04/91] refs #5066 move sql --- db/changes/232401/00-ACLgetVehiclesSorted.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/changes/232401/00-ACLgetVehiclesSorted.sql diff --git a/db/changes/232401/00-ACLgetVehiclesSorted.sql b/db/changes/232401/00-ACLgetVehiclesSorted.sql new file mode 100644 index 000000000..5d3ec454d --- /dev/null +++ b/db/changes/232401/00-ACLgetVehiclesSorted.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`) + VALUES + ('Vehicle','getVehiclesSorted','WRITE','ALLOW','employee'); \ No newline at end of file From d8e7c2700a110bde087ae5bee817fe6fc997acfb Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 29 May 2023 12:42:27 +0200 Subject: [PATCH 05/91] refs #5066 fix autocomplete --- e2e/paths/08-route/02_basic_data.spec.js | 2 +- front/core/components/autocomplete/index.js | 14 +++++++++++++- .../back/methods/vehicle/getVehiclesSorted.js | 10 ++++++---- modules/route/front/basic-data/index.html | 8 +++----- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/e2e/paths/08-route/02_basic_data.spec.js b/e2e/paths/08-route/02_basic_data.spec.js index 6008b0482..7ab7dda42 100644 --- a/e2e/paths/08-route/02_basic_data.spec.js +++ b/e2e/paths/08-route/02_basic_data.spec.js @@ -24,7 +24,7 @@ describe('Route basic Data path', () => { const form = 'vn-route-basic-data form'; const values = { worker: 'adminBossNick', - vehicle: '1111-IMK - Warehouse One', + vehicle: '1111-IMK', created: nextMonth, kmStart: 1, kmEnd: 2, diff --git a/front/core/components/autocomplete/index.js b/front/core/components/autocomplete/index.js index 2539c4ef4..52491f7e0 100755 --- a/front/core/components/autocomplete/index.js +++ b/front/core/components/autocomplete/index.js @@ -174,6 +174,7 @@ export default class Autocomplete extends Field { refreshDisplayed() { let display = ''; + let hasTemplate = this.$transclude && this.$transclude.isSlotFilled('tplItem'); if (this._selection && this.showField) { if (this.multiple && Array.isArray(this._selection)) { @@ -181,8 +182,19 @@ export default class Autocomplete extends Field { if (display.length > 0) display += ', '; display += item[this.showField]; } - } else + } else { display = this._selection[this.showField]; + if (hasTemplate) { + let template = this.$transclude(() => {}, null, 'tplItem'); + const element = template[0]; + const description = element.querySelector('.text-secondary'); + if (description) description.remove(); + + const displayElement = angular.element(element); + const displayText = displayElement.text(); + display = this.$interpolate(displayText)(this._selection); + } + } } this.input.value = display; diff --git a/modules/route/back/methods/vehicle/getVehiclesSorted.js b/modules/route/back/methods/vehicle/getVehiclesSorted.js index 9dad8b80a..384d89391 100644 --- a/modules/route/back/methods/vehicle/getVehiclesSorted.js +++ b/modules/route/back/methods/vehicle/getVehiclesSorted.js @@ -18,11 +18,13 @@ module.exports = Self => { Self.getVehiclesSorted = async warehouseFk => { const vehicles = await Self.rawSql(` - SELECT v.id, v.numberPlate, w.name + SELECT ROW_NUMBER() OVER (ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate) AS 'order', + v.id, + v.warehouseFk, + CONCAT(v.numberPlate, ' - ', w.name) as description FROM vehicle v - JOIN warehouse w ON w.id = v.warehouseFk - ORDER BY v.warehouseFk = ? DESC, v.numberPlate ASC`, [warehouseFk]); - + JOIN warehouse w ON w.id = v.warehouseFk + ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC`, [warehouseFk, warehouseFk]); return vehicles; }; }; diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html index 0f62dc107..1ba84583f 100644 --- a/modules/route/front/basic-data/index.html +++ b/modules/route/front/basic-data/index.html @@ -25,19 +25,17 @@ - - {{numberPlate}} - {{name}} - + vn-name="created"> Date: Mon, 29 May 2023 13:49:32 +0200 Subject: [PATCH 06/91] refs #5066 e2e fixs, change name sorted --- db/changes/232401/00-ACLgetVehiclesSorted.sql | 2 +- e2e/paths/08-route/02_basic_data.spec.js | 2 +- front/core/components/autocomplete/index.js | 14 +------------- .../vehicle/{getVehiclesSorted.js => sorted.js} | 6 +++--- modules/route/back/models/vehicle.js | 2 +- modules/route/front/basic-data/index.html | 3 ++- modules/route/front/basic-data/index.js | 2 +- 7 files changed, 10 insertions(+), 21 deletions(-) rename modules/route/back/methods/vehicle/{getVehiclesSorted.js => sorted.js} (85%) diff --git a/db/changes/232401/00-ACLgetVehiclesSorted.sql b/db/changes/232401/00-ACLgetVehiclesSorted.sql index 5d3ec454d..6625f0d5c 100644 --- a/db/changes/232401/00-ACLgetVehiclesSorted.sql +++ b/db/changes/232401/00-ACLgetVehiclesSorted.sql @@ -1,3 +1,3 @@ INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`) VALUES - ('Vehicle','getVehiclesSorted','WRITE','ALLOW','employee'); \ No newline at end of file + ('Vehicle','sorted','WRITE','ALLOW','employee'); \ No newline at end of file diff --git a/e2e/paths/08-route/02_basic_data.spec.js b/e2e/paths/08-route/02_basic_data.spec.js index 7ab7dda42..6008b0482 100644 --- a/e2e/paths/08-route/02_basic_data.spec.js +++ b/e2e/paths/08-route/02_basic_data.spec.js @@ -24,7 +24,7 @@ describe('Route basic Data path', () => { const form = 'vn-route-basic-data form'; const values = { worker: 'adminBossNick', - vehicle: '1111-IMK', + vehicle: '1111-IMK - Warehouse One', created: nextMonth, kmStart: 1, kmEnd: 2, diff --git a/front/core/components/autocomplete/index.js b/front/core/components/autocomplete/index.js index 52491f7e0..2539c4ef4 100755 --- a/front/core/components/autocomplete/index.js +++ b/front/core/components/autocomplete/index.js @@ -174,7 +174,6 @@ export default class Autocomplete extends Field { refreshDisplayed() { let display = ''; - let hasTemplate = this.$transclude && this.$transclude.isSlotFilled('tplItem'); if (this._selection && this.showField) { if (this.multiple && Array.isArray(this._selection)) { @@ -182,19 +181,8 @@ export default class Autocomplete extends Field { if (display.length > 0) display += ', '; display += item[this.showField]; } - } else { + } else display = this._selection[this.showField]; - if (hasTemplate) { - let template = this.$transclude(() => {}, null, 'tplItem'); - const element = template[0]; - const description = element.querySelector('.text-secondary'); - if (description) description.remove(); - - const displayElement = angular.element(element); - const displayText = displayElement.text(); - display = this.$interpolate(displayText)(this._selection); - } - } } this.input.value = display; diff --git a/modules/route/back/methods/vehicle/getVehiclesSorted.js b/modules/route/back/methods/vehicle/sorted.js similarity index 85% rename from modules/route/back/methods/vehicle/getVehiclesSorted.js rename to modules/route/back/methods/vehicle/sorted.js index 384d89391..4231b77cb 100644 --- a/modules/route/back/methods/vehicle/getVehiclesSorted.js +++ b/modules/route/back/methods/vehicle/sorted.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('getVehiclesSorted', { + Self.remoteMethod('sorted', { description: 'Sort the vehicles by warehouse', accessType: 'WRITE', accepts: [{ @@ -11,12 +11,12 @@ module.exports = Self => { root: true }, http: { - path: `/getVehiclesSorted`, + path: `/sorted`, verb: `POST` } }); - Self.getVehiclesSorted = async warehouseFk => { + Self.sorted = async warehouseFk => { const vehicles = await Self.rawSql(` SELECT ROW_NUMBER() OVER (ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate) AS 'order', v.id, diff --git a/modules/route/back/models/vehicle.js b/modules/route/back/models/vehicle.js index 459afe1c2..73e321443 100644 --- a/modules/route/back/models/vehicle.js +++ b/modules/route/back/models/vehicle.js @@ -1,3 +1,3 @@ module.exports = Self => { - require('../methods/vehicle/getVehiclesSorted')(Self); + require('../methods/vehicle/sorted')(Self); }; diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html index 1ba84583f..1d6e260a9 100644 --- a/modules/route/front/basic-data/index.html +++ b/modules/route/front/basic-data/index.html @@ -28,7 +28,8 @@ show-field="description" order="order" value-field="id" - label="Vehicle"> + label="Vehicle" + vn-name="vehicle"> diff --git a/modules/route/front/basic-data/index.js b/modules/route/front/basic-data/index.js index 80626e97e..a147a451c 100644 --- a/modules/route/front/basic-data/index.js +++ b/modules/route/front/basic-data/index.js @@ -12,7 +12,7 @@ class Controller extends Section { this.$http.get(`UserConfigs/getUserConfig`) .then(res => { if (res && res.data) { - this.$http.post(`Vehicles/getVehiclesSorted`, {warehouseFk: res.data.warehouseFk}) + this.$http.post(`Vehicles/sorted`, {warehouseFk: res.data.warehouseFk}) .then(res => { if (res && res.data) this.vehicles = res.data; From b60cd2539a205433a24e41d38ae19d0ca81922e3 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 29 May 2023 15:21:37 +0200 Subject: [PATCH 07/91] refs #5712 feat(workerDms): docuware integration --- back/methods/docuware/checkFile.js | 50 ++++---- back/methods/docuware/core.js | 113 ++++++++++++++---- back/methods/docuware/download.js | 4 +- db/changes/232401/00-workerDocuware.sql | 3 + .../back/methods/worker-dms/docuware.js | 46 +++++++ .../worker/back/methods/worker-dms/filter.js | 39 +++++- modules/worker/back/models/worker-dms.js | 1 + modules/worker/front/dms/index/index.html | 12 +- modules/worker/front/dms/index/index.js | 3 +- 9 files changed, 219 insertions(+), 52 deletions(-) create mode 100644 db/changes/232401/00-workerDocuware.sql create mode 100644 modules/worker/back/methods/worker-dms/docuware.js diff --git a/back/methods/docuware/checkFile.js b/back/methods/docuware/checkFile.js index c0a4e8ef3..447efa760 100644 --- a/back/methods/docuware/checkFile.js +++ b/back/methods/docuware/checkFile.js @@ -1,7 +1,7 @@ const axios = require('axios'); module.exports = Self => { - Self.remoteMethodCtx('checkFile', { + Self.remoteMethod('checkFile', { description: 'Check if exist docuware file', accessType: 'READ', accepts: [ @@ -20,8 +20,14 @@ module.exports = Self => { { arg: 'signed', type: 'boolean', - required: true, + required: false, description: 'If pdf is necessary to be signed' + }, + { + arg: 'filter', + type: 'object', + required: false, + description: 'The filter' } ], returns: { @@ -34,7 +40,7 @@ module.exports = Self => { } }); - Self.checkFile = async function(ctx, id, fileCabinet, signed) { + Self.checkFile = async function(id, fileCabinet, signed, filter) { const models = Self.app.models; const action = 'find'; @@ -44,35 +50,39 @@ module.exports = Self => { action: action } }); - - const searchFilter = { - condition: [ - { - DBName: docuwareInfo.findById, - - Value: [id] - } - ], - sortOrder: [ - { - Field: 'FILENAME', - Direction: 'Desc' - } - ] - }; + console.log(id, fileCabinet, signed, filter); + if (!filter) { + filter = { + condition: [ + { + DBName: docuwareInfo.findById, + Value: [id] + } + ], + sortOrder: [ + { + Field: 'FILENAME', + Direction: 'Desc' + } + ] + }; + } try { const options = await Self.getOptions(); const fileCabinetId = await Self.getFileCabinet(fileCabinet); const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId); + console.log('FILTER', filter); const response = await axios.post( `${options.url}/FileCabinets/${fileCabinetId}/Query/DialogExpression?dialogId=${dialogId}`, - searchFilter, + filter, options.headers ); const [documents] = response.data.Items; + console.log(response); + console.log(response.data); if (!documents) return false; const state = documents.Fields.find(field => field.FieldName == 'ESTADO'); diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 2053ddf85..ac04c1958 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -1,6 +1,28 @@ const axios = require('axios'); module.exports = Self => { + /** + * Returns basic headers + * + * @param {string} cookie - The docuware cookie + * @return {object} - The headers + */ + Self.getOptions = async() => { + const docuwareConfig = await Self.app.models.DocuwareConfig.findOne(); + const headers = { + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Cookie': docuwareConfig.cookie + } + }; + + return { + url: docuwareConfig.url, + headers + }; + }; + /** * Returns the dialog id * @@ -20,9 +42,6 @@ module.exports = Self => { const options = await Self.getOptions(); - if (!process.env.NODE_ENV) - return Math.round(); - const response = await axios.get(`${options.url}/FileCabinets/${fileCabinetId}/dialogs`, options.headers); const dialogs = response.data.Dialog; const dialogId = dialogs.find(dialogs => dialogs.DisplayName === docuwareInfo.dialogName).Id; @@ -44,9 +63,6 @@ module.exports = Self => { } }); - if (!process.env.NODE_ENV) - return Math.round(); - const fileCabinetResponse = await axios.get(`${options.url}/FileCabinets`, options.headers); const fileCabinets = fileCabinetResponse.data.FileCabinet; const fileCabinetId = fileCabinets.find(fileCabinet => fileCabinet.Name === docuwareInfo.fileCabinetName).Id; @@ -55,24 +71,81 @@ module.exports = Self => { }; /** - * Returns basic headers + * Returns docuware data * - * @param {string} cookie - The docuware cookie - * @return {object} - The headers + * @param {string} code - The fileCabinet code + * @param {object} filter - The filter for docuware + * @param {object} parse - The fields parsed + * @return {object} - The data */ - Self.getOptions = async() => { - const docuwareConfig = await Self.app.models.DocuwareConfig.findOne(); - const headers = { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Cookie': docuwareConfig.cookie + Self.get = async(code, filter, parse) => { + const options = await Self.getOptions(); + const fileCabinetId = await Self.getFileCabinet(code); + const dialogId = await Self.getDialog(code, 'find', fileCabinetId); + + const {data} = await axios.post( + `${options.url}/FileCabinets/${fileCabinetId}/Query/DialogExpression?dialogId=${dialogId}`, + filter, + options.headers + ); + + return parser(data, parse); + }; + + /** + * Returns docuware data + * + * @param {string} code - The fileCabinet code + * @param {any} id - The id of docuware + * @param {object} parse - The fields parsed + * @return {object} - The data + */ + Self.getById = async(code, id, parse) => { + const docuwareInfo = await Self.app.models.Docuware.findOne({ + fields: ['findById'], + where: { + code: code, + action: 'find' } + }); + const filter = { + condition: [ + { + DBName: docuwareInfo.findById, + Value: [id] + } + ] }; - return { - url: docuwareConfig.url, - headers - }; + return Self.get(code, filter, parse); }; + + /** + * Returns docuware data filtered + * + * @param {array} data - The data + * @param {object} parse - The fields parsed + * @return {object} - The data parsed + */ + function parser(data, parse) { + if (!(data && data.Items)) return data; + + const parsed = []; + for (item of data.Items) { + const itemParsed = {}; + item.Fields.map(field => { + if (field.ItemElementName.includes('Date')) field.Item = toDate(field.Item); + if (!parse) return itemParsed[field.FieldLabel] = field.Item; + if (parse[field.FieldLabel]) + itemParsed[parse[field.FieldLabel]] = field.Item; + }); + parsed.push(itemParsed); + } + return parsed; + } + + function toDate(value) { + if (!value) return; + return new Date(Number(value.substring(6, 19))); + } }; diff --git a/back/methods/docuware/download.js b/back/methods/docuware/download.js index 56d006ee7..b9c646adb 100644 --- a/back/methods/docuware/download.js +++ b/back/methods/docuware/download.js @@ -41,8 +41,10 @@ module.exports = Self => { } }); - Self.download = async function(ctx, id, fileCabinet) { + Self.download = async function(ctx, id, fileCabinet, filter) { const models = Self.app.models; + + // REVIEW const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, true); if (!docuwareFile) throw new UserError('The DOCUWARE PDF document does not exists'); diff --git a/db/changes/232401/00-workerDocuware.sql b/db/changes/232401/00-workerDocuware.sql new file mode 100644 index 000000000..45d64bd78 --- /dev/null +++ b/db/changes/232401/00-workerDocuware.sql @@ -0,0 +1,3 @@ +INSERT INTO `vn`.`docuware` +(code, fileCabinetName, `action`, dialogName, findById) +VALUES('hr', 'RRHH', 'find', 'Búsqueda', 'N__DOCUMENTO'); diff --git a/modules/worker/back/methods/worker-dms/docuware.js b/modules/worker/back/methods/worker-dms/docuware.js new file mode 100644 index 000000000..ff5902e8f --- /dev/null +++ b/modules/worker/back/methods/worker-dms/docuware.js @@ -0,0 +1,46 @@ +module.exports = Self => { + Self.remoteMethodCtx('docuwareDownload', { + description: 'Download a worker document', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'Number', + description: 'The document id', + http: {source: 'path'} + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: `/:id/docuwareDownload`, + verb: 'GET' + } + }); + + Self.docuwareDownload = async function(ctx, id) { + // CHECK ROLE? + const filter = { + condition: [ + { + DBName: 'FILENAME', + Value: [id] + } + ] + }; + return await Self.app.models.Docuware.download(ctx, id, 'hr', false, filter); + }; +}; diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index c16b2bbb1..7de838311 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -5,6 +5,12 @@ module.exports = Self => { description: 'Find all instances of the model matched by filter from the data source.', accessType: 'READ', accepts: [ + { + arg: 'id', + type: 'Number', + description: 'The worker id', + http: {source: 'path'} + }, { arg: 'filter', type: 'Object', @@ -17,16 +23,17 @@ module.exports = Self => { root: true }, http: { - path: `/filter`, + path: `/:id/filter`, verb: 'GET' } }); - Self.filter = async(ctx, filter) => { + Self.filter = async(ctx, id, filter) => { const conn = Self.dataSource.connector; const userId = ctx.req.accessToken.userId; + const models = Self.app.models; - const account = await Self.app.models.VnUser.findById(userId); + const account = await models.VnUser.findById(userId); const stmt = new ParameterizedSQL( `SELECT d.id dmsFk, d.reference, d.description, d.file, d.created, d.hardCopyNumber, d.hasFile FROM workerDocument wd @@ -47,7 +54,31 @@ module.exports = Self => { }] }, oldWhere]}; stmt.merge(conn.makeSuffix(filter)); + const workerDms = await conn.executeStmt(stmt); - return await conn.executeStmt(stmt); + // Get docuware info + const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); + const docuwareParse = { + 'Document ID': 'dmsFk', + 'Tipo Documento': 'description', + 'Stored on': 'created', + }; + const workerDocuware = await models.Docuware.getById('hr', 'BONO MOLA XAVIER', docuwareParse);// worker.lastName + worker.firstName); + + for (document of workerDocuware) { + const defaultData = { + file: document.dmsFk + '.png', + isDocuware: true, + hardCopyNumber: null, + hasFile: false, + reference: worker.fi + }; + + document = Object.assign(document, defaultData); + } + console.log(workerDocuware); + console.log(workerDms); + + return workerDms.concat(workerDocuware); }; }; diff --git a/modules/worker/back/models/worker-dms.js b/modules/worker/back/models/worker-dms.js index b9d6f9a77..1712383b3 100644 --- a/modules/worker/back/models/worker-dms.js +++ b/modules/worker/back/models/worker-dms.js @@ -2,6 +2,7 @@ module.exports = Self => { require('../methods/worker-dms/downloadFile')(Self); require('../methods/worker-dms/removeFile')(Self); require('../methods/worker-dms/filter')(Self); + require('../methods/worker-dms/docuware')(Self); Self.isMine = async function(ctx, dmsId) { const myUserId = ctx.req.accessToken.userId; diff --git a/modules/worker/front/dms/index/index.html b/modules/worker/front/dms/index/index.html index 1404336a2..6ed3a6f15 100644 --- a/modules/worker/front/dms/index/index.html +++ b/modules/worker/front/dms/index/index.html @@ -1,6 +1,6 @@ - + ng-click="$ctrl.downloadFile(document.dmsFk, document.isDocuware)"> {{::document.file}} @@ -63,7 +63,7 @@ + ng-click="$ctrl.downloadFile(document.dmsFk, document.isDocuware)"> @@ -91,9 +91,9 @@ fixed-bottom-right> - - \ No newline at end of file + diff --git a/modules/worker/front/dms/index/index.js b/modules/worker/front/dms/index/index.js index 9bb3c896a..ae2d51a17 100644 --- a/modules/worker/front/dms/index/index.js +++ b/modules/worker/front/dms/index/index.js @@ -17,7 +17,8 @@ class Controller extends Component { }); } - downloadFile(dmsId) { + downloadFile(dmsId, isDocuware) { + if (isDocuware) return this.vnFile.download(`api/workerDms/${dmsId}/docuwareDownload`); this.vnFile.download(`api/workerDms/${dmsId}/downloadFile`); } } From 0661bf8fa98cead2a07a4ee16b499520e771be0c Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 May 2023 12:21:44 +0200 Subject: [PATCH 08/91] refs #5066 remake sql without ROW_ORDER --- modules/route/back/methods/vehicle/sorted.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/route/back/methods/vehicle/sorted.js b/modules/route/back/methods/vehicle/sorted.js index 4231b77cb..5c4c305cc 100644 --- a/modules/route/back/methods/vehicle/sorted.js +++ b/modules/route/back/methods/vehicle/sorted.js @@ -17,14 +17,11 @@ module.exports = Self => { }); Self.sorted = async warehouseFk => { - const vehicles = await Self.rawSql(` - SELECT ROW_NUMBER() OVER (ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate) AS 'order', - v.id, - v.warehouseFk, - CONCAT(v.numberPlate, ' - ', w.name) as description - FROM vehicle v - JOIN warehouse w ON w.id = v.warehouseFk - ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC`, [warehouseFk, warehouseFk]); - return vehicles; + return Self.rawSql(` + SELECT v.id, v.warehouseFk, CONCAT(v.numberPlate, ' - ', w.name) as description + FROM vehicle v + JOIN warehouse w ON w.id = v.warehouseFk + ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC; + `, [warehouseFk]); }; }; From c23d8282ebf9433d69e75ad45c12323128349f9f Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 30 May 2023 15:34:11 +0200 Subject: [PATCH 09/91] refs #5712 feat(workerDms): docuware download --- back/methods/docuware/checkFile.js | 31 +++++------ back/methods/docuware/core.js | 6 +- back/methods/docuware/download.js | 17 +++--- back/methods/docuware/upload.js | 5 -- db/changes/232401/00-workerDocuware.sql | 6 +- .../back/methods/ticket/docuwareDownload.js | 55 +++++++++++++++++++ .../ticket/front/descriptor-menu/index.html | 7 +-- modules/ticket/front/descriptor-menu/index.js | 4 ++ .../back/methods/worker-dms/docuware.js | 3 +- .../worker/back/methods/worker-dms/filter.js | 3 +- modules/worker/front/dms/index/index.html | 20 +++++-- 11 files changed, 111 insertions(+), 46 deletions(-) create mode 100644 modules/ticket/back/methods/ticket/docuwareDownload.js diff --git a/back/methods/docuware/checkFile.js b/back/methods/docuware/checkFile.js index 447efa760..803755d09 100644 --- a/back/methods/docuware/checkFile.js +++ b/back/methods/docuware/checkFile.js @@ -17,18 +17,16 @@ module.exports = Self => { required: true, description: 'The fileCabinet name' }, - { - arg: 'signed', - type: 'boolean', - required: false, - description: 'If pdf is necessary to be signed' - }, { arg: 'filter', type: 'object', - required: false, description: 'The filter' - } + }, + { + arg: 'signed', + type: 'boolean', + description: 'If pdf is necessary to be signed' + }, ], returns: { type: 'object', @@ -40,7 +38,7 @@ module.exports = Self => { } }); - Self.checkFile = async function(id, fileCabinet, signed, filter) { + Self.checkFile = async function(id, fileCabinet, filter, signed) { const models = Self.app.models; const action = 'find'; @@ -50,7 +48,8 @@ module.exports = Self => { action: action } }); - console.log(id, fileCabinet, signed, filter); + console.log('ENTRY'); + console.log(filter, signed); if (!filter) { filter = { condition: [ @@ -67,13 +66,18 @@ module.exports = Self => { ] }; } + if (signed) { + filter.condition.push({ + DBName: 'ESTADO', + Value: ['Firmado'] + }); + } try { const options = await Self.getOptions(); const fileCabinetId = await Self.getFileCabinet(fileCabinet); const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId); - console.log('FILTER', filter); const response = await axios.post( `${options.url}/FileCabinets/${fileCabinetId}/Query/DialogExpression?dialogId=${dialogId}`, @@ -81,13 +85,8 @@ module.exports = Self => { options.headers ); const [documents] = response.data.Items; - console.log(response); - console.log(response.data); if (!documents) return false; - const state = documents.Fields.find(field => field.FieldName == 'ESTADO'); - if (signed && state.Item != 'Firmado') return false; - return {id: documents.Id}; } catch (error) { return false; diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index ac04c1958..f13b69b13 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -83,13 +83,13 @@ module.exports = Self => { const fileCabinetId = await Self.getFileCabinet(code); const dialogId = await Self.getDialog(code, 'find', fileCabinetId); - const {data} = await axios.post( + const data = await axios.post( `${options.url}/FileCabinets/${fileCabinetId}/Query/DialogExpression?dialogId=${dialogId}`, filter, options.headers ); - - return parser(data, parse); + console.log(data.data); + return parser(data.data, parse); }; /** diff --git a/back/methods/docuware/download.js b/back/methods/docuware/download.js index b9c646adb..a0d72ce01 100644 --- a/back/methods/docuware/download.js +++ b/back/methods/docuware/download.js @@ -3,7 +3,7 @@ const axios = require('axios'); const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethodCtx('download', { + Self.remoteMethod('download', { description: 'Download an docuware PDF', accessType: 'READ', accepts: [ @@ -16,8 +16,12 @@ module.exports = Self => { { arg: 'fileCabinet', type: 'string', - description: 'The file cabinet', - http: {source: 'path'} + description: 'The file cabinet' + }, + { + arg: 'filter', + type: 'object', + description: 'The filter' } ], returns: [ @@ -36,16 +40,15 @@ module.exports = Self => { } ], http: { - path: `/:id/download/:fileCabinet`, + path: `/:id/download`, verb: 'GET' } }); - Self.download = async function(ctx, id, fileCabinet, filter) { + Self.download = async function(id, fileCabinet, filter) { const models = Self.app.models; - // REVIEW - const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, true); + const docuwareFile = await models.Docuware.checkFile(id, fileCabinet, filter); if (!docuwareFile) throw new UserError('The DOCUWARE PDF document does not exists'); const fileCabinetId = await Self.getFileCabinet(fileCabinet); diff --git a/back/methods/docuware/upload.js b/back/methods/docuware/upload.js index ea9ee3622..9dd1f2103 100644 --- a/back/methods/docuware/upload.js +++ b/back/methods/docuware/upload.js @@ -16,11 +16,6 @@ module.exports = Self => { arg: 'fileCabinet', type: 'string', description: 'The file cabinet' - }, - { - arg: 'dialog', - type: 'string', - description: 'The dialog' } ], returns: [], diff --git a/db/changes/232401/00-workerDocuware.sql b/db/changes/232401/00-workerDocuware.sql index 45d64bd78..fbacb23f9 100644 --- a/db/changes/232401/00-workerDocuware.sql +++ b/db/changes/232401/00-workerDocuware.sql @@ -1,3 +1,3 @@ -INSERT INTO `vn`.`docuware` -(code, fileCabinetName, `action`, dialogName, findById) -VALUES('hr', 'RRHH', 'find', 'Búsqueda', 'N__DOCUMENTO'); +INSERT INTO `vn`.`docuware` (code, fileCabinetName, `action`, dialogName, findById) + VALUES + ('hr', 'RRHH', 'find', 'Búsqueda', 'N__DOCUMENTO'); diff --git a/modules/ticket/back/methods/ticket/docuwareDownload.js b/modules/ticket/back/methods/ticket/docuwareDownload.js new file mode 100644 index 000000000..bc74e0d21 --- /dev/null +++ b/modules/ticket/back/methods/ticket/docuwareDownload.js @@ -0,0 +1,55 @@ +module.exports = Self => { + Self.remoteMethodCtx('docuwareDownload', { + description: 'Download a ticket delivery note document', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'Number', + description: 'The document id', + http: {source: 'path'} + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: `/:id/docuwareDownload`, + verb: 'GET' + } + }); + + Self.docuwareDownload = async function(ctx, id) { + const filter = { + condition: [ + { + DBName: docuwareInfo.findById, + Value: [id] + }, + { + DBName: 'ESTADO', + Value: ['Firmado'] + } + ], + sortOrder: [ + { + Field: 'FILENAME', + Direction: 'Desc' + } + ] + }; + return await Self.app.models.Docuware.download(id, 'deliveryNote', filter); + }; +}; diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index c2ebc3e3a..b645005be 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -36,13 +36,12 @@ translate> as PDF without prices - as PDF signed - + diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 987d6a3f1..bcb08c565 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -336,6 +336,10 @@ class Controller extends Section { this.vnApp.showSuccess(this.$t('PDF sent!')); }); } + + docuwareDownload() { + this.vnFile.download(`api/Ticket/${this.ticket.id}/docuwareDownload`); + } } Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; diff --git a/modules/worker/back/methods/worker-dms/docuware.js b/modules/worker/back/methods/worker-dms/docuware.js index ff5902e8f..764b7633c 100644 --- a/modules/worker/back/methods/worker-dms/docuware.js +++ b/modules/worker/back/methods/worker-dms/docuware.js @@ -32,7 +32,6 @@ module.exports = Self => { }); Self.docuwareDownload = async function(ctx, id) { - // CHECK ROLE? const filter = { condition: [ { @@ -41,6 +40,6 @@ module.exports = Self => { } ] }; - return await Self.app.models.Docuware.download(ctx, id, 'hr', false, filter); + return await Self.app.models.Docuware.download(id, 'hr', filter); }; }; diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index 7de838311..eaefe67d3 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -59,12 +59,11 @@ module.exports = Self => { // Get docuware info const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); const docuwareParse = { - 'Document ID': 'dmsFk', + 'Filename': 'dmsFk', 'Tipo Documento': 'description', 'Stored on': 'created', }; const workerDocuware = await models.Docuware.getById('hr', 'BONO MOLA XAVIER', docuwareParse);// worker.lastName + worker.firstName); - for (document of workerDocuware) { const defaultData = { file: document.dmsFk + '.png', diff --git a/modules/worker/front/dms/index/index.html b/modules/worker/front/dms/index/index.html index 6ed3a6f15..9d2d5b25d 100644 --- a/modules/worker/front/dms/index/index.html +++ b/modules/worker/front/dms/index/index.html @@ -60,19 +60,31 @@ {{::document.created | date:'dd/MM/yyyy HH:mm'}} - + - - + + - + + + + + Date: Wed, 31 May 2023 10:04:34 +0200 Subject: [PATCH 10/91] refs #5066 sorted without CONCAT, order=false --- modules/route/back/methods/vehicle/sorted.js | 2 +- modules/route/front/basic-data/index.html | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/route/back/methods/vehicle/sorted.js b/modules/route/back/methods/vehicle/sorted.js index 5c4c305cc..b379743bc 100644 --- a/modules/route/back/methods/vehicle/sorted.js +++ b/modules/route/back/methods/vehicle/sorted.js @@ -18,7 +18,7 @@ module.exports = Self => { Self.sorted = async warehouseFk => { return Self.rawSql(` - SELECT v.id, v.warehouseFk, CONCAT(v.numberPlate, ' - ', w.name) as description + SELECT v.id, v.warehouseFk, v.numberPlate, w.name FROM vehicle v JOIN warehouse w ON w.id = v.warehouseFk ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC; diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html index 1d6e260a9..bf7bf672c 100644 --- a/modules/route/front/basic-data/index.html +++ b/modules/route/front/basic-data/index.html @@ -22,14 +22,14 @@
{{::name}}
- + order="false"> + {{::numberPlate}} - {{::name}}
From d18137bce0c97552ab8628d4458d5f346678ce9e Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 31 May 2023 10:20:13 +0200 Subject: [PATCH 11/91] refs #5066 not dense --- modules/route/front/basic-data/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html index bf7bf672c..514c535a2 100644 --- a/modules/route/front/basic-data/index.html +++ b/modules/route/front/basic-data/index.html @@ -22,7 +22,7 @@
{{::name}}
- Date: Wed, 31 May 2023 11:32:37 +0200 Subject: [PATCH 12/91] refs #5712 openDocuware --- back/methods/docuware/checkFile.js | 3 +-- back/methods/docuware/core.js | 1 - db/changes/232401/00-workerDocuware.sql | 4 ++++ front/core/services/app.js | 6 +++++- front/core/services/locale/es.yml | 3 ++- .../worker/back/methods/worker-dms/filter.js | 4 +--- modules/worker/front/dms/index/index.html | 20 +++++++------------ modules/worker/front/dms/index/index.js | 5 +++++ 8 files changed, 25 insertions(+), 21 deletions(-) diff --git a/back/methods/docuware/checkFile.js b/back/methods/docuware/checkFile.js index 803755d09..18d169085 100644 --- a/back/methods/docuware/checkFile.js +++ b/back/methods/docuware/checkFile.js @@ -48,8 +48,7 @@ module.exports = Self => { action: action } }); - console.log('ENTRY'); - console.log(filter, signed); + if (!filter) { filter = { condition: [ diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index f13b69b13..7bb3e617a 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -88,7 +88,6 @@ module.exports = Self => { filter, options.headers ); - console.log(data.data); return parser(data.data, parse); }; diff --git a/db/changes/232401/00-workerDocuware.sql b/db/changes/232401/00-workerDocuware.sql index fbacb23f9..c8d4e4f23 100644 --- a/db/changes/232401/00-workerDocuware.sql +++ b/db/changes/232401/00-workerDocuware.sql @@ -1,3 +1,7 @@ INSERT INTO `vn`.`docuware` (code, fileCabinetName, `action`, dialogName, findById) VALUES ('hr', 'RRHH', 'find', 'Búsqueda', 'N__DOCUMENTO'); + +INSERT INTO `salix`.`url` (appName, environment, url) + VALUES + ('docuware', 'production', 'https://verdnatura.docuware.cloud/DocuWare/Platform/'); diff --git a/front/core/services/app.js b/front/core/services/app.js index fb0a08777..6c80fafcc 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -66,7 +66,11 @@ export default class App { return this.logger.$http.get('Urls/findOne', {filter}) .then(res => { - return res.data.url + route; + if (res && res.data) + return res.data.url + route; + }) + .catch(() => { + this.showError('Direction not found'); }); } } diff --git a/front/core/services/locale/es.yml b/front/core/services/locale/es.yml index cf8801b52..e9811e38f 100644 --- a/front/core/services/locale/es.yml +++ b/front/core/services/locale/es.yml @@ -3,4 +3,5 @@ Could not contact the server: No se ha podido contactar con el servidor, asegura Please enter your username: Por favor introduce tu nombre de usuario It seems that the server has fall down: Parece que el servidor se ha caído, espera unos minutos e inténtalo de nuevo Session has expired: Tu sesión ha expirado, por favor vuelve a iniciar sesión -Access denied: Acción no permitida \ No newline at end of file +Access denied: Acción no permitida +Direction not found: Dirección no encontrada diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index eaefe67d3..0b89cc883 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -63,7 +63,7 @@ module.exports = Self => { 'Tipo Documento': 'description', 'Stored on': 'created', }; - const workerDocuware = await models.Docuware.getById('hr', 'BONO MOLA XAVIER', docuwareParse);// worker.lastName + worker.firstName); + const workerDocuware = await models.Docuware.getById('hr', worker.lastName + worker.firstName, docuwareParse); for (document of workerDocuware) { const defaultData = { file: document.dmsFk + '.png', @@ -75,8 +75,6 @@ module.exports = Self => { document = Object.assign(document, defaultData); } - console.log(workerDocuware); - console.log(workerDms); return workerDms.concat(workerDocuware); }; diff --git a/modules/worker/front/dms/index/index.html b/modules/worker/front/dms/index/index.html index 9d2d5b25d..aefbbcf34 100644 --- a/modules/worker/front/dms/index/index.html +++ b/modules/worker/front/dms/index/index.html @@ -60,11 +60,13 @@ {{::document.created | date:'dd/MM/yyyy HH:mm'}} - + + + @@ -76,19 +78,11 @@ tabindex="-1"> - - - - - + diff --git a/modules/worker/front/dms/index/index.js b/modules/worker/front/dms/index/index.js index ae2d51a17..489fe1732 100644 --- a/modules/worker/front/dms/index/index.js +++ b/modules/worker/front/dms/index/index.js @@ -21,6 +21,11 @@ class Controller extends Component { if (isDocuware) return this.vnFile.download(`api/workerDms/${dmsId}/docuwareDownload`); this.vnFile.download(`api/workerDms/${dmsId}/downloadFile`); } + + async openDocuware() { + const url = await this.vnApp.getUrl(`WebClient`, 'docuware'); + if (url) window.open(url).focus(); + } } Controller.$inject = ['$element', '$scope', 'vnFile']; From cc27d1fa97df7d7ce648a9b0d4019618525bbb85 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 7 Jun 2023 08:30:37 +0200 Subject: [PATCH 13/91] refs #5066 fix vehicle res.data --- modules/route/front/basic-data/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/route/front/basic-data/index.js b/modules/route/front/basic-data/index.js index a147a451c..d7f178985 100644 --- a/modules/route/front/basic-data/index.js +++ b/modules/route/front/basic-data/index.js @@ -11,10 +11,10 @@ class Controller extends Section { super($element, $); this.$http.get(`UserConfigs/getUserConfig`) .then(res => { - if (res && res.data) { + if (res.data) { this.$http.post(`Vehicles/sorted`, {warehouseFk: res.data.warehouseFk}) .then(res => { - if (res && res.data) + if (res.data) this.vehicles = res.data; }); } From dcbe8c5f7a36c29ed985705c07f0a80a4c17556a Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 26 Jun 2023 06:28:35 +0200 Subject: [PATCH 14/91] refs #5066 quit if --- modules/route/front/basic-data/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/route/front/basic-data/index.js b/modules/route/front/basic-data/index.js index d7f178985..e6be796ce 100644 --- a/modules/route/front/basic-data/index.js +++ b/modules/route/front/basic-data/index.js @@ -14,8 +14,7 @@ class Controller extends Section { if (res.data) { this.$http.post(`Vehicles/sorted`, {warehouseFk: res.data.warehouseFk}) .then(res => { - if (res.data) - this.vehicles = res.data; + this.vehicles = res.data; }); } }); From eff46c1cec81cf0d12a6e775e4749098481025fc Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 26 Jun 2023 07:43:36 +0200 Subject: [PATCH 15/91] refs #5066 e2e fix, vnConfig --- e2e/paths/08-route/02_basic_data.spec.js | 2 +- modules/route/front/basic-data/index.html | 3 ++- modules/route/front/basic-data/index.js | 19 +++++++------------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/e2e/paths/08-route/02_basic_data.spec.js b/e2e/paths/08-route/02_basic_data.spec.js index 6008b0482..7ab7dda42 100644 --- a/e2e/paths/08-route/02_basic_data.spec.js +++ b/e2e/paths/08-route/02_basic_data.spec.js @@ -24,7 +24,7 @@ describe('Route basic Data path', () => { const form = 'vn-route-basic-data form'; const values = { worker: 'adminBossNick', - vehicle: '1111-IMK - Warehouse One', + vehicle: '1111-IMK', created: nextMonth, kmStart: 1, kmEnd: 2, diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html index 514c535a2..ade9230e8 100644 --- a/modules/route/front/basic-data/index.html +++ b/modules/route/front/basic-data/index.html @@ -28,7 +28,8 @@ data="$ctrl.vehicles" show-field="numberPlate" value-field="id" - order="false"> + order="false" + vn-name="vehicle"> {{::numberPlate}} - {{::name}}
diff --git a/modules/route/front/basic-data/index.js b/modules/route/front/basic-data/index.js index e6be796ce..f051e23c5 100644 --- a/modules/route/front/basic-data/index.js +++ b/modules/route/front/basic-data/index.js @@ -2,23 +2,18 @@ import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { + $onInit() { + this.$http.post(`Vehicles/sorted`, {warehouseFk: this.vnConfig.warehouseFk}) + .then(res => { + this.vehicles = res.data; + }); + } + onSubmit() { this.$.watcher.submit().then(() => this.card.reload() ); } - constructor($element, $) { - super($element, $); - this.$http.get(`UserConfigs/getUserConfig`) - .then(res => { - if (res.data) { - this.$http.post(`Vehicles/sorted`, {warehouseFk: res.data.warehouseFk}) - .then(res => { - this.vehicles = res.data; - }); - } - }); - } } ngModule.vnComponent('vnRouteBasicData', { From 4f616397a2d1c513f5e051872fb7468de28e5978 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 3 Jul 2023 15:05:39 +0200 Subject: [PATCH 16/91] refs #5712 use dmsType readRole --- db/changes/232401/00-workerDocuware.sql | 7 ---- db/changes/232801/00-workerDocuware.sql | 10 +++++ .../{docuware.js => docuwareDownload.js} | 0 .../worker/back/methods/worker-dms/filter.js | 38 +++++++++++-------- modules/worker/back/models/worker-dms.js | 2 +- 5 files changed, 34 insertions(+), 23 deletions(-) delete mode 100644 db/changes/232401/00-workerDocuware.sql create mode 100644 db/changes/232801/00-workerDocuware.sql rename modules/worker/back/methods/worker-dms/{docuware.js => docuwareDownload.js} (100%) diff --git a/db/changes/232401/00-workerDocuware.sql b/db/changes/232401/00-workerDocuware.sql deleted file mode 100644 index c8d4e4f23..000000000 --- a/db/changes/232401/00-workerDocuware.sql +++ /dev/null @@ -1,7 +0,0 @@ -INSERT INTO `vn`.`docuware` (code, fileCabinetName, `action`, dialogName, findById) - VALUES - ('hr', 'RRHH', 'find', 'Búsqueda', 'N__DOCUMENTO'); - -INSERT INTO `salix`.`url` (appName, environment, url) - VALUES - ('docuware', 'production', 'https://verdnatura.docuware.cloud/DocuWare/Platform/'); diff --git a/db/changes/232801/00-workerDocuware.sql b/db/changes/232801/00-workerDocuware.sql new file mode 100644 index 000000000..2d0ce3c33 --- /dev/null +++ b/db/changes/232801/00-workerDocuware.sql @@ -0,0 +1,10 @@ +ALTER TABLE `vn`.`docuware` ADD dmsTypeFk INT(11) DEFAULT NULL NULL; +ALTER TABLE `vn`.`docuware` ADD CONSTRAINT docuware_FK FOREIGN KEY (dmsTypeFk) REFERENCES `vn`.`dmsType`(id) ON DELETE RESTRICT ON UPDATE CASCADE; +INSERT INTO `vn`.`docuware` (code, fileCabinetName, `action`, dialogName, findById, dmsTypeFk) + VALUES + ('hr', 'RRHH', 'find', 'Búsqueda', 'N__DOCUMENTO', NULL); + +INSERT INTO `salix`.`url` (appName, environment, url) + VALUES + ('docuware', 'production', 'https://verdnatura.docuware.cloud/DocuWare/Platform/'); + diff --git a/modules/worker/back/methods/worker-dms/docuware.js b/modules/worker/back/methods/worker-dms/docuwareDownload.js similarity index 100% rename from modules/worker/back/methods/worker-dms/docuware.js rename to modules/worker/back/methods/worker-dms/docuwareDownload.js diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index 0b89cc883..1343038b7 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -57,23 +57,31 @@ module.exports = Self => { const workerDms = await conn.executeStmt(stmt); // Get docuware info - const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); - const docuwareParse = { - 'Filename': 'dmsFk', - 'Tipo Documento': 'description', - 'Stored on': 'created', - }; - const workerDocuware = await models.Docuware.getById('hr', worker.lastName + worker.firstName, docuwareParse); - for (document of workerDocuware) { - const defaultData = { - file: document.dmsFk + '.png', - isDocuware: true, - hardCopyNumber: null, - hasFile: false, - reference: worker.fi + const docuware = await models.Docuware.findOne({ + fields: ['dmsTypeFk'], + where: {code: 'hr', action: 'find'} + }); + const docuwareDmsType = docuware.dmsTypeFk; + if (!(docuwareDmsType && !await models.DmsType.hasReadRole(ctx, docuwareDmsType))) { + const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); + const docuwareParse = { + 'Filename': 'dmsFk', + 'Tipo Documento': 'description', + 'Stored on': 'created', }; + const workerDocuware = + await models.Docuware.getById('hr', worker.lastName + worker.firstName, docuwareParse); + for (document of workerDocuware) { + const defaultData = { + file: document.dmsFk + '.png', + isDocuware: true, + hardCopyNumber: null, + hasFile: false, + reference: worker.fi + }; - document = Object.assign(document, defaultData); + document = Object.assign(document, defaultData); + } } return workerDms.concat(workerDocuware); diff --git a/modules/worker/back/models/worker-dms.js b/modules/worker/back/models/worker-dms.js index 1712383b3..6343e902e 100644 --- a/modules/worker/back/models/worker-dms.js +++ b/modules/worker/back/models/worker-dms.js @@ -2,7 +2,7 @@ module.exports = Self => { require('../methods/worker-dms/downloadFile')(Self); require('../methods/worker-dms/removeFile')(Self); require('../methods/worker-dms/filter')(Self); - require('../methods/worker-dms/docuware')(Self); + require('../methods/worker-dms/docuwareDownload')(Self); Self.isMine = async function(ctx, dmsId) { const myUserId = ctx.req.accessToken.userId; From e58d4e5db3451316308d2e2bb196676d0da5ce7e Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 4 Jul 2023 14:42:51 +0200 Subject: [PATCH 17/91] =?UTF-8?q?refs=20#4770=20feat:=20a=C3=B1adida=20sec?= =?UTF-8?q?ci=C3=B3n=20'Troncales'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/changes/232801/00-roadmap.sql | 10 + db/changes/232801/00-roadmapACL.sql | 4 + db/dump/fixtures.sql | 15 +- front/core/styles/icons/salixfont.css | 805 +++++++++--------- front/core/styles/icons/salixfont.eot | Bin 46420 -> 49176 bytes front/core/styles/icons/salixfont.svg | 7 +- front/core/styles/icons/salixfont.ttf | Bin 46248 -> 49004 bytes front/core/styles/icons/salixfont.woff | Bin 46324 -> 49080 bytes modules/client/front/summary/style.scss | 4 +- modules/entry/front/buy/index/style.scss | 9 +- modules/route/back/methods/roadmap/clone.js | 81 ++ modules/route/back/model-config.json | 14 +- .../route/back/models/expedition-truck.json | 43 + modules/route/back/models/roadmap.js | 3 + modules/route/back/models/roadmap.json | 63 ++ modules/route/front/index.js | 1 + .../route/front/roadmap/basic-data/index.html | 98 +++ .../route/front/roadmap/basic-data/index.js | 16 + modules/route/front/roadmap/card/index.html | 5 + modules/route/front/roadmap/card/index.js | 19 + modules/route/front/roadmap/create/index.html | 37 + modules/route/front/roadmap/create/index.js | 23 + modules/route/front/roadmap/create/style.scss | 6 + .../route/front/roadmap/descriptor/index.html | 39 + .../route/front/roadmap/descriptor/index.js | 26 + .../front/roadmap/descriptor/locale/es.yml | 3 + modules/route/front/roadmap/index.js | 9 + modules/route/front/roadmap/index/index.html | 112 +++ modules/route/front/roadmap/index/index.js | 62 ++ .../route/front/roadmap/index/locale/es.yml | 3 + modules/route/front/roadmap/locale/es.yml | 14 + modules/route/front/roadmap/main/index.html | 20 + modules/route/front/roadmap/main/index.js | 61 ++ .../route/front/roadmap/main/locale/es.yml | 1 + .../front/roadmap/search-panel/index.html | 74 ++ .../route/front/roadmap/search-panel/index.js | 7 + modules/route/front/roadmap/stops/index.html | 71 ++ modules/route/front/roadmap/stops/index.js | 39 + .../route/front/roadmap/stops/locale/es.yml | 4 + .../route/front/roadmap/summary/index.html | 113 +++ modules/route/front/roadmap/summary/index.js | 68 ++ .../route/front/roadmap/summary/locale/es.yml | 3 + .../route/front/roadmap/summary/style.scss | 11 + modules/route/front/routes.json | 47 +- modules/shelving/front/descriptor/index.html | 8 +- .../shelving/front/descriptor/locale/es.yml | 3 + modules/worker/front/create/index.html | 2 +- modules/worker/front/create/locale/es.yml | 2 +- 48 files changed, 1643 insertions(+), 422 deletions(-) create mode 100644 db/changes/232801/00-roadmap.sql create mode 100644 db/changes/232801/00-roadmapACL.sql create mode 100644 modules/route/back/methods/roadmap/clone.js create mode 100644 modules/route/back/models/expedition-truck.json create mode 100644 modules/route/back/models/roadmap.js create mode 100644 modules/route/back/models/roadmap.json create mode 100644 modules/route/front/roadmap/basic-data/index.html create mode 100644 modules/route/front/roadmap/basic-data/index.js create mode 100644 modules/route/front/roadmap/card/index.html create mode 100644 modules/route/front/roadmap/card/index.js create mode 100644 modules/route/front/roadmap/create/index.html create mode 100644 modules/route/front/roadmap/create/index.js create mode 100644 modules/route/front/roadmap/create/style.scss create mode 100644 modules/route/front/roadmap/descriptor/index.html create mode 100644 modules/route/front/roadmap/descriptor/index.js create mode 100644 modules/route/front/roadmap/descriptor/locale/es.yml create mode 100644 modules/route/front/roadmap/index.js create mode 100644 modules/route/front/roadmap/index/index.html create mode 100644 modules/route/front/roadmap/index/index.js create mode 100644 modules/route/front/roadmap/index/locale/es.yml create mode 100644 modules/route/front/roadmap/locale/es.yml create mode 100644 modules/route/front/roadmap/main/index.html create mode 100644 modules/route/front/roadmap/main/index.js create mode 100644 modules/route/front/roadmap/main/locale/es.yml create mode 100644 modules/route/front/roadmap/search-panel/index.html create mode 100644 modules/route/front/roadmap/search-panel/index.js create mode 100644 modules/route/front/roadmap/stops/index.html create mode 100644 modules/route/front/roadmap/stops/index.js create mode 100644 modules/route/front/roadmap/stops/locale/es.yml create mode 100644 modules/route/front/roadmap/summary/index.html create mode 100644 modules/route/front/roadmap/summary/index.js create mode 100644 modules/route/front/roadmap/summary/locale/es.yml create mode 100644 modules/route/front/roadmap/summary/style.scss create mode 100644 modules/shelving/front/descriptor/locale/es.yml diff --git a/db/changes/232801/00-roadmap.sql b/db/changes/232801/00-roadmap.sql new file mode 100644 index 000000000..a2835160f --- /dev/null +++ b/db/changes/232801/00-roadmap.sql @@ -0,0 +1,10 @@ +ALTER TABLE `vn`.`roadmap` COMMENT='Troncales diarios que se contratan'; +ALTER TABLE `vn`.`roadmap` ADD price decimal(10,2) NULL; +ALTER TABLE `vn`.`roadmap` ADD driverName varchar(45) NULL; +ALTER TABLE `vn`.`roadmap` ADD name varchar(45) NOT NULL; +ALTER TABLE `vn`.`roadmap` CHANGE name name varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL AFTER id; +ALTER TABLE `vn`.`roadmap` MODIFY COLUMN etd datetime NOT NULL; + +ALTER TABLE `vn`.`expeditionTruck` COMMENT='Distintas paradas que hacen los trocales'; +ALTER TABLE `vn`.`expeditionTruck` DROP FOREIGN KEY expeditionTruck_FK_2; +ALTER TABLE `vn`.`expeditionTruck` ADD CONSTRAINT expeditionTruck_FK_2 FOREIGN KEY (roadmapFk) REFERENCES vn.roadmap(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/changes/232801/00-roadmapACL.sql b/db/changes/232801/00-roadmapACL.sql new file mode 100644 index 000000000..8954ecb27 --- /dev/null +++ b/db/changes/232801/00-roadmapACL.sql @@ -0,0 +1,4 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Roadmap', '*', '*', 'ALLOW', 'ROLE', 'employee'), + ('ExpeditionTruck', '*', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 208eb2c21..a5cc2ddbe 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2593,7 +2593,7 @@ UPDATE `vn`.`ticket` UPDATE `vn`.`ticket` SET refFk = 'A1111111' - WHERE id = 6; + WHERE id = 6; INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`) VALUES @@ -2602,9 +2602,18 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`) (3, 6, 5), (4, 7, 1); -INSERT INTO `vn`.`expeditionTruck` (`id`, `eta`, `description`) +INSERT INTO `vn`.`roadmap` (`id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `userFk`, `price`, `driverName`) VALUES - (1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +3 YEAR))), 'Best truck in fleet'); + (1, 'val-algemesi', 'RE-001', 'PO-001', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'), + (2, 'alg-valencia', 'RE-002', 'PO-002', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'), + (3, 'alz-algemesi', 'RE-003', 'PO-003', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman'); + +INSERT INTO `vn`.`expeditionTruck` (`id`, `roadmapFk`, `warehouseFk`, `eta`, `description`, `userFk`) + VALUES + (1, 1, 1, DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY), 'Best truck in fleet', 1), + (2, 1, 2, DATE_ADD(util.VN_NOW(), INTERVAL '1 2' DAY_HOUR), 'Second truck in fleet', 1), + (3, 1, 3, DATE_ADD(util.VN_NOW(), INTERVAL '1 4' DAY_HOUR), 'Third truck in fleet', 1), + (4, 2, 1, DATE_ADD(util.VN_NOW(), INTERVAL 3 DAY), 'Truck red', 1); INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPrint`) VALUES diff --git a/front/core/styles/icons/salixfont.css b/front/core/styles/icons/salixfont.css index 6f9b1fe15..37f489fe2 100644 --- a/front/core/styles/icons/salixfont.css +++ b/front/core/styles/icons/salixfont.css @@ -1,402 +1,411 @@ @font-face { - font-family: 'salixfont'; - src: - url('./salixfont.ttf?wtrl3') format('truetype'), - url('./salixfont.woff?wtrl3') format('woff'), - url('./salixfont.svg?wtrl3#salixfont') format('svg'); - font-weight: normal; - font-style: normal; -} + font-family: 'salixfont'; + src: + url('./salixfont.ttf?wtrl3') format('truetype'), + url('./salixfont.woff?wtrl3') format('woff'), + url('./salixfont.svg?wtrl3#salixfont') format('svg'); + font-weight: normal; + font-style: normal; + } -[class^="icon-"], [class*=" icon-"] { - /* use !important to prevent issues with browser extensions that change fonts */ - font-family: 'salixfont' !important; - speak: none; - font-style: normal; - font-weight: normal; - font-variant: normal; - text-transform: none; - line-height: 1; + [class^="icon-"], [class*=" icon-"] { + /* use !important to prevent issues with browser extensions that change fonts */ + font-family: 'salixfont' !important; + speak: none; + font-style: normal; + font-weight: normal; + font-variant: normal; + text-transform: none; + line-height: 1; - /* Better Font Rendering =========== */ - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} + /* Better Font Rendering =========== */ + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + } -.icon-agency-term:before { - content: "\e950"; -} -.icon-defaulter:before { - content: "\e94b"; -} -.icon-100:before { - content: "\e95a"; -} -.icon-clientUnpaid:before { - content: "\e95b"; -} -.icon-history:before { - content: "\e968"; -} -.icon-Person:before { - content: "\e901"; -} -.icon-accessory:before { - content: "\e90a"; -} -.icon-account:before { - content: "\e92a"; -} -.icon-actions:before { - content: "\e960"; -} -.icon-addperson:before { - content: "\e90e"; -} -.icon-agency:before { - content: "\e938"; -} -.icon-albaran:before { - content: "\e94d"; -} -.icon-anonymous:before { - content: "\e930"; -} -.icon-apps:before { - content: "\e951"; -} -.icon-artificial:before { - content: "\e90b"; -} -.icon-attach:before { - content: "\e92e"; -} -.icon-barcode:before { - content: "\e971"; -} -.icon-basket:before { - content: "\e914"; -} -.icon-basketadd:before { - content: "\e913"; -} -.icon-bin:before { - content: "\e96f"; -} -.icon-botanical:before { - content: "\e972"; -} -.icon-bucket:before { - content: "\e97a"; -} -.icon-buscaman:before { - content: "\e93b"; -} -.icon-buyrequest:before { - content: "\e932"; -} -.icon-calc_volum .path1:before { - content: "\e915"; -} -.icon-calc_volum .path2:before { - content: "\e916"; - margin-left: -1em; -} -.icon-calc_volum .path3:before { - content: "\e917"; - margin-left: -1em; -} -.icon-calc_volum .path4:before { - content: "\e918"; - margin-left: -1em; -} -.icon-calc_volum .path5:before { - content: "\e919"; - margin-left: -1em; -} -.icon-calc_volum .path6:before { - content: "\e91a"; - margin-left: -1em; -} -.icon-calendar:before { - content: "\e93d"; -} -.icon-catalog:before { - content: "\e937"; -} -.icon-claims:before { - content: "\e963"; -} -.icon-client:before { - content: "\e928"; -} -.icon-clone:before { - content: "\e973"; -} -.icon-columnadd:before { - content: "\e954"; -} -.icon-columndelete:before { - content: "\e953"; -} -.icon-components:before { - content: "\e946"; -} -.icon-consignatarios:before { - content: "\e93f"; -} -.icon-control:before { - content: "\e949"; -} -.icon-credit:before { - content: "\e927"; -} -.icon-deletedTicket:before { - content: "\e935"; -} -.icon-deleteline:before { - content: "\e955"; -} -.icon-delivery:before { - content: "\e939"; -} -.icon-deliveryprices:before { - content: "\e91c"; -} -.icon-details:before { - content: "\e961"; -} -.icon-dfiscales:before { - content: "\e984"; -} -.icon-disabled:before { - content: "\e921"; -} -.icon-doc:before { - content: "\e977"; -} -.icon-entry:before { - content: "\e934"; -} -.icon-exit:before { - content: "\e92f"; -} -.icon-eye:before { - content: "\e976"; -} -.icon-fixedPrice:before { - content: "\e90d"; -} -.icon-flower:before { - content: "\e90c"; -} -.icon-frozen:before { - content: "\e900"; -} -.icon-fruit:before { - content: "\e903"; -} -.icon-funeral:before { - content: "\e904"; -} -.icon-greenery:before { - content: "\e907"; -} -.icon-greuge:before { - content: "\e944"; -} -.icon-grid:before { - content: "\e980"; -} -.icon-handmade:before { - content: "\e909"; -} -.icon-handmadeArtificial:before { - content: "\e902"; -} -.icon-headercol:before { - content: "\e958"; -} -.icon-info:before { - content: "\e952"; -} -.icon-inventory:before { - content: "\e92b"; -} -.icon-invoice:before { - content: "\e923"; -} -.icon-invoice-in:before { - content: "\e911"; -} -.icon-invoice-in-create:before { - content: "\e912"; -} -.icon-invoice-out:before { - content: "\e910"; -} -.icon-isTooLittle:before { - content: "\e91b"; -} -.icon-item:before { - content: "\e956"; -} -.icon-languaje:before { - content: "\e926"; -} -.icon-lines:before { - content: "\e942"; -} -.icon-linesprepaired:before { - content: "\e948"; -} -.icon-logout:before { - content: "\e936"; -} -.icon-mana:before { - content: "\e96a"; -} -.icon-mandatory:before { - content: "\e97b"; -} -.icon-net:before { - content: "\e931"; -} -.icon-niche:before { - content: "\e96c"; -} -.icon-no036:before { - content: "\e920"; -} -.icon-noPayMethod:before { - content: "\e905"; -} -.icon-notes:before { - content: "\e941"; -} -.icon-noweb:before { - content: "\e91f"; -} -.icon-onlinepayment:before { - content: "\e91d"; -} -.icon-package:before { - content: "\e978"; -} -.icon-payment:before { - content: "\e97e"; -} -.icon-pbx:before { - content: "\e93c"; -} -.icon-pets:before { - content: "\e947"; -} -.icon-photo:before { - content: "\e924"; -} -.icon-plant:before { - content: "\e908"; -} -.icon-polizon:before { - content: "\e95e"; -} -.icon-preserved:before { - content: "\e906"; -} -.icon-recovery:before { - content: "\e97c"; -} -.icon-regentry:before { - content: "\e964"; -} -.icon-reserva:before { - content: "\e959"; -} -.icon-revision:before { - content: "\e94a"; -} -.icon-risk:before { - content: "\e91e"; -} -.icon-services:before { - content: "\e94c"; -} -.icon-settings:before { - content: "\e979"; -} -.icon-shipment-01:before { - content: "\e929"; -} -.icon-sign:before { - content: "\e95d"; -} -.icon-sms:before { - content: "\e975"; -} -.icon-solclaim:before { - content: "\e95f"; -} -.icon-solunion:before { - content: "\e94e"; -} -.icon-stowaway:before { - content: "\e94f"; -} -.icon-splitline:before { - content: "\e93e"; -} -.icon-splur:before { - content: "\e970"; -} -.icon-supplier:before { - content: "\e925"; -} -.icon-supplierfalse:before { - content: "\e90f"; -} -.icon-tags:before { - content: "\e96d"; -} -.icon-tax:before { - content: "\e940"; -} -.icon-thermometer:before { - content: "\e933"; -} -.icon-ticket:before { - content: "\e96b"; -} -.icon-ticketAdd:before { - content: "\e945"; -} -.icon-traceability:before { - content: "\e962"; -} -.icon-transaction:before { - content: "\e966"; -} -.icon-treatments:before { - content: "\e922"; -} -.icon-unavailable:before { - content: "\e92c"; -} -.icon-volume:before { - content: "\e96e"; -} -.icon-wand:before { - content: "\e93a"; -} -.icon-web:before { - content: "\e982"; -} -.icon-wiki:before { - content: "\e92d"; -} -.icon-worker:before { - content: "\e957"; -} -.icon-zone:before { - content: "\e943"; -} + .icon-trailer:before { + content: "\e967"; + } + .icon-grafana:before { + content: "\e965"; + } + .icon-trolley:before { + content: "\e95c"; + } + .icon-agency-term:before { + content: "\e950"; + } + .icon-defaulter:before { + content: "\e94b"; + } + .icon-100:before { + content: "\e95a"; + } + .icon-clientUnpaid:before { + content: "\e95b"; + } + .icon-history:before { + content: "\e968"; + } + .icon-Person:before { + content: "\e901"; + } + .icon-accessory:before { + content: "\e90a"; + } + .icon-account:before { + content: "\e92a"; + } + .icon-actions:before { + content: "\e960"; + } + .icon-addperson:before { + content: "\e90e"; + } + .icon-agency:before { + content: "\e938"; + } + .icon-albaran:before { + content: "\e94d"; + } + .icon-anonymous:before { + content: "\e930"; + } + .icon-apps:before { + content: "\e951"; + } + .icon-artificial:before { + content: "\e90b"; + } + .icon-attach:before { + content: "\e92e"; + } + .icon-barcode:before { + content: "\e971"; + } + .icon-basket:before { + content: "\e914"; + } + .icon-basketadd:before { + content: "\e913"; + } + .icon-bin:before { + content: "\e96f"; + } + .icon-botanical:before { + content: "\e972"; + } + .icon-bucket:before { + content: "\e97a"; + } + .icon-buscaman:before { + content: "\e93b"; + } + .icon-buyrequest:before { + content: "\e932"; + } + .icon-calc_volum .path1:before { + content: "\e915"; + } + .icon-calc_volum .path2:before { + content: "\e916"; + margin-left: -1em; + } + .icon-calc_volum .path3:before { + content: "\e917"; + margin-left: -1em; + } + .icon-calc_volum .path4:before { + content: "\e918"; + margin-left: -1em; + } + .icon-calc_volum .path5:before { + content: "\e919"; + margin-left: -1em; + } + .icon-calc_volum .path6:before { + content: "\e91a"; + margin-left: -1em; + } + .icon-calendar:before { + content: "\e93d"; + } + .icon-catalog:before { + content: "\e937"; + } + .icon-claims:before { + content: "\e963"; + } + .icon-client:before { + content: "\e928"; + } + .icon-clone:before { + content: "\e973"; + } + .icon-columnadd:before { + content: "\e954"; + } + .icon-columndelete:before { + content: "\e953"; + } + .icon-components:before { + content: "\e946"; + } + .icon-consignatarios:before { + content: "\e93f"; + } + .icon-control:before { + content: "\e949"; + } + .icon-credit:before { + content: "\e927"; + } + .icon-deletedTicket:before { + content: "\e935"; + } + .icon-deleteline:before { + content: "\e955"; + } + .icon-delivery:before { + content: "\e939"; + } + .icon-deliveryprices:before { + content: "\e91c"; + } + .icon-details:before { + content: "\e961"; + } + .icon-dfiscales:before { + content: "\e984"; + } + .icon-disabled:before { + content: "\e921"; + } + .icon-doc:before { + content: "\e977"; + } + .icon-entry:before { + content: "\e934"; + } + .icon-exit:before { + content: "\e92f"; + } + .icon-eye:before { + content: "\e976"; + } + .icon-fixedPrice:before { + content: "\e90d"; + } + .icon-flower:before { + content: "\e90c"; + } + .icon-frozen:before { + content: "\e900"; + } + .icon-fruit:before { + content: "\e903"; + } + .icon-funeral:before { + content: "\e904"; + } + .icon-greenery:before { + content: "\e907"; + } + .icon-greuge:before { + content: "\e944"; + } + .icon-grid:before { + content: "\e980"; + } + .icon-handmade:before { + content: "\e909"; + } + .icon-handmadeArtificial:before { + content: "\e902"; + } + .icon-headercol:before { + content: "\e958"; + } + .icon-info:before { + content: "\e952"; + } + .icon-inventory:before { + content: "\e92b"; + } + .icon-invoice:before { + content: "\e923"; + } + .icon-invoice-in:before { + content: "\e911"; + } + .icon-invoice-in-create:before { + content: "\e912"; + } + .icon-invoice-out:before { + content: "\e910"; + } + .icon-isTooLittle:before { + content: "\e91b"; + } + .icon-item:before { + content: "\e956"; + } + .icon-languaje:before { + content: "\e926"; + } + .icon-lines:before { + content: "\e942"; + } + .icon-linesprepaired:before { + content: "\e948"; + } + .icon-logout:before { + content: "\e936"; + } + .icon-mana:before { + content: "\e96a"; + } + .icon-mandatory:before { + content: "\e97b"; + } + .icon-net:before { + content: "\e931"; + } + .icon-niche:before { + content: "\e96c"; + } + .icon-no036:before { + content: "\e920"; + } + .icon-noPayMethod:before { + content: "\e905"; + } + .icon-notes:before { + content: "\e941"; + } + .icon-noweb:before { + content: "\e91f"; + } + .icon-onlinepayment:before { + content: "\e91d"; + } + .icon-package:before { + content: "\e978"; + } + .icon-payment:before { + content: "\e97e"; + } + .icon-pbx:before { + content: "\e93c"; + } + .icon-pets:before { + content: "\e947"; + } + .icon-photo:before { + content: "\e924"; + } + .icon-plant:before { + content: "\e908"; + } + .icon-polizon:before { + content: "\e95e"; + } + .icon-preserved:before { + content: "\e906"; + } + .icon-recovery:before { + content: "\e97c"; + } + .icon-regentry:before { + content: "\e964"; + } + .icon-reserva:before { + content: "\e959"; + } + .icon-revision:before { + content: "\e94a"; + } + .icon-risk:before { + content: "\e91e"; + } + .icon-services:before { + content: "\e94c"; + } + .icon-settings:before { + content: "\e979"; + } + .icon-shipment-01:before { + content: "\e929"; + } + .icon-sign:before { + content: "\e95d"; + } + .icon-sms:before { + content: "\e975"; + } + .icon-solclaim:before { + content: "\e95f"; + } + .icon-solunion:before { + content: "\e94e"; + } + .icon-stowaway:before { + content: "\e94f"; + } + .icon-splitline:before { + content: "\e93e"; + } + .icon-splur:before { + content: "\e970"; + } + .icon-supplier:before { + content: "\e925"; + } + .icon-supplierfalse:before { + content: "\e90f"; + } + .icon-tags:before { + content: "\e96d"; + } + .icon-tax:before { + content: "\e940"; + } + .icon-thermometer:before { + content: "\e933"; + } + .icon-ticket:before { + content: "\e96b"; + } + .icon-ticketAdd:before { + content: "\e945"; + } + .icon-traceability:before { + content: "\e962"; + } + .icon-transaction:before { + content: "\e966"; + } + .icon-treatments:before { + content: "\e922"; + } + .icon-unavailable:before { + content: "\e92c"; + } + .icon-volume:before { + content: "\e96e"; + } + .icon-wand:before { + content: "\e93a"; + } + .icon-web:before { + content: "\e982"; + } + .icon-wiki:before { + content: "\e92d"; + } + .icon-worker:before { + content: "\e957"; + } + .icon-zone:before { + content: "\e943"; + } diff --git a/front/core/styles/icons/salixfont.eot b/front/core/styles/icons/salixfont.eot index 61a3be8b7a499b5ad3f597168c821e1139893db8..6a158c806f3d7e215af3cca22ba80fed7ad300b4 100644 GIT binary patch delta 3142 zcmZuzU2Ggz6~5>G&Hv2qdUn@d|L?BXPMo+q`{%?>q6oE3D3%&GaSUn;7*djlgoZY% z(gDnF_a^r?Ly4~QooP(>r8A|B$xcW3OxL9EWq z+_`h^Io~<=-0$qWf9K!-iqM1C7(4ss72T80=EetC4nNa>@7^mjjL`^V?CI01Pn^dy zhxe;^+NaMx^@Zo2eR%`#uQ2wD3uhi(Jyrkmk6vPI!|3eWMU$Bg~zY1pvOtzJCOe!!n(?AOmgf8vX)=Y}5r^va))VB%FM zymgR8eSXalM)lOw#4K0&++0n`rd!8i4Vm! zR%H#ghq0-AtvK1Oy;7Mf=f&ZC zd8$&WmkOBOvqv1h`Tm0V`U@}Iykt$pm8q#pJYhM`?J@t|N53a~Ve>4tK6;0(KmM&@ zr%!AKc&>|U{5WE2#&B%yltwja=tP&w*<`Gtkc?5X&)mxpT}n#5`E0yEcN4xHqHfac zBnN0eH9OryG@nVSm(0<0(yS)c=6>o_q0sI3ItS?hB?qa~=pLYhG!2zIWtOmFma4i| z)ptM}q2dUQ5+0fN?R$HH+Rc`^r-P*3>|rzyY4zF}lvWRz;K%BRRLdfR{oR!8CftoQ zt8HAhYNNIjO``*l-MEuD&0nX z3;UR<%>S8(ab)6-o$57EDb`NxY4Q@(3;j`Qp=>1`sfv!Bvx$yf(ruf|K39&Q`+J8j zxJ6&Nx;%W(ierUVakiv96;7_qHx)A;oAX-9c_U?xT`>*tS*<;ElJ>BEnRIg2aOn(iv^?%(ei zhol25tmXlh&orCZNR*4K@JVWH5{xU2;)tj7h4COL+LmiljIX}ql>J~Nibf;k(99rI zE7IYR>*Xz|38R>zk{AhWvsnk5S*)@zg{xKQ*aZh0Xgry0DG@hd5Ea0)OqwN*_UmPD z&_^l5D&p0q;w*{uLy#SR$Sc*&R>O#v(zC)w*&7Oi;V>Kx3otCnicIA|!eO)5%I+)R z#&T39RuNa`o?$Zs{J4;j>y`uK(ZrXEF%*u3>GyOJ1_W8YcCaUsP|O847|Z2r1BK}V z+|3>qC9}bZ3;{uv7CQAMw5#=RKevziHrq=~yvM)FX4nbVXK%2#Kwt-H4J{!fDBZ}; zx?!MZ3k<(SLSPo~glPryAondQO?%f)!f2yIq)WPU1eu-|}^Pej5Pz zIGfzb=1IHTM&r1X_Dq;}!E6%^EU6Vs{j|x9845L$Amp~n;3l=Ew$LM?xE-Z|fM%Jt z_^ou99L23R^xCav=DyuaeIg3eywZ+|DETi<`S?yW7Fiw+35tbl99~H{7N8yF$spiw zJF($VI{=G80Y4lEEu@ygkcXPLaiD~2Z$6JoO4p$jxZ|Yd26NDsU@#DktGtkl!O{xK z8}$}VL|E;(P)rL5XESx$$C>d_k-&!Aclm3k9ygcFoA@Cd!Hzj@lG}p=SQ3^ToE>~E z?uv1Oys_9VI68G3mICKOyn&z4H=${&noHYY;8Kj&azrhtp?*^YeIV6EuEgd` zIMDCP4t+{m<9dMkae0b z!R4{5X;LVBE0HxExRPl~Vq=J`)mMn2fsbUqUu_>g(h{4HjGeX8@l?dRIQ z*XQZ-`uW!{6M1Vl-l#blQ$lE@}ajL SwjW-=A8*DkuU}ffPX7fLBU>&2 delta 408 zcmbQyz22kEC11P|u$Fc^ReZG3%;fng(%&&ZUUSW&<*i>Zu(VbckqdWF2iT*=h9@SE;Hffqmp z^9u5dOBk4eQVd%GNMGC&70Gw?7lGAO)^ewp$z?PbQx;+Hiq>s~gzY25MxS%y>Y2vcLhh&Av=Rots~Gi*auLI?IA_ zbLE0?DH*$|9QpD5HeVUIS-^%o;A}bwVu0w$Z+4k8Hf&be-OM<7^&SOA=FM03$T51j z*0~k9Gr1?ZZ}5=vSm7z)xyFmno5v@_XOgd#?;XDozY4z<{u=%b{^tTL0x|-60!0E# c0#5{Yg$abkge?lY0yLcwh#NNB?YqSY0AsU==>Px# diff --git a/front/core/styles/icons/salixfont.svg b/front/core/styles/icons/salixfont.svg index d6bfd5d74..da5404842 100644 --- a/front/core/styles/icons/salixfont.svg +++ b/front/core/styles/icons/salixfont.svg @@ -98,7 +98,8 @@ - + + @@ -107,7 +108,9 @@ + + @@ -131,4 +134,4 @@ - + \ No newline at end of file diff --git a/front/core/styles/icons/salixfont.ttf b/front/core/styles/icons/salixfont.ttf index 89d3bd57d3429a743fb9421dd39b7ae8a38b38e7..b484f2a6022b2897ea5e4eff21768a430dce4a00 100644 GIT binary patch delta 3124 zcmZ8jU2I%O6`nIQcjo@z-SypFd;Pz=UORE(?%h8(&W|FLl29Twe@;McfrysmA)zUa zsw6_XLMcd86|^#~)Cbytgp`M(D43r%0ufcEsu1LfK9C30CnTf@5K<8jN#L7%ZO6en zJ9mE0ob#PCXTI^(zwtZw`Kwdu$B(@>#~6(<#$Gyg@`ZEw7BIeouYKyw#jpL~)gRx$ z_$p)Xo5q{QZc=eD@Xk0PXY499x2 zwCYJqC8|=*Cu0SLWP*}MOUjt=KUqwNm$!M{iNMXcF_)M_xgKiF_+39S)kdZ zT~F%m9n`Bsp`Q+VyJ;6CyQ$ae@1or_3zdgup0Hz{>Z(y!4?!EF@)(U1KDqbxw!1{# zcE_|?C+W5a=q*AzgKiF`GXN&|(P>DHJTlndO37A2YouN8;@7CR8k^CydH~svdr80D z>-Gi@V$02DE_YI=Zqi_qlS^DFR{=GFl##$(a<2>dCu`@iF)_Y3d(8X&N0AzMUU}_e zIb9E7BNlW_AJOHqIOweP0BF%Vy6um9T6}I?^gTcEKh(bV+q>F1h6hdVH|wyj%7yS5-&%op5xh%kve> zv%={Ub46$u#(d(mu%x$Gl>c$E3a(d+qUmBOZI;}UtuRG`q$^AHD5`mGQCXTuaOvB2 z$#pBPS9Un(>-%94tAvjL2wMsp1Ck_!7G_cjp(Ga^{d|vU^PetgJJiaTmNM2-5f@Bg zjs?idvxJpff;HtUuj*AAp0YC|*?uXkz%I_${LxT_Ixt?fjK;%oET}D%+=9}sl+suR z5a4%}KQ$!Xb?ZtXCb5v;MkWr3MMg~; zOI``N%EHV1S|qVz2?4WGT7lz?L^{yk_?Di_1tEGnvUR~mKR%f5Xo$}vv9JgTl5^Jr zW}2K`KIK@R8k&od%;vfM6NSl0d1~*|VnK6@l%hwfTOW6fLsEeb>qTJYbL}?H5!K>a zSdz*l0Zxz;z7u^^cM&+J5z5pKo#p$m+FjP9+wg7X(|lna5%@UQ-puAnx8KFX@h}gX zxF3PtHXg8~QLbcf%mg7NMiQi;Yvu5hMq6n-ks6uX^v z?!G(7d?F0mU#faJcsh zOjgd4Pz<8Uf^y*{M*Io{PNk_R3eC-TK>`Xtq8)(XL`stbelX@C4ibovjYr`ON82=r zl3SsT96{hh06c<3j&0a*%08~Q9V!aZ$h(yDNIk_yeAo2*TYK{c>mpT2(q!-QPw~;IYisEoaBEamR!+8Ng3#Env1YmT% zGEP&%rf>ZMsdX%Q#I@YA2a7sT&eKOStO$|l8K35URQS|B~7 z@ca)b;Ub(hNmsdZycA3aq z*>}C+%t1-uw|({W^$9w-@Ar>=@Y!GPKd}Gm{(m3%%7MRs?)bq&2k$&ldgA<{ZydgH z_&-Ok9R1AE8%O_gEIjtTV}D)lEx)yVYx!TtFCD*qV&Mz_eDcL7-+#(}Y6<^$Gj@6P J*3WL!{{Z7KRgeGx delta 379 zcmaF!k7>nArU?r56LThIGcYj9FfcI8Nlz>;0MY_L{th6`k)BhTb~uOa6_9^`fnn{6 zjMT&w<++|;85q`Q0OidxfC3zPENg)L1wg(^Ms7*Pw?c_Z}XLbn+0Sx!voHygD`rs!!C2ihRqebni(hm z->tyNyjf$99Al7com+uBlY5f;1`jEZ6`lf~YrOcpd3-{ACizFyx(_b_RgKn?Dx#<>?WIR=g!wA+av^OlUM^unrx!9RYO~oABl}N z)HVo%qzYQlgl&rjZ9}2p4<&}J8iS>wR4Jmx9~NqUh`$6O_(d!Ik+eSVy}QXq9L{^^ zopaB7&U4Ot-sfdL_#3aua3g;lh1q!x(_Vt${91BKmY306OSKz%(AYYfKA_w#@B!H$_Xf;yNKTn zGwgYB>BOlsPeb>%Wij6j_LbpZoP6R@*!}7c@QD~?U)yKdfCU0ZLSozzQP-E=!`qgJ=KlNNGG`sqB)q^(+7Yi*-$4F92TY~_WFqVytfslLFBH%{r_cMZb;JP2~92w{r2h%02fSE7Fz9kR-gfO zZo|Z+o!miv8~eEF%>U8DIVy42PW7AU6ulmMR=gDbLcbG=OIr#@$g*P>Y@!2aRmWyx zz@)?Jf&R`jZrPWvs*K!s)X||X&n426;ndODBFqb;J~5hK)Egz`A4am^detbJDwY~0 zw`415h?8(dsTM_5&n+sci8vF!ZI@g(alNv`7+YHoe|Sp+d~?C1Ex6605yZLXMyWVg zf^mjvGOFBxg$7JzVa$wQumad`N)R&J8@y3}9g_G1vKw34BB@E|#dUm;}RI2$4zXm4y|*JYfL zy&c)QU}GNd+g9hFL1Ez$5Cmhc1Z0|+Svu}WPYun+sAc2yp7Fv&q&&6j5k9Y(B&Fz{ z%BH~sjtNLA&|$3zuxz%~!bYN9T!~jgVUyroDl|ttQ!GscLD|->DKXyqj#Kf2(I^^= zP(!0Zsyb5P2G=WUm~ms6p%R#JY_nMhpLwogAh@e!=-4F(8)zb#YDpe9;Se3b@=BT| zj`AB7Z`emG!z=PtrsK3g`5~x|zrjlyW~<>u3E}CmS@AXm!AKa6g(Wx^q$ATgkZ{E8 zwX_EkxUn3aiB-g;dFI&61RuslL^SzjVjP8|VfH>#!T~4kD+hZb2+dq_gYiPK zK2(}1A>7<9o|p|rW=II8wAgJN#C5f@<@v2Nu&pg*@%Pv_tXb=@HLxyQZ-Kye&@!%s zoS;-QKkJ5pT5T}=DhYvEz!T;wSOB@NQfYQ~ttX5QZisA2Z=N7C)3s(DT(QP|9i8#Z z9U4#CYwnvf+FTltW-YfjTm(X0K7Y16$lmm3rrLdTf7GXHYK(A+PUDU;JX%`?jpesv z-O;ZB03YYd^=zJYdL3LGchjCp^B%Zu;Q~wR)3ATd%0Vb_zd+cMygKIvjKb<|=1JC9V!93~AphKmDA+mzOc18gI}!G+nlRYMhlMa`A~{t}})@l7oUoB*RZ zoRJ1VJD4z5K+;^Pp#T{eW3PE)sI0RnP9OWT}>xNJsXUr`k65NwyE04bLx$5XYuHJIK5N-d^@&vfWvi|Z+ z_rCb4pVH#Y`G1|Zn-g@GGPuV7%Dyl}tRL>>A1IY5Cq6LThIrzaK{FfcH& z0QnqHERdd4nFbW&VPIIh0)!9eu)WGiO-x~6Sic3R#tej&=X!q4015)d-T?V3Ak3l1 zvL++9q=JEAg8)!JP>6})TcJdFPJS{_-6o(IBT$f$Nou3f>sz^r6+nwOivU$AfblG* zvb@CHRG^p%P|-XPjtjr(UXWj00`$X`iGR9H8-NOB7z7xY8F+wRQ+OHuGUa93%Z!)B zFKb@by=-{d^s?pu-~a!Cs(^;RWOx}1lAXMPQHe|Juh<{4-$0F^5D=fdVL#jEw~Rua zo4dQkI5$t7Wx=>vazVJ1jNMd@{CIwwuMFIv0AXNwz}a*VMo;e9WzN{J`N*zj#>w7$ z6d0K|m+X;a^l+_nD{yCWPjcVjA?2~cQ^0eL7oRtePl(SXUn}1`ej$Dpek=Sn{2Tnw m1y}@R1oQ-o1eOGz2<{3K2#X0@6m|t@JR=Y{Y`(Ym79#)x`HcDi diff --git a/modules/client/front/summary/style.scss b/modules/client/front/summary/style.scss index 77fc020ef..7dc1cc928 100644 --- a/modules/client/front/summary/style.scss +++ b/modules/client/front/summary/style.scss @@ -8,7 +8,7 @@ vn-client-summary .summary { } vn-horizontal h4 .grafana:after { - content: 'contact_support'; - font-size: 17px; + font-family: 'salixfont' !important; + content: "\e965"; } } diff --git a/modules/entry/front/buy/index/style.scss b/modules/entry/front/buy/index/style.scss index 04c8d130a..3fad252df 100644 --- a/modules/entry/front/buy/index/style.scss +++ b/modules/entry/front/buy/index/style.scss @@ -3,14 +3,13 @@ vn-entry-buy-index vn-card { max-width: $width-xl; - + .dark-row { background-color: lighten($color-marginal, 10%); } thead tr { - border-left: 1px solid white; - border-right: 1px solid white; + border: 1px solid white;; } tbody tr:nth-child(1), @@ -22,7 +21,7 @@ vn-entry-buy-index vn-card { tbody tr:nth-child(2) { border-bottom: 1px solid $color-spacer; } - + tbody{ border-bottom: 1px solid $color-spacer; } @@ -40,4 +39,4 @@ vn-entry-buy-index vn-card { } } -$color-font-link-medium: lighten($color-font-link, 20%) \ No newline at end of file +$color-font-link-medium: lighten($color-font-link, 20%) diff --git a/modules/route/back/methods/roadmap/clone.js b/modules/route/back/methods/roadmap/clone.js new file mode 100644 index 000000000..456ed823d --- /dev/null +++ b/modules/route/back/methods/roadmap/clone.js @@ -0,0 +1,81 @@ +const UserError = require('vn-loopback/util/user-error'); +module.exports = Self => { + Self.remoteMethod('clone', { + description: 'Clones the selected routes', + accessType: 'WRITE', + accepts: [ + { + arg: 'ids', + type: ['number'], + required: true, + description: 'The routes ids to clone' + }, + { + arg: 'etd', + type: 'date', + required: true, + description: 'The estimated time of departure for all roadmaps' + } + ], + returns: { + type: ['Object'], + root: true + }, + http: { + path: `/clone`, + verb: 'POST' + } + }); + + Self.clone = async(ids, etd) => { + const tx = await Self.beginTransaction({}); + try { + const models = Self.app.models; + const options = {transaction: tx}; + const originalRoadmaps = await models.Roadmap.find({ + where: {id: {inq: ids}}, + fields: [ + 'id', + 'name', + 'tractorPlate', + 'trailerPlate', + 'phone', + 'supplierFk', + 'etd', + 'observations', + 'price'], + include: [{ + relation: 'expeditionTruck', + scope: { + fields: ['roadmapFk', 'warehouseFk', 'eta', 'description'] + } + }] + + }, options); + + if (ids.length != originalRoadmaps.length) + throw new UserError(`The amount of roadmaps found don't match`); + + for (const roadmap of originalRoadmaps) { + roadmap.id = undefined; + roadmap.etd = etd; + + const clone = await models.Roadmap.create(roadmap, options); + + const expeditionTrucks = roadmap.expeditionTruck(); + expeditionTrucks.map(expeditionTruck => { + expeditionTruck.roadmapFk = clone.id; + return expeditionTruck; + }); + await models.ExpeditionTruck.create(expeditionTrucks, options); + } + + await tx.commit(); + + return true; + } catch (e) { + await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json index 31aaad9f5..6688a243a 100644 --- a/modules/route/back/model-config.json +++ b/modules/route/back/model-config.json @@ -5,18 +5,22 @@ "AgencyTermConfig": { "dataSource": "vn" }, - "Route": { + "DeliveryPoint": { "dataSource": "vn" }, - "Vehicle": { + "ExpeditionTruck": { + "dataSource": "vn" + }, + "Roadmap": { + "dataSource": "vn" + }, + "Route": { "dataSource": "vn" }, "RouteLog": { "dataSource": "vn" }, - "DeliveryPoint": { + "Vehicle": { "dataSource": "vn" } } - - diff --git a/modules/route/back/models/expedition-truck.json b/modules/route/back/models/expedition-truck.json new file mode 100644 index 000000000..8edc7347f --- /dev/null +++ b/modules/route/back/models/expedition-truck.json @@ -0,0 +1,43 @@ +{ + "name": "ExpeditionTruck", + "base": "VnModel", + "options": { + "mysql": { + "table": "expeditionTruck" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "roadmapFk": { + "type": "number" + }, + "warehouseFk": { + "type": "number" + }, + "eta": { + "type": "date" + }, + "description": { + "type": "string" + }, + "userFk": { + "type": "number" + } + }, + "relations": { + "roadmap": { + "type": "belongsTo", + "model": "Roadmap", + "foreignKey": "roadmapFk" + }, + "warehouse": { + "type": "belongsTo", + "model": "Warehouse", + "foreignKey": "warehouseFk" + } + } +} diff --git a/modules/route/back/models/roadmap.js b/modules/route/back/models/roadmap.js new file mode 100644 index 000000000..4a2a02022 --- /dev/null +++ b/modules/route/back/models/roadmap.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/roadmap/clone')(Self); +}; diff --git a/modules/route/back/models/roadmap.json b/modules/route/back/models/roadmap.json new file mode 100644 index 000000000..7ca8fe0f6 --- /dev/null +++ b/modules/route/back/models/roadmap.json @@ -0,0 +1,63 @@ +{ + "name": "Roadmap", + "base": "VnModel", + "options": { + "mysql": { + "table": "roadmap" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string" + }, + "tractorPlate": { + "type": "string" + }, + "trailerPlate": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "supplierFk": { + "type": "number" + }, + "etd": { + "type": "date" + }, + "observations": { + "type": "string" + }, + "userFk": { + "type": "number" + }, + "price": { + "type": "number" + }, + "driverName": { + "type": "string" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "userFk" + }, + "supplier": { + "type": "belongsTo", + "model": "Supplier", + "foreignKey": "supplierFk" + }, + "expeditionTruck": { + "type": "hasMany", + "model": "ExpeditionTruck", + "foreignKey": "roadmapFk" + } + } +} diff --git a/modules/route/front/index.js b/modules/route/front/index.js index c43048df5..803fc1045 100644 --- a/modules/route/front/index.js +++ b/modules/route/front/index.js @@ -16,3 +16,4 @@ import './agency-term/createInvoiceIn'; import './agency-term-search-panel'; import './ticket-popup'; import './sms'; +import './roadmap'; diff --git a/modules/route/front/roadmap/basic-data/index.html b/modules/route/front/roadmap/basic-data/index.html new file mode 100644 index 000000000..28c67eb47 --- /dev/null +++ b/modules/route/front/roadmap/basic-data/index.html @@ -0,0 +1,98 @@ + + + +
+ + + + + + + + + + + + + + + + + + + {{::id}} - {{::nickname}} + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/modules/route/front/roadmap/basic-data/index.js b/modules/route/front/roadmap/basic-data/index.js new file mode 100644 index 000000000..d5b39b76e --- /dev/null +++ b/modules/route/front/roadmap/basic-data/index.js @@ -0,0 +1,16 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + onSubmit() { + this.$.watcher.submit(); + } +} + +ngModule.component('vnRoadmapBasicData', { + template: require('./index.html'), + controller: Controller, + bindings: { + roadmap: '<' + } +}); diff --git a/modules/route/front/roadmap/card/index.html b/modules/route/front/roadmap/card/index.html new file mode 100644 index 000000000..97ca40f95 --- /dev/null +++ b/modules/route/front/roadmap/card/index.html @@ -0,0 +1,5 @@ + + + + + diff --git a/modules/route/front/roadmap/card/index.js b/modules/route/front/roadmap/card/index.js new file mode 100644 index 000000000..ff2d13616 --- /dev/null +++ b/modules/route/front/roadmap/card/index.js @@ -0,0 +1,19 @@ +import ngModule from '../../module'; +import ModuleCard from 'salix/components/module-card'; + +class Controller extends ModuleCard { + reload() { + const filter = { + include: [ + {relation: 'supplier'} + ] + }; + this.$http.get(`Roadmaps/${this.$params.id}`, {filter}) + .then(res => this.roadmap = res.data); + } +} + +ngModule.vnComponent('vnRoadmapCard', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/route/front/roadmap/create/index.html b/modules/route/front/roadmap/create/index.html new file mode 100644 index 000000000..f5a26566e --- /dev/null +++ b/modules/route/front/roadmap/create/index.html @@ -0,0 +1,37 @@ + + +
+ + + + + + + + + + + + + + + + +
diff --git a/modules/route/front/roadmap/create/index.js b/modules/route/front/roadmap/create/index.js new file mode 100644 index 000000000..7e638da94 --- /dev/null +++ b/modules/route/front/roadmap/create/index.js @@ -0,0 +1,23 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; +import './style.scss'; + +class Controller extends Section { + constructor($element, $, $transclude, vnReport, vnEmail) { + super($element, $, $transclude); + this.roadmap = {etd: Date.vnNew()}; + } + + onSubmit() { + this.$.watcher.submit().then( + res => this.$state.go('route.roadmap.card.summary', {id: res.data.id}) + ); + } +} + +Controller.$inject = ['$element', '$scope']; + +ngModule.vnComponent('vnRoadmapCreate', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/route/front/roadmap/create/style.scss b/modules/route/front/roadmap/create/style.scss new file mode 100644 index 000000000..8ee7ecb09 --- /dev/null +++ b/modules/route/front/roadmap/create/style.scss @@ -0,0 +1,6 @@ +vn-ticket-request { + .vn-textfield { + margin: 0!important; + max-width: 100px; + } +} diff --git a/modules/route/front/roadmap/descriptor/index.html b/modules/route/front/roadmap/descriptor/index.html new file mode 100644 index 000000000..92ae8eab1 --- /dev/null +++ b/modules/route/front/roadmap/descriptor/index.html @@ -0,0 +1,39 @@ + + + + Delete roadmap + + + +
+ + + + + + + {{$ctrl.roadmap.supplier.nickname}} + + +
+
+
+ + + + diff --git a/modules/route/front/roadmap/descriptor/index.js b/modules/route/front/roadmap/descriptor/index.js new file mode 100644 index 000000000..2846b073a --- /dev/null +++ b/modules/route/front/roadmap/descriptor/index.js @@ -0,0 +1,26 @@ +import ngModule from '../../module'; +import Descriptor from 'salix/components/descriptor'; + +class Controller extends Descriptor { + get roadmap() { + return this.entity; + } + + set roadmap(value) { + this.entity = value; + } + + onDelete() { + return this.$http.delete(`Roadmaps/${this.roadmap.id}`) + .then(() => this.$state.go('route.roadmap')) + .then(() => this.vnApp.showSuccess(this.$t('Roadmap removed'))); + } +} + +ngModule.component('vnRoadmapDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + roadmap: '<' + } +}); diff --git a/modules/route/front/roadmap/descriptor/locale/es.yml b/modules/route/front/roadmap/descriptor/locale/es.yml new file mode 100644 index 000000000..376209694 --- /dev/null +++ b/modules/route/front/roadmap/descriptor/locale/es.yml @@ -0,0 +1,3 @@ +Delete roadmap: Eliminar troncal +The roadmap will be removed: La troncal será eliminada +Roadmap removed: Troncal eliminada diff --git a/modules/route/front/roadmap/index.js b/modules/route/front/roadmap/index.js new file mode 100644 index 000000000..91b782a9b --- /dev/null +++ b/modules/route/front/roadmap/index.js @@ -0,0 +1,9 @@ +import './main'; +import './index/'; +import './summary'; +import './card'; +import './descriptor'; +import './create'; +import './basic-data'; +import './search-panel'; +import './stops'; diff --git a/modules/route/front/roadmap/index/index.html b/modules/route/front/roadmap/index/index.html new file mode 100644 index 000000000..6f8cbecc4 --- /dev/null +++ b/modules/route/front/roadmap/index/index.html @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + Roadmap + ETD + Carrier + Plate + Price + Observations + + + + + + + + + + {{::roadmap.name}} + {{::roadmap.etd | date:'dd/MM/yyyy HH:mm'}} + + + {{::roadmap.supplier.nickname}} + + + {{::roadmap.tractorPlate | dashIfEmpty}} + {{::roadmap.price | currency: 'EUR':2 | dashIfEmpty}} + {{::roadmap.observations | dashIfEmpty}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/route/front/roadmap/index/index.js b/modules/route/front/roadmap/index/index.js new file mode 100644 index 000000000..3ffc5b4b1 --- /dev/null +++ b/modules/route/front/roadmap/index/index.js @@ -0,0 +1,62 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +class Controller extends Section { + get checked() { + const roadmaps = this.$.model.data || []; + const checkedRoadmap = []; + for (let roadmap of roadmaps) { + if (roadmap.checked) + checkedRoadmap.push(roadmap); + } + + return checkedRoadmap; + } + + get totalChecked() { + return this.checked.length; + } + + preview(roadmap) { + this.roadmapSelected = roadmap; + this.$.summary.show(); + } + + openClonationDialog() { + this.$.clonationDialog.show(); + this.etd = Date.vnNew(); + } + + cloneSelectedRoadmaps() { + try { + if (!this.etd) + throw new Error(`The date can't be empty`); + + const roadmapsIds = []; + for (let roadmap of this.checked) + roadmapsIds.push(roadmap.id); + + return this.$http.post('Roadmaps/clone', {ids: roadmapsIds, etd: this.etd}).then(() => { + this.$.model.refresh(); + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + } + } + + deleteRoadmaps() { + console.log(this.checked); + + for (const roadmap of this.checked) { + this.$http.delete(`Roadmaps/${roadmap.id}`) + .then(() => this.$.model.refresh()) + .then(() => this.vnApp.showSuccess(this.$t('Roadmaps removed'))); + } + } +} + +ngModule.vnComponent('vnRoadmapIndex', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/route/front/roadmap/index/locale/es.yml b/modules/route/front/roadmap/index/locale/es.yml new file mode 100644 index 000000000..dd93eac6e --- /dev/null +++ b/modules/route/front/roadmap/index/locale/es.yml @@ -0,0 +1,3 @@ +Delete roadmap(s): Eliminar troncal(es) +Selected roadmaps will be removed: Los troncales seleccionados serán eliminados +Roadmaps removed: Troncales eliminados diff --git a/modules/route/front/roadmap/locale/es.yml b/modules/route/front/roadmap/locale/es.yml new file mode 100644 index 000000000..e136eca31 --- /dev/null +++ b/modules/route/front/roadmap/locale/es.yml @@ -0,0 +1,14 @@ +Roadmaps: Troncales +Roadmap: Troncal +Driver name: Nombre conductor +Plate: Matrícula +Price: Precio +Observations: Observaciones +Clone selected roadmaps: Clonar troncales seleccionadas +Select the estimated time of departure (ETD): Seleccione la hora estimada de salida (ETD) +Create roadmap: Crear troncal +Tractor plate: Matrícula tractor +Trailer plate: Matrícula trailer +Carrier: Transportista +ETD date: Fecha ETD +ETD hour: Hora ETD diff --git a/modules/route/front/roadmap/main/index.html b/modules/route/front/roadmap/main/index.html new file mode 100644 index 000000000..3a8eb2599 --- /dev/null +++ b/modules/route/front/roadmap/main/index.html @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/modules/route/front/roadmap/main/index.js b/modules/route/front/roadmap/main/index.js new file mode 100644 index 000000000..e7b3366f2 --- /dev/null +++ b/modules/route/front/roadmap/main/index.js @@ -0,0 +1,61 @@ +import ngModule from '../../module'; +import ModuleMain from 'salix/components/module-main'; + +export default class Roadmap extends ModuleMain { + constructor($element, $) { + super($element, $); + + this.include = { + relation: 'supplier', + scope: { + fields: ['nickname'] + } + }; + } + + $postLink() { + const from = Date.vnNew(); + from.setHours(0, 0, 0, 0); + + const to = Date.vnNew(); + to.setHours(23, 59, 59, 999); + + this.filterParams = { + from: from, + to: to + }; + + this.$.model.addFilter({where: { + and: [ + {etd: {gte: from}}, + {etd: {lte: to}} + ] + }}); + } + + exprBuilder(param, value) { + switch (param) { + case 'search': + return /^\d+$/.test(value) + ? {id: value} + : {name: {like: `%${value}%`}}; + case 'from': + return {etd: {gte: value}}; + case 'to': + return {etd: {lte: value}}; + case 'supplierFk': + case 'price': + return {[param]: value}; + case 'tractorPlate': + case 'trailerPlate': + case 'phone': + case 'driverName': + return {[param]: {like: `%${value}%`}}; + } + } +} + +ngModule.vnComponent('vnRoadmap', { + controller: Roadmap, + template: require('./index.html') +}); diff --git a/modules/route/front/roadmap/main/locale/es.yml b/modules/route/front/roadmap/main/locale/es.yml new file mode 100644 index 000000000..78342bce8 --- /dev/null +++ b/modules/route/front/roadmap/main/locale/es.yml @@ -0,0 +1 @@ +Search roadmap by id or trunk: Buscar troncales por id o troncal diff --git a/modules/route/front/roadmap/search-panel/index.html b/modules/route/front/roadmap/search-panel/index.html new file mode 100644 index 000000000..53fd37344 --- /dev/null +++ b/modules/route/front/roadmap/search-panel/index.html @@ -0,0 +1,74 @@ +
+
+ + + + +
+ + + + + + +
+ + + + + + + + + + {{::id}} - {{::nickname}} + + + + + + + + + + + + + + +
+
diff --git a/modules/route/front/roadmap/search-panel/index.js b/modules/route/front/roadmap/search-panel/index.js new file mode 100644 index 000000000..499027d14 --- /dev/null +++ b/modules/route/front/roadmap/search-panel/index.js @@ -0,0 +1,7 @@ +import ngModule from '../../module'; +import SearchPanel from 'core/components/searchbar/search-panel'; + +ngModule.component('vnRoadmapSearchPanel', { + template: require('./index.html'), + controller: SearchPanel +}); diff --git a/modules/route/front/roadmap/stops/index.html b/modules/route/front/roadmap/stops/index.html new file mode 100644 index 000000000..b69492a21 --- /dev/null +++ b/modules/route/front/roadmap/stops/index.html @@ -0,0 +1,71 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/modules/route/front/roadmap/stops/index.js b/modules/route/front/roadmap/stops/index.js new file mode 100644 index 000000000..075a1c8a4 --- /dev/null +++ b/modules/route/front/roadmap/stops/index.js @@ -0,0 +1,39 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + add() { + const filter = { + fields: ['etd'] + }; + this.$http.get(`Roadmaps/${this.$params.id}`, {filter}) + .then(res => { + this.roadmap = res.data; + + const eta = new Date(this.roadmap.etd); + eta.setDate(eta.getDate() + 1); + + this.$.model.insert({ + roadmapFk: this.$params.id, + eta: eta + }); + }); + } + + onSubmit() { + this.$.watcher.check(); + this.$.model.save().then(() => { + this.$.watcher.notifySaved(); + this.$.watcher.updateOriginalData(); + this.$.model.refresh(); + }); + } +} + +ngModule.component('vnRoadmapStops', { + template: require('./index.html'), + controller: Controller, + bindings: { + roadmap: '<' + } +}); diff --git a/modules/route/front/roadmap/stops/locale/es.yml b/modules/route/front/roadmap/stops/locale/es.yml new file mode 100644 index 000000000..1db275949 --- /dev/null +++ b/modules/route/front/roadmap/stops/locale/es.yml @@ -0,0 +1,4 @@ +Remove stop: Eliminar parada +Add stop: Añadir parada +ETA date: Fecha ETA +ETA hour: Hora ETA diff --git a/modules/route/front/roadmap/summary/index.html b/modules/route/front/roadmap/summary/index.html new file mode 100644 index 000000000..e6b50601e --- /dev/null +++ b/modules/route/front/roadmap/summary/index.html @@ -0,0 +1,113 @@ + +
+ {{summary.id}} - {{summary.name}} +
+ + + + + {{summary.supplier.nickname}} + + + + + + + + + + + + + + + + + + +

+ + Stops + + + +

+ + + + Wharehouse + ETA + + + + + {{expeditionTruck.warehouse.name}} + {{expeditionTruck.eta | date:'dd/MM/yyyy HH:mm'}} + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/route/front/roadmap/summary/index.js b/modules/route/front/roadmap/summary/index.js new file mode 100644 index 000000000..041b43ce3 --- /dev/null +++ b/modules/route/front/roadmap/summary/index.js @@ -0,0 +1,68 @@ +import ngModule from '../../module'; +import Component from 'core/lib/component'; +import './style.scss'; + +class Controller extends Component { + set roadmap(value) { + this._roadmap = value; + this.$.summary = null; + if (!value) return; + + this.loadData(); + } + + get roadmap() { + return this._roadmap; + } + + loadData() { + const filter = { + include: [ + {relation: 'supplier'}, + {relation: 'worker'}, + {relation: 'expeditionTruck', + scope: { + include: [ + {relation: 'warehouse'} + ] + }} + ] + }; + this.$http.get(`Roadmaps/${this.roadmap.id}`, {filter}) + .then(res => this.$.summary = res.data); + } + + getETD() { + const eta = new Date(this.roadmap.etd); + eta.setDate(eta.getDate() + 1); + + this.expeditionTruck = {eta: eta}; + } + + onAddAccept() { + try { + const data = { + roadmapFk: this.roadmap.id, + warehouseFk: this.expeditionTruck.warehouseFk, + eta: this.expeditionTruck.eta, + description: this.expeditionTruck.description + }; + + this.$http.post(`ExpeditionTrucks`, data) + .then(() => { + this.loadData(); + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + } catch (e) { + this.vnApp.showError(this.$t(e.message)); + } + } +} + +ngModule.component('vnRoadmapSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + roadmap: '<' + } +}); diff --git a/modules/route/front/roadmap/summary/locale/es.yml b/modules/route/front/roadmap/summary/locale/es.yml new file mode 100644 index 000000000..f2d82438a --- /dev/null +++ b/modules/route/front/roadmap/summary/locale/es.yml @@ -0,0 +1,3 @@ +Stops: Paradas +Wharehouse: Almacén +You must fill all the fields: Debes rellenar todos los campos diff --git a/modules/route/front/roadmap/summary/style.scss b/modules/route/front/roadmap/summary/style.scss new file mode 100644 index 000000000..8e75d3e0b --- /dev/null +++ b/modules/route/front/roadmap/summary/style.scss @@ -0,0 +1,11 @@ +@import "variables"; + + +vn-roadmap-summary .summary { + a { + display: flex; + align-items: center; + height: 18.328px; + } + +} diff --git a/modules/route/front/routes.json b/modules/route/front/routes.json index 75e1fdc57..3b866581d 100644 --- a/modules/route/front/routes.json +++ b/modules/route/front/routes.json @@ -7,12 +7,17 @@ "menus": { "main": [ {"state": "route.index", "icon": "icon-delivery"}, - {"state": "route.agencyTerm.index", "icon": "icon-agency-term"} + {"state": "route.agencyTerm.index", "icon": "icon-agency-term"}, + {"state": "route.roadmap", "icon": "icon-trailer"} ], "card": [ {"state": "route.card.basicData", "icon": "settings"}, {"state": "route.card.tickets", "icon": "icon-ticket"}, {"state": "route.card.log", "icon": "history"} + ], + "roadmap": [ + {"state": "route.roadmap.card.basicData", "icon": "settings"}, + {"state": "route.roadmap.card.stops", "icon": "icon-lines"} ] }, "routes": [ @@ -90,6 +95,46 @@ "route": "$ctrl.route" }, "acl": ["delivery"] + }, { + "url": "/roadmap?q", + "state": "route.roadmap", + "component": "vn-roadmap", + "description": "Roadmaps" + }, { + "url": "/create", + "state": "route.roadmap.create", + "component": "vn-roadmap-create", + "description": "Create roadmap" + },{ + "url": "/:id", + "state": "route.roadmap.card", + "component": "vn-roadmap-card", + "abstract": true, + "description": "Detail" + },{ + "url": "/summary", + "state": "route.roadmap.card.summary", + "component": "vn-roadmap-summary", + "description": "Summary", + "params": { + "roadmap": "$ctrl.roadmap" + } + },{ + "url": "/basic-data", + "state": "route.roadmap.card.basicData", + "component": "vn-roadmap-basic-data", + "description": "Basic data", + "params": { + "roadmap": "$ctrl.roadmap" + } + }, { + "url": "/stops", + "state": "route.roadmap.card.stops", + "component": "vn-roadmap-stops", + "description": "Stops", + "params": { + "route": "$ctrl.roadmap" + } } ] } diff --git a/modules/shelving/front/descriptor/index.html b/modules/shelving/front/descriptor/index.html index 1344bb52a..53dd37258 100644 --- a/modules/shelving/front/descriptor/index.html +++ b/modules/shelving/front/descriptor/index.html @@ -7,7 +7,7 @@ ng-click="deleteShelving.show()" name="deleteShelving" translate> - Delete + Delete shelving @@ -32,7 +32,7 @@ @@ -40,6 +40,6 @@ - - \ No newline at end of file + diff --git a/modules/shelving/front/descriptor/locale/es.yml b/modules/shelving/front/descriptor/locale/es.yml new file mode 100644 index 000000000..e7fafc320 --- /dev/null +++ b/modules/shelving/front/descriptor/locale/es.yml @@ -0,0 +1,3 @@ +Delete shelving: Eliminar carro +Shelving will be removed: El carro será eliminado +Shelving removed: Carro eliminado diff --git a/modules/worker/front/create/index.html b/modules/worker/front/create/index.html index eb45704a7..481746761 100644 --- a/modules/worker/front/create/index.html +++ b/modules/worker/front/create/index.html @@ -38,7 +38,7 @@ Date: Tue, 4 Jul 2023 15:04:32 +0200 Subject: [PATCH 18/91] refs #4770 feat: add test --- .../back/methods/roadmap/specs/clone.spec.js | 109 ++++++++++++++++++ .../route/front/roadmap/card/index.spec.js | 27 +++++ .../route/front/roadmap/create/index.spec.js | 107 +++++++++++++++++ .../route/front/roadmap/index/index.spec.js | 94 +++++++++++++++ .../route/front/roadmap/main/index.spec.js | 31 +++++ 5 files changed, 368 insertions(+) create mode 100644 modules/route/back/methods/roadmap/specs/clone.spec.js create mode 100644 modules/route/front/roadmap/card/index.spec.js create mode 100644 modules/route/front/roadmap/create/index.spec.js create mode 100644 modules/route/front/roadmap/index/index.spec.js create mode 100644 modules/route/front/roadmap/main/index.spec.js diff --git a/modules/route/back/methods/roadmap/specs/clone.spec.js b/modules/route/back/methods/roadmap/specs/clone.spec.js new file mode 100644 index 000000000..41e696157 --- /dev/null +++ b/modules/route/back/methods/roadmap/specs/clone.spec.js @@ -0,0 +1,109 @@ +const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; + +describe('AgencyTerm filter()', () => { + const authUserId = 9; + const today = Date.vnNew(); + today.setHours(2, 0, 0, 0); + + it('should return all results matching the filter', async() => { + const tx = await models.AgencyTerm.beginTransaction({}); + + try { + const options = {transaction: tx}; + const filter = {}; + const ctx = {req: {accessToken: {userId: authUserId}}}; + + const agencyTerms = await models.AgencyTerm.filter(ctx, filter, options); + const firstAgencyTerm = agencyTerms[0]; + + expect(firstAgencyTerm.routeFk).toEqual(1); + expect(agencyTerms.length).toEqual(5); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return results matching "search" searching by integer', async() => { + let ctx = { + args: { + search: 1, + } + }; + + let result = await app.models.AgencyTerm.filter(ctx); + + expect(result.length).toEqual(1); + expect(result[0].routeFk).toEqual(1); + }); + + it('should return results matching "search" searching by string', async() => { + let ctx = { + args: { + search: 'Plants SL', + } + }; + + let result = await app.models.AgencyTerm.filter(ctx); + + expect(result.length).toEqual(2); + }); + + it('should return results matching "from" and "to"', async() => { + const tx = await models.Buy.beginTransaction({}); + const options = {transaction: tx}; + + try { + const from = Date.vnNew(); + from.setHours(0, 0, 0, 0); + + const to = Date.vnNew(); + to.setHours(23, 59, 59, 999); + + const ctx = { + args: { + from: from, + to: to + } + }; + + const results = await models.AgencyTerm.filter(ctx, options); + + expect(results.length).toBe(5); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return results matching "agencyModeFk"', async() => { + let ctx = { + args: { + agencyModeFk: 1, + } + }; + + let result = await app.models.AgencyTerm.filter(ctx); + + expect(result.length).toEqual(1); + expect(result[0].routeFk).toEqual(1); + }); + + it('should return results matching "agencyFk"', async() => { + let ctx = { + args: { + agencyFk: 2, + } + }; + + let result = await app.models.AgencyTerm.filter(ctx); + + expect(result.length).toEqual(1); + expect(result[0].routeFk).toEqual(2); + }); +}); diff --git a/modules/route/front/roadmap/card/index.spec.js b/modules/route/front/roadmap/card/index.spec.js new file mode 100644 index 000000000..ab2314bb9 --- /dev/null +++ b/modules/route/front/roadmap/card/index.spec.js @@ -0,0 +1,27 @@ +import './index'; + +describe('component vnItemTypeCard', () => { + let controller; + let $httpBackend; + + beforeEach(ngModule('item')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnItemTypeCard', {$element: null}); + })); + + describe('reload()', () => { + it('should reload the controller data', () => { + controller.$params.id = 1; + + const itemType = {id: 1}; + + $httpBackend.expectGET('ItemTypes/1').respond(itemType); + controller.reload(); + $httpBackend.flush(); + + expect(controller.itemType).toEqual(itemType); + }); + }); +}); diff --git a/modules/route/front/roadmap/create/index.spec.js b/modules/route/front/roadmap/create/index.spec.js new file mode 100644 index 000000000..d6d9883a7 --- /dev/null +++ b/modules/route/front/roadmap/create/index.spec.js @@ -0,0 +1,107 @@ +import './index'; +import watcher from 'core/mocks/watcher.js'; + +describe('AgencyTerm', () => { + describe('Component vnAgencyTermCreateInvoiceIn', () => { + let controller; + let $scope; + let $httpBackend; + let $httpParamSerializer; + + beforeEach(ngModule('route')); + + beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + $scope = $rootScope.$new(); + $httpBackend = _$httpBackend_; + $httpParamSerializer = _$httpParamSerializer_; + const $element = angular.element(''); + controller = $componentController('vnAgencyTermCreateInvoiceIn', {$element}); + controller._route = { + id: 1 + }; + })); + + describe('$onChanges()', () => { + it('should update the params data when $params.q is defined', () => { + controller.$params = {q: '{"supplierName": "Plants SL","rows": null}'}; + + const params = {q: '{"supplierName": "Plants SL", "rows": null}'}; + const json = JSON.parse(params.q); + + controller.$onChanges(); + + expect(controller.params).toEqual(json); + }); + }); + + describe('route() setter', () => { + it('should set the ticket data and then call setDefaultParams() and getAllowedContentTypes()', () => { + jest.spyOn(controller, 'setDefaultParams'); + jest.spyOn(controller, 'getAllowedContentTypes'); + controller.route = { + id: 1 + }; + + expect(controller.route).toBeDefined(); + expect(controller.setDefaultParams).toHaveBeenCalledWith(); + expect(controller.getAllowedContentTypes).toHaveBeenCalledWith(); + }); + }); + + describe('getAllowedContentTypes()', () => { + it('should make an HTTP GET request to get the allowed content types', () => { + const expectedResponse = ['image/png', 'image/jpg']; + $httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond(expectedResponse); + controller.getAllowedContentTypes(); + $httpBackend.flush(); + + expect(controller.allowedContentTypes).toBeDefined(); + expect(controller.allowedContentTypes).toEqual('image/png, image/jpg'); + }); + }); + + describe('setDefaultParams()', () => { + it('should perform a GET query and define the dms property on controller', () => { + const params = {filter: { + where: {code: 'invoiceIn'} + }}; + const serializedParams = $httpParamSerializer(params); + $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 1, code: 'invoiceIn'}); + controller.params = {supplierName: 'Plants SL'}; + controller.setDefaultParams(); + $httpBackend.flush(); + + expect(controller.dms).toBeDefined(); + expect(controller.dms.dmsTypeId).toEqual(1); + }); + }); + + describe('onSubmit()', () => { + it('should make an HTTP POST request to save the form data', () => { + controller.$.watcher = watcher; + + jest.spyOn(controller.$.watcher, 'updateOriginalData'); + const files = [{id: 1, name: 'MyFile'}]; + controller.dms = {files}; + const serializedParams = $httpParamSerializer(controller.dms); + const query = `dms/uploadFile?${serializedParams}`; + controller.params = {rows: null}; + + $httpBackend.expect('POST', query).respond({}); + $httpBackend.expect('POST', 'AgencyTerms/createInvoiceIn').respond({}); + controller.onSubmit(); + $httpBackend.flush(); + }); + }); + + describe('onFileChange()', () => { + it('should set dms hasFileAttached property to true if has any files', () => { + const files = [{id: 1, name: 'MyFile'}]; + controller.onFileChange(files); + $scope.$apply(); + + expect(controller.dms.hasFileAttached).toBeTruthy(); + }); + }); + }); +}); diff --git a/modules/route/front/roadmap/index/index.spec.js b/modules/route/front/roadmap/index/index.spec.js new file mode 100644 index 000000000..55c40daa5 --- /dev/null +++ b/modules/route/front/roadmap/index/index.spec.js @@ -0,0 +1,94 @@ +import './index.js'; +import crudModel from 'core/mocks/crud-model'; + +describe('AgencyTerm', () => { + describe('Component vnAgencyTermIndex', () => { + let controller; + let $window; + + beforeEach(ngModule('route')); + + beforeEach(inject(($componentController, _$window_) => { + $window = _$window_; + const $element = angular.element(''); + controller = $componentController('vnAgencyTermIndex', {$element}); + controller.$.model = crudModel; + controller.$.model.data = [ + {supplierFk: 1, totalPrice: null}, + {supplierFk: 1}, + {supplierFk: 2} + ]; + })); + + describe('checked() getter', () => { + it('should return the checked lines', () => { + const data = controller.$.model.data; + data[0].checked = true; + + const checkedRows = controller.checked; + + const firstCheckedRow = checkedRows[0]; + + expect(firstCheckedRow.supplierFk).toEqual(1); + }); + }); + + describe('totalCheked() getter', () => { + it('should return the total checked lines', () => { + const data = controller.$.model.data; + data[0].checked = true; + + const checkedRows = controller.totalChecked; + + expect(checkedRows).toEqual(1); + }); + }); + + describe('preview()', () => { + it('should show the summary dialog', () => { + controller.$.summary = {show: () => {}}; + jest.spyOn(controller.$.summary, 'show'); + + let event = new MouseEvent('click', { + view: $window, + bubbles: true, + cancelable: true + }); + const route = {id: 1}; + + controller.preview(event, route); + + expect(controller.$.summary.show).toHaveBeenCalledWith(); + }); + }); + + describe('createInvoiceIn()', () => { + it('should throw an error if more than one autonomous are checked', () => { + jest.spyOn(controller.vnApp, 'showError'); + const data = controller.$.model.data; + data[0].checked = true; + data[2].checked = true; + + controller.createInvoiceIn(); + + expect(controller.vnApp.showError).toHaveBeenCalled(); + }); + + it('should call the function go() on $state to go to the file management', () => { + jest.spyOn(controller.$state, 'go'); + const data = controller.$.model.data; + data[0].checked = true; + + controller.createInvoiceIn(); + + delete data[0].checked; + const params = JSON.stringify({ + supplierName: data[0].supplierName, + rows: [data[0]] + }); + + expect(controller.$state.go).toHaveBeenCalledWith('route.agencyTerm.createInvoiceIn', {q: params}); + }); + }); + }); +}); diff --git a/modules/route/front/roadmap/main/index.spec.js b/modules/route/front/roadmap/main/index.spec.js new file mode 100644 index 000000000..dcb14ec0e --- /dev/null +++ b/modules/route/front/roadmap/main/index.spec.js @@ -0,0 +1,31 @@ +import './index'; + +describe('Item', () => { + describe('Component vnItemType', () => { + let controller; + + beforeEach(ngModule('item')); + + beforeEach(inject($componentController => { + const $element = angular.element(''); + controller = $componentController('vnItemType', {$element}); + })); + + describe('exprBuilder()', () => { + it('should return a filter based on a search by id', () => { + const filter = controller.exprBuilder('search', '123'); + + expect(filter).toEqual({id: '123'}); + }); + + it('should return a filter based on a search by name or code', () => { + const filter = controller.exprBuilder('search', 'Alstroemeria'); + + expect(filter).toEqual({or: [ + {name: {like: '%Alstroemeria%'}}, + {code: {like: '%Alstroemeria%'}}, + ]}); + }); + }); + }); +}); From 1a18ba66a940959bdae82335289ccd1a39a1fac8 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 4 Jul 2023 15:18:57 +0200 Subject: [PATCH 19/91] refs #5712 fix(workerDms): filter --- back/models/docuware.json | 7 +++++++ modules/worker/back/methods/worker-dms/filter.js | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/back/models/docuware.json b/back/models/docuware.json index dec20eede..b1a6a8bce 100644 --- a/back/models/docuware.json +++ b/back/models/docuware.json @@ -28,5 +28,12 @@ "findById": { "type": "string" } + }, + "relations": { + "dmsType": { + "type": "belongsTo", + "model": "DmsType", + "foreignKey": "dmsTypeFk" + } } } diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index 1343038b7..e19010988 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -62,22 +62,25 @@ module.exports = Self => { where: {code: 'hr', action: 'find'} }); const docuwareDmsType = docuware.dmsTypeFk; + let workerDocuware; if (!(docuwareDmsType && !await models.DmsType.hasReadRole(ctx, docuwareDmsType))) { const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); const docuwareParse = { 'Filename': 'dmsFk', 'Tipo Documento': 'description', 'Stored on': 'created', + 'Document ID': 'id' }; - const workerDocuware = + workerDocuware = await models.Docuware.getById('hr', worker.lastName + worker.firstName, docuwareParse); for (document of workerDocuware) { const defaultData = { - file: document.dmsFk + '.png', + file: 'dw' + document.id + '.png', isDocuware: true, hardCopyNumber: null, hasFile: false, - reference: worker.fi + reference: worker.fi, + dmsFk: 'DW' + document.id }; document = Object.assign(document, defaultData); From 444b08c566c18e0b716b38ff4f6f45b76116f921 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 5 Jul 2023 12:09:52 +0200 Subject: [PATCH 20/91] refs #5712 test(docuware) --- back/methods/docuware/checkFile.js | 15 +- back/methods/docuware/core.js | 18 ++- back/methods/docuware/specs/checkFile.spec.js | 74 ++-------- back/methods/docuware/specs/core.spec.js | 135 ++++++++++++++++++ back/methods/docuware/specs/download.spec.js | 2 +- db/changes/232801/00-workerDocuware.sql | 2 +- .../back/methods/ticket/docuwareDownload.js | 6 +- .../methods/worker-dms/docuwareDownload.js | 6 +- .../worker/back/methods/worker-dms/filter.js | 5 +- 9 files changed, 176 insertions(+), 87 deletions(-) create mode 100644 back/methods/docuware/specs/core.spec.js diff --git a/back/methods/docuware/checkFile.js b/back/methods/docuware/checkFile.js index 18d169085..19224057c 100644 --- a/back/methods/docuware/checkFile.js +++ b/back/methods/docuware/checkFile.js @@ -1,5 +1,3 @@ -const axios = require('axios'); - module.exports = Self => { Self.remoteMethod('checkFile', { description: 'Check if exist docuware file', @@ -73,17 +71,8 @@ module.exports = Self => { } try { - const options = await Self.getOptions(); - - const fileCabinetId = await Self.getFileCabinet(fileCabinet); - const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId); - - const response = await axios.post( - `${options.url}/FileCabinets/${fileCabinetId}/Query/DialogExpression?dialogId=${dialogId}`, - filter, - options.headers - ); - const [documents] = response.data.Items; + const response = await Self.get(fileCabinet, filter); + const [documents] = response.Items; if (!documents) return false; return {id: documents.Id}; diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 7bb3e617a..74d922236 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -32,10 +32,13 @@ module.exports = Self => { * @return {number} - The fileCabinet id */ Self.getDialog = async(code, action, fileCabinetId) => { + if (!process.env.NODE_ENV) + return Math.floor(Math.random() + 100); + const docuwareInfo = await Self.app.models.Docuware.findOne({ where: { - code: code, - action: action + code, + action } }); if (!fileCabinetId) fileCabinetId = await Self.getFileCabinet(code); @@ -56,10 +59,13 @@ module.exports = Self => { * @return {number} - The fileCabinet id */ Self.getFileCabinet = async code => { + if (!process.env.NODE_ENV) + return Math.floor(Math.random() + 100); + const options = await Self.getOptions(); const docuwareInfo = await Self.app.models.Docuware.findOne({ where: { - code: code + code } }); @@ -79,6 +85,8 @@ module.exports = Self => { * @return {object} - The data */ Self.get = async(code, filter, parse) => { + if (!process.env.NODE_ENV) return; + const options = await Self.getOptions(); const fileCabinetId = await Self.getFileCabinet(code); const dialogId = await Self.getDialog(code, 'find', fileCabinetId); @@ -100,10 +108,12 @@ module.exports = Self => { * @return {object} - The data */ Self.getById = async(code, id, parse) => { + if (!process.env.NODE_ENV) return; + const docuwareInfo = await Self.app.models.Docuware.findOne({ fields: ['findById'], where: { - code: code, + code, action: 'find' } }); diff --git a/back/methods/docuware/specs/checkFile.spec.js b/back/methods/docuware/specs/checkFile.spec.js index dd11951cc..8460bb561 100644 --- a/back/methods/docuware/specs/checkFile.spec.js +++ b/back/methods/docuware/specs/checkFile.spec.js @@ -1,57 +1,15 @@ const models = require('vn-loopback/server/server').models; -const axios = require('axios'); describe('docuware download()', () => { const ticketId = 1; - const userId = 9; - const ctx = { - req: { - - accessToken: {userId: userId}, - headers: {origin: 'http://localhost:5000'}, - } - }; const docuwareModel = models.Docuware; const fileCabinetName = 'deliveryNote'; - beforeAll(() => { - spyOn(docuwareModel, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random())))); - spyOn(docuwareModel, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random())))); - }); - it('should return false if there are no documents', async() => { - const response = { - data: { - Items: [] - } - }; - spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(response))); + spyOn(docuwareModel, 'get').and.returnValue((new Promise(resolve => resolve({Items: []})))); - const result = await models.Docuware.checkFile(ctx, ticketId, fileCabinetName, true); - - expect(result).toEqual(false); - }); - - it('should return false if the document is unsigned', async() => { - const response = { - data: { - Items: [ - { - Id: 1, - Fields: [ - { - FieldName: 'ESTADO', - Item: 'Unsigned' - } - ] - } - ] - } - }; - spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(response))); - - const result = await models.Docuware.checkFile(ctx, ticketId, fileCabinetName, true); + const result = await models.Docuware.checkFile(ticketId, fileCabinetName, null, true); expect(result).toEqual(false); }); @@ -59,23 +17,21 @@ describe('docuware download()', () => { it('should return the document data', async() => { const docuwareId = 1; const response = { - data: { - Items: [ - { - Id: docuwareId, - Fields: [ - { - FieldName: 'ESTADO', - Item: 'Firmado' - } - ] - } - ] - } + Items: [ + { + Id: docuwareId, + Fields: [ + { + FieldName: 'ESTADO', + Item: 'Firmado' + } + ] + } + ] }; - spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(response))); + spyOn(docuwareModel, 'get').and.returnValue((new Promise(resolve => resolve(response)))); - const result = await models.Docuware.checkFile(ctx, ticketId, fileCabinetName, true); + const result = await models.Docuware.checkFile(ticketId, fileCabinetName, null, true); expect(result.id).toEqual(docuwareId); }); diff --git a/back/methods/docuware/specs/core.spec.js b/back/methods/docuware/specs/core.spec.js new file mode 100644 index 000000000..cdf8a3b62 --- /dev/null +++ b/back/methods/docuware/specs/core.spec.js @@ -0,0 +1,135 @@ +const axios = require('axios'); +const models = require('vn-loopback/server/server').models; + +describe('Docuware core', () => { + beforeAll(() => { + process.env.NODE_ENV = 'testing'; + }); + + afterAll(() => { + delete process.env.NODE_ENV; + }); + + describe('getOptions()', () => { + it('should return url and headers', async() => { + const result = await models.Docuware.getOptions(); + + expect(result.url).toBeDefined(); + expect(result.headers).toBeDefined(); + }); + }); + + describe('getDialog()', () => { + it('should return dialogId', async() => { + const dialogs = { + data: { + Dialog: [ + { + DisplayName: 'find', + Id: 'getDialogTest' + } + ] + } + }; + spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(dialogs))); + const result = await models.Docuware.getDialog('deliveryNote', 'find', 'randomFileCabinetId'); + + expect(result).toEqual('getDialogTest'); + }); + }); + + describe('getFileCabinet()', () => { + it('should return fileCabinetId', async() => { + const code = 'deliveryNote'; + const docuwareInfo = await models.Docuware.findOne({ + where: { + code + } + }); + const dialogs = { + data: { + FileCabinet: [ + { + Name: docuwareInfo.fileCabinetName, + Id: 'getFileCabinetTest' + } + ] + } + }; + spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(dialogs))); + const result = await models.Docuware.getFileCabinet(code); + + expect(result).toEqual('getFileCabinetTest'); + }); + }); + + describe('get()', () => { + it('should return data without parse', async() => { + spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random())))); + spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random())))); + const data = { + data: { + id: 1 + } + }; + spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data))); + const result = await models.Docuware.get('deliveryNote'); + + expect(result.id).toEqual(1); + }); + + it('should return data with parse', async() => { + spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random())))); + spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random())))); + const data = { + data: { + Items: [{ + Fields: [ + { + ItemElementName: 'integer', + FieldLabel: 'firstRequiredField', + Item: 1 + }, + { + ItemElementName: 'string', + FieldLabel: 'secondRequiredField', + Item: 'myName' + }, + { + ItemElementName: 'integer', + FieldLabel: 'notRequiredField', + Item: 2 + } + ] + }] + } + }; + const parse = { + 'firstRequiredField': 'id', + 'secondRequiredField': 'name', + }; + spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data))); + const [result] = await models.Docuware.get('deliveryNote', null, parse); + + expect(result.id).toEqual(1); + expect(result.name).toEqual('myName'); + expect(result.notRequiredField).not.toBeDefined(); + }); + }); + + describe('getById()', () => { + it('should return data', async() => { + spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random())))); + spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random())))); + const data = { + data: { + id: 1 + } + }; + spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data))); + const result = await models.Docuware.getById('deliveryNote', 1); + + expect(result.id).toEqual(1); + }); + }); +}); diff --git a/back/methods/docuware/specs/download.spec.js b/back/methods/docuware/specs/download.spec.js index fcc1671a6..bc580a079 100644 --- a/back/methods/docuware/specs/download.spec.js +++ b/back/methods/docuware/specs/download.spec.js @@ -39,7 +39,7 @@ describe('docuware download()', () => { spyOn(docuwareModel, 'checkFile').and.returnValue({}); spyOn(axios, 'get').and.returnValue(new stream.PassThrough({objectMode: true})); - const result = await models.Docuware.download(ctx, ticketId, fileCabinetName); + const result = await models.Docuware.download(ticketId, fileCabinetName); expect(result[1]).toEqual('application/pdf'); expect(result[2]).toEqual(`filename="${ticketId}.pdf"`); diff --git a/db/changes/232801/00-workerDocuware.sql b/db/changes/232801/00-workerDocuware.sql index 2d0ce3c33..2f2c4a1cd 100644 --- a/db/changes/232801/00-workerDocuware.sql +++ b/db/changes/232801/00-workerDocuware.sql @@ -2,7 +2,7 @@ ALTER TABLE `vn`.`docuware` ADD dmsTypeFk INT(11) DEFAULT NULL NULL; ALTER TABLE `vn`.`docuware` ADD CONSTRAINT docuware_FK FOREIGN KEY (dmsTypeFk) REFERENCES `vn`.`dmsType`(id) ON DELETE RESTRICT ON UPDATE CASCADE; INSERT INTO `vn`.`docuware` (code, fileCabinetName, `action`, dialogName, findById, dmsTypeFk) VALUES - ('hr', 'RRHH', 'find', 'Búsqueda', 'N__DOCUMENTO', NULL); + ('hr', 'RRHH', 'find', 'Búsqueda', 'N__DOCUMENTO', NULL); -- set dmsTypeFk 3 when deploy in production INSERT INTO `salix`.`url` (appName, environment, url) VALUES diff --git a/modules/ticket/back/methods/ticket/docuwareDownload.js b/modules/ticket/back/methods/ticket/docuwareDownload.js index bc74e0d21..e9b74b1a9 100644 --- a/modules/ticket/back/methods/ticket/docuwareDownload.js +++ b/modules/ticket/back/methods/ticket/docuwareDownload.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('docuwareDownload', { + Self.remoteMethod('docuwareDownload', { description: 'Download a ticket delivery note document', accessType: 'READ', accepts: [ @@ -31,7 +31,7 @@ module.exports = Self => { } }); - Self.docuwareDownload = async function(ctx, id) { + Self.docuwareDownload = async id => { const filter = { condition: [ { @@ -50,6 +50,6 @@ module.exports = Self => { } ] }; - return await Self.app.models.Docuware.download(id, 'deliveryNote', filter); + return Self.app.models.Docuware.download(id, 'deliveryNote', filter); }; }; diff --git a/modules/worker/back/methods/worker-dms/docuwareDownload.js b/modules/worker/back/methods/worker-dms/docuwareDownload.js index 764b7633c..c64c159ed 100644 --- a/modules/worker/back/methods/worker-dms/docuwareDownload.js +++ b/modules/worker/back/methods/worker-dms/docuwareDownload.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('docuwareDownload', { + Self.remoteMethod('docuwareDownload', { description: 'Download a worker document', accessType: 'READ', accepts: [ @@ -31,7 +31,7 @@ module.exports = Self => { } }); - Self.docuwareDownload = async function(ctx, id) { + Self.docuwareDownload = async id => { const filter = { condition: [ { @@ -40,6 +40,6 @@ module.exports = Self => { } ] }; - return await Self.app.models.Docuware.download(id, 'hr', filter); + return Self.app.models.Docuware.download(id, 'hr', filter); }; }; diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index e19010988..55db68d5d 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -62,8 +62,8 @@ module.exports = Self => { where: {code: 'hr', action: 'find'} }); const docuwareDmsType = docuware.dmsTypeFk; - let workerDocuware; - if (!(docuwareDmsType && !await models.DmsType.hasReadRole(ctx, docuwareDmsType))) { + let workerDocuware = []; + if (!docuwareDmsType || (docuwareDmsType && await models.DmsType.hasReadRole(ctx, docuwareDmsType))) { const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); const docuwareParse = { 'Filename': 'dmsFk', @@ -86,7 +86,6 @@ module.exports = Self => { document = Object.assign(document, defaultData); } } - return workerDms.concat(workerDocuware); }; }; From 5d933da28af0c03b33095375748664c9424b7612 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 5 Jul 2023 12:14:26 +0200 Subject: [PATCH 21/91] refs #5712 fix empty data --- modules/worker/back/methods/worker-dms/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index 55db68d5d..5f55f1bd7 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -72,7 +72,7 @@ module.exports = Self => { 'Document ID': 'id' }; workerDocuware = - await models.Docuware.getById('hr', worker.lastName + worker.firstName, docuwareParse); + await models.Docuware.getById('hr', worker.lastName + worker.firstName, docuwareParse) ?? []; for (document of workerDocuware) { const defaultData = { file: 'dw' + document.id + '.png', From 7030be3efa7f0df9dd0fc9f0680a7147f17820ba Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 7 Jul 2023 09:30:04 +0200 Subject: [PATCH 22/91] fix --- front/core/services/token.js | 1 - modules/worker/back/models/worker.json | 8 -------- modules/worker/front/calendar/index.html | 2 +- modules/worker/front/card/index.js | 11 ++++++----- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/front/core/services/token.js b/front/core/services/token.js index c4b644a89..c16cc3c4f 100644 --- a/front/core/services/token.js +++ b/front/core/services/token.js @@ -83,7 +83,6 @@ export default class Token { this.renewPeriod = data.renewPeriod; this.stopRenewer(); this.inservalId = setInterval(() => this.checkValidity(), data.renewInterval * 1000); - this.checkValidity(); }); } diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 978d613e9..6d23c1b66 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -43,9 +43,6 @@ "SSN": { "type" : "string" }, - "labelerFk": { - "type" : "number" - }, "mobileExtension": { "type" : "number" }, @@ -86,11 +83,6 @@ "type": "hasMany", "model": "WorkerTeamCollegues", "foreignKey": "workerFk" - }, - "sector": { - "type": "belongsTo", - "model": "Sector", - "foreignKey": "sectorFk" } } } diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index ace2f4e27..877add57b 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -31,7 +31,7 @@
-
{{'Contract' | translate}} #{{$ctrl.card.worker.hasWorkCenter}}
+
{{'Contract' | translate}} #{{$ctrl.businessId}}
{{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed || 0}} {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index e1eb97327..35f331764 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -33,11 +33,12 @@ class Controller extends ModuleCard { }; this.$http.get(`Workers/${this.$params.id}`, {filter}) - .then(res => this.worker = res.data); - this.$http.get(`Workers/${this.$params.id}/activeContract`) - .then(res => { - if (res.data) this.worker.hasWorkCenter = res.data.workCenterFk; - }); + .then(res => this.worker = res.data) + .then(() => + this.$http.get(`Workers/${this.$params.id}/activeContract`) + .then(res => { + if (res.data) this.worker.hasWorkCenter = res.data.workCenterFk; + })); } } From 6fa6c21cb1c086ce7c23e0a9a5bae7fb3c0a3af1 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 7 Jul 2023 09:31:26 +0200 Subject: [PATCH 23/91] remove fixtures --- db/dump/fixtures.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 475a4992f..3de5f15ab 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -188,13 +188,13 @@ INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAd UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1; -INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`, `sectorFk`, `labelerFk`) +INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`) VALUES - (1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106, NULL, NULL), - (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107, NULL, NULL), - (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108, 1, NULL), - (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109, 1, NULL), - (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, NULL); + (1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106), + (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107), + (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108), + (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109), + (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110); INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) VALUES From 9f2ef5c2c0835237e621e28e4fba908bd2d6516c Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 10 Jul 2023 07:22:23 +0200 Subject: [PATCH 24/91] change ref master --- modules/travel/front/extra-community/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/travel/front/extra-community/index.html b/modules/travel/front/extra-community/index.html index c888f97da..8132bddb1 100644 --- a/modules/travel/front/extra-community/index.html +++ b/modules/travel/front/extra-community/index.html @@ -163,7 +163,7 @@ {{::entry.invoiceAmount | currency: 'EUR': 2}} - {{::entry.invoiceNumber}} + {{::entry.reference}} {{::entry.stickers}} {{::entry.loadedkg}} From d1c8f0ff11ef80c2769dec1f6e6ca8d6a7c620f0 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 11 Jul 2023 07:37:51 +0200 Subject: [PATCH 25/91] refs #5949 itemRecycle --- db/changes/233001/00-itemRecycle.sql | 2 + modules/item/back/methods/item/filter.js | 4 +- modules/item/back/models/item.json | 6 ++ modules/item/front/basic-data/index.html | 78 ++++++++++++++---------- modules/item/front/summary/index.html | 12 ++++ 5 files changed, 70 insertions(+), 32 deletions(-) create mode 100644 db/changes/233001/00-itemRecycle.sql diff --git a/db/changes/233001/00-itemRecycle.sql b/db/changes/233001/00-itemRecycle.sql new file mode 100644 index 000000000..c191e5d1c --- /dev/null +++ b/db/changes/233001/00-itemRecycle.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn`.`item` ADD recycledPlastic INT NULL; +ALTER TABLE `vn`.`item` ADD nonRecycledPlastic INT NULL; diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index c0b1cc0d9..d5de6a954 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -145,7 +145,7 @@ module.exports = Self => { const stmts = []; const stmt = new ParameterizedSQL( - `SELECT + `SELECT i.id, i.image, i.name, @@ -164,6 +164,8 @@ module.exports = Self => { i.stemMultiplier, i.typeFk, i.isFloramondo, + i.recycledPlastic, + i.nonRecycledPlastic, pr.name AS producer, it.name AS typeName, it.workerFk AS buyerFk, diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index 4a7e04002..e99dcd996 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -125,6 +125,12 @@ "minPrice": { "type": "number" }, + "recycledPlastic": { + "type": "number" + }, + "nonRecycledPlastic": { + "type": "number" + }, "packingOut": { "type": "number" }, diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html index a7e603bd1..61456f154 100644 --- a/modules/item/front/basic-data/index.html +++ b/modules/item/front/basic-data/index.html @@ -82,6 +82,8 @@ vn-name="expence" initial-data="$ctrl.item.expense"> + + - - - - - - + + + + + + - - - - - - + + + + + + + + + + + + + + + + + +

From 1bcd3039cdf58af87eff7d0c2f8004db9be4cb95 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 11 Jul 2023 07:41:05 +0200 Subject: [PATCH 26/91] refs #5475 redesign 2FA email --- .../email/auth-code/assets/css/style.css | 5 +- .../templates/email/auth-code/auth-code.html | 68 ++++++++++++------- print/templates/email/auth-code/auth-code.js | 4 +- print/templates/email/auth-code/locale/en.yml | 3 +- print/templates/email/auth-code/locale/es.yml | 3 +- print/templates/email/auth-code/locale/fr.yml | 3 +- print/templates/email/auth-code/locale/pt.yml | 3 +- 7 files changed, 54 insertions(+), 35 deletions(-) diff --git a/print/templates/email/auth-code/assets/css/style.css b/print/templates/email/auth-code/assets/css/style.css index d3bfa2aea..7fbccdc3f 100644 --- a/print/templates/email/auth-code/assets/css/style.css +++ b/print/templates/email/auth-code/assets/css/style.css @@ -1,5 +1,6 @@ .code { border: 2px dashed #8dba25; border-radius: 3px; - text-align: center -} \ No newline at end of file + text-align: center; + font-size: 24px; +} diff --git a/print/templates/email/auth-code/auth-code.html b/print/templates/email/auth-code/auth-code.html index 0d303682a..ae9aa6478 100644 --- a/print/templates/email/auth-code/auth-code.html +++ b/print/templates/email/auth-code/auth-code.html @@ -1,23 +1,45 @@ - -
-
-

{{ $t('title') }}

-

{{ $t('description') }}

-

- {{ $t('device') }}: {{ device }} -

-

- {{$t('ip')}}: {{ ip }} -

-
-
-
-
-

{{ $t('Enter the following code to continue to your account') }}

-
- {{ code }} -
-

{{ $t('It expires in 5 minutes') }}

-
-
-
+ + + + + + + + + + + + + +
+
+
+
+
+
+ +
+
+
+
+

{{ $t('title') }}

+

{{ $t('description') }}

+

+ {{ $t('device') }}: {{ device }} +

+

+ {{$t('ip')}}: {{ ip }} +

+
+
+
+
+

{{ $t('Enter the following code to continue to your account. It expires in 5 minutes.') }}

+
+ {{ code }} +
+
+
+
+ + diff --git a/print/templates/email/auth-code/auth-code.js b/print/templates/email/auth-code/auth-code.js index 362b307d8..b16833036 100755 --- a/print/templates/email/auth-code/auth-code.js +++ b/print/templates/email/auth-code/auth-code.js @@ -1,10 +1,10 @@ const Component = require(`vn-print/core/component`); -const emailBody = new Component('email-body'); +const emailHeader = new Component('email-header'); module.exports = { name: 'auth-code', components: { - 'email-body': emailBody.build(), + 'email-header': emailHeader.build(), }, props: { code: { diff --git a/print/templates/email/auth-code/locale/en.yml b/print/templates/email/auth-code/locale/en.yml index 27b493e20..74ea87e32 100644 --- a/print/templates/email/auth-code/locale/en.yml +++ b/print/templates/email/auth-code/locale/en.yml @@ -3,5 +3,4 @@ title: Verification code description: Somebody did request a verification code for login. If you didn't request it, please ignore this email. device: 'Device' ip: 'IP' -Enter the following code to continue to your account: Enter the following code to continue to your account -It expires in 5 minutes: It expires in 5 minutes +Enter the following code to continue to your account. It expires in 5 minutes.: Enter the following code to continue to your account. It expires in 5 minutes. diff --git a/print/templates/email/auth-code/locale/es.yml b/print/templates/email/auth-code/locale/es.yml index 463ea95fa..0de99f5be 100644 --- a/print/templates/email/auth-code/locale/es.yml +++ b/print/templates/email/auth-code/locale/es.yml @@ -3,5 +3,4 @@ title: Código de verificación description: Alguien ha solicitado un código de verificación para poder iniciar sesión. Si no lo has solicitado tu, ignora este email. device: 'Dispositivo' ip: 'IP' -Enter the following code to continue to your account: Introduce el siguiente código para poder continuar con tu cuenta -It expires in 5 minutes: Expira en 5 minutos +Enter the following code to continue to your account. It expires in 5 minutes: Introduce el siguiente código para poder continuar con tu cuenta. Expira en 5 minutos. diff --git a/print/templates/email/auth-code/locale/fr.yml b/print/templates/email/auth-code/locale/fr.yml index 454bb80ae..0b71d4228 100644 --- a/print/templates/email/auth-code/locale/fr.yml +++ b/print/templates/email/auth-code/locale/fr.yml @@ -3,5 +3,4 @@ title: Code de vérification description: Quelqu'un a demandé un code de vérification pour se connecter. Si ce n'était pas toi, ignore cet email. device: 'Appareil' ip: 'IP' -Enter the following code to continue to your account: Entrez le code suivant pour continuer avec votre compte -It expires in 5 minutes: Il expire dans 5 minutes. +Enter the following code to continue to your account. It expires in 5 minutes.: Entrez le code suivant pour continuer avec votre compte. Il expire dans 5 minutes. diff --git a/print/templates/email/auth-code/locale/pt.yml b/print/templates/email/auth-code/locale/pt.yml index 7f9eb85f5..cea27dce7 100644 --- a/print/templates/email/auth-code/locale/pt.yml +++ b/print/templates/email/auth-code/locale/pt.yml @@ -3,5 +3,4 @@ title: Código de verificação description: Alguém solicitou um código de verificação para entrar. Se você não fez essa solicitação, ignore este e-mail. device: 'Dispositivo' ip: 'IP' -Enter the following code to continue to your account: Insira o seguinte código para continuar com sua conta. -It expires in 5 minutes: Expira em 5 minutos. +Enter the following code to continue to your account. It expires in 5 minutes: Insira o seguinte código para continuar com sua conta. Expira em 5 minutos. From ba109dccc5fec9f636fbd76178d42ffbc5d38e06 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 11 Jul 2023 07:58:18 +0200 Subject: [PATCH 27/91] refs #5949 trad --- modules/item/front/basic-data/index.html | 6 +++--- modules/item/front/basic-data/locale/es.yml | 10 ++++++---- modules/item/front/summary/index.html | 8 ++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html index 61456f154..285ad11f9 100644 --- a/modules/item/front/basic-data/index.html +++ b/modules/item/front/basic-data/index.html @@ -170,14 +170,14 @@ diff --git a/modules/item/front/basic-data/locale/es.yml b/modules/item/front/basic-data/locale/es.yml index 747dfe792..b6f3c9f75 100644 --- a/modules/item/front/basic-data/locale/es.yml +++ b/modules/item/front/basic-data/locale/es.yml @@ -1,7 +1,7 @@ Reference: Referencia -Full name calculates based on tags 1-3. Is not recommended to change it manually: >- - El nombre completo se calcula - basado en los tags 1-3. +Full name calculates based on tags 1-3. Is not recommended to change it manually: >- + El nombre completo se calcula + basado en los tags 1-3. No se recomienda cambiarlo manualmente Is active: Activo Expense: Gasto @@ -13,4 +13,6 @@ Is shown at website, app that this item cannot travel (wreath, palms, ...): Se m Multiplier: Multiplicador Generic: Genérico This item does need a photo: Este artículo necesita una foto -Do photo: Hacer foto \ No newline at end of file +Do photo: Hacer foto +Recyled Plastic: Plástico reciclado +No recycled plastic: Plástico no reciclado diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html index 78b7af355..af8752b5f 100644 --- a/modules/item/front/summary/index.html +++ b/modules/item/front/summary/index.html @@ -113,19 +113,19 @@ - - - - From 6978339fd3f2d3f13c7161f14c74769cd1117c77 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 11 Jul 2023 08:03:36 +0200 Subject: [PATCH 28/91] refs #5475 fix email translations --- print/templates/email/auth-code/locale/es.yml | 2 +- print/templates/email/auth-code/locale/pt.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/print/templates/email/auth-code/locale/es.yml b/print/templates/email/auth-code/locale/es.yml index 0de99f5be..92150c4ed 100644 --- a/print/templates/email/auth-code/locale/es.yml +++ b/print/templates/email/auth-code/locale/es.yml @@ -3,4 +3,4 @@ title: Código de verificación description: Alguien ha solicitado un código de verificación para poder iniciar sesión. Si no lo has solicitado tu, ignora este email. device: 'Dispositivo' ip: 'IP' -Enter the following code to continue to your account. It expires in 5 minutes: Introduce el siguiente código para poder continuar con tu cuenta. Expira en 5 minutos. +Enter the following code to continue to your account. It expires in 5 minutes.: Introduce el siguiente código para poder continuar con tu cuenta. Expira en 5 minutos. diff --git a/print/templates/email/auth-code/locale/pt.yml b/print/templates/email/auth-code/locale/pt.yml index cea27dce7..1cf5d23be 100644 --- a/print/templates/email/auth-code/locale/pt.yml +++ b/print/templates/email/auth-code/locale/pt.yml @@ -3,4 +3,4 @@ title: Código de verificação description: Alguém solicitou um código de verificação para entrar. Se você não fez essa solicitação, ignore este e-mail. device: 'Dispositivo' ip: 'IP' -Enter the following code to continue to your account. It expires in 5 minutes: Insira o seguinte código para continuar com sua conta. Expira em 5 minutos. +Enter the following code to continue to your account. It expires in 5 minutes.: Insira o seguinte código para continuar com sua conta. Expira em 5 minutos. From 7291b793ae6cdf80b7d5ab394564711eb7629284 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 11 Jul 2023 08:41:43 +0200 Subject: [PATCH 29/91] refs #5949 fix traduct --- modules/item/front/basic-data/index.html | 4 ++-- modules/item/front/basic-data/locale/es.yml | 4 ++-- modules/item/front/summary/index.html | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html index 285ad11f9..fba4d679c 100644 --- a/modules/item/front/basic-data/index.html +++ b/modules/item/front/basic-data/index.html @@ -170,14 +170,14 @@ diff --git a/modules/item/front/basic-data/locale/es.yml b/modules/item/front/basic-data/locale/es.yml index b6f3c9f75..8f459c417 100644 --- a/modules/item/front/basic-data/locale/es.yml +++ b/modules/item/front/basic-data/locale/es.yml @@ -14,5 +14,5 @@ Multiplier: Multiplicador Generic: Genérico This item does need a photo: Este artículo necesita una foto Do photo: Hacer foto -Recyled Plastic: Plástico reciclado -No recycled plastic: Plástico no reciclado +Recycled Plastic: Plástico reciclado +Non recycled plastic: Plástico no reciclado diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html index af8752b5f..fcc267b4d 100644 --- a/modules/item/front/summary/index.html +++ b/modules/item/front/summary/index.html @@ -122,10 +122,10 @@ - - From 93e70e699a4821e1a91b6f2adc5fa5910c6ab820 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 11 Jul 2023 09:19:15 +0200 Subject: [PATCH 30/91] =?UTF-8?q?refs=20#5874=20feat:=20refactorizado=20pr?= =?UTF-8?q?oceso=20facturaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loopback/locale/en.json | 5 +- loopback/locale/es.json | 3 +- modules/client/back/models/client.js | 6 +- modules/client/front/summary/index.html | 5 +- .../back/methods/invoiceOut/invoiceClient.js | 56 ++------- .../methods/invoiceOut/makePdfAndNotify.js | 5 +- .../back/methods/ticket/canBeInvoiced.js | 47 ++++--- .../back/methods/ticket/invoiceTickets.js | 105 ++++++++++++++++ .../ticket/back/methods/ticket/makeInvoice.js | 91 ++++++-------- .../ticket/specs/canBeInvoiced.spec.js | 76 +++++++++--- .../ticket/specs/invoiceTickets.spec.js | 115 ++++++++++++++++++ .../methods/ticket/specs/makeInvoice.spec.js | 92 +++----------- modules/ticket/back/models/ticket-methods.js | 1 + modules/ticket/front/descriptor-menu/index.js | 2 +- .../front/descriptor-menu/index.spec.js | 2 +- modules/ticket/front/index/index.js | 2 +- 16 files changed, 390 insertions(+), 223 deletions(-) create mode 100644 modules/ticket/back/methods/ticket/invoiceTickets.js create mode 100644 modules/ticket/back/methods/ticket/specs/invoiceTickets.spec.js diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 9b1b04600..d7d31a3dc 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -177,5 +177,6 @@ "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", - "The renew period has not been exceeded": "The renew period has not been exceeded" -} \ No newline at end of file + "The renew period has not been exceeded": "The renew period has not been exceeded", + "Negative basis of tickets": "Negative basis of tickets: {{ticketsIds}}" +} diff --git a/loopback/locale/es.json b/loopback/locale/es.json index ed036331f..20a9557e9 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -297,5 +297,6 @@ "Error while generating PDF": "Error al generar PDF", "Error when sending mail to client": "Error al enviar el correo al cliente", "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico", - "The renew period has not been exceeded": "El periodo de renovación no ha sido superado" + "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", + "Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}" } diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 51157e15d..046138725 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -14,7 +14,7 @@ module.exports = Self => { Self.validatesPresenceOf('street', { message: 'Street cannot be empty' }); - + Self.validatesPresenceOf('city', { message: 'City cannot be empty' }); @@ -89,7 +89,7 @@ module.exports = Self => { }; const country = await Self.app.models.Country.findOne(filter); const code = country ? country.code.toLowerCase() : null; - const countryCode = this.fi.toLowerCase().substring(0, 2); + const countryCode = this.fi?.toLowerCase().substring(0, 2); if (!this.fi || !validateTin(this.fi, code) || (this.isVies && countryCode == code)) err(); @@ -401,7 +401,7 @@ module.exports = Self => { Self.changeCredit = async function changeCredit(ctx, finalState, changes) { const models = Self.app.models; const userId = ctx.options.accessToken.userId; - const accessToken = {req: {accessToken: ctx.options.accessToken} }; + const accessToken = {req: {accessToken: ctx.options.accessToken}}; const canEditCredit = await models.ACL.checkAccessAcl(accessToken, 'Client', 'editCredit', 'WRITE'); if (!canEditCredit) { diff --git a/modules/client/front/summary/index.html b/modules/client/front/summary/index.html index a0d4b918a..0a15efcd1 100644 --- a/modules/client/front/summary/index.html +++ b/modules/client/front/summary/index.html @@ -64,7 +64,7 @@ - @@ -296,6 +296,9 @@ value="{{$ctrl.summary.rating}}" info="Value from 1 to 20. The higher the better value"> + + diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js index ddd008942..fa22dab1e 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js @@ -1,5 +1,3 @@ -const UserError = require('vn-loopback/util/user-error'); - module.exports = Self => { Self.remoteMethodCtx('invoiceClient', { description: 'Make a invoice of a client', @@ -56,7 +54,6 @@ module.exports = Self => { const minShipped = Date.vnNew(); minShipped.setFullYear(args.maxShipped.getFullYear() - 1); - let invoiceId; try { const client = await models.Client.findById(args.clientId, { fields: ['id', 'hasToInvoiceByAddress'] @@ -77,56 +74,21 @@ module.exports = Self => { ], options); } - // Check negative bases - - let query = - `SELECT COUNT(*) isSpanishCompany - FROM supplier s - JOIN country c ON c.id = s.countryFk - AND c.code = 'ES' - WHERE s.id = ?`; - const [supplierCompany] = await Self.rawSql(query, [ - args.companyFk - ], options); - - const isSpanishCompany = supplierCompany?.isSpanishCompany; - - query = 'SELECT hasAnyNegativeBase() AS base'; - const [result] = await Self.rawSql(query, null, options); - - const hasAnyNegativeBase = result?.base; - if (hasAnyNegativeBase && isSpanishCompany) - throw new UserError('Negative basis'); - - // Invoicing - - query = `SELECT invoiceSerial(?, ?, ?) AS serial`; - const [invoiceSerial] = await Self.rawSql(query, [ - client.id, + const invoiceType = 'G'; + const invoiceId = await models.Ticket.makeInvoice( + ctx, + invoiceType, args.companyFk, - 'G' - ], options); - const serialLetter = invoiceSerial.serial; - - query = `CALL invoiceOut_new(?, ?, NULL, @invoiceId)`; - await Self.rawSql(query, [ - serialLetter, - args.invoiceDate - ], options); - - const [newInvoice] = await Self.rawSql(`SELECT @invoiceId id`, null, options); - if (!newInvoice) - throw new UserError('No tickets to invoice', 'notInvoiced'); - - await Self.rawSql('CALL invoiceOutBooking(?)', [newInvoice.id], options); - invoiceId = newInvoice.id; + args.invoiceDate, + options + ); if (tx) await tx.commit(); + + return invoiceId; } catch (e) { if (tx) await tx.rollback(); throw e; } - - return invoiceId; }; }; diff --git a/modules/invoiceOut/back/methods/invoiceOut/makePdfAndNotify.js b/modules/invoiceOut/back/methods/invoiceOut/makePdfAndNotify.js index a999437c0..a48664b30 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/makePdfAndNotify.js +++ b/modules/invoiceOut/back/methods/invoiceOut/makePdfAndNotify.js @@ -14,8 +14,7 @@ module.exports = Self => { }, { arg: 'printerFk', type: 'number', - description: 'The printer to print', - required: true + description: 'The printer to print' } ], http: { @@ -51,7 +50,7 @@ module.exports = Self => { const ref = invoiceOut.ref; const client = invoiceOut.client(); - if (client.isToBeMailed) { + if (client.isToBeMailed || !printerFk) { try { ctx.args = { reference: ref, diff --git a/modules/ticket/back/methods/ticket/canBeInvoiced.js b/modules/ticket/back/methods/ticket/canBeInvoiced.js index 6b8f9e71a..0f6cb476b 100644 --- a/modules/ticket/back/methods/ticket/canBeInvoiced.js +++ b/modules/ticket/back/methods/ticket/canBeInvoiced.js @@ -1,3 +1,5 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = function(Self) { Self.remoteMethodCtx('canBeInvoiced', { description: 'Whether the ticket can or not be invoiced', @@ -21,8 +23,9 @@ module.exports = function(Self) { } }); - Self.canBeInvoiced = async(ticketsIds, options) => { + Self.canBeInvoiced = async(ctx, ticketsIds, options) => { const myOptions = {}; + const $t = ctx.req.__; // $translate if (typeof options == 'object') Object.assign(myOptions, options); @@ -31,29 +34,43 @@ module.exports = function(Self) { where: { id: {inq: ticketsIds} }, - fields: ['id', 'refFk', 'shipped', 'totalWithVat'] + fields: ['id', 'refFk', 'shipped', 'totalWithVat', 'companyFk'] }, myOptions); + const [firstTicket] = tickets; + const companyFk = firstTicket.companyFk; - const query = ` - SELECT vn.hasSomeNegativeBase(t.id) AS hasSomeNegativeBase - FROM ticket t - WHERE id IN(?)`; - const ticketBases = await Self.rawSql(query, [ticketsIds], myOptions); - const hasSomeNegativeBase = ticketBases.some( - ticketBases => ticketBases.hasSomeNegativeBase - ); + const query = + `SELECT COUNT(*) isSpanishCompany + FROM supplier s + JOIN country c ON c.id = s.countryFk + AND c.code = 'ES' + WHERE s.id = ?`; + const [supplierCompany] = await Self.rawSql(query, [companyFk], options); + + const isSpanishCompany = supplierCompany?.isSpanishCompany; + + const [result] = await Self.rawSql('SELECT hasAnyNegativeBase() AS base', null, options); + const hasAnyNegativeBase = result?.base && isSpanishCompany; + if (hasAnyNegativeBase) + throw new UserError($t('Negative basis of tickets', {ticketsIds: ticketsIds})); const today = Date.vnNew(); - const invalidTickets = tickets.some(ticket => { + tickets.some(ticket => { const shipped = new Date(ticket.shipped); const shippingInFuture = shipped.getTime() > today.getTime(); - const isInvoiced = ticket.refFk; - const priceZero = ticket.totalWithVat == 0; + if (shippingInFuture) + throw new UserError(`Can't invoice to future`); - return isInvoiced || priceZero || shippingInFuture; + const isInvoiced = ticket.refFk; + if (isInvoiced) + throw new UserError(`This ticket is already invoiced`); + + const priceZero = ticket.totalWithVat == 0; + if (priceZero) + throw new UserError(`A ticket with an amount of zero can't be invoiced`); }); - return !(invalidTickets || hasSomeNegativeBase); + return true; }; }; diff --git a/modules/ticket/back/methods/ticket/invoiceTickets.js b/modules/ticket/back/methods/ticket/invoiceTickets.js new file mode 100644 index 000000000..780e9eb57 --- /dev/null +++ b/modules/ticket/back/methods/ticket/invoiceTickets.js @@ -0,0 +1,105 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = function(Self) { + Self.remoteMethodCtx('invoiceTickets', { + description: 'Make out an invoice from one or more tickets', + accessType: 'WRITE', + accepts: [ + { + arg: 'ticketsIds', + description: 'The tickets id', + type: ['number'], + required: true + } + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/invoiceTickets`, + verb: 'POST' + } + }); + + Self.invoiceTickets = async(ctx, ticketsIds, options) => { + const models = Self.app.models; + const date = Date.vnNew(); + date.setHours(0, 0, 0, 0); + + const myOptions = {userId: ctx.req.accessToken.userId}; + let tx; + + if (typeof options === 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + let invoicesIds = []; + try { + const tickets = await models.Ticket.find({ + where: { + id: {inq: ticketsIds} + }, + fields: ['id', 'clientFk', 'companyFk'] + }, myOptions); + + const [firstTicket] = tickets; + const clientId = firstTicket.clientFk; + const companyId = firstTicket.companyFk; + + const isSameClient = tickets.every(ticket => ticket.clientFk === clientId); + if (!isSameClient) + throw new UserError(`You can't invoice tickets from multiple clients`); + + const client = await models.Client.findById(clientId, { + fields: ['id', 'hasToInvoiceByAddress'] + }, myOptions); + + if (client.hasToInvoiceByAddress) { + const query = ` + SELECT DISTINCT addressFk + FROM ticket t + WHERE id IN (?)`; + const result = await Self.rawSql(query, [ticketsIds], myOptions); + + const addressIds = result.map(address => address.addressFk); + for (const address of addressIds) + await createInvoice(ctx, companyId, ticketsIds, address, invoicesIds, myOptions); + } else + await createInvoice(ctx, companyId, ticketsIds, null, invoicesIds, myOptions); + + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + + for (const invoiceId of invoicesIds) + await models.InvoiceOut.makePdfAndNotify(ctx, invoiceId, null); + + return invoicesIds; + }; + + async function createInvoice(ctx, companyId, ticketsIds, address, invoicesIds, myOptions) { + const models = Self.app.models; + + await models.Ticket.rawSql(` + DROP TEMPORARY TABLE IF EXISTS tmp.ticketToInvoice; + CREATE TEMPORARY TABLE tmp.ticketToInvoice + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT id + FROM vn.ticket + WHERE id IN (?) + ${address ? `AND addressFk = ${address}` : ''} + `, [ticketsIds], myOptions); + + const invoiceId = await models.Ticket.makeInvoice(ctx, 'R', companyId, Date.vnNew(), myOptions); + invoicesIds.push(invoiceId); + } +}; + diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index ee82b874f..22fe7b3f5 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -6,15 +6,26 @@ module.exports = function(Self) { accessType: 'WRITE', accepts: [ { - arg: 'ticketsIds', - description: 'The tickets id', - type: ['number'], + arg: 'invoiceType', + description: 'The invoice type', + type: 'string', + required: true + }, + { + arg: 'companyFk', + description: 'The company id', + type: 'string', + required: true + }, + { + arg: 'invoiceDate', + description: 'The invoice date', + type: 'date', required: true } ], returns: { - arg: 'data', - type: 'boolean', + type: ['object'], root: true }, http: { @@ -23,10 +34,9 @@ module.exports = function(Self) { } }); - Self.makeInvoice = async(ctx, ticketsIds, options) => { + Self.makeInvoice = async(ctx, invoiceType, companyFk, invoiceDate, options) => { const models = Self.app.models; - const date = Date.vnNew(); - date.setHours(0, 0, 0, 0); + invoiceDate.setHours(0, 0, 0, 0); const myOptions = {userId: ctx.req.accessToken.userId}; let tx; @@ -40,81 +50,50 @@ module.exports = function(Self) { } let serial; - let invoiceId; - let invoiceOut; try { + const ticketToInvoice = await Self.rawSql(` + SELECT id + FROM tmp.ticketToInvoice`, null, myOptions); + + const ticketsIds = ticketToInvoice.map(ticket => ticket.id); const tickets = await models.Ticket.find({ where: { id: {inq: ticketsIds} }, - fields: ['id', 'clientFk', 'companyFk'] + fields: ['id', 'clientFk'] }, myOptions); + await models.Ticket.canBeInvoiced(ctx, ticketsIds, myOptions); + const [firstTicket] = tickets; const clientId = firstTicket.clientFk; - const companyId = firstTicket.companyFk; - - const isSameClient = tickets.every(ticket => ticket.clientFk == clientId); - if (!isSameClient) - throw new UserError(`You can't invoice tickets from multiple clients`); - const clientCanBeInvoiced = await models.Client.canBeInvoiced(clientId, myOptions); if (!clientCanBeInvoiced) throw new UserError(`This client can't be invoiced`); - const ticketCanBeInvoiced = await models.Ticket.canBeInvoiced(ticketsIds, myOptions); - if (!ticketCanBeInvoiced) - throw new UserError(`Some of the selected tickets are not billable`); - const query = `SELECT vn.invoiceSerial(?, ?, ?) AS serial`; const [result] = await Self.rawSql(query, [ clientId, - companyId, - 'R' + companyFk, + invoiceType, ], myOptions); serial = result.serial; - await Self.rawSql(` - DROP TEMPORARY TABLE IF EXISTS tmp.ticketToInvoice; - CREATE TEMPORARY TABLE tmp.ticketToInvoice - (PRIMARY KEY (id)) - ENGINE = MEMORY - SELECT id FROM vn.ticket - WHERE id IN(?) AND refFk IS NULL - `, [ticketsIds], myOptions); - - await Self.rawSql('CALL invoiceOut_new(?, ?, null, @invoiceId)', [serial, date], myOptions); + await Self.rawSql('CALL invoiceOut_new(?, ?, null, @invoiceId)', [serial, invoiceDate], myOptions); const [resultInvoice] = await Self.rawSql('SELECT @invoiceId id', [], myOptions); + if (!resultInvoice) + throw new UserError('No tickets to invoice', 'notInvoiced'); - invoiceId = resultInvoice.id; + if (serial != 'R' && resultInvoice.id) + await Self.rawSql('CALL invoiceOutBooking(?)', [resultInvoice.id], myOptions); - if (serial != 'R' && invoiceId) - await Self.rawSql('CALL invoiceOutBooking(?)', [invoiceId], myOptions); - - invoiceOut = await models.InvoiceOut.findById(invoiceId, { - include: { - relation: 'client' - } - }, myOptions); if (tx) await tx.commit(); + + return resultInvoice.id; } catch (e) { if (tx) await tx.rollback(); throw e; } - - if (serial != 'R' && invoiceId) - await models.InvoiceOut.createPdf(ctx, invoiceId); - - if (invoiceId) { - ctx.args = { - reference: invoiceOut.ref, - recipientId: invoiceOut.clientFk, - recipient: invoiceOut.client().email - }; - await models.InvoiceOut.invoiceEmail(ctx, invoiceOut.ref); - } - - return {invoiceFk: invoiceId, serial: serial}; }; }; diff --git a/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js b/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js index 806f80227..42f9b5a9e 100644 --- a/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js +++ b/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js @@ -1,61 +1,83 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('ticket canBeInvoiced()', () => { const userId = 19; const ticketId = 11; - const activeCtx = { - accessToken: {userId: userId} + const ctx = {req: {accessToken: {userId: userId}}}; + ctx.req.__ = value => { + return value; }; - beforeAll(async() => { - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); - it('should return falsy for an already invoiced ticket', async() => { const tx = await models.Ticket.beginTransaction({}); + let error; try { const options = {transaction: tx}; const ticket = await models.Ticket.findById(ticketId, null, options); await ticket.updateAttribute('refFk', 'T1111111', options); - const canBeInvoiced = await models.Ticket.canBeInvoiced([ticketId], options); + await models.Ticket.rawSql(` + DROP TEMPORARY TABLE IF EXISTS tmp.ticketToInvoice; + CREATE TEMPORARY TABLE tmp.ticketToInvoice + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT id + FROM vn.ticket + WHERE id IN (?) + `, [ticketId], options); + + const canBeInvoiced = await models.Ticket.canBeInvoiced(ctx, [ticketId], options); expect(canBeInvoiced).toEqual(false); await tx.rollback(); } catch (e) { + error = e; await tx.rollback(); - throw e; } + + expect(error.message).toEqual(`This ticket is already invoiced`); }); it('should return falsy for a ticket with a price of zero', async() => { const tx = await models.Ticket.beginTransaction({}); + let error; try { const options = {transaction: tx}; const ticket = await models.Ticket.findById(ticketId, null, options); await ticket.updateAttribute('totalWithVat', 0, options); - const canBeInvoiced = await models.Ticket.canBeInvoiced([ticketId], options); + await models.Ticket.rawSql(` + DROP TEMPORARY TABLE IF EXISTS tmp.ticketToInvoice; + CREATE TEMPORARY TABLE tmp.ticketToInvoice + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT id + FROM vn.ticket + WHERE id IN (?) + `, [ticketId], options); + + const canBeInvoiced = await models.Ticket.canBeInvoiced(ctx, [ticketId], options); expect(canBeInvoiced).toEqual(false); await tx.rollback(); } catch (e) { + error = e; await tx.rollback(); - throw e; } + + expect(error.message).toEqual(`A ticket with an amount of zero can't be invoiced`); }); it('should return falsy for a ticket shipping in future', async() => { const tx = await models.Ticket.beginTransaction({}); + + let error; try { const options = {transaction: tx}; @@ -66,15 +88,27 @@ describe('ticket canBeInvoiced()', () => { await ticket.updateAttribute('shipped', shipped, options); - const canBeInvoiced = await models.Ticket.canBeInvoiced([ticketId], options); + await models.Ticket.rawSql(` + DROP TEMPORARY TABLE IF EXISTS tmp.ticketToInvoice; + CREATE TEMPORARY TABLE tmp.ticketToInvoice + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT id + FROM vn.ticket + WHERE id IN (?) + `, [ticketId], options); + + const canBeInvoiced = await models.Ticket.canBeInvoiced(ctx, [ticketId], options); expect(canBeInvoiced).toEqual(false); await tx.rollback(); } catch (e) { + error = e; await tx.rollback(); - throw e; } + + expect(error.message).toEqual(`Can't invoice to future`); }); it('should return truthy for an invoiceable ticket', async() => { @@ -83,7 +117,17 @@ describe('ticket canBeInvoiced()', () => { try { const options = {transaction: tx}; - const canBeInvoiced = await models.Ticket.canBeInvoiced([ticketId], options); + await models.Ticket.rawSql(` + DROP TEMPORARY TABLE IF EXISTS tmp.ticketToInvoice; + CREATE TEMPORARY TABLE tmp.ticketToInvoice + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT id + FROM vn.ticket + WHERE id IN (?) + `, [ticketId], options); + + const canBeInvoiced = await models.Ticket.canBeInvoiced(ctx, [ticketId], options); expect(canBeInvoiced).toEqual(true); diff --git a/modules/ticket/back/methods/ticket/specs/invoiceTickets.spec.js b/modules/ticket/back/methods/ticket/specs/invoiceTickets.spec.js new file mode 100644 index 000000000..8971fb24a --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/invoiceTickets.spec.js @@ -0,0 +1,115 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); + +describe('ticket invoiceTickets()', () => { + const userId = 19; + const clientId = 1102; + const activeCtx = { + getLocale: () => { + return 'en'; + }, + accessToken: {userId: userId}, + headers: {origin: 'http://localhost:5000'}, + }; + const ctx = {req: activeCtx}; + + beforeAll(async() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + + it('should throw an error when invoicing tickets from multiple clients', async() => { + const invoiceOutModel = models.InvoiceOut; + spyOn(invoiceOutModel, 'makePdfAndNotify'); + + const tx = await models.Ticket.beginTransaction({}); + + let error; + + try { + const options = {transaction: tx}; + + const ticketsIds = [11, 16]; + await models.Ticket.invoiceTickets(ctx, ticketsIds, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error.message).toEqual(`You can't invoice tickets from multiple clients`); + }); + + it(`should throw an error when invoicing a client without tax data checked`, async() => { + const invoiceOutModel = models.InvoiceOut; + spyOn(invoiceOutModel, 'makePdfAndNotify'); + + const tx = await models.Ticket.beginTransaction({}); + + let error; + + try { + const options = {transaction: tx}; + + const client = await models.Client.findById(clientId, null, options); + await client.updateAttribute('isTaxDataChecked', false, options); + + const ticketsIds = [11]; + await models.Ticket.invoiceTickets(ctx, ticketsIds, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error.message).toEqual(`This client can't be invoiced`); + }); + + it('should invoice a ticket, then try again to fail', async() => { + const invoiceOutModel = models.InvoiceOut; + spyOn(invoiceOutModel, 'makePdfAndNotify'); + + const tx = await models.Ticket.beginTransaction({}); + + let error; + + try { + const options = {transaction: tx}; + + const ticketsIds = [11]; + await models.Ticket.invoiceTickets(ctx, ticketsIds, options); + await models.Ticket.invoiceTickets(ctx, ticketsIds, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error.message).toEqual(`This ticket is already invoiced`); + }); + + it('should success to invoice a ticket', async() => { + const invoiceOutModel = models.InvoiceOut; + spyOn(invoiceOutModel, 'makePdfAndNotify'); + + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const ticketsIds = [11]; + const invoicesIds = await models.Ticket.invoiceTickets(ctx, ticketsIds, options); + + expect(invoicesIds.length).toBeGreaterThan(0); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js index 270ba5c93..9af6ad557 100644 --- a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js +++ b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js @@ -3,8 +3,9 @@ const LoopBackContext = require('loopback-context'); describe('ticket makeInvoice()', () => { const userId = 19; - const ticketId = 11; - const clientId = 1102; + const invoiceType = 'R'; + const companyFk = 442; + const invoiceDate = Date.vnNew(); const activeCtx = { getLocale: () => { return 'en'; @@ -20,77 +21,6 @@ describe('ticket makeInvoice()', () => { }); }); - it('should throw an error when invoicing tickets from multiple clients', async() => { - const invoiceOutModel = models.InvoiceOut; - spyOn(invoiceOutModel, 'createPdf'); - - const tx = await models.Ticket.beginTransaction({}); - - let error; - - try { - const options = {transaction: tx}; - const otherClientTicketId = 16; - await models.Ticket.makeInvoice(ctx, [ticketId, otherClientTicketId], options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toEqual(`You can't invoice tickets from multiple clients`); - }); - - it(`should throw an error when invoicing a client without tax data checked`, async() => { - const invoiceOutModel = models.InvoiceOut; - spyOn(invoiceOutModel, 'createPdf'); - - const tx = await models.Ticket.beginTransaction({}); - - let error; - - try { - const options = {transaction: tx}; - - const client = await models.Client.findById(clientId, null, options); - await client.updateAttribute('isTaxDataChecked', false, options); - - await models.Ticket.makeInvoice(ctx, [ticketId], options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toEqual(`This client can't be invoiced`); - }); - - it('should invoice a ticket, then try again to fail', async() => { - const invoiceOutModel = models.InvoiceOut; - spyOn(invoiceOutModel, 'createPdf'); - spyOn(invoiceOutModel, 'invoiceEmail'); - - const tx = await models.Ticket.beginTransaction({}); - - let error; - - try { - const options = {transaction: tx}; - - await models.Ticket.makeInvoice(ctx, [ticketId], options); - await models.Ticket.makeInvoice(ctx, [ticketId], options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toEqual(`Some of the selected tickets are not billable`); - }); - it('should success to invoice a ticket', async() => { const invoiceOutModel = models.InvoiceOut; spyOn(invoiceOutModel, 'createPdf'); @@ -101,10 +31,20 @@ describe('ticket makeInvoice()', () => { try { const options = {transaction: tx}; - const invoice = await models.Ticket.makeInvoice(ctx, [ticketId], options); + const ticketsIds = [11, 16]; + await models.Ticket.rawSql(` + DROP TEMPORARY TABLE IF EXISTS tmp.ticketToInvoice; + CREATE TEMPORARY TABLE tmp.ticketToInvoice + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT id + FROM vn.ticket + WHERE id IN (?) + `, [ticketsIds], options); - expect(invoice.invoiceFk).toBeDefined(); - expect(invoice.serial).toEqual('T'); + const invoiceId = await models.Ticket.makeInvoice(ctx, invoiceType, companyFk, invoiceDate, options); + + expect(invoiceId).toBeDefined(); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index e5a8e8d94..f0c85ecc4 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -39,4 +39,5 @@ module.exports = function(Self) { require('../methods/ticket/collectionLabel')(Self); require('../methods/ticket/expeditionPalletLabel')(Self); require('../methods/ticket/saveSign')(Self); + require('../methods/ticket/invoiceTickets')(Self); }; diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 17a34ad59..dd518671b 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -275,7 +275,7 @@ class Controller extends Section { }); } - return this.$http.post(`Tickets/makeInvoice`, params) + return this.$http.post(`Tickets/invoiceTickets`, params) .then(() => this.reload()) .then(() => this.vnApp.showSuccess(this.$t('Ticket invoiced'))); } diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 0aef956db..fbe67d21a 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -191,7 +191,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { jest.spyOn(controller.vnApp, 'showSuccess'); const expectedParams = {ticketsIds: [ticket.id]}; - $httpBackend.expectPOST(`Tickets/makeInvoice`, expectedParams).respond(); + $httpBackend.expectPOST(`Tickets/invoiceTickets`, expectedParams).respond(); controller.makeInvoice(); $httpBackend.flush(); diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 55229eabb..b3afc838c 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -163,7 +163,7 @@ export default class Controller extends Section { makeInvoice() { const ticketsIds = this.checked.map(ticket => ticket.id); - return this.$http.post(`Tickets/makeInvoice`, {ticketsIds}) + return this.$http.post(`Tickets/invoiceTickets`, {ticketsIds}) .then(() => this.$.model.refresh()) .then(() => this.vnApp.showSuccess(this.$t('Ticket invoiced'))); } From 56247b50127df6d878d61bf081a2ef1b709c1019 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 11 Jul 2023 09:33:45 +0200 Subject: [PATCH 31/91] add acl --- db/changes/232601/00-aclInvoiceTickets.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/changes/232601/00-aclInvoiceTickets.sql diff --git a/db/changes/232601/00-aclInvoiceTickets.sql b/db/changes/232601/00-aclInvoiceTickets.sql new file mode 100644 index 000000000..2c221950e --- /dev/null +++ b/db/changes/232601/00-aclInvoiceTickets.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES('Ticket', 'invoiceTickets', 'WRITE', 'ALLOW', 'ROLE', 'employee'); From da13f0811cf793b115bdd7bc3180162592391f79 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 11 Jul 2023 09:59:11 +0200 Subject: [PATCH 32/91] refs 5887 cambiado drop y create por create or replace --- modules/client/front/credit-management/index.html | 2 +- modules/client/front/summary/index.html | 4 ++-- modules/ticket/back/methods/ticket/invoiceTickets.js | 3 +-- .../back/methods/ticket/specs/canBeInvoiced.spec.js | 12 ++++-------- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/modules/client/front/credit-management/index.html b/modules/client/front/credit-management/index.html index b9064ff69..f66b988f5 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 | currency: 'EUR'}} diff --git a/modules/client/front/summary/index.html b/modules/client/front/summary/index.html index 0a15efcd1..15a55ec8c 100644 --- a/modules/client/front/summary/index.html +++ b/modules/client/front/summary/index.html @@ -270,7 +270,7 @@ info="Invoices minus payments plus orders not yet invoiced"> @@ -297,7 +297,7 @@ info="Value from 1 to 20. The higher the better value"> + value="{{$ctrl.summary.recommendedCredit | currency: 'EUR'}}"> diff --git a/modules/ticket/back/methods/ticket/invoiceTickets.js b/modules/ticket/back/methods/ticket/invoiceTickets.js index 780e9eb57..ca1bf15fb 100644 --- a/modules/ticket/back/methods/ticket/invoiceTickets.js +++ b/modules/ticket/back/methods/ticket/invoiceTickets.js @@ -88,8 +88,7 @@ module.exports = function(Self) { const models = Self.app.models; await models.Ticket.rawSql(` - DROP TEMPORARY TABLE IF EXISTS tmp.ticketToInvoice; - CREATE TEMPORARY TABLE tmp.ticketToInvoice + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketToInvoice (PRIMARY KEY (id)) ENGINE = MEMORY SELECT id diff --git a/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js b/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js index 42f9b5a9e..538dbc49f 100644 --- a/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js +++ b/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js @@ -19,8 +19,7 @@ describe('ticket canBeInvoiced()', () => { await ticket.updateAttribute('refFk', 'T1111111', options); await models.Ticket.rawSql(` - DROP TEMPORARY TABLE IF EXISTS tmp.ticketToInvoice; - CREATE TEMPORARY TABLE tmp.ticketToInvoice + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketToInvoice (PRIMARY KEY (id)) ENGINE = MEMORY SELECT id @@ -52,8 +51,7 @@ describe('ticket canBeInvoiced()', () => { await ticket.updateAttribute('totalWithVat', 0, options); await models.Ticket.rawSql(` - DROP TEMPORARY TABLE IF EXISTS tmp.ticketToInvoice; - CREATE TEMPORARY TABLE tmp.ticketToInvoice + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketToInvoice (PRIMARY KEY (id)) ENGINE = MEMORY SELECT id @@ -89,8 +87,7 @@ describe('ticket canBeInvoiced()', () => { await ticket.updateAttribute('shipped', shipped, options); await models.Ticket.rawSql(` - DROP TEMPORARY TABLE IF EXISTS tmp.ticketToInvoice; - CREATE TEMPORARY TABLE tmp.ticketToInvoice + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketToInvoice (PRIMARY KEY (id)) ENGINE = MEMORY SELECT id @@ -118,8 +115,7 @@ describe('ticket canBeInvoiced()', () => { const options = {transaction: tx}; await models.Ticket.rawSql(` - DROP TEMPORARY TABLE IF EXISTS tmp.ticketToInvoice; - CREATE TEMPORARY TABLE tmp.ticketToInvoice + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketToInvoice (PRIMARY KEY (id)) ENGINE = MEMORY SELECT id From d4a4e04f2590d7da33da070f1476a19484e20e22 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 11 Jul 2023 12:33:34 +0200 Subject: [PATCH 33/91] =?UTF-8?q?refs=20#5887=20feat:=20cambiados=20permis?= =?UTF-8?q?os=20para=20a=C3=B1adir/quitar=20alias=20de=20correo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/methods/vn-user/addAlias.js | 68 ++++++++++++++++++++++++++++ back/methods/vn-user/removeAlias.js | 55 ++++++++++++++++++++++ db/changes/232601/00-aclAddAlias.sql | 11 +++++ 3 files changed, 134 insertions(+) create mode 100644 back/methods/vn-user/addAlias.js create mode 100644 back/methods/vn-user/removeAlias.js create mode 100644 db/changes/232601/00-aclAddAlias.sql diff --git a/back/methods/vn-user/addAlias.js b/back/methods/vn-user/addAlias.js new file mode 100644 index 000000000..a9a5dcb85 --- /dev/null +++ b/back/methods/vn-user/addAlias.js @@ -0,0 +1,68 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethod('addAlias', { + description: 'Add alias if user has grant', + accessType: 'WRITE', + accepts: [ + { + arg: 'ctx', + type: 'Object', + http: {source: 'context'} + }, + { + arg: 'id', + type: 'number', + required: true, + description: 'The user id', + http: {source: 'path'} + }, + { + arg: 'mailAlias', + type: 'number', + description: 'The new alias for user', + required: true + } + ], + http: { + path: `/:id/addAlias`, + verb: 'POST' + } + }); + + Self.addAlias = async function(ctx, id, mailAlias, options) { + const models = Self.app.models; + const userId = ctx.req.accessToken.userId; + + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const user = await Self.findById(userId, {fields: ['hasGrant']}, myOptions); + + if (!user.hasGrant) + throw new UserError(`You don't have grant privilege`); + + const account = await models.Account.findById(userId, { + fields: ['id'], + include: { + relation: 'aliases', + scope: { + fields: ['mailAlias'] + } + } + }, myOptions); + + const aliases = account.aliases().map(alias => alias.mailAlias); + + const hasAlias = aliases.includes(mailAlias); + if (!hasAlias) + throw new UserError(`You don't have the alias assigned and you can't assign it to another user`); + + return models.MailAliasAccount.create({ + mailAlias: mailAlias, + account: id + }, myOptions); + }; +}; diff --git a/back/methods/vn-user/removeAlias.js b/back/methods/vn-user/removeAlias.js new file mode 100644 index 000000000..4c402cc54 --- /dev/null +++ b/back/methods/vn-user/removeAlias.js @@ -0,0 +1,55 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethod('removeAlias', { + description: 'Add alias if user has grant', + accessType: 'WRITE', + accepts: [ + { + arg: 'ctx', + type: 'Object', + http: {source: 'context'} + }, + { + arg: 'id', + type: 'number', + required: true, + description: 'The user id', + http: {source: 'path'} + }, + { + arg: 'mailAlias', + type: 'number', + description: 'The alias to delete', + required: true + } + ], + http: { + path: `/:id/removeAlias`, + verb: 'POST' + } + }); + + Self.removeAlias = async function(ctx, id, mailAlias, options) { + const models = Self.app.models; + const userId = ctx.req.accessToken.userId; + + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const canRemoveAlias = await models.ACL.checkAccessAcl(ctx, 'VnUser', 'canRemoveAlias', 'WRITE'); + + if (userId != id && !canRemoveAlias) throw new UserError(`You don't have grant privilege`); + + const mailAliasAccount = await models.MailAliasAccount.findOne({ + where: { + mailAlias: mailAlias, + account: id + } + }, myOptions); + + await mailAliasAccount.destroy(myOptions); + }; +}; diff --git a/db/changes/232601/00-aclAddAlias.sql b/db/changes/232601/00-aclAddAlias.sql new file mode 100644 index 000000000..cc96f5ad8 --- /dev/null +++ b/db/changes/232601/00-aclAddAlias.sql @@ -0,0 +1,11 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES + ('VnUser', 'addAlias', 'WRITE', 'ALLOW', 'ROLE', 'employee'); + +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES + ('VnUser', 'removeAlias', 'WRITE', 'ALLOW', 'ROLE', 'employee'); + +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES + ('VnUser', 'canRemoveAlias', 'WRITE', 'ALLOW', 'ROLE', 'itManagement'); From e1f12bea020fc367cd8002241f5e950680770fe4 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 11 Jul 2023 12:33:44 +0200 Subject: [PATCH 34/91] a --- back/models/vn-user.js | 2 ++ loopback/locale/es.json | 5 +++-- modules/account/front/aliases/index.html | 8 ++------ modules/account/front/aliases/index.js | 16 +++++++++------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/back/models/vn-user.js b/back/models/vn-user.js index b58395acc..12aab585c 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -11,6 +11,8 @@ module.exports = function(Self) { require('../methods/vn-user/validate-token')(Self); require('../methods/vn-user/privileges')(Self); require('../methods/vn-user/renew-token')(Self); + require('../methods/vn-user/addAlias')(Self); + require('../methods/vn-user/removeAlias')(Self); Self.definition.settings.acls = Self.definition.settings.acls.filter(acl => acl.property !== 'create'); diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 20a9557e9..63b20995d 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -296,7 +296,8 @@ "Fecha fuera de rango": "Fecha fuera de rango", "Error while generating PDF": "Error al generar PDF", "Error when sending mail to client": "Error al enviar el correo al cliente", - "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico", + "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico", "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", - "Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}" + "Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}", + "You don't have the alias assigned and you can't assign it to another user": "No tienes el alias asignado y no puedes asignarlo a otro usuario" } diff --git a/modules/account/front/aliases/index.html b/modules/account/front/aliases/index.html index 11d546afb..4a73ec873 100644 --- a/modules/account/front/aliases/index.html +++ b/modules/account/front/aliases/index.html @@ -17,9 +17,7 @@ + ng-click="removeConfirm.show(row)"> @@ -32,9 +30,7 @@ translate-attr="{title: 'Add'}" vn-bind="+" ng-click="$ctrl.onAddClick()" - fixed-bottom-right - vn-acl="itManagement" - vn-acl-action="remove"> + fixed-bottom-right> this.refresh()) .then(() => this.vnApp.showSuccess( this.$t('Subscribed to alias!')) @@ -34,11 +33,14 @@ export default class Controller extends Section { } onRemove(row) { - return this.$http.delete(`MailAliasAccounts/${row.id}`) - .then(() => { - this.$.data.splice(this.$.data.indexOf(row), 1); - this.vnApp.showSuccess(this.$t('Unsubscribed from alias!')); - }); + const params = { + mailAlias: row.mailAlias + }; + return this.$http.post(`VnUsers/${this.$params.id}/removeAlias`, params) + .then(() => this.refresh()) + .then(() => this.vnApp.showSuccess( + this.$t('Subscribed to alias!')) + ); } } From 5a5a1ed20bebc4bee8be651903980fe5f4e3c778 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 11 Jul 2023 13:22:54 +0200 Subject: [PATCH 35/91] refs #5887 feat: addback test --- back/methods/vn-user/specs/addAlias.spec.js | 68 +++++++++++++++++++++ modules/account/front/aliases/index.js | 4 +- modules/account/front/aliases/index.spec.js | 9 ++- 3 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 back/methods/vn-user/specs/addAlias.spec.js diff --git a/back/methods/vn-user/specs/addAlias.spec.js b/back/methods/vn-user/specs/addAlias.spec.js new file mode 100644 index 000000000..239d09c94 --- /dev/null +++ b/back/methods/vn-user/specs/addAlias.spec.js @@ -0,0 +1,68 @@ +const {models} = require('vn-loopback/server/server'); + +describe('VnUser addAlias()', () => { + const employeeId = 1; + const sysadminId = 66; + const developerId = 9; + const customerId = 2; + const mailAlias = 1; + it('should throw an error when user not has privileges', async() => { + const ctx = {req: {accessToken: {userId: employeeId}}}; + const tx = await models.VnUser.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + + await models.VnUser.addAlias(ctx, employeeId, mailAlias, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error.message).toContain(`You don't have grant privilege`); + }); + + it('should throw an error when user has privileges but not has the role from user', async() => { + const ctx = {req: {accessToken: {userId: sysadminId}}}; + const tx = await models.VnUser.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + + await models.VnUser.addAlias(ctx, employeeId, mailAlias, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error.message).toContain(`You don't have the alias assigned and you can't assign it to another user`); + }); + + it('should add an alias', async() => { + const ctx = {req: {accessToken: {userId: developerId}}}; + const tx = await models.VnUser.beginTransaction({}); + + let result; + try { + const options = {transaction: tx}; + + const user = await models.VnUser.findById(developerId, null, options); + await user.updateAttribute('hasGrant', true, options); + + result = await models.VnUser.addAlias(ctx, customerId, mailAlias, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + } + + expect(result.mailAlias).toBe(mailAlias); + expect(result.account).toBe(customerId); + }); +}); diff --git a/modules/account/front/aliases/index.js b/modules/account/front/aliases/index.js index 91d0c6e7c..e0c738ee4 100644 --- a/modules/account/front/aliases/index.js +++ b/modules/account/front/aliases/index.js @@ -38,9 +38,7 @@ export default class Controller extends Section { }; return this.$http.post(`VnUsers/${this.$params.id}/removeAlias`, params) .then(() => this.refresh()) - .then(() => this.vnApp.showSuccess( - this.$t('Subscribed to alias!')) - ); + .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); } } diff --git a/modules/account/front/aliases/index.spec.js b/modules/account/front/aliases/index.spec.js index 466f1e1e9..61f71949c 100644 --- a/modules/account/front/aliases/index.spec.js +++ b/modules/account/front/aliases/index.spec.js @@ -25,8 +25,9 @@ describe('component vnUserAliases', () => { describe('onAddSave()', () => { it('should add the new row', () => { controller.addData = {account: 1}; + controller.$params = {id: 1}; - $httpBackend.expectPOST('MailAliasAccounts').respond(); + $httpBackend.expectPOST('VnUsers/1/addAlias').respond(); $httpBackend.expectGET('MailAliasAccounts').respond('foo'); controller.onAddSave(); $httpBackend.flush(); @@ -41,12 +42,14 @@ describe('component vnUserAliases', () => { {id: 1, alias: 'foo'}, {id: 2, alias: 'bar'} ]; + controller.$params = {id: 1}; - $httpBackend.expectDELETE('MailAliasAccounts/1').respond(); + $httpBackend.expectPOST('VnUsers/1/removeAlias').respond(); + $httpBackend.expectGET('MailAliasAccounts').respond(controller.$.data[1]); controller.onRemove(controller.$.data[0]); $httpBackend.flush(); - expect(controller.$.data).toEqual([{id: 2, alias: 'bar'}]); + expect(controller.$.data).toEqual({id: 2, alias: 'bar'}); expect(controller.vnApp.showSuccess).toHaveBeenCalled(); }); }); From d4217ff8d3c812fc4f42ee04c96aef494843b052 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 11 Jul 2023 13:38:48 +0200 Subject: [PATCH 36/91] refs #5887 correct translations --- back/methods/vn-user/addAlias.js | 4 ++-- loopback/locale/es.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/back/methods/vn-user/addAlias.js b/back/methods/vn-user/addAlias.js index a9a5dcb85..9fe43e713 100644 --- a/back/methods/vn-user/addAlias.js +++ b/back/methods/vn-user/addAlias.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethod('addAlias', { - description: 'Add alias if user has grant', + description: 'Add an alias if the user has the grant', accessType: 'WRITE', accepts: [ { @@ -58,7 +58,7 @@ module.exports = Self => { const hasAlias = aliases.includes(mailAlias); if (!hasAlias) - throw new UserError(`You don't have the alias assigned and you can't assign it to another user`); + throw new UserError(`You cannot assign an alias that you are not assigned to`); return models.MailAliasAccount.create({ mailAlias: mailAlias, diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 63b20995d..809ed5874 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -299,5 +299,5 @@ "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico", "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", "Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}", - "You don't have the alias assigned and you can't assign it to another user": "No tienes el alias asignado y no puedes asignarlo a otro usuario" + "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado" } From a215797390f0b2601a51b4e5a21dd30c456ce70f Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 11 Jul 2023 13:39:22 +0200 Subject: [PATCH 37/91] tranalstion --- back/methods/vn-user/removeAlias.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/vn-user/removeAlias.js b/back/methods/vn-user/removeAlias.js index 4c402cc54..0424c3e96 100644 --- a/back/methods/vn-user/removeAlias.js +++ b/back/methods/vn-user/removeAlias.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethod('removeAlias', { - description: 'Add alias if user has grant', + description: 'Remove alias if the user has the grant', accessType: 'WRITE', accepts: [ { From 6655807d8042cb99de271d40330ebfd6eb652e3f Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 11 Jul 2023 13:50:38 +0200 Subject: [PATCH 38/91] refs #4770 refactor: change acl --- db/changes/232801/00-roadmapACL.sql | 6 ++++-- modules/route/front/roadmap/summary/style.scss | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/db/changes/232801/00-roadmapACL.sql b/db/changes/232801/00-roadmapACL.sql index 8954ecb27..4fc116f86 100644 --- a/db/changes/232801/00-roadmapACL.sql +++ b/db/changes/232801/00-roadmapACL.sql @@ -1,4 +1,6 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES - ('Roadmap', '*', '*', 'ALLOW', 'ROLE', 'employee'), - ('ExpeditionTruck', '*', '*', 'ALLOW', 'ROLE', 'employee'); + ('Roadmap', '*', '*', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('Roadmap', '*', '*', 'ALLOW', 'ROLE', 'productionBoss'), + ('ExpeditionTruck', '*', '*', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('ExpeditionTruck', '*', '*', 'ALLOW', 'ROLE', 'productionBoss'); diff --git a/modules/route/front/roadmap/summary/style.scss b/modules/route/front/roadmap/summary/style.scss index 8e75d3e0b..63b3f625a 100644 --- a/modules/route/front/roadmap/summary/style.scss +++ b/modules/route/front/roadmap/summary/style.scss @@ -1,6 +1,5 @@ @import "variables"; - vn-roadmap-summary .summary { a { display: flex; From 808a9976abcb5ef86115902641a1c8d6337189c7 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 11 Jul 2023 13:53:25 +0200 Subject: [PATCH 39/91] refs #5887 fix: back etst --- back/methods/vn-user/specs/addAlias.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/vn-user/specs/addAlias.spec.js b/back/methods/vn-user/specs/addAlias.spec.js index 239d09c94..ef657a3a8 100644 --- a/back/methods/vn-user/specs/addAlias.spec.js +++ b/back/methods/vn-user/specs/addAlias.spec.js @@ -41,7 +41,7 @@ describe('VnUser addAlias()', () => { await tx.rollback(); } - expect(error.message).toContain(`You don't have the alias assigned and you can't assign it to another user`); + expect(error.message).toContain(`You cannot assign an alias that you are not assigned to`); }); it('should add an alias', async() => { From d7ac20dc6a7df1fe92db107a463e399baf812cd7 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 12 Jul 2023 13:02:27 +0200 Subject: [PATCH 40/91] hotFix(supplier): fix accessToken in before save --- modules/supplier/back/models/supplier.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 9c78e8590..e88fadc0b 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -103,7 +103,7 @@ module.exports = Self => { const changes = ctx.data || ctx.instance; const orgData = ctx.currentInstance; const loopBackContext = LoopBackContext.getCurrentContext(); - const accessToken = {req: loopBackContext.active.accessToken}; + const accessToken = {req: loopBackContext.active}; const editPayMethodCheck = await Self.app.models.ACL.checkAccessAcl(accessToken, 'Supplier', 'editPayMethodCheck', 'WRITE'); From 510b78c7035eabcef9d51c78816fe3349968f9c5 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 12 Jul 2023 13:08:46 +0200 Subject: [PATCH 41/91] refs #6006 mod dias anteriores --- modules/travel/front/search-panel/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/travel/front/search-panel/index.js b/modules/travel/front/search-panel/index.js index 089953127..f53c15ca8 100644 --- a/modules/travel/front/search-panel/index.js +++ b/modules/travel/front/search-panel/index.js @@ -38,10 +38,12 @@ class Controller extends SearchPanel { applyFilters(param) { if (typeof this.filter.scopeDays === 'number') { - const shippedFrom = Date.vnNew(); + const today = Date.vnNew(); + const shippedFrom = new Date(today.getTime()); + shippedFrom.setDate(today.getDate() - 30); shippedFrom.setHours(0, 0, 0, 0); - const shippedTo = new Date(shippedFrom.getTime()); + const shippedTo = new Date(today.getTime()); shippedTo.setDate(shippedTo.getDate() + this.filter.scopeDays); shippedTo.setHours(23, 59, 59, 999); Object.assign(this.filter, {shippedFrom, shippedTo}); From 551d06ee8358554f2c83dbeaf6a1f054e634e2af Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 12 Jul 2023 13:55:57 +0200 Subject: [PATCH 42/91] =?UTF-8?q?refs=20#5887=20para=20eliminar=20sigue=20?= =?UTF-8?q?las=20mismas=20reglas=20que=20para=20a=C3=B1adir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/methods/vn-user/specs/addAlias.spec.js | 8 +-- back/models/vn-user.js | 2 - db/changes/232402/00-hotFix_travelConfig.sql | 32 +++++------ db/changes/232601/00-aclAddAlias.sql | 12 ++--- loopback/locale/es.json | 2 +- .../methods/mail-alias-account}/addAlias.js | 25 +-------- .../mail-alias-account}/removeAlias.js | 6 +-- .../account/back/models/mail-alias-account.js | 53 +++++++++++++++++++ modules/account/front/aliases/index.js | 4 +- modules/account/front/aliases/index.spec.js | 4 +- 10 files changed, 83 insertions(+), 65 deletions(-) rename {back/methods/vn-user => modules/account/back/methods/mail-alias-account}/addAlias.js (58%) rename {back/methods/vn-user => modules/account/back/methods/mail-alias-account}/removeAlias.js (83%) create mode 100644 modules/account/back/models/mail-alias-account.js diff --git a/back/methods/vn-user/specs/addAlias.spec.js b/back/methods/vn-user/specs/addAlias.spec.js index ef657a3a8..880c08139 100644 --- a/back/methods/vn-user/specs/addAlias.spec.js +++ b/back/methods/vn-user/specs/addAlias.spec.js @@ -14,7 +14,7 @@ describe('VnUser addAlias()', () => { try { const options = {transaction: tx}; - await models.VnUser.addAlias(ctx, employeeId, mailAlias, options); + await models.MailAliasAccount.addAlias(ctx, employeeId, mailAlias, options); await tx.rollback(); } catch (e) { @@ -33,7 +33,7 @@ describe('VnUser addAlias()', () => { try { const options = {transaction: tx}; - await models.VnUser.addAlias(ctx, employeeId, mailAlias, options); + await models.MailAliasAccount.addAlias(ctx, employeeId, mailAlias, options); await tx.rollback(); } catch (e) { @@ -41,7 +41,7 @@ describe('VnUser addAlias()', () => { await tx.rollback(); } - expect(error.message).toContain(`You cannot assign an alias that you are not assigned to`); + expect(error.message).toContain(`You cannot assign/remove an alias that you are not assigned to`); }); it('should add an alias', async() => { @@ -55,7 +55,7 @@ describe('VnUser addAlias()', () => { const user = await models.VnUser.findById(developerId, null, options); await user.updateAttribute('hasGrant', true, options); - result = await models.VnUser.addAlias(ctx, customerId, mailAlias, options); + result = await models.MailAliasAccount.addAlias(ctx, customerId, mailAlias, options); await tx.rollback(); } catch (e) { diff --git a/back/models/vn-user.js b/back/models/vn-user.js index 12aab585c..b58395acc 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -11,8 +11,6 @@ module.exports = function(Self) { require('../methods/vn-user/validate-token')(Self); require('../methods/vn-user/privileges')(Self); require('../methods/vn-user/renew-token')(Self); - require('../methods/vn-user/addAlias')(Self); - require('../methods/vn-user/removeAlias')(Self); Self.definition.settings.acls = Self.definition.settings.acls.filter(acl => acl.property !== 'create'); diff --git a/db/changes/232402/00-hotFix_travelConfig.sql b/db/changes/232402/00-hotFix_travelConfig.sql index 65450a74d..2691999dc 100644 --- a/db/changes/232402/00-hotFix_travelConfig.sql +++ b/db/changes/232402/00-hotFix_travelConfig.sql @@ -1,19 +1,19 @@ -CREATE TABLE `vn`.`travelConfig` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `warehouseInFk` smallint(6) unsigned NOT NULL DEFAULT 8 COMMENT 'Warehouse de origen', - `warehouseOutFk` smallint(6) unsigned NOT NULL DEFAULT 60 COMMENT 'Warehouse destino', - `agencyFk` int(11) NOT NULL DEFAULT 1378 COMMENT 'Agencia por defecto', - `companyFk` int(10) unsigned NOT NULL DEFAULT 442 COMMENT 'Compañía por defecto', - PRIMARY KEY (`id`), - KEY `travelConfig_FK` (`warehouseInFk`), - KEY `travelConfig_FK_1` (`warehouseOutFk`), - KEY `travelConfig_FK_2` (`agencyFk`), - KEY `travelConfig_FK_3` (`companyFk`), - CONSTRAINT `travelConfig_FK` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `travelConfig_FK_1` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `travelConfig_FK_2` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `travelConfig_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +-- CREATE TABLE `vn`.`travelConfig` ( +-- `id` int(11) unsigned NOT NULL AUTO_INCREMENT, +-- `warehouseInFk` smallint(6) unsigned NOT NULL DEFAULT 8 COMMENT 'Warehouse de origen', +-- `warehouseOutFk` smallint(6) unsigned NOT NULL DEFAULT 60 COMMENT 'Warehouse destino', +-- `agencyFk` int(11) NOT NULL DEFAULT 1378 COMMENT 'Agencia por defecto', +-- `companyFk` int(10) unsigned NOT NULL DEFAULT 442 COMMENT 'Compañía por defecto', +-- PRIMARY KEY (`id`), +-- KEY `travelConfig_FK` (`warehouseInFk`), +-- KEY `travelConfig_FK_1` (`warehouseOutFk`), +-- KEY `travelConfig_FK_2` (`agencyFk`), +-- KEY `travelConfig_FK_3` (`companyFk`), +-- CONSTRAINT `travelConfig_FK` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, +-- CONSTRAINT `travelConfig_FK_1` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, +-- CONSTRAINT `travelConfig_FK_2` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, +-- CONSTRAINT `travelConfig_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES diff --git a/db/changes/232601/00-aclAddAlias.sql b/db/changes/232601/00-aclAddAlias.sql index cc96f5ad8..db2100bed 100644 --- a/db/changes/232601/00-aclAddAlias.sql +++ b/db/changes/232601/00-aclAddAlias.sql @@ -1,11 +1,5 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) VALUES - ('VnUser', 'addAlias', 'WRITE', 'ALLOW', 'ROLE', 'employee'); - -INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) - VALUES - ('VnUser', 'removeAlias', 'WRITE', 'ALLOW', 'ROLE', 'employee'); - -INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) - VALUES - ('VnUser', 'canRemoveAlias', 'WRITE', 'ALLOW', 'ROLE', 'itManagement'); + ('MailAliasAccount', 'addAlias', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('MailAliasAccount', 'removeAlias', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('MailAliasAccount', 'canEditAlias', 'WRITE', 'ALLOW', 'ROLE', 'itManagement'); diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 809ed5874..4408b48b5 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -299,5 +299,5 @@ "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico", "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", "Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}", - "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado" + "You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado" } diff --git a/back/methods/vn-user/addAlias.js b/modules/account/back/methods/mail-alias-account/addAlias.js similarity index 58% rename from back/methods/vn-user/addAlias.js rename to modules/account/back/methods/mail-alias-account/addAlias.js index 9fe43e713..74624b63c 100644 --- a/back/methods/vn-user/addAlias.js +++ b/modules/account/back/methods/mail-alias-account/addAlias.js @@ -1,5 +1,3 @@ -const UserError = require('vn-loopback/util/user-error'); - module.exports = Self => { Self.remoteMethod('addAlias', { description: 'Add an alias if the user has the grant', @@ -32,33 +30,12 @@ module.exports = Self => { Self.addAlias = async function(ctx, id, mailAlias, options) { const models = Self.app.models; - const userId = ctx.req.accessToken.userId; - const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - const user = await Self.findById(userId, {fields: ['hasGrant']}, myOptions); - - if (!user.hasGrant) - throw new UserError(`You don't have grant privilege`); - - const account = await models.Account.findById(userId, { - fields: ['id'], - include: { - relation: 'aliases', - scope: { - fields: ['mailAlias'] - } - } - }, myOptions); - - const aliases = account.aliases().map(alias => alias.mailAlias); - - const hasAlias = aliases.includes(mailAlias); - if (!hasAlias) - throw new UserError(`You cannot assign an alias that you are not assigned to`); + await Self.hasGrant(ctx, mailAlias, myOptions); return models.MailAliasAccount.create({ mailAlias: mailAlias, diff --git a/back/methods/vn-user/removeAlias.js b/modules/account/back/methods/mail-alias-account/removeAlias.js similarity index 83% rename from back/methods/vn-user/removeAlias.js rename to modules/account/back/methods/mail-alias-account/removeAlias.js index 0424c3e96..c32911f4d 100644 --- a/back/methods/vn-user/removeAlias.js +++ b/modules/account/back/methods/mail-alias-account/removeAlias.js @@ -32,16 +32,12 @@ module.exports = Self => { Self.removeAlias = async function(ctx, id, mailAlias, options) { const models = Self.app.models; - const userId = ctx.req.accessToken.userId; - const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - const canRemoveAlias = await models.ACL.checkAccessAcl(ctx, 'VnUser', 'canRemoveAlias', 'WRITE'); - - if (userId != id && !canRemoveAlias) throw new UserError(`You don't have grant privilege`); + await Self.hasGrant(ctx, mailAlias, myOptions); const mailAliasAccount = await models.MailAliasAccount.findOne({ where: { diff --git a/modules/account/back/models/mail-alias-account.js b/modules/account/back/models/mail-alias-account.js new file mode 100644 index 000000000..21c70c32e --- /dev/null +++ b/modules/account/back/models/mail-alias-account.js @@ -0,0 +1,53 @@ + +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + require('../methods/account/sync')(Self); + require('../methods/account/sync-by-id')(Self); + require('../methods/account/sync-all')(Self); + require('../methods/account/login')(Self); + require('../methods/account/logout')(Self); + require('../methods/account/change-password')(Self); + require('../methods/account/set-password')(Self); + require('../methods/mail-alias-account/addAlias')(Self); + require('../methods/mail-alias-account/removeAlias')(Self); + + /** + * Checks if current user has + * read privileges over a dms + * + * @param {Object} ctx - Request context + * @param {Interger} mailAlias - mailAlias id + * @param {Object} options - Query options + * @return {Boolean} True for user with grant + */ + Self.hasGrant = async function(ctx, mailAlias, options) { + const models = Self.app.models; + const userId = ctx.req.accessToken.userId; + + const canEditAlias = await models.ACL.checkAccessAcl(ctx, 'MailAliasAccount', 'canEditAlias', 'WRITE'); + if (canEditAlias) return true; + + const user = await models.VnUser.findById(userId, {fields: ['hasGrant']}, options); + if (!user.hasGrant) + throw new UserError(`You don't have grant privilege`); + + const account = await models.Account.findById(userId, { + fields: ['id'], + include: { + relation: 'aliases', + scope: { + fields: ['mailAlias'] + } + } + }, options); + + const aliases = account.aliases().map(alias => alias.mailAlias); + + const hasAlias = aliases.includes(mailAlias); + if (!hasAlias) + throw new UserError(`You cannot assign/remove an alias that you are not assigned to`); + + return true; + }; +}; diff --git a/modules/account/front/aliases/index.js b/modules/account/front/aliases/index.js index e0c738ee4..b4ada07e5 100644 --- a/modules/account/front/aliases/index.js +++ b/modules/account/front/aliases/index.js @@ -25,7 +25,7 @@ export default class Controller extends Section { } onAddSave() { - return this.$http.post(`VnUsers/${this.$params.id}/addAlias`, this.addData) + return this.$http.post(`MailAliasAccounts/${this.$params.id}/addAlias`, this.addData) .then(() => this.refresh()) .then(() => this.vnApp.showSuccess( this.$t('Subscribed to alias!')) @@ -36,7 +36,7 @@ export default class Controller extends Section { const params = { mailAlias: row.mailAlias }; - return this.$http.post(`VnUsers/${this.$params.id}/removeAlias`, params) + return this.$http.post(`MailAliasAccounts/${this.$params.id}/removeAlias`, params) .then(() => this.refresh()) .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); } diff --git a/modules/account/front/aliases/index.spec.js b/modules/account/front/aliases/index.spec.js index 61f71949c..f72c06ab4 100644 --- a/modules/account/front/aliases/index.spec.js +++ b/modules/account/front/aliases/index.spec.js @@ -27,7 +27,7 @@ describe('component vnUserAliases', () => { controller.addData = {account: 1}; controller.$params = {id: 1}; - $httpBackend.expectPOST('VnUsers/1/addAlias').respond(); + $httpBackend.expectPOST('MailAliasAccounts/1/addAlias').respond(); $httpBackend.expectGET('MailAliasAccounts').respond('foo'); controller.onAddSave(); $httpBackend.flush(); @@ -44,7 +44,7 @@ describe('component vnUserAliases', () => { ]; controller.$params = {id: 1}; - $httpBackend.expectPOST('VnUsers/1/removeAlias').respond(); + $httpBackend.expectPOST('MailAliasAccounts/1/removeAlias').respond(); $httpBackend.expectGET('MailAliasAccounts').respond(controller.$.data[1]); controller.onRemove(controller.$.data[0]); $httpBackend.flush(); From aea5133f399837a4281c446e059f910be9b0530b Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 12 Jul 2023 14:01:39 +0200 Subject: [PATCH 43/91] refs #5877 fix: aply changes --- db/changes/232601/{00-aclAddAlias.sql => 01-aclAddAlias.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/232601/{00-aclAddAlias.sql => 01-aclAddAlias.sql} (100%) diff --git a/db/changes/232601/00-aclAddAlias.sql b/db/changes/232601/01-aclAddAlias.sql similarity index 100% rename from db/changes/232601/00-aclAddAlias.sql rename to db/changes/232601/01-aclAddAlias.sql From c0d329edcab295b2277b1bece04bd344b661a1ab Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 12 Jul 2023 14:04:17 +0200 Subject: [PATCH 44/91] a --- db/changes/232402/00-hotFix_travelConfig.sql | 32 +++++++++---------- .../account/back/models/mail-alias-account.js | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/db/changes/232402/00-hotFix_travelConfig.sql b/db/changes/232402/00-hotFix_travelConfig.sql index 2691999dc..65450a74d 100644 --- a/db/changes/232402/00-hotFix_travelConfig.sql +++ b/db/changes/232402/00-hotFix_travelConfig.sql @@ -1,19 +1,19 @@ --- CREATE TABLE `vn`.`travelConfig` ( --- `id` int(11) unsigned NOT NULL AUTO_INCREMENT, --- `warehouseInFk` smallint(6) unsigned NOT NULL DEFAULT 8 COMMENT 'Warehouse de origen', --- `warehouseOutFk` smallint(6) unsigned NOT NULL DEFAULT 60 COMMENT 'Warehouse destino', --- `agencyFk` int(11) NOT NULL DEFAULT 1378 COMMENT 'Agencia por defecto', --- `companyFk` int(10) unsigned NOT NULL DEFAULT 442 COMMENT 'Compañía por defecto', --- PRIMARY KEY (`id`), --- KEY `travelConfig_FK` (`warehouseInFk`), --- KEY `travelConfig_FK_1` (`warehouseOutFk`), --- KEY `travelConfig_FK_2` (`agencyFk`), --- KEY `travelConfig_FK_3` (`companyFk`), --- CONSTRAINT `travelConfig_FK` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, --- CONSTRAINT `travelConfig_FK_1` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, --- CONSTRAINT `travelConfig_FK_2` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, --- CONSTRAINT `travelConfig_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE --- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +CREATE TABLE `vn`.`travelConfig` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `warehouseInFk` smallint(6) unsigned NOT NULL DEFAULT 8 COMMENT 'Warehouse de origen', + `warehouseOutFk` smallint(6) unsigned NOT NULL DEFAULT 60 COMMENT 'Warehouse destino', + `agencyFk` int(11) NOT NULL DEFAULT 1378 COMMENT 'Agencia por defecto', + `companyFk` int(10) unsigned NOT NULL DEFAULT 442 COMMENT 'Compañía por defecto', + PRIMARY KEY (`id`), + KEY `travelConfig_FK` (`warehouseInFk`), + KEY `travelConfig_FK_1` (`warehouseOutFk`), + KEY `travelConfig_FK_2` (`agencyFk`), + KEY `travelConfig_FK_3` (`companyFk`), + CONSTRAINT `travelConfig_FK` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `travelConfig_FK_1` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `travelConfig_FK_2` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `travelConfig_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES diff --git a/modules/account/back/models/mail-alias-account.js b/modules/account/back/models/mail-alias-account.js index 21c70c32e..78ec75326 100644 --- a/modules/account/back/models/mail-alias-account.js +++ b/modules/account/back/models/mail-alias-account.js @@ -14,7 +14,7 @@ module.exports = Self => { /** * Checks if current user has - * read privileges over a dms + * grant to add/remove alias * * @param {Object} ctx - Request context * @param {Interger} mailAlias - mailAlias id From ef6a2ae578988ac536f91fcc7994a0483318983e Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 12 Jul 2023 14:06:28 +0200 Subject: [PATCH 45/91] refs #5887 fix: delete requires --- modules/account/back/models/mail-alias-account.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/modules/account/back/models/mail-alias-account.js b/modules/account/back/models/mail-alias-account.js index 78ec75326..0875bf79a 100644 --- a/modules/account/back/models/mail-alias-account.js +++ b/modules/account/back/models/mail-alias-account.js @@ -2,13 +2,6 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - require('../methods/account/sync')(Self); - require('../methods/account/sync-by-id')(Self); - require('../methods/account/sync-all')(Self); - require('../methods/account/login')(Self); - require('../methods/account/logout')(Self); - require('../methods/account/change-password')(Self); - require('../methods/account/set-password')(Self); require('../methods/mail-alias-account/addAlias')(Self); require('../methods/mail-alias-account/removeAlias')(Self); From 7aaaf5492cebb382e1474ad6a6384843f9ca17e1 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 12 Jul 2023 15:07:06 +0200 Subject: [PATCH 46/91] refs #5887 refacotr: move code to hook --- back/methods/vn-user/specs/addAlias.spec.js | 68 ------------------- db/changes/232601/01-aclAddAlias.sql | 7 +- .../methods/mail-alias-account/addAlias.js | 45 ------------ .../methods/mail-alias-account/removeAlias.js | 51 -------------- .../account/back/models/mail-alias-account.js | 25 ++++--- modules/account/front/aliases/index.js | 14 ++-- modules/account/front/aliases/index.spec.js | 9 +-- 7 files changed, 32 insertions(+), 187 deletions(-) delete mode 100644 back/methods/vn-user/specs/addAlias.spec.js delete mode 100644 modules/account/back/methods/mail-alias-account/addAlias.js delete mode 100644 modules/account/back/methods/mail-alias-account/removeAlias.js diff --git a/back/methods/vn-user/specs/addAlias.spec.js b/back/methods/vn-user/specs/addAlias.spec.js deleted file mode 100644 index 880c08139..000000000 --- a/back/methods/vn-user/specs/addAlias.spec.js +++ /dev/null @@ -1,68 +0,0 @@ -const {models} = require('vn-loopback/server/server'); - -describe('VnUser addAlias()', () => { - const employeeId = 1; - const sysadminId = 66; - const developerId = 9; - const customerId = 2; - const mailAlias = 1; - it('should throw an error when user not has privileges', async() => { - const ctx = {req: {accessToken: {userId: employeeId}}}; - const tx = await models.VnUser.beginTransaction({}); - - let error; - try { - const options = {transaction: tx}; - - await models.MailAliasAccount.addAlias(ctx, employeeId, mailAlias, options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toContain(`You don't have grant privilege`); - }); - - it('should throw an error when user has privileges but not has the role from user', async() => { - const ctx = {req: {accessToken: {userId: sysadminId}}}; - const tx = await models.VnUser.beginTransaction({}); - - let error; - try { - const options = {transaction: tx}; - - await models.MailAliasAccount.addAlias(ctx, employeeId, mailAlias, options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toContain(`You cannot assign/remove an alias that you are not assigned to`); - }); - - it('should add an alias', async() => { - const ctx = {req: {accessToken: {userId: developerId}}}; - const tx = await models.VnUser.beginTransaction({}); - - let result; - try { - const options = {transaction: tx}; - - const user = await models.VnUser.findById(developerId, null, options); - await user.updateAttribute('hasGrant', true, options); - - result = await models.MailAliasAccount.addAlias(ctx, customerId, mailAlias, options); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - } - - expect(result.mailAlias).toBe(mailAlias); - expect(result.account).toBe(customerId); - }); -}); diff --git a/db/changes/232601/01-aclAddAlias.sql b/db/changes/232601/01-aclAddAlias.sql index db2100bed..d4df3cd44 100644 --- a/db/changes/232601/01-aclAddAlias.sql +++ b/db/changes/232601/01-aclAddAlias.sql @@ -1,5 +1,8 @@ +DELETE FROM `salix`.`ACL` WHERE model = 'MailAliasAccount'; + INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) VALUES - ('MailAliasAccount', 'addAlias', 'WRITE', 'ALLOW', 'ROLE', 'employee'), - ('MailAliasAccount', 'removeAlias', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('MailAliasAccount', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('MailAliasAccount', 'create', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('MailAliasAccount', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('MailAliasAccount', 'canEditAlias', 'WRITE', 'ALLOW', 'ROLE', 'itManagement'); diff --git a/modules/account/back/methods/mail-alias-account/addAlias.js b/modules/account/back/methods/mail-alias-account/addAlias.js deleted file mode 100644 index 74624b63c..000000000 --- a/modules/account/back/methods/mail-alias-account/addAlias.js +++ /dev/null @@ -1,45 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('addAlias', { - description: 'Add an alias if the user has the grant', - accessType: 'WRITE', - accepts: [ - { - arg: 'ctx', - type: 'Object', - http: {source: 'context'} - }, - { - arg: 'id', - type: 'number', - required: true, - description: 'The user id', - http: {source: 'path'} - }, - { - arg: 'mailAlias', - type: 'number', - description: 'The new alias for user', - required: true - } - ], - http: { - path: `/:id/addAlias`, - verb: 'POST' - } - }); - - Self.addAlias = async function(ctx, id, mailAlias, options) { - const models = Self.app.models; - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - await Self.hasGrant(ctx, mailAlias, myOptions); - - return models.MailAliasAccount.create({ - mailAlias: mailAlias, - account: id - }, myOptions); - }; -}; diff --git a/modules/account/back/methods/mail-alias-account/removeAlias.js b/modules/account/back/methods/mail-alias-account/removeAlias.js deleted file mode 100644 index c32911f4d..000000000 --- a/modules/account/back/methods/mail-alias-account/removeAlias.js +++ /dev/null @@ -1,51 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.remoteMethod('removeAlias', { - description: 'Remove alias if the user has the grant', - accessType: 'WRITE', - accepts: [ - { - arg: 'ctx', - type: 'Object', - http: {source: 'context'} - }, - { - arg: 'id', - type: 'number', - required: true, - description: 'The user id', - http: {source: 'path'} - }, - { - arg: 'mailAlias', - type: 'number', - description: 'The alias to delete', - required: true - } - ], - http: { - path: `/:id/removeAlias`, - verb: 'POST' - } - }); - - Self.removeAlias = async function(ctx, id, mailAlias, options) { - const models = Self.app.models; - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - await Self.hasGrant(ctx, mailAlias, myOptions); - - const mailAliasAccount = await models.MailAliasAccount.findOne({ - where: { - mailAlias: mailAlias, - account: id - } - }, myOptions); - - await mailAliasAccount.destroy(myOptions); - }; -}; diff --git a/modules/account/back/models/mail-alias-account.js b/modules/account/back/models/mail-alias-account.js index 0875bf79a..6f5213f24 100644 --- a/modules/account/back/models/mail-alias-account.js +++ b/modules/account/back/models/mail-alias-account.js @@ -2,8 +2,17 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - require('../methods/mail-alias-account/addAlias')(Self); - require('../methods/mail-alias-account/removeAlias')(Self); + Self.observe('before save', async ctx => { + const changes = ctx.currentInstance || ctx.instance; + + await Self.hasGrant(ctx, changes.mailAlias); + }); + + Self.observe('before delete', async ctx => { + const mailAliasAccount = await Self.findById(ctx.where.id); + + await Self.hasGrant(ctx, mailAliasAccount.mailAlias); + }); /** * Checks if current user has @@ -11,17 +20,17 @@ module.exports = Self => { * * @param {Object} ctx - Request context * @param {Interger} mailAlias - mailAlias id - * @param {Object} options - Query options * @return {Boolean} True for user with grant */ - Self.hasGrant = async function(ctx, mailAlias, options) { + Self.hasGrant = async function(ctx, mailAlias) { const models = Self.app.models; - const userId = ctx.req.accessToken.userId; + const accessToken = {req: {accessToken: ctx.options.accessToken}}; + const userId = accessToken.req.accessToken.userId; - const canEditAlias = await models.ACL.checkAccessAcl(ctx, 'MailAliasAccount', 'canEditAlias', 'WRITE'); + const canEditAlias = await models.ACL.checkAccessAcl(accessToken, 'MailAliasAccount', 'canEditAlias', 'WRITE'); if (canEditAlias) return true; - const user = await models.VnUser.findById(userId, {fields: ['hasGrant']}, options); + const user = await models.VnUser.findById(userId, {fields: ['hasGrant']}); if (!user.hasGrant) throw new UserError(`You don't have grant privilege`); @@ -33,7 +42,7 @@ module.exports = Self => { fields: ['mailAlias'] } } - }, options); + }); const aliases = account.aliases().map(alias => alias.mailAlias); diff --git a/modules/account/front/aliases/index.js b/modules/account/front/aliases/index.js index b4ada07e5..0fc806a71 100644 --- a/modules/account/front/aliases/index.js +++ b/modules/account/front/aliases/index.js @@ -21,11 +21,12 @@ export default class Controller extends Section { } onAddClick() { + this.addData = {account: this.$params.id}; this.$.dialog.show(); } onAddSave() { - return this.$http.post(`MailAliasAccounts/${this.$params.id}/addAlias`, this.addData) + return this.$http.post(`MailAliasAccounts`, this.addData) .then(() => this.refresh()) .then(() => this.vnApp.showSuccess( this.$t('Subscribed to alias!')) @@ -33,12 +34,11 @@ export default class Controller extends Section { } onRemove(row) { - const params = { - mailAlias: row.mailAlias - }; - return this.$http.post(`MailAliasAccounts/${this.$params.id}/removeAlias`, params) - .then(() => this.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); + return this.$http.delete(`MailAliasAccounts/${row.id}`) + .then(() => { + this.$.data.splice(this.$.data.indexOf(row), 1); + this.vnApp.showSuccess(this.$t('Unsubscribed from alias!')); + }); } } diff --git a/modules/account/front/aliases/index.spec.js b/modules/account/front/aliases/index.spec.js index f72c06ab4..466f1e1e9 100644 --- a/modules/account/front/aliases/index.spec.js +++ b/modules/account/front/aliases/index.spec.js @@ -25,9 +25,8 @@ describe('component vnUserAliases', () => { describe('onAddSave()', () => { it('should add the new row', () => { controller.addData = {account: 1}; - controller.$params = {id: 1}; - $httpBackend.expectPOST('MailAliasAccounts/1/addAlias').respond(); + $httpBackend.expectPOST('MailAliasAccounts').respond(); $httpBackend.expectGET('MailAliasAccounts').respond('foo'); controller.onAddSave(); $httpBackend.flush(); @@ -42,14 +41,12 @@ describe('component vnUserAliases', () => { {id: 1, alias: 'foo'}, {id: 2, alias: 'bar'} ]; - controller.$params = {id: 1}; - $httpBackend.expectPOST('MailAliasAccounts/1/removeAlias').respond(); - $httpBackend.expectGET('MailAliasAccounts').respond(controller.$.data[1]); + $httpBackend.expectDELETE('MailAliasAccounts/1').respond(); controller.onRemove(controller.$.data[0]); $httpBackend.flush(); - expect(controller.$.data).toEqual({id: 2, alias: 'bar'}); + expect(controller.$.data).toEqual([{id: 2, alias: 'bar'}]); expect(controller.vnApp.showSuccess).toHaveBeenCalled(); }); }); From 69c3a49cce42c1f0d2d07c5b1a24b245a004d3e5 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 13 Jul 2023 08:05:10 +0200 Subject: [PATCH 48/91] warnFix: smtp prevents the sending of emails depending on the condition --- print/core/smtp.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/print/core/smtp.js b/print/core/smtp.js index 276b85401..8c07e7eca 100644 --- a/print/core/smtp.js +++ b/print/core/smtp.js @@ -10,16 +10,17 @@ module.exports = { async send(options) { options.from = `${config.app.senderName} <${config.app.senderEmail}>`; - if (!process.env.NODE_ENV) - options.to = config.app.senderEmail; + const env = process.env.NODE_ENV; + const canSend = env === 'production' || !env || options.force; - if (process.env.NODE_ENV !== 'production' && !options.force) { + if (!canSend || !config.smtp.auth.user) { const notProductionError = {message: 'This not production, this email not sended'}; await this.mailLog(options, notProductionError); + return Promise.resolve(true); } - if (!config.smtp.auth.user) - return Promise.resolve(true); + if (!env) + options.to = config.app.senderEmail; let res; let error; From 3a61bc6052a2137f6590e7092aac6a9d8c4f76b3 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 13 Jul 2023 08:21:17 +0200 Subject: [PATCH 49/91] refs #5887 move changes sql --- db/changes/{232601 => 232602}/01-aclAddAlias.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/{232601 => 232602}/01-aclAddAlias.sql (100%) diff --git a/db/changes/232601/01-aclAddAlias.sql b/db/changes/232602/01-aclAddAlias.sql similarity index 100% rename from db/changes/232601/01-aclAddAlias.sql rename to db/changes/232602/01-aclAddAlias.sql From 337ce56a60e7296e49143455f2784de28fe0b68d Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 13 Jul 2023 08:37:11 +0200 Subject: [PATCH 50/91] refs #5887 test exlcuido --- modules/ticket/back/methods/ticket/specs/filter.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 6cc1a3ad2..510446cab 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -141,6 +141,7 @@ describe('ticket filter()', () => { }); it('should return the tickets that are not pending', async() => { + pending('#6010 test intermitente'); const tx = await models.Ticket.beginTransaction({}); try { From 392dc5060a7707c4fa288c7b1b85b67e503903de Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 13 Jul 2023 10:19:12 +0200 Subject: [PATCH 51/91] refs #4770 delete test --- .../route/front/roadmap/card/index.spec.js | 27 ----- .../route/front/roadmap/create/index.spec.js | 107 ------------------ .../route/front/roadmap/index/index.spec.js | 94 --------------- .../route/front/roadmap/main/index.spec.js | 31 ----- modules/ticket/front/descriptor-menu/index.js | 2 +- 5 files changed, 1 insertion(+), 260 deletions(-) delete mode 100644 modules/route/front/roadmap/card/index.spec.js delete mode 100644 modules/route/front/roadmap/create/index.spec.js delete mode 100644 modules/route/front/roadmap/index/index.spec.js delete mode 100644 modules/route/front/roadmap/main/index.spec.js diff --git a/modules/route/front/roadmap/card/index.spec.js b/modules/route/front/roadmap/card/index.spec.js deleted file mode 100644 index ab2314bb9..000000000 --- a/modules/route/front/roadmap/card/index.spec.js +++ /dev/null @@ -1,27 +0,0 @@ -import './index'; - -describe('component vnItemTypeCard', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnItemTypeCard', {$element: null}); - })); - - describe('reload()', () => { - it('should reload the controller data', () => { - controller.$params.id = 1; - - const itemType = {id: 1}; - - $httpBackend.expectGET('ItemTypes/1').respond(itemType); - controller.reload(); - $httpBackend.flush(); - - expect(controller.itemType).toEqual(itemType); - }); - }); -}); diff --git a/modules/route/front/roadmap/create/index.spec.js b/modules/route/front/roadmap/create/index.spec.js deleted file mode 100644 index d6d9883a7..000000000 --- a/modules/route/front/roadmap/create/index.spec.js +++ /dev/null @@ -1,107 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher.js'; - -describe('AgencyTerm', () => { - describe('Component vnAgencyTermCreateInvoiceIn', () => { - let controller; - let $scope; - let $httpBackend; - let $httpParamSerializer; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - const $element = angular.element(''); - controller = $componentController('vnAgencyTermCreateInvoiceIn', {$element}); - controller._route = { - id: 1 - }; - })); - - describe('$onChanges()', () => { - it('should update the params data when $params.q is defined', () => { - controller.$params = {q: '{"supplierName": "Plants SL","rows": null}'}; - - const params = {q: '{"supplierName": "Plants SL", "rows": null}'}; - const json = JSON.parse(params.q); - - controller.$onChanges(); - - expect(controller.params).toEqual(json); - }); - }); - - describe('route() setter', () => { - it('should set the ticket data and then call setDefaultParams() and getAllowedContentTypes()', () => { - jest.spyOn(controller, 'setDefaultParams'); - jest.spyOn(controller, 'getAllowedContentTypes'); - controller.route = { - id: 1 - }; - - expect(controller.route).toBeDefined(); - expect(controller.setDefaultParams).toHaveBeenCalledWith(); - expect(controller.getAllowedContentTypes).toHaveBeenCalledWith(); - }); - }); - - describe('getAllowedContentTypes()', () => { - it('should make an HTTP GET request to get the allowed content types', () => { - const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond(expectedResponse); - controller.getAllowedContentTypes(); - $httpBackend.flush(); - - expect(controller.allowedContentTypes).toBeDefined(); - expect(controller.allowedContentTypes).toEqual('image/png, image/jpg'); - }); - }); - - describe('setDefaultParams()', () => { - it('should perform a GET query and define the dms property on controller', () => { - const params = {filter: { - where: {code: 'invoiceIn'} - }}; - const serializedParams = $httpParamSerializer(params); - $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 1, code: 'invoiceIn'}); - controller.params = {supplierName: 'Plants SL'}; - controller.setDefaultParams(); - $httpBackend.flush(); - - expect(controller.dms).toBeDefined(); - expect(controller.dms.dmsTypeId).toEqual(1); - }); - }); - - describe('onSubmit()', () => { - it('should make an HTTP POST request to save the form data', () => { - controller.$.watcher = watcher; - - jest.spyOn(controller.$.watcher, 'updateOriginalData'); - const files = [{id: 1, name: 'MyFile'}]; - controller.dms = {files}; - const serializedParams = $httpParamSerializer(controller.dms); - const query = `dms/uploadFile?${serializedParams}`; - controller.params = {rows: null}; - - $httpBackend.expect('POST', query).respond({}); - $httpBackend.expect('POST', 'AgencyTerms/createInvoiceIn').respond({}); - controller.onSubmit(); - $httpBackend.flush(); - }); - }); - - describe('onFileChange()', () => { - it('should set dms hasFileAttached property to true if has any files', () => { - const files = [{id: 1, name: 'MyFile'}]; - controller.onFileChange(files); - $scope.$apply(); - - expect(controller.dms.hasFileAttached).toBeTruthy(); - }); - }); - }); -}); diff --git a/modules/route/front/roadmap/index/index.spec.js b/modules/route/front/roadmap/index/index.spec.js deleted file mode 100644 index 55c40daa5..000000000 --- a/modules/route/front/roadmap/index/index.spec.js +++ /dev/null @@ -1,94 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('AgencyTerm', () => { - describe('Component vnAgencyTermIndex', () => { - let controller; - let $window; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, _$window_) => { - $window = _$window_; - const $element = angular.element(''); - controller = $componentController('vnAgencyTermIndex', {$element}); - controller.$.model = crudModel; - controller.$.model.data = [ - {supplierFk: 1, totalPrice: null}, - {supplierFk: 1}, - {supplierFk: 2} - ]; - })); - - describe('checked() getter', () => { - it('should return the checked lines', () => { - const data = controller.$.model.data; - data[0].checked = true; - - const checkedRows = controller.checked; - - const firstCheckedRow = checkedRows[0]; - - expect(firstCheckedRow.supplierFk).toEqual(1); - }); - }); - - describe('totalCheked() getter', () => { - it('should return the total checked lines', () => { - const data = controller.$.model.data; - data[0].checked = true; - - const checkedRows = controller.totalChecked; - - expect(checkedRows).toEqual(1); - }); - }); - - describe('preview()', () => { - it('should show the summary dialog', () => { - controller.$.summary = {show: () => {}}; - jest.spyOn(controller.$.summary, 'show'); - - let event = new MouseEvent('click', { - view: $window, - bubbles: true, - cancelable: true - }); - const route = {id: 1}; - - controller.preview(event, route); - - expect(controller.$.summary.show).toHaveBeenCalledWith(); - }); - }); - - describe('createInvoiceIn()', () => { - it('should throw an error if more than one autonomous are checked', () => { - jest.spyOn(controller.vnApp, 'showError'); - const data = controller.$.model.data; - data[0].checked = true; - data[2].checked = true; - - controller.createInvoiceIn(); - - expect(controller.vnApp.showError).toHaveBeenCalled(); - }); - - it('should call the function go() on $state to go to the file management', () => { - jest.spyOn(controller.$state, 'go'); - const data = controller.$.model.data; - data[0].checked = true; - - controller.createInvoiceIn(); - - delete data[0].checked; - const params = JSON.stringify({ - supplierName: data[0].supplierName, - rows: [data[0]] - }); - - expect(controller.$state.go).toHaveBeenCalledWith('route.agencyTerm.createInvoiceIn', {q: params}); - }); - }); - }); -}); diff --git a/modules/route/front/roadmap/main/index.spec.js b/modules/route/front/roadmap/main/index.spec.js deleted file mode 100644 index dcb14ec0e..000000000 --- a/modules/route/front/roadmap/main/index.spec.js +++ /dev/null @@ -1,31 +0,0 @@ -import './index'; - -describe('Item', () => { - describe('Component vnItemType', () => { - let controller; - - beforeEach(ngModule('item')); - - beforeEach(inject($componentController => { - const $element = angular.element(''); - controller = $componentController('vnItemType', {$element}); - })); - - describe('exprBuilder()', () => { - it('should return a filter based on a search by id', () => { - const filter = controller.exprBuilder('search', '123'); - - expect(filter).toEqual({id: '123'}); - }); - - it('should return a filter based on a search by name or code', () => { - const filter = controller.exprBuilder('search', 'Alstroemeria'); - - expect(filter).toEqual({or: [ - {name: {like: '%Alstroemeria%'}}, - {code: {like: '%Alstroemeria%'}}, - ]}); - }); - }); - }); -}); diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 0b47102ac..0fc8488ca 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -270,7 +270,7 @@ class Controller extends Section { }); } - return this.$http.post(`Tickets/invoiceTickets`, params) + return this.$http.post(`Tickets/invoiceTickets`, {ticketsIds: [this.id]}) .then(() => this.reload()) .then(() => this.vnApp.showSuccess(this.$t('Ticket invoiced'))); } From c91db1b42922acaccfe7dd562f2b006997b7b8a0 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 13 Jul 2023 10:19:57 +0200 Subject: [PATCH 52/91] a --- back/methods/vn-user/specs/addAlias.spec.js | 68 --------------------- 1 file changed, 68 deletions(-) delete mode 100644 back/methods/vn-user/specs/addAlias.spec.js diff --git a/back/methods/vn-user/specs/addAlias.spec.js b/back/methods/vn-user/specs/addAlias.spec.js deleted file mode 100644 index ef657a3a8..000000000 --- a/back/methods/vn-user/specs/addAlias.spec.js +++ /dev/null @@ -1,68 +0,0 @@ -const {models} = require('vn-loopback/server/server'); - -describe('VnUser addAlias()', () => { - const employeeId = 1; - const sysadminId = 66; - const developerId = 9; - const customerId = 2; - const mailAlias = 1; - it('should throw an error when user not has privileges', async() => { - const ctx = {req: {accessToken: {userId: employeeId}}}; - const tx = await models.VnUser.beginTransaction({}); - - let error; - try { - const options = {transaction: tx}; - - await models.VnUser.addAlias(ctx, employeeId, mailAlias, options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toContain(`You don't have grant privilege`); - }); - - it('should throw an error when user has privileges but not has the role from user', async() => { - const ctx = {req: {accessToken: {userId: sysadminId}}}; - const tx = await models.VnUser.beginTransaction({}); - - let error; - try { - const options = {transaction: tx}; - - await models.VnUser.addAlias(ctx, employeeId, mailAlias, options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toContain(`You cannot assign an alias that you are not assigned to`); - }); - - it('should add an alias', async() => { - const ctx = {req: {accessToken: {userId: developerId}}}; - const tx = await models.VnUser.beginTransaction({}); - - let result; - try { - const options = {transaction: tx}; - - const user = await models.VnUser.findById(developerId, null, options); - await user.updateAttribute('hasGrant', true, options); - - result = await models.VnUser.addAlias(ctx, customerId, mailAlias, options); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - } - - expect(result.mailAlias).toBe(mailAlias); - expect(result.account).toBe(customerId); - }); -}); From 660612cb849e9615e09c5fb98abd424b9d37493a Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 13 Jul 2023 10:22:41 +0200 Subject: [PATCH 53/91] refs #5999 url --- modules/client/front/defaulter/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/client/front/defaulter/index.js b/modules/client/front/defaulter/index.js index 95c7622f9..a2efdcb5c 100644 --- a/modules/client/front/defaulter/index.js +++ b/modules/client/front/defaulter/index.js @@ -32,6 +32,7 @@ export default class Controller extends Section { }, { field: 'country', autocomplete: { + url: 'Countries', showField: 'country', valueField: 'country' } From 2627cafc229aa0910e07198e7f19f99d44883c07 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 13 Jul 2023 10:54:22 +0200 Subject: [PATCH 54/91] refs #5999 defaulter country autocomplete --- modules/client/back/methods/defaulter/filter.js | 3 ++- modules/client/back/models/defaulter.json | 4 ++-- modules/client/front/defaulter/index.html | 4 ++-- modules/client/front/defaulter/index.js | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index 736c29f9c..ec6088ff0 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -69,11 +69,12 @@ module.exports = Self => { c.creditInsurance, d.defaulterSinced, cn.country, + c.countryFk, pm.name payMethod FROM vn.defaulter d JOIN vn.client c ON c.id = d.clientFk JOIN vn.country cn ON cn.id = c.countryFk - JOIN vn.payMethod pm ON pm.id = c.payMethodFk + JOIN vn.payMethod pm ON pm.id = c.payMethodFk LEFT JOIN vn.clientObservation co ON co.clientFk = c.id LEFT JOIN account.user u ON u.id = c.salesPersonFk LEFT JOIN account.user uw ON uw.id = co.workerFk diff --git a/modules/client/back/models/defaulter.json b/modules/client/back/models/defaulter.json index 03d68ea71..ef22c2429 100644 --- a/modules/client/back/models/defaulter.json +++ b/modules/client/back/models/defaulter.json @@ -33,7 +33,7 @@ "country": { "type": "belongsTo", "model": "Country", - "foreignKey": "country" + "foreignKey": "countryFk" }, "payMethod": { "type": "belongsTo", @@ -41,4 +41,4 @@ "foreignKey": "payMethod" } } -} \ No newline at end of file +} diff --git a/modules/client/front/defaulter/index.html b/modules/client/front/defaulter/index.html index 4f662b62b..3c66e6459 100644 --- a/modules/client/front/defaulter/index.html +++ b/modules/client/front/defaulter/index.html @@ -57,7 +57,7 @@ Comercial - + Country {{::defaulter.payMethod}} - + {{::defaulter.amount | currency: 'EUR': 2}} Date: Thu, 13 Jul 2023 13:45:07 +0200 Subject: [PATCH 55/91] refs #5964 fix supply --- modules/supplier/back/models/supplier.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 9c78e8590..488b03b0f 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -68,9 +68,9 @@ module.exports = Self => { }; const country = await Self.app.models.Country.findOne(filter); const code = country ? country.code.toLowerCase() : null; - const countryCode = this.nif.toLowerCase().substring(0, 2); + const countryCode = this.nif?.toLowerCase().substring(0, 2); - if (!this.nif || !validateTin(this.nif, code) || (this.isVies && countryCode == code)) + if (!validateTin(this.nif, code) || (this.isVies && countryCode == code)) err(); done(); } @@ -122,7 +122,7 @@ module.exports = Self => { }); async function hasSupplierSameName(err, done) { - if (!this.name || !this.countryFk) done(); + if (!this.name || !this.countryFk) return done(); const supplier = await Self.app.models.Supplier.findOne( { where: { From 765a84e2eb9ec325fc892994d18361796f6dfd7e Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 14 Jul 2023 07:27:04 +0200 Subject: [PATCH 56/91] refs #5819 Added param to call zone_getLeaves --- modules/zone/back/methods/zone/getLeaves.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/zone/back/methods/zone/getLeaves.js b/modules/zone/back/methods/zone/getLeaves.js index a6db3b711..aeed9f3a2 100644 --- a/modules/zone/back/methods/zone/getLeaves.js +++ b/modules/zone/back/methods/zone/getLeaves.js @@ -38,7 +38,7 @@ module.exports = Self => { Object.assign(myOptions, options); const [res] = await Self.rawSql( - `CALL zone_getLeaves(?, ?, ?)`, + `CALL zone_getLeaves(?, ?, ?, FALSE)`, [id, parentId, search], myOptions ); From 6d8b3e346dc99043d23af1c771d3483b80aef386 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 14 Jul 2023 09:40:16 +0200 Subject: [PATCH 57/91] refs #5837 fix filter existingClient France --- modules/client/back/models/client.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index ca279ef71..dc48f9d3d 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -50,9 +50,14 @@ module.exports = Self => { ] } }; - const client = await Self.app.models.Client.findOne(filter); - if (client) - err(); + + const existingClient = await Self.app.models.Client.findOne(filter); + + if (existingClient) { + if (this.countryFk !== 19 && this.socialName === existingClient.socialName) + err(); + } + done(); } From 765c22df969a5ebd8c73907cd30f503a7934ca5e Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 14 Jul 2023 11:30:13 +0200 Subject: [PATCH 58/91] refs #5837 new table --- back/models/country.json | 5 ++++- db/changes/233001/00-noUniqueSocialName.sql | 2 ++ modules/client/back/models/client.js | 3 ++- modules/client/back/models/client.json | 5 +++++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 db/changes/233001/00-noUniqueSocialName.sql diff --git a/back/models/country.json b/back/models/country.json index 8fa25b88e..fd540d819 100644 --- a/back/models/country.json +++ b/back/models/country.json @@ -22,6 +22,9 @@ }, "isUeeMember": { "type": "boolean" + }, + "isSocialNameUnique": { + "type": "boolean" } }, "relations": { @@ -39,4 +42,4 @@ "permission": "ALLOW" } ] -} \ No newline at end of file +} diff --git a/db/changes/233001/00-noUniqueSocialName.sql b/db/changes/233001/00-noUniqueSocialName.sql new file mode 100644 index 000000000..0dc4c832f --- /dev/null +++ b/db/changes/233001/00-noUniqueSocialName.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn`.`country` +ADD COLUMN `isSocialNameUnique` tinyint(1) NOT NULL DEFAULT 1; diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index dc48f9d3d..089500149 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -54,7 +54,8 @@ module.exports = Self => { const existingClient = await Self.app.models.Client.findOne(filter); if (existingClient) { - if (this.countryFk !== 19 && this.socialName === existingClient.socialName) + console.log(this.isSocialNameUnique); + if (!this.isSocialNameUnique && this.socialName === existingClient.socialName) err(); } diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index 5f56a1ed2..66a67ec2e 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -181,6 +181,11 @@ "model": "Country", "foreignKey": "countryFk" }, + "isSocialNameUnique": { + "type": "belongsTo", + "model": "Country", + "foreignKey": "countryFk" + }, "contactChannel": { "type": "belongsTo", "model": "ContactChannel", From 4a7cfe912204156944dc354db1eb256ef101bfb6 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 14 Jul 2023 11:51:15 +0200 Subject: [PATCH 59/91] fix: workCenter --- modules/worker/front/calendar/index.html | 142 ++++++------ modules/worker/front/calendar/index.js | 7 +- modules/worker/front/card/index.js | 15 +- modules/worker/front/time-control/index.html | 222 ++++++++++--------- modules/worker/front/time-control/index.js | 6 +- 5 files changed, 201 insertions(+), 191 deletions(-) diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index 877add57b..d264e0ebc 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -1,9 +1,9 @@ - - -
+
+ +
-
-
- Autonomous worker -
- -
-
-
{{'Contract' | translate}} #{{$ctrl.businessId}}
-
- {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} + +
+
+
{{'Contract' | translate}} #{{$ctrl.businessId}}
+
+ {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} +
+
+ {{'Spent' | translate}} {{$ctrl.contractHolidays.hoursEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.contractHolidays.totalHours || 0}} {{'hours' | translate}} +
+
+ {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays || 0}} {{'days' | translate}} +
-
- {{'Spent' | translate}} {{$ctrl.contractHolidays.hoursEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.contractHolidays.totalHours || 0}} {{'hours' | translate}} -
-
- {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays || 0}} {{'days' | translate}} -
-
-
-
{{'Year' | translate}} {{$ctrl.year}}
-
- {{'Used' | translate}} {{$ctrl.yearHolidays.holidaysEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.yearHolidays.totalHolidays || 0}} {{'days' | translate}} +
+
{{'Year' | translate}} {{$ctrl.year}}
+
+ {{'Used' | translate}} {{$ctrl.yearHolidays.holidaysEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.yearHolidays.totalHolidays || 0}} {{'days' | translate}} +
+
+ {{'Spent' | translate}} {{$ctrl.yearHolidays.hoursEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.yearHolidays.totalHours || 0}} {{'hours' | translate}} +
-
- {{'Spent' | translate}} {{$ctrl.yearHolidays.hoursEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.yearHolidays.totalHours || 0}} {{'hours' | translate}} -
-
-
- + - - + +
- - - - {{absenceType.name}} - -
-
- - - - Festive - - - - - Current day - -
+ ng-click="$ctrl.pick(absenceType)"> + + + + {{absenceType.name}} +
- - - +
+ + + + Festive + + + + + Current day + +
+
+
+ + +
+
+ Autonomous worker +
diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js index 87e806cc3..5606ad0ce 100644 --- a/modules/worker/front/calendar/index.js +++ b/modules/worker/front/calendar/index.js @@ -31,6 +31,8 @@ class Controller extends Section { } set businessId(value) { + if (!this.card.hasWorkCenter) return; + this._businessId = value; if (value) { this.refresh() @@ -64,7 +66,7 @@ class Controller extends Section { set worker(value) { this._worker = value; - if (value && value.hasWorkCenter) { + if (value) { this.getIsSubordinate(); this.getActiveContract(); } @@ -293,5 +295,8 @@ ngModule.vnComponent('vnWorkerCalendar', { controller: Controller, bindings: { worker: '<' + }, + require: { + card: '^vnWorkerCard' } }); diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index 35f331764..0bf9ae5c4 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -3,7 +3,7 @@ import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { reload() { - let filter = { + const filter = { include: [ { relation: 'user', @@ -32,13 +32,12 @@ class Controller extends ModuleCard { ] }; - this.$http.get(`Workers/${this.$params.id}`, {filter}) - .then(res => this.worker = res.data) - .then(() => - this.$http.get(`Workers/${this.$params.id}/activeContract`) - .then(res => { - if (res.data) this.worker.hasWorkCenter = res.data.workCenterFk; - })); + return Promise.all([ + this.$http.get(`Workers/${this.$params.id}`, {filter}) + .then(res => this.worker = res.data), + this.$http.get(`Workers/${this.$params.id}/activeContract`) + .then(res => this.hasWorkCenter = res.data.workCenterFk) + ]); } } diff --git a/modules/worker/front/time-control/index.html b/modules/worker/front/time-control/index.html index 5f0855ee6..5d8d2c503 100644 --- a/modules/worker/front/time-control/index.html +++ b/modules/worker/front/time-control/index.html @@ -4,7 +4,7 @@ filter="::$ctrl.filter" data="$ctrl.hours"> -
+
@@ -105,118 +105,120 @@ ng-show="::$ctrl.isHr"> + + + +
+
+
Hours
+ + + + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + +
+ + + + Are you sure you want to send it? + + + + + +
Autonomous worker
- - -
-
-
Hours
- - - - -
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
- - - - -
- - - - Are you sure you want to send it? - - - - - - diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index 90ec33293..38e6721d6 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -141,6 +141,8 @@ class Controller extends Section { ]} }; this.$.model.applyFilter(filter, params).then(() => { + if (!this.card.hasWorkCenter) return; + this.getWorkedHours(this.started, this.ended); this.getAbsences(); }); @@ -151,7 +153,6 @@ class Controller extends Section { } getAbsences() { - if (!this.worker.hasWorkerCenter) return; const fullYear = this.started.getFullYear(); let params = { workerFk: this.$params.id, @@ -486,5 +487,8 @@ ngModule.vnComponent('vnWorkerTimeControl', { controller: Controller, bindings: { worker: '<' + }, + require: { + card: '^vnWorkerCard' } }); From 4f183d1c6a6d52d2cf4f55b7b15baff616e3c830 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 14 Jul 2023 12:18:41 +0200 Subject: [PATCH 60/91] fix: worker.basic-data el boton guardar estava activo al hacer F5 --- db/changes/232802/01-aclAddAlias.sql | 4 +++ modules/worker/front/descriptor/index.html | 37 +++++++++------------- modules/worker/front/descriptor/index.js | 25 +++++---------- 3 files changed, 27 insertions(+), 39 deletions(-) create mode 100644 db/changes/232802/01-aclAddAlias.sql diff --git a/db/changes/232802/01-aclAddAlias.sql b/db/changes/232802/01-aclAddAlias.sql new file mode 100644 index 000000000..149dd6f15 --- /dev/null +++ b/db/changes/232802/01-aclAddAlias.sql @@ -0,0 +1,4 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES + ('WorkerDisableExcluded', '*', 'READ', 'ALLOW', 'ROLE', 'itManagement'), + ('WorkerDisableExcluded', '*', 'WRITE', 'ALLOW', 'ROLE', 'itManagement'); diff --git a/modules/worker/front/descriptor/index.html b/modules/worker/front/descriptor/index.html index 58ac3d9e6..ea005e1a2 100644 --- a/modules/worker/front/descriptor/index.html +++ b/modules/worker/front/descriptor/index.html @@ -5,8 +5,8 @@
- - Click to exclude the user from getting disabled - - - Click to allow the user to be disabled - + + {{$ctrl.workerExcluded + ? 'Click to allow the user to be disabled' + : 'Click to exclude the user from getting disabled'}} +
@@ -84,7 +77,7 @@ - - \ No newline at end of file + diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index ef2f64e85..a53528ef2 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -18,28 +18,19 @@ class Controller extends Descriptor { 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; + this.$http.get(`WorkerDisableExcludeds/${this.entity.id}/exists`).then(data => { + this.workerExcluded = 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; - } + if (this.workerExcluded) + this.$http.delete(`WorkerDisableExcludeds/${this.entity.id}`); + else + this.$http.post(`WorkerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date}); + + this.workerExcluded = !this.workerExcluded; } loadData() { From 5716acaa3c94b9396553acac874bd9cb58d5c39c Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 14 Jul 2023 13:01:31 +0200 Subject: [PATCH 61/91] fix: test --- modules/worker/front/calendar/index.html | 174 +++++++------- modules/worker/front/calendar/index.spec.js | 5 +- modules/worker/front/time-control/index.html | 219 +++++++++--------- .../worker/front/time-control/index.spec.js | 5 +- 4 files changed, 202 insertions(+), 201 deletions(-) diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index d264e0ebc..1b0560185 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -1,9 +1,9 @@ + +
- -
- -
-
-
{{'Contract' | translate}} #{{$ctrl.businessId}}
-
- {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} -
-
- {{'Spent' | translate}} {{$ctrl.contractHolidays.hoursEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.contractHolidays.totalHours || 0}} {{'hours' | translate}} -
-
- {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays || 0}} {{'days' | translate}} -
-
- -
-
{{'Year' | translate}} {{$ctrl.year}}
-
- {{'Used' | translate}} {{$ctrl.yearHolidays.holidaysEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.yearHolidays.totalHolidays || 0}} {{'days' | translate}} -
-
- {{'Spent' | translate}} {{$ctrl.yearHolidays.hoursEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.yearHolidays.totalHours || 0}} {{'hours' | translate}} -
-
- -
- - - - -
#{{businessFk}}
-
- {{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}} -
-
-
-
-
- - - - - {{absenceType.name}} - -
-
- - - - Festive - - - - - Current day - -
-
-
- -
Autonomous worker
+ +
+
+
{{'Contract' | translate}} #{{$ctrl.businessId}}
+
+ {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} +
+
+ {{'Spent' | translate}} {{$ctrl.contractHolidays.hoursEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.contractHolidays.totalHours || 0}} {{'hours' | translate}} +
+
+ {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays || 0}} {{'days' | translate}} +
+
+
+
{{'Year' | translate}} {{$ctrl.year}}
+
+ {{'Used' | translate}} {{$ctrl.yearHolidays.holidaysEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.yearHolidays.totalHolidays || 0}} {{'days' | translate}} +
+
+ {{'Spent' | translate}} {{$ctrl.yearHolidays.hoursEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.yearHolidays.totalHours || 0}} {{'hours' | translate}} +
+
+ +
+ + + + +
#{{businessFk}}
+
+ {{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}} +
+
+
+
+
+ + + + + {{absenceType.name}} + +
+
+ + + + Festive + + + + + Current day + +
+
+
+ + + diff --git a/modules/worker/front/calendar/index.spec.js b/modules/worker/front/calendar/index.spec.js index 4b78d883b..5d7ae0795 100644 --- a/modules/worker/front/calendar/index.spec.js +++ b/modules/worker/front/calendar/index.spec.js @@ -20,6 +20,9 @@ describe('Worker', () => { controller.absenceType = {id: 1, name: 'Holiday', code: 'holiday', rgb: 'red'}; controller.$params.id = 1106; controller._worker = {id: 1106}; + controller.card = { + hasWorkCenter: true + }; })); describe('year() getter', () => { @@ -74,7 +77,7 @@ describe('Worker', () => { let yesterday = new Date(today.getTime()); yesterday.setDate(yesterday.getDate() - 1); - controller.worker = {id: 1107, hasWorkCenter: true}; + controller.worker = {id: 1107}; expect(controller.getIsSubordinate).toHaveBeenCalledWith(); expect(controller.getActiveContract).toHaveBeenCalledWith(); diff --git a/modules/worker/front/time-control/index.html b/modules/worker/front/time-control/index.html index 5d8d2c503..760b0dafc 100644 --- a/modules/worker/front/time-control/index.html +++ b/modules/worker/front/time-control/index.html @@ -105,116 +105,6 @@ ng-show="::$ctrl.isHr"> - - - -
-
-
Hours
- - - - -
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
- - - - -
- - - - Are you sure you want to send it? - - - - - -
Autonomous worker
+ + +
+
+
Hours
+ + + + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + +
+ + + + Are you sure you want to send it? + + + + + + diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js index 0132f50fe..6d8510ba8 100644 --- a/modules/worker/front/time-control/index.spec.js +++ b/modules/worker/front/time-control/index.spec.js @@ -16,9 +16,8 @@ describe('Component vnWorkerTimeControl', () => { $scope = $rootScope.$new(); $element = angular.element(''); controller = $componentController('vnWorkerTimeControl', {$element, $scope}); - controller.worker = { - hasWorkerCenter: true - + controller.card = { + hasWorkCenter: true }; })); From 93387cae62aed6a12f860fe3207bf656b84d73ac Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 14 Jul 2023 13:07:40 +0200 Subject: [PATCH 62/91] refs #5837 if isSocialNameUnique --- modules/client/back/models/client.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 089500149..163d51fc5 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -42,6 +42,14 @@ module.exports = Self => { async function socialNameIsUnique(err, done) { const filter = { + include: { + relation: 'country', + scope: { + fields: { + isSocialNameUnique: true, + }, + }, + }, where: { and: [ {socialName: this.socialName}, @@ -54,8 +62,8 @@ module.exports = Self => { const existingClient = await Self.app.models.Client.findOne(filter); if (existingClient) { - console.log(this.isSocialNameUnique); - if (!this.isSocialNameUnique && this.socialName === existingClient.socialName) + // eslint-disable-next-line max-len + if (existingClient.country().isSocialNameUnique && this.socialName === existingClient.socialName) err(); } From 6980392ba1a44925b198806c4ec80ee31803a5f1 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 14 Jul 2023 13:11:09 +0200 Subject: [PATCH 63/91] fix: tabulacion --- ...clAddAlias.sql => 01-aclWorkerDisable.sql} | 0 modules/worker/front/calendar/index.html | 24 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) rename db/changes/232802/{01-aclAddAlias.sql => 01-aclWorkerDisable.sql} (100%) diff --git a/db/changes/232802/01-aclAddAlias.sql b/db/changes/232802/01-aclWorkerDisable.sql similarity index 100% rename from db/changes/232802/01-aclAddAlias.sql rename to db/changes/232802/01-aclWorkerDisable.sql diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index 1b0560185..08f63ddf9 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -59,20 +59,20 @@
+ url="Workers/{{$ctrl.$params.id}}/contracts" + fields="['started', 'ended']" + ng-model="$ctrl.businessId" + search-function="{businessFk: $search}" + value-field="businessFk" + order="businessFk DESC" + limit="5">
#{{businessFk}}
@@ -82,10 +82,8 @@
- - + + {{absenceType.name}} From f24aa2c80130ce509ffc9e7b4e03a5c9b42a211d Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 17 Jul 2023 13:27:27 +0200 Subject: [PATCH 64/91] pop vehicle error --- back/models/invoice-in.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 back/models/invoice-in.js diff --git a/back/models/invoice-in.js b/back/models/invoice-in.js new file mode 100644 index 000000000..6fa1fa0e1 --- /dev/null +++ b/back/models/invoice-in.js @@ -0,0 +1,9 @@ +let UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.rewriteDbError(function(err) { + if (err.code === 'ER_ROW_IS_REFERENCED') + return new UserError(`This invoice has a linked vehicle.`); + return err; + }); +}; From 10e726c48656803a2c076adc066e43bff49a0595 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 17 Jul 2023 13:51:16 +0200 Subject: [PATCH 65/91] move vehicleInvoice --- .../invoiceIn/back/models/invoiceInVehicle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename back/models/invoice-in.js => modules/invoiceIn/back/models/invoiceInVehicle.js (81%) diff --git a/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoiceInVehicle.js similarity index 81% rename from back/models/invoice-in.js rename to modules/invoiceIn/back/models/invoiceInVehicle.js index 6fa1fa0e1..cf45bf741 100644 --- a/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoiceInVehicle.js @@ -2,7 +2,7 @@ let UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.rewriteDbError(function(err) { - if (err.code === 'ER_ROW_IS_REFERENCED') + if (err.code === 'ER_ROW_IS_REFERENCED_2') return new UserError(`This invoice has a linked vehicle.`); return err; }); From a5d1c68511060e930ec2a802542ec591913c728c Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 17 Jul 2023 14:07:45 +0200 Subject: [PATCH 66/91] change err and traduction --- loopback/locale/es.json | 3 ++- modules/invoiceIn/back/models/invoice-in.js | 8 ++++++++ modules/invoiceIn/back/models/invoiceInVehicle.js | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 4086cfa4a..08f5bf765 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -305,5 +305,6 @@ "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", "Valid priorities": "Prioridades válidas: %d", "Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}", - "You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado" + "You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado", + "This invoice has a linked vehicle.": "Esta factura tiene un vehiculo vinculado" } diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index 51905ccb8..0efa6c309 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -1,3 +1,5 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = Self => { require('../methods/invoice-in/filter')(Self); require('../methods/invoice-in/summary')(Self); @@ -7,4 +9,10 @@ module.exports = Self => { require('../methods/invoice-in/invoiceInPdf')(Self); require('../methods/invoice-in/invoiceInEmail')(Self); require('../methods/invoice-in/getSerial')(Self); + Self.rewriteDbError(function(err) { + console.log(err); + if (err.code === 'ER_ROW_IS_REFERENCED_2') + return new UserError(`This invoice has a linked vehicle.`); + return err; + }); }; diff --git a/modules/invoiceIn/back/models/invoiceInVehicle.js b/modules/invoiceIn/back/models/invoiceInVehicle.js index cf45bf741..7fa780142 100644 --- a/modules/invoiceIn/back/models/invoiceInVehicle.js +++ b/modules/invoiceIn/back/models/invoiceInVehicle.js @@ -2,6 +2,7 @@ let UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.rewriteDbError(function(err) { + console.log(err); if (err.code === 'ER_ROW_IS_REFERENCED_2') return new UserError(`This invoice has a linked vehicle.`); return err; From 52f58a92c85f78d978bec7304816bef5b55c2d2f Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 17 Jul 2023 14:11:05 +0200 Subject: [PATCH 67/91] refs err.sqlMessage --- modules/invoiceIn/back/models/invoice-in.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index 0efa6c309..82e0bf078 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -10,8 +10,7 @@ module.exports = Self => { require('../methods/invoice-in/invoiceInEmail')(Self); require('../methods/invoice-in/getSerial')(Self); Self.rewriteDbError(function(err) { - console.log(err); - if (err.code === 'ER_ROW_IS_REFERENCED_2') + if (err.code === 'ER_ROW_IS_REFERENCED_2' && err.sqlMessage.includes('vehicleInvoiceIn')) return new UserError(`This invoice has a linked vehicle.`); return err; }); From 47e8fab8d9401ce78c6baa04a6c1667f59e786c6 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 17 Jul 2023 19:51:46 +0200 Subject: [PATCH 68/91] refs remove --- modules/invoiceIn/back/models/invoiceInVehicle.js | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 modules/invoiceIn/back/models/invoiceInVehicle.js diff --git a/modules/invoiceIn/back/models/invoiceInVehicle.js b/modules/invoiceIn/back/models/invoiceInVehicle.js deleted file mode 100644 index 7fa780142..000000000 --- a/modules/invoiceIn/back/models/invoiceInVehicle.js +++ /dev/null @@ -1,10 +0,0 @@ -let UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.rewriteDbError(function(err) { - console.log(err); - if (err.code === 'ER_ROW_IS_REFERENCED_2') - return new UserError(`This invoice has a linked vehicle.`); - return err; - }); -}; From 3c013110d35a96aadb7f78b226f3de590bf4957a Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 18 Jul 2023 07:32:45 +0200 Subject: [PATCH 69/91] refs #5819 Changed structure sql --- db/dump/structure.sql | 121 ++++++++++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 47 deletions(-) diff --git a/db/dump/structure.sql b/db/dump/structure.sql index ee5fb40a1..4e7127310 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -77831,7 +77831,7 @@ BEGIN LEAVE cur1Loop; END IF; - CALL zone_getLeaves2(vZoneFk, NULL, NULL); + CALL zone_getLeaves(vZoneFk, NULL, NULL, TRUE); myLoop: LOOP SET vGeoFk = NULL; @@ -77844,7 +77844,7 @@ BEGIN LEAVE myLoop; END IF; - CALL zone_getLeaves2(vZoneFk, vGeoFk, NULL); + CALL zone_getLeaves(vZoneFk, vGeoFk, NULL, TRUE); UPDATE tmp.zoneNodes SET isChecked = TRUE WHERE geoFk = vGeoFk; @@ -78130,55 +78130,58 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLeaves`(vSelf INT, vParentFk INT, vSearch VARCHAR(255)) -BEGIN +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getLeaves`( + vSelf INT, + vParentFk INT, + vSearch VARCHAR(255), + vHasInsert BOOL +) +BEGIN /** * Devuelve las ubicaciones incluidas en la ruta y que sean hijos de parentFk. * @param vSelf Id de la zona * @param vParentFk Id del geo a calcular - * @param vSearch cadena a buscar + * @param vSearch Cadena a buscar + * @param vHasInsert Indica si inserta en tmp.zoneNodes + * Optional @table tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk) */ DECLARE vIsNumber BOOL; - DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch != ''; + DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch <> ''; - DROP TEMPORARY TABLE IF EXISTS tNodes; - CREATE TEMPORARY TABLE tNodes + CREATE OR REPLACE TEMPORARY TABLE tNodes (UNIQUE (id)) ENGINE = MEMORY - SELECT id - FROM zoneGeo + SELECT id + FROM zoneGeo LIMIT 0; IF vIsSearch THEN SET vIsNumber = vSearch REGEXP '^[0-9]+$'; - + INSERT INTO tNodes - SELECT id + SELECT id FROM zoneGeo WHERE (vIsNumber AND `name` = vSearch) OR (!vIsNumber AND `name` LIKE CONCAT('%', vSearch, '%')) LIMIT 1000; - + ELSEIF vParentFk IS NULL THEN INSERT INTO tNodes - SELECT geoFk + SELECT geoFk FROM zoneIncluded WHERE zoneFk = vSelf; END IF; IF vParentFk IS NULL THEN - DROP TEMPORARY TABLE IF EXISTS tChilds; - CREATE TEMPORARY TABLE tChilds + CREATE OR REPLACE TEMPORARY TABLE tChilds + (INDEX(id)) ENGINE = MEMORY - SELECT id - FROM tNodes; + SELECT id FROM tNodes; - DROP TEMPORARY TABLE IF EXISTS tParents; - CREATE TEMPORARY TABLE tParents + CREATE OR REPLACE TEMPORARY TABLE tParents + (INDEX(id)) ENGINE = MEMORY - SELECT id - FROM zoneGeo - LIMIT 0; + SELECT id FROM zoneGeo LIMIT 0; myLoop: LOOP DELETE FROM tParents; @@ -78186,43 +78189,67 @@ BEGIN SELECT parentFk id FROM zoneGeo g JOIN tChilds c ON c.id = g.id - WHERE g.parentFk IS NOT NULL; - + WHERE g.parentFk IS NOT NULL; + INSERT IGNORE INTO tNodes - SELECT id - FROM tParents; - - IF ROW_COUNT() = 0 THEN + SELECT id FROM tParents; + + IF NOT ROW_COUNT() THEN LEAVE myLoop; END IF; - + DELETE FROM tChilds; INSERT INTO tChilds - SELECT id - FROM tParents; + SELECT id FROM tParents; END LOOP; - + DROP TEMPORARY TABLE tChilds, tParents; END IF; - IF !vIsSearch THEN + IF NOT vIsSearch THEN INSERT IGNORE INTO tNodes - SELECT id + SELECT id FROM zoneGeo WHERE parentFk <=> vParentFk; END IF; - SELECT g.id, - g.name, - g.parentFk, - g.sons, - isIncluded selected - FROM zoneGeo g - JOIN tNodes n ON n.id = g.id - LEFT JOIN zoneIncluded i ON i.geoFk = g.id AND i.zoneFk = vSelf - ORDER BY `depth`, selected DESC, name; + CREATE OR REPLACE TEMPORARY TABLE tZones + SELECT g.id, + g.name, + g.parentFk, + g.sons, + NOT g.sons OR `type` = 'country' isChecked, + i.isIncluded selected, + g.`depth`, + vSelf + FROM zoneGeo g + JOIN tNodes n ON n.id = g.id + LEFT JOIN zoneIncluded i ON i.geoFk = g.id + AND i.zoneFk = vSelf + ORDER BY g.`depth`, selected DESC, g.name; - DROP TEMPORARY TABLE tNodes; + IF vHasInsert THEN + INSERT IGNORE INTO tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk) + SELECT id, + name, + parentFk, + sons, + isChecked, + vSelf + FROM tZones + WHERE selected + OR (selected IS NULL AND vParentFk IS NOT NULL); + ELSE + SELECT id, + name, + parentFk, + sons, + selected + FROM tZones + ORDER BY `depth`, selected DESC, name; + END IF; + + DROP TEMPORARY TABLE tNodes, tZones; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -78540,7 +78567,7 @@ BEGIN INDEX(geoFk)) ENGINE = MEMORY; - CALL zone_getLeaves2(vSelf, NULL , NULL); + CALL zone_getLeaves(vSelf, NULL , NULL, TRUE); UPDATE tmp.zoneNodes zn SET isChecked = 0 @@ -78553,7 +78580,7 @@ BEGIN WHERE NOT isChecked LIMIT 1; - CALL zone_getLeaves2(vSelf, vGeoFk, NULL); + CALL zone_getLeaves(vSelf, vGeoFk, NULL, TRUE); UPDATE tmp.zoneNodes SET isChecked = TRUE WHERE geoFk = vGeoFk; From 93da12923959e0b829871d30e08b1e157f3b6e7c Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 18 Jul 2023 08:54:45 +0200 Subject: [PATCH 70/91] refs #5983 feat(itemShelving): add getInventory --- .../233001/00-itemShelving_inventory.sql | 52 +++++++++++++++++++ .../methods/item-shelving/getInventory.js | 37 +++++++++++++ .../item-shelving/specs/getInventory.spec.js | 19 +++++++ modules/item/back/models/item-shelving.js | 1 + 4 files changed, 109 insertions(+) create mode 100644 db/changes/233001/00-itemShelving_inventory.sql create mode 100644 modules/item/back/methods/item-shelving/getInventory.js create mode 100644 modules/item/back/methods/item-shelving/specs/getInventory.spec.js diff --git a/db/changes/233001/00-itemShelving_inventory.sql b/db/changes/233001/00-itemShelving_inventory.sql new file mode 100644 index 000000000..b2a2ff321 --- /dev/null +++ b/db/changes/233001/00-itemShelving_inventory.sql @@ -0,0 +1,52 @@ + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_inventory`(vParkingFromFk INT, vParkingToFk INT) +/** + * Devuelve un listado de ubicaciones a revisar + * + * @param vParkingFromFk Parking de partida, identificador de vn.parking + * @param vParkingToFk Parking de llegada, identificador de vn.parking +*/ + + DECLARE vSectorFk INT; + DECLARE vPickingOrderFrom INT; + DECLARE vPickingOrderTo INT; + + SELECT ish.id, + p.pickingOrder, + p.code parking, + ish.shelvingFk, + ish.itemFk, + i.longName, + ish.visible, + p.sectorFk, + it.workerFk buyer, + CONCAT('http:',ic.url, '/catalog/1600x900/',i.image) urlImage, + ish.isChecked, + CASE + WHEN s.notPrepared > sm.parked THEN 0 + WHEN sm.visible > sm.parked THEN 1 + ELSE 2 + END + FROM vn.itemShelving ish + JOIN vn.item i ON i.id = ish.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN (SELECT s.itemFk, sum(s.quantity) notPrepared + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + WHERE t.shipped BETWEEN CURDATE() + AND CURDATE() + INTERVAL 23 HOUR + AND s.isPicked = FALSE + AND w.name = 'Algemesi' + GROUP BY s.itemFk) s ON s.itemFk = i.id + JOIN hedera.imageConfig ic + WHERE p.pickingOrder BETWEEN vParkingFrom AND vPickingOrderTo + AND p.sectorFk = vSectorFk + ORDER BY p.pickingOrder; + +END ;; +DELIMITER ; diff --git a/modules/item/back/methods/item-shelving/getInventory.js b/modules/item/back/methods/item-shelving/getInventory.js new file mode 100644 index 000000000..144bd83e7 --- /dev/null +++ b/modules/item/back/methods/item-shelving/getInventory.js @@ -0,0 +1,37 @@ +module.exports = Self => { + Self.remoteMethod('getInventory', { + description: 'Get list of itemShelving to review between two parking code', + accessType: 'WRITE', + accepts: [{ + arg: 'parkingFrom', + type: 'string', + required: true, + description: 'Parking code from' + }, + { + arg: 'parkingTo', + type: 'string', + required: true, + description: 'Parking code to' + }], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/getInventory`, + verb: 'POST' + } + }); + + Self.getInventory = async(parkingFrom, parkingTo, options) => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const [result] = await Self.rawSql(`CALL vn.itemShelving_inventory(?, ?)`, [parkingFrom, parkingTo], myOptions); + + return result; + }; +}; diff --git a/modules/item/back/methods/item-shelving/specs/getInventory.spec.js b/modules/item/back/methods/item-shelving/specs/getInventory.spec.js new file mode 100644 index 000000000..76cc39073 --- /dev/null +++ b/modules/item/back/methods/item-shelving/specs/getInventory.spec.js @@ -0,0 +1,19 @@ +const models = require('vn-loopback/server/server').models; + +describe('itemShelving getInventory()', () => { + it('should return a list of itemShelvings', async() => { + const tx = await models.ItemShelving.beginTransaction({}); + + let response; + try { + const options = {transaction: tx}; + response = await models.ItemShelving.getInventory(1, 2, options); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + + expect(response.length).toEqual(2); + }); +}); diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index 5f372a3be..98ff18931 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -1,3 +1,4 @@ module.exports = Self => { require('../methods/item-shelving/deleteItemShelvings')(Self); + require('../methods/item-shelving/getInventory')(Self); }; From b3a7a170f0522ff693be1684d3201b8914a8ca7e Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Jul 2023 11:54:43 +0200 Subject: [PATCH 71/91] =?UTF-8?q?refs=20#5934=20feat:=20a=C3=B1adido=20cli?= =?UTF-8?q?entSms=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/changes/233001/00-clientSms.sql | 15 +++++++ modules/client/back/methods/client/sendSms.js | 8 +++- modules/client/back/model-config.json | 3 ++ modules/client/back/models/client-sms.json | 29 +++++++++++++ modules/client/back/models/sms.json | 2 +- modules/client/front/index.js | 1 + modules/client/front/routes.json | 7 ++++ modules/client/front/sms/index.html | 42 +++++++++++++++++++ modules/client/front/sms/index.js | 39 +++++++++++++++++ modules/client/front/sms/locale/es.yml | 2 + 10 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 db/changes/233001/00-clientSms.sql create mode 100644 modules/client/back/models/client-sms.json create mode 100644 modules/client/front/sms/index.html create mode 100644 modules/client/front/sms/index.js create mode 100644 modules/client/front/sms/locale/es.yml diff --git a/db/changes/233001/00-clientSms.sql b/db/changes/233001/00-clientSms.sql new file mode 100644 index 000000000..353041ad9 --- /dev/null +++ b/db/changes/233001/00-clientSms.sql @@ -0,0 +1,15 @@ +CREATE TABLE `vn`.`clientSms` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `smsFk` mediumint(8) unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `clientSms_FK` (`clientFk`), + KEY `clientSms_FK_1` (`smsFk`), + CONSTRAINT `clientSms_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, + CONSTRAINT `clientSms_FK_1` FOREIGN KEY (`smsFk`) REFERENCES `sms` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('ClientSms', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('ClientSms', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/client/back/methods/client/sendSms.js b/modules/client/back/methods/client/sendSms.js index 83b7c8d6e..270d7e5b5 100644 --- a/modules/client/back/methods/client/sendSms.js +++ b/modules/client/back/methods/client/sendSms.js @@ -7,7 +7,7 @@ module.exports = Self => { arg: 'id', type: 'number', required: true, - description: 'The ticket id', + description: 'The client id', http: {source: 'path'} }, { @@ -33,6 +33,12 @@ module.exports = Self => { Self.sendSms = async(ctx, id, destination, message) => { const models = Self.app.models; const sms = await models.Sms.send(ctx, destination, message); + + await models.ClientSms.create({ + clientFk: id, + smsFk: sms.id + }); + return sms; }; }; diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index 1e06ea1c0..bc48ec360 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -95,6 +95,9 @@ "ClientSample": { "dataSource": "vn" }, + "ClientSms": { + "dataSource": "vn" + }, "Sms": { "dataSource": "vn" }, diff --git a/modules/client/back/models/client-sms.json b/modules/client/back/models/client-sms.json new file mode 100644 index 000000000..18d7ad051 --- /dev/null +++ b/modules/client/back/models/client-sms.json @@ -0,0 +1,29 @@ +{ + "name": "ClientSms", + "base": "VnModel", + "options": { + "mysql": { + "table": "clientSms" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "clientFk": { + "type": "number" + }, + "smsFk": { + "type": "number" + } + }, + "relations": { + "sms": { + "type": "belongsTo", + "model": "Sms", + "foreignKey": "smsFk" + } + } +} diff --git a/modules/client/back/models/sms.json b/modules/client/back/models/sms.json index 4639131ef..8f349b073 100644 --- a/modules/client/back/models/sms.json +++ b/modules/client/back/models/sms.json @@ -36,7 +36,7 @@ } }, "relations": { - "sender": { + "user": { "type": "belongsTo", "model": "VnUser", "foreignKey": "senderFk" diff --git a/modules/client/front/index.js b/modules/client/front/index.js index c7e39ea5d..62076459b 100644 --- a/modules/client/front/index.js +++ b/modules/client/front/index.js @@ -48,4 +48,5 @@ import './notification'; import './unpaid'; import './extended-list'; import './credit-management'; +import './sms'; diff --git a/modules/client/front/routes.json b/modules/client/front/routes.json index 01d1b53bf..773b7b22a 100644 --- a/modules/client/front/routes.json +++ b/modules/client/front/routes.json @@ -23,6 +23,7 @@ {"state": "client.card.recovery.index", "icon": "icon-recovery"}, {"state": "client.card.webAccess", "icon": "cloud"}, {"state": "client.card.log", "icon": "history"}, + {"state": "client.card.sms", "icon": "contact_support"}, { "description": "Credit management", "icon": "monetization_on", @@ -373,6 +374,12 @@ "component": "vn-client-log", "description": "Log" }, + { + "url" : "/sms", + "state": "client.card.sms", + "component": "vn-client-sms", + "description": "Sms" + }, { "url": "/dms", "state": "client.card.dms", diff --git a/modules/client/front/sms/index.html b/modules/client/front/sms/index.html new file mode 100644 index 000000000..db944e3b0 --- /dev/null +++ b/modules/client/front/sms/index.html @@ -0,0 +1,42 @@ + + + + + + + + Sender + Number sender + Destination + Message + Status + Created + + + + + + + {{::clientSms.sms.user.name}} + + + {{::clientSms.sms.sender}} + {{::clientSms.sms.destination}} + {{::clientSms.sms.message}} + {{::clientSms.sms.status}} + {{::clientSms.sms.created | date:'dd/MM/yyyy HH:mm'}} + + + + + + + diff --git a/modules/client/front/sms/index.js b/modules/client/front/sms/index.js new file mode 100644 index 000000000..1478b78e9 --- /dev/null +++ b/modules/client/front/sms/index.js @@ -0,0 +1,39 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + constructor($element, $) { + super($element, $); + + this.filter = { + fields: ['id', 'smsFk'], + include: { + relation: 'sms', + scope: { + fields: [ + 'senderFk', + 'sender', + 'destination', + 'message', + 'statusCode', + 'status', + 'created'], + include: { + relation: 'user', + scope: { + fields: ['name'] + } + } + } + } + }; + } +} + +ngModule.vnComponent('vnClientSms', { + template: require('./index.html'), + controller: Controller, + bindings: { + client: '<' + } +}); diff --git a/modules/client/front/sms/locale/es.yml b/modules/client/front/sms/locale/es.yml new file mode 100644 index 000000000..6d1e9e147 --- /dev/null +++ b/modules/client/front/sms/locale/es.yml @@ -0,0 +1,2 @@ +Sender: Remitente +Number sender: Número remitente From 3e8775149a4dc286ebedeeb4cd9b95a4157d2596 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Jul 2023 13:02:42 +0200 Subject: [PATCH 72/91] refs #5934 feat: change icon --- modules/client/back/models/sms.json | 2 +- modules/client/front/routes.json | 2 +- modules/client/front/sms/index.html | 4 +--- modules/client/front/sms/index.js | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/client/back/models/sms.json b/modules/client/back/models/sms.json index 8f349b073..4639131ef 100644 --- a/modules/client/back/models/sms.json +++ b/modules/client/back/models/sms.json @@ -36,7 +36,7 @@ } }, "relations": { - "user": { + "sender": { "type": "belongsTo", "model": "VnUser", "foreignKey": "senderFk" diff --git a/modules/client/front/routes.json b/modules/client/front/routes.json index 773b7b22a..63d6709e5 100644 --- a/modules/client/front/routes.json +++ b/modules/client/front/routes.json @@ -23,7 +23,7 @@ {"state": "client.card.recovery.index", "icon": "icon-recovery"}, {"state": "client.card.webAccess", "icon": "cloud"}, {"state": "client.card.log", "icon": "history"}, - {"state": "client.card.sms", "icon": "contact_support"}, + {"state": "client.card.sms", "icon": "sms"}, { "description": "Credit management", "icon": "monetization_on", diff --git a/modules/client/front/sms/index.html b/modules/client/front/sms/index.html index db944e3b0..3331f217b 100644 --- a/modules/client/front/sms/index.html +++ b/modules/client/front/sms/index.html @@ -13,7 +13,6 @@ Sender - Number sender Destination Message Status @@ -24,10 +23,9 @@ - {{::clientSms.sms.user.name}} + {{::clientSms.sms.sender.name}} - {{::clientSms.sms.sender}} {{::clientSms.sms.destination}} {{::clientSms.sms.message}} {{::clientSms.sms.status}} diff --git a/modules/client/front/sms/index.js b/modules/client/front/sms/index.js index 1478b78e9..6ad64282e 100644 --- a/modules/client/front/sms/index.js +++ b/modules/client/front/sms/index.js @@ -19,7 +19,7 @@ export default class Controller extends Section { 'status', 'created'], include: { - relation: 'user', + relation: 'sender', scope: { fields: ['name'] } From 9076553070b5ff5e7399eeb5df7d28904a86ba79 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 18 Jul 2023 14:11:50 +0200 Subject: [PATCH 73/91] refs #5983 test(itemShelving): add getInventory --- .../233001/00-itemShelving_inventory.sql | 94 +++++++++++-------- db/dump/fixtures.sql | 12 ++- .../item-shelving/specs/getInventory.spec.js | 7 +- 3 files changed, 70 insertions(+), 43 deletions(-) diff --git a/db/changes/233001/00-itemShelving_inventory.sql b/db/changes/233001/00-itemShelving_inventory.sql index b2a2ff321..c66ad69e9 100644 --- a/db/changes/233001/00-itemShelving_inventory.sql +++ b/db/changes/233001/00-itemShelving_inventory.sql @@ -1,52 +1,64 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_inventory`(vParkingFromFk INT, vParkingToFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_inventory`(vParkingFromFk VARCHAR(8), vParkingToFk VARCHAR(8)) +BEGIN /** * Devuelve un listado de ubicaciones a revisar * - * @param vParkingFromFk Parking de partida, identificador de vn.parking - * @param vParkingToFk Parking de llegada, identificador de vn.parking + * @param vParkingFromFk Parking de partida, identificador de parking + * @param vParkingToFk Parking de llegada, identificador de parking */ DECLARE vSectorFk INT; DECLARE vPickingOrderFrom INT; - DECLARE vPickingOrderTo INT; - - SELECT ish.id, - p.pickingOrder, - p.code parking, - ish.shelvingFk, - ish.itemFk, - i.longName, - ish.visible, - p.sectorFk, - it.workerFk buyer, - CONCAT('http:',ic.url, '/catalog/1600x900/',i.image) urlImage, - ish.isChecked, - CASE - WHEN s.notPrepared > sm.parked THEN 0 - WHEN sm.visible > sm.parked THEN 1 - ELSE 2 - END - FROM vn.itemShelving ish - JOIN vn.item i ON i.id = ish.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN (SELECT s.itemFk, sum(s.quantity) notPrepared - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE t.shipped BETWEEN CURDATE() - AND CURDATE() + INTERVAL 23 HOUR - AND s.isPicked = FALSE - AND w.name = 'Algemesi' - GROUP BY s.itemFk) s ON s.itemFk = i.id - JOIN hedera.imageConfig ic - WHERE p.pickingOrder BETWEEN vParkingFrom AND vPickingOrderTo - AND p.sectorFk = vSectorFk - ORDER BY p.pickingOrder; + DECLARE vPickingOrderTo INT; -END ;; + SELECT p.sectorFk, p.pickingOrder INTO vSectorFk, vPickingOrderFrom + FROM vn.parking p + WHERE p.code = vParkingFromFk COLLATE 'utf8mb3_general_ci'; + + SELECT p.pickingOrder INTO vPickingOrderTo + FROM vn.parking p + WHERE p.code = vParkingToFk COLLATE 'utf8mb3_general_ci'; + + CALL vn.visible_getMisfit(vSectorFk); + + SELECT ish.id, + p.pickingOrder, + p.code parking, + ish.shelvingFk, + ish.itemFk, + i.longName, + ish.visible, + p.sectorFk, + it.workerFk buyer, + CONCAT('http:',ic.url, '/catalog/1600x900/',i.image) urlImage, + ish.isChecked, + CASE + WHEN s.notPrepared > sm.parked THEN 0 + WHEN sm.visible > sm.parked THEN 1 + ELSE 2 + END priority + FROM vn.itemShelving ish + JOIN vn.item i ON i.id = ish.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN (SELECT s.itemFk, sum(s.quantity) notPrepared + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN vn.config c ON c.mainWarehouseFk = w.id + WHERE t.shipped BETWEEN util.VN_CURDATE() + AND util.VN_CURDATE() + INTERVAL 23 HOUR + AND s.isPicked = FALSE + GROUP BY s.itemFk) s ON s.itemFk = i.id + JOIN hedera.imageConfig ic + WHERE p.pickingOrder BETWEEN vPickingOrderFrom AND vPickingOrderTo + AND p.sectorFk = vSectorFk + ORDER BY p.pickingOrder; + +END$$ DELIMITER ; + diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index fe11d5b64..670a45778 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -37,7 +37,7 @@ ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1; INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) VALUES - ('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66); + ('DEFAULT_TOKEN', '1209600', CURDATE(), 66); INSERT INTO `salix`.`printConfig` (`id`, `itRecipient`, `incidencesEmail`) VALUES @@ -2953,3 +2953,13 @@ INSERT INTO `vn`.`invoiceInSerial` (`code`, `description`, `cplusTerIdNifFk`, `t ('E', 'Midgard', 1, 'CEE'), ('R', 'Jotunheim', 1, 'NATIONAL'), ('W', 'Vanaheim', 1, 'WORLD'); + + +INSERT INTO `hedera`.`imageConfig` (`id`, `maxSize`, `useXsendfile`, `url`) + VALUES + (1, 0, 0, 'marvel.com'); + +/* DELETE ME */ +UPDATE vn.config + SET mainWarehouseFk=1 + WHERE id=1; \ No newline at end of file diff --git a/modules/item/back/methods/item-shelving/specs/getInventory.spec.js b/modules/item/back/methods/item-shelving/specs/getInventory.spec.js index 76cc39073..6a8c9804c 100644 --- a/modules/item/back/methods/item-shelving/specs/getInventory.spec.js +++ b/modules/item/back/methods/item-shelving/specs/getInventory.spec.js @@ -7,7 +7,12 @@ describe('itemShelving getInventory()', () => { let response; try { const options = {transaction: tx}; - response = await models.ItemShelving.getInventory(1, 2, options); + await models.ItemShelving.rawSql(` + UPDATE vn.config + SET mainWarehouseFk=1 + WHERE id=1 + `, null, options); + response = await models.ItemShelving.getInventory('100-01', 'LR-02-3', options); await tx.rollback(); } catch (e) { await tx.rollback(); From 7bd378e9dde911c7176e92fc1d4a5883f44e071d Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Jul 2023 14:15:56 +0200 Subject: [PATCH 74/91] refs # --- back/models/company.json | 3 + db/changes/233001/00-company.sql | 1 + loopback/locale/en.json | 1 + loopback/locale/es.json | 4 +- .../back/methods/client/canBeInvoiced.js | 25 ++++++- .../ticket/back/methods/ticket/makeInvoice.js | 4 +- print/templates/reports/invoice/sql/sales.sql | 66 ++++++------------- 7 files changed, 53 insertions(+), 51 deletions(-) create mode 100644 db/changes/233001/00-company.sql diff --git a/back/models/company.json b/back/models/company.json index f16c5762f..f8b5641ac 100644 --- a/back/models/company.json +++ b/back/models/company.json @@ -18,6 +18,9 @@ }, "expired": { "type": "date" + }, + "supplierAccountFk": { + "type": "number" } }, "scope": { diff --git a/db/changes/233001/00-company.sql b/db/changes/233001/00-company.sql new file mode 100644 index 000000000..a3b61b9cc --- /dev/null +++ b/db/changes/233001/00-company.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`company` MODIFY COLUMN sage200Company int(2) DEFAULT 10 NOT NULL; diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 030afbe9e..5c7c10967 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -177,6 +177,7 @@ "Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address", "The renew period has not been exceeded": "The renew period has not been exceeded", "You can not use the same password": "You can not use the same password", + "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias", "Valid priorities": "Valid priorities: %d", "Negative basis of tickets": "Negative basis of tickets: {{ticketsIds}}" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 784ff5e6e..69f157a47 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -305,5 +305,7 @@ "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", "Valid priorities": "Prioridades válidas: %d", "Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}", - "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado" + "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado", + "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias" + " } diff --git a/modules/client/back/methods/client/canBeInvoiced.js b/modules/client/back/methods/client/canBeInvoiced.js index 567d491f1..843e9549f 100644 --- a/modules/client/back/methods/client/canBeInvoiced.js +++ b/modules/client/back/methods/client/canBeInvoiced.js @@ -1,3 +1,5 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = function(Self) { Self.remoteMethodCtx('canBeInvoiced', { description: 'Change property isEqualizated in all client addresses', @@ -9,6 +11,12 @@ module.exports = function(Self) { required: true, description: 'Client id', http: {source: 'path'} + }, + { + arg: 'companyFk', + description: 'The company id', + type: 'number', + required: true } ], returns: { @@ -22,18 +30,29 @@ module.exports = function(Self) { } }); - Self.canBeInvoiced = async(id, options) => { + Self.canBeInvoiced = async(id, companyFk, options) => { const models = Self.app.models; - const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); const client = await models.Client.findById(id, { - fields: ['id', 'isTaxDataChecked', 'hasToInvoice'] + fields: ['id', 'isTaxDataChecked', 'hasToInvoice', 'payMethodFk'], + include: + { + relation: 'payMethod', + scope: { + fields: ['code'] + } + } }, myOptions); + const company = await models.Company.findById(companyFk, {fields: ['supplierAccountFk']}, myOptions); + + if (client.payMethod().code === 'wireTransfer' && !company.supplierAccountFk) + throw new UserError('The company has not informed the supplier account for bank transfers'); + if (client.isTaxDataChecked && client.hasToInvoice) return true; diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index 22fe7b3f5..e18e58e0b 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -14,7 +14,7 @@ module.exports = function(Self) { { arg: 'companyFk', description: 'The company id', - type: 'string', + type: 'number', required: true }, { @@ -67,7 +67,7 @@ module.exports = function(Self) { const [firstTicket] = tickets; const clientId = firstTicket.clientFk; - const clientCanBeInvoiced = await models.Client.canBeInvoiced(clientId, myOptions); + const clientCanBeInvoiced = await models.Client.canBeInvoiced(clientId, companyFk, myOptions); if (!clientCanBeInvoiced) throw new UserError(`This client can't be invoiced`); diff --git a/print/templates/reports/invoice/sql/sales.sql b/print/templates/reports/invoice/sql/sales.sql index f5721a594..3833a3700 100644 --- a/print/templates/reports/invoice/sql/sales.sql +++ b/print/templates/reports/invoice/sql/sales.sql @@ -1,31 +1,19 @@ -SELECT +SELECT io.ref, - c.socialName, - sa.iban, - pm.name AS payMethod, - t.clientFk, - t.shipped, - t.nickname, s.ticketFk, - s.itemFk, - s.concept, - s.quantity, - s.price, + ib.ediBotanic botanical, + s.quantity, + s.price, s.discount, - i.tag5, - i.value5, - i.tag6, - i.value6, - i.tag7, - i.value7, - tc.code AS vatType, - ib.ediBotanic botanical + s.itemFk, + s.concept, + tc.code vatType FROM vn.invoiceOut io JOIN vn.ticket t ON t.refFk = io.ref JOIN vn.supplier su ON su.id = io.companyFk - JOIN vn.client c ON c.id = t.clientFk + JOIN vn.client c ON c.id = t.clientFk JOIN vn.payMethod pm ON pm.id = c.payMethodFk - JOIN vn.company co ON co.id = io.companyFk + JOIN vn.company co ON co.id = io.companyFk JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk JOIN vn.sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk @@ -38,35 +26,23 @@ SELECT AND itc.itemFk = s.itemFk JOIN vn.taxClass tc ON tc.id = itc.taxClassFk WHERE t.refFk = ? - UNION ALL -SELECT + UNION ALL +SELECT io.ref, - c.socialName, - sa.iban, - pm.name AS payMethod, - t.clientFk, - t.shipped, - t.nickname, - t.id AS ticketFk, + t.id ticketFk, + NULL botanical, + ts.quantity, + ts.price, + 0 discount, '', - ts.description concept, - ts.quantity, - ts.price, - 0 discount, - NULL AS tag5, - NULL AS value5, - NULL AS tag6, - NULL AS value6, - NULL AS tag7, - NULL AS value7, - tc.code AS vatType, - NULL AS botanical + ts.description concept, + tc.code vatType FROM vn.invoiceOut io JOIN vn.ticket t ON t.refFk = io.ref JOIN vn.ticketService ts ON ts.ticketFk = t.id - JOIN vn.client c ON c.id = t.clientFk + JOIN vn.client c ON c.id = t.clientFk JOIN vn.payMethod pm ON pm.id = c.payMethodFk - JOIN vn.company co ON co.id = io.companyFk + JOIN vn.company co ON co.id = io.companyFk JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk JOIN vn.taxClass tc ON tc.id = ts.taxClassFk - WHERE t.refFk = ? \ No newline at end of file + WHERE t.refFk = ? From 4c7f42acb5a05bd868dbc095feff9504d80f2d91 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Jul 2023 14:17:07 +0200 Subject: [PATCH 75/91] a --- loopback/locale/es.json | 1 - 1 file changed, 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 69f157a47..9412a9571 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -307,5 +307,4 @@ "Negative basis of tickets": "Base negativa para los tickets: {{ticketsIds}}", "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado", "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias" - " } From d3165fcdc75c74bb05a15060dcfec1c55bc80394 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Jul 2023 14:25:53 +0200 Subject: [PATCH 76/91] refs #5849 fix: tback --- .../client/back/methods/client/specs/canBeInvoiced.spec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/client/back/methods/client/specs/canBeInvoiced.spec.js b/modules/client/back/methods/client/specs/canBeInvoiced.spec.js index 2f11d8013..397be3c92 100644 --- a/modules/client/back/methods/client/specs/canBeInvoiced.spec.js +++ b/modules/client/back/methods/client/specs/canBeInvoiced.spec.js @@ -4,6 +4,7 @@ const LoopBackContext = require('loopback-context'); describe('client canBeInvoiced()', () => { const userId = 19; const clientId = 1101; + const companyId = 442; const activeCtx = { accessToken: {userId: userId} }; @@ -23,7 +24,7 @@ describe('client canBeInvoiced()', () => { const client = await models.Client.findById(clientId, null, options); await client.updateAttribute('isTaxDataChecked', false, options); - const canBeInvoiced = await models.Client.canBeInvoiced(clientId, options); + const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); expect(canBeInvoiced).toEqual(false); @@ -43,7 +44,7 @@ describe('client canBeInvoiced()', () => { const client = await models.Client.findById(clientId, null, options); await client.updateAttribute('hasToInvoice', false, options); - const canBeInvoiced = await models.Client.canBeInvoiced(clientId, options); + const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); expect(canBeInvoiced).toEqual(false); @@ -60,7 +61,7 @@ describe('client canBeInvoiced()', () => { try { const options = {transaction: tx}; - const canBeInvoiced = await models.Client.canBeInvoiced(clientId, options); + const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); expect(canBeInvoiced).toEqual(true); From bd723bb7ba540771f786ecd3bc9972781d92e0ca Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 18 Jul 2023 15:01:58 +0200 Subject: [PATCH 77/91] refs #5824 mod ng --- modules/item/front/fixed-price/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/front/fixed-price/index.html b/modules/item/front/fixed-price/index.html index d9a955fe1..f1f6e1419 100644 --- a/modules/item/front/fixed-price/index.html +++ b/modules/item/front/fixed-price/index.html @@ -85,7 +85,7 @@ show-field="id" value-field="id" search-function="$ctrl.itemSearchFunc($search)" - on-change="$ctrl.upsertPrice(price, true)" + ng-change="$ctrl.upsertPrice(price, true)" order="id DESC" tabindex="1"> From 49c656928ed8049f00f333c4e7cb482d836cefd1 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 18 Jul 2023 15:43:11 +0200 Subject: [PATCH 78/91] refs #5983 feat(itemShelving): add visible --- modules/item/back/models/item-shelving.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 49bebcb6b..be379adca 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -23,6 +23,9 @@ }, "isChecked": { "type": "boolean" + }, + "visible": { + "type": "number" } }, "relations": { From 85c017431ce9c199bfa0f7f5a1e394cd43b8931f Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 19 Jul 2023 07:01:43 +0200 Subject: [PATCH 79/91] refs #5983 fix(itemShelving): fixtures --- db/dump/fixtures.sql | 5 ----- 1 file changed, 5 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 670a45778..eaa00a3de 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2958,8 +2958,3 @@ INSERT INTO `vn`.`invoiceInSerial` (`code`, `description`, `cplusTerIdNifFk`, `t INSERT INTO `hedera`.`imageConfig` (`id`, `maxSize`, `useXsendfile`, `url`) VALUES (1, 0, 0, 'marvel.com'); - -/* DELETE ME */ -UPDATE vn.config - SET mainWarehouseFk=1 - WHERE id=1; \ No newline at end of file From b17de86fb1f7f94e6f892f0662ec09d8d5d467f8 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 19 Jul 2023 12:15:52 +0200 Subject: [PATCH 80/91] refs #6043 add ACL --- db/changes/233001/00-fixACLVehicle.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/changes/233001/00-fixACLVehicle.sql diff --git a/db/changes/233001/00-fixACLVehicle.sql b/db/changes/233001/00-fixACLVehicle.sql new file mode 100644 index 000000000..6625f0d5c --- /dev/null +++ b/db/changes/233001/00-fixACLVehicle.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`) + VALUES + ('Vehicle','sorted','WRITE','ALLOW','employee'); \ No newline at end of file From 7cff0149887a1eb09d586a51212798caa97d570a Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 19 Jul 2023 13:27:31 +0200 Subject: [PATCH 81/91] refs #5983 fix(itemShelving): vn --- .../233001/00-itemShelving_inventory.sql | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/db/changes/233001/00-itemShelving_inventory.sql b/db/changes/233001/00-itemShelving_inventory.sql index c66ad69e9..b0b080ef3 100644 --- a/db/changes/233001/00-itemShelving_inventory.sql +++ b/db/changes/233001/00-itemShelving_inventory.sql @@ -14,14 +14,14 @@ BEGIN DECLARE vPickingOrderTo INT; SELECT p.sectorFk, p.pickingOrder INTO vSectorFk, vPickingOrderFrom - FROM vn.parking p + FROM parking p WHERE p.code = vParkingFromFk COLLATE 'utf8mb3_general_ci'; SELECT p.pickingOrder INTO vPickingOrderTo - FROM vn.parking p + FROM parking p WHERE p.code = vParkingToFk COLLATE 'utf8mb3_general_ci'; - CALL vn.visible_getMisfit(vSectorFk); + CALL visible_getMisfit(vSectorFk); SELECT ish.id, p.pickingOrder, @@ -39,19 +39,19 @@ BEGIN WHEN sm.visible > sm.parked THEN 1 ELSE 2 END priority - FROM vn.itemShelving ish - JOIN vn.item i ON i.id = ish.itemFk - JOIN vn.itemType it ON it.id = i.typeFk + FROM itemShelving ish + JOIN item i ON i.id = ish.itemFk + JOIN itemType it ON it.id = i.typeFk JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON p.id = sh.parkingFk JOIN (SELECT s.itemFk, sum(s.quantity) notPrepared - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - JOIN vn.config c ON c.mainWarehouseFk = w.id + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN warehouse w ON w.id = t.warehouseFk + JOIN config c ON c.mainWarehouseFk = w.id WHERE t.shipped BETWEEN util.VN_CURDATE() - AND util.VN_CURDATE() + INTERVAL 23 HOUR + AND util.dayEnd(util.VN_CURDATE()) AND s.isPicked = FALSE GROUP BY s.itemFk) s ON s.itemFk = i.id JOIN hedera.imageConfig ic From ab95ef74a945c4c232f2cb6a9a73c9c51f767147 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Jul 2023 07:17:35 +0200 Subject: [PATCH 82/91] refs #5934 refactor: nombres variables --- db/changes/233001/00-clientSms.sql | 6 +++--- modules/client/back/models/client-sms.json | 3 --- modules/client/front/sms/index.html | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/db/changes/233001/00-clientSms.sql b/db/changes/233001/00-clientSms.sql index 353041ad9..e1e34f6b2 100644 --- a/db/changes/233001/00-clientSms.sql +++ b/db/changes/233001/00-clientSms.sql @@ -7,9 +7,9 @@ CREATE TABLE `vn`.`clientSms` ( KEY `clientSms_FK_1` (`smsFk`), CONSTRAINT `clientSms_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, CONSTRAINT `clientSms_FK_1` FOREIGN KEY (`smsFk`) REFERENCES `sms` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES - ('ClientSms', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('ClientSms', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); + ('ClientSms', 'find', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('ClientSms', 'create', 'WRITE', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/client/back/models/client-sms.json b/modules/client/back/models/client-sms.json index 18d7ad051..b2244ebbb 100644 --- a/modules/client/back/models/client-sms.json +++ b/modules/client/back/models/client-sms.json @@ -14,9 +14,6 @@ }, "clientFk": { "type": "number" - }, - "smsFk": { - "type": "number" } }, "relations": { diff --git a/modules/client/front/sms/index.html b/modules/client/front/sms/index.html index 3331f217b..9abadd312 100644 --- a/modules/client/front/sms/index.html +++ b/modules/client/front/sms/index.html @@ -3,7 +3,7 @@ url="ClientSms" link="{clientFk: $ctrl.$params.id}" filter="::$ctrl.filter" - data="clientSmss" + data="clientSmsList" limit="20" auto-load="true"> @@ -20,7 +20,7 @@ - + {{::clientSms.sms.sender.name}} From b13618529aebd455f42d1285dbe59e2c6313549a Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Jul 2023 07:21:38 +0200 Subject: [PATCH 83/91] =?UTF-8?q?refs=20#5849=20delete:=20traducci=C3=B3n?= =?UTF-8?q?=20erronea?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loopback/locale/en.json | 1 - 1 file changed, 1 deletion(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 5c7c10967..030afbe9e 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -177,7 +177,6 @@ "Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address", "The renew period has not been exceeded": "The renew period has not been exceeded", "You can not use the same password": "You can not use the same password", - "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias", "Valid priorities": "Valid priorities: %d", "Negative basis of tickets": "Negative basis of tickets: {{ticketsIds}}" } From 60e75d7825cfdc9c5222700ac0f36cf3d92101e0 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 20 Jul 2023 08:23:43 +0200 Subject: [PATCH 84/91] refs #5837 fix client condition --- modules/client/back/models/client.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 163d51fc5..8369fa906 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -41,6 +41,9 @@ module.exports = Self => { }); async function socialNameIsUnique(err, done) { + if (!this.countryFk) + return done(); + const filter = { include: { relation: 'country', @@ -59,13 +62,11 @@ module.exports = Self => { } }; - const existingClient = await Self.app.models.Client.findOne(filter); + const client = await Self.app.models.Country.findById(this.countryFk, {fields: ['isSocialNameUnique']}); + const existingClient = await Self.findOne(filter); - if (existingClient) { - // eslint-disable-next-line max-len - if (existingClient.country().isSocialNameUnique && this.socialName === existingClient.socialName) - err(); - } + if (existingClient && (existingClient.country().isSocialNameUnique || client.isSocialNameUnique)) + err(); done(); } From 0585080303f72750987698c299e4d716ca13890f Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 20 Jul 2023 09:26:40 +0200 Subject: [PATCH 85/91] refs #6011 deploy 2330 version --- CHANGELOG.md | 5 +++++ db/changes/232401/00-ACLgetVehiclesSorted.sql | 3 --- db/changes/{232801 => 233001}/00-roadmap.sql | 2 -- db/changes/{232801 => 233001}/00-roadmapACL.sql | 0 4 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 db/changes/232401/00-ACLgetVehiclesSorted.sql rename db/changes/{232801 => 233001}/00-roadmap.sql (69%) rename db/changes/{232801 => 233001}/00-roadmapACL.sql (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76527ac83..847275825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2330.01] - 2023-07-27 ### Added +- (Artículos -> Vista Previa) Añadido campo "Plástico reciclado" +- (Rutas -> Troncales) Nueva sección +- (Tickets -> Opciones) Opción establecer peso ### Changed +- (General -> Iconos) Añadidos nuevos iconos + ### Fixed diff --git a/db/changes/232401/00-ACLgetVehiclesSorted.sql b/db/changes/232401/00-ACLgetVehiclesSorted.sql deleted file mode 100644 index 6625f0d5c..000000000 --- a/db/changes/232401/00-ACLgetVehiclesSorted.sql +++ /dev/null @@ -1,3 +0,0 @@ -INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`) - VALUES - ('Vehicle','sorted','WRITE','ALLOW','employee'); \ No newline at end of file diff --git a/db/changes/232801/00-roadmap.sql b/db/changes/233001/00-roadmap.sql similarity index 69% rename from db/changes/232801/00-roadmap.sql rename to db/changes/233001/00-roadmap.sql index a2835160f..9b5db54eb 100644 --- a/db/changes/232801/00-roadmap.sql +++ b/db/changes/233001/00-roadmap.sql @@ -6,5 +6,3 @@ ALTER TABLE `vn`.`roadmap` CHANGE name name varchar(45) CHARACTER SET utf8mb3 CO ALTER TABLE `vn`.`roadmap` MODIFY COLUMN etd datetime NOT NULL; ALTER TABLE `vn`.`expeditionTruck` COMMENT='Distintas paradas que hacen los trocales'; -ALTER TABLE `vn`.`expeditionTruck` DROP FOREIGN KEY expeditionTruck_FK_2; -ALTER TABLE `vn`.`expeditionTruck` ADD CONSTRAINT expeditionTruck_FK_2 FOREIGN KEY (roadmapFk) REFERENCES vn.roadmap(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/changes/232801/00-roadmapACL.sql b/db/changes/233001/00-roadmapACL.sql similarity index 100% rename from db/changes/232801/00-roadmapACL.sql rename to db/changes/233001/00-roadmapACL.sql From 071a891d30079e13792765a7578b5aae03da6ee2 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 20 Jul 2023 09:30:18 +0200 Subject: [PATCH 86/91] refs #6011 add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 847275825..d5928e9c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - (Artículos -> Vista Previa) Añadido campo "Plástico reciclado" - (Rutas -> Troncales) Nueva sección - (Tickets -> Opciones) Opción establecer peso +- (Clientes -> SMS) Nueva sección ### Changed - (General -> Iconos) Añadidos nuevos iconos +- (Clientes -> Razón social) Nuevas restricciones por pais ### Fixed From 75ea5942729af3e528157f6b946ef0d3679596e7 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 20 Jul 2023 09:32:52 +0200 Subject: [PATCH 87/91] refs #6011 deploy(2332): init version --- CHANGELOG.md | 9 +++++++++ db/changes/233201/.gitkeep | 0 package-lock.json | 2 +- package.json | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 db/changes/233201/.gitkeep diff --git a/CHANGELOG.md b/CHANGELOG.md index d5928e9c4..d4a1e147f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ 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). +## [2330.01] - 2023-07-27 + +### Added + +### Changed + +### Fixed + + ## [2330.01] - 2023-07-27 ### Added diff --git a/db/changes/233201/.gitkeep b/db/changes/233201/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/package-lock.json b/package-lock.json index ee6d4e0fa..5506075b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.30.01", + "version": "23.32.01", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 66e341ad5..37e39d5a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.30.01", + "version": "23.32.01", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 9db8ae237fcbb9fce120af1f237d7b6496338fd7 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 20 Jul 2023 10:19:03 +0200 Subject: [PATCH 88/91] refs #5866 addBackTransferClient --- db/changes/233001/00-transferClient.sql | 2 + .../back/methods/ticket/transferClient.js | 69 +++++++++++++++++++ modules/ticket/back/models/ticket-methods.js | 1 + modules/ticket/front/descriptor-menu/index.js | 8 +++ 4 files changed, 80 insertions(+) create mode 100644 db/changes/233001/00-transferClient.sql create mode 100644 modules/ticket/back/methods/ticket/transferClient.js diff --git a/db/changes/233001/00-transferClient.sql b/db/changes/233001/00-transferClient.sql new file mode 100644 index 000000000..8a7ce0543 --- /dev/null +++ b/db/changes/233001/00-transferClient.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) + VALUES ('Ticket','transferClient','WRITE','ALLOW','ROLE','administrative'); \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/transferClient.js b/modules/ticket/back/methods/ticket/transferClient.js new file mode 100644 index 000000000..226f5dedf --- /dev/null +++ b/modules/ticket/back/methods/ticket/transferClient.js @@ -0,0 +1,69 @@ +const UserError = require('vn-loopback/util/user-error'); +module.exports = Self => { + Self.remoteMethodCtx('transferClient', { + description: 'Transfering ticket to another client', + accessType: 'WRITE', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'the ticket id', + http: {source: 'path'} + }, + { + arg: 'data', + type: 'object', + required: true, + description: 'the client id', + http: {source: 'body'} + }, + ], + returns: { + type: 'boolean', + root: true + }, + http: { + path: `/:id/transferClient`, + verb: 'PATCH' + } + }); + + Self.transferClient = async(ctx, ticketId, params) => { + const models = Self.app.models; + const args = ctx.args; + const myOptions = {}; + try { + const clientId = params.clientId; + const isEditable = await Self.isEditable(ctx, args.id, myOptions); + console.log('es editable?',isEditable) // Revisar + /* if (!isEditable){ + console.log('no es editable!') + throw new UserError(`The sales of this ticket can't be modified`); + } */ + + const ticket = await models.Ticket.findById(ticketId, myOptions); + console.log('ticket',ticket); + if(!ticket) return false; + const nparams = { + clientFk: clientId, + addressFk: ticket.addressFk, + } + + const promise = await ticket.updateAttributes(nparams); + console.log('promise', promise); + if(promise) return true; + } catch (error) { + console.log(error); + } + + /* if (typeof options == 'object') + Object.assign(myOptions, options); + + const ticket = await Self.findById(id, { + fields: ['isDeleted', 'refFk'] + }, myOptions); */ + + return false; + }; +}; \ No newline at end of file diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index f0c85ecc4..b432c9f6b 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -19,6 +19,7 @@ module.exports = function(Self) { require('../methods/ticket/uploadFile')(Self); require('../methods/ticket/addSale')(Self); require('../methods/ticket/transferSales')(Self); + require('../methods/ticket/transferClient')(Self); require('../methods/ticket/recalculateComponents')(Self); require('../methods/ticket/sendSms')(Self); require('../methods/ticket/isLocked')(Self); diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 0fc8488ca..019ae4fa6 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -96,6 +96,14 @@ class Controller extends Section { } transferClient() { + const ticket = this.ticket; + const clientId = ticket.client.id; + console.log('ticketId',ticket.id) + console.log('clientId',clientId); + this.$http.patch(`Tickets/${ticket.id}/transferClient`, {clientId}).then(() =>{ + this.vnApp.showSuccess(this.$t('Data saved!')); + this.reload(); + }) this.$http.get(`Clients/${this.ticket.client.id}`).then(client => { const ticket = this.ticket; From 618989052a481df85338fa54ec297c0ae57d876c Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 20 Jul 2023 15:15:33 +0200 Subject: [PATCH 89/91] refs #5866 fix transferClient and test added --- .../{233001 => 233201}/00-transferClient.sql | 0 .../ticket/specs/transferClient.spec.js | 49 +++++++++++++++ .../back/methods/ticket/transferClient.js | 60 +++++++------------ modules/ticket/front/descriptor-menu/index.js | 18 +----- .../front/descriptor-menu/index.spec.js | 13 ---- 5 files changed, 71 insertions(+), 69 deletions(-) rename db/changes/{233001 => 233201}/00-transferClient.sql (100%) create mode 100644 modules/ticket/back/methods/ticket/specs/transferClient.spec.js diff --git a/db/changes/233001/00-transferClient.sql b/db/changes/233201/00-transferClient.sql similarity index 100% rename from db/changes/233001/00-transferClient.sql rename to db/changes/233201/00-transferClient.sql diff --git a/modules/ticket/back/methods/ticket/specs/transferClient.spec.js b/modules/ticket/back/methods/ticket/specs/transferClient.spec.js new file mode 100644 index 000000000..ed10e5159 --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/transferClient.spec.js @@ -0,0 +1,49 @@ +const models = require('vn-loopback/server/server').models; + +describe('Ticket transferClient()', () => { + const userId = 9; + const activeCtx = { + accessToken: {userId: userId}, + }; + const ctx = {req: activeCtx}; + + it('should throw an error as the ticket is not editable', async() => { + const tx = await models.Ticket.beginTransaction({}); + let error; + + try { + const options = {transaction: tx}; + const ticketId = 4; + const clientId = 1; + await models.Ticket.transferClient(ctx, ticketId, clientId, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toEqual(`The current ticket can't be modified`); + }); + + it('should be assigned a different clientFk', async() => { + const tx = await models.Ticket.beginTransaction({}); + let updatedTicket; + const ticketId = 10; + const clientId = 1; + + try { + const options = {transaction: tx}; + + await models.Ticket.transferClient(ctx, ticketId, clientId, options); + updatedTicket = await models.Ticket.findById(ticketId, {fields: ['clientFk']}, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + + expect(updatedTicket.clientFk).toEqual(clientId); + }); +}); diff --git a/modules/ticket/back/methods/ticket/transferClient.js b/modules/ticket/back/methods/ticket/transferClient.js index 226f5dedf..05ea27fa0 100644 --- a/modules/ticket/back/methods/ticket/transferClient.js +++ b/modules/ticket/back/methods/ticket/transferClient.js @@ -12,58 +12,38 @@ module.exports = Self => { http: {source: 'path'} }, { - arg: 'data', - type: 'object', + arg: 'clientId', + type: 'number', required: true, - description: 'the client id', - http: {source: 'body'} }, ], - returns: { - type: 'boolean', - root: true - }, http: { path: `/:id/transferClient`, verb: 'PATCH' } }); - Self.transferClient = async(ctx, ticketId, params) => { + Self.transferClient = async(ctx, ticketId, clientId, options) => { const models = Self.app.models; - const args = ctx.args; const myOptions = {}; - try { - const clientId = params.clientId; - const isEditable = await Self.isEditable(ctx, args.id, myOptions); - console.log('es editable?',isEditable) // Revisar - /* if (!isEditable){ - console.log('no es editable!') - throw new UserError(`The sales of this ticket can't be modified`); - } */ - - const ticket = await models.Ticket.findById(ticketId, myOptions); - console.log('ticket',ticket); - if(!ticket) return false; - const nparams = { - clientFk: clientId, - addressFk: ticket.addressFk, - } - - const promise = await ticket.updateAttributes(nparams); - console.log('promise', promise); - if(promise) return true; - } catch (error) { - console.log(error); - } - - /* if (typeof options == 'object') + if (typeof options == 'object') Object.assign(myOptions, options); - const ticket = await Self.findById(id, { - fields: ['isDeleted', 'refFk'] - }, myOptions); */ + const isEditable = await Self.isEditable(ctx, ticketId, myOptions); - return false; + if (!isEditable) + throw new UserError(`The current ticket can't be modified`); + + const ticket = await models.Ticket.findById( + ticketId, + {fields: ['id', 'shipped', 'clientFk', 'addressFk']}, + myOptions + ); + const client = await models.Client.findById(clientId, {fields: ['id', 'defaultAddressFk']}, myOptions); + + await ticket.updateAttributes({ + clientFk: clientId, + addressFk: client.defaultAddressFk, + }); }; -}; \ No newline at end of file +}; diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 019ae4fa6..62a233891 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -98,26 +98,12 @@ class Controller extends Section { transferClient() { const ticket = this.ticket; const clientId = ticket.client.id; - console.log('ticketId',ticket.id) - console.log('clientId',clientId); - this.$http.patch(`Tickets/${ticket.id}/transferClient`, {clientId}).then(() =>{ - this.vnApp.showSuccess(this.$t('Data saved!')); - this.reload(); - }) - this.$http.get(`Clients/${this.ticket.client.id}`).then(client => { - const ticket = this.ticket; - const params = - { - clientFk: client.data.id, - addressFk: client.data.defaultAddressFk, - }; - - this.$http.patch(`Tickets/${ticket.id}`, params).then(() => { + this.$http.patch(`Tickets/${ticket.id}/transferClient`, {clientId}) + .then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); this.reload(); }); - }); } isTicketEditable() { diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 914fe486c..1bb270165 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -326,17 +326,4 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { expect(controller.vnApp.showSuccess).toHaveBeenCalled(); }); }); - - describe('transferClient()', () => { - it(`should perform two queries, a get to obtain the clientData and a patch to update the ticket`, () => { - const client = - { - clientFk: 1101, - addressFk: 1, - }; - $httpBackend.expect('GET', `Clients/${ticket.client.id}`).respond(client); - $httpBackend.expect('PATCH', `Tickets/${ticket.id}`).respond(); - controller.transferClient(); - }); - }); }); From eb963ff993f8f142298a6edefc631f2451fbf90b Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 21 Jul 2023 08:28:19 +0200 Subject: [PATCH 90/91] refs #5866 fix(transferClient): correct variable name --- modules/ticket/back/methods/ticket/transferClient.js | 12 ++++++------ modules/ticket/front/descriptor-menu/index.js | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/ticket/back/methods/ticket/transferClient.js b/modules/ticket/back/methods/ticket/transferClient.js index 05ea27fa0..04c153bd2 100644 --- a/modules/ticket/back/methods/ticket/transferClient.js +++ b/modules/ticket/back/methods/ticket/transferClient.js @@ -12,7 +12,7 @@ module.exports = Self => { http: {source: 'path'} }, { - arg: 'clientId', + arg: 'clientFk', type: 'number', required: true, }, @@ -23,26 +23,26 @@ module.exports = Self => { } }); - Self.transferClient = async(ctx, ticketId, clientId, options) => { + Self.transferClient = async(ctx, id, clientFk, options) => { const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - const isEditable = await Self.isEditable(ctx, ticketId, myOptions); + const isEditable = await Self.isEditable(ctx, id, myOptions); if (!isEditable) throw new UserError(`The current ticket can't be modified`); const ticket = await models.Ticket.findById( - ticketId, + id, {fields: ['id', 'shipped', 'clientFk', 'addressFk']}, myOptions ); - const client = await models.Client.findById(clientId, {fields: ['id', 'defaultAddressFk']}, myOptions); + const client = await models.Client.findById(clientFk, {fields: ['id', 'defaultAddressFk']}, myOptions); await ticket.updateAttributes({ - clientFk: clientId, + clientFk, addressFk: client.defaultAddressFk, }); }; diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 62a233891..7bdefcd97 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -97,9 +97,9 @@ class Controller extends Section { transferClient() { const ticket = this.ticket; - const clientId = ticket.client.id; + const clientFk = ticket.client.id; - this.$http.patch(`Tickets/${ticket.id}/transferClient`, {clientId}) + this.$http.patch(`Tickets/${ticket.id}/transferClient`, {clientFk}) .then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); this.reload(); From 203f6a5659f6fdead03c013a43f2b59ec881e5f8 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 21 Jul 2023 12:41:16 +0200 Subject: [PATCH 91/91] refs #5712 correct sql folder --- db/changes/{232801 => 233201}/00-workerDocuware.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/{232801 => 233201}/00-workerDocuware.sql (100%) diff --git a/db/changes/232801/00-workerDocuware.sql b/db/changes/233201/00-workerDocuware.sql similarity index 100% rename from db/changes/232801/00-workerDocuware.sql rename to db/changes/233201/00-workerDocuware.sql