paye 1.0.5
paye: ^1.0.5 copied to clipboard
A Dart package for calculating PAYE (Pay As You Earn) tax and pension contributions.
PayE Dart Implementation #
A complete Dart implementation of the PayE payroll and pension management system, featuring progressive subtraction tax calculation and comprehensive payroll reporting.
Features #
- Multi-country support with configurable tax brackets
- Progressive subtraction tax calculation where threshold amounts are progressively subtracted from basic salary
- Flexible salary calculation supporting both basic salary and piece-rate work
- Pension contribution calculations with configurable tiered allocation
- Detailed payroll reporting with step-by-step tax calculation breakdown
- Configurable salary splitting between basic salary and allowances
- No automatic sorting - tax brackets are processed in the exact order they were entered
Progressive Subtraction Tax Calculation #
The system implements a progressive subtraction tax calculation where:
- Each threshold amount gets taxed at its respective rate
- Threshold amounts are progressively subtracted from the basic salary
- Tax calculation: Each threshold amount × its tax rate = tax for that amount
- PAYE tax: Sum of all calculated tax amounts
- Net salary: Original salary minus total tax
Example Tax Bracket Setup: #
Threshold 490: 0% tax = 0.00 tax
Threshold 110: 5% tax = 5.50 tax
Threshold 130: 10% tax = 13.00 tax
Threshold 3166: 17.5% tax = 554.05 tax
Threshold 16000: 25% tax = 4,000.00 tax
Threshold 30520: 30% tax = 9,156.00 tax
Progressive Subtraction Example: #
Starting salary: 50,416.67
- Subtract 490 → Remaining: 49,926.67, Tax: 0.00
- Subtract 110 → Remaining: 49,816.67, Tax: 5.50
- Subtract 130 → Remaining: 49,686.67, Tax: 13.00
- Subtract 3166 → Remaining: 46,520.67, Tax: 554.05
- Subtract 16000 → Remaining: 30,520.67, Tax: 4,000.00
- Subtract 30520 → Remaining: 0.00, Tax: 9,156.00
Total PAYE Tax: 13,728.55
Project Structure #
PayE_Dart/
├── lib/
│ ├── main.dart # Main application entry point
│ ├── types.dart # Core data structures
│ ├── payroll.dart # Payroll and tax calculations
│ └── pension.dart # Pension calculations
├── pubspec.yaml # Dart project configuration
└── README.md # This file
Installation #
- Install Dart SDK (version 3.0.0 or higher)
- Clone or download the PayE_Dart folder
- Navigate to the project directory:
cd PayE_Dart - Get dependencies:
dart pub get
Usage #
Run the Application #
dart run lib/main.dart
Interactive Setup Process #
-
Pension Tier Setup
- Enter custom pension tiers (total must equal 100%)
- Or use default tiers if total doesn't reach 100%
-
Country Setup
- Enter country code (3 letters)
- Enter country name and minimum wage
- Set up tax brackets (threshold amounts and rates)
- Minimum wage automatically gets 0% tax rate
-
Salary Configuration
- Enable/disable salary splitting
- Configure basic salary and allowance ratios
-
Employee Setup
- Enter employee details
- Set basic salary and/or piece-rate work
- Assign country code
-
Payroll Processing
- Automatic tax calculation using progressive subtraction
- Pension calculations with tier allocations
- Comprehensive payroll reports
Key Classes #
Employee #
- Basic salary, piece-rate work, country information
- Automatic calculation of total earnings
TaxBracket #
- Threshold amount and tax rate
- No automatic sorting - preserves input order
PensionCalculator #
- Employee and employer contributions
- Tier-based allocation system
- Configurable contribution rates
PayrollCalculator #
- Progressive subtraction tax calculation
- Salary and piece-rate calculations
- Comprehensive reporting functions
Tax Calculation Algorithm #
// Progressive subtraction: each threshold amount is subtracted from basic salary
double remainingSalary = originalSalary;
for (final bracket in enhancedBrackets) {
if (remainingSalary >= bracket.threshold) {
// Tax at the threshold rate for the full threshold amount
taxAmount = bracket.threshold * (bracket.rate / 100);
remainingSalary -= bracket.threshold;
} else if (remainingSalary > 0) {
// Apply the same rate to the remaining salary
taxAmount = remainingSalary * (bracket.rate / 100);
remainingSalary = 0;
}
totalTax += taxAmount;
}
Example Output #
Progressive Subtraction Tax Calculation Steps:
Step | Remaining Salary | Subtract Amount | Tax Rate | Tax Amount
-----|------------------|----------------|----------|-----------
1 | 50416.67 | 490.00 | 0.0% | 0.00
2 | 49926.67 | 110.00 | 5.0% | 5.50
3 | 49816.67 | 130.00 | 10.0% | 13.00
4 | 49686.67 | 3166.00 | 17.5% | 554.05
5 | 46520.67 | 16000.00 | 25.0% | 4000.00
6 | 30520.67 | 30520.00 | 30.0% | 9156.00
Total Tax: 13728.55
Dependencies #
- Dart SDK: >=3.0.0
- args: ^2.4.0 (for command-line argument parsing)
Development #
Run Tests #
dart test
Format Code #
dart format .
Analyze Code #
dart analyze
Differences from Go Implementation #
- Immutable vs Mutable: Dart classes use mutable fields for runtime modifications
- Records: Uses Dart 3.0+ records for returning multiple values
- Null Safety: Full null safety implementation
- Collections: Uses Dart's built-in collection methods (fold, map, etc.)
- String Interpolation: Modern Dart string interpolation syntax
License #
[Add your license information here]