"""A distribution recorded by hand, without a registry statement to upload.
There was no form for one: a US dividend, or one whose PDF nobody has, could
not be entered at all. The holding page now offers the statement form for
its own holding, in a dialog, and /dividend/new is the same form as a page
for a browser without scripting.
"""
from __future__ import annotations
import re
from decimal import Decimal
from formdata import as_sent
from sqlalchemy import select
import factories as fac
from app.models import Dividend
from test_routes import bind_to_only_portfolio, make_login, reading
HTML = {"accept": "text/html"}
SAVE = "/imports-exports/statement/commit"
def _acme(client, session_factory):
make_login(client, session_factory)
with session_factory() as s:
bind_to_only_portfolio(s)
acme = fac.make_instrument(s, "ACME", name="Acme Industries")
fac.add_trade(s, acme, "2026-01-05", "buy", 100, "5.00")
s.commit()
def test_the_page_is_the_statement_form_for_that_holding(client, session_factory):
_acme(client, session_factory)
page = client.get("/dividend/new?ticker=ACME", headers=HTML)
assert page.status_code == 200
assert "