Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var TaxBandsByYear = map[int]*Bands{ 2024: { IncomeTax: &TaxBands{ Duration: Year, Bands: []*TaxBand{ {Minimum: 0, Rate: 0.2}, {Minimum: 37700, Rate: 0.4}, {Minimum: 125140, Rate: 0.45}, }, }, NicEmployeeTax: &TaxBands{ Duration: Month, Bands: []*TaxBand{ {Minimum: 1048, Rate: 0.08}, {Minimum: 4189, Rate: 0.02}, }, }, NicEmployerTax: &TaxBands{ Duration: Month, Bands: []*TaxBand{ {Minimum: 758, Rate: 0.138}, }, }, PensionQualifiedEarnings: &TaxBand{ Minimum: 6240, Maximum: 50270, }, }, 2025: { IncomeTax: &TaxBands{ Duration: Year, Bands: []*TaxBand{ {Minimum: 0, Rate: 0.2}, {Minimum: 37700, Rate: 0.4}, {Minimum: 125140, Rate: 0.45}, }, }, NicEmployeeTax: &TaxBands{ Duration: Month, Bands: []*TaxBand{ {Minimum: 1048, Rate: 0.08}, {Minimum: 4189, Rate: 0.02}, }, }, NicEmployerTax: &TaxBands{ Duration: Month, Bands: []*TaxBand{ {Minimum: 417, Rate: 0.15}, }, }, PensionQualifiedEarnings: &TaxBand{ Minimum: 6240, Maximum: 50270, }, }, }
Note that for now, the 2025 figures are just copies of 2024.
Functions ¶
This section is empty.
Types ¶
type Bands ¶
type NumberRate ¶
Number rate models a number per duration. E.g £10,000 /year.
func (NumberRate) Per ¶
func (self NumberRate) Per(rate Duration) NumberRate
Convert this NumberRate to a given duration.
func (NumberRate) String ¶
func (self NumberRate) String() string
type Payslip ¶
type Payslip struct { // The tax year. So if the tax year is 2024/25, set this to be // 2024. If you leave this blank then the tax year will be // calcualed correctly from the Previous payslip. Year is 0 and // Previous is nil, then Year will be set to the current year. Year int // If this is month 1 (i.e. April), then Previous may be nil. In // all other cases, Previous must point to the payslip for the // Previous month. Previous *Payslip // The month of the tax year; 1-based. If 0 and Previous is nil, // then will be set to 1. If 0 and Previous is not nil, then will // be set to (Previous.Month % 12) + 1. Month int // Input; if zero, will copy from Previous TaxCode TaxCode // Input only. The zero value is fine to use as an income of 0. Salary NumberRate // Input only. Expenses are not included in any tax calculations. Expenses float64 // Output only GrossIncome float64 // Output only GrossIncomeYTD float64 // Input only PensionType PensionType // Input or output - exactly one of EmployeePensionContributionRate // and EmployeePensionContribution must be provided. EmployeePensionContributionRate float64 // Input or output - exactly one of EmployeePensionContributionRate // and EmployeePensionContribution must be provided. EmployeePensionContribution float64 // Output only EmployeePensionContributionYTD float64 // The employer side of pension contributions. Follows the same // rules as for the corresponding employee pension fields. EmployerPensionContributionRate float64 EmployerPensionContribution float64 EmployerPensionContributionYTD float64 // Output only PensionContributionYTD float64 // Output only TaxableIncome float64 // Output only TaxableIncomeYTD float64 // Output only PersonalAllowanceYTD float64 // Output only NetTaxableIncomeYTD float64 // Output only IncomeTaxYTD float64 // Input or output IncomeTax float64 // Output only EmployeeNicTax float64 // Output only EmployeeNicTaxYTD float64 // Output only EmployerNicTax float64 // Output only EmployerNicTaxYTD float64 // Output only NetIncome float64 // Output only NetIncomeYTD float64 }
Payslip models a monthly payslip. Some fields must be provided prior to calling *Payslip.Complete, some fields can be provided (which is helpful if you wish to provide numbers from actual payslips you've received), and some fields are output only.
func (*Payslip) CloseYear ¶
func (self *Payslip) CloseYear() *YearSummary
CloseYear produces a YearSummary based on the year-to-date figures in the Payslip. Normally you'd only call this on a payslip with Month 12 (i.e. March).
func (*Payslip) Complete ¶
func (self *Payslip) Complete()
Complete attempts to fill in all missing fields in this Payslip. If this Payslip is month 1 (i.e. April) then Previous can be nil. In all other cases Previous should point to the Payslip for the previous month.
func (*Payslip) FormattedDate ¶
FormattedDate returns a string such as "January 2006" for this Payslip's year and month.
type Payslips ¶
type Payslips []*Payslip
Payslips is the easy way to build a sequence of [*Payslip]s. The oldest payslip must be month 1 and must be at index 0. The payslips should form a contiguous sequence with no months missing.
func (Payslips) Complete ¶
func (self Payslips) Complete()
Complete completes all the payslips, in the right order. It also sets up the Previous field correctly, so you don't need to do that explicitly.
func (Payslips) String ¶
String produces a really nice string of the details of all the payslips, and *YearSummary for every month 12 payslip.
type PensionType ¶
type PensionType uint8
const ( // Pension contribution rates are interpreted as being a fraction // of the month's salary. Salary PensionType = iota // Pension contributino rates are interpreted as being a fraction // of the month's qualifying earnings. This seems to be // increasingly common for auto-enrolment pensions in the UK. QualifyingEarnings )
func (PensionType) String ¶
func (self PensionType) String() string
type TaxBand ¶
TaxBand represents a tax band that applies Rate between the Minimum and Maximum bounds.
type TaxBands ¶
TaxBands model a set of TaxBands. The individual bands must be non-overlapping. It is best to define individual bands with only their Minimums set; the call to *TaxBands.Init will sort the bands, and populate the Maximum field.
func (*TaxBands) Init ¶
func (self *TaxBands) Init()
Init sets up TaxBands for use by sorting them (by the Minimum field, ascending), and by setting the Maximum of any band to be the Minimum of its successor. The Maximum of the last band is set to +Inf.
func (TaxBands) InvertedTax ¶
func (self TaxBands) InvertedTax(tax NumberRate) NumberRate
From an amount of tax paid, figure out what the amount must have been.
func (TaxBands) Tax ¶
func (self TaxBands) Tax(amount NumberRate) NumberRate
Calculate the tax due (to be paid) on an amount.
type TaxCode ¶
type TaxCode string
func (TaxCode) PersonalAllowance ¶
func (self TaxCode) PersonalAllowance() NumberRate
Calculate the Personal Allowance of a Tax Code. Note that this currently only copes with Tax Codes that end with L.
type YearSummary ¶
type YearSummary struct { Year int LastPayslip *Payslip TaxableIncome float64 PersonalAllowance float64 NetTaxableIncome float64 IncomeTax float64 IncomeTaxOwing float64 NetIncome float64 }
YearSummary can be thought as as similar to a P60. It identifies over- or under-payment of tax (over-payment is far more likely with PAYE).
func (*YearSummary) String ¶
func (summary *YearSummary) String() string