From 5b5191a6a5e0bd79666752556de0025d3d06a1d4 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 11 Jul 2023 13:49:39 +0200 Subject: [PATCH] refs #5525 findOne sql --- .../231001 => changes/233001}/00-supplier.sql | 0 .../email/letter-debtor-st/letter-debtor-st.js | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) rename db/{.archive/231001 => changes/233001}/00-supplier.sql (100%) diff --git a/db/.archive/231001/00-supplier.sql b/db/changes/233001/00-supplier.sql similarity index 100% rename from db/.archive/231001/00-supplier.sql rename to db/changes/233001/00-supplier.sql diff --git a/print/templates/email/letter-debtor-st/letter-debtor-st.js b/print/templates/email/letter-debtor-st/letter-debtor-st.js index e0a690f81..5d93116af 100755 --- a/print/templates/email/letter-debtor-st/letter-debtor-st.js +++ b/print/templates/email/letter-debtor-st/letter-debtor-st.js @@ -1,14 +1,18 @@ const Component = require(`vn-print/core/component`); const emailBody = new Component('email-body'); const attachment = new Component('attachment'); +const db = require('../../../core/database'); module.exports = { name: 'letter-debtor-st', async serverPrefetch() { - this.debtor = await this.fetchDebtor(this.id, this.companyId); - - if (!this.debtor) - throw new Error('Something went wrong'); + this.debtor = await db.findOne(` + SELECT sa.iban, be.name bankName + FROM supplierAccount sa + 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() { return {