diff --git a/modules/claim/back/methods/claim/getSummary.js b/modules/claim/back/methods/claim/getSummary.js
index 35e4e14792..fce4caecfa 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 7c5c2a3d43..e8f9fe3b79 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 8da7c317d9..ab3edb2f63 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 561f00b067..559de1fc73 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 11f183563a..692da79ee8 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 8a132665f0..009cd310e4 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 0b74b70a2b..bccfa61932 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 66ab1fdc7c..636e32ffa2 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 6f108d640d..631fce3aa1 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 25117ead3e..2a02ce41f8 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 b62c5b4f5a..6a9d04677a 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 176f5cd933..0c056718d9 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 ce69bf158f..a15fed1ee8 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 de0a5511c7..56f6a8c0ec 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 e7ffd467ba..3003b08d82 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 5acc5fb2ec..eb34141c14 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 33012d0f6c..a7e5eeb5d9 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 e9f1684e50..a96da252b2 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 60b57064f2..62ca149f0a 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 fe244becd8..208333aad7 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 434cf56245..24009ed0a4 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 34ec2be989..44fc3e48b9 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 f5c4891c37..c24b4c843d 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}}