-
Notifications
You must be signed in to change notification settings - Fork 31
Add firm-level VAT implementation #1322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Create Firm entity with owner role - Add VAT registration thresholds (£90k) and rates - Implement VAT calculation variables for firms - Add comprehensive tests for firm entity and VAT logic Fixes #1320
|
The test failure appears to be unrelated to the firm VAT implementation. The error is an ImportError with the 'tables' module in test_reform_impacts.py: All the firm VAT tests passed successfully (5 tests in test_firm_vat.py). This seems to be an existing CI issue with the pytables dependency on macOS. |
The test_reform_impacts.py test was failing in CI because it tries to instantiate a Microsimulation which loads data from HDF5 files, requiring the tables package. This was working before but missing from explicit dependencies.
The test_validity.py test expects all entities to have a weight variable. Added firm_weight and firm_count variables to support microsimulation weighting.
Firm entity should not be in group_entities as it's not part of the household hierarchy and we don't have firm microdata for simulations. This was causing the reform impact tests to produce different results.
YAML test files don't include firm data, so we need to make firm populations optional. Only create firm populations when firm data is explicitly provided in the situation.
This reverts commit 005b5f7.
This reverts commit f86cd48.
Firm entity and variables exist but are not included in default entity list to avoid issues with YAML tests that don't provide firm data. Firm simulations will need to explicitly add the Firm entity.
CI Status UpdateThe firm-level VAT implementation is structurally complete but faces integration challenges with the existing test infrastructure: What's Implemented ✅
Integration Challenge
|
Changed 'if' to 'when' to make it clear registration is mandatory when taxable turnover exceeds the threshold, not optional.
- Added defined_for="firm_vat_registered" to VAT calculation variables since only registered firms charge/pay/reclaim VAT - Reworded deregistration threshold to describe requirement to remain registered above the threshold, for consistency with registration threshold
Changed from 'vat_params' and 'threshold' to use 'p' for accessing parameter subtrees, following PolicyEngine coding conventions.
Zero rate is always 0% by definition, so we don't need a parameter file. Updated firm_vat_on_sales to only calculate VAT on standard and reduced rated supplies.
|
@nikhilwoodruff @vahid-ahmadi could you take a look to see how we can pass the tests? Adding a new entity type seems to cause some issues. |
|
Superseded by #1332 |
Summary
Implements firm-level VAT logic for PolicyEngine UK, enabling modeling of VAT at the business level with registration thresholds and rate calculations.
Changes
Firmentity with owner role linking to personsfirm_turnover: Annual business turnoverfirm_vat_registered: Registration status based on thresholdfirm_standard_rated_supplies: Supplies at 20% ratefirm_reduced_rated_supplies: Supplies at 5% ratefirm_zero_rated_supplies: Supplies at 0% ratefirm_vat_on_sales: Output VAT calculationfirm_vat_on_purchases: Input VATfirm_net_vat_liability: Net VAT (output - input)Testing
Use Cases
This enables PolicyEngine to:
Fixes #1320
🤖 Generated with Claude Code