"""Download worked-scenarios.json beside this file; run with Python 3. Standard library only. All scenarios are fictional, not eligibility determinations. """ import json from pathlib import Path from datetime import date from decimal import Decimal d = json.loads(Path(__file__).with_name('worked-scenarios.json').read_text()) model = d['oncall'] for key in ['a', 'b']: x = model[key] cash = x['base'] + x['rotation_weeks'] * x['stipend_per_week'] hours = model['ordinary_hours'] * model['ordinary_working_weeks'] + x['rotation_weeks'] * x['extra_active_hours_per_week'] assert cash == x['expected_cash'] and hours == x['expected_active_hours'] print('Offer', key.upper(), cash, hours, round(cash / hours, 2)) x = d['coverage'] old, new, first, last = [date.fromisoformat(x[k]).toordinal() for k in ['old_end', 'new_start', 'bridge_start', 'bridge_end']] between = max(0, new - old - 1) overlap = max(0, min(new - 1, last) - max(old + 1, first) + 1) assert (between, overlap, between - overlap) == (x['expected_between'], x['expected_bridge_overlap'], x['expected_outside']) print('Coverage dates: between, overlap, outside', between, overlap, between - overlap) x = d['premium'] total = Decimal(str(x['full_monthly_premium'])) * (1 + Decimal(str(x['administration_fraction']))) * x['assumed_full_billing_months'] difference = total - x['old_employee_monthly_deduction'] * x['assumed_full_billing_months'] assert total == x['expected_total'] and difference == x['expected_difference'] print('Fictional premium total and difference:', total, difference)