Class PayrunEndFunction
Executes once at the end of a payrun, after all employees have been processed.
Implements
Inherited Members
Namespace: PayrollEngine.Client.Scripting.Function
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public class PayrunEndFunction : PayrunFunction, IDisposable
Remarks
This function is the global finalizer for a payrun job. It runs exactly once, after every employee's wage types, collectors, and employee-level functions have completed.
Typical uses:
- Aggregate cross-employee results and write payrun-level results (SetPayrunResult(string, object, ValueType?, string, IEnumerable<string>, Dictionary<string, object>, string)).
- Read all employee runtime values via GetRuntimeValuesEmployees() and GetEmployeeRuntimeValues(string) for summary calculations.
- Log payrun completion statistics or trigger downstream webhooks.
Return value: This function returns void; there is no early-abort
mechanism at payrun end.
Runtime value access: GetPayrunRuntimeValues() returns all payrun-scoped key/value pairs written during the run. Per-employee values are accessible via GetRuntimeValuesEmployees() (list of identifiers) and GetEmployeeRuntimeValues(string) (values for a given employee).
Examples
// Sum up a custom runtime value from all processed employees
var total = 0m;
foreach (var employeeId in GetRuntimeValuesEmployees())
{
var values = GetEmployeeRuntimeValues(employeeId);
if (values.TryGetValue("BonusAmount", out var raw))
total += decimal.Parse(raw);
}
SetPayrunResult("TotalBonus", total);
Constructors
View SourcePayrunEndFunction(object)
Initializes a new instance with the function runtime
Declaration
public PayrunEndFunction(object runtime)
Parameters
| Type | Name | Description |
|---|---|---|
| object | runtime | The runtime |
PayrunEndFunction(string)
New function instance without runtime (scripting development)
Declaration
protected PayrunEndFunction(string sourceFileName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | sourceFileName | The name of the source file |
Remarks
Use GetSourceFileName(string) in your constructor for the source file name
Methods
View SourceEnd()
Entry point for the runtime
Declaration
public void End()
Remarks
Internal usage only, do not call this method
GetEmployeeRuntimeValues(string)
Get employee runtime values
Declaration
public Dictionary<string, string> GetEmployeeRuntimeValues(string employeeIdentifier)
Parameters
| Type | Name | Description |
|---|---|---|
| string | employeeIdentifier | The employee identifier |
Returns
| Type | Description |
|---|---|
| Dictionary<string, string> | Employee runtime values |
GetPayrunRuntimeValues()
Get payrun runtime values
Declaration
public Dictionary<string, string> GetPayrunRuntimeValues()
Returns
| Type | Description |
|---|---|
| Dictionary<string, string> | Payrun runtime values |
GetRuntimeValuesEmployees()
Returns the identifiers of all employees that have runtime values set during this payrun
Declaration
public List<string> GetRuntimeValuesEmployees()
Returns
| Type | Description |
|---|---|
| List<string> | List of employee identifiers with at least one runtime value |