refactor(origin): .origin por getUrl()
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
f832c1d9ec
commit
033c02750b
|
@ -45,11 +45,11 @@ module.exports = Self => {
|
||||||
i.longName,
|
i.longName,
|
||||||
i.size,
|
i.size,
|
||||||
ic.color,
|
ic.color,
|
||||||
o.code url,
|
o.code origin,
|
||||||
ish.packing,
|
ish.packing,
|
||||||
ish.grouping,
|
ish.grouping,
|
||||||
s.isAdded,
|
s.isAdded,
|
||||||
s.urlalQuantity,
|
s.originalQuantity,
|
||||||
s.quantity saleQuantity,
|
s.quantity saleQuantity,
|
||||||
iss.quantity reservedQuantity,
|
iss.quantity reservedQuantity,
|
||||||
SUM(iss.quantity) OVER (PARTITION BY s.id ORDER BY ish.id) accumulatedQuantity,
|
SUM(iss.quantity) OVER (PARTITION BY s.id ORDER BY ish.id) accumulatedQuantity,
|
||||||
|
@ -73,7 +73,7 @@ module.exports = Self => {
|
||||||
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
|
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||||
LEFT JOIN parking p ON p.id = sh.parkingFk
|
LEFT JOIN parking p ON p.id = sh.parkingFk
|
||||||
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
|
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
|
||||||
LEFT JOIN url o ON o.id = i.urlFk
|
LEFT JOIN origin o ON o.id = i.originFk
|
||||||
WHERE tc.collectionFk = ?
|
WHERE tc.collectionFk = ?
|
||||||
GROUP BY ish.id, p.code, p2.code
|
GROUP BY ish.id, p.code, p2.code
|
||||||
ORDER BY pickingOrder;`, [id], myOptions);
|
ORDER BY pickingOrder;`, [id], myOptions);
|
||||||
|
@ -91,7 +91,7 @@ module.exports = Self => {
|
||||||
promises.push(Self.app.models.Chat.send(ctx, observation,
|
promises.push(Self.app.models.Chat.send(ctx, observation,
|
||||||
$t('The ticket is in preparation', {
|
$t('The ticket is in preparation', {
|
||||||
ticketId: ticketId,
|
ticketId: ticketId,
|
||||||
ticketUrl: `${url}/#!/ticket/${ticketId}/summary`,
|
ticketUrl: `${url}ticket/${ticketId}/summary`,
|
||||||
salesPersonId: ticket.salesPersonFk
|
salesPersonId: ticket.salesPersonFk
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const vnModel = require('vn-loopback/common/models/vn-model');
|
const vnModel = require('vn-loopback/common/models/vn-model');
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
const {Email} = require('vn-print');
|
const {Email} = require('vn-print');
|
||||||
|
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
|
@ -90,11 +89,7 @@ module.exports = function(Self) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Self.on('resetPasswordRequest', async function(info) {
|
Self.on('resetPasswordRequest', async function(info) {
|
||||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const httpCtx = {req: loopBackContext.active};
|
|
||||||
const httpRequest = httpCtx.req.http.req;
|
|
||||||
const headers = httpRequest.headers;
|
|
||||||
const origin = headers.origin;
|
|
||||||
|
|
||||||
const defaultHash = '/reset-password?access_token=$token$';
|
const defaultHash = '/reset-password?access_token=$token$';
|
||||||
const recoverHashes = {
|
const recoverHashes = {
|
||||||
|
@ -110,7 +105,7 @@ module.exports = function(Self) {
|
||||||
const params = {
|
const params = {
|
||||||
recipient: info.email,
|
recipient: info.email,
|
||||||
lang: user.lang,
|
lang: user.lang,
|
||||||
url: origin + '/#!' + recoverHash
|
url: url.slice(0, -1) + recoverHash
|
||||||
};
|
};
|
||||||
|
|
||||||
const options = Object.assign({}, info.options);
|
const options = Object.assign({}, info.options);
|
||||||
|
@ -177,46 +172,4 @@ module.exports = function(Self) {
|
||||||
Self.sharedClass._methods.find(method => method.name == 'changePassword').ctor.settings.acls =
|
Self.sharedClass._methods.find(method => method.name == 'changePassword').ctor.settings.acls =
|
||||||
Self.sharedClass._methods.find(method => method.name == 'changePassword').ctor.settings.acls
|
Self.sharedClass._methods.find(method => method.name == 'changePassword').ctor.settings.acls
|
||||||
.filter(acl => acl.property != 'changePassword');
|
.filter(acl => acl.property != 'changePassword');
|
||||||
|
|
||||||
// FIXME: https://redmine.verdnatura.es/issues/5761
|
|
||||||
// Self.afterRemote('prototype.patchAttributes', async(ctx, instance) => {
|
|
||||||
// if (!ctx.args || !ctx.args.data.email) return;
|
|
||||||
|
|
||||||
// const loopBackContext = LoopBackContext.getCurrentContext();
|
|
||||||
// const httpCtx = {req: loopBackContext.active};
|
|
||||||
// const httpRequest = httpCtx.req.http.req;
|
|
||||||
// const headers = httpRequest.headers;
|
|
||||||
// const origin = headers.origin;
|
|
||||||
// const url = origin.split(':');
|
|
||||||
|
|
||||||
// class Mailer {
|
|
||||||
// async send(verifyOptions, cb) {
|
|
||||||
// const params = {
|
|
||||||
// url: verifyOptions.verifyHref,
|
|
||||||
// recipient: verifyOptions.to,
|
|
||||||
// lang: ctx.req.getLocale()
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const email = new Email('email-verify', params);
|
|
||||||
// email.send();
|
|
||||||
|
|
||||||
// cb(null, verifyOptions.to);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const options = {
|
|
||||||
// type: 'email',
|
|
||||||
// to: instance.email,
|
|
||||||
// from: {},
|
|
||||||
// redirect: `${origin}/#!/account/${instance.id}/basic-data?emailConfirmed`,
|
|
||||||
// template: false,
|
|
||||||
// mailer: new Mailer,
|
|
||||||
// host: url[1].split('/')[2],
|
|
||||||
// port: url[2],
|
|
||||||
// protocol: url[0],
|
|
||||||
// user: Self
|
|
||||||
// };
|
|
||||||
|
|
||||||
// await instance.verify(options);
|
|
||||||
// });
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,7 +53,8 @@ describe('ticket ticketCalculateClon()', () => {
|
||||||
expect(result[orderIndex][0].ticketFk).toBeGreaterThan(newestTicketIdInFixtures);
|
expect(result[orderIndex][0].ticketFk).toBeGreaterThan(newestTicketIdInFixtures);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add the ticket to the order containing the original ticket and generate landed value if it was null', async() => {
|
it('should add the ticket to the order containing the original ' +
|
||||||
|
'ticket and generate landed value if it was null', async() => {
|
||||||
let stmts = [];
|
let stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Self.getUrl = async(appName = 'salix') => {
|
Self.getUrl = async(appName = 'salix') => {
|
||||||
const {url} = Self.app.models.Url.findOne({
|
const {url} = await Self.app.models.Url.findOne({
|
||||||
|
|
||||||
where: {
|
where: {
|
||||||
appName,
|
appName,
|
||||||
enviroment: process.env.NODE_ENV || 'development'
|
enviroment: process.env.NODE_ENV || 'development'
|
||||||
|
|
|
@ -94,13 +94,13 @@ module.exports = Self => {
|
||||||
|
|
||||||
const salesPerson = ticket.client().salesPersonUser();
|
const salesPerson = ticket.client().salesPersonUser();
|
||||||
if (salesPerson) {
|
if (salesPerson) {
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
|
|
||||||
const message = $t('Created claim', {
|
const message = $t('Created claim', {
|
||||||
claimId: newClaim.id,
|
claimId: newClaim.id,
|
||||||
ticketId: ticketId,
|
ticketId: ticketId,
|
||||||
ticketUrl: `${origin}/#!/ticket/${ticketId}/sale`,
|
ticketUrl: `${url}/ticket/${ticketId}/sale`,
|
||||||
claimUrl: `${origin}/#!/claim/${newClaim.id}/summary`,
|
claimUrl: `${url}/claim/${newClaim.id}/summary`,
|
||||||
changes: changesMade
|
changes: changesMade
|
||||||
});
|
});
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
|
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
|
||||||
|
|
|
@ -56,15 +56,15 @@ module.exports = Self => {
|
||||||
const salesPerson = sale.ticket().client().salesPersonUser();
|
const salesPerson = sale.ticket().client().salesPersonUser();
|
||||||
if (salesPerson) {
|
if (salesPerson) {
|
||||||
const nickname = address && address.nickname || destination.description;
|
const nickname = address && address.nickname || destination.description;
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const message = $t('Sent units from ticket', {
|
const message = $t('Sent units from ticket', {
|
||||||
quantity: sale.quantity,
|
quantity: sale.quantity,
|
||||||
concept: sale.concept,
|
concept: sale.concept,
|
||||||
itemId: sale.itemFk,
|
itemId: sale.itemFk,
|
||||||
ticketId: sale.ticketFk,
|
ticketId: sale.ticketFk,
|
||||||
nickname: nickname,
|
nickname: nickname,
|
||||||
ticketUrl: `${origin}/#!/ticket/${sale.ticketFk}/sale`,
|
ticketUrl: `${url}ticket/${sale.ticketFk}/sale`,
|
||||||
itemUrl: `${origin}/#!/item/${sale.itemFk}/summary`
|
itemUrl: `${url}item/${sale.itemFk}/summary`
|
||||||
});
|
});
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
|
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,12 @@ module.exports = Self => {
|
||||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||||
const accessToken = {req: loopBackContext.active.accessToken};
|
const accessToken = {req: loopBackContext.active.accessToken};
|
||||||
|
|
||||||
const editVerifiedDataWithoutTaxDataChecked = models.ACL.checkAccessAcl(accessToken, 'Client', 'editVerifiedDataWithoutTaxDataCheck', 'WRITE');
|
const editVerifiedDataWithoutTaxDataChecked = models.ACL.checkAccessAcl(
|
||||||
|
accessToken,
|
||||||
|
'Client',
|
||||||
|
'editVerifiedDataWithoutTaxDataCheck',
|
||||||
|
'WRITE'
|
||||||
|
);
|
||||||
const hasChanges = orgData && changes;
|
const hasChanges = orgData && changes;
|
||||||
|
|
||||||
const isTaxDataChecked = hasChanges && (changes.isTaxDataChecked || orgData.isTaxDataChecked);
|
const isTaxDataChecked = hasChanges && (changes.isTaxDataChecked || orgData.isTaxDataChecked);
|
||||||
|
@ -263,7 +268,9 @@ module.exports = Self => {
|
||||||
const sageTransactionTypeChanged = hasChanges && orgData.sageTransactionTypeFk != sageTransactionType;
|
const sageTransactionTypeChanged = hasChanges && orgData.sageTransactionTypeFk != sageTransactionType;
|
||||||
|
|
||||||
const cantEditVerifiedData = isTaxDataCheckedChanged && !editVerifiedDataWithoutTaxDataChecked;
|
const cantEditVerifiedData = isTaxDataCheckedChanged && !editVerifiedDataWithoutTaxDataChecked;
|
||||||
const cantChangeSageData = (sageTaxTypeChanged || sageTransactionTypeChanged) && !editVerifiedDataWithoutTaxDataChecked;
|
const cantChangeSageData = (sageTaxTypeChanged ||
|
||||||
|
sageTransactionTypeChanged
|
||||||
|
) && !editVerifiedDataWithoutTaxDataChecked;
|
||||||
|
|
||||||
if (cantEditVerifiedData || cantChangeSageData)
|
if (cantEditVerifiedData || cantChangeSageData)
|
||||||
throw new UserError(`You don't have enough privileges`);
|
throw new UserError(`You don't have enough privileges`);
|
||||||
|
@ -346,8 +353,7 @@ module.exports = Self => {
|
||||||
const httpCtx = {req: loopBackContext.active};
|
const httpCtx = {req: loopBackContext.active};
|
||||||
const httpRequest = httpCtx.req.http.req;
|
const httpRequest = httpCtx.req.http.req;
|
||||||
const $t = httpRequest.__;
|
const $t = httpRequest.__;
|
||||||
const headers = httpRequest.headers;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const origin = headers.origin;
|
|
||||||
|
|
||||||
const salesPersonId = instance.salesPersonFk;
|
const salesPersonId = instance.salesPersonFk;
|
||||||
|
|
||||||
|
@ -366,7 +372,7 @@ module.exports = Self => {
|
||||||
await email.send();
|
await email.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
const fullUrl = `${origin}/#!/client/${instance.id}/billing-data`;
|
const fullUrl = `${url}client/${instance.id}/billing-data`;
|
||||||
const message = $t('Changed client paymethod', {
|
const message = $t('Changed client paymethod', {
|
||||||
clientId: instance.id,
|
clientId: instance.id,
|
||||||
clientName: instance.name,
|
clientName: instance.name,
|
||||||
|
@ -389,8 +395,7 @@ module.exports = Self => {
|
||||||
const httpCtx = {req: loopBackContext.active};
|
const httpCtx = {req: loopBackContext.active};
|
||||||
const httpRequest = httpCtx.req.http.req;
|
const httpRequest = httpCtx.req.http.req;
|
||||||
const $t = httpRequest.__;
|
const $t = httpRequest.__;
|
||||||
const headers = httpRequest.headers;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const origin = headers.origin;
|
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
|
||||||
let previousWorker = {name: $t('None')};
|
let previousWorker = {name: $t('None')};
|
||||||
|
@ -411,7 +416,7 @@ module.exports = Self => {
|
||||||
currentWorker.name = worker && worker.user().nickname;
|
currentWorker.name = worker && worker.user().nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fullUrl = `${origin}/#!/client/${client.id}/basic-data`;
|
const fullUrl = `${url}client/${client.id}/basic-data`;
|
||||||
const message = $t('Client assignment has changed', {
|
const message = $t('Client assignment has changed', {
|
||||||
clientId: client.id,
|
clientId: client.id,
|
||||||
clientName: client.name,
|
clientName: client.name,
|
||||||
|
|
|
@ -57,8 +57,8 @@ module.exports = function(Self) {
|
||||||
|
|
||||||
const httpRequest = httpCtx.req.http.req;
|
const httpRequest = httpCtx.req.http.req;
|
||||||
const $t = httpRequest.__;
|
const $t = httpRequest.__;
|
||||||
const origin = httpRequest.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const fullPath = `${origin}/#!/client/${client.id}/credit-insurance/index`;
|
const fullPath = `${url}client/${client.id}/credit-insurance/index`;
|
||||||
const message = $t('MESSAGE_INSURANCE_CHANGE', {
|
const message = $t('MESSAGE_INSURANCE_CHANGE', {
|
||||||
clientId: client.id,
|
clientId: client.id,
|
||||||
clientName: client.name,
|
clientName: client.name,
|
||||||
|
|
|
@ -59,10 +59,10 @@ module.exports = Self => {
|
||||||
};
|
};
|
||||||
await Self.invoiceEmail(ctx, ref);
|
await Self.invoiceEmail(ctx, ref);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const message = ctx.req.__('Mail not sent', {
|
const message = ctx.req.__('Mail not sent', {
|
||||||
clientId: client.id,
|
clientId: client.id,
|
||||||
clientUrl: `${origin}/#!/claim/${id}/summary`
|
clientUrl: `${url}claim/${id}/summary`
|
||||||
});
|
});
|
||||||
const salesPersonId = client.salesPersonFk;
|
const salesPersonId = client.salesPersonFk;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
let UserError = require('vn-loopback/util/user-error');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('deleteSales', {
|
Self.remoteMethodCtx('deleteSales', {
|
||||||
description: 'Deletes the selected sales',
|
description: 'Deletes the selected sales',
|
||||||
|
@ -70,11 +68,11 @@ module.exports = Self => {
|
||||||
|
|
||||||
const salesPerson = ticket.client().salesPersonUser();
|
const salesPerson = ticket.client().salesPersonUser();
|
||||||
if (salesPerson) {
|
if (salesPerson) {
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
|
|
||||||
const message = $t('Deleted sales from ticket', {
|
const message = $t('Deleted sales from ticket', {
|
||||||
ticketId: ticketId,
|
ticketId: ticketId,
|
||||||
ticketUrl: `${origin}/#!/ticket/${ticketId}/sale`,
|
ticketUrl: `${url}ticket/${ticketId}/sale`,
|
||||||
deletions: deletions
|
deletions: deletions
|
||||||
});
|
});
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
|
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
|
|
||||||
let UserError = require('vn-loopback/util/user-error');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('reserve', {
|
Self.remoteMethodCtx('reserve', {
|
||||||
description: 'Change the state of a ticket',
|
description: 'Change the state of a ticket',
|
||||||
|
@ -65,7 +62,8 @@ module.exports = Self => {
|
||||||
|
|
||||||
promises.push(reservedSale);
|
promises.push(reservedSale);
|
||||||
|
|
||||||
changesMade += `\r\n-${sale.itemFk}: ${sale.concept} (${sale.quantity}) ${$t('State')}: ${$t(oldState)} ➔ *${$t(newState)}*`;
|
changesMade += `\r\n-${sale.itemFk}: ${sale.concept} (${sale.quantity})
|
||||||
|
${$t('State')}: ${$t(oldState)} ➔ *${$t(newState)}*`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,11 +85,11 @@ module.exports = Self => {
|
||||||
|
|
||||||
const salesPerson = ticket.client().salesPersonUser();
|
const salesPerson = ticket.client().salesPersonUser();
|
||||||
if (salesPerson) {
|
if (salesPerson) {
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
|
|
||||||
const message = $t('Changed sale reserved state', {
|
const message = $t('Changed sale reserved state', {
|
||||||
ticketId: ticketId,
|
ticketId: ticketId,
|
||||||
ticketUrl: `${origin}/#!/ticket/${ticketId}/sale`,
|
ticketUrl: `${url}ticket/${ticketId}/sale`,
|
||||||
changes: changesMade
|
changes: changesMade
|
||||||
});
|
});
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
|
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
let UserError = require('vn-loopback/util/user-error');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('updatePrice', {
|
Self.remoteMethodCtx('updatePrice', {
|
||||||
description: 'Changes the price of a sale',
|
description: 'Changes the price of a sale',
|
||||||
|
@ -100,7 +98,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
const salesPerson = sale.ticket().client().salesPersonUser();
|
const salesPerson = sale.ticket().client().salesPersonUser();
|
||||||
if (salesPerson) {
|
if (salesPerson) {
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const message = $t('Changed sale price', {
|
const message = $t('Changed sale price', {
|
||||||
ticketId: sale.ticket().id,
|
ticketId: sale.ticket().id,
|
||||||
itemId: sale.itemFk,
|
itemId: sale.itemFk,
|
||||||
|
@ -108,8 +106,8 @@ module.exports = Self => {
|
||||||
quantity: sale.quantity,
|
quantity: sale.quantity,
|
||||||
oldPrice: oldPrice,
|
oldPrice: oldPrice,
|
||||||
newPrice: newPrice,
|
newPrice: newPrice,
|
||||||
ticketUrl: `${origin}/#!/ticket/${sale.ticket().id}/sale`,
|
ticketUrl: `${url}ticket/${sale.ticket().id}/sale`,
|
||||||
itemUrl: `${origin}/#!/item/${sale.itemFk}/summary`
|
itemUrl: `${url}item/${sale.itemFk}/summary`
|
||||||
});
|
});
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
|
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,15 +80,16 @@ module.exports = Self => {
|
||||||
|
|
||||||
const salesPerson = sale.ticket().client().salesPersonUser();
|
const salesPerson = sale.ticket().client().salesPersonUser();
|
||||||
if (salesPerson) {
|
if (salesPerson) {
|
||||||
const url = await models.Application.getUrl();
|
const url = await Self.app.models.Application.getUrl();
|
||||||
|
console.log(url);
|
||||||
const message = $t('Changed sale quantity', {
|
const message = $t('Changed sale quantity', {
|
||||||
ticketId: sale.ticket().id,
|
ticketId: sale.ticket().id,
|
||||||
itemId: sale.itemFk,
|
itemId: sale.itemFk,
|
||||||
concept: sale.concept,
|
concept: sale.concept,
|
||||||
oldQuantity: oldQuantity,
|
oldQuantity: oldQuantity,
|
||||||
newQuantity: newQuantity,
|
newQuantity: newQuantity,
|
||||||
ticketUrl: `${url}/ticket/${sale.ticket().id}/sale`,
|
ticketUrl: `${url}ticket/${sale.ticket().id}/sale`,
|
||||||
itemUrl: `${url}/item/${sale.itemFk}/summary`
|
itemUrl: `${url}item/${sale.itemFk}/summary`
|
||||||
});
|
});
|
||||||
|
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
|
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
|
||||||
|
|
|
@ -84,7 +84,7 @@ module.exports = Self => {
|
||||||
const query = `CALL vn.sale_calculateComponent(?, NULL)`;
|
const query = `CALL vn.sale_calculateComponent(?, NULL)`;
|
||||||
await Self.rawSql(query, [sale.id], myOptions);
|
await Self.rawSql(query, [sale.id], myOptions);
|
||||||
|
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const requesterId = request.requesterFk;
|
const requesterId = request.requesterFk;
|
||||||
|
|
||||||
const message = $t('Bought units from buy request', {
|
const message = $t('Bought units from buy request', {
|
||||||
|
@ -92,8 +92,8 @@ module.exports = Self => {
|
||||||
concept: sale.concept,
|
concept: sale.concept,
|
||||||
itemId: sale.itemFk,
|
itemId: sale.itemFk,
|
||||||
ticketId: sale.ticketFk,
|
ticketId: sale.ticketFk,
|
||||||
url: `${origin}/#!/ticket/${sale.ticketFk}/summary`,
|
url: `${url}ticket/${sale.ticketFk}/summary`,
|
||||||
urlItem: `${origin}/#!/item/${sale.itemFk}/summary`
|
urlItem: `${url}item/${sale.itemFk}/summary`
|
||||||
});
|
});
|
||||||
await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions);
|
await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions);
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,12 @@ module.exports = Self => {
|
||||||
const request = await Self.app.models.TicketRequest.findById(ctx.args.id, null, myOptions);
|
const request = await Self.app.models.TicketRequest.findById(ctx.args.id, null, myOptions);
|
||||||
await request.updateAttributes(params, myOptions);
|
await request.updateAttributes(params, myOptions);
|
||||||
|
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const requesterId = request.requesterFk;
|
const requesterId = request.requesterFk;
|
||||||
|
|
||||||
const message = $t('Deny buy request', {
|
const message = $t('Deny buy request', {
|
||||||
ticketId: request.ticketFk,
|
ticketId: request.ticketFk,
|
||||||
url: `${origin}/#!/ticket/${request.ticketFk}/request/index`,
|
url: `${url}ticket/${request.ticketFk}/request/index`,
|
||||||
observation: params.response
|
observation: params.response
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -94,11 +94,11 @@ module.exports = Self => {
|
||||||
|
|
||||||
const salesPerson = ticket.client().salesPersonUser();
|
const salesPerson = ticket.client().salesPersonUser();
|
||||||
if (salesPerson) {
|
if (salesPerson) {
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
|
|
||||||
const message = $t('Added sale to ticket', {
|
const message = $t('Added sale to ticket', {
|
||||||
ticketId: id,
|
ticketId: id,
|
||||||
ticketUrl: `${origin}/#!/ticket/${id}/sale`,
|
ticketUrl: `${url}ticket/${id}/sale`,
|
||||||
addition: addition
|
addition: addition
|
||||||
});
|
});
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
|
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
|
||||||
|
|
|
@ -237,7 +237,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
const salesPersonId = originalTicket.client().salesPersonFk;
|
const salesPersonId = originalTicket.client().salesPersonFk;
|
||||||
if (salesPersonId) {
|
if (salesPersonId) {
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
|
|
||||||
let changesMade = '';
|
let changesMade = '';
|
||||||
for (let change in newProperties) {
|
for (let change in newProperties) {
|
||||||
|
@ -249,7 +249,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
const message = $t('Changed this data from the ticket', {
|
const message = $t('Changed this data from the ticket', {
|
||||||
ticketId: args.id,
|
ticketId: args.id,
|
||||||
ticketUrl: `${origin}/#!/ticket/${args.id}/sale`,
|
ticketUrl: `${url}ticket/${args.id}/sale`,
|
||||||
changes: changesMade
|
changes: changesMade
|
||||||
});
|
});
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
||||||
|
|
|
@ -25,7 +25,7 @@ module.exports = Self => {
|
||||||
Self.merge = async(ctx, tickets, options) => {
|
Self.merge = async(ctx, tickets, options) => {
|
||||||
const httpRequest = ctx.req;
|
const httpRequest = ctx.req;
|
||||||
const $t = httpRequest.__;
|
const $t = httpRequest.__;
|
||||||
const origin = httpRequest.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
let tx;
|
let tx;
|
||||||
|
@ -40,8 +40,8 @@ module.exports = Self => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (let ticket of tickets) {
|
for (let ticket of tickets) {
|
||||||
const originFullPath = `${origin}/#!/ticket/${ticket.originId}/summary`;
|
const originFullPath = `${url}ticket/${ticket.originId}/summary`;
|
||||||
const destinationFullPath = `${origin}/#!/ticket/${ticket.destinationId}/summary`;
|
const destinationFullPath = `${url}ticket/${ticket.destinationId}/summary`;
|
||||||
const message = $t('Ticket merged', {
|
const message = $t('Ticket merged', {
|
||||||
originDated: dateUtil.toString(new Date(ticket.originShipped)),
|
originDated: dateUtil.toString(new Date(ticket.originShipped)),
|
||||||
destinationDated: dateUtil.toString(new Date(ticket.destinationShipped)),
|
destinationDated: dateUtil.toString(new Date(ticket.destinationShipped)),
|
||||||
|
|
|
@ -48,10 +48,10 @@ module.exports = Self => {
|
||||||
// Send notification to salesPerson
|
// Send notification to salesPerson
|
||||||
const salesPersonId = ticket.client().salesPersonFk;
|
const salesPersonId = ticket.client().salesPersonFk;
|
||||||
if (salesPersonId) {
|
if (salesPersonId) {
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const message = $t(`I have restored the ticket id`, {
|
const message = $t(`I have restored the ticket id`, {
|
||||||
id: id,
|
id: id,
|
||||||
url: `${origin}/#!/ticket/${id}/summary`
|
url: `${url}ticket/${id}/summary`
|
||||||
});
|
});
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,10 +119,10 @@ module.exports = Self => {
|
||||||
// Send notification to salesPerson
|
// Send notification to salesPerson
|
||||||
const salesPersonUser = ticket.client().salesPersonUser();
|
const salesPersonUser = ticket.client().salesPersonUser();
|
||||||
if (salesPersonUser && sales.length) {
|
if (salesPersonUser && sales.length) {
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const message = $t(`I have deleted the ticket id`, {
|
const message = $t(`I have deleted the ticket id`, {
|
||||||
id: id,
|
id: id,
|
||||||
url: `${origin}/#!/ticket/${id}/summary`
|
url: `${url}ticket/${id}/summary`
|
||||||
});
|
});
|
||||||
await models.Chat.send(ctx, `@${salesPersonUser.name}`, message);
|
await models.Chat.send(ctx, `@${salesPersonUser.name}`, message);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,8 @@ module.exports = Self => {
|
||||||
JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk
|
JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk
|
||||||
JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
|
JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
|
||||||
JOIN vn.sale s ON s.id = sgd.saleFk
|
JOIN vn.sale s ON s.id = sgd.saleFk
|
||||||
WHERE s.ticketFk = ?;`, [ticket.id], myOptions);
|
WHERE s.ticketFk = ?;`, [ticket.id], myOptions
|
||||||
|
);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
|
|
@ -165,11 +165,10 @@ module.exports = Self => {
|
||||||
|
|
||||||
const salesPerson = ticket.client().salesPersonUser();
|
const salesPerson = ticket.client().salesPersonUser();
|
||||||
if (salesPerson) {
|
if (salesPerson) {
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
|
|
||||||
const message = $t('Changed sale discount', {
|
const message = $t('Changed sale discount', {
|
||||||
ticketId: id,
|
ticketId: id,
|
||||||
ticketUrl: `${origin}/#!/ticket/${id}/sale`,
|
ticketUrl: `${url}ticket/${id}/sale`,
|
||||||
changes: changesMade
|
changes: changesMade
|
||||||
});
|
});
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
|
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
|
||||||
|
|
|
@ -109,13 +109,13 @@ module.exports = Self => {
|
||||||
const absenceType = await models.AbsenceType.findById(args.absenceTypeId, null, myOptions);
|
const absenceType = await models.AbsenceType.findById(args.absenceTypeId, null, myOptions);
|
||||||
const account = await models.VnUser.findById(userId, null, myOptions);
|
const account = await models.VnUser.findById(userId, null, myOptions);
|
||||||
const subordinated = await models.VnUser.findById(id, null, myOptions);
|
const subordinated = await models.VnUser.findById(id, null, myOptions);
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const body = $t('Created absence', {
|
const body = $t('Created absence', {
|
||||||
author: account.nickname,
|
author: account.nickname,
|
||||||
employee: subordinated.nickname,
|
employee: subordinated.nickname,
|
||||||
absenceType: absenceType.name,
|
absenceType: absenceType.name,
|
||||||
dated: formatDate(args.dated),
|
dated: formatDate(args.dated),
|
||||||
workerUrl: `${origin}/#!/worker/${id}/calendar`
|
workerUrl: `${url}worker/${id}/calendar`
|
||||||
});
|
});
|
||||||
await models.Mail.create({
|
await models.Mail.create({
|
||||||
subject: $t('Absence change notification on the labour calendar'),
|
subject: $t('Absence change notification on the labour calendar'),
|
||||||
|
|
|
@ -60,13 +60,13 @@ module.exports = Self => {
|
||||||
const absenceType = await models.AbsenceType.findById(absence.dayOffTypeFk, null, myOptions);
|
const absenceType = await models.AbsenceType.findById(absence.dayOffTypeFk, null, myOptions);
|
||||||
const account = await models.VnUser.findById(userId, null, myOptions);
|
const account = await models.VnUser.findById(userId, null, myOptions);
|
||||||
const subordinated = await models.VnUser.findById(labour.workerFk, null, myOptions);
|
const subordinated = await models.VnUser.findById(labour.workerFk, null, myOptions);
|
||||||
const origin = ctx.req.headers.origin;
|
const url = await Self.app.models.Application.getUrl();
|
||||||
const body = $t('Deleted absence', {
|
const body = $t('Deleted absence', {
|
||||||
author: account.nickname,
|
author: account.nickname,
|
||||||
employee: subordinated.nickname,
|
employee: subordinated.nickname,
|
||||||
absenceType: absenceType.name,
|
absenceType: absenceType.name,
|
||||||
dated: formatDate(absence.dated),
|
dated: formatDate(absence.dated),
|
||||||
workerUrl: `${origin}/#!/worker/${id}/calendar`
|
workerUrl: `${url}worker/${id}/calendar`
|
||||||
});
|
});
|
||||||
await models.Mail.create({
|
await models.Mail.create({
|
||||||
subject: $t('Absence change notification on the labour calendar'),
|
subject: $t('Absence change notification on the labour calendar'),
|
||||||
|
|
Loading…
Reference in New Issue