diff --git a/modules/client/back/methods/receipt/debBalancesCompEmail.js b/modules/client/back/methods/receipt/balanceCompensationEmail.js similarity index 72% rename from modules/client/back/methods/receipt/debBalancesCompEmail.js rename to modules/client/back/methods/receipt/balanceCompensationEmail.js index 569940c85..e9ded147d 100644 --- a/modules/client/back/methods/receipt/debBalancesCompEmail.js +++ b/modules/client/back/methods/receipt/balanceCompensationEmail.js @@ -1,13 +1,13 @@ const {Email} = require('vn-print'); module.exports = Self => { - Self.remoteMethodCtx('debBalancesCompEmail', { + Self.remoteMethodCtx('balanceCompensationEmail', { description: 'Sends the debit balances compensation email with an attached PDF', accessType: 'WRITE', accepts: [ { arg: 'id', - type: 'number', + type: 'Number', required: true, description: 'The receipt id', http: { source: 'path' } @@ -18,20 +18,20 @@ module.exports = Self => { root: true }, http: { - path: '/:id/deb-balances-comp-email', + path: '/:id/balance-compensation-email', verb: 'POST' } }); - Self.debBalancesCompEmail = async (ctx, id) => { + Self.balanceCompensationEmail = async (ctx, id) => { const models = Self.app.models; const receipt = await models.Receipt.findById(id, {fields: ['clientFk']}); const client = await models.Client.findById(receipt.clientFk, {fields:['email']}); - const email = new Email('deb-balances-comp', { + const email = new Email('balance-compensation', { lang: ctx.req.getLocale(), - recipient: client.name+',administracion@verdnatura.es', + recipient: client.email+',administracion@verdnatura.es', id }); diff --git a/modules/client/back/methods/receipt/debBalancesCompPdf.js b/modules/client/back/methods/receipt/balanceCompensationPdf.js similarity index 84% rename from modules/client/back/methods/receipt/debBalancesCompPdf.js rename to modules/client/back/methods/receipt/balanceCompensationPdf.js index 549c52700..ff8713253 100644 --- a/modules/client/back/methods/receipt/debBalancesCompPdf.js +++ b/modules/client/back/methods/receipt/balanceCompensationPdf.js @@ -1,7 +1,7 @@ const { Report } = require('vn-print'); module.exports = Self => { - Self.remoteMethodCtx('debBalancesCompPdf', { + Self.remoteMethodCtx('balanceCompensationPdf', { description: 'Returns the the debit balances compensation pdf', accessType: 'READ', accepts: [ @@ -29,12 +29,12 @@ module.exports = Self => { } ], http: { - path: '/:id/deb-balances-comp-pdf', + path: '/:id/balance-compensation-pdf', verb: 'GET' } }); - Self.debBalancesCompPdf = async(ctx, id) => { + Self.balanceCompensationPdf = async(ctx, id) => { const args = Object.assign({}, ctx.args); const params = {lang: ctx.req.getLocale()}; @@ -42,7 +42,7 @@ module.exports = Self => { for (const param in args) params[param] = args[param]; - const report = new Report('deb-balances-comp', params); + const report = new Report('balance-compensation', params); const stream = await report.toPdfStream(); return [stream, 'application/pdf', `filename="doc-${id}.pdf"`]; diff --git a/modules/client/back/models/receipt.js b/modules/client/back/models/receipt.js index 71753abb6..bfd71a19b 100644 --- a/modules/client/back/models/receipt.js +++ b/modules/client/back/models/receipt.js @@ -2,8 +2,8 @@ const LoopBackContext = require('loopback-context'); module.exports = function(Self) { require('../methods/receipt/filter')(Self); - require('../methods/receipt/debBalancesCompEmail')(Self); - require('../methods/receipt/debBalancesCompPdf')(Self); + require('../methods/receipt/balanceCompensationEmail')(Self); + require('../methods/receipt/balanceCompensationPdf')(Self); Self.validateBinded('amountPaid', isNotZero, { message: 'Amount cannot be zero', diff --git a/modules/client/front/balance/index/index.js b/modules/client/front/balance/index/index.js index 8ecdd2c70..b2529924f 100644 --- a/modules/client/front/balance/index/index.js +++ b/modules/client/front/balance/index/index.js @@ -2,9 +2,8 @@ import ngModule from '../../module'; import Section from 'salix/components/section'; class Controller extends Section { - constructor($element, $, vnReport, vnEmail) { + constructor($element, $, vnEmail) { super($element, $); - this.vnReport = vnReport; this.vnEmail = vnEmail; this.filter = { include: { @@ -94,11 +93,11 @@ class Controller extends Section { } sendEmail(balance) { - return this.vnEmail.send(`Receipts/${balance.id}/deb-balances-comp-email`); + return this.vnEmail.send(`Receipts/${balance.id}/balance-compensation-email`); } } -Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; +Controller.$inject = ['$element', '$scope', 'vnEmail']; ngModule.vnComponent('vnClientBalanceIndex', { template: require('./index.html'), diff --git a/print/templates/email/deb-balances-comp/assets/css/import.js b/print/templates/email/balance-compensation/assets/css/import.js similarity index 100% rename from print/templates/email/deb-balances-comp/assets/css/import.js rename to print/templates/email/balance-compensation/assets/css/import.js diff --git a/print/templates/email/balance-compensation/attachments.json b/print/templates/email/balance-compensation/attachments.json new file mode 100644 index 000000000..d2bf461c5 --- /dev/null +++ b/print/templates/email/balance-compensation/attachments.json @@ -0,0 +1,6 @@ +[ + { + "filename": "balance-compensation.pdf", + "component": "balance-compensation" + } +] \ No newline at end of file diff --git a/print/templates/email/deb-balances-comp/deb-balances-comp.html b/print/templates/email/balance-compensation/balance-compensation.html similarity index 100% rename from print/templates/email/deb-balances-comp/deb-balances-comp.html rename to print/templates/email/balance-compensation/balance-compensation.html diff --git a/print/templates/email/deb-balances-comp/deb-balances-comp.js b/print/templates/email/balance-compensation/balance-compensation.js similarity index 83% rename from print/templates/email/deb-balances-comp/deb-balances-comp.js rename to print/templates/email/balance-compensation/balance-compensation.js index 735dd1e4f..362e1b178 100755 --- a/print/templates/email/deb-balances-comp/deb-balances-comp.js +++ b/print/templates/email/balance-compensation/balance-compensation.js @@ -5,7 +5,7 @@ const attachment = new Component('attachment'); module.exports = { - name: 'deb-balances-comp', + name: 'balance-compensation', async serverPrefetch() { this.client = await this.fetchClient(this.id); }, @@ -23,9 +23,9 @@ module.exports = { return { attachments: [ { - filename: 'deb-balances-comp.pdf', + filename: 'balance-compensation.pdf', type: 'pdf', - path: `Receipts/${this.id}/deb-balances-comp-pdf` + path: `Receipts/${this.id}/balance-compensation-pdf` } ] }; diff --git a/print/templates/email/deb-balances-comp/locale/es.yml b/print/templates/email/balance-compensation/locale/es.yml similarity index 100% rename from print/templates/email/deb-balances-comp/locale/es.yml rename to print/templates/email/balance-compensation/locale/es.yml diff --git a/print/templates/email/deb-balances-comp/sql/client.sql b/print/templates/email/balance-compensation/sql/client.sql similarity index 100% rename from print/templates/email/deb-balances-comp/sql/client.sql rename to print/templates/email/balance-compensation/sql/client.sql diff --git a/print/templates/email/deb-balances-comp/attachments.json b/print/templates/email/deb-balances-comp/attachments.json deleted file mode 100644 index a8112f21a..000000000 --- a/print/templates/email/deb-balances-comp/attachments.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "filename": "deb-balances-comp.pdf", - "component": "deb-balances-comp" - } -] \ No newline at end of file diff --git a/print/templates/reports/deb-balances-comp/deb-balances-comp.html b/print/templates/reports/balance-compensation/balance-compensation.html similarity index 56% rename from print/templates/reports/deb-balances-comp/deb-balances-comp.html rename to print/templates/reports/balance-compensation/balance-compensation.html index 1e16c7d64..3291d66f4 100644 --- a/print/templates/reports/deb-balances-comp/deb-balances-comp.html +++ b/print/templates/reports/balance-compensation/balance-compensation.html @@ -13,16 +13,16 @@
Algemesí, a {{currentDate()}}
-De una parte:
-Verdnatura Levante SL con CIF B-97367486 y domicilio sito en calle Fenollar 2, Valencia.
-De la otra:
-Don/Doña {{client.name}} con NIF {{client.fi}}, y domicilio sito en {{client.street}}, {{client.city}}.
-En fecha de {{client.payed | date('%d-%m-%Y')}} se ha compensado el saldo de {{client.amountPaid}} € del cliente/proveedor {{client.name}} con el cliente/proveedor Verdnatura Levante SL.
-Por favor, rogamos confirmen la recepción de esta compensación al email administracion@verdnatura.es
-{{$t('Place')}} {{currentDate()}}
+{{$t('In one hand')}}:
+{{company.name}} {{$t('CIF')}} {{company.nif}} {{$t('Home')}} {{company.street}}, {{company.city}}.
+{{$t('In other hand')}}:
+{{$t('Sr')}} {{client.name}} {{$t('NIF')}} {{client.fi}} {{$t('Home')}} {{client.street}}, {{client.city}}.
+{{$t('Date')}} {{client.payed | date('%d-%m-%Y')}} {{$t('Compensate')}} {{client.amountPaid}} € {{$t('From client')}} {{client.name}} {{$t('To client')}} {{company.name}}.
+{{$t('Reception')}} administracion@verdnatura.es
+