Skip to content

Commit b245ace

Browse files
Fix expense history sorting issues
1 parent 3bed487 commit b245ace

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

static/js/reports.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ function loadMonthlySpendingTable(monthlySpendingTable) {
174174
else {
175175
$('#monthlyExpenses').DataTable({
176176
"pagingType": "full_numbers",
177-
"order": [[0, "asc"]],
177+
"order": [[0, "desc"]],
178178
"scrollY": "300px",
179179
"scrollCollapse": true,
180180
"paging": false,

tendie_expenses.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def addExpenses(formData, userID):
6363

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

6969
history = convertSQLToDict(results)

tendie_reports.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def generateMonthlyReport(userID, year=None):
5555

5656
# Get the spending data from DB for the table (individual expenses per month)
5757
results = db.execute(
58-
"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()
58+
"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()
5959
spending_month_table = convertSQLToDict(results)
6060

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

0 commit comments

Comments
 (0)