Merge pull request '5120-reports_loopback' (!1389) from 5120-reports_loopback into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #1389
Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
Joan Sanchez 2023-03-16 06:34:02 +00:00
commit d373d80b12
5 changed files with 30 additions and 26 deletions

View File

@ -62,6 +62,11 @@
"type": "belongsTo",
"model": "Bank",
"foreignKey": "bankFk"
},
"supplier": {
"type": "belongsTo",
"model": "Supplier",
"foreignKey": "companyFk"
}
}
}
}

View File

@ -17,8 +17,8 @@
</p>
<h4 style="text-align: center; margin-top: 10%">{{$t('Agree') | uppercase}}</h4>
<p style="margin-top: 8%; text-align: justify">
{{$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}}.
</p>
<p style="margin-top: 8%">
{{$t('Reception')}} <span style="color: blue">administracion@verdnatura.es</span>

View File

@ -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: {

View File

@ -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 = ?

View File

@ -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 = ?;