Skip to content

Commit

Permalink
fix ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
mbayopanda committed Dec 4, 2020
1 parent b3c5d8d commit 29cf73b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/controllers/stock/reports/stock/stock_sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ async function stockSheetReport(req, res, next) {

const data = { inventory, depot };

data.rows = rows.movements.sort((x, y) => x.date - y.date);
if (!parseInt(options.orderByCreatedAt, 10)) {
data.rows = rows.movements.sort((x, y) => x.date - y.date);
} else {
// already sorted by created_at by mysql
data.rows = rows.movements;
}

data.totals = rows.totals;
data.result = rows.result;
data.dateFrom = options.dateFrom;
Expand Down

0 comments on commit 29cf73b

Please sign in to comment.