diff --git a/modules/client/back/models/receipt.json b/modules/client/back/models/receipt.json index 19107f561..da7879df9 100644 --- a/modules/client/back/models/receipt.json +++ b/modules/client/back/models/receipt.json @@ -62,6 +62,11 @@ "type": "belongsTo", "model": "Bank", "foreignKey": "bankFk" + }, + "supplier": { + "type": "belongsTo", + "model": "Supplier", + "foreignKey": "companyFk" } } -} \ No newline at end of file +} diff --git a/print/templates/reports/balance-compensation/balance-compensation.html b/print/templates/reports/balance-compensation/balance-compensation.html index d1a2788ed..c7448eeb9 100644 --- a/print/templates/reports/balance-compensation/balance-compensation.html +++ b/print/templates/reports/balance-compensation/balance-compensation.html @@ -17,8 +17,8 @@
- {{$t('Date')}} {{client.payed | date('%d-%m-%Y')}} {{$t('Compensate')}} {{client.amountPaid}} € - {{$t('From client')}} {{client.name}} {{$t('Against the balance of')}}: {{client.invoiceFk}}. + {{$t('Date')}} {{formatDate(receipt.payed, '%d-%m-%Y')}} {{$t('Compensate')}} {{receipt.amountPaid}} € + {{$t('From client')}} {{client.name}} {{$t('Against the balance of')}}: {{receipt.description}}.
{{$t('Reception')}} administracion@verdnatura.es diff --git a/print/templates/reports/balance-compensation/balance-compensation.js b/print/templates/reports/balance-compensation/balance-compensation.js index bae7c5c3c..c2c2e9288 100644 --- a/print/templates/reports/balance-compensation/balance-compensation.js +++ b/print/templates/reports/balance-compensation/balance-compensation.js @@ -1,12 +1,31 @@ const vnReport = require('../../../core/mixins/vn-report.js'); +const app = require('vn-loopback/server/server'); module.exports = { name: 'balance-compensation', mixins: [vnReport], async serverPrefetch() { - this.client = await this.findOneFromDef('client', [this.id]); - this.checkMainEntity(this.client); - this.company = await this.findOneFromDef('company', [this.id]); + this.receipt = await app.models.Receipt.findOne({ + fields: ['amountPaid', 'payed', 'clientFk', 'companyFk', 'description'], + include: [ + { + relation: 'client', + scope: { + fields: ['name', 'street', 'fi', 'city'], + } + }, { + relation: 'supplier', + scope: { + fields: ['name', 'street', 'nif', 'city'], + } + } + ], + where: {id: this.id} + }); + this.client = this.receipt.client(); + this.company = this.receipt.supplier(); + + this.checkMainEntity(this.receipt); }, props: { id: { diff --git a/print/templates/reports/balance-compensation/sql/client.sql b/print/templates/reports/balance-compensation/sql/client.sql deleted file mode 100644 index c3679b68a..000000000 --- a/print/templates/reports/balance-compensation/sql/client.sql +++ /dev/null @@ -1,12 +0,0 @@ -SELECT - c.name, - c.socialName, - c.street, - c.fi, - c.city, - r.invoiceFk, - r.amountPaid, - r.payed - FROM client c - JOIN receipt r ON r.clientFk = c.id - WHERE r.id = ? diff --git a/print/templates/reports/balance-compensation/sql/company.sql b/print/templates/reports/balance-compensation/sql/company.sql deleted file mode 100644 index e61228a10..000000000 --- a/print/templates/reports/balance-compensation/sql/company.sql +++ /dev/null @@ -1,8 +0,0 @@ -SELECT - 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 diff --git a/print/templates/reports/extra-community/extra-community.js b/print/templates/reports/extra-community/extra-community.js index 9941faa35..8f93fdc13 100755 --- a/print/templates/reports/extra-community/extra-community.js +++ b/print/templates/reports/extra-community/extra-community.js @@ -38,11 +38,11 @@ module.exports = { computed: { landedEnd: function() { if (!this.landedTo) return; - return formatDate(this.landedTo, '%Y-%m-%d'); + return this.formatDate(this.landedTo, '%Y-%m-%d'); }, shippedStart: function() { if (!this.shippedFrom) return; - return formatDate(this.shippedFrom, '%Y-%m-%d'); + return this.formatDate(this.shippedFrom, '%Y-%m-%d'); } }, methods: {