add accounting page and fix issue with db selects
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
from rio import Column, Component, event, Text, TextStyle, Button, Color, Spacer, Revealer, Row
|
||||
|
||||
from src.ez_lan_manager import ConfigurationService, UserService, AccountingService
|
||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||
from src.ez_lan_manager.pages import BasePage
|
||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
||||
|
||||
|
||||
class AccountPage(Component):
|
||||
@event.on_populate
|
||||
async def on_populate(self) -> None:
|
||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Guthabenkonto")
|
||||
|
||||
async def _on_banking_info_press(self):
|
||||
self.banking_info_revealer.is_open = not self.banking_info_revealer.is_open
|
||||
|
||||
def build(self) -> Component:
|
||||
user = self.session[UserService].get_user(self.session[SessionStorage].user_id)
|
||||
a_s = self.session[AccountingService]
|
||||
self.banking_info_revealer = Revealer(
|
||||
header=None,
|
||||
content=Column(
|
||||
Text(
|
||||
"Bankverbindung:",
|
||||
style=TextStyle(
|
||||
fill=self.session.theme.background_color
|
||||
),
|
||||
margin=0,
|
||||
margin_top=0,
|
||||
margin_bottom=1,
|
||||
align_x=0.5
|
||||
),
|
||||
Text(
|
||||
"Kontoinhaber: Einfach Zocken Gaming Gesellschaft\n"
|
||||
"IBAN: DE47 5176 2434 0019 8566 07\n"
|
||||
"BLZ: 51762434\n"
|
||||
"BIC: GENODE51BIK\n\n"
|
||||
"Verwendungszweck:",
|
||||
style=TextStyle(
|
||||
fill=self.session.theme.background_color,
|
||||
font_size=0.78
|
||||
),
|
||||
margin=0,
|
||||
margin_bottom=1,
|
||||
align_x=0.2
|
||||
),
|
||||
Text(
|
||||
f"AUFLADUNG - {user.user_id} - {user.user_name}",
|
||||
style=TextStyle(
|
||||
fill=self.session.theme.neutral_color
|
||||
),
|
||||
margin=0,
|
||||
margin_bottom=1,
|
||||
align_x=0.5
|
||||
)
|
||||
),
|
||||
margin = 2,
|
||||
margin_top = 0,
|
||||
margin_bottom = 1,
|
||||
grow_x=True
|
||||
)
|
||||
|
||||
transaction_history = Column(
|
||||
Text(
|
||||
"Transaktionshistorie",
|
||||
style=TextStyle(
|
||||
fill=self.session.theme.background_color,
|
||||
font_size=1.2
|
||||
),
|
||||
margin_top=1,
|
||||
margin_bottom=1,
|
||||
align_x=0.5
|
||||
)
|
||||
)
|
||||
|
||||
for transaction in sorted(self.session[AccountingService].get_transaction_history(user.user_id), key=lambda t: t.transaction_date, reverse=True):
|
||||
transaction_history.add(
|
||||
Row(
|
||||
Text(
|
||||
f"{transaction.reference} ({transaction.transaction_date.strftime('%d.%m - %H:%M')})",
|
||||
style=TextStyle(
|
||||
fill=self.session.theme.danger_color if transaction.is_debit else self.session.theme.success_color,
|
||||
font_size=0.8
|
||||
),
|
||||
margin=0,
|
||||
margin_top=0,
|
||||
margin_left=0.5,
|
||||
margin_bottom=0.4,
|
||||
align_x=0
|
||||
),
|
||||
Text(
|
||||
f"{'-' if transaction.is_debit else '+'}{a_s.make_euro_string_from_int(transaction.value)}",
|
||||
style=TextStyle(
|
||||
fill=self.session.theme.danger_color if transaction.is_debit else self.session.theme.success_color,
|
||||
font_size=0.8
|
||||
),
|
||||
margin=0,
|
||||
margin_top=0,
|
||||
margin_right=0.5,
|
||||
margin_bottom=0.4,
|
||||
align_x=1
|
||||
)
|
||||
)
|
||||
)
|
||||
return BasePage(
|
||||
content=Column(
|
||||
MainViewContentBox(
|
||||
content=Text(
|
||||
f"Kontostand: {a_s.make_euro_string_from_int(a_s.get_balance(user.user_id))}",
|
||||
style=TextStyle(
|
||||
fill=self.session.theme.background_color,
|
||||
font_size=1.2
|
||||
),
|
||||
margin=2,
|
||||
align_x=0.5
|
||||
)
|
||||
),
|
||||
MainViewContentBox(
|
||||
content=Column(
|
||||
Text(
|
||||
"LAN-Konto aufladen",
|
||||
style=TextStyle(
|
||||
fill=self.session.theme.background_color,
|
||||
font_size=1.2
|
||||
),
|
||||
margin=2,
|
||||
align_x=0.5
|
||||
),
|
||||
Button(
|
||||
content=Text("BANKÜBERWEISUNG", style=TextStyle(fill=Color.from_hex("121212"), font_size=0.8), justify="center"),
|
||||
shape="rectangle",
|
||||
style="major",
|
||||
color="secondary",
|
||||
grow_x=True,
|
||||
margin=2,
|
||||
margin_top=0,
|
||||
margin_bottom=1,
|
||||
on_press=self._on_banking_info_press
|
||||
),
|
||||
self.banking_info_revealer,
|
||||
Button(
|
||||
content=Text("PAYPAL", style=TextStyle(fill=Color.from_hex("121212"), font_size=0.8), justify="center"),
|
||||
shape="rectangle",
|
||||
style="major",
|
||||
color="secondary",
|
||||
grow_x=True,
|
||||
margin=2,
|
||||
margin_top=0,
|
||||
is_sensitive=False
|
||||
)
|
||||
)
|
||||
),
|
||||
MainViewContentBox(
|
||||
content=transaction_history
|
||||
),
|
||||
align_y=0,
|
||||
)
|
||||
)
|
||||
@@ -2,3 +2,4 @@ from .BasePage import BasePage
|
||||
from .NewsPage import NewsPage
|
||||
from .PlaceholderPage import PlaceholderPage
|
||||
from .Logout import LogoutPage
|
||||
from.Account import AccountPage
|
||||
|
||||
Reference in New Issue
Block a user