Added the missing handlers for the PaginationException to the views in the accounting application.

This commit is contained in:
依瑪貓 2020-08-05 13:38:12 +08:00
parent 184e94e2c6
commit 4f8ed8dc85

View File

@ -252,7 +252,10 @@ def cash_summary(request, account):
balance=sum([x.balance for x in months]),
cumulative_balance=cumulative_balance,
))
try:
pagination = Pagination(request, months, True)
except PaginationException as e:
return HttpResponseRedirect(e.url)
shortcut_accounts = settings.ACCOUNTING["CASH_SHORTCUT_ACCOUNTS"]
return render(request, "accounting/cash-summary.html", {
"item_list": pagination.items,
@ -328,7 +331,10 @@ def ledger(request, account, period):
record.balance = balance
if record_brought_forward is not None:
records.insert(0, record_brought_forward)
try:
pagination = Pagination(request, records, True)
except PaginationException as e:
return HttpResponseRedirect(e.url)
records = pagination.items
find_imbalanced(records)
find_order_holes(records)
@ -394,7 +400,10 @@ def ledger_summary(request, account):
balance=sum([x.balance for x in months]),
cumulative_balance=cumulative_balance,
))
try:
pagination = Pagination(request, months, True)
except PaginationException as e:
return HttpResponseRedirect(e.url)
return render(request, "accounting/ledger-summary.html", {
"item_list": pagination.items,
"pagination": pagination,
@ -476,7 +485,10 @@ def journal(request, period):
amount=sum_debits - sum_credits
))
records = list(debit_records) + list(credit_records) + list(records)
try:
pagination = Pagination(request, records, True)
except PaginationException as e:
return HttpResponseRedirect(e.url)
return render(request, "accounting/journal.html", {
"item_list": pagination.items,
"pagination": pagination,
@ -790,7 +802,10 @@ def search(request):
| Q(account__code__icontains=query)
| Q(summary__icontains=query)
| Q(transaction__note__icontains=query))
try:
pagination = Pagination(request, records, True)
except PaginationException as e:
return HttpResponseRedirect(e.url)
return render(request, "accounting/search.html", {
"item_list": pagination.items,
"pagination": pagination,