Skip to content

Commit

Permalink
fix(reports): incorrect footer account statement
Browse files Browse the repository at this point in the history
This commit fixes a bug in the summing of debits/credits on the Account
Statement report.

Closes #2609.
  • Loading branch information
jniles committed Mar 21, 2018
1 parent f0e7b22 commit 3dda25f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 5 additions & 5 deletions server/controllers/finance/reports/account_statement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function report(req, res, next) {
} catch (e) {
return next(e);
}
// converting uuids in binary
// converting uuids in binary
db.convert(options, ['uuids']);

return generalLedger.find(options)
Expand All @@ -48,9 +48,9 @@ function report(req, res, next) {
glb.rows = rows;

const aggregateSql = `
SELECT SUM(debit_equiv) AS debit_equiv, SUM(credit_equiv) AS credit_equiv,
SUM(debit_equiv - credit_equiv) AS balance
FROM general_ledger
SELECT SUM(debit_equiv) AS debit_equiv, SUM(credit_equiv) AS credit_equiv,
SUM(debit_equiv - credit_equiv) AS balance
FROM general_ledger
WHERE uuid IN (?);
`;
const transactionIds = rows.map(row => {
Expand All @@ -71,4 +71,4 @@ function report(req, res, next) {
})
.catch(next)
.done();
}
}
5 changes: 2 additions & 3 deletions server/controllers/finance/reports/reportAccounts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ function getTotalsSQL(options) {
SELECT
IFNULL(GetExchangeRate(${options.enterprise_id}, ${currencyId}, NOW()), 1) AS rate,
${currencyId} AS currency_id,
SUM(ROUND(debit_equiv, 2)) AS debit, SUM(ROUND(credit_equiv, 2)) AS credit,
SUM(ROUND(debit, 2)) AS debit, SUM(ROUND(credit, 2)) AS credit,
SUM(ROUND(debit_equiv, 2)) AS debit_equiv, SUM(ROUND(credit_equiv, 2)) AS credit_equiv,
(SUM(ROUND(debit_equiv, 2)) - SUM(ROUND(credit_equiv, 2))) AS balance
FROM general_ledger
`;
Expand Down Expand Up @@ -242,8 +243,6 @@ function getAccountTransactions(options, openingBalance = 0) {
// contains the grid totals for the footer
const footer = {
date : lastDate,
exchangedDebit : totals.debit * totals.rate,
exchangedCredit : totals.credit * totals.rate,
exchangedBalance : totals.balance * totals.rate,
exchangedCumSum : lastCumSum,
exchangedDate : new Date(),
Expand Down

0 comments on commit 3dda25f

Please sign in to comment.