From 377a0f722823a6d14b030fc8c6dbb3bc4a1a0cb6 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 4 Oct 2022 13:41:37 +0200 Subject: [PATCH] Attachments refactor --- db/changes/10490-august/00-ACL.sql | 6 +- e2e/paths/04-item/09_index.spec.js | 2 +- .../methods/client/clientDebtStatementHtml.js | 2 + .../methods/client/clientDebtStatementPdf.js | 61 ++++++++++++++++++ .../back/methods/client/creditRequestHtml.js | 2 + .../back/methods/client/creditRequestPdf.js | 56 +++++++++++++++++ .../client/incotermsAuthorizationHtml.js | 2 + .../client/incotermsAuthorizationPdf.js | 62 +++++++++++++++++++ .../back/methods/client/letterDebtorNdHtml.js | 2 + .../back/methods/client/letterDebtorPdf.js | 62 +++++++++++++++++++ .../back/methods/client/letterDebtorStHtml.js | 2 + modules/client/back/models/client-methods.js | 4 ++ modules/item/front/index/style.scss | 10 +++ print/common/css/email.css | 5 ++ .../attachment/assets/css/style.css | 11 ++-- .../components/attachment/attachment.html | 8 ++- .../core/components/attachment/attachment.js | 8 +-- print/core/email.js | 1 - print/core/mixins/prop-validator.js | 4 +- print/core/mixins/user-locale.js | 2 +- .../client-debt-statement/attachments.json | 6 -- .../client-debt-statement.js | 11 +++- .../email/credit-request/credit-request.js | 17 ++++- .../incoterms-authorization/attachments.json | 6 -- .../incoterms-authorization.js | 11 +++- .../email/letter-debtor-nd/attachments.json | 6 -- .../letter-debtor-nd/letter-debtor-nd.js | 11 +++- .../email/letter-debtor-st/attachments.json | 6 -- .../letter-debtor-st/letter-debtor-st.js | 11 +++- 29 files changed, 347 insertions(+), 50 deletions(-) create mode 100644 modules/client/back/methods/client/clientDebtStatementPdf.js create mode 100644 modules/client/back/methods/client/creditRequestPdf.js create mode 100644 modules/client/back/methods/client/incotermsAuthorizationPdf.js create mode 100644 modules/client/back/methods/client/letterDebtorPdf.js delete mode 100644 print/templates/email/client-debt-statement/attachments.json delete mode 100644 print/templates/email/incoterms-authorization/attachments.json delete mode 100644 print/templates/email/letter-debtor-nd/attachments.json delete mode 100644 print/templates/email/letter-debtor-st/attachments.json diff --git a/db/changes/10490-august/00-ACL.sql b/db/changes/10490-august/00-ACL.sql index 55852a38d..2cce197b2 100644 --- a/db/changes/10490-august/00-ACL.sql +++ b/db/changes/10490-august/00-ACL.sql @@ -8,18 +8,22 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp ('Client', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'campaignMetricsEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'clientWelcomeHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('Client', 'clientWelcomeEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),, + ('Client', 'clientWelcomeEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'creditRequestPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'creditRequestHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'creditRequestEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'printerSetupHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'printerSetupEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'sepaCoreEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'letterDebtorPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'letterDebtorStHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'letterDebtorStEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'letterDebtorNdHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'letterDebtorNdEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'clientDebtStatementPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'clientDebtStatementHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'clientDebtStatementEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'incotermsAuthorizationPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'incotermsAuthorizationHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'incotermsAuthorizationEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'consumptionSendQueued', 'WRITE', 'ALLOW', 'ROLE', 'system'), diff --git a/e2e/paths/04-item/09_index.spec.js b/e2e/paths/04-item/09_index.spec.js index 6e0a4bd5c..03492f8c1 100644 --- a/e2e/paths/04-item/09_index.spec.js +++ b/e2e/paths/04-item/09_index.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -describe('Item index path', () => { +fdescribe('Item index path', () => { let browser; let page; beforeAll(async() => { diff --git a/modules/client/back/methods/client/clientDebtStatementHtml.js b/modules/client/back/methods/client/clientDebtStatementHtml.js index 76502ff6c..bfed696bc 100644 --- a/modules/client/back/methods/client/clientDebtStatementHtml.js +++ b/modules/client/back/methods/client/clientDebtStatementHtml.js @@ -46,6 +46,7 @@ module.exports = Self => { }); Self.clientDebtStatementHtml = async(ctx, id) => { + const {accessToken} = ctx.req; const args = Object.assign({}, ctx.args); const params = {lang: ctx.req.getLocale()}; @@ -54,6 +55,7 @@ module.exports = Self => { params[param] = args[param]; params.isPreview = true; + params.access_token = accessToken.id; const report = new Email('client-debt-statement', params); const html = await report.render(); diff --git a/modules/client/back/methods/client/clientDebtStatementPdf.js b/modules/client/back/methods/client/clientDebtStatementPdf.js new file mode 100644 index 000000000..8e2dca314 --- /dev/null +++ b/modules/client/back/methods/client/clientDebtStatementPdf.js @@ -0,0 +1,61 @@ +const {Report} = require('vn-print'); + +module.exports = Self => { + Self.remoteMethodCtx('clientDebtStatementPdf', { + description: 'Returns the client debt statement pdf', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The client id', + http: {source: 'path'} + }, + { + arg: 'recipientId', + type: 'number', + description: 'The recipient id', + required: false + }, + { + arg: 'from', + type: 'string', + required: true + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/client-debt-statement-pdf', + verb: 'GET' + } + }); + + Self.clientDebtStatementPdf = async(ctx, id) => { + const args = Object.assign({}, ctx.args); + const params = {lang: ctx.req.getLocale()}; + + delete args.ctx; + for (const param in args) + params[param] = args[param]; + + const report = new Report('client-debt-statement', params); + const stream = await report.toPdfStream(); + + return [stream, 'application/pdf', `filename="doc-${id}.pdf"`]; + }; +}; diff --git a/modules/client/back/methods/client/creditRequestHtml.js b/modules/client/back/methods/client/creditRequestHtml.js index 303308615..6b2d7fe4e 100644 --- a/modules/client/back/methods/client/creditRequestHtml.js +++ b/modules/client/back/methods/client/creditRequestHtml.js @@ -41,6 +41,7 @@ module.exports = Self => { }); Self.creditRequestHtml = async(ctx, id) => { + const {accessToken} = ctx.req; const args = Object.assign({}, ctx.args); const params = {lang: ctx.req.getLocale()}; @@ -49,6 +50,7 @@ module.exports = Self => { params[param] = args[param]; params.isPreview = true; + params.access_token = accessToken.id; const report = new Email('credit-request', params); const html = await report.render(); diff --git a/modules/client/back/methods/client/creditRequestPdf.js b/modules/client/back/methods/client/creditRequestPdf.js new file mode 100644 index 000000000..2e3dc0619 --- /dev/null +++ b/modules/client/back/methods/client/creditRequestPdf.js @@ -0,0 +1,56 @@ +const {Report} = require('vn-print'); + +module.exports = Self => { + Self.remoteMethodCtx('creditRequestPdf', { + description: 'Returns the credit request pdf', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The client id', + http: {source: 'path'} + }, + { + arg: 'recipientId', + type: 'number', + description: 'The recipient id', + required: false + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/credit-request-pdf', + verb: 'GET' + } + }); + + Self.creditRequestPdf = async(ctx, id) => { + const args = Object.assign({}, ctx.args); + const params = {lang: ctx.req.getLocale()}; + + delete args.ctx; + for (const param in args) + params[param] = args[param]; + + const report = new Report('credit-request', params); + const stream = await report.toPdfStream(); + + return [stream, 'application/pdf', `filename="doc-${id}.pdf"`]; + }; +}; diff --git a/modules/client/back/methods/client/incotermsAuthorizationHtml.js b/modules/client/back/methods/client/incotermsAuthorizationHtml.js index f8c3e6e60..875495d93 100644 --- a/modules/client/back/methods/client/incotermsAuthorizationHtml.js +++ b/modules/client/back/methods/client/incotermsAuthorizationHtml.js @@ -47,6 +47,7 @@ module.exports = Self => { }); Self.incotermsAuthorizationHtml = async(ctx, id) => { + const {accessToken} = ctx.req; const args = Object.assign({}, ctx.args); const params = {lang: ctx.req.getLocale()}; @@ -55,6 +56,7 @@ module.exports = Self => { params[param] = args[param]; params.isPreview = true; + params.access_token = accessToken.id; const report = new Email('incoterms-authorization', params); const html = await report.render(); diff --git a/modules/client/back/methods/client/incotermsAuthorizationPdf.js b/modules/client/back/methods/client/incotermsAuthorizationPdf.js new file mode 100644 index 000000000..9a8a8d296 --- /dev/null +++ b/modules/client/back/methods/client/incotermsAuthorizationPdf.js @@ -0,0 +1,62 @@ +const {Report} = require('vn-print'); + +module.exports = Self => { + Self.remoteMethodCtx('incotermsAuthorizationPdf', { + description: 'Returns the incoterms authorization pdf', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The client id', + http: {source: 'path'} + }, + { + arg: 'recipientId', + type: 'number', + description: 'The recipient id', + required: false + }, + { + arg: 'companyId', + type: 'number', + description: 'The company id', + required: true + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/incoterms-authorization-pdf', + verb: 'GET' + } + }); + + Self.incotermsAuthorizationPdf = async(ctx, id) => { + const args = Object.assign({}, ctx.args); + const params = {lang: ctx.req.getLocale()}; + + delete args.ctx; + for (const param in args) + params[param] = args[param]; + + const report = new Report('incoterms-authorization', params); + const stream = await report.toPdfStream(); + + return [stream, 'application/pdf', `filename="doc-${id}.pdf"`]; + }; +}; diff --git a/modules/client/back/methods/client/letterDebtorNdHtml.js b/modules/client/back/methods/client/letterDebtorNdHtml.js index d709a3cee..320fbaef3 100644 --- a/modules/client/back/methods/client/letterDebtorNdHtml.js +++ b/modules/client/back/methods/client/letterDebtorNdHtml.js @@ -47,6 +47,7 @@ module.exports = Self => { }); Self.letterDebtorNdHtml = async(ctx, id) => { + const {accessToken} = ctx.req; const args = Object.assign({}, ctx.args); const params = {lang: ctx.req.getLocale()}; @@ -55,6 +56,7 @@ module.exports = Self => { params[param] = args[param]; params.isPreview = true; + params.access_token = accessToken.id; const report = new Email('letter-debtor-nd', params); const html = await report.render(); diff --git a/modules/client/back/methods/client/letterDebtorPdf.js b/modules/client/back/methods/client/letterDebtorPdf.js new file mode 100644 index 000000000..421d531e6 --- /dev/null +++ b/modules/client/back/methods/client/letterDebtorPdf.js @@ -0,0 +1,62 @@ +const {Report} = require('vn-print'); + +module.exports = Self => { + Self.remoteMethodCtx('letterDebtorPdf', { + description: 'Returns the letter debtor pdf', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The client id', + http: {source: 'path'} + }, + { + arg: 'recipientId', + type: 'number', + description: 'The recipient id', + required: false + }, + { + arg: 'companyId', + type: 'number', + description: 'The company id', + required: true + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/letter-debtor-pdf', + verb: 'GET' + } + }); + + Self.letterDebtorPdf = async(ctx, id) => { + const args = Object.assign({}, ctx.args); + const params = {lang: ctx.req.getLocale()}; + + delete args.ctx; + for (const param in args) + params[param] = args[param]; + + const report = new Report('letter-debtor', params); + const stream = await report.toPdfStream(); + + return [stream, 'application/pdf', `filename="doc-${id}.pdf"`]; + }; +}; diff --git a/modules/client/back/methods/client/letterDebtorStHtml.js b/modules/client/back/methods/client/letterDebtorStHtml.js index b97ce9767..acf75272b 100644 --- a/modules/client/back/methods/client/letterDebtorStHtml.js +++ b/modules/client/back/methods/client/letterDebtorStHtml.js @@ -47,6 +47,7 @@ module.exports = Self => { }); Self.letterDebtorStHtml = async(ctx, id) => { + const {accessToken} = ctx.req; const args = Object.assign({}, ctx.args); const params = {lang: ctx.req.getLocale()}; @@ -55,6 +56,7 @@ module.exports = Self => { params[param] = args[param]; params.isPreview = true; + params.access_token = accessToken.id; const report = new Email('letter-debtor-st', params); const html = await report.render(); diff --git a/modules/client/back/models/client-methods.js b/modules/client/back/models/client-methods.js index bacbea727..04d10413a 100644 --- a/modules/client/back/models/client-methods.js +++ b/modules/client/back/models/client-methods.js @@ -32,14 +32,18 @@ module.exports = Self => { require('../methods/client/printerSetupHtml')(Self); require('../methods/client/printerSetupEmail')(Self); require('../methods/client/sepaCoreEmail')(Self); + require('../methods/client/letterDebtorPdf')(Self); require('../methods/client/letterDebtorStHtml')(Self); require('../methods/client/letterDebtorStEmail')(Self); require('../methods/client/letterDebtorNdHtml')(Self); require('../methods/client/letterDebtorNdEmail')(Self); + require('../methods/client/clientDebtStatementPdf')(Self); require('../methods/client/clientDebtStatementHtml')(Self); require('../methods/client/clientDebtStatementEmail')(Self); + require('../methods/client/creditRequestPdf')(Self); require('../methods/client/creditRequestHtml')(Self); require('../methods/client/creditRequestEmail')(Self); + require('../methods/client/incotermsAuthorizationPdf')(Self); require('../methods/client/incotermsAuthorizationHtml')(Self); require('../methods/client/incotermsAuthorizationEmail')(Self); require('../methods/client/consumptionSendQueued')(Self); diff --git a/modules/item/front/index/style.scss b/modules/item/front/index/style.scss index 451dd09ae..e9fd9f935 100644 --- a/modules/item/front/index/style.scss +++ b/modules/item/front/index/style.scss @@ -21,4 +21,14 @@ vn-item-product { vn-label-value:first-of-type section{ margin-top: 9px; } +} + +vn-item-index { + table { + img { + border-radius: 50%; + width: 50px; + height: 50px; + } + } } \ No newline at end of file diff --git a/print/common/css/email.css b/print/common/css/email.css index 6e6350ff5..5fe3b955e 100644 --- a/print/common/css/email.css +++ b/print/common/css/email.css @@ -31,3 +31,8 @@ h1 { font-weight: 100; font-size: 1.5em } + +h6 { + font-weight: 100; + font-size: 1.2em +} diff --git a/print/core/components/attachment/assets/css/style.css b/print/core/components/attachment/assets/css/style.css index 775c43ada..37fde9285 100644 --- a/print/core/components/attachment/assets/css/style.css +++ b/print/core/components/attachment/assets/css/style.css @@ -4,19 +4,22 @@ div { } a { - background-color: #F5F5F5; + background-color: #fcfcfc; border: 1px solid #CCC; display: flex; vertical-align: middle; box-sizing: border-box; min-width: 150px; text-decoration: none; - border-radius: 3px; + border-radius: 8px; color: #8dba25 } a > div.icon { + border-radius: 5px; + padding: 2px 5px; + background-color: red; font-weight: bold; - font-size: 18px; - color: #555 + font-size: 12px; + color: #FFF } \ No newline at end of file diff --git a/print/core/components/attachment/attachment.html b/print/core/components/attachment/attachment.html index 88fa64434..0044190a7 100644 --- a/print/core/components/attachment/attachment.html +++ b/print/core/components/attachment/attachment.html @@ -1,6 +1,10 @@ -
+ \ No newline at end of file diff --git a/print/core/components/attachment/attachment.js b/print/core/components/attachment/attachment.js index 5c78a895c..30e1944a4 100755 --- a/print/core/components/attachment/attachment.js +++ b/print/core/components/attachment/attachment.js @@ -4,10 +4,10 @@ module.exports = { attachmentPath() { const filename = this.attachment.filename; const component = this.attachment.component; - if (this.attachment.cid) + if (this.attachment.cid && component) return `/api/${component}/assets/files/${filename}`; - else - return `/api/report/${component}?${this.getHttpParams()}`; + else if (this.attachment.path) + return `/api/${this.attachment.path}?${this.getHttpParams()}`; } }, methods: { @@ -15,7 +15,7 @@ module.exports = { const props = this.args; let query = ''; for (let param in props) { - if (!(props[param] instanceof Object)) { + if (props[param] && !(props[param] instanceof Object)) { if (query != '') query += '&'; query += `${param}=${props[param]}`; } diff --git a/print/core/email.js b/print/core/email.js index 353b70367..0184e360c 100644 --- a/print/core/email.js +++ b/print/core/email.js @@ -1,6 +1,5 @@ const path = require('path'); const smtp = require('./smtp'); -const config = require('./config'); const Component = require('./component'); const Report = require('./report'); diff --git a/print/core/mixins/prop-validator.js b/print/core/mixins/prop-validator.js index 16c71a6db..cb41d3dd8 100644 --- a/print/core/mixins/prop-validator.js +++ b/print/core/mixins/prop-validator.js @@ -4,7 +4,7 @@ const validator = { const props = this.$options.props; const invalidProps = []; - for (prop in props) { + for (const prop in props) { const isObject = typeof props[prop] === 'object'; const isRequired = props[prop].required; const isNotDefined = this[prop] === undefined; @@ -19,7 +19,7 @@ const validator = { throw new Error(`Required properties not found [${required}]`); } }, - props: ['isPreview', 'authorization'] + props: ['isPreview', 'access_token'] }; Vue.mixin(validator); diff --git a/print/core/mixins/user-locale.js b/print/core/mixins/user-locale.js index 0e4727334..18b4c68c5 100644 --- a/print/core/mixins/user-locale.js +++ b/print/core/mixins/user-locale.js @@ -24,7 +24,7 @@ const userLocale = { }); } }, - props: ['auth', 'recipientId'] + props: ['recipientId'] }; Vue.mixin(userLocale); diff --git a/print/templates/email/client-debt-statement/attachments.json b/print/templates/email/client-debt-statement/attachments.json deleted file mode 100644 index 9cc4911e6..000000000 --- a/print/templates/email/client-debt-statement/attachments.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "filename": "client-debt-statement.pdf", - "component": "client-debt-statement" - } -] \ No newline at end of file diff --git a/print/templates/email/client-debt-statement/client-debt-statement.js b/print/templates/email/client-debt-statement/client-debt-statement.js index 4d5499960..85b3c5cc3 100755 --- a/print/templates/email/client-debt-statement/client-debt-statement.js +++ b/print/templates/email/client-debt-statement/client-debt-statement.js @@ -2,7 +2,6 @@ const Component = require(`vn-print/core/component`); const emailHeader = new Component('email-header'); const emailFooter = new Component('email-footer'); const attachment = new Component('attachment'); -const attachments = require('./attachments.json'); module.exports = { name: 'client-debt-statement', @@ -12,7 +11,15 @@ module.exports = { 'attachment': attachment.build() }, data() { - return {attachments}; + return { + attachments: [ + { + filename: 'client-debt-statement.pdf', + type: 'pdf', + path: `Clients/${this.id}/client-debt-statement-pdf` + } + ] + }; }, props: { id: { diff --git a/print/templates/email/credit-request/credit-request.js b/print/templates/email/credit-request/credit-request.js index 79c33ba0c..8f68d56c0 100755 --- a/print/templates/email/credit-request/credit-request.js +++ b/print/templates/email/credit-request/credit-request.js @@ -2,7 +2,6 @@ const Component = require(`vn-print/core/component`); const emailHeader = new Component('email-header'); const emailFooter = new Component('email-footer'); const attachment = new Component('attachment'); -const attachments = require('./attachments.json'); module.exports = { name: 'credit-request', @@ -12,6 +11,20 @@ module.exports = { 'attachment': attachment.build() }, data() { - return {attachments}; + return { + attachments: [ + { + filename: 'credit-request.pdf', + type: 'pdf', + path: `Clients/${this.id}/credit-request-pdf` + } + ] + }; }, + props: { + id: { + type: Number, + required: true + } + } }; diff --git a/print/templates/email/incoterms-authorization/attachments.json b/print/templates/email/incoterms-authorization/attachments.json deleted file mode 100644 index 9dfd945db..000000000 --- a/print/templates/email/incoterms-authorization/attachments.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "filename": "incoterms-authorization.pdf", - "component": "incoterms-authorization" - } -] \ No newline at end of file diff --git a/print/templates/email/incoterms-authorization/incoterms-authorization.js b/print/templates/email/incoterms-authorization/incoterms-authorization.js index f8db74e0e..b1c7286dd 100755 --- a/print/templates/email/incoterms-authorization/incoterms-authorization.js +++ b/print/templates/email/incoterms-authorization/incoterms-authorization.js @@ -2,12 +2,19 @@ const Component = require(`vn-print/core/component`); const emailHeader = new Component('email-header'); const emailFooter = new Component('email-footer'); const attachment = new Component('attachment'); -const attachments = require('./attachments.json'); module.exports = { name: 'incoterms-authorization', data() { - return {attachments}; + return { + attachments: [ + { + filename: 'incoterms-authorization.pdf', + type: 'pdf', + path: `Clients/${this.id}/incoterms-authorization-pdf` + } + ] + }; }, components: { 'email-header': emailHeader.build(), diff --git a/print/templates/email/letter-debtor-nd/attachments.json b/print/templates/email/letter-debtor-nd/attachments.json deleted file mode 100644 index 1e21ea343..000000000 --- a/print/templates/email/letter-debtor-nd/attachments.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "filename": "letter-debtor.pdf", - "component": "letter-debtor" - } -] \ No newline at end of file diff --git a/print/templates/email/letter-debtor-nd/letter-debtor-nd.js b/print/templates/email/letter-debtor-nd/letter-debtor-nd.js index a51797fa1..cf9cc7ddd 100755 --- a/print/templates/email/letter-debtor-nd/letter-debtor-nd.js +++ b/print/templates/email/letter-debtor-nd/letter-debtor-nd.js @@ -2,7 +2,6 @@ const Component = require(`vn-print/core/component`); const emailHeader = new Component('email-header'); const emailFooter = new Component('email-footer'); const attachment = new Component('attachment'); -const attachments = require('./attachments.json'); module.exports = { name: 'letter-debtor-nd', @@ -13,7 +12,15 @@ module.exports = { throw new Error('Something went wrong'); }, data() { - return {attachments}; + return { + attachments: [ + { + filename: 'letter-debtor.pdf', + type: 'pdf', + path: `Clients/${this.id}/letter-debtor-pdf` + } + ] + }; }, methods: { fetchDebtor(id, companyId) { diff --git a/print/templates/email/letter-debtor-st/attachments.json b/print/templates/email/letter-debtor-st/attachments.json deleted file mode 100644 index 1e21ea343..000000000 --- a/print/templates/email/letter-debtor-st/attachments.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "filename": "letter-debtor.pdf", - "component": "letter-debtor" - } -] \ No newline at end of file diff --git a/print/templates/email/letter-debtor-st/letter-debtor-st.js b/print/templates/email/letter-debtor-st/letter-debtor-st.js index 9f357e6de..1a6555673 100755 --- a/print/templates/email/letter-debtor-st/letter-debtor-st.js +++ b/print/templates/email/letter-debtor-st/letter-debtor-st.js @@ -2,7 +2,6 @@ const Component = require(`vn-print/core/component`); const emailHeader = new Component('email-header'); const emailFooter = new Component('email-footer'); const attachment = new Component('attachment'); -const attachments = require('./attachments.json'); module.exports = { name: 'letter-debtor-st', @@ -13,7 +12,15 @@ module.exports = { throw new Error('Something went wrong'); }, data() { - return {attachments}; + return { + attachments: [ + { + filename: 'letter-debtor.pdf', + type: 'pdf', + path: `Clients/${this.id}/letter-debtor-pdf` + } + ] + }; }, methods: { fetchDebtor(id, companyId) {