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 = { module.exports = {
name: 'report-footer', name: 'report-footer',
async serverPrefetch() { async serverPrefetch() {
this.company = await db.findOne( this.company = await db.findOne(`
`SELECT SELECT IFNULL(ci.footnotes, cl.footnotes) as footnotes
ci.footnotes FROM company c
FROM companyI18n ci LEFT JOIN companyL10n cl ON c.id = cl.id
JOIN company c ON c.id = ci.companyFk LEFT JOIN companyI18n ci ON ci.companyFk = cl.id
WHERE c.code = ? AND ci.lang = (SELECT lang FROM account.user WHERE id = ?)`, AND ci.lang = (SELECT lang FROM account.user where id = ?)
[this.companyCode, this.recipientId]); WHERE c.code = ?`,
[this.recipientId, this.companyCode]);
}, },
props: ['leftText', 'companyCode', 'recipientId', 'centerText'] props: ['leftText', 'companyCode', 'recipientId', 'centerText']