Skip to content

Commit

Permalink
fix(accounts): fix report date handling
Browse files Browse the repository at this point in the history
This commit fixes the account report's date handling so that it limits
to the correct dates.  It is a critical bug fix for Vanga.

Caused by a variation on #1274.
  • Loading branch information
Jonathan Niles authored and jniles committed Feb 28, 2017
1 parent f2df45b commit d458d8e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/controllers/finance/reports/reportAccounts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ function getAccountTransactions(accountId, source, dateFrom, dateTo) {
// get the table name
const tableName = sourceMap[sourceId];
const params = [accountId];

let dateCondition = '';

if (dateFrom && dateTo) {
dateCondition = 'AND DATE(trans_date) BETWEEN DATE(?) AND DATE(?)';
params.push(dateFrom, dateTo);
params.push(new Date(dateFrom), new Date(dateTo));
}

const csum = 'SET @csum := 0;';
Expand All @@ -95,7 +96,6 @@ function getAccountTransactions(accountId, source, dateFrom, dateTo) {
) AS a
`;


const sqlAggrega = `
SELECT SUM(t.debit) AS debit, SUM(t.credit) AS credit, SUM(t.debit - t.credit) AS balance
FROM (
Expand Down

0 comments on commit d458d8e

Please sign in to comment.