Extended Functions
For developing extensive and complex regulations, the engine's runtime functions can be extended with custom C# classes. This is an advanced pattern typically used by Regulation Developers or Automators — it requires a .NET development environment. Standard No-Code and Low-Code regulation work does not require this.
Externalizing functions offers several advantages:
- Code can be reused by higher-level regulations
- Development in professional IDEs (syntax highlighting, IntelliSense, etc.)
- Debug support for case and report scripts
- Better integration with version control systems
The implementation involves three steps: 1. Implement the business functions in C# 2. Register the function extension 3. Use the extended functionality
Composite Function
The business functions are C# classes that receive the WageTypeValueFunction as a constructor argument:
using System;
using PayrollEngine.Client.Scripting.Function;
namespace ExtendedPayroll.Scripts;
public class CompositeWageTypeValueFunction
{
private WageTypeValueFunction Function { get; }
public CompositeWageTypeValueFunction(WageTypeValueFunction function) // constructor
{
Function = function ?? throw new ArgumentNullException(nameof(function));
}
public decimal GetSalary() // custom wage type value method
{
return Function.CaseValue["Salary"];
}
}
Function Registration
In the next step, WageTypeValueFunction is extended using partial to expose access to the composite type:
using ExtendedPayroll.Scripts;
namespace PayrollEngine.Client.Scripting.Function;
public partial class WageTypeValueFunction // extend with partial
{
private CompositeWageTypeValueFunction function;
public CompositeWageTypeValueFunction MyRegulation => function ??= new(this); // expose composite
}
Extended Function Usage
The extension class can be used in the wage type ValueExpression:
"wageTypes": [
{
"wageTypeNumber": 100,
"name": "Salary",
"valueExpression": "MyRegulation.GetSalary()" // call extended function
}
]
The extension can be verified with the Payroll Console:
PayrollConsole PayrunEmployeeTest Test.et.json
Next Steps
- Examples — payroll examples and demos
- Client Tutorials — SDK tutorials