From a2e1eb79d2fa83ea948dec8180663e73df9ce8b4 Mon Sep 17 00:00:00 2001 From: Alex Morask <144709477+amorask-bitwarden@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:02:17 -0400 Subject: [PATCH] [AC-2947] Fix provider account credit display (#4590) * Fix provider account credit * Fix test --- .../Models/Responses/ProviderSubscriptionResponse.cs | 6 ++++-- .../Billing/Controllers/ProviderBillingControllerTests.cs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Api/Billing/Models/Responses/ProviderSubscriptionResponse.cs b/src/Api/Billing/Models/Responses/ProviderSubscriptionResponse.cs index ded2e027c..e9902f98b 100644 --- a/src/Api/Billing/Models/Responses/ProviderSubscriptionResponse.cs +++ b/src/Api/Billing/Models/Responses/ProviderSubscriptionResponse.cs @@ -11,7 +11,7 @@ public record ProviderSubscriptionResponse( decimal? DiscountPercentage, string CollectionMethod, IEnumerable Plans, - long AccountCredit, + decimal AccountCredit, TaxInformation TaxInformation, DateTime? CancelAt, SubscriptionSuspension Suspension) @@ -42,13 +42,15 @@ public record ProviderSubscriptionResponse( cadence); }); + var accountCredit = Convert.ToDecimal(subscription.Customer?.Balance) * -1 / 100; + return new ProviderSubscriptionResponse( subscription.Status, subscription.CurrentPeriodEnd, subscription.Customer?.Discount?.Coupon?.PercentOff, subscription.CollectionMethod, providerPlanResponses, - subscription.Customer?.Balance ?? 0, + accountCredit, taxInformation, subscription.CancelAt, subscriptionSuspension); diff --git a/test/Api.Test/Billing/Controllers/ProviderBillingControllerTests.cs b/test/Api.Test/Billing/Controllers/ProviderBillingControllerTests.cs index e596b5e3d..03f486342 100644 --- a/test/Api.Test/Billing/Controllers/ProviderBillingControllerTests.cs +++ b/test/Api.Test/Billing/Controllers/ProviderBillingControllerTests.cs @@ -323,7 +323,7 @@ public class ProviderBillingControllerTests City = "Example Town", State = "NY" }, - Balance = 100000, + Balance = -100000, Discount = new Discount { Coupon = new Coupon { PercentOff = 10 } }, TaxIds = new StripeList { Data = [new TaxId { Value = "123456789" }] } }, @@ -404,7 +404,7 @@ public class ProviderBillingControllerTests Assert.Equal(100 * enterprisePlan.PasswordManager.ProviderPortalSeatPrice, providerEnterprisePlan.Cost); Assert.Equal("Monthly", providerEnterprisePlan.Cadence); - Assert.Equal(100000, response.AccountCredit); + Assert.Equal(1000.00M, response.AccountCredit); var customer = subscription.Customer; Assert.Equal(customer.Address.Country, response.TaxInformation.Country);