Skip to content

Commit

Permalink
fixup! Enable export of non-attributable transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
FestplattenSchnitzel committed May 8, 2024
1 parent ce1ee7f commit af839d2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pycroft/lib/finance/retransfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

from sepaxml import SepaTransfer
from sqlalchemy import select
from sqlalchemy.orm import joinedload
from sqlalchemy.orm import joinedload, Session

from pycroft import config
from pycroft.helpers.utc import ensure_tz
from pycroft.model import session

Check failure on line 10 in pycroft/lib/finance/retransfer.py

View workflow job for this annotation

GitHub Actions / python-lint

Ruff (F401)

pycroft/lib/finance/retransfer.py:10:27: F401 `pycroft.model.session` imported but unused
from pycroft.model.finance import BankAccountActivity


def get_activities_to_return() -> Sequence[BankAccountActivity]:
def get_activities_to_return(session: Session) -> Sequence[BankAccountActivity]:

Check failure on line 14 in pycroft/lib/finance/retransfer.py

View workflow job for this annotation

GitHub Actions / python-lint

Ruff (F811)

pycroft/lib/finance/retransfer.py:14:30: F811 Redefinition of unused `session` from line 10
statement = (
select(BankAccountActivity)
.options(joinedload(BankAccountActivity.bank_account))
Expand All @@ -20,7 +20,7 @@ def get_activities_to_return() -> Sequence[BankAccountActivity]:
.filter(BankAccountActivity.imported_at < ensure_tz(datetime.utcnow() - timedelta(days=14)))
)

return session.session.scalars(statement).all()
return session.scalars(statement).all()


def generate_activities_return_sepaxml(activities: list[BankAccountActivity]) -> bytes:
Expand Down
8 changes: 6 additions & 2 deletions web/blueprints/finance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,12 @@ class ActivityEntry(t.TypedDict):
@bp.route("/bank-account-activities/return/")
@access.require("finance_change")
def bank_account_activities_return() -> ResponseReturnValue:
s = session.session

Check failure on line 566 in web/blueprints/finance/__init__.py

View workflow job for this annotation

GitHub Actions / python-lint

Error

"Session" has no attribute "session" [attr-defined]

field_list: BooleanFieldList = []
activities: dict[str, ActivityEntry] = {}

for activity in get_activities_to_return():
for activity in get_activities_to_return(s):
activities[str(activity.id)] = {
"bank_account": activity.bank_account.name,
"name": activity.other_name,
Expand All @@ -589,8 +591,10 @@ def bank_account_activities_return() -> ResponseReturnValue:
@bp.route("/bank-account-activities/return/do/", methods=["GET", "POST"])
@access.require("finance_change")
def bank_account_activities_return_do() -> ResponseReturnValue:
s = session.session

Check failure on line 594 in web/blueprints/finance/__init__.py

View workflow job for this annotation

GitHub Actions / python-lint

Error

"Session" has no attribute "session" [attr-defined]

field_list: BooleanFieldList = []
activities_to_return: Sequence[BankAccountActivity] = get_activities_to_return()
activities_to_return: Sequence[BankAccountActivity] = get_activities_to_return(s)

for activity in activities_to_return:
field_list.append((str(activity.id), BooleanField(str(activity.id), default=True)))
Expand Down
5 changes: 0 additions & 5 deletions web/templates/finance/bank_account_activities_return.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{#
SPDX-FileCopyrightText: 2024 Gregor Düster <git@gdstr.eu>

SPDX-License-Identifier: Apache-2.0
#}
{% extends "layout.html" %}

{% set page_title = "Unzuordenbare Überweisungen zurücküberweisen" %}
Expand Down

0 comments on commit af839d2

Please sign in to comment.