Merge pull request 'refs move reports views' (!1518) from footnotesSolve into test
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #1518
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
Reviewed-by: Juan Ferrer <juan@verdnatura.es>
This commit is contained in:
Carlos Satorres 2023-05-11 12:50:27 +00:00
commit f53eef0455
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']