Add UK Gift Aid support with PolicyEngine-UK#66
Conversation
This PR adds UK tax calculation support to GiveCalc, enabling UK users to calculate the tax impact of charitable donations via Gift Aid. ## Changes ### New UK Module (`givecalc/uk/`) - `constants.py`: UK-specific constants (tax year, regions) - `situation.py`: Creates PolicyEngine-UK situations with donation axes - `tax.py`: UK tax calculations (marginal savings, donation effects) ### API Endpoints (`api/main.py`) - `GET /api/uk/regions`: List UK regions grouped by nation - `GET /api/uk/tax-programs`: Gift Aid program information - `POST /api/uk/calculate`: Calculate UK tax impact of Gift Aid donations ### Schemas (`api/schemas.py`) - `UKIncomeInput`, `UKCalculateRequest`, `UKCalculateResponse` - `UKRegionInfo`, `UKRegionsResponse` - `UKDonationDataPoint`, `UKTaxProgramsResponse` ### Dependencies - Added `policyengine-uk>=2.45.0,<2.55.0` (Python 3.12 compatible) - Includes workaround for policyengine-uk dataset attribute bug ## UK Tax System Details Gift Aid provides tax relief in two ways: 1. Charities reclaim 25p per £1 donated (basic rate relief at 20%) 2. Higher rate (40%+) taxpayers claim additional relief personally Supports all UK regions including Scotland (with different tax rates). ## Testing 47 new tests covering: - UK situation creation (18 tests) - UK tax calculations (14 tests) - UK API endpoints (13 tests) All 80 tests pass (existing + new). Closes #58 Related: #60, #61, #62, #63 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Update requires-python to >=3.13,<3.14 - Update policyengine-uk to >=2.55.0 (now 2.62.1) - Remove workaround for dataset attribute bug (fixed in 2.55.0+) - Update black target-version to py313 only 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Drop Python 3.11 and 3.12 support in CI to match pyproject.toml requirement. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Required by FastAPI TestClient (starlette.testclient). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The uv run command creates a fresh virtual environment which doesn't see packages installed via uv pip install --system. Using pytest directly uses the system Python where dev dependencies were installed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add country selector toggle (US/UK) with flag icons - Create UKInputForm component with: - Region selector (grouped by nation) - Employment/self-employment income inputs - Gift Aid donation amount with gross-up display - Scottish tax rate indicator - Add UK types, API functions, and React Query hooks - Update Results component to support GBP currency formatting - Update formatCurrency utility to handle USD/GBP 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This version includes the Gift Aid Personal Allowance taper fix (PolicyEngine/policyengine-uk#1430) required for accurate UK tax calculations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Merged latest changes from main including: - STATES constant for instant load - Tax programs data module - Vercel config moved to frontend Resolved conflicts in: - useCalculation.ts: Combined UK hooks with STATES/taxPrograms imports - pyproject.toml: Added policyengine-uk>=2.63.0 with plotly - uv.lock: Regenerated with all dependencies 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
MaxGhenis
left a comment
There was a problem hiding this comment.
Review: Vercel Deployment Setup
I noticed the Vercel deployment is running on this PR. There was a recent issue where Vercel needs the Root Directory set to frontend in the Vercel dashboard (not in vercel.json) to avoid hitting the 250MB serverless function limit.
What happened with the Vercel setup:
- The
vercel.jsonfile was moved from repo root tofrontend/vercel.json(PR #69) - The Root Directory must be set to
frontendin the Vercel dashboard settings (Project Settings → Root Directory)
To fix Vercel deployments for this branch:
- First, check if the vercel.json exists at
frontend/vercel.json- if not, you need to add it:
{
"buildCommand": "npm install && npm run build",
"outputDirectory": "dist",
"framework": "vite",
"installCommand": "npm install"
}-
Make sure there's NO vercel.json in the repository root - Vercel should only look at the frontend folder
-
The Vercel dashboard should have Root Directory =
frontend
What likely went wrong:
If there's still a vercel.json at the root OR if the dashboard Root Directory isn't set, Vercel will try to deploy the entire repo including the Python api/ folder, which exceeds the 250MB limit.
Check your branch to ensure vercel.json is ONLY in frontend/ and not at the repo root.
MaxGhenis
left a comment
There was a problem hiding this comment.
Update: I checked your branch - the vercel.json setup looks correct:
- ✅ No vercel.json at repo root
- ✅
frontend/vercel.jsonexists with correct config
The Vercel deployment should work as long as the Vercel dashboard has Root Directory set to frontend. If it wasn't set before, you may need to wait for Vercel to re-deploy or trigger a new deployment after confirming the dashboard setting.
Everything else in the PR looks good - comprehensive UK Gift Aid support with 47 new tests!
Summary
This PR adds UK tax calculation support to GiveCalc, enabling UK users to calculate the tax impact of charitable donations via Gift Aid.
Dependencies
Blocked by: PolicyEngine/policyengine-uk#1430 - Fix Gift Aid Personal Allowance taper interaction
This PR depends on the policyengine-uk fix for Gift Aid PA taper calculation. Once that PR is merged and released, the policyengine-uk version constraint here can be updated.
Changes
New UK Module (
givecalc/uk/)constants.py: UK-specific constants (tax year, regions)situation.py: Creates PolicyEngine-UK situations with donation axestax.py: UK tax calculations (marginal savings, donation effects)API Endpoints (
api/main.py)GET /api/uk/regions: List UK regions grouped by nationGET /api/uk/tax-programs: Gift Aid program informationPOST /api/uk/calculate: Calculate UK tax impact of Gift Aid donationsSchemas (
api/schemas.py)UKIncomeInput,UKCalculateRequest,UKCalculateResponseUKRegionInfo,UKRegionsResponseUKDonationDataPoint,UKTaxProgramsResponseDependencies
policyengine-uk>=2.45.0,<2.55.0(Python 3.12 compatible)UK Tax System Details
Gift Aid provides tax relief in two ways:
Example for a £100 donation by a 40% taxpayer:
Supports all UK regions including Scotland (with different income tax rates).
Testing
47 new tests covering:
All 80 tests pass (existing + new).
Related Issues
Closes #58 (parent issue)