Ten31 LLC (and any GP/mgmt entity) can be linked to its investor account, so its Assets tab shows its real capital-account balance in each fund, pulled live from the eNAV capital accounts instead of manual entry. - entities.linked_user_id (migration c9d0e1f2a3b4) + EntityCreate/Update/ Response fields; validated to be an investor account. - Edit-entity form gains a "Linked investor account" picker for GP/mgmt. - Assets tab now auto-lists the linked account's balance per fund (the earlier manual-stakes API remains but is no longer used by the UI). Verified: 13/13 backend tests pass; alembic head c9d0e1f2a3b4; frontend tsc + vite build clean.
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
"""Linking a GP entity to its investor account (so Assets can pull real balances)."""
|
|
|
|
from tests.conftest import make_user
|
|
from ten31portal.models import Entity, EntityType, UserRole
|
|
|
|
|
|
def test_link_entity_to_investor(auth_client, session):
|
|
inv = make_user(session, username="ten31llc", role=UserRole.investor, name="Ten31 LLC")
|
|
gp = Entity(name="Ten31 LLC", type=EntityType.gp)
|
|
session.add(gp)
|
|
session.commit()
|
|
session.refresh(gp)
|
|
|
|
linked = auth_client.patch(f"/api/entities/{gp.id}", json={"linked_user_id": inv.id})
|
|
assert linked.status_code == 200, linked.text
|
|
assert linked.json()["linked_user_id"] == inv.id
|
|
|
|
# Unlink.
|
|
unlinked = auth_client.patch(f"/api/entities/{gp.id}", json={"linked_user_id": None})
|
|
assert unlinked.status_code == 200
|
|
assert unlinked.json()["linked_user_id"] is None
|
|
|
|
|
|
def test_link_rejects_non_investor(auth_client, session):
|
|
staff = make_user(session, username="ops2", role=UserRole.operations)
|
|
gp = Entity(name="Mgmt Co", type=EntityType.mgmt_co)
|
|
session.add(gp)
|
|
session.commit()
|
|
session.refresh(gp)
|
|
resp = auth_client.patch(f"/api/entities/{gp.id}", json={"linked_user_id": staff.id})
|
|
assert resp.status_code == 400
|