fixed sepa-core get mandate by supplier id
gitea/salix/test This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-03-12 07:52:12 +01:00
parent 91f8f337f5
commit 3b5b5112e0
1 changed files with 7 additions and 7 deletions

View File

@ -11,7 +11,7 @@ module.exports = {
if (!params.companyFk) if (!params.companyFk)
throw new UserException('No company id specified'); throw new UserException('No company id specified');
return this.methods.fetchClient(params.clientFk) return this.methods.fetchClient(params.clientFk, params.companyFk)
.then(([[client]]) => { .then(([[client]]) => {
if (!client) if (!client)
throw new UserException('No client data found'); throw new UserException('No client data found');
@ -24,7 +24,7 @@ module.exports = {
this.$i18n.locale = this.locale; this.$i18n.locale = this.locale;
}, },
methods: { methods: {
fetchClient(clientFk) { fetchClient(clientFk, companyFk) {
return database.pool.query( return database.pool.query(
`SELECT `SELECT
c.id clientId, c.id clientId,
@ -46,12 +46,12 @@ module.exports = {
FROM client c FROM client c
JOIN account.user u ON u.id = c.id JOIN account.user u ON u.id = c.id
JOIN country ct ON ct.id = c.countryFk JOIN country ct ON ct.id = c.countryFk
JOIN mandate m ON m.clientFk = c.id AND m.finished IS NULL
JOIN supplier s ON s.id = m.companyFk
JOIN country sc ON sc.id = s.countryFk
JOIN province sp ON sp.id = s.provinceFk
LEFT JOIN province p ON p.id = c.provinceFk LEFT JOIN province p ON p.id = c.provinceFk
LEFT JOIN mandate m ON m.clientFk = c.id AND m.finished IS NULL WHERE m.companyFk = ? AND c.id = ?`, [companyFk, clientFk]);
LEFT JOIN supplier s ON s.id = m.companyFk
LEFT JOIN country sc ON sc.id = s.countryFk
LEFT JOIN province sp ON sp.id = s.provinceFk
WHERE c.id = ?`, [clientFk]);
}, },
dated: () => { dated: () => {
return strftime('%d-%m-%Y', new Date()); return strftime('%d-%m-%Y', new Date());