This commit is contained in:
parent
556b403a5b
commit
ea31d3bebb
|
@ -7,12 +7,28 @@ module.exports = {
|
||||||
name: 'letter-debtor-nd',
|
name: 'letter-debtor-nd',
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.debtor = await db.findOne(`
|
this.debtor = await db.findOne(`
|
||||||
SELECT sa.iban, be.name bankName
|
SELECT sa.iban,
|
||||||
FROM supplierAccount sa
|
be.name bankName,
|
||||||
LEFT JOIN bankEntity be ON sa.bankEntityFk = be.id
|
sa.countryFk,
|
||||||
LEFT JOIN client c ON c.countryFk = sa.countryFk
|
c.countryFk
|
||||||
WHERE c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk)`,
|
FROM supplierAccount sa
|
||||||
[this.id]);
|
JOIN bankEntity be ON sa.bankEntityFk = be.id
|
||||||
|
LEFT JOIN company co ON co.supplierAccountFk = sa.id
|
||||||
|
LEFT JOIN client c ON c.countryFk = sa.countryFk
|
||||||
|
WHERE c.id = ?
|
||||||
|
ORDER BY co.id DESC
|
||||||
|
LIMIT 1;
|
||||||
|
`, [this.id]);
|
||||||
|
if (!this.debtor.length) {
|
||||||
|
this.debtor = await db.findOne(`
|
||||||
|
SELECT sa.iban,
|
||||||
|
be.name bankName
|
||||||
|
FROM supplierAccount sa
|
||||||
|
JOIN bankEntity be ON sa.bankEntityFk = be.id
|
||||||
|
JOIN company co ON co.supplierAccountFk = sa.id
|
||||||
|
WHERE co.code = ?;
|
||||||
|
`, [this.companyCode]);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue