Save vs Readiness Table Trace
Summary
Both paths use the SAME endpoint and write to the SAME tables with the SAME effective dating logic.Write Path
Endpoint
- Both admin drawer and wizard drawer use:
/api/v1/admin/onboarding/businesses/{id}/save - Client method:
businessOnboardingClient.saveBusinessConfig() - Backend handler:
save_business_config_endpoint()inapi/routes/business_onboarding.py - BigQuery function:
save_business_config()inapi/bigquery/business_onboarding_queries.py
Tables Written
-
config_business_agent_assignment- Written when
mode = 'AGENT_PEPM' - Fields:
effective_start_date,effective_end_date(NULL for new rows) - Org context:
org_id(NULL for SHARED, org_id for ORG_SCOPED)
- Written when
-
config_business_agent_pepm_assignment- Written when
mode = 'AGENT_PEPM' - Fields:
effective_start_date,effective_end_date(NULL for new rows) - Org context:
org_id(NULL for SHARED, org_id for ORG_SCOPED)
- Written when
-
config_business_policy- Written when
mode = 'OWNER_ROLLUP' - Fields:
effective_start_date,effective_end_date(NULL for new rows) - Org context:
org_id(NULL for SHARED, org_id for ORG_SCOPED)
- Written when
Effective Start Date Logic
Source (fromapi/routes/business_onboarding.py:1736-1755):
effective_start_date (DATE type, parsed from YYYY-MM-DD string)
- If
request.effective_start_dateprovided → use it - Else if
request.period_labelprovided → use it (defaults to period_label) - Format: YYYY-MM-DD (parsed to DATE)
period_label = "2026-02-01" and effective_start_date is missing:
- Written:
effective_start_date = DATE('2026-02-01')
Read Path (Readiness Query)
Query Function
- Function:
get_business_readiness()inapi/bigquery/business_onboarding_queries.py - Called by:
/api/v1/intake/ingestion-wizard/readinessendpoint
Tables Read
-
config_business_onboarding- Source for business list
- Org filter:
(scope = 'SHARED' OR (scope = 'ORG_SCOPED' AND owning_org_id = @org_id))
-
config_business_agent_assignment- Filter:
effective_start_date <= @as_of_date AND (effective_end_date IS NULL OR effective_end_date >= @as_of_date) - Org filter:
(org_id = @org_id OR org_id IS NULL)
- Filter:
-
config_business_agent_pepm_assignment- Filter:
effective_start_date <= @as_of_date AND (effective_end_date IS NULL OR effective_end_date >= @as_of_date) - Org filter:
(org_id = @org_id OR org_id IS NULL)
- Filter:
-
config_business_policy- Filter:
effective_start_date <= @as_of_date AND (effective_end_date IS NULL OR effective_end_date >= @as_of_date) - Org filter:
(org_id = @org_id OR org_id IS NULL)
- Filter:
Effective Date Filter Logic
Source (fromapi/bigquery/business_onboarding_queries.py:224-230):
@as_of_date (DATE type, normalized from period_label)
- Input:
period_label(YYYY-MM-01 format) - Normalized:
normalize_period_for_bigquery(period_label)→ DATE - Format: YYYY-MM-01 → DATE (first day of month)
period_label = "2026-02-01":
- Read filter:
effective_start_date <= DATE('2026-02-01') AND (effective_end_date IS NULL OR effective_end_date >= DATE('2026-02-01'))
Comparison
✅ Tables Match
- Write:
config_business_agent_assignment,config_business_agent_pepm_assignment,config_business_policy - Read: Same tables
✅ Effective Dating Logic Matches
- Write:
effective_start_date <= @as_of_date AND (effective_end_date IS NULL OR effective_end_date >= @as_of_date) - Read: Same filter
⚠️ Potential Mismatch: Date Normalization
Write:- Accepts
effective_start_dateas YYYY-MM-DD (any day of month) - Defaults to
period_label(YYYY-MM-01) if missing - Written as DATE (preserves day)
- Uses
period_label(YYYY-MM-01) normalized to DATE - Filter:
effective_start_date <= DATE(period_label)
- Write:
effective_start_date = "2026-02-15"(mid-month)- Written:
effective_start_date = DATE('2026-02-15')
- Written:
- Read:
period_label = "2026-02-01"- Filter:
effective_start_date <= DATE('2026-02-01') - Result: Row NOT matched (2026-02-15 > 2026-02-01)
- Filter:
effective_start_date is omitted and defaults to period_label:
- Write:
effective_start_datemissing,period_label = "2026-02-01"- Written:
effective_start_date = DATE('2026-02-01')
- Written:
- Read:
period_label = "2026-02-01"- Filter:
effective_start_date <= DATE('2026-02-01') - Result: Row matched ✅
- Filter:
Frontend Effective Date Derivation
Source (fromdashboard/src/components/admin/onboarding/BusinessDetailDrawer.tsx:292-323):
BusinessDetailDrawer.tsx:738):
effectiveStartDate is always periodLabel (YYYY-MM-01 format), which is then passed to buildRequestPayload() and sent to the API.
Conclusion
✅ Both paths write to the same tables with the same effective dating logic. ✅ Effective date matching:- Write:
effective_start_datedefaults toperiodLabel(YYYY-MM-01) viaderiveDefaultEffectiveStart() - Read: Uses
periodLabel(YYYY-MM-01) normalized to DATE as@as_of_date - Result: Perfect match ✅
- Write:
config_business_agent_assignment,config_business_agent_pepm_assignment,config_business_policy - Read: Same tables
- Write:
effective_start_date = DATE(periodLabel)(YYYY-MM-01) - Read:
effective_start_date <= DATE(periodLabel) AND (effective_end_date IS NULL OR effective_end_date >= DATE(periodLabel)) - Result: Row written with
effective_start_date = DATE('2026-02-01')will match read filtereffective_start_date <= DATE('2026-02-01')✅