From a48fa07cad7ca966dee3196831ebad404c9cf789 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 30 Jan 2019 14:27:35 +0100 Subject: [PATCH 1/8] #1069 activeWrokersWithRole now returns the nickname --- modules/client/back/methods/client/activeWorkersWithRole.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/client/back/methods/client/activeWorkersWithRole.js b/modules/client/back/methods/client/activeWorkersWithRole.js index 5e13e9bf6..3b0ccaac2 100644 --- a/modules/client/back/methods/client/activeWorkersWithRole.js +++ b/modules/client/back/methods/client/activeWorkersWithRole.js @@ -40,7 +40,7 @@ module.exports = Self => { return {or: [ {'w.firstName': {like: `%${value}%`}}, {'w.name': {like: `%${value}%`}}, - {'u.name': {like: `%${value}%`}} + {'u.nickname': {like: `%${value}%`}} ]}; case 'id': return {'w.id': value}; @@ -54,7 +54,7 @@ module.exports = Self => { myFilter = mergeFilters(myFilter, clientFilter); let stmt = new ParameterizedSQL( - `SELECT DISTINCT w.id, w.firstName, w.name + `SELECT DISTINCT w.id, w.firstName, w.name, u.nickname FROM worker w JOIN account.user u ON u.id = w.userFk JOIN account.roleRole i ON i.role = u.role From f4e202dc62c89c3ea0dd817450b73d8c5d3dba97 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 30 Jan 2019 15:10:52 +0100 Subject: [PATCH 2/8] #1069 index now show nicknames --- modules/claim/front/index/index.html | 2 +- modules/claim/front/index/index.js | 8 +- modules/item/back/methods/item/filter.js | 5 +- modules/item/front/index/product.html | 3 +- modules/order/back/methods/order/filter.js | 156 ++++++++++++++++++ modules/order/front/index/index.html | 4 + modules/order/front/index/index.js | 17 +- modules/ticket/back/methods/ticket/filter.js | 8 +- modules/ticket/front/index/index.html | 2 +- modules/ticket/front/tracking/edit/index.html | 4 +- 10 files changed, 196 insertions(+), 13 deletions(-) create mode 100644 modules/order/back/methods/order/filter.js diff --git a/modules/claim/front/index/index.html b/modules/claim/front/index/index.html index 0c7a821bb..85c79b4f7 100644 --- a/modules/claim/front/index/index.html +++ b/modules/claim/front/index/index.html @@ -42,7 +42,7 @@ {{::claim.created | date:'dd/MM/yyyy'}} - {{::claim.worker.firstName}} {{::claim.worker.name}} + {{::claim.worker.user.nickname}} {{::claim.claimState.description}} { `SELECT i.id, i.image, i.name, i.description, i.size, i.tag5, i.value5, i.tag6, i.value6, i.tag7, i.value7, i.tag8, i.value8, - t.name type, w.firstName, w.name worker + t.name type, u.nickname userNickname FROM item i JOIN itemType t ON t.id = i.typeFk - JOIN worker w ON w.id = t.workerFk` + JOIN worker w ON w.id = t.workerFk + JOIN account.user u ON u.id = w.userFk` ); if (tags) { diff --git a/modules/item/front/index/product.html b/modules/item/front/index/product.html index 6c1b0d4d7..a390e2e09 100644 --- a/modules/item/front/index/product.html +++ b/modules/item/front/index/product.html @@ -18,7 +18,7 @@ value="{{::$ctrl.item.type}}"> + value="{{::$ctrl.item.userNickname}}"> @@ -36,4 +36,3 @@ - diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js new file mode 100644 index 000000000..ba8641f84 --- /dev/null +++ b/modules/order/back/methods/order/filter.js @@ -0,0 +1,156 @@ + +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +const buildFilter = require('vn-loopback/util/filter').buildFilter; +const mergeFilters = require('vn-loopback/util/filter').mergeFilters; + +module.exports = Self => { + Self.remoteMethod('filter', { + description: 'Find all instances of the model matched by filter from the data source.', + accepts: [ + { + arg: 'ctx', + type: 'Object', + http: {source: 'context'} + }, { + arg: 'filter', + type: 'Object', + description: `Filter defining where, order, offset, and limit - must be a JSON-encoded string` + }, { + arg: 'search', + type: 'String', + description: `The search value` + }, { + arg: 'id', + type: 'Integer', + description: `The order id` + }, { + arg: 'clientFk', + type: 'Integer', + description: `The client id` + }, { + arg: 'agencyModeFk', + type: 'Integer', + description: `The agency id` + }, { + arg: 'workerFk', + type: 'Integer', + description: `The worker id` + }, { + arg: 'from', + type: 'Date', + description: `The from date` + }, { + arg: 'to', + type: 'Date', + description: `The to date` + }, { + arg: 'sourceApp', + type: 'Date', + description: `The source app used` + }, { + arg: 'isConfirmed', + type: 'Boolean', + description: `The state of the order` + } + ], + returns: { + type: ['Object'], + root: true + }, + http: { + path: '/filter', + verb: 'GET' + } + }); + + Self.filter = async(ctx, filter) => { + let where = buildFilter(ctx.args, (param, value) => { + switch (param) { + case 'search': + return {'o.id': value}; + case 'from': + return {'o.landed': {gte: value}}; + case 'to': + return {'o.landed': {lte: value}}; + case 'clientFk': + return {'o.clientFk': value}; + case 'salesPersonFk': + return {'c.salesPersonFk': value}; + case 'ticketFk': + return {'t.id': value}; + case 'stateFk': + return {'ts.stateFk': value}; + case 'mine': + case 'myTeam': + return {'c.salesPersonFk': {inq: teamIds}}; + case 'alertLevel': + return {'ts.alertLevel': value}; + // case 'id': + // case 'clientFk': + // case 'agencyModeFk': + // case 'warehouseFk': + // param = `t.${param}`; + // return {[param]: value}; + } + }); + + filter = mergeFilters(filter, {where}); + + let stmts = []; + let stmt; + + // stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter'); + + stmt = new ParameterizedSQL(` + SELECT + o.id, c.id clientFk, c.name clientName, wk.name workerName, o.isConfirmed, o.source_app sourceApp, o.date_make created, o.date_send landed, com.code companyCode + FROM hereda.order o + LEFT JOIN client c ON c.id = o.clientFk + LEFT JOIN worker wk ON wk.id = c.salesPersonFk + LEFT JOIN company com ON com.id = o.company_id + LEFT JOIN orderTicket ot ON ot.orderFk = o.id + `); + + stmt.merge(conn.makeSuffix(filter)); + stmts.push(stmt); + + // stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.ticketGetProblems'); + // stmts.push(` + // CREATE TEMPORARY TABLE tmp.ticketGetProblems + // (INDEX (ticketFk)) + // ENGINE = MEMORY + // SELECT id ticketFk, clientFk, warehouseFk, shipped + // FROM tmp.filter`); + // stmts.push('CALL ticketGetProblems()'); + + // stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.ticket'); + // stmts.push(` + // CREATE TEMPORARY TABLE tmp.ticket + // (INDEX (ticketFk)) ENGINE = MEMORY + // SELECT id ticketFk FROM tmp.filter`); + // stmts.push('CALL ticketGetTotal()'); + + // stmt = new ParameterizedSQL(` + // SELECT + // f.*, + // tt.total, + // tp.problem + // FROM tmp.filter f + // LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = f.id + // LEFT JOIN tmp.ticketTotal tt ON tt.ticketFk = f.id`); + // stmt.merge(conn.makeOrderBy(filter.order)); + // let ticketsIndex = stmts.push(stmt) - 1; + + // stmts.push( + // `DROP TEMPORARY TABLE + // tmp.filter, + // tmp.ticket, + // tmp.ticketTotal, + // tmp.ticketGetProblems`); + + // let sql = ParameterizedSQL.join(stmts, ';'); + // let result = await conn.executeStmt(sql); + + // return result[ticketsIndex]; + }; +}; diff --git a/modules/order/front/index/index.html b/modules/order/front/index/index.html index 2151e44db..3f717809b 100644 --- a/modules/order/front/index/index.html +++ b/modules/order/front/index/index.html @@ -23,9 +23,11 @@ Id Client + Sales person Confirmed Created from Created + Landed Company @@ -38,6 +40,7 @@ {{::order.client.name}} + {{::order.client.salesPerson.user.nickname}} {{::order.sourceApp}} {{::order.created | date:'dd/MM/yyyy HH:mm'}} + {{::order.landed | date:'dd/MM/yyyy'}} {{::order.company.code}} { stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter'); stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.filter + `CREATE TEMPORARY TABLE tmp.filter (INDEX (id)) ENGINE = MEMORY SELECT @@ -182,7 +182,8 @@ module.exports = Self => { wk.name AS salesPerson, ts.stateFk as stateFk, ts.alertLevel as alertLevel, - ts.code as alertLevelCode + ts.code as alertLevelCode, + u.nickname userNickname FROM ticket t LEFT JOIN address a ON a.id = t.addressFk LEFT JOIN province p ON p.id = a.provinceFk @@ -191,7 +192,8 @@ module.exports = Self => { LEFT JOIN ticketState ts ON ts.ticketFk = t.id LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN client c ON c.id = t.clientFk - LEFT JOIN worker wk ON wk.id = c.salesPersonFk`); + LEFT JOIN worker wk ON wk.id = c.salesPersonFk + LEFT JOIN account.user u ON u.id = wk.userFk`); stmt.merge(conn.makeSuffix(filter)); stmts.push(stmt); diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index 8c741932b..6c2dd9457 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -57,7 +57,7 @@ {{::ticket.id}} - {{::ticket.salesPerson | dashIfEmpty}} + {{::ticket.userNickname | dashIfEmpty}} {{::ticket.shipped | dateTime: 'dd/MM/yyyy'}} diff --git a/modules/ticket/front/tracking/edit/index.html b/modules/ticket/front/tracking/edit/index.html index 0f2cfd09d..f155fd00e 100644 --- a/modules/ticket/front/tracking/edit/index.html +++ b/modules/ticket/front/tracking/edit/index.html @@ -19,12 +19,12 @@ ng-if="$ctrl.isPickerDesignedState" field="$ctrl.workerFk" url="/client/api/Clients/activeWorkersWithRole" - show-field="firstName" + show-field="nickname" search-function="{firstName: $search}" value-field="id" where="{role: 'employee'}" label="Worker"> - {{firstName}} {{name}} + {{nickname}} From f27ca4ce3b44d8fa39431bbba2f3b34b74cb59d3 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 30 Jan 2019 16:03:29 +0100 Subject: [PATCH 3/8] #1069 descriptor de claim --- modules/claim/front/card/index.js | 23 +++++++++++++++++++++-- modules/claim/front/descriptor/index.html | 4 ++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/modules/claim/front/card/index.js b/modules/claim/front/card/index.js index 22209ee5c..8c8907b6f 100644 --- a/modules/claim/front/card/index.js +++ b/modules/claim/front/card/index.js @@ -6,7 +6,17 @@ class Controller { this.$state = $state; this.filter = { include: [ - {relation: 'worker', scope: {fields: ['name', 'firstName']}}, + {relation: 'worker', + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + } + }, { relation: 'ticket', scope: { @@ -23,7 +33,16 @@ class Controller { fields: ['salesPersonFk', 'name'], include: { relation: 'salesPerson', - fields: ['firstName', 'name'] + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + } + } } } diff --git a/modules/claim/front/descriptor/index.html b/modules/claim/front/descriptor/index.html index 7f492e6b0..91cc5802d 100644 --- a/modules/claim/front/descriptor/index.html +++ b/modules/claim/front/descriptor/index.html @@ -29,10 +29,10 @@ value="{{$ctrl.claim.created | dateTime: 'dd/MM/yyyy'}}"> + value="{{$ctrl.claim.client.salesPerson.user.nickname}}"> + value="{{$ctrl.claim.worker.user.nickname}}"> From 00ccf9a4a00979a4c98f6168f47028e90a4e1d02 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 31 Jan 2019 14:14:39 +0100 Subject: [PATCH 4/8] #1069 mostrar el nickname en los sitios donde aparezca nombre solo --- .../02_create_development.spec.js | 10 +- .../client-module/02_edit_basic_data.spec.js | 4 +- .../claim/back/methods/claim/getSummary.js | 30 ++++- modules/claim/front/basic-data/index.html | 11 +- modules/claim/front/development/index.html | 9 +- modules/claim/front/summary/index.html | 4 +- modules/client/back/methods/client/getCard.js | 8 +- modules/client/back/methods/client/summary.js | 48 +++++++- modules/client/back/methods/receipt/filter.js | 5 +- .../back/models/client-observation.json | 101 +++++++++-------- .../client/back/models/credit-insurance.json | 28 ++--- modules/client/front/basic-data/index.html | 7 +- modules/client/front/credit/index/index.html | 2 +- modules/client/front/credit/index/index.js | 8 +- modules/client/front/descriptor/index.html | 2 +- modules/client/front/note/index/index.html | 4 +- modules/client/front/note/index/index.js | 3 + modules/client/front/risk/index/index.html | 2 +- modules/client/front/sample/index/index.html | 2 +- modules/client/front/sample/index/index.js | 8 +- modules/client/front/summary/index.html | 4 +- modules/item/back/methods/item/getCard.js | 14 ++- modules/item/back/methods/item/getSummary.js | 8 +- modules/item/front/descriptor/index.html | 2 +- modules/item/front/summary/index.html | 4 +- modules/item/front/summary/index.js | 5 +- .../front/ticket-descriptor-popover/index.js | 28 ++++- .../ticket-descriptor-popover/index.spec.js | 28 ++++- .../item/front/ticket-descriptor/index.html | 12 +- modules/order/front/card/index.js | 28 ++++- modules/order/front/descriptor/index.html | 2 +- .../methods/sale-tracking/listSaleTracking.js | 4 +- modules/ticket/back/methods/ticket/summary.js | 10 +- modules/ticket/back/models/ticket-log.json | 104 +++++++++--------- modules/ticket/front/card/index.js | 10 +- .../ticket/front/request/create/index.html | 12 +- modules/ticket/front/request/index/index.html | 4 +- modules/ticket/front/request/index/index.js | 20 +++- modules/ticket/front/sale-tracking/index.html | 2 +- modules/ticket/front/summary/index.html | 2 +- modules/ticket/front/tracking/edit/index.html | 1 - modules/worker/front/index/index.html | 2 +- modules/worker/front/index/index.js | 2 +- 43 files changed, 394 insertions(+), 210 deletions(-) diff --git a/e2e/paths/claim-module/02_create_development.spec.js b/e2e/paths/claim-module/02_create_development.spec.js index 9b47f3fbe..d3cac011b 100644 --- a/e2e/paths/claim-module/02_create_development.spec.js +++ b/e2e/paths/claim-module/02_create_development.spec.js @@ -18,7 +18,7 @@ describe('Claim development', () => { .autocompleteSearch(selectors.claimDevelopment.secondClaimReasonAutocomplete, 'Baja calidad') .autocompleteSearch(selectors.claimDevelopment.secondClaimResultAutocomplete, 'Deshidratacion') .autocompleteSearch(selectors.claimDevelopment.secondClaimResponsibleAutocomplete, 'Calidad general') - .autocompleteSearch(selectors.claimDevelopment.secondClaimWorkerAutocomplete, 'delivery') + .autocompleteSearch(selectors.claimDevelopment.secondClaimWorkerAutocomplete, 'deliveryNick') .autocompleteSearch(selectors.claimDevelopment.secondClaimRedeliveryAutocomplete, 'Reparto') .waitToClick(selectors.claimDevelopment.saveDevelopmentButton) .waitForLastSnackbar(); @@ -31,7 +31,7 @@ describe('Claim development', () => { .autocompleteSearch(selectors.claimDevelopment.firstClaimReasonAutocomplete, 'Calor') .autocompleteSearch(selectors.claimDevelopment.firstClaimResultAutocomplete, 'Cocido') .autocompleteSearch(selectors.claimDevelopment.firstClaimResponsibleAutocomplete, 'Calidad general') - .autocompleteSearch(selectors.claimDevelopment.firstClaimWorkerAutocomplete, 'adminAssistant') + .autocompleteSearch(selectors.claimDevelopment.firstClaimWorkerAutocomplete, 'adminAssistantNick') .autocompleteSearch(selectors.claimDevelopment.firstClaimRedeliveryAutocomplete, 'Cliente') .waitToClick(selectors.claimDevelopment.saveDevelopmentButton) .waitForLastSnackbar(); @@ -59,7 +59,7 @@ describe('Claim development', () => { expect(reason).toEqual('Calor'); expect(result).toEqual('Cocido'); expect(responsible).toEqual('Calidad general'); - expect(worker).toEqual('adminAssistant adminAssistant'); + expect(worker).toEqual('adminAssistantNick'); expect(redelivery).toEqual('Cliente'); }); @@ -82,7 +82,7 @@ describe('Claim development', () => { expect(reason).toEqual('Baja calidad'); expect(result).toEqual('Deshidratacion'); expect(responsible).toEqual('Calidad general'); - expect(worker).toEqual('delivery delivery'); + expect(worker).toEqual('deliveryNick'); expect(redelivery).toEqual('Reparto'); }); @@ -115,7 +115,7 @@ describe('Claim development', () => { expect(reason).toEqual('Prisas'); expect(result).toEqual('Otros daños'); expect(responsible).toEqual('Compradores'); - expect(worker).toEqual('manager manager'); + expect(worker).toEqual('managerNick'); expect(redelivery).toEqual('Cliente'); }); }); diff --git a/e2e/paths/client-module/02_edit_basic_data.spec.js b/e2e/paths/client-module/02_edit_basic_data.spec.js index d1973410d..ddd1dc528 100644 --- a/e2e/paths/client-module/02_edit_basic_data.spec.js +++ b/e2e/paths/client-module/02_edit_basic_data.spec.js @@ -114,7 +114,7 @@ describe('Client Edit basicData path', () => { .write(selectors.clientBasicData.mobileInput, '987654321') .clearInput(selectors.clientBasicData.emailInput) .write(selectors.clientBasicData.emailInput, 'Storm@verdnatura.es') - .autocompleteSearch(selectors.clientBasicData.salesPersonAutocomplete, 'Accessory') + .autocompleteSearch(selectors.clientBasicData.salesPersonAutocomplete, 'AccessoryNick') .autocompleteSearch(selectors.clientBasicData.channelAutocomplete, 'Metropolis newspaper') .waitToClick(selectors.clientBasicData.saveButton) .waitForLastSnackbar(); @@ -162,7 +162,7 @@ describe('Client Edit basicData path', () => { const result = await nightmare .waitToGetProperty(`${selectors.clientBasicData.salesPersonAutocomplete} input`, 'value'); - expect(result).toEqual('accessory accessory'); + expect(result).toEqual('accessoryNick'); }); it('should now confirm the channel have been selected', async() => { diff --git a/modules/claim/back/methods/claim/getSummary.js b/modules/claim/back/methods/claim/getSummary.js index 04e12f937..ac57447b6 100644 --- a/modules/claim/back/methods/claim/getSummary.js +++ b/modules/claim/back/methods/claim/getSummary.js @@ -28,15 +28,39 @@ module.exports = Self => { let filter = { where: {id: id}, include: [ - {relation: 'worker', scope: {fields: ['name', 'firstName']}}, - {relation: 'claimState', scope: {fields: ['id', 'description']}}, + { + relation: 'worker', + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + } + }, + { + relation: 'claimState', + scope: { + fields: ['id', 'description'] + } + }, { relation: 'client', scope: { fields: ['salesPersonFk', 'name'], include: { relation: 'salesPerson', - fields: ['firstName', 'name'] + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + } } } } diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html index f77a658c6..cbd610911 100644 --- a/modules/claim/front/basic-data/index.html +++ b/modules/claim/front/basic-data/index.html @@ -18,15 +18,16 @@ label="Client" order="id"> - - {{firstName}} {{name}} - {{firstName}} {{name}} + value="{{$ctrl.summary.claim.client.salesPerson.user.nickname}}"> + value="{{$ctrl.summary.claim.worker.user.nickname}}"> diff --git a/modules/client/back/methods/client/getCard.js b/modules/client/back/methods/client/getCard.js index 6a9331a86..6c69d32a8 100644 --- a/modules/client/back/methods/client/getCard.js +++ b/modules/client/back/methods/client/getCard.js @@ -27,7 +27,13 @@ module.exports = function(Self) { { relation: 'salesPerson', scope: { - fields: ['id', 'firstName', 'name'] + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } } }, { relation: 'contactChannel', diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js index 57d742a13..08d5011cb 100644 --- a/modules/client/back/methods/client/summary.js +++ b/modules/client/back/methods/client/summary.js @@ -35,12 +35,48 @@ module.exports = Self => { async function getSummary(client, clientId) { let filter = { include: [ - {relation: 'account', scope: {fields: ['name', 'active']}}, - {relation: 'salesPerson', scope: {fields: ['firstName', 'name']}}, - {relation: 'country', scope: {fields: ['country']}}, - {relation: 'province', scope: {fields: ['name']}}, - {relation: 'contactChannel', scope: {fields: ['name']}}, - {relation: 'payMethod', scope: {fields: ['name']}}, + { + relation: 'account', + scope: { + fields: ['name', 'active'] + } + }, + { + relation: 'salesPerson', + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + } + }, + { + relation: 'country', + scope: { + fields: ['country'] + } + }, + { + relation: 'province', + scope: { + fields: ['name'] + } + }, + { + relation: 'contactChannel', + scope: { + fields: ['name'] + } + }, + { + relation: 'payMethod', + scope: { + fields: ['name'] + } + }, { relation: 'addresses', scope: { diff --git a/modules/client/back/methods/receipt/filter.js b/modules/client/back/methods/receipt/filter.js index b9f26b1ab..aa60e8235 100644 --- a/modules/client/back/methods/receipt/filter.js +++ b/modules/client/back/methods/receipt/filter.js @@ -40,12 +40,12 @@ module.exports = Self => { NULL debit, r.amountPaid credit, r.bankFk, - firstName, - name, + u.nickname userNickname, r.clientFk, FALSE pdf FROM vn.receipt r LEFT JOIN vn.worker w ON w.id = r.workerFk + LEFT JOIN account.user u ON u.id = w.userFk JOIN vn.company c ON c.id = r.companyFk WHERE r.clientFk = ? AND r.companyFk = ? UNION ALL @@ -60,7 +60,6 @@ module.exports = Self => { NULL, NULL, NULL, - NULL, i.clientFk, i.pdf FROM vn.invoiceOut i diff --git a/modules/client/back/models/client-observation.json b/modules/client/back/models/client-observation.json index ea05bed55..a9c7b483a 100644 --- a/modules/client/back/models/client-observation.json +++ b/modules/client/back/models/client-observation.json @@ -1,47 +1,58 @@ { - "name": "ClientObservation", - "description": "Client notes", - "base": "Loggable", - "log": { - "model": "ClientLog", - "relation": "client" - }, - "options": { - "mysql": { - "table": "clientObservation" - } - }, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" - }, - "clientFk": { - "type": "Number" - }, - "text": { - "type": "string", - "description": "Text" - }, - "created": { - "type": "date", - "description": "Creation date and time" - } - }, - "relations": { - "worker": { - "type": "belongsTo", - "model": "Worker", - "foreignKey": "workerFk" - }, - "client": { - "type": "belongsTo", - "model": "Client", - "foreignKey": "clientFk" - } - }, - "scope": { - "include": "worker" - } + "name": "ClientObservation", + "description": "Client notes", + "base": "Loggable", + "log": { + "model": "ClientLog", + "relation": "client" + }, + "options": { + "mysql": { + "table": "clientObservation" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "clientFk": { + "type": "Number" + }, + "text": { + "type": "string", + "description": "Text" + }, + "created": { + "type": "date", + "description": "Creation date and time" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "clientFk" + } + }, + "scope": { + "include": { + "relation": "worker", + "scope": { + "fields": ["userFk"], + "include": { + "relation": "user", + "scope": { + "fields": ["nickname"] + } + } + } + } + } } diff --git a/modules/client/back/models/credit-insurance.json b/modules/client/back/models/credit-insurance.json index 58dd53ccc..688c511fb 100644 --- a/modules/client/back/models/credit-insurance.json +++ b/modules/client/back/models/credit-insurance.json @@ -1,14 +1,14 @@ { - "name": "CreditInsurance", - "description": "Credit insurance", - "base": "VnModel", - "options": { - "mysql": { - "table": "creditInsurance" - } - }, - "properties": { - "id": { + "name": "CreditInsurance", + "description": "Credit insurance", + "base": "VnModel", + "options": { + "mysql": { + "table": "creditInsurance" + } + }, + "properties": { + "id": { "id": true, "type": "Number", "description": "Identifier" @@ -18,9 +18,9 @@ }, "created": { "type": "date", - "mysql": { - "columnName": "creationDate" - } + "mysql": { + "columnName": "creationDate" + } }, "grade": { "type": "Number" @@ -30,7 +30,7 @@ "classification": { "type": "belongsTo", "model": "CreditClassification", - "foreignKey": "creditClassification" + "foreignKey": "creditClassification" } } } \ No newline at end of file diff --git a/modules/client/front/basic-data/index.html b/modules/client/front/basic-data/index.html index 189cfe261..f31ab8138 100644 --- a/modules/client/front/basic-data/index.html +++ b/modules/client/front/basic-data/index.html @@ -40,18 +40,17 @@ - - {{firstName}} {{name}} {{::credit.amount | number:2}} € {{::credit.created | date:'dd/MM/yyyy HH:mm'}} - {{::credit.worker.firstName}} {{::credit.worker.name}} + {{::credit.worker.user.nickname}} diff --git a/modules/client/front/credit/index/index.js b/modules/client/front/credit/index/index.js index a12dfc5fe..e8fae8d9d 100644 --- a/modules/client/front/credit/index/index.js +++ b/modules/client/front/credit/index/index.js @@ -8,7 +8,13 @@ class Controller { { relation: 'worker', scope: { - fields: ['firstName', 'name'] + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } } } ] diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index 3c088add6..13444a6f4 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -33,7 +33,7 @@ value="{{$ctrl.client.creditInsurance | currency: '€ ': 2}}"> + value="{{$ctrl.client.salesPerson.user.nickname}}">
diff --git a/modules/client/front/note/index/index.html b/modules/client/front/note/index/index.html index 6c60c4f03..59267b9c4 100644 --- a/modules/client/front/note/index/index.html +++ b/modules/client/front/note/index/index.html @@ -1,7 +1,7 @@ @@ -15,7 +15,7 @@ border-radius margin-small-bottom> - {{::note.worker.firstName}} {{::note.worker.name}} + {{::note.worker.user.nickname}} {{::note.created | date:'dd/MM/yyyy HH:mm'}} diff --git a/modules/client/front/note/index/index.js b/modules/client/front/note/index/index.js index 2415aa482..63fc6643a 100644 --- a/modules/client/front/note/index/index.js +++ b/modules/client/front/note/index/index.js @@ -3,6 +3,9 @@ import ngModule from '../../module'; export default class Controller { constructor($stateParams) { this.$stateParams = $stateParams; + this.filter = { + order: 'created DESC', + }; } } diff --git a/modules/client/front/risk/index/index.html b/modules/client/front/risk/index/index.html index a11e01724..fdea08a5d 100644 --- a/modules/client/front/risk/index/index.html +++ b/modules/client/front/risk/index/index.html @@ -60,7 +60,7 @@ {{::risk.payed | dateTime:'dd/MM/yyyy'}} {{::risk.created | dateTime:'dd/MM/yyyy HH:mm'}} - {{::risk.firstName}} {{::risk.name}} + {{::risk.userNickname}} BILL {{::risk.ref}} diff --git a/modules/client/front/sample/index/index.html b/modules/client/front/sample/index/index.html index 3d27eb3d5..bc44265f3 100644 --- a/modules/client/front/sample/index/index.html +++ b/modules/client/front/sample/index/index.html @@ -24,7 +24,7 @@ {{::sample.created | date:'dd/MM/yyyy HH:mm' }} {{::sample.type.description}} - {{::sample.worker.firstName}} {{::sample.worker.name}} + {{::sample.worker.user.nickname}} {{::sample.company.code}} diff --git a/modules/client/front/sample/index/index.js b/modules/client/front/sample/index/index.js index 78fd7f37e..646544eb6 100644 --- a/modules/client/front/sample/index/index.js +++ b/modules/client/front/sample/index/index.js @@ -14,7 +14,13 @@ class Controller { { relation: 'worker', scope: { - fields: ['firstName', 'name'] + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } } }, { diff --git a/modules/client/front/summary/index.html b/modules/client/front/summary/index.html index f14f4e651..5b4aa1c21 100644 --- a/modules/client/front/summary/index.html +++ b/modules/client/front/summary/index.html @@ -1,5 +1,5 @@ -
{{$ctrl.summary.name}} - {{$ctrl.summary.id}} - {{$ctrl.summary.salesPerson.firstName}} {{$ctrl.summary.salesPerson.name}}
+
{{$ctrl.summary.name}} - {{$ctrl.summary.id}} - {{$ctrl.summary.salesPerson.user.nickname}}

Basic data

@@ -22,7 +22,7 @@ value="{{$ctrl.summary.email}}"> + value="{{$ctrl.summary.salesPerson.user.nickname}}"> diff --git a/modules/item/back/methods/item/getCard.js b/modules/item/back/methods/item/getCard.js index b076d46c8..b9be274e1 100644 --- a/modules/item/back/methods/item/getCard.js +++ b/modules/item/back/methods/item/getCard.js @@ -26,18 +26,26 @@ module.exports = Self => { let filter = { where: {id: id}, include: [ - {relation: 'itemType', + { + relation: 'itemType', scope: { fields: ['id', 'name', 'workerFk', 'warehouseFk'], include: [{ relation: 'worker', scope: { - fields: ['id', 'name', 'firstName'] + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } } }] } }, - {relation: 'tags', + { + relation: 'tags', scope: { fields: ['id', 'value', 'tagFk'], include: [{ diff --git a/modules/item/back/methods/item/getSummary.js b/modules/item/back/methods/item/getSummary.js index 3cbb8bcab..44e599e4a 100644 --- a/modules/item/back/methods/item/getSummary.js +++ b/modules/item/back/methods/item/getSummary.js @@ -33,7 +33,13 @@ module.exports = Self => { include: [{ relation: 'worker', scope: { - fields: ['id', 'name', 'firstName'] + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } } }] } diff --git a/modules/item/front/descriptor/index.html b/modules/item/front/descriptor/index.html index 09df4d520..3210366d0 100644 --- a/modules/item/front/descriptor/index.html +++ b/modules/item/front/descriptor/index.html @@ -49,7 +49,7 @@ value="{{::$ctrl.item.name}}"> + value="{{$ctrl.item.itemType.worker.user.nickname}}">

Basic data

- + value="{{$ctrl.summary.item.itemType.worker.user.nickname}}">
diff --git a/modules/item/front/summary/index.js b/modules/item/front/summary/index.js index 3bea01ea5..9c7e98785 100644 --- a/modules/item/front/summary/index.js +++ b/modules/item/front/summary/index.js @@ -7,15 +7,14 @@ class Controller { } getSummary() { - this.$http.get(`/item/api/Items/${this.item.id}/getSummary`).then((response) => { + this.$http.get(`/item/api/Items/${this.item.id}/getSummary`).then(response => { this.summary = response.data; }); } $onChanges() { - if (this.item && this.item.id) { + if (this.item && this.item.id) this.getSummary(); - } } } diff --git a/modules/item/front/ticket-descriptor-popover/index.js b/modules/item/front/ticket-descriptor-popover/index.js index 21b87a7ac..e552fde16 100644 --- a/modules/item/front/ticket-descriptor-popover/index.js +++ b/modules/item/front/ticket-descriptor-popover/index.js @@ -51,25 +51,43 @@ class Controller extends Component { let filter = { include: [ - {relation: 'warehouse', scope: {fields: ['name']}}, - {relation: 'agencyMode', scope: {fields: ['name']}}, + { + relation: 'warehouse', + scope: { + fields: ['name'] + } + }, + { + relation: 'agencyMode', + scope: { + fields: ['name'] + } + }, { relation: 'client', scope: { fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'], include: { relation: 'salesPerson', - fields: ['firstName', 'name'] + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + } } } }, { - relation: 'tracking', + relation: 'state', scope: { fields: ['stateFk'], include: { relation: 'state', - fields: ['name'] + fields: ['id', 'name'], } } } diff --git a/modules/item/front/ticket-descriptor-popover/index.spec.js b/modules/item/front/ticket-descriptor-popover/index.spec.js index 2059b9fdb..9e3d39e4b 100644 --- a/modules/item/front/ticket-descriptor-popover/index.spec.js +++ b/modules/item/front/ticket-descriptor-popover/index.spec.js @@ -71,25 +71,43 @@ describe('Item', () => { let filter = { include: [ - {relation: 'warehouse', scope: {fields: ['name']}}, - {relation: 'agencyMode', scope: {fields: ['name']}}, + { + relation: 'warehouse', + scope: { + fields: ['name'] + } + }, + { + relation: 'agencyMode', + scope: { + fields: ['name'] + } + }, { relation: 'client', scope: { fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'], include: { relation: 'salesPerson', - fields: ['firstName', 'name'] + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + } } } }, { - relation: 'tracking', + relation: 'state', scope: { fields: ['stateFk'], include: { relation: 'state', - fields: ['name'] + fields: ['id', 'name'], } } } diff --git a/modules/item/front/ticket-descriptor/index.html b/modules/item/front/ticket-descriptor/index.html index 6cd41ab54..da734aa11 100644 --- a/modules/item/front/ticket-descriptor/index.html +++ b/modules/item/front/ticket-descriptor/index.html @@ -29,19 +29,19 @@ - + - - - -
diff --git a/modules/order/front/card/index.js b/modules/order/front/card/index.js index 3b3e2524c..948f24989 100644 --- a/modules/order/front/card/index.js +++ b/modules/order/front/card/index.js @@ -7,16 +7,36 @@ class Controller { this.order = {}; this.filter = { include: [ - {relation: 'agencyMode', scope: {fields: ['name']}}, - {relation: 'address', scope: {fields: ['nickname']}}, - {relation: 'rows', scope: {fields: ['id']}}, + { + relation: 'agencyMode', scope: { + fields: ['name'] + } + }, + { + relation: 'address', scope: { + fields: ['nickname'] + } + }, + { + relation: 'rows', scope: { + fields: ['id'] + } + }, { relation: 'client', scope: { fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'], include: { relation: 'salesPerson', - fields: ['firstName', 'name'] + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + } } } } diff --git a/modules/order/front/descriptor/index.html b/modules/order/front/descriptor/index.html index 51776be31..2d7201a6d 100644 --- a/modules/order/front/descriptor/index.html +++ b/modules/order/front/descriptor/index.html @@ -20,7 +20,7 @@ value="{{$ctrl.order.isConfirmed ? $ctrl.translate.instant('Confirmed') : $ctrl.translate.instant('Not confirmed')}}"> + value="{{$ctrl.order.client.salesPerson.user.nickname}}"> diff --git a/modules/ticket/back/methods/sale-tracking/listSaleTracking.js b/modules/ticket/back/methods/sale-tracking/listSaleTracking.js index 1d3fb05f0..8d3e0c248 100644 --- a/modules/ticket/back/methods/sale-tracking/listSaleTracking.js +++ b/modules/ticket/back/methods/sale-tracking/listSaleTracking.js @@ -31,12 +31,12 @@ module.exports = Self => { st.originalQuantity, st.created, st.workerFk, - w.firstName, - w.name, + u.nickname userNickname, ste.name AS state FROM saleTracking st JOIN sale s ON s.id = st.saleFk JOIN worker w ON w.id = st.workerFk + JOIN account.user u ON u.id = w.userFk JOIN state ste ON ste.id = st.stateFk`); stmt.merge(Self.makeSuffix(filter)); diff --git a/modules/ticket/back/methods/ticket/summary.js b/modules/ticket/back/methods/ticket/summary.js index b951b8f5c..36a5b961e 100644 --- a/modules/ticket/back/methods/ticket/summary.js +++ b/modules/ticket/back/methods/ticket/summary.js @@ -57,7 +57,15 @@ module.exports = Self => { fields: ['salesPersonFk', 'name'], include: { relation: 'salesPerson', - fields: ['firstName', 'name'] + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + } } } }, diff --git a/modules/ticket/back/models/ticket-log.json b/modules/ticket/back/models/ticket-log.json index 843a0f4be..be4021637 100644 --- a/modules/ticket/back/models/ticket-log.json +++ b/modules/ticket/back/models/ticket-log.json @@ -1,55 +1,55 @@ { - "name": "TicketLog", + "name": "TicketLog", "base": "VnModel", - "options": { - "mysql": { - "table": "ticketLog" - } - }, - "properties": { - "id": { - "id": true, - "type": "Number", - "forceId": false - }, - "originFk": { - "type": "Number", - "required": true - }, - "userFk": { - "type": "Number" - }, - "action": { - "type": "String", - "required": true - }, - "changedModel": { - "type": "String" - }, - "oldInstance": { - "type": "Object" - }, - "newInstance": { - "type": "Object" - }, - "creationDate": { - "type": "Date" - }, - "changedModelId": { - "type": "Number" - }, - "changedModelValue": { - "type": "String" - }, - "description": { - "type": "String" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "Account", - "foreignKey": "userFk" - } - } + "options": { + "mysql": { + "table": "ticketLog" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "forceId": false + }, + "originFk": { + "type": "Number", + "required": true + }, + "userFk": { + "type": "Number" + }, + "action": { + "type": "String", + "required": true + }, + "changedModel": { + "type": "String" + }, + "oldInstance": { + "type": "Object" + }, + "newInstance": { + "type": "Object" + }, + "creationDate": { + "type": "Date" + }, + "changedModelId": { + "type": "Number" + }, + "changedModelValue": { + "type": "String" + }, + "description": { + "type": "String" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFk" + } + } } diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js index cfd60800d..776b450ca 100644 --- a/modules/ticket/front/card/index.js +++ b/modules/ticket/front/card/index.js @@ -16,7 +16,15 @@ class Controller { fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked', 'credit'], include: { relation: 'salesPerson', - fields: ['firstName', 'name'], + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] + } + } + } }, }, }, diff --git a/modules/ticket/front/request/create/index.html b/modules/ticket/front/request/create/index.html index 99b34b2fd..941184a30 100644 --- a/modules/ticket/front/request/create/index.html +++ b/modules/ticket/front/request/create/index.html @@ -10,16 +10,16 @@ - - {{firstName}} {{name}} + value-field="id" + where="{role: 'buyer'}" + label="Buyer" + vn-acl="salesAssistant"> diff --git a/modules/ticket/front/request/index/index.html b/modules/ticket/front/request/index/index.html index f89487688..365df8d48 100644 --- a/modules/ticket/front/request/index/index.html +++ b/modules/ticket/front/request/index/index.html @@ -34,8 +34,8 @@ {{::request.id}} {{::request.description}} {{::request.created | dateTime: 'dd/MM/yyyy'}} - {{::request.requester.user.name}} - {{::request.atender.user.name}} + {{::request.requester.user.nickname}} + {{::request.atender.user.nickname}} {{::request.quantity}} {{::request.price | currency: '€': 2}} diff --git a/modules/ticket/front/request/index/index.js b/modules/ticket/front/request/index/index.js index 9dbd4fec1..5b146e769 100644 --- a/modules/ticket/front/request/index/index.js +++ b/modules/ticket/front/request/index/index.js @@ -6,21 +6,31 @@ class Controller { this.$scope = $scope; this.filter = { include: [ - {relation: 'atender', + { + relation: 'atender', scope: { include: { - relation: 'user' + relation: 'user', + scope: { + fields: ['nickname'] + } } } }, - {relation: 'requester', + { + relation: 'requester', scope: { include: { - relation: 'user' + relation: 'user', + scope: { + fields: ['nickname'] + } } } }, - {relation: 'sale'} + { + relation: 'sale' + } ] }; } diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html index 1ef05b7b7..b19a1a74e 100644 --- a/modules/ticket/front/sale-tracking/index.html +++ b/modules/ticket/front/sale-tracking/index.html @@ -42,7 +42,7 @@ {{::sale.originalQuantity}} - {{::sale.firstName}} {{::sale.name}} + {{::sale.userNickname}} {{::sale.state}} {{::sale.created | date: 'dd/MM/yyyy HH:mm'}} diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index 0a1b1f4f1..6f2963ee7 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -6,7 +6,7 @@ value="{{$ctrl.summary.state.state.name}}"> + value="{{$ctrl.summary.client.salesPerson.user.nickname}}"> diff --git a/modules/ticket/front/tracking/edit/index.html b/modules/ticket/front/tracking/edit/index.html index f155fd00e..ce7019d92 100644 --- a/modules/ticket/front/tracking/edit/index.html +++ b/modules/ticket/front/tracking/edit/index.html @@ -24,7 +24,6 @@ value-field="id" where="{role: 'employee'}" label="Worker"> - {{nickname}}
diff --git a/modules/worker/front/index/index.html b/modules/worker/front/index/index.html index e3853083b..b89c5c3e3 100644 --- a/modules/worker/front/index/index.html +++ b/modules/worker/front/index/index.html @@ -22,7 +22,7 @@ class="vn-list-item"> -
{{::worker.firstName}} {{::worker.name}}
+
{{::worker.user.nickname}}
diff --git a/modules/worker/front/index/index.js b/modules/worker/front/index/index.js index 4f6ea1a7e..6be62edd6 100644 --- a/modules/worker/front/index/index.js +++ b/modules/worker/front/index/index.js @@ -8,7 +8,7 @@ export default class Controller { include: [ { relation: 'user', - scope: {fields: ['name', 'email']} + scope: {fields: ['nickname', 'email']} }, { relation: 'client', scope: {fields: ['fi']} From 8e6d38ab31a6d12ee4734709e4e73744ad06ab51 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 31 Jan 2019 14:58:14 +0100 Subject: [PATCH 5/8] #1069 mostrar el nickname en los sitios donde aparezca nombre solo --- modules/claim/front/card/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/claim/front/card/index.js b/modules/claim/front/card/index.js index 8c8907b6f..df11f322f 100644 --- a/modules/claim/front/card/index.js +++ b/modules/claim/front/card/index.js @@ -26,7 +26,12 @@ class Controller { } } }, - {relation: 'claimState', scope: {fields: ['id', 'description']}}, + { + relation: 'claimState', + scope: { + fields: ['id', 'description'] + } + }, { relation: 'client', scope: { From a288f9efd9495c7fb3651ff04c483ae771a74d71 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 31 Jan 2019 15:06:12 +0100 Subject: [PATCH 6/8] removed unused file --- modules/order/back/methods/order/filter.js | 156 --------------------- 1 file changed, 156 deletions(-) delete mode 100644 modules/order/back/methods/order/filter.js diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js deleted file mode 100644 index ba8641f84..000000000 --- a/modules/order/back/methods/order/filter.js +++ /dev/null @@ -1,156 +0,0 @@ - -const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; -const buildFilter = require('vn-loopback/util/filter').buildFilter; -const mergeFilters = require('vn-loopback/util/filter').mergeFilters; - -module.exports = Self => { - Self.remoteMethod('filter', { - description: 'Find all instances of the model matched by filter from the data source.', - accepts: [ - { - arg: 'ctx', - type: 'Object', - http: {source: 'context'} - }, { - arg: 'filter', - type: 'Object', - description: `Filter defining where, order, offset, and limit - must be a JSON-encoded string` - }, { - arg: 'search', - type: 'String', - description: `The search value` - }, { - arg: 'id', - type: 'Integer', - description: `The order id` - }, { - arg: 'clientFk', - type: 'Integer', - description: `The client id` - }, { - arg: 'agencyModeFk', - type: 'Integer', - description: `The agency id` - }, { - arg: 'workerFk', - type: 'Integer', - description: `The worker id` - }, { - arg: 'from', - type: 'Date', - description: `The from date` - }, { - arg: 'to', - type: 'Date', - description: `The to date` - }, { - arg: 'sourceApp', - type: 'Date', - description: `The source app used` - }, { - arg: 'isConfirmed', - type: 'Boolean', - description: `The state of the order` - } - ], - returns: { - type: ['Object'], - root: true - }, - http: { - path: '/filter', - verb: 'GET' - } - }); - - Self.filter = async(ctx, filter) => { - let where = buildFilter(ctx.args, (param, value) => { - switch (param) { - case 'search': - return {'o.id': value}; - case 'from': - return {'o.landed': {gte: value}}; - case 'to': - return {'o.landed': {lte: value}}; - case 'clientFk': - return {'o.clientFk': value}; - case 'salesPersonFk': - return {'c.salesPersonFk': value}; - case 'ticketFk': - return {'t.id': value}; - case 'stateFk': - return {'ts.stateFk': value}; - case 'mine': - case 'myTeam': - return {'c.salesPersonFk': {inq: teamIds}}; - case 'alertLevel': - return {'ts.alertLevel': value}; - // case 'id': - // case 'clientFk': - // case 'agencyModeFk': - // case 'warehouseFk': - // param = `t.${param}`; - // return {[param]: value}; - } - }); - - filter = mergeFilters(filter, {where}); - - let stmts = []; - let stmt; - - // stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter'); - - stmt = new ParameterizedSQL(` - SELECT - o.id, c.id clientFk, c.name clientName, wk.name workerName, o.isConfirmed, o.source_app sourceApp, o.date_make created, o.date_send landed, com.code companyCode - FROM hereda.order o - LEFT JOIN client c ON c.id = o.clientFk - LEFT JOIN worker wk ON wk.id = c.salesPersonFk - LEFT JOIN company com ON com.id = o.company_id - LEFT JOIN orderTicket ot ON ot.orderFk = o.id - `); - - stmt.merge(conn.makeSuffix(filter)); - stmts.push(stmt); - - // stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.ticketGetProblems'); - // stmts.push(` - // CREATE TEMPORARY TABLE tmp.ticketGetProblems - // (INDEX (ticketFk)) - // ENGINE = MEMORY - // SELECT id ticketFk, clientFk, warehouseFk, shipped - // FROM tmp.filter`); - // stmts.push('CALL ticketGetProblems()'); - - // stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.ticket'); - // stmts.push(` - // CREATE TEMPORARY TABLE tmp.ticket - // (INDEX (ticketFk)) ENGINE = MEMORY - // SELECT id ticketFk FROM tmp.filter`); - // stmts.push('CALL ticketGetTotal()'); - - // stmt = new ParameterizedSQL(` - // SELECT - // f.*, - // tt.total, - // tp.problem - // FROM tmp.filter f - // LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = f.id - // LEFT JOIN tmp.ticketTotal tt ON tt.ticketFk = f.id`); - // stmt.merge(conn.makeOrderBy(filter.order)); - // let ticketsIndex = stmts.push(stmt) - 1; - - // stmts.push( - // `DROP TEMPORARY TABLE - // tmp.filter, - // tmp.ticket, - // tmp.ticketTotal, - // tmp.ticketGetProblems`); - - // let sql = ParameterizedSQL.join(stmts, ';'); - // let result = await conn.executeStmt(sql); - - // return result[ticketsIndex]; - }; -}; From fd4205f9abe196a0bd661e63d3bb0cca84be02c5 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 31 Jan 2019 17:01:33 +0100 Subject: [PATCH 7/8] #1069 --- e2e/helpers/selectors.js | 6 ++---- e2e/paths/ticket-module/07_edit_sale.spec.js | 2 +- e2e/paths/ticket-module/10_ticket_request.spec.js | 3 +-- modules/ticket/front/request/create/index.html | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index ede784f6f..42d05aafa 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -349,7 +349,7 @@ export default { firstSaleColour: `vn-ticket-sale vn-tr:nth-child(1) vn-td:nth-child(5) section:nth-child(1)`, firstSaleLength: `vn-ticket-sale vn-tr:nth-child(1) vn-td:nth-child(5) section:nth-child(3)`, firstSaleCheckbox: `vn-ticket-sale vn-tr:nth-child(1) vn-check[field="sale.checked"] label`, - secondSaleClaimId: 'vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(2) > a > vn-icon', + secondSaleClaimIcon: 'vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(2) > a > vn-icon', secondSaleColour: `vn-ticket-sale vn-tr:nth-child(2) vn-td:nth-child(5) section:nth-child(5)`, secondSalePrice: `vn-ticket-sale vn-tr:nth-child(2) vn-td:nth-child(7)`, secondSaleDiscount: `vn-ticket-sale vn-tr:nth-child(2) vn-td:nth-child(8)`, @@ -402,9 +402,7 @@ export default { addRequestButton: `vn-ticket-request-index > a > vn-float-button > button`, request: 'vn-ticket-request-index > form > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr', descriptionInput: `vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(1) > vn-textfield > div > div > div.infix > input`, - atenderSelect: `vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(1) > vn-autocomplete > div > div > input`, - atenderSelectFirstOption: `vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(1) > vn-autocomplete > vn-drop-down > vn-popover > div > div.content > div > div.list > ul > li:nth-child(1)`, - atenderSelectSecondOption: `vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(1) > vn-autocomplete > vn-drop-down > vn-popover > div > div.content > div > div.list > ul > li:nth-child(2)`, + atenderAutocomplete: `vn-ticket-request-create vn-autocomplete[field="$ctrl.ticketRequest.atenderFk"]`, quantityInput: `vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(2) > vn-textfield:nth-child(1) > div > div > div.infix > input`, priceInput: `vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(2) > vn-textfield:nth-child(2) > div > div > div.infix > input`, firstRemoveRequestButton: `vn-ticket-request-index vn-icon[icon="delete"]:nth-child(1)`, diff --git a/e2e/paths/ticket-module/07_edit_sale.spec.js b/e2e/paths/ticket-module/07_edit_sale.spec.js index 3a5feff15..1e1302ab8 100644 --- a/e2e/paths/ticket-module/07_edit_sale.spec.js +++ b/e2e/paths/ticket-module/07_edit_sale.spec.js @@ -13,7 +13,7 @@ describe('Ticket Edit sale path', () => { it(`should click on the second claim id to navigate over there`, async() => { const url = await nightmare - .waitToClick(selectors.ticketSales.secondSaleClaimId) + .waitToClick(selectors.ticketSales.secondSaleClaimIcon) .wait(selectors.claimBasicData.claimStateAutocomplete) .parsedUrl(); diff --git a/e2e/paths/ticket-module/10_ticket_request.spec.js b/e2e/paths/ticket-module/10_ticket_request.spec.js index a3ece83de..0a31cb75a 100644 --- a/e2e/paths/ticket-module/10_ticket_request.spec.js +++ b/e2e/paths/ticket-module/10_ticket_request.spec.js @@ -16,8 +16,7 @@ describe('Ticket purchase request path', () => { .waitToClick(selectors.ticketRequests.addRequestButton) .write(selectors.ticketRequests.descriptionInput, 'New stuff') .write(selectors.ticketRequests.quantityInput, 99) - .waitToClick(selectors.ticketRequests.atenderSelect) - .waitToClick(selectors.ticketRequests.atenderSelectSecondOption) + .autocompleteSearch(selectors.ticketRequests.atenderAutocomplete, 'buyerNick') .write(selectors.ticketRequests.priceInput, 999) .waitToClick(selectors.ticketRequests.saveButton) .waitForLastSnackbar(); diff --git a/modules/ticket/front/request/create/index.html b/modules/ticket/front/request/create/index.html index 941184a30..1e9dacbd0 100644 --- a/modules/ticket/front/request/create/index.html +++ b/modules/ticket/front/request/create/index.html @@ -18,8 +18,7 @@ search-function="{firstName: $search}" value-field="id" where="{role: 'buyer'}" - label="Buyer" - vn-acl="salesAssistant"> + label="Buyer">
From 2ac6342838f343e0832fca0df602b2ae95779519 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Fri, 1 Feb 2019 09:43:30 +0100 Subject: [PATCH 8/8] test fixed for fixtures dates --- modules/item/back/methods/item/specs/getLastEntries.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/item/back/methods/item/specs/getLastEntries.spec.js b/modules/item/back/methods/item/specs/getLastEntries.spec.js index 5c28d16bd..5147dd126 100644 --- a/modules/item/back/methods/item/specs/getLastEntries.spec.js +++ b/modules/item/back/methods/item/specs/getLastEntries.spec.js @@ -12,7 +12,8 @@ describe('item getLastEntries()', () => { it('should return three entries for a given item', async() => { let date = new Date(); - date.setMonth(date.getMonth() - 2, 15); + date.setMonth(date.getMonth() - 2, 1); + let filter = {where: {itemFk: 1, date: date}}; let result = await app.models.Item.getLastEntries(filter);