1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 23:52:50 -05:00

[AC-2795] Add account credit & tax information to provider subscription (#4276)

* Add account credit, suspension and tax information to subscription response

* Run dotnet format'
This commit is contained in:
Alex Morask
2024-06-26 09:08:18 -04:00
committed by GitHub
parent 6646d11074
commit e8e725c389
7 changed files with 220 additions and 61 deletions

View File

@ -385,19 +385,34 @@ public class ProviderBillingControllerTests
var subscription = new Subscription
{
Status = "active",
CurrentPeriodEnd = new DateTime(2025, 1, 1),
Customer = new Customer { Discount = new Discount { Coupon = new Coupon { PercentOff = 10 } } }
Status = "unpaid",
CurrentPeriodEnd = new DateTime(2024, 6, 30),
Customer = new Customer
{
Balance = 100000,
Discount = new Discount
{
Coupon = new Coupon
{
PercentOff = 10
}
}
}
};
DateTime? SuspensionDate = new DateTime();
DateTime? UnpaidPeriodEndDate = new DateTime();
var gracePeriod = 30;
var taxInformation =
new TaxInformationDTO("US", "12345", "123456789", "123 Example St.", null, "Example Town", "NY");
var suspension = new SubscriptionSuspensionDTO(
new DateTime(2024, 7, 30),
new DateTime(2024, 5, 30),
30);
var consolidatedBillingSubscription = new ConsolidatedBillingSubscriptionDTO(
configuredProviderPlans,
subscription,
SuspensionDate,
UnpaidPeriodEndDate);
taxInformation,
suspension);
sutProvider.GetDependency<IProviderBillingService>().GetConsolidatedBillingSubscription(provider)
.Returns(consolidatedBillingSubscription);
@ -408,13 +423,10 @@ public class ProviderBillingControllerTests
var response = ((Ok<ConsolidatedBillingSubscriptionResponse>)result).Value;
Assert.Equal(response.Status, subscription.Status);
Assert.Equal(response.CurrentPeriodEndDate, subscription.CurrentPeriodEnd);
Assert.Equal(response.DiscountPercentage, subscription.Customer!.Discount!.Coupon!.PercentOff);
Assert.Equal(response.CollectionMethod, subscription.CollectionMethod);
Assert.Equal(response.UnpaidPeriodEndDate, UnpaidPeriodEndDate);
Assert.Equal(response.GracePeriod, gracePeriod);
Assert.Equal(response.SuspensionDate, SuspensionDate);
Assert.Equal(subscription.Status, response.Status);
Assert.Equal(subscription.CurrentPeriodEnd, response.CurrentPeriodEndDate);
Assert.Equal(subscription.Customer!.Discount!.Coupon!.PercentOff, response.DiscountPercentage);
Assert.Equal(subscription.CollectionMethod, response.CollectionMethod);
var teamsPlan = StaticStore.GetPlan(PlanType.TeamsMonthly);
var providerTeamsPlan = response.Plans.FirstOrDefault(plan => plan.PlanName == teamsPlan.Name);
@ -433,7 +445,13 @@ public class ProviderBillingControllerTests
Assert.Equal(90, providerEnterprisePlan.AssignedSeats);
Assert.Equal(100 * enterprisePlan.PasswordManager.ProviderPortalSeatPrice, providerEnterprisePlan.Cost);
Assert.Equal("Monthly", providerEnterprisePlan.Cadence);
Assert.Equal(100000, response.AccountCredit);
Assert.Equal(taxInformation, response.TaxInformation);
Assert.Null(response.CancelAt);
Assert.Equal(suspension, response.Suspension);
}
#endregion
#region GetTaxInformationAsync