Snapshot commit bringing the uncommitted phase-2 work into version control
together with four new features and the 0.2.22 version bump.
New features:
- Investor capital-over-time chart (value, paid-in, distributions per
quarter), rendered from existing capital-account history.
- Admin Investor View: read-only reconstruction of an investor's portal
(GET /api/users/{id}/investor-view), reusing the investor portal UI.
- Document upload scoped to the selected fund's own investors, with an
explicit upload-target confirmation to prevent mis-attaching.
- GP/mgmt entities gain an Assets tab listing their stakes in the funds
they manage (new entity_stakes table + /api/entities/{id}/stakes).
- Edit-entity form (change type/status/etc.), so GP entities can be
categorized correctly.
Verified: 11/11 backend tests pass; alembic upgrades to head b8c9d0e1f2a3;
frontend tsc + vite build clean; s9pk packs at 0.2.22:0 (x86_64).
Also: ignore .DS_Store and *.s9pk artifacts.
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
"""Admin Investor View reconstructs what one investor sees, read-only."""
|
|
|
|
from datetime import date
|
|
|
|
from tests.conftest import make_user
|
|
from ten31portal.models import (
|
|
CapitalAccountStatement, Entity, EntityAccess, EntityType, UserRole,
|
|
)
|
|
|
|
|
|
def test_investor_view_reconstructs(auth_client, session):
|
|
inv = make_user(session, username="lp1", role=UserRole.investor)
|
|
ent = Entity(name="LTPF I", type=EntityType.fund)
|
|
other = Entity(name="Not Theirs", type=EntityType.fund)
|
|
session.add(ent)
|
|
session.add(other)
|
|
session.commit()
|
|
session.refresh(ent)
|
|
session.refresh(other)
|
|
|
|
session.add(EntityAccess(user_id=inv.id, entity_id=ent.id))
|
|
session.add(CapitalAccountStatement(
|
|
entity_id=ent.id, investor_user_id=inv.id, as_of_date=date(2026, 3, 31),
|
|
commitment_cents=500_000, ending_balance_cents=600_000,
|
|
))
|
|
session.commit()
|
|
|
|
resp = auth_client.get(f"/api/users/{inv.id}/investor-view")
|
|
assert resp.status_code == 200, resp.text
|
|
body = resp.json()
|
|
assert body["user"]["username"] == "lp1"
|
|
# Only the granted entity is visible, not the other one.
|
|
assert [e["id"] for e in body["entities"]] == [ent.id]
|
|
assert len(body["capital_accounts"]) == 1
|
|
assert body["capital_accounts"][0]["ending_balance_cents"] == 600_000
|
|
|
|
|
|
def test_investor_view_rejects_non_investor(auth_client, session):
|
|
staff = make_user(session, username="ops", role=UserRole.operations)
|
|
assert auth_client.get(f"/api/users/{staff.id}/investor-view").status_code == 400
|