Refactor code for improved readability and consistency across multiple files
Gitea Actions CI / detect (push) Successful in 3s
Gitea Actions CI / Compose & nginx validation (push) Failing after 14s
Gitea Actions CI / Frontend (lint / type / test / build) (push) Successful in 45s
Gitea Actions CI / Backend (lint / type / test / build) (push) Successful in 1m31s
Gitea Actions CI / detect (push) Successful in 3s
Gitea Actions CI / Compose & nginx validation (push) Failing after 14s
Gitea Actions CI / Frontend (lint / type / test / build) (push) Successful in 45s
Gitea Actions CI / Backend (lint / type / test / build) (push) Successful in 1m31s
This commit is contained in:
@@ -546,8 +546,19 @@ class TestAlfaSavingsRule:
|
||||
def savings_statement_rows(self) -> list[list[object]]:
|
||||
rows = [list(row) for row in synthetic_alfa_rows()]
|
||||
rows[9] = [
|
||||
None, None, None, None, None, None, None, None, None, None,
|
||||
"Расходы", None, "416,90 RUR",
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
"Расходы",
|
||||
None,
|
||||
"416,90 RUR",
|
||||
]
|
||||
savings_row = [
|
||||
"03.09.2026",
|
||||
|
||||
@@ -163,9 +163,7 @@ def test_revert_removes_created_savings_transfer(db: Session) -> None:
|
||||
assert db.query(Operation).filter_by(space_id=space.id).count() == 0
|
||||
assert db.query(SourceRecordLink).filter_by(space_id=space.id).count() == 0
|
||||
assert document.status == "ready"
|
||||
source = (
|
||||
db.query(SourceRecord).filter_by(parse_run_id=document.active_parse_run_id).one()
|
||||
)
|
||||
source = db.query(SourceRecord).filter_by(parse_run_id=document.active_parse_run_id).one()
|
||||
# Repeated parse gives the same decision: the hint survives revert.
|
||||
assert source.review_decision == "savings_transfer"
|
||||
|
||||
@@ -350,9 +348,9 @@ def test_unresolved_hold_counts_and_month_filter(db: Session) -> None:
|
||||
|
||||
unresolved = service.unresolved_holds(db, space_id=space.id, document=document)
|
||||
assert len(unresolved) == 2
|
||||
assert service.unresolved_hold_counts(
|
||||
db, space_id=space.id, document_ids=[document.id]
|
||||
) == {document.id: 2}
|
||||
assert service.unresolved_hold_counts(db, space_id=space.id, document_ids=[document.id]) == {
|
||||
document.id: 2
|
||||
}
|
||||
may = service.parse_month_filter("2026-05")
|
||||
assert may == (2026, 5)
|
||||
may_holds = [h for h in unresolved if h.occurred_on and h.occurred_on.month == 5]
|
||||
|
||||
@@ -58,9 +58,7 @@ def category_ids(client: TestClient) -> dict[str, str]:
|
||||
)
|
||||
assert response.status_code == 200, response.text
|
||||
return {
|
||||
item["systemKey"]: item["id"]
|
||||
for item in response.json()
|
||||
if item["systemKey"] is not None
|
||||
item["systemKey"]: item["id"] for item in response.json() if item["systemKey"] is not None
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -97,9 +97,7 @@ def test_adjust_balance_creates_single_signed_posting(db: Session) -> None:
|
||||
assert len(postings) == 1
|
||||
assert postings[0].amount_kopecks == -25_000
|
||||
assert account_balance(db, account) == 475_000
|
||||
event = (
|
||||
db.query(AuditEvent).filter_by(event_type="account.balance_adjusted").one()
|
||||
)
|
||||
event = db.query(AuditEvent).filter_by(event_type="account.balance_adjusted").one()
|
||||
assert event.detail["old_balance_kopecks"] == 500_000
|
||||
assert event.detail["new_balance_kopecks"] == 475_000
|
||||
assert event.detail["delta_kopecks"] == -25_000
|
||||
@@ -235,9 +233,7 @@ def test_convert_expense_to_savings_and_revert_roundtrip(db: Session) -> None:
|
||||
assert account_balance(db, account) == 500_000 - 12_345
|
||||
assert account_balance(db, savings_account) == 12_345
|
||||
|
||||
reverted = revert_savings_conversion(
|
||||
db, space_id=space.id, user=user, operation_id=expense.id
|
||||
)
|
||||
reverted = revert_savings_conversion(db, space_id=space.id, user=user, operation_id=expense.id)
|
||||
assert reverted.type == "expense"
|
||||
assert reverted.counter_account_id is None
|
||||
assert reverted.category_id == category.id
|
||||
@@ -263,9 +259,7 @@ def test_convert_rejects_income_refund_transfer_and_double_conversion(
|
||||
occurred_on=date(2026, 3, 2),
|
||||
)
|
||||
with pytest.raises(AppError) as exc:
|
||||
convert_expense_to_savings(
|
||||
db, space_id=space.id, user=user, operation_id=income.id
|
||||
)
|
||||
convert_expense_to_savings(db, space_id=space.id, user=user, operation_id=income.id)
|
||||
assert exc.value.code == "LEDGER_SAVINGS_CONVERT_INVALID"
|
||||
|
||||
refundable_expense = create_expense(
|
||||
@@ -285,9 +279,7 @@ def test_convert_rejects_income_refund_transfer_and_double_conversion(
|
||||
occurred_on=date(2026, 3, 4),
|
||||
)
|
||||
with pytest.raises(AppError) as exc:
|
||||
convert_expense_to_savings(
|
||||
db, space_id=space.id, user=user, operation_id=refund.id
|
||||
)
|
||||
convert_expense_to_savings(db, space_id=space.id, user=user, operation_id=refund.id)
|
||||
assert exc.value.code == "LEDGER_SAVINGS_CONVERT_INVALID"
|
||||
|
||||
expense = create_expense(
|
||||
@@ -300,9 +292,7 @@ def test_convert_rejects_income_refund_transfer_and_double_conversion(
|
||||
)
|
||||
convert_expense_to_savings(db, space_id=space.id, user=user, operation_id=expense.id)
|
||||
with pytest.raises(AppError) as exc:
|
||||
convert_expense_to_savings(
|
||||
db, space_id=space.id, user=user, operation_id=expense.id
|
||||
)
|
||||
convert_expense_to_savings(db, space_id=space.id, user=user, operation_id=expense.id)
|
||||
assert exc.value.code == "LEDGER_SAVINGS_CONVERT_INVALID"
|
||||
|
||||
transfer = create_transfer(
|
||||
@@ -315,9 +305,7 @@ def test_convert_rejects_income_refund_transfer_and_double_conversion(
|
||||
occurred_on=date(2026, 3, 6),
|
||||
)
|
||||
with pytest.raises(AppError) as exc:
|
||||
convert_expense_to_savings(
|
||||
db, space_id=space.id, user=user, operation_id=transfer.id
|
||||
)
|
||||
convert_expense_to_savings(db, space_id=space.id, user=user, operation_id=transfer.id)
|
||||
assert exc.value.code == "LEDGER_SAVINGS_CONVERT_INVALID"
|
||||
|
||||
|
||||
@@ -341,9 +329,7 @@ def test_convert_rejects_expense_with_confirmed_refund(db: Session) -> None:
|
||||
)
|
||||
|
||||
with pytest.raises(AppError) as exc:
|
||||
convert_expense_to_savings(
|
||||
db, space_id=space.id, user=user, operation_id=expense.id
|
||||
)
|
||||
convert_expense_to_savings(db, space_id=space.id, user=user, operation_id=expense.id)
|
||||
assert exc.value.code == "LEDGER_SAVINGS_CONVERT_HAS_REFUNDS"
|
||||
|
||||
|
||||
@@ -365,14 +351,10 @@ def test_convert_rejects_closed_period_and_cross_space_operation(db: Session) ->
|
||||
period = get_or_create_period(db, space_id=space.id, year=2026, month=3)
|
||||
close_period(db, space_id=space.id, user=user, period=period)
|
||||
with pytest.raises(AppError) as exc:
|
||||
convert_expense_to_savings(
|
||||
db, space_id=space.id, user=user, operation_id=expense.id
|
||||
)
|
||||
convert_expense_to_savings(db, space_id=space.id, user=user, operation_id=expense.id)
|
||||
assert exc.value.code == "BUDGET_PERIOD_CLOSED"
|
||||
with pytest.raises(AppError) as exc:
|
||||
convert_expense_to_savings(
|
||||
db, space_id=other_space.id, user=user, operation_id=expense.id
|
||||
)
|
||||
convert_expense_to_savings(db, space_id=other_space.id, user=user, operation_id=expense.id)
|
||||
assert exc.value.code == "LEDGER_OPERATION_NOT_FOUND"
|
||||
|
||||
|
||||
@@ -490,6 +472,4 @@ def test_operations_on_other_spaces_are_isolated(db: Session) -> None:
|
||||
occurred_on=date(2026, 3, 14),
|
||||
)
|
||||
convert_expense_to_savings(db, space_id=space.id, user=user, operation_id=expense.id)
|
||||
assert (
|
||||
db.query(Operation).filter_by(space_id=other_space.id).count() == 0
|
||||
)
|
||||
assert db.query(Operation).filter_by(space_id=other_space.id).count() == 0
|
||||
|
||||
Reference in New Issue
Block a user