Skip to content

Commit

Permalink
Fix expense history sorting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyharrington committed Mar 28, 2021
1 parent 3bed487 commit b245ace
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion static/js/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function loadMonthlySpendingTable(monthlySpendingTable) {
else {
$('#monthlyExpenses').DataTable({
"pagingType": "full_numbers",
"order": [[0, "asc"]],
"order": [[0, "desc"]],
"scrollY": "300px",
"scrollCollapse": true,
"paging": false,
Expand Down
2 changes: 1 addition & 1 deletion tendie_expenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def addExpenses(formData, userID):

# Get and return the users lifetime expense history
def getHistory(userID):
results = db.execute("SELECT description, category, expenseDate AS date, payer, amount, submitTime FROM expenses WHERE user_id = :usersID ORDER BY submitTime ASC",
results = db.execute("SELECT description, category, expenseDate AS date, payer, amount, submitTime FROM expenses WHERE user_id = :usersID ORDER BY id ASC",
{"usersID": userID}).fetchall()

history = convertSQLToDict(results)
Expand Down
2 changes: 1 addition & 1 deletion tendie_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def generateMonthlyReport(userID, year=None):

# Get the spending data from DB for the table (individual expenses per month)
results = db.execute(
"SELECT description, category, expensedate, amount, payer FROM expenses WHERE user_id = :usersID AND date_part('year', date(expensedate)) = :year ORDER BY id DESC", {"usersID": userID, "year": year}).fetchall()
"SELECT description, category, expensedate, amount, payer FROM expenses WHERE user_id = :usersID AND date_part('year', date(expensedate)) = :year ORDER BY id ASC", {"usersID": userID, "year": year}).fetchall()
spending_month_table = convertSQLToDict(results)

# Combine both data points (chart and table) into a single data structure
Expand Down

0 comments on commit b245ace

Please sign in to comment.