Let a kroner transfer name the bank
This commit is contained in:
1 parent
9d306aca2a
commit
c382e3c278
1 file changed
+12
-11
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user