#5835 getTotals fixed #1854
|
@ -29,15 +29,18 @@ module.exports = Self => {
|
|||
SELECT iit.*,
|
||||
SUM(iidd.amount) totalDueDay
|
||||
FROM vn.invoiceIn ii
|
||||
LEFT JOIN (SELECT SUM(iit.taxableBase) totalTaxableBase,
|
||||
CAST(SUM(iit.taxableBase * (1 + (ti.PorcentajeIva / 100))) AS DECIMAL(10,2)) totalVat
|
||||
LEFT JOIN (
|
||||
SELECT SUM(iit.taxableBase) totalTaxableBase,
|
||||
CAST(
|
||||
SUM(COALESCE(iit.taxableBase * (1 + (ti.PorcentajeIva / 100)), iit.taxableBase))
|
||||
jorgep marked this conversation as resolved
Outdated
|
||||
AS DECIMAL(10, 2)
|
||||
) totalVat
|
||||
FROM vn.invoiceInTax iit
|
||||
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
|
||||
WHERE iit.invoiceInFk = ?) iit ON TRUE
|
||||
WHERE iit.invoiceInFk = ?
|
||||
) iit ON TRUE
|
||||
LEFT JOIN vn.invoiceInDueDay iidd ON iidd.invoiceInFk = ii.id
|
||||
WHERE
|
||||
ii.id = ?`, [id, id]);
|
||||
|
||||
WHERE ii.id = ?`, [id, id]);
|
||||
return result;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
si hay dos valores, no pongas coalesce, pon ifnull que es mas claro