Skip to content

Commit 1183766

Browse files
author
Jani Giannoudis
committed
collector and wage type function: added culture for payrun and custom results
updated version to 0.9.0-beta.10
1 parent 0dc6075 commit 1183766

12 files changed

+79
-49
lines changed

Client.Scripting/Extensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ public static decimal Round(this decimal value, DecimalRounding rounding) =>
497497
DecimalRounding.Twentieth => RoundTwentieth(value),
498498
DecimalRounding.Fiftieth => RoundFiftieth(value),
499499
DecimalRounding.Hundredth => RoundHundredth(value),
500-
DecimalRounding.None => value,
501500
_ => value
502501
};
503502

Client.Scripting/Function/CaseAction.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ public interface IActionMethod
328328
public interface IActionMethod<in T> : IActionMethod
329329
{
330330
/// <summary>Evaluate the value</summary>
331+
// ReSharper disable once UnusedMemberInSuper.Global
331332
object EvaluateValue(T value);
332333
}
333334

Client.Scripting/Function/CaseBuildFunction.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,12 @@ public void RemoveInfo(string name)
107107
return;
108108
}
109109
var values = JsonSerializer.Deserialize<Dictionary<string, object>>(attribute);
110-
if (!values.ContainsKey(name))
110+
if (!values.Remove(name))
111111
{
112112
return;
113113
}
114114

115115
// remove value
116-
values.Remove(name);
117116
SetCaseAttribute(InputAttributes.EditInfo, values.Count > 0 ? JsonSerializer.Serialize(values) : null);
118117
}
119118

Client.Scripting/Function/CaseValidateFunction.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,12 @@ public void RemoveInfo(string name)
8686
return;
8787
}
8888
var values = JsonSerializer.Deserialize<Dictionary<string, object>>(attribute);
89-
if (!values.ContainsKey(name))
89+
if (!values.Remove(name))
9090
{
9191
return;
9292
}
9393

9494
// remove value
95-
values.Remove(name);
9695
SetCaseAttribute(InputAttributes.EditInfo, values.Count > 0 ? JsonSerializer.Serialize(values) : null);
9796
}
9897

Client.Scripting/Function/CollectorFunction.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@ public decimal GetCollectorCurrentConsolidatedValue(CollectorConsolidatedResultQ
138138
/// <param name="slot">The result slot</param>
139139
/// <param name="tags">The result tags</param>
140140
/// <param name="attributes">The wage type custom result attributes</param>
141+
/// <param name="culture">The result culture</param>
141142
public void AddPayrunResult(string name, object value, ValueType? valueType = null, string source = null,
142-
string slot = null, IEnumerable<string> tags = null, Dictionary<string, object> attributes = null) =>
143-
AddPayrunResult(name, value, PeriodStart, PeriodEnd, valueType, source, slot, tags, attributes);
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);
144146

145147
/// <summary>Add payrun result</summary>
146148
/// <param name="name">The result name</param>
@@ -152,9 +154,10 @@ public void AddPayrunResult(string name, object value, ValueType? valueType = nu
152154
/// <param name="slot">The result slot</param>
153155
/// <param name="tags">The result tags</param>
154156
/// <param name="attributes">The wage type custom result attributes</param>
157+
/// <param name="culture">The result culture</param>
155158
public void AddPayrunResult(string name, object value, DateTime startDate, DateTime endDate,
156159
ValueType? valueType = null, string source = null, string slot = null,
157-
IEnumerable<string> tags = null, Dictionary<string, object> attributes = null)
160+
IEnumerable<string> tags = null, Dictionary<string, object> attributes = null, string culture = null)
158161
{
159162
if (string.IsNullOrWhiteSpace(name))
160163
{
@@ -168,7 +171,8 @@ public void AddPayrunResult(string name, object value, DateTime startDate, DateT
168171
source ??= GetType().Name;
169172
var json = JsonSerializer.Serialize(value);
170173
valueType ??= value.GetValueType();
171-
Runtime.AddPayrunResult(source, name, json, (int)valueType.Value, startDate, endDate, slot, tags?.ToList(), attributes);
174+
Runtime.AddPayrunResult(source, name, json, (int)valueType.Value, startDate, endDate,
175+
slot, tags?.ToList(), attributes, culture);
172176
}
173177

174178
#endregion
@@ -181,9 +185,10 @@ public void AddPayrunResult(string name, object value, DateTime startDate, DateT
181185
/// <param name="tags">The result tags</param>
182186
/// <param name="attributes">The collector custom result attributes</param>
183187
/// <param name="valueType">The result value type (numeric), default is the collector value type</param>
188+
/// <param name="culture">The result culture</param>
184189
public void AddCustomResult(string source, decimal value, IEnumerable<string> tags = null,
185-
Dictionary<string, object> attributes = null, ValueType? valueType = null) =>
186-
AddCustomResult(source, value, PeriodStart, PeriodEnd, tags, attributes, valueType);
190+
Dictionary<string, object> attributes = null, ValueType? valueType = null, string culture = null) =>
191+
AddCustomResult(source, value, PeriodStart, PeriodEnd, tags, attributes, valueType, culture);
187192

188193
/// <summary>Adds a custom collector result</summary>
189194
/// <param name="source">The value source</param>
@@ -193,10 +198,11 @@ public void AddCustomResult(string source, decimal value, IEnumerable<string> ta
193198
/// <param name="tags">The result tags</param>
194199
/// <param name="attributes">The collector custom result attributes</param>
195200
/// <param name="valueType">The result value type (numeric), default is the collector value type</param>
201+
/// <param name="culture">The result culture</param>
196202
public void AddCustomResult(string source, decimal value, DateTime startDate, DateTime endDate,
197203
IEnumerable<string> tags = null, Dictionary<string, object> attributes = null,
198-
ValueType? valueType = null) =>
199-
Runtime.AddCustomResult(source, value, startDate, endDate, tags?.ToList(), attributes, (int?)valueType);
204+
ValueType? valueType = null, string culture = null) =>
205+
Runtime.AddCustomResult(source, value, startDate, endDate, tags?.ToList(), attributes, (int?)valueType, culture);
200206

201207
#endregion
202208

Client.Scripting/Function/ReportFunction.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ public DataTable ExecuteEmployeeTimeCaseValueQuery(string tableName, int payroll
617617
{"TenantId", TenantId.ToString()},
618618
{"PayrollId", payrollId.ToString()},
619619
{"EmployeeId", employeeId.ToString()},
620-
{"CaseType", CaseType.Employee.ToString()},
620+
{"CaseType", nameof(CaseType.Employee)},
621621
// fallback culture
622622
{"Culture", culture ?? UserCulture},
623623
{"CaseFieldNames", JsonSerializer.Serialize(columnNames)}
@@ -1100,13 +1100,12 @@ public void RemoveInfo(string name)
11001100
return;
11011101
}
11021102
var values = JsonSerializer.Deserialize<Dictionary<string, object>>(attribute);
1103-
if (!values.ContainsKey(name))
1103+
if (!values.Remove(name))
11041104
{
11051105
return;
11061106
}
11071107

11081108
// remove value
1109-
values.Remove(name);
11101109
SetReportAttribute(InputAttributes.EditInfo, values.Count > 0 ? JsonSerializer.Serialize(values) : null);
11111110
}
11121111

Client.Scripting/Function/WageTypeFunction.cs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ public decimal GetWageTypeCurrentConsolidatedValue(WageTypeConsolidatedResultQue
146146
/// <param name="slot">The result slot</param>
147147
/// <param name="tags">The result tags</param>
148148
/// <param name="attributes">The wage type custom result attributes</param>
149+
/// <param name="culture">The result culture</param>
149150
public void AddPayrunResult(string name, object value, ValueType? valueType = null, string source = null,
150-
string slot = null, IEnumerable<string> tags = null, Dictionary<string, object> attributes = null) =>
151-
AddPayrunResult(name, value, PeriodStart, PeriodEnd, valueType, source, slot, tags, attributes);
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);
152154

153155
/// <summary>Add payrun result</summary>
154156
/// <param name="name">The result name</param>
@@ -160,9 +162,10 @@ public void AddPayrunResult(string name, object value, ValueType? valueType = nu
160162
/// <param name="slot">The result slot</param>
161163
/// <param name="tags">The result tags</param>
162164
/// <param name="attributes">The wage type custom result attributes</param>
165+
/// <param name="culture">The result culture</param>
163166
public void AddPayrunResult(string name, object value, DateTime startDate, DateTime endDate,
164167
ValueType? valueType = null, string source = null, string slot = null,
165-
IEnumerable<string> tags = null, Dictionary<string, object> attributes = null)
168+
IEnumerable<string> tags = null, Dictionary<string, object> attributes = null, string culture = null)
166169
{
167170
if (string.IsNullOrWhiteSpace(name))
168171
{
@@ -176,7 +179,7 @@ public void AddPayrunResult(string name, object value, DateTime startDate, DateT
176179
source ??= GetType().Name;
177180
var json = JsonSerializer.Serialize(value);
178181
valueType ??= value.GetValueType();
179-
Runtime.AddPayrunResult(source, name, json, (int)valueType.Value, startDate, endDate, slot, tags?.ToList(), attributes);
182+
Runtime.AddPayrunResult(source, name, json, (int)valueType.Value, startDate, endDate, slot, tags?.ToList(), attributes, culture);
180183
}
181184

182185
#endregion
@@ -188,19 +191,21 @@ public void AddPayrunResult(string name, object value, DateTime startDate, DateT
188191
/// <param name="tags">The result tags</param>
189192
/// <param name="attributes">The wage type custom result attributes</param>
190193
/// <param name="valueType">The result value type (numeric), default is the wage type value type</param>
194+
/// <param name="culture">The result culture</param>
191195
public void AddCustomResult(string source, IEnumerable<string> tags = null,
192-
Dictionary<string, object> attributes = null, ValueType? valueType = null) =>
193-
AddCustomResult(source, PeriodStart, PeriodEnd, tags, attributes, valueType);
196+
Dictionary<string, object> attributes = null, ValueType? valueType = null, string culture = null) =>
197+
AddCustomResult(source, PeriodStart, PeriodEnd, tags, attributes, valueType, culture);
194198

195199
/// <summary>Add wage type custom result from case field values, using the current period</summary>
196200
/// <param name="source">The value source</param>
197201
/// <param name="value">The period value</param>
198202
/// <param name="tags">The result tags</param>
199203
/// <param name="attributes">The wage type custom result attributes</param>
200204
/// <param name="valueType">The result value type (numeric), default is the wage type value type</param>
205+
/// <param name="culture">The result culture</param>
201206
public void AddCustomResult(string source, decimal value, IEnumerable<string> tags = null,
202-
Dictionary<string, object> attributes = null, ValueType? valueType = null) =>
203-
AddCustomResult(source, value, PeriodStart, PeriodEnd, tags, attributes, valueType);
207+
Dictionary<string, object> attributes = null, ValueType? valueType = null, string culture = null) =>
208+
AddCustomResult(source, value, PeriodStart, PeriodEnd, tags, attributes, valueType, culture);
204209

205210
/// <summary>Add wage type custom result from case field values</summary>
206211
/// <param name="source">The value source</param>
@@ -209,9 +214,10 @@ public void AddCustomResult(string source, decimal value, IEnumerable<string> ta
209214
/// <param name="tags">The result tags</param>
210215
/// <param name="attributes">The wage type custom result attributes</param>
211216
/// <param name="valueType">The result value type (numeric), default is the wage type value type</param>
217+
/// <param name="culture">The result culture</param>
212218
public void AddCustomResult(string source, DateTime startDate, DateTime endDate,
213219
IEnumerable<string> tags = null, Dictionary<string, object> attributes = null,
214-
ValueType? valueType = null)
220+
ValueType? valueType = null, string culture = null)
215221
{
216222
var tagList = tags?.ToList();
217223
var caseValues = GetPeriodCaseValues(new DatePeriod(startDate, endDate), source);
@@ -222,7 +228,7 @@ public void AddCustomResult(string source, DateTime startDate, DateTime endDate,
222228
if (periodValue.Value is decimal decimalValue)
223229
{
224230
var period = new DatePeriod(periodValue.Start, periodValue.End);
225-
AddCustomResult(source, decimalValue, period.Start, period.End, tagList, attributes, valueType);
231+
AddCustomResult(source, decimalValue, period.Start, period.End, tagList, attributes, valueType, culture);
226232
}
227233
}
228234
}
@@ -236,10 +242,11 @@ public void AddCustomResult(string source, DateTime startDate, DateTime endDate,
236242
/// <param name="tags">The result tags</param>
237243
/// <param name="attributes">The wage type custom result attributes</param>
238244
/// <param name="valueType">The result value type (numeric), default is the wage type value type</param>
245+
/// <param name="culture">The result culture</param>
239246
public void AddCustomResult(string source, decimal value, DateTime startDate,
240247
DateTime endDate, IEnumerable<string> tags = null, Dictionary<string, object> attributes = null,
241-
ValueType? valueType = null) =>
242-
Runtime.AddCustomResult(source, value, startDate, endDate, tags?.ToList(), attributes, (int?)valueType);
248+
ValueType? valueType = null, string culture = null) =>
249+
Runtime.AddCustomResult(source, value, startDate, endDate, tags?.ToList(), attributes, (int?)valueType, culture);
243250

244251
#endregion
245252

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.9" />
185+
<PackageReference Include="PayrollEngine.Client.Core" Version="0.9.0-beta.10" />
186186
</ItemGroup>
187187

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

0 commit comments

Comments
 (0)