This commit is contained in:
parent
f9382a1c22
commit
a27bb53089
|
@ -29,15 +29,18 @@ module.exports = Self => {
|
||||||
SELECT iit.*,
|
SELECT iit.*,
|
||||||
SUM(iidd.amount) totalDueDay
|
SUM(iidd.amount) totalDueDay
|
||||||
FROM vn.invoiceIn ii
|
FROM vn.invoiceIn ii
|
||||||
LEFT JOIN (SELECT SUM(iit.taxableBase) totalTaxableBase,
|
LEFT JOIN (
|
||||||
CAST(SUM(iit.taxableBase * (1 + (ti.PorcentajeIva / 100))) AS DECIMAL(10,2)) totalVat
|
SELECT SUM(iit.taxableBase) totalTaxableBase,
|
||||||
|
CAST(
|
||||||
|
SUM(COALESCE(iit.taxableBase * (1 + (ti.PorcentajeIva / 100)), iit.taxableBase))
|
||||||
|
AS DECIMAL(10, 2)
|
||||||
|
) totalVat
|
||||||
FROM vn.invoiceInTax iit
|
FROM vn.invoiceInTax iit
|
||||||
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
|
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
|
LEFT JOIN vn.invoiceInDueDay iidd ON iidd.invoiceInFk = ii.id
|
||||||
WHERE
|
WHERE ii.id = ?`, [id, id]);
|
||||||
ii.id = ?`, [id, id]);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue