Skip to content

Commit

Permalink
We may not need this here.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonashendrickx committed Nov 12, 2024
1 parent d5eb62a commit 0c5844d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 56 deletions.
7 changes: 0 additions & 7 deletions src/Billing/Services/Implementations/ProviderEventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ public async Task TryRecordInvoiceLineItems(Event parsedEvent)

var providerPlans = await providerPlanRepository.GetByProviderId(parsedProviderId);

if (providerPlans.Any(x => !x.IsConfigured()))
{
logger.LogError("Provider {ProviderID} is missing or has misconfigured provider plans", parsedProviderId);

throw new Exception("Cannot record invoice line items for Provider with missing or misconfigured provider plans");
}

var invoiceItems = new List<ProviderInvoiceItem>();

foreach (var client in clients)
Expand Down
49 changes: 0 additions & 49 deletions test/Billing.Test/Services/ProviderEventServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Bit.Core.Billing.Repositories;
using Bit.Core.Enums;
using Bit.Core.Utilities;
using FluentAssertions;
using Microsoft.Extensions.Logging;
using NSubstitute;
using Stripe;
Expand Down Expand Up @@ -89,54 +88,6 @@ public async Task TryRecordInvoiceLineItems_EventNotProviderRelated_NoOp()
await _providerOrganizationRepository.DidNotReceiveWithAnyArgs().GetManyDetailsByProviderAsync(Arg.Any<Guid>());
}

[Fact]
public async Task TryRecordInvoiceLineItems_InvoiceCreated_MisconfiguredProviderPlans_ThrowsException()
{
// Arrange
var stripeEvent = await StripeTestEvents.GetAsync(StripeEventType.InvoiceCreated);

const string subscriptionId = "sub_1";
var providerId = Guid.NewGuid();

var invoice = new Invoice
{
SubscriptionId = subscriptionId
};

_stripeEventService.GetInvoice(stripeEvent).Returns(invoice);

var subscription = new Subscription
{
Metadata = new Dictionary<string, string> { { "providerId", providerId.ToString() } }
};

_stripeFacade.GetSubscription(subscriptionId).Returns(subscription);

var providerPlans = new List<ProviderPlan>
{
new ()
{
Id = Guid.NewGuid(),
ProviderId = providerId,
PlanType = PlanType.TeamsMonthly,
AllocatedSeats = 0,
PurchasedSeats = 0,
SeatMinimum = 100
}
};

_providerPlanRepository.GetByProviderId(providerId).Returns(providerPlans);

// Act
var function = async () => await _providerEventService.TryRecordInvoiceLineItems(stripeEvent);

// Assert
await function
.Should()
.ThrowAsync<Exception>()
.WithMessage("Cannot record invoice line items for Provider with missing or misconfigured provider plans");
}

[Fact]
public async Task TryRecordInvoiceLineItems_InvoiceCreated_Succeeds()
{
Expand Down

0 comments on commit 0c5844d

Please sign in to comment.