diff --git a/print/templates/reports/balance-compensation/balance-compensation.js b/print/templates/reports/balance-compensation/balance-compensation.js index b1d61e1c5c..6227412a9c 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 5354fd0958..92e6f6cabe 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 b22d53659e..e61228a105 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