Skip to content

Commit

Permalink
Dont fetch accounts information for ENK (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
SondreJDigdir authored Sep 16, 2024
1 parent 125b7c9 commit d001fe7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Dan.Plugin.Tilda/Tilda.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,15 +447,16 @@ private async Task<List<TildaRegistryEntry>> GetOrganizationsFromBR(string organ
{
var result = new List<TildaRegistryEntry>();
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;
Expand All @@ -467,12 +468,17 @@ private async Task<List<TildaRegistryEntry>> GetOrganizationsFromBR(string organ

private async Task<TildaRegistryEntry> 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;
Expand Down

0 comments on commit d001fe7

Please sign in to comment.