Delivery note

This commit is contained in:
Joan Sanchez 2022-09-21 13:18:32 +02:00
parent 09bdee8b34
commit 5a43bdb6c9
4 changed files with 28 additions and 12 deletions

View File

@ -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();
};
};

View File

@ -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();

View File

@ -15,7 +15,7 @@
<div class="columns">
<div class="size50">
<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">
<tbody>
<tr>
@ -23,7 +23,7 @@
<th>{{client.id}}</th>
</tr>
<tr>
<td class="font gray uppercase">{{$t(type)}}</td>
<td class="font gray uppercase">{{$t(deliverNoteType)}}</td>
<th>{{ticket.id}}</th>
</tr>
<tr>

View File

@ -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}`;
}
},