salix/modules/invoiceIn/back/models/invoice-in.js

22 lines
958 B
JavaScript
Raw Normal View History

2021-02-10 14:03:11 +00:00
module.exports = Self => {
require('../methods/invoice-in/filter')(Self);
require('../methods/invoice-in/summary')(Self);
2021-07-23 12:06:48 +00:00
require('../methods/invoice-in/clone')(Self);
2021-09-24 06:24:34 +00:00
require('../methods/invoice-in/toBook')(Self);
Self.getTotals = async function getTotals(invoiceInFk) {
return (await Self.rawSql(`
SELECT iit.*,
SUM(iidd.amount) totalDueDay
FROM vn.invoiceIn ii
LEFT JOIN (SELECT SUM(iit.taxableBase) totalTaxableBase,
SUM(iit.taxableBase * (1 + (ti.PorcentajeIva / 100))) totalVat
FROM vn.invoiceInTax iit
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
WHERE iit.invoiceInFk = ?) iit ON TRUE
LEFT JOIN vn.invoiceInDueDay iidd ON iidd.invoiceInFk = ii.id
WHERE
ii.id = ?`, [invoiceInFk, invoiceInFk]))[0];
};
2021-02-10 14:03:11 +00:00
};