Skip to content

Commit

Permalink
Merge branch 'finance_ux' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasjuhrich committed May 28, 2024
2 parents cb5003c + bcdf4fd commit 590d33d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
15 changes: 10 additions & 5 deletions web/blueprints/finance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ def bank_accounts_list() -> ResponseReturnValue:
create_account=privilege_check(current_user, 'finance_change'))

bank_account_activity_table = BankAccountActivityTable(
data_url=url_for('.bank_accounts_activities_json'))
data_url=url_for(".bank_accounts_activities_json"),
finance_change=privilege_check(current_user, "finance_change"),
)

return render_template(
'finance/bank_accounts_list.html',
Expand All @@ -180,7 +182,7 @@ def bank_accounts_list_json() -> ResponseReturnValue:
last_imported_at=(
str(datetime.date(i))
if (i := bank_account.last_imported_at) is not None
else "nie"
else "-"
),
)
for bank_account in get_all_bank_accounts(session)
Expand Down Expand Up @@ -268,7 +270,7 @@ def flash_fints_errors() -> t.Iterator[None]:
def bank_accounts_import() -> ResponseReturnValue:
form = BankAccountActivitiesImportForm()
form.account.choices = [
(acc.id, acc.name) for acc in get_all_bank_accounts(session)
(acc.id, acc.name) for acc in get_all_bank_accounts(session) if not acc.account.legacy
]
imported = ImportedTransactions([], [], [])

Expand All @@ -285,6 +287,8 @@ def display_form_response(
if not form.is_submitted():
del (form.start_date)
form.end_date.data = date.today() - timedelta(days=1)
form.account.data = config.membership_fee_bank_account_id

return display_form_response(imported)

if not form.validate():
Expand Down Expand Up @@ -1364,8 +1368,9 @@ def membership_fee_users_due_json(fee_id: int) -> ResponseReturnValue:
).model_dump()


@bp.route("/membership_fees", methods=['GET', 'POST'])
@nav.navigate("Beiträge", icon='fa-hand-holding-usd')
@bp.route("/membership_fees", methods=["GET", "POST"])
@nav.navigate("Beiträge", icon="fa-hand-holding-usd")
@access.require("finance_change")
def membership_fees() -> ResponseReturnValue:
table = MembershipFeeTable(data_url=url_for('.membership_fees_json'))
return render_template('finance/membership_fees.html', table=table)
Expand Down
27 changes: 26 additions & 1 deletion web/blueprints/finance/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ def toolbar(self) -> HasDunderStr | None:
href = url_for(".bank_accounts_create")
return button_toolbar(gettext("Neues Bankkonto anlegen"), href)

class Meta:
table_args = {
"data-sort-order": "desc",
"data-sort-name": "last_imported_at",
}


class BankAccountRow(BaseModel):
name: str
Expand All @@ -231,7 +237,9 @@ class BankAccountActivityTable(BootstrapTable):
amount = Column("Betrag", width=1, formatter="table.euroFormatter")
actions = MultiBtnColumn("Aktionen", width=1)

def __init__(self, **kw: t.Any) -> None:
def __init__(self, *, finance_change: bool = False, **kw: t.Any) -> None:
self.finance_change = finance_change

table_args = kw.pop('table_args', {})
table_args.setdefault('data-detail-view', "true")
table_args.setdefault('data-row-style', "table.financeRowFormatter")
Expand All @@ -240,6 +248,23 @@ def __init__(self, **kw: t.Any) -> None:

super().__init__(**kw)

@property
@lazy_join
def toolbar(self) -> t.Iterator[str] | None:
"""Do operations on BankAccountActivities"""
if not self.finance_change:
return None
yield from button_toolbar(
"Kontobewegungen zuordnen",
url_for(".bank_account_activities_match"),
icon="fa-check",
)
yield from button_toolbar(
"Kontobewegungen rücküberweisen",
url_for(".bank_account_activities_return"),
icon="fa-rotate-left",
)

class Meta:
table_args = {
'data-sort-order': 'desc',
Expand Down
2 changes: 0 additions & 2 deletions web/templates/finance/bank_accounts_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ <h2 class="page-header">{{ _("Übersicht") }}</h2>

<section>
<h2 class="page-header">{{ _("Unzugeordnete Kontobewegungen") }}</h2>
<a href="{{ url_for('.bank_account_activities_match') }}" class="btn btn-primary">Kontobewegungen matchen</a>
<a href="{{ url_for('.bank_account_activities_return') }}" class="btn btn-outline-secondary">Unzugeordnete Kontobewegungen rücküberweisen</a>
{{ bank_account_activity_table.render('bank_accounts_activities') }}
</section>
{% endblock %}

0 comments on commit 590d33d

Please sign in to comment.