refs #5525 findOne sql
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Satorres 2023-07-11 13:49:39 +02:00
parent c453935ddd
commit 5b5191a6a5
2 changed files with 8 additions and 4 deletions

View File

@ -1,14 +1,18 @@
const Component = require(`vn-print/core/component`); const Component = require(`vn-print/core/component`);
const emailBody = new Component('email-body'); const emailBody = new Component('email-body');
const attachment = new Component('attachment'); const attachment = new Component('attachment');
const db = require('../../../core/database');
module.exports = { module.exports = {
name: 'letter-debtor-st', name: 'letter-debtor-st',
async serverPrefetch() { async serverPrefetch() {
this.debtor = await this.fetchDebtor(this.id, this.companyId); this.debtor = await db.findOne(`
SELECT sa.iban, be.name bankName
if (!this.debtor) FROM supplierAccount sa
throw new Error('Something went wrong'); LEFT JOIN bankEntity be ON sa.bankEntityFk = be.id
LEFT JOIN client c ON c.countryFk = sa.countryFk
WHERE c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk)`,
[this.id]);
}, },
data() { data() {
return { return {