feat: refs #8077 defaulter filter #3103

Closed
robert wants to merge 20 commits from 8077-sumDefaulter into dev
1 changed files with 4 additions and 17 deletions
Showing only changes of commit 7593edeabc - Show all commits

View File

@ -8,7 +8,7 @@ module.exports = Self => {
arg: 'id',
type: 'number',
required: true,
description: 'The client id',
description: 'The route id',
http: {source: 'path'}
}, {
arg: 'replyTo',
@ -31,26 +31,13 @@ module.exports = Self => {
});
Self.driverRouteEmail = async(ctx, id) => {
const models = Self.app.models;
const {workerFk, agencyMode} = await Self.findById(id, {
fields: ['workerFk', 'agencyModeFk'],
const {agencyMode} = await Self.findById(id, {
fields: ['agencyModeFk'],
include: {relation: 'agencyMode'}
});
const {reportMail} = agencyMode();
let user;
let account;
if (workerFk) {
user = await models.VnUser.findById(workerFk, {
fields: ['active', 'id'],
include: {relation: 'emailUser'}
});
account = await models.Account.findById(workerFk);
}
if (user?.active && account) ctx.args.recipient = user.emailUser().email;
else ctx.args.recipient = reportMail;
ctx.args.recipient = reportMail;
if (!ctx.args.recipient) throw new UserError('An email is necessary');
return Self.sendTemplate(ctx, 'driver-route');
};