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

este no cal

este no cal
[
clientId,