Skip to content

Commit 38446f0

Browse files
author
Jani Giannoudis
committed
moved method add-payrun-result from collector/wage-type runtime/function to payrun runtime/function
payroll runtime/function: added method has-lookup updated third party nugets updated version to 0.9.0-beta.11
1 parent 1183766 commit 38446f0

12 files changed

+134
-212
lines changed

Client.Scripting.Tests/PayrollEngine.Client.Scripting.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
1212
<PackageReference Include="xunit" Version="2.9.3" />
13-
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
13+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
</PackageReference>

Client.Scripting/Function/CollectorFunction.cs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
using System;
44
using System.Linq;
5-
using System.Text.Json;
65
using System.Collections.Generic;
76

87
namespace PayrollEngine.Client.Scripting.Function;
@@ -128,55 +127,6 @@ public decimal GetCollectorCurrentConsolidatedValue(CollectorConsolidatedResultQ
128127
return value;
129128
}
130129

131-
#region Payrun Results
132-
133-
/// <summary>Add payrun result using the current period</summary>
134-
/// <param name="name">The result name</param>
135-
/// <param name="value">The result value</param>
136-
/// <param name="valueType">The result value type</param>
137-
/// <param name="source">The result source</param>
138-
/// <param name="slot">The result slot</param>
139-
/// <param name="tags">The result tags</param>
140-
/// <param name="attributes">The wage type custom result attributes</param>
141-
/// <param name="culture">The result culture</param>
142-
public void AddPayrunResult(string name, object value, ValueType? valueType = null, string source = null,
143-
string slot = null, IEnumerable<string> tags = null,
144-
Dictionary<string, object> attributes = null, string culture = null) =>
145-
AddPayrunResult(name, value, PeriodStart, PeriodEnd, valueType, source, slot, tags, attributes, culture);
146-
147-
/// <summary>Add payrun result</summary>
148-
/// <param name="name">The result name</param>
149-
/// <param name="value">The result value</param>
150-
/// <param name="startDate">The start date</param>
151-
/// <param name="endDate">The end date</param>
152-
/// <param name="valueType">The result value type</param>
153-
/// <param name="source">The result source</param>
154-
/// <param name="slot">The result slot</param>
155-
/// <param name="tags">The result tags</param>
156-
/// <param name="attributes">The wage type custom result attributes</param>
157-
/// <param name="culture">The result culture</param>
158-
public void AddPayrunResult(string name, object value, DateTime startDate, DateTime endDate,
159-
ValueType? valueType = null, string source = null, string slot = null,
160-
IEnumerable<string> tags = null, Dictionary<string, object> attributes = null, string culture = null)
161-
{
162-
if (string.IsNullOrWhiteSpace(name))
163-
{
164-
throw new ArgumentException(nameof(name));
165-
}
166-
if (value == null)
167-
{
168-
throw new ArgumentNullException(nameof(value));
169-
}
170-
171-
source ??= GetType().Name;
172-
var json = JsonSerializer.Serialize(value);
173-
valueType ??= value.GetValueType();
174-
Runtime.AddPayrunResult(source, name, json, (int)valueType.Value, startDate, endDate,
175-
slot, tags?.ToList(), attributes, culture);
176-
}
177-
178-
#endregion
179-
180130
#region Custom Results
181131

182132
/// <summary>Adds a custom collector result, using the current period</summary>

Client.Scripting/Function/PayrollFunction.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,12 @@ public string GetSlotByValue(string caseFieldName, string value, string prefix =
907907

908908
#region Lookups
909909

910+
/// <summary>Test for existing lookup</summary>
911+
/// <param name="lookupName">The lookup name</param>
912+
/// <returns>True on existing lookup</returns>
913+
public bool HasLookup(string lookupName) =>
914+
Runtime.HasLookup(lookupName);
915+
910916
/// <summary>Get lookup value</summary>
911917
/// <param name="lookupName">The lookup name</param>
912918
/// <param name="lookupKey">The lookup key</param>

Client.Scripting/Function/PayrunFunction.cs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,55 @@ public void SetEmployeeRuntimeValue(string key, string value) =>
160160
/// <param name="key">The value key</param>
161161
/// <param name="value">The employee runtime value</param>
162162
public void SetEmployeeRuntimeValue<T>(string key, T value) =>
163-
SetEmployeeRuntimeValue(key, JsonSerializer.Serialize(value));
163+
SetEmployeeRuntimeValue(key, value != null ? JsonSerializer.Serialize(value) : null);
164+
165+
#endregion
166+
167+
#region Payrun Results
168+
169+
/// <summary>Add payrun result using the current period</summary>
170+
/// <param name="name">The result name</param>
171+
/// <param name="value">The result value</param>
172+
/// <param name="valueType">The result value type</param>
173+
/// <param name="source">The result source</param>
174+
/// <param name="slot">The result slot</param>
175+
/// <param name="tags">The result tags</param>
176+
/// <param name="attributes">The wage type custom result attributes</param>
177+
/// <param name="culture">The result culture</param>
178+
public void AddPayrunResult(string name, object value, ValueType? valueType = null, string source = null,
179+
string slot = null, IEnumerable<string> tags = null,
180+
Dictionary<string, object> attributes = null, string culture = null) =>
181+
AddPayrunResult(name, value, PeriodStart, PeriodEnd, valueType, source, slot, tags, attributes, culture);
182+
183+
/// <summary>Add payrun result</summary>
184+
/// <param name="name">The result name</param>
185+
/// <param name="value">The result value</param>
186+
/// <param name="startDate">The start date</param>
187+
/// <param name="endDate">The end date</param>
188+
/// <param name="valueType">The result value type</param>
189+
/// <param name="source">The result source</param>
190+
/// <param name="slot">The result slot</param>
191+
/// <param name="tags">The result tags</param>
192+
/// <param name="attributes">The wage type custom result attributes</param>
193+
/// <param name="culture">The result culture</param>
194+
public void AddPayrunResult(string name, object value, DateTime startDate, DateTime endDate,
195+
ValueType? valueType = null, string source = null, string slot = null,
196+
IEnumerable<string> tags = null, Dictionary<string, object> attributes = null, string culture = null)
197+
{
198+
if (string.IsNullOrWhiteSpace(name))
199+
{
200+
throw new ArgumentException(nameof(name));
201+
}
202+
if (value == null)
203+
{
204+
throw new ArgumentNullException(nameof(value));
205+
}
206+
207+
source ??= GetType().Name;
208+
var json = JsonSerializer.Serialize(value);
209+
valueType ??= value.GetValueType();
210+
Runtime.AddPayrunResult(source, name, json, (int)valueType.Value, startDate, endDate, slot, tags?.ToList(), attributes, culture);
211+
}
164212

165213
#endregion
166214

Client.Scripting/Function/WageTypeFunction.cs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
using System;
44
using System.Linq;
5-
using System.Text.Json;
65
using System.Collections.Generic;
76

87
namespace PayrollEngine.Client.Scripting.Function;
@@ -136,54 +135,6 @@ public decimal GetWageTypeCurrentConsolidatedValue(WageTypeConsolidatedResultQue
136135
return value;
137136
}
138137

139-
#region Payrun Results
140-
141-
/// <summary>Add payrun result using the current period</summary>
142-
/// <param name="name">The result name</param>
143-
/// <param name="value">The result value</param>
144-
/// <param name="valueType">The result value type</param>
145-
/// <param name="source">The result source</param>
146-
/// <param name="slot">The result slot</param>
147-
/// <param name="tags">The result tags</param>
148-
/// <param name="attributes">The wage type custom result attributes</param>
149-
/// <param name="culture">The result culture</param>
150-
public void AddPayrunResult(string name, object value, ValueType? valueType = null, string source = null,
151-
string slot = null, IEnumerable<string> tags = null,
152-
Dictionary<string, object> attributes = null, string culture = null) =>
153-
AddPayrunResult(name, value, PeriodStart, PeriodEnd, valueType, source, slot, tags, attributes, culture);
154-
155-
/// <summary>Add payrun result</summary>
156-
/// <param name="name">The result name</param>
157-
/// <param name="value">The result value</param>
158-
/// <param name="startDate">The start date</param>
159-
/// <param name="endDate">The end date</param>
160-
/// <param name="valueType">The result value type</param>
161-
/// <param name="source">The result source</param>
162-
/// <param name="slot">The result slot</param>
163-
/// <param name="tags">The result tags</param>
164-
/// <param name="attributes">The wage type custom result attributes</param>
165-
/// <param name="culture">The result culture</param>
166-
public void AddPayrunResult(string name, object value, DateTime startDate, DateTime endDate,
167-
ValueType? valueType = null, string source = null, string slot = null,
168-
IEnumerable<string> tags = null, Dictionary<string, object> attributes = null, string culture = null)
169-
{
170-
if (string.IsNullOrWhiteSpace(name))
171-
{
172-
throw new ArgumentException(nameof(name));
173-
}
174-
if (value == null)
175-
{
176-
throw new ArgumentNullException(nameof(value));
177-
}
178-
179-
source ??= GetType().Name;
180-
var json = JsonSerializer.Serialize(value);
181-
valueType ??= value.GetValueType();
182-
Runtime.AddPayrunResult(source, name, json, (int)valueType.Value, startDate, endDate, slot, tags?.ToList(), attributes, culture);
183-
}
184-
185-
#endregion
186-
187138
#region Custom Results
188139

189140
/// <summary>Add wage type custom result from case field values, using the current period</summary>

Client.Scripting/PayrollEngine.Client.Scripting.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182

183183
<ItemGroup>
184184
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
185-
<PackageReference Include="PayrollEngine.Client.Core" Version="0.9.0-beta.10" />
185+
<PackageReference Include="PayrollEngine.Client.Core" Version="0.9.0-beta.11" />
186186
</ItemGroup>
187187

188188
<!-- include xml documention files and json schemas to the nuget package -->

0 commit comments

Comments
 (0)