From c382e3c278cb5549068bf363283140798b403829 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Mon, 16 Nov 2026 19:22:12 +0000 Subject: [PATCH] Let a kroner transfer name the bank --- app.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app.py b/app.py index b139008..ae41892 100644 --- a/app.py +++ b/app.py @@ -682,7 +682,9 @@ class SkuldHandler(BaseHTTPRequestHandler): raise ApiError(400, error, "lot_picks") conn = database.connect() try: - tx, errors = validation.validate_transaction(body, _load_markets(conn)) + tx, errors = validation.validate_transaction( + body, _load_markets(conn), _bank_market_id(conn) + ) if errors: _raise_errors(errors) if tx["type"] == "admin_cost" and picks: @@ -690,16 +692,15 @@ class SkuldHandler(BaseHTTPRequestHandler): raise ApiError( 400, "Forvaltningskostnad rører ingen parti.", "lot_picks" ) - if tx["type"] != "admin_cost": - # The bank is only the counterparty of a cost (section 3.11). - bank_id = _bank_market_id(conn) - for field in ("market_id", "to_market_id"): - if tx[field] == bank_id: - raise ApiError( - 400, - "Bankkontoen kan berre brukast av forvaltningskostnad.", - field, - ) + if tx["type"] != "admin_cost" and not _may_name_bank(tx, _bank_market_id(conn)): + # The bank is the counterparty of a cost, and a side of a kroner + # transfer, and nothing else (docs/spec.md section 3.11). + raise ApiError( + 400, + "Bankkontoen kan berre brukast av forvaltningskostnad og av ei " + "overføring i kroner.", + "market_id", + ) previous = None if tx_id is not None: row = conn.execute(