Skip to content

Commit

Permalink
fix(journal): order Trial Balance by account number (#1602)
Browse files Browse the repository at this point in the history
This commit orders the trial balance by the account number for better predictability in account
ordering.  Ideally, the accounts should be ordered respecting their account tree ordering ... but
this can be optimized later as necessary.

Closes #1599.
  • Loading branch information
jniles committed May 8, 2017
1 parent 72aa815 commit c309572
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions server/config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,10 @@ exports.configure = function configure(app) {
app.get('/finance/cashflow', financeReports.cashflow.report);
app.get('/finance/incomeExpense', financeReports.incomeExpense.report);

// stock flux
// stock flux
app.get('/stock/flux', stock.listStockFlux);

// stock management API
// stock management API
app.post('/stock/lots/movements', stock.createMovement);
app.get('/stock/lots/movements', stock.listLotsMovements);

Expand All @@ -624,7 +624,7 @@ exports.configure = function configure(app) {
// stock integration
app.post('/stock/integration', stock.createIntegration);

// stock reports API
// stock reports API
app.get('/reports/stock/lots', stockReports.stockLotsReport);
app.get('/reports/stock/movements', stockReports.stockMovementsReport);
app.get('/reports/stock/inventories', stockReports.stockInventoriesReport);
Expand Down
10 changes: 6 additions & 4 deletions server/controllers/finance/journal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ function transformColumns(rows, newRecord) {

if (row.account_label) {
delete row.account_label;
}
}

if (row.hrEntity) {
// reverse barcode lookup entity
databaseRequests.push(ENTITY_QUERY);
Expand Down Expand Up @@ -502,10 +502,12 @@ function reverse(req, res, next) {
*
*/
function count(req, res, next) {
const sql = `SELECT COUNT(DISTINCT posting_journal.trans_id) AS number_transactions FROM posting_journal;`;
const sql = `
SELECT COUNT(DISTINCT posting_journal.trans_id) AS number_transactions FROM posting_journal;
`;

db.exec(sql)
.then(function (rows) {
.then((rows) => {
res.status(200).send(rows);
})
.catch(next);
Expand Down
7 changes: 4 additions & 3 deletions server/controllers/finance/trialBalance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
const db = require('../../../lib/db');
const BadRequest = require('../../../lib/errors/BadRequest');

exports.getDataPerAccount = function (req, res, next) {
exports.getDataPerAccount = function getDataPerAccount(req, res, next) {
const transactions = req.body.transactions;

if (!transactions) {
Expand Down Expand Up @@ -40,7 +40,8 @@ exports.getDataPerAccount = function (req, res, next) {
WHERE posting_journal.trans_id IN (?)
GROUP BY posting_journal.account_id
) AS combined
JOIN account ON account.id = combined.account_id;
JOIN account ON account.id = combined.account_id
ORDER BY account.number;
`;

// execute the query
Expand Down Expand Up @@ -108,7 +109,7 @@ exports.checkTransactions = function runTrialBalance(req, res, next) {
* This function can be called only when there is no fatal error
* It posts data to the general ledger.
**/
exports.postToGeneralLedger = function (req, res, next) {
exports.postToGeneralLedger = function postToGeneralLedger(req, res, next) {
const transactions = req.body.transactions;

if (!transactions || !Array.isArray(transactions)) {
Expand Down

0 comments on commit c309572

Please sign in to comment.