Skip to content

.NET Standard version of HMRC-compliant PAYE, National Insurance, and related calculators. Core components for building payroll services.

License

Notifications You must be signed in to change notification settings

kurt-hardy/Coda.Payroll

 
 

Repository files navigation

Coda.Payroll

Coda.Payroll is a .NET Standard version of HMRC-compliant PAYE, National Insurance, and related calculators. Core components for building payroll services.

Formerly Cedita.Payroll, now operated and managed by Coda Technology, an innovative payroll solutions company.

Usage

Version 2 comes with a revised API meaning there's less wiring up to do, and is also DI first (whilst retaining ease to wire up manually).

To get started, install from NuGet:

Install-Package Coda.Payroll

If you're using ASP.NET Core (or any IServiceCollection compatible DI library), just call:

services.AddCodaPayroll();

Calculate Payroll for a Pay Period

To calculate both PAYE Tax and National Insurance in a few lines of code using the V2 Payroll Calculation API, let's take a look at a basic example:

// ctor
..(IPayrollCalculatorFactory payrollCalculatorFactory)
{
   payrollCalculator = payrollCalculatorFactory.CreatePayrollCalculator(2018);
}

// implementation
var calcRequest = new PayrollCalculationRequest
{
    PayFrequency = PayPeriods.Weekly,
    PayPeriod = 3,
    TaxCode = TaxCode.Parse("1185L"),
    IsWeek1Month1 = true,
    TaxableGross = 500,
    NiableGross = 500
};

var result = payrollCalculator.Calculate(calcRequest);
// Tax - result.Paye.Tax
// NI - result.NationalInsurance.NetNi
// Ee NI result.NationalInsurance.EmployeeNi
// Er NI result.NationalInsurance.EmployerNi

Calculate Tax Due for Pay Period (PAYE only)

Of course, you can also continue to calculate individually not unlike the V1 API, it just takes a little bit less wiring up.

To calculate the tax due for any specific period would take 2 lines of code once wired up and injected via your DI container (see above for single line).

// Where DI is used
public decimal CalculateTax(IPayeCalculationEngineFactory payeFactory)
{
    var payeEngine = payeFactory.CreatePayeCalculationEngine(2018); // Specify tax year
    var taxDueInPeriod = payeEngine.CalculateTaxDueForPeriod("1185L", 5000, PayPeriods.Monthly, 1);
    
    // ..
}

About

.NET Standard version of HMRC-compliant PAYE, National Insurance, and related calculators. Core components for building payroll services.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%