Skip to content

Commit ec0af4c

Browse files
author
Jani Giannoudis
committed
add ExecuteConsolidatedQuery to report runtime and function
1 parent fb6a5ab commit ec0af4c

3 files changed

Lines changed: 57 additions & 0 deletions

File tree

Client.Scripting/Function/ReportFunction.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,19 @@ public DataTable ExecuteCollectorCustomResultQuery(string tableName, int payroll
373373
public DataTable ExecutePayrunResultQuery(string tableName, int payrollResultId, ReportQuery query = null) =>
374374
Runtime.ExecutePayrunResultQuery(tableName, payrollResultId, ReportQueryToTuple(query));
375375

376+
/// <summary>Executes a query across all provider tenants that have granted Consolidation permission
377+
/// to the current tenant. Results are merged into a single table.
378+
/// Use this in ReportEndFunction to aggregate cross-tenant payroll results (e.g. Benelux consolidation).
379+
/// TenantId in parameters is overridden per share — do not set it manually.</summary>
380+
/// <param name="tableName">Target table name for the merged result</param>
381+
/// <param name="methodName">The API query method name (e.g. QueryPayrollResultValues)</param>
382+
/// <param name="mergeColumn">Column used as primary key for row merging</param>
383+
/// <param name="parameters">Base query parameters; TenantId is overridden per share</param>
384+
/// <returns>Merged data table, empty table when no Consolidation shares exist</returns>
385+
public DataTable ExecuteConsolidatedQuery(string tableName, string methodName,
386+
string mergeColumn, Dictionary<string, string> parameters = null) =>
387+
Runtime.ExecuteConsolidatedQuery(tableName, methodName, UserCulture, mergeColumn, parameters);
388+
376389
private static Tuple<int?, string, string, string, long?, long?> ReportQueryToTuple(ReportQuery query)
377390
{
378391
if (query == null)

Client.Scripting/PayrollEngine.Client.Scripting.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7669,6 +7669,17 @@
76697669
<param name="query">The query</param>
76707670
<returns>Payrun result data table, null on empty collection</returns>
76717671
</member>
7672+
<member name="M:PayrollEngine.Client.Scripting.Function.ReportFunction.ExecuteConsolidatedQuery(System.String,System.String,System.String,System.Collections.Generic.Dictionary{System.String,System.String})">
7673+
<summary>Executes a query across all provider tenants that have granted Consolidation permission
7674+
to the current tenant. Results are merged into a single table.
7675+
Use this in ReportEndFunction to aggregate cross-tenant payroll results (e.g. Benelux consolidation).
7676+
TenantId in parameters is overridden per share — do not set it manually.</summary>
7677+
<param name="tableName">Target table name for the merged result</param>
7678+
<param name="methodName">The API query method name (e.g. QueryPayrollResultValues)</param>
7679+
<param name="mergeColumn">Column used as primary key for row merging</param>
7680+
<param name="parameters">Base query parameters; TenantId is overridden per share</param>
7681+
<returns>Merged data table, empty table when no Consolidation shares exist</returns>
7682+
</member>
76727683
<member name="M:PayrollEngine.Client.Scripting.Function.ReportFunction.GetOperationBaseName(System.String)">
76737684
<summary>Get operation base name</summary>
76747685
<param name="operation">The operation name</param>
@@ -11047,6 +11058,20 @@
1104711058
<param name="key">The log key</param>
1104811059
<param name="reportDate">The report date (default: now)</param>
1104911060
</member>
11061+
<member name="M:PayrollEngine.Client.Scripting.Runtime.IReportRuntime.ExecuteConsolidatedQuery(System.String,System.String,System.String,System.String,System.Collections.Generic.Dictionary{System.String,System.String})">
11062+
<summary>Executes a query across all provider tenants that have granted
11063+
Consolidation permission to the current tenant via regulation sharing.
11064+
For each share, the query is executed with the provider tenant's id
11065+
and the results are merged into a single table.
11066+
Use this in ReportEndFunction scripts to aggregate cross-tenant payroll results.
11067+
Example: collecting COM-normalized results from NL and BE tenants into one table.</summary>
11068+
<param name="tableName">Target table name for the merged result</param>
11069+
<param name="methodName">The API query method name (e.g. QueryPayrollResultValues)</param>
11070+
<param name="culture">The content culture</param>
11071+
<param name="mergeColumn">Column used as primary key for merging — must be unique across all tenants</param>
11072+
<param name="parameters">Base query parameters; TenantId is overridden per share iteration</param>
11073+
<returns>Merged data table containing rows from all provider tenants, empty table when no shares exist</returns>
11074+
</member>
1105011075
<member name="T:PayrollEngine.Client.Scripting.Runtime.IReportStartRuntime">
1105111076
<summary>Runtime for the report start function <see cref="T:PayrollEngine.Client.Scripting.Function.ReportStartFunction"/></summary>
1105211077
</member>

Client.Scripting/Runtime/IReportRuntime.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,23 @@ DataTable ExecuteCollectorCustomResultQuery(string tableName, int payrollResultI
158158

159159
#endregion
160160

161+
#region Consolidation
162+
163+
/// <summary>Executes a query across all provider tenants that have granted
164+
/// Consolidation permission to the current tenant via regulation sharing.
165+
/// For each share, the query is executed with the provider tenant's id
166+
/// and the results are merged into a single table.
167+
/// Use this in ReportEndFunction scripts to aggregate cross-tenant payroll results.
168+
/// Example: collecting COM-normalized results from NL and BE tenants into one table.</summary>
169+
/// <param name="tableName">Target table name for the merged result</param>
170+
/// <param name="methodName">The API query method name (e.g. QueryPayrollResultValues)</param>
171+
/// <param name="culture">The content culture</param>
172+
/// <param name="mergeColumn">Column used as primary key for merging — must be unique across all tenants</param>
173+
/// <param name="parameters">Base query parameters; TenantId is overridden per share iteration</param>
174+
/// <returns>Merged data table containing rows from all provider tenants, empty table when no shares exist</returns>
175+
DataTable ExecuteConsolidatedQuery(string tableName, string methodName, string culture,
176+
string mergeColumn, Dictionary<string, string> parameters);
177+
178+
#endregion
179+
161180
}

0 commit comments

Comments
 (0)