First create an instance of Calculator
, passing in the values as per the following example:
val calculator = Calculator(
taxCode = "1250L", // Required
wages = 20000.0, // Required
payPeriod = YEARLY, // Required
isPensionAge = false, // Optional (Default: false)
hoursPerWeek = null, // Optional (Default: null)
taxYear = 2019 // Optional (Default: Current Tax Year)
)
The default values are working in Android (and other JVM) but currently do not seem to be present in iOS, so pass in the default values for now.
Run calculations by calling run()
:
val response = calculator.run()
This will returns an object of type CalculatorResponse
. This class is broken up into weekly, four_weekly, monthly and yearly. Each of these members is of type CalculatorResponsePayPeriod
and the members of this class are what will return the values (relative to their PayPeriod) needed for the app, they are:
taxToPay: Double
employeesNI: Double
employersNI: Double
wages: Double
taxBreakdown: List<BandBreakdown>
taxFree: Double
totalDeductions: Double
takeHome: Double
For tax breakdown this is the amount of tax per tax band which has two members,
percentage: Double
andamount: Double
.
To validate a tax code:
val isValid = Calculator.isValidTaxCode("1250L") // true
To validate wages:
val isAboveMinimumWages = Calculator.isAboveMinimumWages(0.0) // false
val isBelowMaximumWages = Calculator.isBelowMaximumWages(120000.0) // true
To validate hours worked per week:
val isAboveMinimumHoursPerWeek = Calculator.isAboveMinimumHoursPerWeek(1.0) // true
val isBelowMaximumHoursPerWeek = Calculator.isBelowMaximumHoursPerWeek(170.0) // false
To run unit tests and checks:
./gradlew check
To update the README badges:
./gradlew cleanBuildTestCoverage
Add the framework to the project. All dependencies are bundled!
Add the mobile-releases bintray repository to your top-level build.gradle
:
repositories {
maven {
url "https://hmrc.bintray.com/mobile-releases"
}
}
Add the dependency in the build.gradle
of the module:
dependencies {
implementation "uk.gov.hmrc:tax-kalculator-jvm:x.y.z"
}