diff --git a/client/src/partials/reports/modals/report_accounts.modal.html b/client/src/partials/reports/modals/report_accounts.modal.html
index cd135b015d..9fc93dae37 100644
--- a/client/src/partials/reports/modals/report_accounts.modal.html
+++ b/client/src/partials/reports/modals/report_accounts.modal.html
@@ -19,14 +19,14 @@
-
-
+
-
+
diff --git a/server/controllers/finance/reports/reportAccounts/index.js b/server/controllers/finance/reports/reportAccounts/index.js
index 6373f6faf6..89357db6d1 100644
--- a/server/controllers/finance/reports/reportAccounts/index.js
+++ b/server/controllers/finance/reports/reportAccounts/index.js
@@ -32,7 +32,7 @@ function document(req, res, next) {
accountLabel : params.account_label,
source : params.sourceLabel,
dateFrom : params.dateFrom,
- dateTo : params.dateTo
+ dateTo : params.dateTo,
};
params.user = req.session.user;
@@ -73,41 +73,41 @@ function getAccountTransactions(accountId, source, dateFrom, dateTo) {
const params = [accountId];
let dateCondition = '';
- if(dateFrom && dateTo){
- dateCondition = `AND DATE(trans_date) BETWEEN ? AND ?`
+ if (dateFrom && dateTo) {
+ dateCondition = 'AND DATE(trans_date) BETWEEN DATE(?) AND DATE(?)';
params.push(dateFrom, dateTo);
}
- const csum = `SET @csum := 0`;
+ const csum = 'SET @csum := 0;';
const sql = `
- SELECT a.trans_id, a.debit, a.credit, a.balance, a.trans_date, (@csum := @csum + a.balance) AS cumulBalance
- FROM(
- SELECT trans_id, BUID(entity_uuid) AS entity_uuid, description, trans_date,
+ SELECT a.trans_id, a.debit, a.credit, a.balance, a.trans_date, (@csum := @csum + a.balance) AS cumulBalance,
+ a.description
+ FROM (
+ SELECT trans_id, BUID(entity_uuid) AS entity_uuid, description, trans_date,
SUM(debit_equiv) as debit, SUM(credit_equiv) as credit, (SUM(debit_equiv) - SUM(credit_equiv)) AS balance
FROM ${tableName}
WHERE account_id = ? ${dateCondition}
- GROUP BY trans_id
- ORDER BY trans_date ASC
+ GROUP BY trans_id
+ ORDER BY trans_date ASC
) AS a`;
- const sqlAggrega = ` SELECT SUM(t.debit) AS debit, SUM(t.credit) AS credit, SUM(t.debit - t.credit) AS balance
+ const sqlAggrega = `
+ SELECT SUM(t.debit) AS debit, SUM(t.credit) AS credit, SUM(t.debit - t.credit) AS balance
FROM (
- SELECT trans_id, BUID(entity_uuid) AS entity_uuid, description, trans_date,
+ SELECT trans_id, BUID(entity_uuid) AS entity_uuid, description, trans_date,
SUM(debit_equiv) as debit, SUM(credit_equiv) as credit
FROM ${tableName}
WHERE account_id = ? ${dateCondition}
- GROUP BY trans_id
+ GROUP BY trans_id
ORDER BY trans_date ASC
- ) AS t
+ ) AS t
`;
const bundle = {};
return db.exec(csum)
- .then((err) => {
- return db.exec(sql, params);
- })
+ .then(() => db.exec(sql, params))
.then((transactions) => {
_.extend(bundle, { transactions });
return db.one(sqlAggrega, params);
@@ -118,4 +118,4 @@ function getAccountTransactions(accountId, source, dateFrom, dateTo) {
});
}
-exports.document = document;
\ No newline at end of file
+exports.document = document;
diff --git a/server/controllers/finance/reports/reportAccounts/report.handlebars b/server/controllers/finance/reports/reportAccounts/report.handlebars
index a08d0f87ab..ecceaa243a 100644
--- a/server/controllers/finance/reports/reportAccounts/report.handlebars
+++ b/server/controllers/finance/reports/reportAccounts/report.handlebars
@@ -9,7 +9,7 @@
{{date title.dateFrom }} - {{date title.dateTo }}
- {{/if}}
+ {{/if}}