@@ -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
0 commit comments