diff --git a/db/changes/10490-august/00-ACL.sql b/db/changes/10490-august/00-ACL.sql index 29277e8bb..b32a87a5a 100644 --- a/db/changes/10490-august/00-ACL.sql +++ b/db/changes/10490-august/00-ACL.sql @@ -2,20 +2,22 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp VALUES ('ClientConsumptionQueue', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Ticket', 'deliveryNotePdf', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('Ticket', 'deliveryNoteEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Ticket', 'deliveryNoteEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'campaignMetricsPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('Client', 'campaignMetricsEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'campaignMetricsEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'clientWelcomeHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('Client', 'clientWelcomeEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'clientWelcomeEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),, + ('Client', 'creditRequestHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'creditRequestEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'printerSetupHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('Client', 'printerSetupEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('Client', 'sepaCoreEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'printerSetupEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'sepaCoreEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'letterDebtorStHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('Client', 'letterDebtorStEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'letterDebtorStEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'letterDebtorNdHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('Client', 'letterDebtorNdEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'letterDebtorNdEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'clientDebtStatementHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('Client', 'clientDebtStatementEmail', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Client', 'clientDebtStatementEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'incotermsAuthorizationHtml', 'READ', 'ALLOW', 'ROLE', 'employee'), ('Client', 'incotermsAuthorizationEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Client', 'consumptionSendQueued', 'WRITE', 'ALLOW', 'ROLE', 'system'), @@ -28,7 +30,9 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp ('Travel', 'extraCommunityEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'), ('Entry', 'entryOrderPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), ('OsTicket', 'osTicketReportEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'), - ('Item', 'buyerWasteEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'); + ('Item', 'buyerWasteEmail', 'WRITE', 'ALLOW', 'ROLE', 'system'), + ('Claim', 'claimPickupPdf', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Claim', 'claimPickupEmail', 'WRITE', 'ALLOW', 'ROLE', 'claimManager'); INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) VALUES ('Sector','*','READ','ALLOW','ROLE','employee'); diff --git a/db/changes/10490-august/00-sample.sql b/db/changes/10490-august/00-sample.sql index e9dd9e9a0..f84cd723e 100644 --- a/db/changes/10490-august/00-sample.sql +++ b/db/changes/10490-august/00-sample.sql @@ -3,4 +3,4 @@ alter table `vn`.`sample` UPDATE vn.sample t SET t.model = 'Clients' - WHERE t.id IN(13, 14, 15, 16, 18, 19, 20); \ No newline at end of file + WHERE t.id IN(12, 13, 14, 15, 16, 18, 19, 20); \ No newline at end of file diff --git a/modules/claim/front/descriptor/index.html b/modules/claim/front/descriptor/index.html index 96d0882e6..0bbacf94b 100644 --- a/modules/claim/front/descriptor/index.html +++ b/modules/claim/front/descriptor/index.html @@ -5,8 +5,6 @@ Show Pickup order diff --git a/modules/client/back/methods/client/campaignMetricsEmail.js b/modules/client/back/methods/client/campaignMetricsEmail.js index fab90fbe0..bb57f90a0 100644 --- a/modules/client/back/methods/client/campaignMetricsEmail.js +++ b/modules/client/back/methods/client/campaignMetricsEmail.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('campaignMetricsEmail', { description: 'Sends the campaign metrics email with an attached PDF', + accessType: 'WRITE', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/campaignMetricsPdf.js b/modules/client/back/methods/client/campaignMetricsPdf.js index a6afa95a3..14194d62b 100644 --- a/modules/client/back/methods/client/campaignMetricsPdf.js +++ b/modules/client/back/methods/client/campaignMetricsPdf.js @@ -3,6 +3,7 @@ const {Report} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('campaignMetricsPdf', { description: 'Returns the campaign metrics pdf', + accessType: 'READ', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/clientDebtStatementEmail.js b/modules/client/back/methods/client/clientDebtStatementEmail.js index 0b34598b7..8bcdc900f 100644 --- a/modules/client/back/methods/client/clientDebtStatementEmail.js +++ b/modules/client/back/methods/client/clientDebtStatementEmail.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('clientDebtStatementEmail', { description: 'Sends the client debt statement email with an attached PDF', + accessType: 'WRITE', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/clientDebtStatementHtml.js b/modules/client/back/methods/client/clientDebtStatementHtml.js index 79455f4c4..76502ff6c 100644 --- a/modules/client/back/methods/client/clientDebtStatementHtml.js +++ b/modules/client/back/methods/client/clientDebtStatementHtml.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('clientDebtStatementHtml', { description: 'Returns the client debt statement email preview', + accessType: 'READ', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/clientWelcomeEmail.js b/modules/client/back/methods/client/clientWelcomeEmail.js index aee4f9296..318ee18e6 100644 --- a/modules/client/back/methods/client/clientWelcomeEmail.js +++ b/modules/client/back/methods/client/clientWelcomeEmail.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('clientWelcomeEmail', { description: 'Sends the client welcome email with an attached PDF', + accessType: 'WRITE', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/clientWelcomeHtml.js b/modules/client/back/methods/client/clientWelcomeHtml.js index a54857e57..dfb560326 100644 --- a/modules/client/back/methods/client/clientWelcomeHtml.js +++ b/modules/client/back/methods/client/clientWelcomeHtml.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('clientWelcomeHtml', { description: 'Returns the client welcome email preview', + accessType: 'READ', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/creditRequestEmail.js b/modules/client/back/methods/client/creditRequestEmail.js index d6e6e69ea..b6a60e971 100644 --- a/modules/client/back/methods/client/creditRequestEmail.js +++ b/modules/client/back/methods/client/creditRequestEmail.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('clientCreditEmail', { description: 'Sends the credit request email with an attached PDF', + accessType: 'WRITE', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/creditRequestHtml.js b/modules/client/back/methods/client/creditRequestHtml.js index 2a7820c14..303308615 100644 --- a/modules/client/back/methods/client/creditRequestHtml.js +++ b/modules/client/back/methods/client/creditRequestHtml.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('creditRequestHtml', { description: 'Returns the credit request email preview', + accessType: 'READ', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/letterDebtorNdEmail.js b/modules/client/back/methods/client/letterDebtorNdEmail.js index 3d03a8ab0..e188c6e0a 100644 --- a/modules/client/back/methods/client/letterDebtorNdEmail.js +++ b/modules/client/back/methods/client/letterDebtorNdEmail.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('letterDebtorNdEmail', { description: 'Sends the second debtor letter email with an attached PDF', + accessType: 'WRITE', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/letterDebtorNdHtml.js b/modules/client/back/methods/client/letterDebtorNdHtml.js index d57e8edc5..d709a3cee 100644 --- a/modules/client/back/methods/client/letterDebtorNdHtml.js +++ b/modules/client/back/methods/client/letterDebtorNdHtml.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('letterDebtorNdHtml', { description: 'Returns the second letter debtor email preview', + accessType: 'READ', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/letterDebtorStEmail.js b/modules/client/back/methods/client/letterDebtorStEmail.js index bec260cb0..ee39a101b 100644 --- a/modules/client/back/methods/client/letterDebtorStEmail.js +++ b/modules/client/back/methods/client/letterDebtorStEmail.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('letterDebtorStEmail', { description: 'Sends the printer setup email with an attached PDF', + accessType: 'WRITE', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/letterDebtorStHtml.js b/modules/client/back/methods/client/letterDebtorStHtml.js index 68f8f5056..b97ce9767 100644 --- a/modules/client/back/methods/client/letterDebtorStHtml.js +++ b/modules/client/back/methods/client/letterDebtorStHtml.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('letterDebtorStHtml', { description: 'Returns the letter debtor email preview', + accessType: 'READ', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/printerSetupEmail.js b/modules/client/back/methods/client/printerSetupEmail.js index df4864dda..254948659 100644 --- a/modules/client/back/methods/client/printerSetupEmail.js +++ b/modules/client/back/methods/client/printerSetupEmail.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('printerSetupEmail', { description: 'Sends the printer setup email with an attached PDF', + accessType: 'WRITE', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/printerSetupHtml.js b/modules/client/back/methods/client/printerSetupHtml.js index 37e318723..1ef1843e0 100644 --- a/modules/client/back/methods/client/printerSetupHtml.js +++ b/modules/client/back/methods/client/printerSetupHtml.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('printerSetupHtml', { description: 'Returns the printer setup email preview', + accessType: 'READ', accepts: [ { arg: 'id', diff --git a/modules/client/back/methods/client/sepaCoreEmail.js b/modules/client/back/methods/client/sepaCoreEmail.js index 47e0be132..93c9d4302 100644 --- a/modules/client/back/methods/client/sepaCoreEmail.js +++ b/modules/client/back/methods/client/sepaCoreEmail.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('sepaCoreEmail', { description: 'Sends the campaign metrics email with an attached PDF', + accessType: 'WRITE', accepts: [ { arg: 'id', diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 3f6853c55..3bd89eff1 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -1,4 +1,3 @@ -const got = require('got'); const UserError = require('vn-loopback/util/user-error'); const getFinalState = require('vn-loopback/util/hook').getFinalState; const isMultiple = require('vn-loopback/util/hook').isMultiple; @@ -292,23 +291,22 @@ module.exports = Self => { const $t = httpRequest.__; const headers = httpRequest.headers; const origin = headers.origin; - const authorization = headers.authorization; const salesPersonId = instance.salesPersonFk; if (salesPersonId) { // Send email to client if (instance.email) { + const {Email} = require('vn-print'); const worker = await models.EmailUser.findById(salesPersonId); const params = { - authorization: authorization, + id: instance.id, recipientId: instance.id, recipient: instance.email, replyTo: worker.email }; - await got.get(`${origin}/api/email/payment-update`, { - searchParams: params - }); + const email = new Email('payment-update', params); + await email.send(); } const fullUrl = `${origin}/#!/client/${instance.id}/billing-data`; diff --git a/modules/ticket/back/methods/ticket/deliveryNoteEmail.js b/modules/ticket/back/methods/ticket/deliveryNoteEmail.js index b15783e1b..cf9f5dd62 100644 --- a/modules/ticket/back/methods/ticket/deliveryNoteEmail.js +++ b/modules/ticket/back/methods/ticket/deliveryNoteEmail.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('deliveryNoteEmail', { description: 'Sends the delivery note email with an attached PDF', + accessType: 'WRITE', accepts: [ { arg: 'id', diff --git a/modules/ticket/back/methods/ticket/deliveryNotePdf.js b/modules/ticket/back/methods/ticket/deliveryNotePdf.js index 3f6af8359..b2b3f7198 100644 --- a/modules/ticket/back/methods/ticket/deliveryNotePdf.js +++ b/modules/ticket/back/methods/ticket/deliveryNotePdf.js @@ -3,6 +3,7 @@ const {Report} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('deliveryNotePdf', { description: 'Returns the delivery note pdf', + accessType: 'READ', accepts: [ { arg: 'id', diff --git a/print/core/smtp.js b/print/core/smtp.js index 50a413673..a55ba448d 100644 --- a/print/core/smtp.js +++ b/print/core/smtp.js @@ -29,7 +29,7 @@ module.exports = { for (let attachment of options.attachments) { const fileName = attachment.filename; const filePath = attachment.path; - if (fileName.includes('.png')) return; + if (fileName.includes('.png')) continue; if (fileName || filePath) attachments.push(filePath ? filePath : fileName); diff --git a/print/templates/email/payment-update/assets/css/import.js b/print/templates/email/payment-update/assets/css/import.js index b44d6bd37..1582b82c5 100644 --- a/print/templates/email/payment-update/assets/css/import.js +++ b/print/templates/email/payment-update/assets/css/import.js @@ -1,8 +1,12 @@ -const Stylesheet = require(`${appPath}/core/stylesheet`); +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); module.exports = new Stylesheet([ - `${appPath}/common/css/spacing.css`, - `${appPath}/common/css/misc.css`, - `${appPath}/common/css/layout.css`, - `${appPath}/common/css/email.css`]) + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/email.css`]) .mergeStyles(); + diff --git a/print/templates/email/payment-update/payment-update.js b/print/templates/email/payment-update/payment-update.js index 2b92976a3..a9d99d4ef 100755 --- a/print/templates/email/payment-update/payment-update.js +++ b/print/templates/email/payment-update/payment-update.js @@ -1,11 +1,11 @@ -const Component = require(`${appPath}/core/component`); +const Component = require(`vn-print/core/component`); const emailHeader = new Component('email-header'); const emailFooter = new Component('email-footer'); module.exports = { name: 'payment-update', async serverPrefetch() { - this.payMethod = await this.fetchPayMethod(this.recipientId); + this.payMethod = await this.fetchPayMethod(this.id); if (!this.payMethod) throw new Error('Something went wrong'); @@ -16,8 +16,8 @@ module.exports = { }, }, methods: { - fetchPayMethod(clientId) { - return this.findOneFromDef('payMethod', [clientId]); + fetchPayMethod(id) { + return this.findOneFromDef('payMethod', [id]); } }, components: { @@ -25,9 +25,10 @@ module.exports = { 'email-footer': emailFooter.build() }, props: { - recipientId: { + id: { type: [Number, String], - required: true + required: true, + description: 'The client id' } } }; diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.html b/print/templates/reports/claim-pickup-order/claim-pickup-order.html index 1f6db4966..6764344b5 100644 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.html +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.html @@ -17,7 +17,7 @@ {{$t('claimId')}} - {{claimId}} + {{id}} {{$t('clientId')}} @@ -85,7 +85,7 @@