diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js index 2600b596e..8c4e4911c 100755 --- a/print/templates/reports/sepa-core/sepa-core.js +++ b/print/templates/reports/sepa-core/sepa-core.js @@ -1,13 +1,12 @@ const vnReport = require('../../../core/mixins/vn-report.js'); -const db = require('../../../core/database'); module.exports = { name: 'sepa-core', mixins: [vnReport], async serverPrefetch() { - this.client = await this.findOneFromDef('client', [this.companyId, this.companyId, this.id]); + this.client = await this.findOneFromDef('client', [this.id]); this.checkMainEntity(this.client); - const suppliers = await this.rawSqlFromDef('supplier', [this.companyId, this.companyId, this.id]); + const suppliers = await this.rawSqlFromDef('supplier', [this.companyId, this.id]); this.supplier = { ...suppliers[0], accountDetailValue: suppliers.map(val => val?.accountDetailValue) diff --git a/print/templates/reports/sepa-core/sql/client.sql b/print/templates/reports/sepa-core/sql/client.sql index 6cdd7403f..6e0ec89eb 100644 --- a/print/templates/reports/sepa-core/sql/client.sql +++ b/print/templates/reports/sepa-core/sql/client.sql @@ -1,5 +1,4 @@ SELECT c.id, - m.code mandateCode, c.socialName, c.street, c.postcode, @@ -11,11 +10,5 @@ SELECT c.id, ct.ibanLength ibanLength FROM client c JOIN country ct ON ct.id = c.countryFk - LEFT JOIN province p ON p.id = c.provinceFk - LEFT JOIN mandate m ON m.clientFk = c.id - AND m.companyFk = ? - AND m.finished IS NULL - WHERE (m.companyFk = ? OR m.companyFk IS NULL) - AND c.id = ? - ORDER BY m.created DESC - LIMIT 1 \ No newline at end of file + JOIN province p ON p.id = c.provinceFk + WHERE c.id = ? \ No newline at end of file diff --git a/print/templates/reports/sepa-core/sql/supplier.sql b/print/templates/reports/sepa-core/sql/supplier.sql index 749f2c430..da543147a 100644 --- a/print/templates/reports/sepa-core/sql/supplier.sql +++ b/print/templates/reports/sepa-core/sql/supplier.sql @@ -20,6 +20,5 @@ SELECT m.code mandateCode, AND c.id = ? AND mt.name = 'CORE' AND adt.description = 'Referencia Remesas' - GROUP BY m.id - ORDER BY m.created DESC - LIMIT 1; + GROUP BY m.id, ad.value + ORDER BY m.created DESC \ No newline at end of file