0.2.33: exited positions (secondary-sale edge case)
A member who sold/transferred their stake showed a phantom -100% loss
($0 ending balance, no distribution through the fund). Now:
- entity_access.exited_on (migration e1f2a3b4c5d6), set/cleared from the
Partners tab (writer-only, inline date picker, audited)
- LP portal card shows a quiet "Exited <date>" badge, keeps documents,
hides balance/gain
- portfolio summary excludes exited positions ("Excludes N exited")
- fund committed totals (rollup + Partners tab) skip exited members so
seller + buyer are not double-counted
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
4215d4478f
commit
a639ba14cf
@@ -10,7 +10,7 @@ from ten31portal.auth import (
|
||||
)
|
||||
from ten31portal.database import get_session
|
||||
from ten31portal.models import (
|
||||
CapitalAccountStatement, Entity, User, UserRole,
|
||||
CapitalAccountStatement, Entity, EntityAccess, User, UserRole,
|
||||
)
|
||||
from ten31portal.schemas import CapitalAccountCreate, CapitalAccountResponse
|
||||
|
||||
@@ -57,10 +57,22 @@ def list_statements(
|
||||
col(User.id).in_({r.investor_user_id for r in rows})
|
||||
)
|
||||
).all()) if rows else {}
|
||||
# And each (investor, entity)'s exit date, so a sold/transferred stake renders as
|
||||
# "Exited" instead of a phantom -100% loss.
|
||||
exits = {
|
||||
(a.user_id, a.entity_id): a.exited_on
|
||||
for a in session.exec(
|
||||
select(EntityAccess).where(
|
||||
col(EntityAccess.user_id).in_({r.investor_user_id for r in rows}),
|
||||
col(EntityAccess.exited_on).is_not(None),
|
||||
)
|
||||
).all()
|
||||
} if rows else {}
|
||||
out: list[CapitalAccountResponse] = []
|
||||
for r in rows:
|
||||
data = CapitalAccountResponse.model_validate(r, from_attributes=True)
|
||||
data.investor_name = names.get(r.investor_user_id)
|
||||
data.exited_on = exits.get((r.investor_user_id, r.entity_id))
|
||||
out.append(data)
|
||||
return out
|
||||
|
||||
|
||||
Reference in New Issue
Block a user