From 1246a65f3282d4d273fa0112ef09fa6b6f6bae4b Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 28 Oct 2022 14:49:22 +0200 Subject: [PATCH 1/6] refs #4547 informe y email generados --- .../methods/receipt/debBalancesCompEmail.js | 40 ++++ .../methods/receipt/debBalancesCompPdf.js | 50 ++++ modules/client/back/models/receipt.js | 2 + modules/client/front/balance/index/index.html | 215 ++++++++---------- modules/client/front/balance/index/index.js | 27 ++- .../client/front/balance/index/locale/es.yml | 1 + .../deb-balances-comp/assets/css/import.js | 11 + .../email/deb-balances-comp/attachments.json | 6 + .../deb-balances-comp/deb-balances-comp.html | 57 +++++ .../deb-balances-comp/deb-balances-comp.js | 39 ++++ .../email/deb-balances-comp/locale/es.yml | 6 + .../email/deb-balances-comp/sql/client.sql | 5 + .../reports/deb-balances-comp/css/import.js | 12 + .../deb-balances-comp/deb-balances-comp.html | 41 ++++ .../deb-balances-comp/deb-balances-comp.js | 35 +++ .../reports/deb-balances-comp/locale/es.yml | 1 + .../reports/deb-balances-comp/sql/client.sql | 12 + 17 files changed, 424 insertions(+), 136 deletions(-) create mode 100644 modules/client/back/methods/receipt/debBalancesCompEmail.js create mode 100644 modules/client/back/methods/receipt/debBalancesCompPdf.js create mode 100644 print/templates/email/deb-balances-comp/assets/css/import.js create mode 100644 print/templates/email/deb-balances-comp/attachments.json create mode 100644 print/templates/email/deb-balances-comp/deb-balances-comp.html create mode 100755 print/templates/email/deb-balances-comp/deb-balances-comp.js create mode 100644 print/templates/email/deb-balances-comp/locale/es.yml create mode 100644 print/templates/email/deb-balances-comp/sql/client.sql create mode 100644 print/templates/reports/deb-balances-comp/css/import.js create mode 100644 print/templates/reports/deb-balances-comp/deb-balances-comp.html create mode 100644 print/templates/reports/deb-balances-comp/deb-balances-comp.js create mode 100644 print/templates/reports/deb-balances-comp/locale/es.yml create mode 100644 print/templates/reports/deb-balances-comp/sql/client.sql diff --git a/modules/client/back/methods/receipt/debBalancesCompEmail.js b/modules/client/back/methods/receipt/debBalancesCompEmail.js new file mode 100644 index 000000000..569940c85 --- /dev/null +++ b/modules/client/back/methods/receipt/debBalancesCompEmail.js @@ -0,0 +1,40 @@ +const {Email} = require('vn-print'); + +module.exports = Self => { + Self.remoteMethodCtx('debBalancesCompEmail', { + description: 'Sends the debit balances compensation email with an attached PDF', + accessType: 'WRITE', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The receipt id', + http: { source: 'path' } + } + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: '/:id/deb-balances-comp-email', + verb: 'POST' + } + }); + + Self.debBalancesCompEmail = 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', { + lang: ctx.req.getLocale(), + recipient: client.name+',administracion@verdnatura.es', + id + }); + + return email.send(); + }; +}; diff --git a/modules/client/back/methods/receipt/debBalancesCompPdf.js b/modules/client/back/methods/receipt/debBalancesCompPdf.js new file mode 100644 index 000000000..549c52700 --- /dev/null +++ b/modules/client/back/methods/receipt/debBalancesCompPdf.js @@ -0,0 +1,50 @@ +const { Report } = require('vn-print'); + +module.exports = Self => { + Self.remoteMethodCtx('debBalancesCompPdf', { + description: 'Returns the the debit balances compensation pdf', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The receipt id', + http: { source: 'path' } + } + ], + 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/deb-balances-comp-pdf', + verb: 'GET' + } + }); + + Self.debBalancesCompPdf = 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('deb-balances-comp', 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 36a4a8952..71753abb6 100644 --- a/modules/client/back/models/receipt.js +++ b/modules/client/back/models/receipt.js @@ -2,6 +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); Self.validateBinded('amountPaid', isNotZero, { message: 'Amount cannot be zero', diff --git a/modules/client/front/balance/index/index.html b/modules/client/front/balance/index/index.html index 3c61d8543..19db55f1a 100644 --- a/modules/client/front/balance/index/index.html +++ b/modules/client/front/balance/index/index.html @@ -1,40 +1,17 @@ - + - + - +
- + -
+
Total by company
-
@@ -43,108 +20,94 @@
- - - - Date - Creation date - Employee - Reference - Bank - Debit - Havings - Balance - Conciliated - - - - - - - - {{::balance.payed | date:'dd/MM/yyyy'}} - - - - - {{::balance.created | date:'dd/MM/yyyy HH:mm'}} - - - - - {{::balance.userName}} - - - - -
- - {{'BILL' | translate: {ref: balance.description} }} - - - {{balance.description}} - -
-
- - - - -
- {{::balance.bankFk}} - {{::balance.debit | currency: 'EUR':2}} - {{::balance.credit | currency: 'EUR':2}} - {{balance.balance | currency: 'EUR':2}} - - - - - - - + + + + Date + Creation date + Employee + Reference + Bank + Debit + Havings + Balance + Conciliated + + + + + + + + {{::balance.payed | date:'dd/MM/yyyy'}} + + + + + {{::balance.created | date:'dd/MM/yyyy HH:mm'}} + + + + + {{::balance.userName}} + + + + +
+ + {{'BILL' | translate: {ref: balance.description} }} + + + {{balance.description}} + +
+
+ + + + +
+ {{::balance.bankFk}} + {{::balance.debit | currency: 'EUR':2}} + {{::balance.credit | currency: 'EUR':2}} + {{balance.balance | currency: 'EUR':2}} + + + + + +
+ + + +
+ + - - -
-
-
+ + + + + +
- + - - + - + \ No newline at end of file diff --git a/modules/client/front/balance/index/index.js b/modules/client/front/balance/index/index.js index 7e09e018c..103186e09 100644 --- a/modules/client/front/balance/index/index.js +++ b/modules/client/front/balance/index/index.js @@ -2,8 +2,10 @@ import ngModule from '../../module'; import Section from 'salix/components/section'; class Controller extends Section { - constructor($element, $) { + constructor($element, $, vnReport, vnEmail) { super($element, $); + this.vnReport = vnReport; + this.vnEmail = vnEmail; this.filter = { include: { relation: 'company', @@ -43,6 +45,7 @@ class Controller extends Section { return this.aclService.hasAny(['administrative']); } + getData() { return this.$.model.applyFilter(null, { clientId: this.$params.id, @@ -54,45 +57,49 @@ class Controller extends Section { } })).then(() => this.getBalances()); } - + getCurrentBalance() { const clientRisks = this.$.riskModel.data; const selectedCompany = this.companyId; const currentBalance = clientRisks.find(balance => { return balance.companyFk === selectedCompany; }); - + return currentBalance && currentBalance.amount; } - + getBalances() { const balances = this.$.model.data; balances.forEach((balance, index) => { if (index === 0) - balance.balance = this.getCurrentBalance(); + balance.balance = this.getCurrentBalance(); if (index > 0) { let previousBalance = balances[index - 1]; balance.balance = previousBalance.balance - (previousBalance.debit - previousBalance.credit); } }); } - + showInvoiceOutDescriptor(event, balance) { if (!balance.isInvoice) return; if (event.defaultPrevented) return; - + this.$.invoiceOutDescriptor.show(event.target, balance.id); } - + changeDescription(balance) { const params = {description: balance.description}; const endpoint = `Receipts/${balance.id}`; this.$http.patch(endpoint, params) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); + .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); + } + + sendEmail(balance) { + return this.vnEmail.send(`Receipts/${balance.id}/deb-balances-comp-email`); } } -Controller.$inject = ['$element', '$scope']; +Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; ngModule.vnComponent('vnClientBalanceIndex', { template: require('./index.html'), diff --git a/modules/client/front/balance/index/locale/es.yml b/modules/client/front/balance/index/locale/es.yml index 05ef7070a..4ddf26153 100644 --- a/modules/client/front/balance/index/locale/es.yml +++ b/modules/client/front/balance/index/locale/es.yml @@ -8,4 +8,5 @@ Havings: Haber Balance: Balance Total by company: Total por empresa Download PDF: Descargar PDF +Send compensation: Enviar compensación BILL: N/FRA {{ref}} \ No newline at end of file diff --git a/print/templates/email/deb-balances-comp/assets/css/import.js b/print/templates/email/deb-balances-comp/assets/css/import.js new file mode 100644 index 000000000..4b4bb7086 --- /dev/null +++ b/print/templates/email/deb-balances-comp/assets/css/import.js @@ -0,0 +1,11 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${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/deb-balances-comp/attachments.json b/print/templates/email/deb-balances-comp/attachments.json new file mode 100644 index 000000000..a8112f21a --- /dev/null +++ b/print/templates/email/deb-balances-comp/attachments.json @@ -0,0 +1,6 @@ +[ + { + "filename": "deb-balances-comp.pdf", + "component": "deb-balances-comp" + } +] \ No newline at end of file diff --git a/print/templates/email/deb-balances-comp/deb-balances-comp.html b/print/templates/email/deb-balances-comp/deb-balances-comp.html new file mode 100644 index 000000000..c7388a7a3 --- /dev/null +++ b/print/templates/email/deb-balances-comp/deb-balances-comp.html @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + +
+ +
+
+
+ +
+
+ +
+
+ +
+
+

{{$t('description.instructions')}} {{client.name}}

+

{{$t('description.attached')}}

+

{{$t('description.response')}}

+

{{$t('description.regards')}}

+
+
+ +
+
+ + +
+
+ +
+
+ +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/print/templates/email/deb-balances-comp/deb-balances-comp.js b/print/templates/email/deb-balances-comp/deb-balances-comp.js new file mode 100755 index 000000000..735dd1e4f --- /dev/null +++ b/print/templates/email/deb-balances-comp/deb-balances-comp.js @@ -0,0 +1,39 @@ +const Component = require(`vn-print/core/component`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); +const attachment = new Component('attachment'); + + +module.exports = { + name: 'deb-balances-comp', + async serverPrefetch() { + this.client = await this.fetchClient(this.id); + }, + methods: { + fetchClient(id) { + return this.findOneFromDef('client', [id]); + }, + }, + components: { + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build(), + 'attachment': attachment.build() + }, + data() { + return { + attachments: [ + { + filename: 'deb-balances-comp.pdf', + type: 'pdf', + path: `Receipts/${this.id}/deb-balances-comp-pdf` + } + ] + }; + }, + props: { + id: { + type: Number, + required: true + } + } +}; diff --git a/print/templates/email/deb-balances-comp/locale/es.yml b/print/templates/email/deb-balances-comp/locale/es.yml new file mode 100644 index 000000000..44253bee2 --- /dev/null +++ b/print/templates/email/deb-balances-comp/locale/es.yml @@ -0,0 +1,6 @@ +subject: Compensación VerdNatura SL +description: + instructions: Buenos días, + attached: Adjuntamos escrito para su confirmación + response: Rogamos su respuesta a la mayor brevedad + regards: Un saludo \ No newline at end of file diff --git a/print/templates/email/deb-balances-comp/sql/client.sql b/print/templates/email/deb-balances-comp/sql/client.sql new file mode 100644 index 000000000..1e842d69d --- /dev/null +++ b/print/templates/email/deb-balances-comp/sql/client.sql @@ -0,0 +1,5 @@ +SELECT + c.name +FROM client c + JOIN receipt r ON r.clientFk = c.id +WHERE r.id = ?; \ No newline at end of file diff --git a/print/templates/reports/deb-balances-comp/css/import.js b/print/templates/reports/deb-balances-comp/css/import.js new file mode 100644 index 000000000..37a98dfdd --- /dev/null +++ b/print/templates/reports/deb-balances-comp/css/import.js @@ -0,0 +1,12 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/deb-balances-comp/deb-balances-comp.html b/print/templates/reports/deb-balances-comp/deb-balances-comp.html new file mode 100644 index 000000000..1e16c7d64 --- /dev/null +++ b/print/templates/reports/deb-balances-comp/deb-balances-comp.html @@ -0,0 +1,41 @@ + + + + + + + + + + +
+ + + +
+
+
+
+

Algemesí, a {{currentDate()}}

+

{{'Compensación de saldos deudores y acreedores' | uppercase}}

+

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}}.

+

{{'Acuerdan' | uppercase}}

+

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

+
Saludos cordiales,
+
+
+
+ +
+ + + +
+ + + \ No newline at end of file diff --git a/print/templates/reports/deb-balances-comp/deb-balances-comp.js b/print/templates/reports/deb-balances-comp/deb-balances-comp.js new file mode 100644 index 000000000..aab343572 --- /dev/null +++ b/print/templates/reports/deb-balances-comp/deb-balances-comp.js @@ -0,0 +1,35 @@ +const config = require(`vn-print/core/config`); +const Component = require(`vn-print/core/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); +const md5 = require('md5'); +const fs = require('fs-extra'); + +module.exports = { + name: 'deb-balances-comp', + async serverPrefetch() { + this.client = await this.fetchClient(this.id); + }, + methods: { + fetchClient(id) { + return this.findOneFromDef('client', [id]); + }, + + currentDate() { + const current = new Date(); + const date = `${current.getDate()}/${current.getMonth()+1}/${current.getFullYear()}`; + return date; + } + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() + }, + props: { + id: { + type: [Number, String], + required: true, + description: 'The receipt id' + } + } +}; diff --git a/print/templates/reports/deb-balances-comp/locale/es.yml b/print/templates/reports/deb-balances-comp/locale/es.yml new file mode 100644 index 000000000..6ababaa12 --- /dev/null +++ b/print/templates/reports/deb-balances-comp/locale/es.yml @@ -0,0 +1 @@ +reportName: compensacion-saldo \ No newline at end of file diff --git a/print/templates/reports/deb-balances-comp/sql/client.sql b/print/templates/reports/deb-balances-comp/sql/client.sql new file mode 100644 index 000000000..b1b5f162e --- /dev/null +++ b/print/templates/reports/deb-balances-comp/sql/client.sql @@ -0,0 +1,12 @@ +SELECT + c.name, + c.socialName, + c.street, + c.fi, + c.city, + r.amountPaid, + r.payed +FROM client c +JOIN receipt r ON r.clientFk = c.id +JOIN supplier s ON c.fi = s.nif +WHERE r.id = ?; \ No newline at end of file From 8d8d217fe76e5bd769c12bc6bbad93eba61305e6 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 2 Nov 2022 13:59:13 +0100 Subject: [PATCH 2/6] refs #4547 formateo arreglado --- modules/client/front/balance/index/index.html | 210 +++++++++++------- modules/client/front/balance/index/index.js | 1 - 2 files changed, 130 insertions(+), 81 deletions(-) diff --git a/modules/client/front/balance/index/index.html b/modules/client/front/balance/index/index.html index 19db55f1a..b505d5ab5 100644 --- a/modules/client/front/balance/index/index.html +++ b/modules/client/front/balance/index/index.html @@ -1,17 +1,40 @@ - + - + - +
- + -
+
Total by company
-
@@ -20,78 +43,94 @@
- - - - Date - Creation date - Employee - Reference - Bank - Debit - Havings - Balance - Conciliated - - - - - - - - {{::balance.payed | date:'dd/MM/yyyy'}} - - - - - {{::balance.created | date:'dd/MM/yyyy HH:mm'}} - - - - - {{::balance.userName}} - - - - -
- - {{'BILL' | translate: {ref: balance.description} }} - - - {{balance.description}} - -
-
- - - - -
- {{::balance.bankFk}} - {{::balance.debit | currency: 'EUR':2}} - {{::balance.credit | currency: 'EUR':2}} - {{balance.balance | currency: 'EUR':2}} - - - - - - - - - - + + + + Date + Creation date + Employee + Reference + Bank + Debit + Havings + Balance + Conciliated + + + + + + + + {{::balance.payed | date:'dd/MM/yyyy'}} + + + + + {{::balance.created | date:'dd/MM/yyyy HH:mm'}} + + + + + {{::balance.userName}} + + + + +
+ + {{'BILL' | translate: {ref: balance.description} }} + + + {{balance.description}} + +
+
+ + + + +
+ {{::balance.bankFk}} + {{::balance.debit | currency: 'EUR':2}} + {{::balance.credit | currency: 'EUR':2}} + {{balance.balance | currency: 'EUR':2}} + + + + + + + + + + - - @@ -101,13 +140,24 @@
- + - - + - + \ No newline at end of file diff --git a/modules/client/front/balance/index/index.js b/modules/client/front/balance/index/index.js index 103186e09..8ecdd2c70 100644 --- a/modules/client/front/balance/index/index.js +++ b/modules/client/front/balance/index/index.js @@ -45,7 +45,6 @@ class Controller extends Section { return this.aclService.hasAny(['administrative']); } - getData() { return this.$.model.applyFilter(null, { clientId: this.$params.id, From 908908a643ee0c9eca72bde25ec678dd6f76a358 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 2 Nov 2022 15:54:23 +0100 Subject: [PATCH 3/6] refs #4547 correcciones --- ...mpEmail.js => balanceCompensationEmail.js} | 12 +++++------ ...esCompPdf.js => balanceCompensationPdf.js} | 8 ++++---- modules/client/back/models/receipt.js | 4 ++-- modules/client/front/balance/index/index.js | 7 +++---- .../assets/css/import.js | 0 .../balance-compensation/attachments.json | 6 ++++++ .../balance-compensation.html} | 0 .../balance-compensation.js} | 6 +++--- .../locale/es.yml | 0 .../sql/client.sql | 0 .../email/deb-balances-comp/attachments.json | 6 ------ .../balance-compensation.html} | 20 +++++++++---------- .../balance-compensation.js} | 11 +++++----- .../css/import.js | 0 .../balance-compensation/locale/es.yml | 16 +++++++++++++++ .../sql/client.sql | 4 ++-- .../balance-compensation/sql/company.sql | 7 +++++++ .../reports/deb-balances-comp/locale/es.yml | 1 - 18 files changed, 65 insertions(+), 43 deletions(-) rename modules/client/back/methods/receipt/{debBalancesCompEmail.js => balanceCompensationEmail.js} (72%) rename modules/client/back/methods/receipt/{debBalancesCompPdf.js => balanceCompensationPdf.js} (84%) rename print/templates/email/{deb-balances-comp => balance-compensation}/assets/css/import.js (100%) create mode 100644 print/templates/email/balance-compensation/attachments.json rename print/templates/email/{deb-balances-comp/deb-balances-comp.html => balance-compensation/balance-compensation.html} (100%) rename print/templates/email/{deb-balances-comp/deb-balances-comp.js => balance-compensation/balance-compensation.js} (83%) rename print/templates/email/{deb-balances-comp => balance-compensation}/locale/es.yml (100%) rename print/templates/email/{deb-balances-comp => balance-compensation}/sql/client.sql (100%) delete mode 100644 print/templates/email/deb-balances-comp/attachments.json rename print/templates/reports/{deb-balances-comp/deb-balances-comp.html => balance-compensation/balance-compensation.html} (56%) rename print/templates/reports/{deb-balances-comp/deb-balances-comp.js => balance-compensation/balance-compensation.js} (80%) rename print/templates/reports/{deb-balances-comp => balance-compensation}/css/import.js (100%) create mode 100644 print/templates/reports/balance-compensation/locale/es.yml rename print/templates/reports/{deb-balances-comp => balance-compensation}/sql/client.sql (59%) create mode 100644 print/templates/reports/balance-compensation/sql/company.sql delete mode 100644 print/templates/reports/deb-balances-comp/locale/es.yml 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()}}

-

{{'Compensación de saldos deudores y acreedores' | uppercase}}

-

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}}.

-

{{'Acuerdan' | uppercase}}

-

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

-
Saludos cordiales,
+

{{$t('Place')}} {{currentDate()}}

+

{{$t('Compensation') | uppercase}}

+

{{$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('Agree') | uppercase}}

+

{{$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

+
{{$t('Greetings')}}
diff --git a/print/templates/reports/deb-balances-comp/deb-balances-comp.js b/print/templates/reports/balance-compensation/balance-compensation.js similarity index 80% rename from print/templates/reports/deb-balances-comp/deb-balances-comp.js rename to print/templates/reports/balance-compensation/balance-compensation.js index aab343572..b1d61e1c5 100644 --- a/print/templates/reports/deb-balances-comp/deb-balances-comp.js +++ b/print/templates/reports/balance-compensation/balance-compensation.js @@ -1,19 +1,20 @@ -const config = require(`vn-print/core/config`); const Component = require(`vn-print/core/component`); const reportHeader = new Component('report-header'); const reportFooter = new Component('report-footer'); -const md5 = require('md5'); -const fs = require('fs-extra'); module.exports = { - name: 'deb-balances-comp', + name: 'balance-compensation', async serverPrefetch() { this.client = await this.fetchClient(this.id); + this.company = await this.fetchCompany(); }, methods: { fetchClient(id) { return this.findOneFromDef('client', [id]); }, + fetchCompany() { + return this.findOneFromDef('company'); + }, currentDate() { const current = new Date(); @@ -27,7 +28,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The receipt id' } diff --git a/print/templates/reports/deb-balances-comp/css/import.js b/print/templates/reports/balance-compensation/css/import.js similarity index 100% rename from print/templates/reports/deb-balances-comp/css/import.js rename to print/templates/reports/balance-compensation/css/import.js diff --git a/print/templates/reports/balance-compensation/locale/es.yml b/print/templates/reports/balance-compensation/locale/es.yml new file mode 100644 index 000000000..546e55f06 --- /dev/null +++ b/print/templates/reports/balance-compensation/locale/es.yml @@ -0,0 +1,16 @@ +reportName: compensacion-saldo +Place: Algemesí, a +Compensation: Compensación de saldos deudores y acreedores +In one hand: De una parte +CIF: con CIF +NIF: con NIF +Home: y domicilio sito en +In other hand: De la otra +Sr: Don/Doña +Agree: Acuerdan +Date: En fecha de +Compensate: se ha compensado el saldo de +From client: del cliente/proveedor +To client: con el cliente/proveedor +Reception: Por favor, rogamos confirmen la recepción de esta compensación al email +Greetings: Saludos cordiales, \ No newline at end of file diff --git a/print/templates/reports/deb-balances-comp/sql/client.sql b/print/templates/reports/balance-compensation/sql/client.sql similarity index 59% rename from print/templates/reports/deb-balances-comp/sql/client.sql rename to print/templates/reports/balance-compensation/sql/client.sql index b1b5f162e..5354fd095 100644 --- a/print/templates/reports/deb-balances-comp/sql/client.sql +++ b/print/templates/reports/balance-compensation/sql/client.sql @@ -7,6 +7,6 @@ SELECT r.amountPaid, r.payed FROM client c -JOIN receipt r ON r.clientFk = c.id -JOIN supplier s ON c.fi = s.nif + JOIN receipt r ON r.clientFk = c.id + JOIN supplier s ON c.fi = s.nif WHERE r.id = ?; \ No newline at end of file diff --git a/print/templates/reports/balance-compensation/sql/company.sql b/print/templates/reports/balance-compensation/sql/company.sql new file mode 100644 index 000000000..b22d53659 --- /dev/null +++ b/print/templates/reports/balance-compensation/sql/company.sql @@ -0,0 +1,7 @@ +SELECT + s.name, + s.nif, + s.street, + s.city +FROM supplier s +WHERE s.id = 442; \ No newline at end of file diff --git a/print/templates/reports/deb-balances-comp/locale/es.yml b/print/templates/reports/deb-balances-comp/locale/es.yml deleted file mode 100644 index 6ababaa12..000000000 --- a/print/templates/reports/deb-balances-comp/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -reportName: compensacion-saldo \ No newline at end of file From 84eb87e02a6c867a69a2767dede934faa55e80e1 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 3 Nov 2022 08:08:24 +0100 Subject: [PATCH 4/6] refs #4547 cambios sql --- .../balance-compensation/balance-compensation.js | 6 +++--- .../reports/balance-compensation/sql/client.sql | 4 ++-- .../reports/balance-compensation/sql/company.sql | 13 +++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/print/templates/reports/balance-compensation/balance-compensation.js b/print/templates/reports/balance-compensation/balance-compensation.js index b1d61e1c5..6227412a9 100644 --- a/print/templates/reports/balance-compensation/balance-compensation.js +++ b/print/templates/reports/balance-compensation/balance-compensation.js @@ -6,14 +6,14 @@ module.exports = { name: 'balance-compensation', async serverPrefetch() { this.client = await this.fetchClient(this.id); - this.company = await this.fetchCompany(); + this.company = await this.fetchCompany(this.id); }, methods: { fetchClient(id) { return this.findOneFromDef('client', [id]); }, - fetchCompany() { - return this.findOneFromDef('company'); + fetchCompany(id) { + return this.findOneFromDef('company', [id]); }, currentDate() { diff --git a/print/templates/reports/balance-compensation/sql/client.sql b/print/templates/reports/balance-compensation/sql/client.sql index 5354fd095..92e6f6cab 100644 --- a/print/templates/reports/balance-compensation/sql/client.sql +++ b/print/templates/reports/balance-compensation/sql/client.sql @@ -6,7 +6,7 @@ SELECT c.city, r.amountPaid, r.payed -FROM client c + FROM client c JOIN receipt r ON r.clientFk = c.id JOIN supplier s ON c.fi = s.nif -WHERE r.id = ?; \ No newline at end of file + WHERE r.id = ? \ No newline at end of file diff --git a/print/templates/reports/balance-compensation/sql/company.sql b/print/templates/reports/balance-compensation/sql/company.sql index b22d53659..e61228a10 100644 --- a/print/templates/reports/balance-compensation/sql/company.sql +++ b/print/templates/reports/balance-compensation/sql/company.sql @@ -1,7 +1,8 @@ SELECT - s.name, - s.nif, - s.street, - s.city -FROM supplier s -WHERE s.id = 442; \ No newline at end of file + s.name, + s.nif, + s.street, + s.city + FROM supplier s + JOIN receipt r ON r.companyFk = s.id + WHERE r.id = ?; \ No newline at end of file From 98dd5963bf55ed91a8aeb935e2b5f9ccfaf06110 Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 4 Nov 2022 08:15:12 +0100 Subject: [PATCH 5/6] =?UTF-8?q?refs=20#4547=20traduccion=20a=C3=B1adida?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/client/front/balance/index/index.html | 2 +- modules/client/front/balance/index/locale/es.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/client/front/balance/index/index.html b/modules/client/front/balance/index/index.html index b505d5ab5..1e0716112 100644 --- a/modules/client/front/balance/index/index.html +++ b/modules/client/front/balance/index/index.html @@ -131,7 +131,7 @@ diff --git a/modules/client/front/balance/index/locale/es.yml b/modules/client/front/balance/index/locale/es.yml index 4ddf26153..de710869e 100644 --- a/modules/client/front/balance/index/locale/es.yml +++ b/modules/client/front/balance/index/locale/es.yml @@ -9,4 +9,5 @@ Balance: Balance Total by company: Total por empresa Download PDF: Descargar PDF Send compensation: Enviar compensación -BILL: N/FRA {{ref}} \ No newline at end of file +BILL: N/FRA {{ref}} +Notify compensation: ¿Desea informar de la compensación al cliente por correo? \ No newline at end of file From f9eee431b42668c036d1baed9afed1a690d56b88 Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 9 Nov 2022 10:27:00 +0100 Subject: [PATCH 6/6] fix(driver-route): routes with empty lines --- print/templates/reports/driver-route/driver-route.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html index 96fb6e957..e310539e0 100644 --- a/print/templates/reports/driver-route/driver-route.html +++ b/print/templates/reports/driver-route/driver-route.html @@ -81,7 +81,7 @@
-
+