diff --git a/modules/ticket/back/methods/ticket/deliveryNoteEmail.js b/modules/ticket/back/methods/ticket/deliveryNoteEmail.js index ecb4556a0..1e7ef43b9 100644 --- a/modules/ticket/back/methods/ticket/deliveryNoteEmail.js +++ b/modules/ticket/back/methods/ticket/deliveryNoteEmail.js @@ -29,6 +29,12 @@ module.exports = Self => { description: 'The recipient id to send to the recipient preferred language', required: false }, + { + arg: 'type', + type: 'string', + description: 'The delivery note type [ deliveryNote, proforma, withoutPrices ]', + required: false + }, ], returns: { type: ['object'], @@ -55,9 +61,11 @@ module.exports = Self => { if (args.replyTo) params.replyTo = args.replyTo; - const email = new Email('delivery-note', params); - await email.send(); + if (args.type) + params.type = args.type; - return true; + const email = new Email('delivery-note', params); + + return email.send(); }; }; diff --git a/modules/ticket/back/methods/ticket/deliveryNotePdf.js b/modules/ticket/back/methods/ticket/deliveryNotePdf.js index 5b34a7265..d1e288a98 100644 --- a/modules/ticket/back/methods/ticket/deliveryNotePdf.js +++ b/modules/ticket/back/methods/ticket/deliveryNotePdf.js @@ -2,7 +2,7 @@ const {Report, Email, smtp} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('deliveryNotePdf', { - description: '', + description: 'Returns the delivery note pdf', accepts: [ { arg: 'id', @@ -17,6 +17,12 @@ module.exports = Self => { description: 'The client id', required: false }, + { + arg: 'type', + type: 'string', + description: 'The delivery note type [ deliveryNote, proforma, withoutPrices ]', + required: false + }, ], returns: [ { @@ -51,6 +57,9 @@ module.exports = Self => { if (args.recipientId) params.recipientId = args.recipientId; + if (args.type) + params.type = args.type; + const report = new Report('delivery-note', params); const stream = await report.toPdfStream(); diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html index 35f9a2960..d166f3307 100644 --- a/print/templates/reports/delivery-note/delivery-note.html +++ b/print/templates/reports/delivery-note/delivery-note.html @@ -15,7 +15,7 @@
-

{{$t(type)}}

+

{{$t(deliverNoteType)}}

@@ -23,7 +23,7 @@ - + diff --git a/print/templates/reports/delivery-note/delivery-note.js b/print/templates/reports/delivery-note/delivery-note.js index a5ff69560..e33b10765 100755 --- a/print/templates/reports/delivery-note/delivery-note.js +++ b/print/templates/reports/delivery-note/delivery-note.js @@ -7,10 +7,6 @@ const fs = require('fs-extra'); module.exports = { name: 'delivery-note', - created() { - if (!this.type) - this.type = 'deliveryNote'; - }, async serverPrefetch() { this.client = await this.fetchClient(this.ticketId); this.ticket = await this.fetchTicket(this.ticketId); @@ -41,6 +37,9 @@ module.exports = { return `data:image/png;base64, ${base64}`; }, + deliverNoteType() { + return this.type ? this.type : 'deliveryNote'; + }, serviceTotal() { let total = 0.00; this.services.forEach(service => { @@ -50,10 +49,10 @@ module.exports = { return total; }, showPrices() { - return this.type != 'withoutPrices'; + return this.deliverNoteType != 'withoutPrices'; }, footerType() { - const translatedType = this.$t(this.type); + const translatedType = this.$t(this.deliverNoteType); return `${translatedType} ${this.ticketId}`; } },
{{client.id}}
{{$t(type)}}{{$t(deliverNoteType)}} {{ticket.id}}