Skip to content

Commit fe87dca

Browse files
Fix FSA/DCFSA expenses missing plan_year_id validation
Add fallback to convert FSA/DCFSA expenses to HSA if no matching plan_year exists for that category/year combination. This prevents CHECK constraint violations during import. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent b073748 commit fe87dca

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

scripts/generate_test_data.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,16 @@ def generate_test_data():
588588
if status in ['Pending', 'Reimbursed', 'Partially Reimbursed'] and random.random() < 0.7:
589589
claim_number = f"CLM{year}{str(expense_id).zfill(6)}"
590590

591-
# Plan year ID for FSA/DCFSA
591+
# Plan year ID for FSA/DCFSA - REQUIRED for these categories
592592
plan_year_id = None
593593
if category in ['FSA', 'DCFSA']:
594594
plan_year_id = plan_year_lookup.get((category, year))
595+
# Validate: FSA/DCFSA MUST have a plan_year_id
596+
if plan_year_id is None:
597+
# Fall back to HSA if no plan year exists for this category/year
598+
category = 'HSA'
599+
status = 'Open'
600+
amount_inflow = 0
595601

596602
# Payment date
597603
date_of_payment = None

0 commit comments

Comments
 (0)