From d001fe7ae7800d24c0cfde0d2a9c7793b0a673a3 Mon Sep 17 00:00:00 2001 From: SondreJDigdir Date: Mon, 16 Sep 2024 11:11:40 +0200 Subject: [PATCH] Dont fetch accounts information for ENK (#6) --- src/Dan.Plugin.Tilda/Tilda.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Dan.Plugin.Tilda/Tilda.cs b/src/Dan.Plugin.Tilda/Tilda.cs index a908c51..b9c045a 100644 --- a/src/Dan.Plugin.Tilda/Tilda.cs +++ b/src/Dan.Plugin.Tilda/Tilda.cs @@ -447,15 +447,16 @@ private async Task> GetOrganizationsFromBR(string organ { var result = new List(); var brResult = await Helpers.GetFromBR(organizationNumber, _erClient, false, _policyRegistry); + var brEntity = brResult.First(); AccountsInformation accountsInformation = null; - if (string.IsNullOrEmpty(brResult.First().OverordnetEnhet)) + if (string.IsNullOrEmpty(brEntity.OverordnetEnhet) && brEntity.Organisasjonsform.Kode != "ENK") { accountsInformation = await Helpers.GetAnnualTurnoverFromBR(organizationNumber, _client, _policyRegistry); } var kofuviAddresses = await Helpers.GetKofuviAddresses(_settings.KofuviEndpoint, organizationNumber, _kofuviClient, _logger); - var organization = await ConvertBRtoTilda(brResult.First(), accountsInformation); + var organization = await ConvertBRtoTilda(brEntity, accountsInformation); if (kofuviAddresses.Count > 0) { organization.Emails = kofuviAddresses; @@ -467,12 +468,17 @@ private async Task> GetOrganizationsFromBR(string organ private async Task GetOrganizationFromBR(string organizationNumber) { - var brResultTask = await Helpers.GetFromBR(organizationNumber, _erClient, false, _policyRegistry); - var accountsInformationTask = await Helpers.GetAnnualTurnoverFromBR(organizationNumber, _client, _policyRegistry); + var brResult = await Helpers.GetFromBR(organizationNumber, _erClient, false, _policyRegistry); + var brEntity = brResult.First(); + AccountsInformation accountsInformation = null; + if (brEntity.Organisasjonsform.Kode != "ENK") + { + accountsInformation = await Helpers.GetAnnualTurnoverFromBR(organizationNumber, _client, _policyRegistry); + } var kofuviAddresses = await Helpers.GetKofuviAddresses(_settings.KofuviEndpoint, organizationNumber, _kofuviClient, _logger); - var organization = await ConvertBRtoTilda(brResultTask.First(), accountsInformationTask); + var organization = await ConvertBRtoTilda(brEntity, accountsInformation); if (kofuviAddresses.Count > 0) { organization.Emails = kofuviAddresses;