Improved history page and spacing between values and currency suffix + minor improvements to css

This commit is contained in:
Julian Müller (ChaoticByte) 2023-04-15 10:01:56 +02:00
parent 8702233934
commit ac59aa0baa
6 changed files with 30 additions and 25 deletions

View file

@ -2,6 +2,7 @@
from django.conf import settings
from django.db import connection
from django.utils.translation import gettext
COMBINE_ALPHABET = "abcdefghijklmnopqrstuvwxyz"
@ -44,11 +45,13 @@ def select_history(user, language_code="en") -> list:
user_id = user.pk
result = _db_select(f"""
select
price_sum as "sum",
concat(
price_sum, '{settings.CURRENCY_SUFFIX} - ',
product_name, ' (',
content_litres::real, -- converting to real removes trailing zeros
'l) x ', amount) as "text",
product_name,
' (',
content_litres::real, -- converting to real removes trailing zeros
'l) x ', amount
) as "text",
datetime
from app_order
where user_id = {user_id}
@ -56,7 +59,8 @@ def select_history(user, language_code="en") -> list:
union
select
concat(transaction_sum, '{settings.CURRENCY_SUFFIX} - Deposit') as "text",
transaction_sum as "sum",
'{gettext("Deposit")}' as "text",
datetime
from app_userdeposits_view
where user_id = {user_id}
@ -64,7 +68,8 @@ def select_history(user, language_code="en") -> list:
union
select
concat(transaction_sum, '{settings.CURRENCY_SUFFIX} - ', comment) as "text",
transaction_sum as "sum",
comment as "text",
datetime
from app_registertransaction
where user_id = {user_id} and is_transfer = true
@ -73,9 +78,6 @@ def select_history(user, language_code="en") -> list:
fetch first 30 rows only;
""")
result = [list(row) for row in result]
if language_code == "de": # reformat for german translation
for row in result:
row[0] = row[0].replace(".", ",")
return result