fix balances #1189

Merged
joan merged 2 commits from fix-balance into master 2022-11-30 09:03:01 +00:00
1 changed files with 7 additions and 8 deletions

View File

@ -57,14 +57,16 @@ module.exports = Self => {
r.clientFk, r.clientFk,
FALSE hasPdf, FALSE hasPdf,
FALSE isInvoice, FALSE isInvoice,
CASE WHEN at2.code LIKE 'compensation' THEN True ELSE False END as isCompensation at2.id IS NOT NULL as isCompensation
FROM vn.receipt r FROM vn.receipt r
LEFT JOIN vn.worker w ON w.id = r.workerFk LEFT JOIN vn.worker w ON w.id = r.workerFk
LEFT JOIN account.user u ON u.id = w.userFk LEFT JOIN account.user u ON u.id = w.userFk
JOIN vn.company c ON c.id = r.companyFk JOIN vn.company c ON c.id = r.companyFk
JOIN vn.accounting a ON a.id = r.bankFk LEFT JOIN vn.accounting a ON a.id = r.bankFk
JOIN vn.accountingType at2 ON at2.id = a.accountingTypeFk LEFT JOIN vn.accountingType at2 ON at2.id = a.accountingTypeFk AND at2.code = 'compensation'
WHERE r.clientFk = ? AND r.companyFk = ? WHERE
r.clientFk = ?
AND r.companyFk = ?
UNION ALL UNION ALL
SELECT SELECT
i.id, i.id,
@ -81,13 +83,10 @@ module.exports = Self => {
i.clientFk, i.clientFk,
i.hasPdf, i.hasPdf,
TRUE isInvoice, TRUE isInvoice,
CASE WHEN at2.code LIKE 'compensation' THEN True ELSE False END as isCompensation NULL
FROM vn.invoiceOut i FROM vn.invoiceOut i
JOIN vn.company c ON c.id = i.companyFk JOIN vn.company c ON c.id = i.companyFk
JOIN vn.accounting a ON a.id = i.bankFk
JOIN vn.accountingType at2 ON at2.id = a.accountingTypeFk
WHERE i.clientFk = ? AND i.companyFk = ? WHERE i.clientFk = ? AND i.companyFk = ?
ORDER BY payed DESC, created DESC
) t ORDER BY payed DESC, created DESC`, ) t ORDER BY payed DESC, created DESC`,
Review

este no cal

este no cal
[ [
clientId, clientId,