Skip to content

Commit

Permalink
feat: settlement report - include previous grid owners
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmajgaard committed Dec 6, 2024
1 parent fef1252 commit db8602c
Showing 1 changed file with 21 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public RequestSettlementReportHandler(

public async Task<JobRunId> HandleAsync(RequestSettlementReportCommand request)
{
var reportId = new SettlementReportRequestId(Guid.NewGuid().ToString());

if (request.MarketRole == MarketRole.GridAccessProvider)
{
JobRunId? firstRunId = null;
Expand All @@ -52,36 +50,14 @@ public async Task<JobRunId> HandleAsync(RequestSettlementReportCommand request)

foreach (var owner in distinctOwners)
{
var id = await _jobHelper.RunSettlementReportsJobAsync(request.RequestDto, request.MarketRole, reportId, owner.Value).ConfigureAwait(false);
var id = await StartReportAsync(request, owner.Value).ConfigureAwait(false);
firstRunId ??= id;

await _settlementReportInitializeHandler
.InitializeFromJobAsync(
request.UserId,
request.ActorId,
request.IsFas,
id,
reportId,
request.RequestDto)
.ConfigureAwait(false);
}

return firstRunId!;
}

var runId = await _jobHelper.RunSettlementReportsJobAsync(request.RequestDto, request.MarketRole, reportId, request.ActorGln).ConfigureAwait(false);

await _settlementReportInitializeHandler
.InitializeFromJobAsync(
request.UserId,
request.ActorId,
request.IsFas,
runId,
reportId,
request.RequestDto)
.ConfigureAwait(false);

return runId;
return await StartReportAsync(request, request.ActorGln).ConfigureAwait(false);
}

private async Task<IEnumerable<ActorNumber>> GetGridAreaOwnersAsync(IEnumerable<string> gridAreaCodes, SettlementReportRequestFilterDto filter)
Expand All @@ -103,4 +79,23 @@ private async Task<IEnumerable<ActorNumber>> GetGridAreaOwnersAsync(IEnumerable<

return gridAreaOwners;
}

private async Task<JobRunId> StartReportAsync(RequestSettlementReportCommand request, string requestActorGln)
{
var reportId = new SettlementReportRequestId(Guid.NewGuid().ToString());

var runId = await _jobHelper.RunSettlementReportsJobAsync(request.RequestDto, request.MarketRole, reportId, requestActorGln).ConfigureAwait(false);

await _settlementReportInitializeHandler
.InitializeFromJobAsync(
request.UserId,
request.ActorId,
request.IsFas,
runId,
reportId,
request.RequestDto)
.ConfigureAwait(false);

return runId;
}
}

0 comments on commit db8602c

Please sign in to comment.