From 43d011ea60fab3cf293ddc042cd09c69223ac91f Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Mon, 14 Sep 2020 09:43:00 +0200 Subject: [PATCH 01/12] isIgnored displayed as vn-check --- modules/entry/front/latest-buys/index.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index b7912a6da..f06301138 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -121,7 +121,12 @@ {{::buy.freightValue | currency: 'EUR':2}} {{::buy.comissionValue | currency: 'EUR':2}} {{::buy.packageValue | currency: 'EUR':2}} - {{::buy.isIgnored}} + + + + {{::buy.price2 | currency: 'EUR':2}} {{::buy.price3 | currency: 'EUR':2}} {{::buy.minPrice | currency: 'EUR':2}} From 7043b833d02ee33ab74a75cd4efb387554b0f468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Mon, 14 Sep 2020 11:44:10 +0200 Subject: [PATCH 02/12] Pdf optimization --- print/core/config.js | 6 ++++-- print/core/report.js | 2 +- .../reports/driver-route/driver-route.js | 15 +++++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/print/core/config.js b/print/core/config.js index 5194762b4..fba30dab9 100644 --- a/print/core/config.js +++ b/print/core/config.js @@ -1,4 +1,5 @@ const fs = require('fs-extra'); +const path = require('path'); let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development'; let configPath = `/etc/salix`; @@ -12,8 +13,9 @@ let configFiles = [ ]; for (let configFile of configFiles) { - if (fs.existsSync(configFile)) { - const conf = require(configFile); + const filePath = path.join(__dirname, configFile); + if (fs.existsSync(filePath)) { + const conf = require(filePath); for (let prop in conf) Object.assign(config[prop], conf[prop]); } diff --git a/print/core/report.js b/print/core/report.js index 46404ff96..b20b8e5df 100644 --- a/print/core/report.js +++ b/print/core/report.js @@ -27,7 +27,7 @@ class Report extends Component { if (fs.existsSync(fullPath)) options = require(optionsPath); - const page = await config.browser.newPage(); + const page = (await config.browser.pages())[0]; await page.emulateMedia('screen'); await page.setContent(template); diff --git a/print/templates/reports/driver-route/driver-route.js b/print/templates/reports/driver-route/driver-route.js index cab5342e5..0f8461046 100755 --- a/print/templates/reports/driver-route/driver-route.js +++ b/print/templates/reports/driver-route/driver-route.js @@ -10,12 +10,15 @@ module.exports = { const routes = await this.fetchRoutes(routesId); const tickets = await this.fetchTickets(routesId); - for (let route of routes) { - const routeTickets = tickets.filter(ticket => { - return ticket.routeFk == route.id; - }); + const map = new Map(); - route.tickets = routeTickets; + for (let route of routes) + map.set(route.id, route); + + for (let ticket of tickets) { + const route = map.get(ticket.routeFk); + if (!route.tickets) route.tickets = []; + route.tickets.push(ticket); } this.routes = routes; @@ -61,7 +64,7 @@ module.exports = { a.postalCode, LPAD(a.id, 5, '0') AS addressFk, p.name province, - vn.ticketGetTotal(t.id) AS import, + 0 AS import, am.name ticketAgency, tob.description, s.shipFk, From 22e7e035c3086c9c264f08fe8b0a96bca4efaf4f Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Mon, 14 Sep 2020 11:44:47 +0200 Subject: [PATCH 03/12] column tags added --- .../entry/back/methods/entry/latestBuysFilter.js | 14 ++++++++++++++ modules/entry/front/latest-buys/index.html | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/modules/entry/back/methods/entry/latestBuysFilter.js b/modules/entry/back/methods/entry/latestBuysFilter.js index 3240652cd..10c41dd92 100644 --- a/modules/entry/back/methods/entry/latestBuysFilter.js +++ b/modules/entry/back/methods/entry/latestBuysFilter.js @@ -108,6 +108,20 @@ module.exports = Self => { i.isActive, i.minPrice, i.description, + i.name, + i.subName, + i.tag5, + i.value5, + i.tag6, + i.value6, + i.tag7, + i.value7, + i.tag8, + i.value8, + i.tag9, + i.value9, + i.tag10, + i.value10, t.name AS type, intr.description AS intrastat, ori.code AS origin, diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index f06301138..2d7b8ab94 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -36,6 +36,7 @@ Quantity Description Size + Tags Type Intrastat Origin @@ -95,6 +96,14 @@ {{::buy.description | dashIfEmpty}} {{::buy.size}} + + + + {{::buy.type}} From 746bf55bcde25815a20478937a914c38772c6110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Mon, 14 Sep 2020 11:54:34 +0200 Subject: [PATCH 04/12] Updated dms path --- modules/client/front/balance/index/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/front/balance/index/index.html b/modules/client/front/balance/index/index.html index cf0c07cfc..53fda7f08 100644 --- a/modules/client/front/balance/index/index.html +++ b/modules/client/front/balance/index/index.html @@ -108,7 +108,7 @@ + href="api/InvoiceOuts/{{::balance.id}}/download?access_token={{::$ctrl.vnToken.token}}"> From 076ee50c0fd74db5e95aefbe9a08a11a991fa555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Mon, 14 Sep 2020 12:14:22 +0200 Subject: [PATCH 05/12] Config file path fix --- print/core/config.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/print/core/config.js b/print/core/config.js index fba30dab9..878caab36 100644 --- a/print/core/config.js +++ b/print/core/config.js @@ -13,7 +13,9 @@ let configFiles = [ ]; for (let configFile of configFiles) { - const filePath = path.join(__dirname, configFile); + if (!configFile.includes(configPath)) + configFile = path.join(__dirname, configFile); + if (fs.existsSync(filePath)) { const conf = require(filePath); for (let prop in conf) From c077afcfed811c0aa6cfc4649c2aaf3644f85dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Mon, 14 Sep 2020 12:34:13 +0200 Subject: [PATCH 06/12] Changed var --- print/core/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/print/core/config.js b/print/core/config.js index 878caab36..e8dd75e4b 100644 --- a/print/core/config.js +++ b/print/core/config.js @@ -16,8 +16,8 @@ for (let configFile of configFiles) { if (!configFile.includes(configPath)) configFile = path.join(__dirname, configFile); - if (fs.existsSync(filePath)) { - const conf = require(filePath); + if (fs.existsSync(configFile)) { + const conf = require(configFile); for (let prop in conf) Object.assign(config[prop], conf[prop]); } From 0b4c53a6550ffc767e1de8e9c0c364c4fd4c9cd4 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Mon, 14 Sep 2020 13:11:53 +0200 Subject: [PATCH 07/12] added invoiceOut descriptor --- modules/ticket/back/methods/ticket/filter.js | 2 ++ modules/ticket/front/index/index.html | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 878b4278e..60b57064f 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -197,6 +197,7 @@ module.exports = Self => { t.routeFk, t.warehouseFk, t.clientFk, + io.id AS invoiceOutId, a.provinceFk, p.name AS province, w.name AS warehouse, @@ -216,6 +217,7 @@ module.exports = Self => { z.id AS zoneFk, CAST(z.hour AS CHAR) AS hour FROM ticket t + LEFT JOIN invoiceOut io ON t.refFk = io.ref LEFT JOIN zone z ON z.id = t.zoneFk LEFT JOIN address a ON a.id = t.addressFk LEFT JOIN province p ON p.id = a.provinceFk diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index 2c598ca03..6a724e9cc 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -103,7 +103,14 @@ {{::ticket.warehouse}} - {{::ticket.refFk | dashIfEmpty}} + + + {{::ticket.refFk | dashIfEmpty}} + + {{::ticket.zoneLanding | date: 'HH:mm'}} @@ -169,6 +176,9 @@ + + From 26f09588389218f73a4242447a8eb9cc81e0125a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Mon, 14 Sep 2020 13:25:37 +0200 Subject: [PATCH 08/12] Trigger build --- print/core/config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/print/core/config.js b/print/core/config.js index e8dd75e4b..c7307bafc 100644 --- a/print/core/config.js +++ b/print/core/config.js @@ -24,5 +24,4 @@ for (let configFile of configFiles) { } config.env = env; - module.exports = config; From 13a5c4c4c92838d21b0d5ee81e9451aec492facb Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Mon, 14 Sep 2020 13:58:42 +0200 Subject: [PATCH 09/12] test enhanced --- .../ticket/back/methods/ticket/specs/filter.spec.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index c03a41975..524354646 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -67,14 +67,12 @@ describe('ticket filter()', () => { const ctx = {req: {accessToken: {userId: 9}}, args: {pending: true}}; const filter = {}; const result = await app.models.Ticket.filter(ctx, filter); - const firstRow = result[0]; - const secondRow = result[1]; - const thirdRow = result[2]; + + const length = result.length; + const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; expect(result.length).toEqual(7); - expect(firstRow.state).toEqual('Libre'); - expect(secondRow.state).toEqual('Libre'); - expect(thirdRow.state).toEqual('Libre'); + expect(anyResult.state).toMatch(/(Libre|Arreglar)/); }); it('should return the tickets that are not pending', async() => { From 1eb088521c593a2cb7c10784ca4eea84a57d7d0a Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Mon, 14 Sep 2020 16:08:37 +0200 Subject: [PATCH 10/12] ticket.index ref and state columns merged --- modules/ticket/front/index/index.html | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index 6a724e9cc..cf4375fc8 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -23,7 +23,6 @@ State Zone Warehouse - Invoice Closure Total @@ -89,8 +88,17 @@ {{::ticket.province}} - - + + + {{::ticket.refFk | dashIfEmpty}} + + {{ticket.state}} @@ -103,14 +111,6 @@ {{::ticket.warehouse}} - - - {{::ticket.refFk | dashIfEmpty}} - - {{::ticket.zoneLanding | date: 'HH:mm'}} From 031e40df51c6995d53a317654ea88a4441197fc9 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Mon, 14 Sep 2020 16:34:11 +0200 Subject: [PATCH 11/12] removed unused dash if empty --- modules/ticket/front/index/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index cf4375fc8..3e9809952 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -94,7 +94,7 @@ title="{{::ticket.refFk}}" vn-click-stop="invoiceOutDescriptor.show($event, ticket.invoiceOutId)" class="link"> - {{::ticket.refFk | dashIfEmpty}} + {{::ticket.refFk}} Date: Tue, 15 Sep 2020 19:43:07 +0200 Subject: [PATCH 12/12] salesPersonUser replaces salesPerson relation --- .../claim/back/methods/claim/getSummary.js | 10 +--- .../back/methods/claim/regularizeClaim.js | 7 ++- modules/claim/front/summary/index.html | 2 +- .../back/methods/client/createWithUser.js | 1 - modules/client/back/methods/client/getCard.js | 11 ----- .../back/methods/client/getTransactions.js | 22 ++++----- .../back/methods/client/hasCustomerRole.js | 4 +- .../back/methods/client/isValidClient.js | 10 ++-- modules/client/back/methods/client/summary.js | 10 +--- .../createWithInsurance.js | 1 - modules/client/back/models/client.js | 2 +- modules/client/back/models/client.json | 5 -- .../client/back/models/credit-insurance.js | 2 +- .../client/back/models/credit-insurance.json | 10 +--- modules/client/front/descriptor/index.html | 2 +- modules/client/front/summary/index.html | 4 +- .../order/back/methods/order/catalogFilter.js | 49 ++++++++++--------- .../methods/order/getItemTypeAvailable.js | 20 ++++---- modules/order/back/methods/order/getTaxes.js | 1 - modules/order/back/methods/order/summary.js | 9 ++-- modules/order/front/card/index.js | 10 +--- modules/order/front/descriptor/index.html | 2 +- .../back/methods/ticket/deleteStowaway.js | 7 ++- modules/ticket/back/methods/ticket/filter.js | 12 ++--- .../ticket/back/methods/ticket/setDeleted.js | 14 ++---- modules/ticket/back/methods/ticket/summary.js | 10 +--- modules/ticket/front/card/index.js | 10 +--- modules/ticket/front/descriptor/index.html | 2 +- modules/ticket/front/descriptor/index.js | 10 +--- modules/ticket/front/summary/index.html | 2 +- 30 files changed, 103 insertions(+), 158 deletions(-) diff --git a/modules/claim/back/methods/claim/getSummary.js b/modules/claim/back/methods/claim/getSummary.js index 35e4e1479..fce4caecf 100644 --- a/modules/claim/back/methods/claim/getSummary.js +++ b/modules/claim/back/methods/claim/getSummary.js @@ -51,15 +51,9 @@ module.exports = Self => { scope: { fields: ['salesPersonFk', 'name'], include: { - relation: 'salesPerson', + relation: 'salesPersonUser', scope: { - fields: ['userFk'], - include: { - relation: 'user', - scope: { - fields: ['nickname'] - } - } + fields: ['id', 'name'] } } } diff --git a/modules/claim/back/methods/claim/regularizeClaim.js b/modules/claim/back/methods/claim/regularizeClaim.js index 7c5c2a3d4..e8f9fe3b7 100644 --- a/modules/claim/back/methods/claim/regularizeClaim.js +++ b/modules/claim/back/methods/claim/regularizeClaim.js @@ -45,7 +45,7 @@ module.exports = Self => { if (addressId) address = await models.Address.findById(addressId, null, options); - const salesPerson = sale.ticket().client().salesPerson(); + const salesPerson = sale.ticket().client().salesPersonUser(); if (salesPerson) { const nickname = address && address.nickname || destination.description; const origin = ctx.req.headers.origin; @@ -113,7 +113,10 @@ module.exports = Self => { relation: 'client', scope: { include: { - relation: 'salesPerson' + relation: 'salesPersonUser', + scope: { + fields: ['id', 'name'] + } } } } diff --git a/modules/claim/front/summary/index.html b/modules/claim/front/summary/index.html index 8da7c317d..ab3edb2f6 100644 --- a/modules/claim/front/summary/index.html +++ b/modules/claim/front/summary/index.html @@ -16,7 +16,7 @@ + value="{{$ctrl.summary.claim.client.salesPersonUser.name}}"> { let conn = Self.dataSource.connector; let stmt = new ParameterizedSQL(` SELECT - t.id, - t.clientFk, - t.created, - t.amount / 100 amount, - t.receiptFk IS NOT NULL AS isConfirmed, - tt.message responseMessage, - te.message errorMessage - FROM hedera.tpvTransaction t - JOIN hedera.tpvMerchant m ON m.id = t.merchantFk - LEFT JOIN hedera.tpvResponse tt ON tt.id = t.response - LEFT JOIN hedera.tpvError te ON te.code = errorCode`); + t.id, + t.clientFk, + t.created, + t.amount / 100 amount, + t.receiptFk IS NOT NULL AS isConfirmed, + tt.message responseMessage, + te.message errorMessage + FROM hedera.tpvTransaction t + JOIN hedera.tpvMerchant m ON m.id = t.merchantFk + LEFT JOIN hedera.tpvResponse tt ON tt.id = t.response + LEFT JOIN hedera.tpvError te ON te.code = errorCode`); stmt.merge(conn.makeSuffix(filter, 't')); diff --git a/modules/client/back/methods/client/hasCustomerRole.js b/modules/client/back/methods/client/hasCustomerRole.js index 561f00b06..559de1fc7 100644 --- a/modules/client/back/methods/client/hasCustomerRole.js +++ b/modules/client/back/methods/client/hasCustomerRole.js @@ -30,8 +30,8 @@ module.exports = Self => { }); Self.hasCustomerRole = (id, context, callback) => { - let query = - `SELECT COUNT(*) > 0 isCustomer + let query = ` + SELECT COUNT(*) > 0 isCustomer FROM salix.Account A JOIN salix.Role r ON r.id = A.roleFK WHERE r.name = 'customer' diff --git a/modules/client/back/methods/client/isValidClient.js b/modules/client/back/methods/client/isValidClient.js index 11f183563..692da79ee 100644 --- a/modules/client/back/methods/client/isValidClient.js +++ b/modules/client/back/methods/client/isValidClient.js @@ -30,12 +30,12 @@ module.exports = Self => { }); Self.isValidClient = async id => { - let query = - `SELECT r.name + let query = ` + SELECT r.name FROM salix.Account a - JOIN vn.client c ON a.id = c.id - JOIN salix.RoleMapping rm ON rm.principalId = a.id - JOIN salix.Role r ON r.id = rm.roleId + JOIN vn.client c ON a.id = c.id + JOIN salix.RoleMapping rm ON rm.principalId = a.id + JOIN salix.Role r ON r.id = rm.roleId WHERE a.id = ? AND c.isActive AND c.isTaxDataChecked`; let roleNames = await Self.rawSql(query, [id]); diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js index 8a132665f..009cd310e 100644 --- a/modules/client/back/methods/client/summary.js +++ b/modules/client/back/methods/client/summary.js @@ -42,15 +42,9 @@ module.exports = Self => { } }, { - relation: 'salesPerson', + relation: 'salesPersonUser', scope: { - fields: ['userFk'], - include: { - relation: 'user', - scope: { - fields: ['name'] - } - } + fields: ['id', 'name'] } }, { diff --git a/modules/client/back/methods/credit-classification/createWithInsurance.js b/modules/client/back/methods/credit-classification/createWithInsurance.js index 0b74b70a2..bccfa6193 100644 --- a/modules/client/back/methods/credit-classification/createWithInsurance.js +++ b/modules/client/back/methods/credit-classification/createWithInsurance.js @@ -25,7 +25,6 @@ module.exports = Self => { Self.createWithInsurance = async(data, ctx) => { const tx = await Self.beginTransaction({}); const models = Self.app.models; - const $t = ctx.req.__; // $translate try { let options = {transaction: tx}; diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 66ab1fdc7..636e32ffa 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -105,7 +105,7 @@ module.exports = Self => { }); function hasSalesMan(err) { - if (this.payMethod && !this.salesPerson) + if (this.payMethod && !this.salesPersonUser) err(); } diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index 6f108d640..631fce3aa 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -131,11 +131,6 @@ "model": "PayMethod", "foreignKey": "payMethodFk" }, - "salesPerson": { - "type": "belongsTo", - "model": "Worker", - "foreignKey": "salesPersonFk" - }, "salesPersonUser": { "type": "belongsTo", "model": "Account", diff --git a/modules/client/back/models/credit-insurance.js b/modules/client/back/models/credit-insurance.js index 25117ead3..2a02ce41f 100644 --- a/modules/client/back/models/credit-insurance.js +++ b/modules/client/back/models/credit-insurance.js @@ -51,7 +51,7 @@ module.exports = function(Self) { const data = ctx.instance; const insurance = await Self.findById(data.id, null, options); const client = insurance.classification().customer(); - const salesPerson = client.salesPerson(); + const salesPerson = client.salesPersonUser(); if (!salesPerson) return; diff --git a/modules/client/back/models/credit-insurance.json b/modules/client/back/models/credit-insurance.json index b62c5b4f5..6a9d04677 100644 --- a/modules/client/back/models/credit-insurance.json +++ b/modules/client/back/models/credit-insurance.json @@ -43,15 +43,9 @@ "scope": { "fields": ["name", "salesPersonFk"], "include": { - "relation": "salesPerson", + "relation": "salesPersonUser", "scope": { - "fields": "userFk", - "include": { - "relation": "user", - "scope": { - "fields": ["name"] - } - } + "fields": ["id", "name"] } } } diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index 176f5cd93..0c056718d 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -39,7 +39,7 @@ - {{$ctrl.client.salesPerson.user.name}} + {{$ctrl.client.salesPersonUser.name}} diff --git a/modules/client/front/summary/index.html b/modules/client/front/summary/index.html index ce69bf158..a15fed1ee 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.user.nickname}}
+
{{$ctrl.summary.name}} - {{$ctrl.summary.id}} - {{$ctrl.summary.salesPersonUser.name}}

Basic data

@@ -25,7 +25,7 @@ - {{$ctrl.summary.salesPerson.user.name}} + {{$ctrl.summary.salesPersonUser.name}} { ] )); - stmt = new ParameterizedSQL(`SELECT - i.id, - i.name, - i.subName, - i.image, - i.tag5, - i.value5, - i.tag6, - i.value6, - i.tag7, - i.value7, - i.tag8, - i.value8, - tci.price, - tci.available, - w.lastName AS lastName, - w.firstName, - tci.priceKg, - ink.hex - FROM tmp.ticketCalculateItem tci - JOIN vn.item i ON i.id = tci.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.ink ON ink.id = i.inkFk - JOIN vn.worker w on w.id = it.workerFk`); + stmt = new ParameterizedSQL(` + SELECT + i.id, + i.name, + i.subName, + i.image, + i.tag5, + i.value5, + i.tag6, + i.value6, + i.tag7, + i.value7, + i.tag8, + i.value8, + tci.price, + tci.available, + w.lastName AS lastName, + w.firstName, + tci.priceKg, + ink.hex + FROM tmp.ticketCalculateItem tci + JOIN vn.item i ON i.id = tci.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.ink ON ink.id = i.inkFk + JOIN vn.worker w on w.id = it.workerFk`); // Apply order by tag if (orderBy.isTag) { diff --git a/modules/order/back/methods/order/getItemTypeAvailable.js b/modules/order/back/methods/order/getItemTypeAvailable.js index de0a5511c..56f6a8c0e 100644 --- a/modules/order/back/methods/order/getItemTypeAvailable.js +++ b/modules/order/back/methods/order/getItemTypeAvailable.js @@ -38,16 +38,16 @@ module.exports = Self => { order.agencyModeFk ]); stmts.push(stmt); - stmt = new ParameterizedSQL(`SELECT it.id, it.name, ic.name categoryName - FROM tmp.availableCalc ac - JOIN cache.available a ON a.calc_id = ac.calcFk - JOIN item i ON i.id = a.item_id - JOIN itemType it ON it.id = i.typeFk - JOIN itemCategory ic ON ic.id = it.categoryFk - WHERE it.categoryFk = ? - GROUP BY it.id`, [ - itemCategoryId - ]); + stmt = new ParameterizedSQL(` + SELECT it.id, it.name, ic.name categoryName + FROM tmp.availableCalc ac + JOIN cache.available a ON a.calc_id = ac.calcFk + JOIN item i ON i.id = a.item_id + JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk + WHERE it.categoryFk = ? + GROUP BY it.id`, [itemCategoryId] + ); let categoriesIndex = stmts.push(stmt) - 1; let sql = ParameterizedSQL.join(stmts, ';'); diff --git a/modules/order/back/methods/order/getTaxes.js b/modules/order/back/methods/order/getTaxes.js index e7ffd467b..3003b08d8 100644 --- a/modules/order/back/methods/order/getTaxes.js +++ b/modules/order/back/methods/order/getTaxes.js @@ -28,7 +28,6 @@ module.exports = Self => { stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.order'); - stmt = new ParameterizedSQL(` CREATE TEMPORARY TABLE tmp.order (INDEX (orderFk)) diff --git a/modules/order/back/methods/order/summary.js b/modules/order/back/methods/order/summary.js index 5acc5fb2e..eb34141c1 100644 --- a/modules/order/back/methods/order/summary.js +++ b/modules/order/back/methods/order/summary.js @@ -31,14 +31,17 @@ module.exports = Self => { async function getOrderData(Self, orderId) { let filter = { include: [ - {relation: 'agencyMode', scope: {fields: ['name']}}, + { + relation: 'agencyMode', scope: {fields: ['name']}}, { relation: 'client', scope: { fields: ['salesPersonFk', 'name'], include: { - relation: 'salesPerson', - fields: ['firstName', 'name'] + relation: 'salesPersonUser', + scope: { + fields: ['id', 'name'] + } } } }, diff --git a/modules/order/front/card/index.js b/modules/order/front/card/index.js index 33012d0f6..a7e5eeb5d 100644 --- a/modules/order/front/card/index.js +++ b/modules/order/front/card/index.js @@ -31,15 +31,9 @@ class Controller extends ModuleCard { 'isTaxDataChecked' ], include: { - relation: 'salesPerson', + relation: 'salesPersonUser', scope: { - fields: ['userFk'], - include: { - relation: 'user', - scope: { - fields: ['name'] - } - } + fields: ['id', 'name'] } } } diff --git a/modules/order/front/descriptor/index.html b/modules/order/front/descriptor/index.html index e9f1684e5..a96da252b 100644 --- a/modules/order/front/descriptor/index.html +++ b/modules/order/front/descriptor/index.html @@ -19,7 +19,7 @@ - {{$ctrl.order.client.salesPerson.user.name}} + {{$ctrl.order.client.salesPersonUser.name}} { relation: 'client', scope: { include: { - relation: 'salesPerson' + relation: 'salesPersonUser', + scope: { + fields: ['id', 'name'] + } } } }] @@ -69,7 +72,7 @@ module.exports = Self => { await ticketTracking.destroy(); - const salesPerson = ticket.client().salesPerson(); + const salesPerson = ticket.client().salesPersonUser(); if (salesPerson) { const origin = ctx.req.headers.origin; const message = $t('This ticket is not an stowaway anymore', { diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 60b57064f..62ca149f0 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -260,12 +260,12 @@ module.exports = Self => { stmt = new ParameterizedSQL(` SELECT - f.*, - tt.total, - tp.* - FROM tmp.filter f - LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = f.id - LEFT JOIN tmp.ticketTotal tt ON tt.ticketFk = f.id`); + f.*, + tt.total, + tp.* + FROM tmp.filter f + LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = f.id + LEFT JOIN tmp.ticketTotal tt ON tt.ticketFk = f.id`); if (args.problems != undefined && (!args.from && !args.to)) throw new UserError('Choose a date range or days forward'); diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index fe244becd..208333aad 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -89,12 +89,9 @@ module.exports = Self => { scope: { fields: ['id', 'salesPersonFk'], include: { - relation: 'salesPerson', + relation: 'salesPersonUser', scope: { - fields: ['id', 'userFk'], - include: { - relation: 'user' - } + fields: ['id', 'name'] } } } @@ -121,15 +118,14 @@ module.exports = Self => { } // Send notification to salesPerson - const salesPerson = ticket.client().salesPerson(); - if (salesPerson) { - const salesPersonUser = salesPerson.user().name; + const salesPersonUser = ticket.client().salesPersonUser(); + if (salesPersonUser) { const origin = ctx.req.headers.origin; const message = $t(`Has deleted the ticket id`, { id: id, url: `${origin}/#!/ticket/${id}/summary` }); - await models.Chat.send(ctx, `@${salesPersonUser}`, message); + await models.Chat.send(ctx, `@${salesPersonUser.name}`, message); } return ticket.updateAttribute('isDeleted', true); diff --git a/modules/ticket/back/methods/ticket/summary.js b/modules/ticket/back/methods/ticket/summary.js index 434cf5624..24009ed0a 100644 --- a/modules/ticket/back/methods/ticket/summary.js +++ b/modules/ticket/back/methods/ticket/summary.js @@ -57,15 +57,9 @@ module.exports = Self => { scope: { fields: ['salesPersonFk', 'name', 'phone', 'mobile'], include: { - relation: 'salesPerson', + relation: 'salesPersonUser', scope: { - fields: ['userFk'], - include: { - relation: 'user', - scope: { - fields: ['name'] - } - } + fields: ['id', 'name'] } } } diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js index 34ec2be98..44fc3e48b 100644 --- a/modules/ticket/front/card/index.js +++ b/modules/ticket/front/card/index.js @@ -38,15 +38,9 @@ class Controller extends ModuleCard { 'mobile' ], include: { - relation: 'salesPerson', + relation: 'salesPersonUser', scope: { - fields: ['userFk'], - include: { - relation: 'user', - scope: { - fields: ['name'] - } - } + fields: ['id', 'name'] } }, }, diff --git a/modules/ticket/front/descriptor/index.html b/modules/ticket/front/descriptor/index.html index f5c4891c3..c24b4c843 100644 --- a/modules/ticket/front/descriptor/index.html +++ b/modules/ticket/front/descriptor/index.html @@ -94,7 +94,7 @@ - {{$ctrl.ticket.client.salesPerson.user.name}} + {{$ctrl.ticket.client.salesPersonUser.name}} - {{$ctrl.summary.client.salesPerson.user.name}} + {{$ctrl.summary.client.salesPersonUser.name}}