diff --git a/source/marketparticipant/Energinet.DataHub.MarketParticipant.Domain/Services/Rules/ExistingActorConsolidationService.cs b/source/marketparticipant/Energinet.DataHub.MarketParticipant.Domain/Services/Rules/ExistingActorConsolidationService.cs index d77c5e5e6..e0dcba173 100644 --- a/source/marketparticipant/Energinet.DataHub.MarketParticipant.Domain/Services/Rules/ExistingActorConsolidationService.cs +++ b/source/marketparticipant/Energinet.DataHub.MarketParticipant.Domain/Services/Rules/ExistingActorConsolidationService.cs @@ -36,15 +36,15 @@ public async Task CheckExistingConsolidationAsync(ActorId fromActorId, ActorId t .GetAsync() .ConfigureAwait(false)).ToList(); - if (existingConsolidations.Any(consolidation => consolidation.ActorFromId == fromActorId || consolidation.ActorToId == fromActorId)) + if (existingConsolidations.Any(consolidation => consolidation.ActorFromId == fromActorId || (consolidation.ActorToId == fromActorId && consolidation.Status == ActorConsolidationStatus.Pending))) { - throw new ValidationException("The specified From actor has already been consolidated before.") + throw new ValidationException("The specified From actor has already been consolidated before or is already scheduled to be consolidated in the future.") .WithErrorCode("actor.consolidation.fromexists"); } - if (existingConsolidations.Any(consolidation => consolidation.ActorToId == fromActorId || consolidation.ActorFromId == toActorId)) + if (existingConsolidations.Any(consolidation => consolidation.ActorFromId == toActorId)) { - throw new ValidationException("The specified From actor has an existing consolidation scheduled already.") + throw new ValidationException("The specified From actor has already been, or is, in an existing consolidation as the discontinued actor.") .WithErrorCode("actor.consolidation.toexists"); } }