Skip to content

Commit ba75b05

Browse files
committed
Return transactions ordered by date
1 parent 546790e commit ba75b05

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

thebook/bookkeeping/templates/bookkeeping/transactions.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ <h5 class="modal-title" id="exampleModalLabel">{% translate "Upload Document" %}
389389
let table = $("#transactions").DataTable(
390390
{
391391
pageLength: 150,
392+
order: [], // Keep original ordering
392393
columnDefs: [
393394
{ type: "custom-brl-sort", targets: 2 },
394395
{ orderable: false, targets: 5 }

thebook/bookkeeping/tests/views/test_bank_account_transactions.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,33 @@ def test_bank_account_transactions_context_without_year_and_valid_month(
232232
assert transaction_3 in context["transactions"]
233233

234234

235+
def test_bank_account_transactions_context__transactions_ordered_by_date_by_default(
236+
db, bank_account_1
237+
):
238+
transaction_1 = baker.make(
239+
Transaction, bank_account=bank_account_1, date=datetime.date(2026, 3, 10)
240+
)
241+
transaction_2 = baker.make(
242+
Transaction, bank_account=bank_account_1, date=datetime.date(2026, 3, 12)
243+
)
244+
transaction_3 = baker.make(
245+
Transaction, bank_account=bank_account_1, date=datetime.date(2026, 3, 5)
246+
)
247+
transaction_4 = baker.make(
248+
Transaction, bank_account=bank_account_1, date=datetime.date(2026, 3, 11)
249+
)
250+
251+
context = _get_bank_account_transactions_context(bank_account_1, month=1)
252+
253+
assert len(context["transactions"]) == 4
254+
transactions = context["transactions"]
255+
256+
assert transactions[0] == transaction_3
257+
assert transactions[1] == transaction_1
258+
assert transactions[2] == transaction_4
259+
assert transactions[3] == transaction_2
260+
261+
235262
@pytest.mark.parametrize(
236263
"year,month,expected_year,expected_month",
237264
[

0 commit comments

Comments
 (0)