Class WageTypeValueFunction
Wage type function
Implements
Inherited Members
Namespace: PayrollEngine.Client.Scripting.Function
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public class WageTypeValueFunction : WageTypeFunction, IDisposable
Remarks
This is the core calculation function of the payrun. It runs once per wage type per employee (or multiple times if RestartExecution() is called). The returned value becomes the wage type result and is fed to all collectors that reference this wage type.
Available data sources within this function:
- Employee case values via
Employee["FieldName"]or GetCaseValue<T>(string, string). - Running collector values via Collector indexer.
- Values from other wage types already calculated via WageType indexer.
- Lookup tables via GetLookup<T>(string, string, string) and GetRangeLookup<T>(string, decimal, string, string).
- Historical wage type results via GetWageTypeResults(WageTypeRangeResultQuery) or GetConsolidatedWageTypeResults(WageTypeConsolidatedResultQuery).
Return value: Return a decimal value to set the wage type result.
Return null to produce no result for this wage type (no result stored, no collector fed).
Return Empty to commit an explicit zero with metadata.
Custom results: Use AddCustomResult(string, decimal, IEnumerable<string>, Dictionary<string, object>, ValueType?, string) to attach supplementary breakdown results (e.g. per cost-centre amounts) alongside the primary result.
Retro runs: Use ScheduleRetroPayrun(DateTime, IEnumerable<string>) to trigger a retrospective correction payrun for a prior period.
Low-Code / No-Code: The wage type value can be derived entirely through
action expressions using WageTypeValueAction attributes — no C# scripting required.
The GetValue() entry point invokes all registered actions before executing
any inline script body.
Examples
// Simple: return a case value as the wage type result
Employee["Salary"]
// Conditional: only return if a prerequisite wage type is positive
(decimal)WageType[2300] > 0 ? Employee["Bonus"] : PayrollValue.Empty
// Lookup-driven calculation
(decimal)Employee["Salary"] * GetLookup<decimal>("SocialRates", "Standard")
// With a custom breakdown result per cost centre
var total = (decimal)Employee["Salary"];
AddCustomResult("CostCenter1", total * 0.6m);
AddCustomResult("CostCenter2", total * 0.4m);
return total;
// Average of the last 3 completed periods
GetWageTypeResults(WageTypeNumber,
new WageTypePeriodResultQuery(3, PayrunJobStatus.Complete))
.DefaultIfEmpty().Average()
Constructors
View SourceWageTypeValueFunction(object)
Initializes a new instance with the function runtime
Declaration
public WageTypeValueFunction(object runtime)
Parameters
| Type | Name | Description |
|---|---|---|
| object | runtime | The runtime |
WageTypeValueFunction(string)
New function instance without runtime (scripting development)
Declaration
protected WageTypeValueFunction(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
Properties
View SourceExecutionCount
The execution count
Declaration
[ActionProperty("Wage type value execution count", null)]
public int ExecutionCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
View SourceGetValue()
Entry point for the runtime
Declaration
public object GetValue()
Returns
| Type | Description |
|---|---|
| object |
Remarks
Internal usage only, do not call this method
RestartExecution()
Restart execution of wage type calculation
Declaration
public void RestartExecution()