diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0f239bf65..722af6e38 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2308,6 +2308,16 @@ REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issu (9, 1009, 'R', 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1242, 1, 442, 1), (10, 1010, 'R', 2, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1243, 1, 442, 1); +INSERT INTO vn.invoiceInTax (invoiceInFk, taxableBase, expenceFk, foreignValue, taxTypeSageFk, transactionTypeSageFk) + VALUES + (1, 252.25, '4751000000', NULL, 7, 61), + (2, 223.17, '6210000567', NULL, 8, 20), + (3, 95.60, '7001000000', NULL, 8, 35), + (4, 446.63, '7001000000', NULL, 6, 61), + (5, 64.23, '6210000567', NULL, 8, 20), + (6, 29.95, '7001000000', NULL, 7, 20), + (7, 58.64, '6210000567', NULL, 8, 20); + INSERT INTO `vn`.`invoiceInDueDay`(`invoiceInFk`, `dueDated`, `bankFk`, `amount`) VALUES (1, CURDATE(), 1, 237), diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/summary.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/summary.spec.js index ff7a39ef5..e2d96fe32 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/summary.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/summary.spec.js @@ -5,5 +5,6 @@ describe('invoiceIn summary()', () => { const summary = await app.models.InvoiceIn.summary(1); expect(summary.supplierRef).toEqual('1234'); + expect(summary.totals).toEqual('1234'); }); }); diff --git a/modules/invoiceIn/back/methods/invoice-in/summary.js b/modules/invoiceIn/back/methods/invoice-in/summary.js index 05e73d4df..b2db8264b 100644 --- a/modules/invoiceIn/back/methods/invoice-in/summary.js +++ b/modules/invoiceIn/back/methods/invoice-in/summary.js @@ -81,15 +81,16 @@ module.exports = Self => { async function getTotals(invoiceInFk) { return (await Self.rawSql(` - SELECT - SUM(iit.taxableBase) totalTaxableBase, - SUM(iit.taxableBase * (1 + (ti.PorcentajeIva / 100))) totalVat, + SELECT iit.*, SUM(iidd.amount) totalDueDay FROM vn.invoiceIn ii - LEFT JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id - LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk + 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]))[0]; + ii.id = ?`, [invoiceInFk, invoiceInFk]))[0]; } }; diff --git a/modules/invoiceIn/front/tax/index.html b/modules/invoiceIn/front/tax/index.html index ebf6daba5..cec875def 100644 --- a/modules/invoiceIn/front/tax/index.html +++ b/modules/invoiceIn/front/tax/index.html @@ -40,6 +40,7 @@