Skip to content

Commit

Permalink
feat: or-2067 allow KBO in oprichting
Browse files Browse the repository at this point in the history
  • Loading branch information
QuintenGreenstack committed Feb 5, 2024
1 parent e27f9df commit c77c16e
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 4 deletions.
1 change: 1 addition & 0 deletions AssociationRegistry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GeefOndernemingResponses",
wiremock\__files\GeefOndernemingResponses\2289324120.vestiging.xml = wiremock\__files\GeefOndernemingResponses\2289324120.vestiging.xml
wiremock\__files\GeefOndernemingResponses\0407622110.xml = wiremock\__files\GeefOndernemingResponses\0407622110.xml
wiremock\__files\GeefOndernemingResponses\0408498573.xml = wiremock\__files\GeefOndernemingResponses\0408498573.xml
wiremock\__files\GeefOndernemingResponses\0407622011.xml = wiremock\__files\GeefOndernemingResponses\0407622011.xml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssociationRegistry.Hosts", "src\AssociationRegistry.Hosts\AssociationRegistry.Hosts.csproj", "{F0853B2C-FEAB-4ACF-92D5-D9FBC3DA1427}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ public async Task<Result<VerenigingVolgensKbo>> GeefVereniging(
return HandleUitzonderingen(kboNummer, magdaResponse);

var magdaOnderneming = magdaResponse?.Body?.GeefOndernemingResponse?.Repliek.Antwoorden.Antwoord.Inhoud.Onderneming ?? null;

if (magdaOnderneming is null ||
!HeeftToegestaneActieveRechtsvorm(magdaOnderneming) ||
!IsOnderneming(magdaOnderneming) ||
!IsActief(magdaOnderneming) ||
!IsActiefOfInOprichting(magdaOnderneming) ||
!IsRechtspersoon(magdaOnderneming))
return VerenigingVolgensKboResult.GeenGeldigeVereniging;

Expand Down Expand Up @@ -98,6 +97,9 @@ public async Task<Result<VerenigingVolgensKbo>> GeefVereniging(
}
}

private static bool IsActiefOfInOprichting(Onderneming2_0Type magdaOnderneming)
=> IsActief(magdaOnderneming) || IsInOprichting(magdaOnderneming);

private VertegenwoordigerVolgensKbo[] GetVertegenwoordigers()
=> _temporaryMagdaVertegenwoordigersSection.TemporaryVertegenwoordigers
.Select(x => new VertegenwoordigerVolgensKbo
Expand Down Expand Up @@ -202,6 +204,9 @@ private static bool IsRechtspersoon(Onderneming2_0Type magdaOnderneming)
private static bool IsActief(Onderneming2_0Type magdaOnderneming)
=> magdaOnderneming.StatusKBO.Code.Value == StatusKBOCodes.Actief;

private static bool IsInOprichting(Onderneming2_0Type magdaOnderneming)
=> magdaOnderneming.StatusKBO.Code.Value == StatusKBOCodes.InOprichting;

private static bool IsOnderneming(Onderneming2_0Type magdaOnderneming)
=> magdaOnderneming.OndernemingOfVestiging.Code.Value == OndernemingOfVestigingCodes.Onderneming;

Expand Down
1 change: 1 addition & 0 deletions src/AssociationRegistry.Magda/Constants/StatusKBOCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
public static class StatusKBOCodes
{
public const string Actief = "AC";
public const string InOprichting = "JU";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
namespace AssociationRegistry.Test.Admin.Api.Magda.MagdaKboService.When_Retrieving_VerenigingVolgensKbo.Status;

using AssociationRegistry.Admin.Api.Magda;
using AssociationRegistry.Framework;
using AssociationRegistry.Kbo;
using AssociationRegistry.Magda;
using AssociationRegistry.Magda.Configuration;
using AssociationRegistry.Magda.Constants;
using AssociationRegistry.Magda.Models;
using AssociationRegistry.Magda.Models.GeefOnderneming;
using AssociationRegistry.Magda.Onderneming.GeefOnderneming;
using AssociationRegistry.Test.Admin.Api.Framework;
using AssociationRegistry.Vereniging;
using AutoFixture;
using FluentAssertions;
using FluentAssertions.Execution;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using ResultNet;
using Xunit;
using Xunit.Categories;

[UnitTest]
public class Given_A_GeefOndernemingResponseBody_Which_Is_Active
{
private readonly MagdaGeefVerenigingService _service;
private readonly Fixture _fixture;

public Given_A_GeefOndernemingResponseBody_Which_Is_Active()
{
_fixture = new Fixture().CustomizeAdminApi();

var magdaFacade = new Mock<IMagdaFacade>();
var responseEnvelope = _fixture.Create<ResponseEnvelope<GeefOndernemingResponseBody>>();

responseEnvelope.Body!.GeefOndernemingResponse!.Repliek.Antwoorden.Antwoord.Inhoud.Onderneming.StatusKBO = new StatusKBOType
{
Code = new CodeStatusKBOType
{
Value = StatusKBOCodes.Actief,
},
};

magdaFacade.Setup(facade => facade.GeefOnderneming(It.IsAny<string>(), It.IsAny<MagdaCallReference>()))
.ReturnsAsync(responseEnvelope);

_service = new MagdaGeefVerenigingService(Mock.Of<IMagdaCallReferenceRepository>(), magdaFacade.Object,
new TemporaryMagdaVertegenwoordigersSection(),
new NullLogger<MagdaGeefVerenigingService>());
}

[Fact]
public async Task Then_It_Returns_A_SuccessResult()
{
var result = await _service.GeefVereniging(_fixture.Create<KboNummer>(), _fixture.Create<CommandMetadata>(),
CancellationToken.None);

result.IsSuccess().Should().BeTrue();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
namespace AssociationRegistry.Test.Admin.Api.Magda.MagdaKboService.When_Retrieving_VerenigingVolgensKbo.Status;

using AssociationRegistry.Admin.Api.Magda;
using AssociationRegistry.Framework;
using AssociationRegistry.Magda;
using AssociationRegistry.Magda.Configuration;
using AssociationRegistry.Magda.Constants;
using AssociationRegistry.Magda.Models;
using AssociationRegistry.Magda.Models.GeefOnderneming;
using AssociationRegistry.Magda.Onderneming.GeefOnderneming;
using AutoFixture;
using FluentAssertions;
using Framework;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using ResultNet;
using Vereniging;
using Xunit;
using Xunit.Categories;

[UnitTest]
public class Given_A_GeefOndernemingResponseBody_Which_Is_In_Oprichting
{
private readonly MagdaGeefVerenigingService _service;
private readonly Fixture _fixture;

public Given_A_GeefOndernemingResponseBody_Which_Is_In_Oprichting()
{
_fixture = new Fixture().CustomizeAdminApi();

var magdaFacade = new Mock<IMagdaFacade>();
var responseEnvelope = _fixture.Create<ResponseEnvelope<GeefOndernemingResponseBody>>();

responseEnvelope.Body!.GeefOndernemingResponse!.Repliek.Antwoorden.Antwoord.Inhoud.Onderneming.StatusKBO = new StatusKBOType
{
Code = new CodeStatusKBOType
{
Value = StatusKBOCodes.InOprichting,
},
};

magdaFacade.Setup(facade => facade.GeefOnderneming(It.IsAny<string>(), It.IsAny<MagdaCallReference>()))
.ReturnsAsync(responseEnvelope);

_service = new MagdaGeefVerenigingService(Mock.Of<IMagdaCallReferenceRepository>(), magdaFacade.Object,
new TemporaryMagdaVertegenwoordigersSection(),
new NullLogger<MagdaGeefVerenigingService>());
}

[Fact]
public async Task Then_It_Returns_A_SuccessResult()
{
var result = await _service.GeefVereniging(_fixture.Create<KboNummer>(), _fixture.Create<CommandMetadata>(),
CancellationToken.None);

result.IsSuccess().Should().BeTrue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
using Xunit.Categories;

[UnitTest]
public class Given_A_GeefOndernemingResponseBody_Which_Is_Not_Active
public class Given_A_GeefOndernemingResponseBody_With_An_Unsupported_Status
{
private readonly MagdaGeefVerenigingService _service;
private readonly Fixture _fixture;

public Given_A_GeefOndernemingResponseBody_Which_Is_Not_Active()
public Given_A_GeefOndernemingResponseBody_With_An_Unsupported_Status()
{
_fixture = new Fixture().CustomizeAdminApi();

Expand Down
122 changes: 122 additions & 0 deletions wiremock/__files/GeefOndernemingResponses/0407622011.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" />
<SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<web:GeefOndernemingResponse
xmlns:web="http://webservice.geefondernemingdienst-02_00.onderneming-02_00.vip.vlaanderen.be">
<Repliek>
<Context>
<Naam>GeefOnderneming</Naam>
<Versie>02.00.0000</Versie>
<Bericht>
<Type>ANTWOORD</Type>
<Tijdstip>
<Datum>2023-08-10</Datum>
<Tijd>09:45:34.243</Tijd>
</Tijdstip>
<Afzender>
<Identificatie>vip.vlaanderen.be</Identificatie>
<Naam>MagdaGateway</Naam>
<Referte>202bfd76-aa75-4265-b560-936beeb77f86</Referte>
</Afzender>
<Ontvanger>
<Identificatie>kbbj.vlaanderen.be/dv/verenigingsregister-aip</Identificatie>
<Referte>AREF_QT_610527_134233</Referte>
<Hoedanigheid />
</Ontvanger>
</Bericht>
</Context>
<Antwoorden>
<Antwoord>
<Referte>efb55ac2-5421-4a7f-bb25-26b1b8a5eb10</Referte>
<Inhoud>
<Onderneming>
<Ondernemingsnummer>0407622011</Ondernemingsnummer>
<AuthentiekBron>
<Code>03</Code>
<Omschrijving>KBO</Omschrijving>
</AuthentiekBron>
<OndernemingOfVestiging>
<Code Beschrijving="Onderneming">1</Code>
</OndernemingOfVestiging>
<StatusKBO>
<Code>JU</Code>
</StatusKBO>
<SoortOnderneming>
<Code Beschrijving="Rechtspersoon">2</Code>
</SoortOnderneming>
<Namen>
<MaatschappelijkeNamen>
<MaatschappelijkeNaam DatumBegin="2004-10-11">
<Naam>Jeugdraad Lille vzw De Bosuil</Naam>
<Taalcode>nl</Taalcode>
</MaatschappelijkeNaam>
</MaatschappelijkeNamen>
<AfgekorteNamen>
<AfgekorteNaam DatumBegin="2004-10-11">
<Naam>Jeugdraad Lille vzw of De Bosuil</Naam>
<Taalcode>nl</Taalcode>
</AfgekorteNaam>
</AfgekorteNamen>
</Namen>
<Adressen>
<Adres DatumBegin="1995-06-08">
<Straat>
<Code>8020</Code>
</Straat>
<Huisnummer>4</Huisnummer>
<Gemeente>
<NISCode>72025</NISCode>
<PostCode>3910</PostCode>
</Gemeente>
<Land>
<NISCode>150</NISCode>
<ISOCode>BE</ISOCode>
<Naam>BELGIE</Naam>
</Land>
<Type>
<Code>001</Code>
</Type>
<Descripties>
<Descriptie>
<Adres>
<Straat>
<Naam>Bosuilstraat(SHL)</Naam>
</Straat>
<Gemeente>
<Naam>Neerpelt</Naam>
</Gemeente>
<Land>
<NISCode>150</NISCode>
<Naam>Belgi&#235;</Naam>
</Land>
</Adres>
<Contact>
<Telefoonnummer>011642985</Telefoonnummer>
<Faxnummer>011663513</Faxnummer>
<Email>info@opdebosuil.be</Email>
<Website>www.opdebosuil.be</Website>
</Contact>
</Descriptie>
</Descripties>
</Adres>
</Adressen>
<Start>
<Datum>1964-12-17</Datum>
</Start>
<Inschrijving>
<Datum>2003-01-18</Datum>
</Inschrijving>
<Rechtsvormen>
<Rechtsvorm DatumBegin="1964-12-17">
<Code>017</Code>
</Rechtsvorm>
</Rechtsvormen>
</Onderneming>
</Inhoud>
</Antwoord>
</Antwoorden>
</Repliek>
</web:GeefOndernemingResponse>
</SOAP-ENV:Body>
</soapenv:Envelope>

0 comments on commit c77c16e

Please sign in to comment.