refs move reports views #1518

Merged
carlossa merged 2 commits from footnotesSolve into test 2023-05-11 12:50:28 +00:00
2 changed files with 20 additions and 7 deletions

View File

@ -0,0 +1,12 @@
-- vn.companyL10n source
CREATE OR REPLACE
ALGORITHM = UNDEFINED VIEW `vn`.`companyL10n` AS
select
`c`.`id` AS `id`,
ifnull(`ci`.`footnotes`, `c`.`footnotes`) AS `footnotes`
from
(`vn`.`company` `c`
left join `vn`.`companyI18n` `ci` on
(`ci`.`companyFk` = `c`.`id`
and `ci`.`lang` = `util`.`LANG`()));

View File

@ -4,13 +4,14 @@ const db = require('../../database');
module.exports = {
name: 'report-footer',
async serverPrefetch() {
this.company = await db.findOne(
`SELECT
ci.footnotes
FROM companyI18n ci
JOIN company c ON c.id = ci.companyFk
WHERE c.code = ? AND ci.lang = (SELECT lang FROM account.user WHERE id = ?)`,
[this.companyCode, this.recipientId]);
this.company = await db.findOne(`
SELECT IFNULL(ci.footnotes, cl.footnotes) as footnotes
FROM company c
LEFT JOIN companyL10n cl ON c.id = cl.id
LEFT JOIN companyI18n ci ON ci.companyFk = cl.id
AND ci.lang = (SELECT lang FROM account.user where id = ?)
WHERE c.code = ?`,
[this.recipientId, this.companyCode]);
},
props: ['leftText', 'companyCode', 'recipientId', 'centerText']