fix: preserve correction and legacy authority semantics
This commit is contained in:
@@ -573,8 +573,10 @@ def get_asset_snapshot_report(basis_date: str = "", selection_policy: str = "exa
|
||||
basis = normalize_date(basis_date, default_today=True) if basis_date else current_kst_date().isoformat()
|
||||
with db(db_path) as conn:
|
||||
rows, close_metadata = _snapshot_rows_for_latest_run(conn, basis)
|
||||
has_close_run = bool(close_metadata.get("snapshot_run_id"))
|
||||
snapshots = _snapshot_items(conn, basis) if rows else []
|
||||
if close_metadata:
|
||||
legacy_snapshots = snapshots if rows and not has_close_run else []
|
||||
if has_close_run:
|
||||
summary = _summarize_valuation_items(snapshots, [])
|
||||
return ok(
|
||||
basis_date=basis,
|
||||
@@ -590,6 +592,19 @@ def get_asset_snapshot_report(basis_date: str = "", selection_policy: str = "exa
|
||||
manual_items, manual_excluded = _manual_asset_valuation_items(conn, basis_date=basis, selection_policy=selection_policy)
|
||||
included = account_items + manual_items
|
||||
excluded = account_excluded + manual_excluded
|
||||
if not included and not excluded and legacy_snapshots:
|
||||
summary = _summarize_valuation_items(legacy_snapshots, [])
|
||||
return ok(
|
||||
basis_date=basis,
|
||||
source="legacy_asset_snapshots",
|
||||
selection_policy=selection_policy,
|
||||
close_status="legacy_read_only",
|
||||
is_closed_snapshot=False,
|
||||
snapshot_count=len(legacy_snapshots),
|
||||
legacy_snapshot_row_count=len(legacy_snapshots),
|
||||
close_metadata={"legacy": True, "snapshot_run_id": ""},
|
||||
**summary,
|
||||
)
|
||||
summary = _summarize_valuation_items(included, excluded)
|
||||
return ok(
|
||||
basis_date=basis,
|
||||
@@ -598,6 +613,7 @@ def get_asset_snapshot_report(basis_date: str = "", selection_policy: str = "exa
|
||||
close_status="incomplete_draft" if excluded else "complete_exact",
|
||||
is_closed_snapshot=False,
|
||||
snapshot_count=0,
|
||||
legacy_snapshot_row_count=len(legacy_snapshots),
|
||||
invalid_bucket_accounts=invalid_bucket_accounts,
|
||||
**summary,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user