diff --git a/server/controllers/finance/creditors.js b/server/controllers/finance/creditors.js index 3a55cd209f..bbb11bd17c 100644 --- a/server/controllers/finance/creditors.js +++ b/server/controllers/finance/creditors.js @@ -173,11 +173,10 @@ function getFinancialActivity(creditorUuid, dateFrom, dateTo) { ORDER BY trans_date ASC, trans_id; `; - const tabSql = (dateFrom && dateTo) - ? [db.exec(sql, [uid, uid]), balance(creditorUuid), openingBalanceCreditor(creditorUuid, dateFrom)] - : [db.exec(sql, [uid, uid]), balance(creditorUuid)]; + const tabSQL = [ db.exec(sql, [uid, uid]), balance(creditorUuid) ]; + if (dateFrom && dateTo) { tabSQL.push(openingBalanceCreditor(creditorUuid, dateFrom)); } - return q.all(tabSql) + return q.all(tabSQL) .spread((transactions, aggs, openingBalance) => { if (!aggs.length) { aggs.push({ debit : 0, credit : 0, balance : 0 }); diff --git a/server/controllers/finance/reports/financial.employee.handlebars b/server/controllers/finance/reports/financial.employee.handlebars index 0bb258fdf0..8e39ba18cd 100644 --- a/server/controllers/finance/reports/financial.employee.handlebars +++ b/server/controllers/finance/reports/financial.employee.handlebars @@ -47,13 +47,13 @@ {{translate "TABLE.COLUMNS.BALANCE_AT" }} {{date dates.dateFrom }} - {{debcred creditoropeningBalance.debit metadata.enterprise.currency_id}} + {{debcred creditorOpeningBalance.debit metadata.enterprise.currency_id}} - {{debcred creditoropeningBalance.credit metadata.enterprise.currency_id}} + {{debcred creditorOpeningBalance.credit metadata.enterprise.currency_id}} - {{debcred creditoropeningBalance.balance metadata.enterprise.currency_id}} + {{debcred creditorOpeningBalance.balance metadata.enterprise.currency_id}} {{/if}} diff --git a/server/controllers/finance/reports/financial.employee.js b/server/controllers/finance/reports/financial.employee.js index b7776a7dea..a2d05f85f2 100644 --- a/server/controllers/finance/reports/financial.employee.js +++ b/server/controllers/finance/reports/financial.employee.js @@ -78,7 +78,7 @@ async function build(req, res, next) { if (creditorOperations.openingBalance) { _.extend(data, { - creditoropeningBalance : creditorOperations.openingBalance[0], + creditorOpeningBalance : creditorOperations.openingBalance[0], }); }