diff --git a/source/settlement-report/Orchestration.SettlementReports/Functions/SettlementReports/SettlementReportRequestTrigger.cs b/source/settlement-report/Orchestration.SettlementReports/Functions/SettlementReports/SettlementReportRequestTrigger.cs index d1b8ec5..f70f705 100644 --- a/source/settlement-report/Orchestration.SettlementReports/Functions/SettlementReports/SettlementReportRequestTrigger.cs +++ b/source/settlement-report/Orchestration.SettlementReports/Functions/SettlementReports/SettlementReportRequestTrigger.cs @@ -64,6 +64,7 @@ await _revisionLogClient.LogAsync( payload: System.Text.Json.JsonSerializer.Serialize(settlementReportRequest))) .ConfigureAwait(false); + var actorNumber = _userContext.CurrentUser.Actor.ActorNumber; var marketRole = _userContext.CurrentUser.Actor.MarketRole switch { FrontendActorMarketRole.Other => MarketRole.Other, @@ -75,9 +76,10 @@ await _revisionLogClient.LogAsync( }; if (_userContext.CurrentUser is { MultiTenancy: true, Actor.MarketRole: FrontendActorMarketRole.DataHubAdministrator } && - settlementReportRequest.MarketRoleOverride.HasValue) + settlementReportRequest is { MarketRoleOverride: not null, ActorNumberOverride: not null }) { marketRole = settlementReportRequest.MarketRoleOverride.Value; + actorNumber = settlementReportRequest.ActorNumberOverride; } if (marketRole == MarketRole.EnergySupplier && string.IsNullOrWhiteSpace(settlementReportRequest.Filter.EnergySupplier)) @@ -103,7 +105,7 @@ await _revisionLogClient.LogAsync( } var chargeOwnerId = marketRole is MarketRole.GridAccessProvider or MarketRole.SystemOperator - ? _userContext.CurrentUser.Actor.ActorNumber + ? actorNumber : null; var actorInfo = new SettlementReportRequestedByActor(marketRole, chargeOwnerId); diff --git a/source/settlement-report/SettlementReports.Interfaces/SettlementReports_v2/Models/SettlementReportRequestDto.cs b/source/settlement-report/SettlementReports.Interfaces/SettlementReports_v2/Models/SettlementReportRequestDto.cs index 9d3836b..21ec35d 100644 --- a/source/settlement-report/SettlementReports.Interfaces/SettlementReports_v2/Models/SettlementReportRequestDto.cs +++ b/source/settlement-report/SettlementReports.Interfaces/SettlementReports_v2/Models/SettlementReportRequestDto.cs @@ -20,4 +20,5 @@ public sealed record SettlementReportRequestDto( bool IncludeBasisData, bool IncludeMonthlyAmount, SettlementReportRequestFilterDto Filter, + string? ActorNumberOverride = null, MarketRole? MarketRoleOverride = null); diff --git a/source/settlement-report/SettlementReports.WebAPI/Controllers/SettlementReportsController.cs b/source/settlement-report/SettlementReports.WebAPI/Controllers/SettlementReportsController.cs index d3b2739..f181963 100644 --- a/source/settlement-report/SettlementReports.WebAPI/Controllers/SettlementReportsController.cs +++ b/source/settlement-report/SettlementReports.WebAPI/Controllers/SettlementReportsController.cs @@ -54,6 +54,7 @@ public SettlementReportsController( [EnableRevision(activityName: "RequestSettlementReportAPI", entityType: typeof(SettlementReportRequestDto))] public async Task> RequestSettlementReport([FromBody] SettlementReportRequestDto settlementReportRequest) { + var actorNumber = _userContext.CurrentUser.Actor.ActorNumber; var marketRole = _userContext.CurrentUser.Actor.MarketRole switch { FrontendActorMarketRole.Other => MarketRole.Other, @@ -65,9 +66,10 @@ public async Task> RequestSettlementReport([FromBody] Settlem }; if (_userContext.CurrentUser is { MultiTenancy: true, Actor.MarketRole: FrontendActorMarketRole.DataHubAdministrator } && - settlementReportRequest.MarketRoleOverride.HasValue) + settlementReportRequest is { MarketRoleOverride: not null, ActorNumberOverride: not null }) { marketRole = settlementReportRequest.MarketRoleOverride.Value; + actorNumber = settlementReportRequest.ActorNumberOverride; } if (marketRole == MarketRole.EnergySupplier && string.IsNullOrWhiteSpace(settlementReportRequest.Filter.EnergySupplier)) @@ -97,7 +99,7 @@ public async Task> RequestSettlementReport([FromBody] Settlem _userContext.CurrentUser.UserId, _userContext.CurrentUser.Actor.ActorId, _userContext.CurrentUser.MultiTenancy, - _userContext.CurrentUser.Actor.ActorNumber, + actorNumber, marketRole); var result = await _requestSettlementReportJobHandler.HandleAsync(requestCommand).ConfigureAwait(false);