From 2e635c950532ff9c116a07b190dea9449aa24ea8 Mon Sep 17 00:00:00 2001 From: Alex Morask <144709477+amorask-bitwarden@users.noreply.github.com> Date: Mon, 11 Nov 2024 10:02:21 -0500 Subject: [PATCH] Create ProviderInvoiceItems for empty invoices (#5021) --- .../Implementations/ProviderEventService.cs | 46 ++++++++----------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/src/Billing/Services/Implementations/ProviderEventService.cs b/src/Billing/Services/Implementations/ProviderEventService.cs index e716f8f16..7ce72526c 100644 --- a/src/Billing/Services/Implementations/ProviderEventService.cs +++ b/src/Billing/Services/Implementations/ProviderEventService.cs @@ -94,20 +94,17 @@ public class ProviderEventService( var unassignedEnterpriseSeats = enterpriseProviderPlan.SeatMinimum - enterpriseClientSeats ?? 0; - if (unassignedEnterpriseSeats > 0) + invoiceItems.Add(new ProviderInvoiceItem { - invoiceItems.Add(new ProviderInvoiceItem - { - ProviderId = parsedProviderId, - InvoiceId = invoice.Id, - InvoiceNumber = invoice.Number, - ClientName = "Unassigned seats", - PlanName = enterprisePlan.Name, - AssignedSeats = unassignedEnterpriseSeats, - UsedSeats = 0, - Total = unassignedEnterpriseSeats * discountedEnterpriseSeatPrice - }); - } + ProviderId = parsedProviderId, + InvoiceId = invoice.Id, + InvoiceNumber = invoice.Number, + ClientName = "Unassigned seats", + PlanName = enterprisePlan.Name, + AssignedSeats = unassignedEnterpriseSeats, + UsedSeats = 0, + Total = unassignedEnterpriseSeats * discountedEnterpriseSeatPrice + }); } if (teamsProviderPlan.PurchasedSeats is null or 0) @@ -118,20 +115,17 @@ public class ProviderEventService( var unassignedTeamsSeats = teamsProviderPlan.SeatMinimum - teamsClientSeats ?? 0; - if (unassignedTeamsSeats > 0) + invoiceItems.Add(new ProviderInvoiceItem { - invoiceItems.Add(new ProviderInvoiceItem - { - ProviderId = parsedProviderId, - InvoiceId = invoice.Id, - InvoiceNumber = invoice.Number, - ClientName = "Unassigned seats", - PlanName = teamsPlan.Name, - AssignedSeats = unassignedTeamsSeats, - UsedSeats = 0, - Total = unassignedTeamsSeats * discountedTeamsSeatPrice - }); - } + ProviderId = parsedProviderId, + InvoiceId = invoice.Id, + InvoiceNumber = invoice.Number, + ClientName = "Unassigned seats", + PlanName = teamsPlan.Name, + AssignedSeats = unassignedTeamsSeats, + UsedSeats = 0, + Total = unassignedTeamsSeats * discountedTeamsSeatPrice + }); } await Task.WhenAll(invoiceItems.Select(providerInvoiceItemRepository.CreateAsync));