4481- Print service refactor #1064

Merged
joan merged 27 commits from 4481-print_library2 into dev 2022-10-05 09:56:51 +00:00
4 changed files with 28 additions and 12 deletions
Showing only changes of commit 5a43bdb6c9 - Show all commits

View File

@ -29,6 +29,12 @@ module.exports = Self => {
description: 'The recipient id to send to the recipient preferred language', description: 'The recipient id to send to the recipient preferred language',
required: false required: false
}, },
{
arg: 'type',
type: 'string',
description: 'The delivery note type [ deliveryNote, proforma, withoutPrices ]',
required: false
},
], ],
returns: { returns: {
type: ['object'], type: ['object'],
@ -55,9 +61,11 @@ module.exports = Self => {
if (args.replyTo) if (args.replyTo)
params.replyTo = args.replyTo; params.replyTo = args.replyTo;
const email = new Email('delivery-note', params); if (args.type)
await email.send(); params.type = args.type;
return true; const email = new Email('delivery-note', params);
return email.send();
}; };
}; };

View File

@ -2,7 +2,7 @@ const {Report, Email, smtp} = require('vn-print');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('deliveryNotePdf', { Self.remoteMethodCtx('deliveryNotePdf', {
description: '', description: 'Returns the delivery note pdf',
accepts: [ accepts: [
{ {
arg: 'id', arg: 'id',
@ -17,6 +17,12 @@ module.exports = Self => {
description: 'The client id', description: 'The client id',
required: false required: false
}, },
{
arg: 'type',
type: 'string',
description: 'The delivery note type [ deliveryNote, proforma, withoutPrices ]',
required: false
},
], ],
returns: [ returns: [
{ {
@ -51,6 +57,9 @@ module.exports = Self => {
if (args.recipientId) if (args.recipientId)
params.recipientId = args.recipientId; params.recipientId = args.recipientId;
if (args.type)
params.type = args.type;
const report = new Report('delivery-note', params); const report = new Report('delivery-note', params);
const stream = await report.toPdfStream(); const stream = await report.toPdfStream();

View File

@ -15,7 +15,7 @@
<div class="columns"> <div class="columns">
<div class="size50"> <div class="size50">
<div class="size75 vn-mt-ml"> <div class="size75 vn-mt-ml">
<h1 class="title uppercase">{{$t(type)}}</h1> <h1 class="title uppercase">{{$t(deliverNoteType)}}</h1>
<table class="row-oriented ticket-info"> <table class="row-oriented ticket-info">
<tbody> <tbody>
<tr> <tr>
@ -23,7 +23,7 @@
<th>{{client.id}}</th> <th>{{client.id}}</th>
</tr> </tr>
<tr> <tr>
<td class="font gray uppercase">{{$t(type)}}</td> <td class="font gray uppercase">{{$t(deliverNoteType)}}</td>
<th>{{ticket.id}}</th> <th>{{ticket.id}}</th>
</tr> </tr>
<tr> <tr>

View File

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