Class CollectorEndFunction
Executes when a collector is finalized in a payrun, after all wage type values have been applied.
Implements
Inherited Members
Namespace: PayrollEngine.Client.Scripting.Function
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public class CollectorEndFunction : CollectorFunction, IDisposable
Remarks
This function runs once per collector per employee, after all wage types have contributed their values. It is the last opportunity to inspect or transform the final accumulated result before it is committed to the payrun output.
The complete collected state is available through the inherited properties: CollectorResult, CollectorSummary, CollectorCount, CollectorMinimum, and CollectorMaximum.
Typical uses:
- Apply a final cap or floor to the collector result by overriding with SetValues(decimal[]).
- Write a custom collector result via AddCustomResult(string, decimal, IEnumerable<string>, Dictionary<string, object>, ValueType?, string).
- Persist the final value as an employee runtime value for use in PayrunEmployeeEndFunction.
- Schedule a retro payrun via ScheduleRetroPayrun(DateTime, IEnumerable<string>) if the result crosses a threshold.
Return value: Return null to commit the current accumulated result.
Return a numeric value to override the final result.
Return null after calling Reset() to clear the result entirely.
Low-Code / No-Code: End-of-collector logic can be expressed through
CollectorEndAction attributes. The End() entry point invokes all
registered actions before executing any inline script body.
Examples
// Cap the final collector result at 12 000
if (CollectorResult > 12000m)
SetValues(new[] { 12000m });
// Store the final value for use in PayrunEmployeeEndFunction
SetEmployeeRuntimeValue("SocialContrib", CollectorResult.ToString());
Constructors
View SourceCollectorEndFunction(object)
Initializes a new instance with the function runtime
Declaration
public CollectorEndFunction(object runtime)
Parameters
| Type | Name | Description |
|---|---|---|
| object | runtime | The runtime |
CollectorEndFunction(string)
New function instance without runtime (scripting development)
Declaration
protected CollectorEndFunction(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 object End()
Returns
| Type | Description |
|---|---|
| object |
Remarks
Internal usage only, do not call this method
GetValues()
Get collector values
Declaration
public decimal[] GetValues()
Returns
| Type | Description |
|---|---|
| decimal[] |
SetValues(decimal[])
Set collector values
Declaration
public void SetValues(decimal[] values)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal[] | values |