Merge pull request 'refs #5094 add scopes' (!1540) from 5094-test_docuware_autoSend into test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1540 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
03d69f81c5
|
@ -4,25 +4,25 @@ module.exports = Self => {
|
|||
Self.remoteMethodCtx('deliveryNoteEmail', {
|
||||
description: 'Sends the delivery note email with an docuware attached PDF',
|
||||
accessType: 'WRITE',
|
||||
accessScopes: ['docuwareDeliveryNoteEmail'],
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The ticket id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'recipient',
|
||||
type: 'string',
|
||||
description: 'The recipient email',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'recipientId',
|
||||
type: 'number',
|
||||
description: 'The client id',
|
||||
required: false
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'recipient',
|
||||
type: 'string',
|
||||
description: 'The recipient email',
|
||||
required: false,
|
||||
}
|
||||
],
|
||||
returns: [
|
||||
|
@ -41,12 +41,13 @@ module.exports = Self => {
|
|||
}
|
||||
],
|
||||
http: {
|
||||
path: '/:id/delivery-note-email',
|
||||
path: '/delivery-note-email',
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.deliveryNoteEmail = async(ctx, id) => {
|
||||
Self.deliveryNoteEmail = async(ctx, id, recipientId, recipient) => {
|
||||
const models = Self.app.models;
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
|
@ -57,9 +58,11 @@ module.exports = Self => {
|
|||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
if (!recipient) params.recipient = models.Client.findById(recipientId, {fields: ['email']});
|
||||
|
||||
const email = new Email('delivery-note', params);
|
||||
|
||||
const docuwareFile = await Self.app.models.Docuware.download(ctx, id, 'deliveryNote');
|
||||
const docuwareFile = await models.Docuware.download(ctx, id, 'deliveryNote');
|
||||
|
||||
return email.send({
|
||||
overrideAttachments: true,
|
||||
|
|
|
@ -142,9 +142,10 @@ class Controller extends Section {
|
|||
|
||||
sendPdfDeliveryNote($data) {
|
||||
let query = `tickets/${this.id}/delivery-note-email`;
|
||||
if (this.hasDocuwareFile) query = `docuwares/${this.id}/delivery-note-email`;
|
||||
if (this.hasDocuwareFile) query = `docuwares/delivery-note-email`;
|
||||
|
||||
return this.vnEmail.send(query, {
|
||||
id: this.id,
|
||||
recipientId: this.ticket.client.id,
|
||||
recipient: $data.email
|
||||
});
|
||||
|
|
|
@ -141,6 +141,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
|
|||
|
||||
const $data = {email: 'brucebanner@gothamcity.com'};
|
||||
const params = {
|
||||
id: 16,
|
||||
recipient: $data.email,
|
||||
recipientId: ticket.client.id
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue