diff --git a/modules/account/back/models/mail.json b/modules/account/back/models/mail.json index 3861460f3..2564f2838 100644 --- a/modules/account/back/models/mail.json +++ b/modules/account/back/models/mail.json @@ -9,19 +9,19 @@ "properties": { "id": { "id": true, - "type": "Number" + "type": "number" }, - "sender": { - "type": "String" + "receiver": { + "type": "string" }, "replyTo": { - "type": "String" + "type": "string" }, "subject": { - "type": "String" + "type": "string" }, "body": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/invoiceOut/front/card/index.js b/modules/invoiceOut/front/card/index.js index 85d03537b..c443912d9 100644 --- a/modules/invoiceOut/front/card/index.js +++ b/modules/invoiceOut/front/card/index.js @@ -8,6 +8,7 @@ class Controller extends ModuleCard { 'id', 'ref', 'issued', + 'serial', 'amount', 'clientFk', 'companyFk', diff --git a/modules/invoiceOut/front/descriptor/index.html b/modules/invoiceOut/front/descriptor/index.html index f4b4d5fc4..d5522f6a9 100644 --- a/modules/invoiceOut/front/descriptor/index.html +++ b/modules/invoiceOut/front/descriptor/index.html @@ -69,6 +69,12 @@ translate> {{!$ctrl.invoiceOut.hasPdf ? 'Generate PDF invoice': 'Regenerate PDF invoice'}} + + Show CIES letter +
diff --git a/modules/invoiceOut/front/descriptor/index.js b/modules/invoiceOut/front/descriptor/index.js index 129fe16d1..f4f8c07bd 100644 --- a/modules/invoiceOut/front/descriptor/index.js +++ b/modules/invoiceOut/front/descriptor/index.js @@ -98,6 +98,13 @@ class Controller extends Descriptor { invoiceId: this.id }); } + + showExportationLetter() { + this.vnReport.show('exportation', { + recipientId: this.invoiceOut.client.id, + invoiceId: this.id, + }); + } } ngModule.vnComponent('vnInvoiceOutDescriptor', { diff --git a/modules/invoiceOut/front/descriptor/locale/es.yml b/modules/invoiceOut/front/descriptor/locale/es.yml index 2f377ebdf..8a4a09db1 100644 --- a/modules/invoiceOut/front/descriptor/locale/es.yml +++ b/modules/invoiceOut/front/descriptor/locale/es.yml @@ -8,12 +8,13 @@ Send PDF invoice: Enviar factura en PDF Send CSV invoice: Enviar factura en CSV Delete Invoice: Eliminar factura Clone Invoice: Clonar factura +Book invoice: Asentar factura +Generate PDF invoice: Generar PDF factura +Show CIES letter: Ver carta CIES InvoiceOut deleted: Factura eliminada Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura? Are you sure you want to clone this invoice?: Estas seguro de clonar esta factura? -Book invoice: Asentar factura InvoiceOut booked: Factura asentada Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? -Generate PDF invoice: Generar PDF factura Regenerate PDF invoice: Regenerar PDF factura The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado \ No newline at end of file diff --git a/modules/supplier/back/models/supplier-account.js b/modules/supplier/back/models/supplier-account.js index ec571464a..2eecab8b3 100644 --- a/modules/supplier/back/models/supplier-account.js +++ b/modules/supplier/back/models/supplier-account.js @@ -26,7 +26,7 @@ module.exports = Self => { const user = await models.user.findById(loopBackContext.active.accessToken.userId); const bankEntity = await models.BankEntity.findById(ctx.instance.bankEntityFk); await Self.app.models.Mail.create({ - sender: 'finanzas@verdnatura.es', + receiver: 'finanzas@verdnatura.es', subject: 'Añadida cuenta bancaria al proveedor' + ctx.instance.supplierFk, body: user.username + ' ha añadido: ' + ctx.instance.iban + ', entidad: ' + bankEntity.name + ', bic: ' + bankEntity.bic diff --git a/modules/worker/back/methods/worker-time-control-mail/checkInbox.js b/modules/worker/back/methods/worker-time-control-mail/checkInbox.js index fa42f8135..bfecb1605 100644 --- a/modules/worker/back/methods/worker-time-control-mail/checkInbox.js +++ b/modules/worker/back/methods/worker-time-control-mail/checkInbox.js @@ -174,7 +174,7 @@ module.exports = Self => { const emailSubject = subject + ' ' + user.name; await Self.app.models.Mail.create({ - sender: sendTo, + receiver: sendTo, subject: emailSubject, body: emailBody }); diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index da64c413f..549ba7fd1 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -87,7 +87,7 @@ module.exports = Self => { await models.Mail.create({ subject: $t('Absence change notification on the labour calendar'), body: body, - sender: department.notificationEmail + receiver: department.notificationEmail }, myOptions); } diff --git a/modules/worker/back/methods/worker/deleteAbsence.js b/modules/worker/back/methods/worker/deleteAbsence.js index e322288d2..18427424d 100644 --- a/modules/worker/back/methods/worker/deleteAbsence.js +++ b/modules/worker/back/methods/worker/deleteAbsence.js @@ -71,7 +71,7 @@ module.exports = Self => { await models.Mail.create({ subject: $t('Absence change notification on the labour calendar'), body: body, - sender: department.notificationEmail + receiver: department.notificationEmail }, myOptions); } diff --git a/print/common/css/layout.css b/print/common/css/layout.css index 57c5db9e3..4f521bea4 100644 --- a/print/common/css/layout.css +++ b/print/common/css/layout.css @@ -256,17 +256,4 @@ table { .line span { background-color: #FFF; padding: 5px -} - -.signature { - width: 100% -} - -.signature section { - height: 150px -} - -.signature p { - margin-right: 50%; - margin-top: 140px -} +} \ No newline at end of file diff --git a/print/methods/closure.js b/print/methods/closure.js index 450bd0ed2..07bd1768d 100644 --- a/print/methods/closure.js +++ b/print/methods/closure.js @@ -1,5 +1,6 @@ const db = require('../core/database'); const Email = require('../core/email'); +const Report = require('../core/report'); const smtp = require('../core/smtp'); const config = require('../core/config'); @@ -195,7 +196,8 @@ module.exports = app => { if (!ticket.recipient) { const body = `No se ha podido enviar el albarán ${ticket.id} al cliente ${ticket.clientFk} porque no tiene un email especificado.

- Para dejar de recibir esta notificación, asígnale un email o desactiva la notificación por email para este cliente.`; + Para dejar de recibir esta notificación, asígnale un email o desactiva + la notificación por email para este cliente.`; smtp.send({ to: ticket.salesPersonEmail, subject: 'No se ha podido enviar el albarán', @@ -207,22 +209,37 @@ module.exports = app => { const hasToInvoice = ticket.hasToInvoice && ticket.hasDailyInvoice; if (hasToInvoice) { - const invoiceId = await db.findValue(` - SELECT io.id + const invoice = await db.findOne(` + SELECT io.id, io.ref, io.serial, cny.code companyCode FROM ticket t JOIN invoiceOut io ON io.ref = t.refFk + JOIN company cny ON cny.id = io.companyFk WHERE t.id = ? `, [ticket.id]); const args = Object.assign({ - invoiceId: invoiceId, + invoiceId: invoice.id, recipientId: ticket.clientFk, recipient: ticket.recipient, replyTo: ticket.salesPersonEmail }, reqArgs); + let mailOptions = {}; + if (invoice.serial == 'E' && invoice.companyCode == 'VNL') { + const exportation = new Report('exportation', args); + const stream = await exportation.toPdfStream(); + const fileName = `exportation-${invoice.ref}.pdf`; + mailOptions = { + overrideAttachments: false, + attachments: [{ + filename: fileName, + content: stream + }] + }; + } + const email = new Email('invoice', args); - await email.send(); + await email.send(mailOptions); } else { const args = Object.assign({ ticketId: ticket.id, diff --git a/print/templates/reports/exportation/assets/css/import.js b/print/templates/reports/exportation/assets/css/import.js new file mode 100644 index 000000000..a2a9334cb --- /dev/null +++ b/print/templates/reports/exportation/assets/css/import.js @@ -0,0 +1,8 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/report.css`, + `${appPath}/common/css/misc.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/exportation/assets/css/style.css b/print/templates/reports/exportation/assets/css/style.css new file mode 100644 index 000000000..174559424 --- /dev/null +++ b/print/templates/reports/exportation/assets/css/style.css @@ -0,0 +1,12 @@ +.grid-block { + font-size: 1.2em +} + +ul li { + margin-bottom: 20px; + text-align: justify; +} + +.signature img { + width: 400px +} \ No newline at end of file diff --git a/print/templates/reports/exportation/assets/images/signature.png b/print/templates/reports/exportation/assets/images/signature.png new file mode 100644 index 000000000..c69cc4798 Binary files /dev/null and b/print/templates/reports/exportation/assets/images/signature.png differ diff --git a/print/templates/reports/exportation/exportation.html b/print/templates/reports/exportation/exportation.html new file mode 100644 index 000000000..f08af2cdb --- /dev/null +++ b/print/templates/reports/exportation/exportation.html @@ -0,0 +1,51 @@ + + + + + + + + + +
+ + + +
+
+

{{$t('title')}}

+

{{$t('toAttention')}}

+

+

+

    +
  • + {{responsibility}} +
  • +
+

+
+

{{$t('issued', [ + 'Algemesí', + invoice.issued.getDate(), + $t('months')[invoice.issued.getMonth()], + invoice.issued.getFullYear()]) + }} +

+

({{$t('signature')}})

+ +

+

{{$t('signer.name')}}: JUAN VICENTE FERRER ROIG
+
{{$t('signer.ID')}}: 73943586N
+
{{$t('signer.position')}}: ADMINISTRADOR
+

+
+
+
+ + + +
+ + \ No newline at end of file diff --git a/print/templates/reports/exportation/exportation.js b/print/templates/reports/exportation/exportation.js new file mode 100755 index 000000000..f63d17930 --- /dev/null +++ b/print/templates/reports/exportation/exportation.js @@ -0,0 +1,34 @@ +const Component = require(`${appPath}/core/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); + +module.exports = { + name: 'exportation', + async serverPrefetch() { + this.invoice = await this.fetchInvoice(this.invoiceId); + + if (!this.invoice) + throw new Error('Something went wrong'); + }, + methods: { + fetchInvoice(invoiceId) { + return this.findOneFromDef('invoice', [invoiceId]); + } + }, + computed: { + issued: function() { + const filters = this.$options.filters; + + return filters.date(this.invoice.issued, '%d-%m-%Y'); + } + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() + }, + props: { + invoiceId: { + required: true + } + } +}; diff --git a/print/templates/reports/exportation/locale/es.yml b/print/templates/reports/exportation/locale/es.yml new file mode 100644 index 000000000..d5fb78b4c --- /dev/null +++ b/print/templates/reports/exportation/locale/es.yml @@ -0,0 +1,50 @@ +title: 'Carta CITES' +toAttention: 'A la atención del Sr. Administrador de la Aduana de la Farga de Moles.' +declaration: 'Por la presente DECLARO, bajo mi responsabilidad, que las mercancías detalladas en la factura +n° {0} de fecha {1} +asi como ninguno de sus componentes,' +issued: 'En {0}, a {1} de {2} de {3}' +invoice: 'Factura {0}' +responsibilities: + - 'NO están comprendidas en la Convención de Washington (CITES). Reglamento (CE) n° 338/1997 +DO L61 de 3.3.1997 y sus últimas modificaciones, relativo a la protección de especies de fauna y +flora silvestres.' + - 'NO están incluidas en las listas del Anexo I del R/CE 428/2009 y sus posteriores modificaciones, +por lo que NO puede considerarse productos ni tecnologias de Doble Uso ni de uso militar. +No estando incluidas en la Relación de Material de Defensa del Anexo I del Real Decreto +679/2014, estando exentas a todos los efectos de autorizaciones administrativas para su comercio +exterior.' + - 'NO están incluidas los Anexos II, III y IV del R/UE 2019/125 L-30 de 31/01/2019 +y sus modificaciones, sobre el comercio de determinados productos que pueden utilizarse para +aplicar la pena de muerte o infligir tortura u otros tratos o penas crueles, inhumanos o +degradantes.' + - 'NO están incluidas en el ANEXO ni en el ANEXO V del Reglamento (UE) N° 649/2012 y +sus modificaciones, relativo a la exportación e importación de productos químicos +peligrosos. ni tampoco contienen mercurio.' + - 'NO están sujetas al Reglamento/CE 1005/2009 L-286 de 30-10-2009 y sus +modificaciones, relativo a las mercancías que agotan la capa de ozono.' + - 'NO están afectadas por la prohibición a las importaciones de gases fluorados de +efecto invernadero, de acuerdo con el R/UE 517/2014.' + - 'NO están sujetas al Reglamento (CE) 116/2009 relativo a la exportación de bienes +culturales; y NO están sujetas a la Ley 16/1985, de 25 de junio, del Patrimonio +Histórico Español, estando exentas de Autorización Administrativa de Exportación.' + - 'NO están sujetos a las disposiciones del Reglamento (CE) Nº 1013/2006, relativo +a los traslados de residuos, y que en ningún modo pueden considerarse afectados por este control.' +signature: Firma y sello de la empresa +signer: + name: Nombre del firmante + ID: DNI del firmante + position: Cargo del firmante +months: + - 'Enero' + - 'Febrero' + - 'Marzo' + - 'Abril' + - 'Mayo' + - 'Junio' + - 'Julio' + - 'Agosto' + - 'Septiembre' + - 'Octubre' + - 'Noviembre' + - 'Diciembre' \ No newline at end of file diff --git a/print/templates/reports/exportation/sql/invoice.sql b/print/templates/reports/exportation/sql/invoice.sql new file mode 100644 index 000000000..8e92333dd --- /dev/null +++ b/print/templates/reports/exportation/sql/invoice.sql @@ -0,0 +1,6 @@ +SELECT + io.id, + io.ref, + io.issued +FROM invoiceOut io +WHERE io.id = ? \ No newline at end of file