Skip to content

Commit

Permalink
feat: or-2353 also add kbo legal entity when coupling
Browse files Browse the repository at this point in the history
  • Loading branch information
koenmetsu committed Sep 16, 2024
1 parent c7507bb commit 71bdc00
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ public async Task Handle(ICommandEnvelope<CoupleOrganisationToKbo> envelope)
AddAddresses(organisation, location, registeredOfficeLocationType);

AddLabel(organisation, kboOrganisation);

organisation.AddKboLegalEntityType(kboOrganisation.LegalEntityType);
});

public async Task Handle(ICommandEnvelope<CancelCouplingWithKbo> envelope)
Expand Down
5 changes: 4 additions & 1 deletion src/OrganisationRegistry/Organisation/Organisation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,9 @@ public void AddKboLegalFormOrganisationClassification(Guid organisationOrganisat

public void AddKboLegalEntityType(IMagdaLegalEntityType kboOrganisationLegalEntityType)
{
if (!string.IsNullOrEmpty(KboState.LegalEntityTypeCode))
return;

ApplyChange(
new KboLegalEntityTypeAdded(
Id,
Expand Down Expand Up @@ -3127,6 +3130,6 @@ public void Apply(OrganisationLocationRemoved evnt)

public void Apply(KboLegalEntityTypeAdded evnt)
{
// no need to keep this in state at time of writing.
KboState.LegalEntityTypeCode = evnt.LegalEntityTypeCode;
}
}
1 change: 1 addition & 0 deletions src/OrganisationRegistry/Organisation/State/KboState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class KboState
public string? ShortNameBeforeKboCoupling { get; set; }
public KboTermination? TerminationInKbo { get; set; }
public KboNumber? KboNumber { get; set; }
public string? LegalEntityTypeCode { get; set; }

public void Clear()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,5 @@ await Given(Events)
public async Task PublishesTheCorrectNumberOfEvents()
=> await Given(Events)
.When(CoupleOrganisationToKboCommand, TestUser.AlgemeenBeheerder)
.ThenItPublishesTheCorrectNumberOfEvents(7);
.ThenItPublishesTheCorrectNumberOfEvents(8);
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,5 @@ await Given(Events)
public async Task PublishesTheCorrectNumberOfEvents()
=> await Given(Events)
.When(CoupleOrganisationToKboCommand, TestUser.AlgemeenBeheerder)
.ThenItPublishesTheCorrectNumberOfEvents(4);
.ThenItPublishesTheCorrectNumberOfEvents(5);
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected override KboOrganisationCommandHandlers BuildHandler(ISession session)
public async Task PublishesElevenEvents()
{
await Given(Events).When(SyncOrganisationWithKboCommand, TestUser.AlgemeenBeheerder)
.ThenItPublishesTheCorrectNumberOfEvents(11);
.ThenItPublishesTheCorrectNumberOfEvents(12);
}

[Fact]
Expand Down

0 comments on commit 71bdc00

Please sign in to comment.