1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

[AC-2947] Fix provider account credit display (#4590)

* Fix provider account credit

* Fix test
This commit is contained in:
Alex Morask 2024-08-05 11:02:17 -04:00 committed by GitHub
parent 1f09233760
commit a2e1eb79d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -11,7 +11,7 @@ public record ProviderSubscriptionResponse(
decimal? DiscountPercentage, decimal? DiscountPercentage,
string CollectionMethod, string CollectionMethod,
IEnumerable<ProviderPlanResponse> Plans, IEnumerable<ProviderPlanResponse> Plans,
long AccountCredit, decimal AccountCredit,
TaxInformation TaxInformation, TaxInformation TaxInformation,
DateTime? CancelAt, DateTime? CancelAt,
SubscriptionSuspension Suspension) SubscriptionSuspension Suspension)
@ -42,13 +42,15 @@ public record ProviderSubscriptionResponse(
cadence); cadence);
}); });
var accountCredit = Convert.ToDecimal(subscription.Customer?.Balance) * -1 / 100;
return new ProviderSubscriptionResponse( return new ProviderSubscriptionResponse(
subscription.Status, subscription.Status,
subscription.CurrentPeriodEnd, subscription.CurrentPeriodEnd,
subscription.Customer?.Discount?.Coupon?.PercentOff, subscription.Customer?.Discount?.Coupon?.PercentOff,
subscription.CollectionMethod, subscription.CollectionMethod,
providerPlanResponses, providerPlanResponses,
subscription.Customer?.Balance ?? 0, accountCredit,
taxInformation, taxInformation,
subscription.CancelAt, subscription.CancelAt,
subscriptionSuspension); subscriptionSuspension);

View File

@ -323,7 +323,7 @@ public class ProviderBillingControllerTests
City = "Example Town", City = "Example Town",
State = "NY" State = "NY"
}, },
Balance = 100000, Balance = -100000,
Discount = new Discount { Coupon = new Coupon { PercentOff = 10 } }, Discount = new Discount { Coupon = new Coupon { PercentOff = 10 } },
TaxIds = new StripeList<TaxId> { Data = [new TaxId { Value = "123456789" }] } TaxIds = new StripeList<TaxId> { Data = [new TaxId { Value = "123456789" }] }
}, },
@ -404,7 +404,7 @@ public class ProviderBillingControllerTests
Assert.Equal(100 * enterprisePlan.PasswordManager.ProviderPortalSeatPrice, providerEnterprisePlan.Cost); Assert.Equal(100 * enterprisePlan.PasswordManager.ProviderPortalSeatPrice, providerEnterprisePlan.Cost);
Assert.Equal("Monthly", providerEnterprisePlan.Cadence); Assert.Equal("Monthly", providerEnterprisePlan.Cadence);
Assert.Equal(100000, response.AccountCredit); Assert.Equal(1000.00M, response.AccountCredit);
var customer = subscription.Customer; var customer = subscription.Customer;
Assert.Equal(customer.Address.Country, response.TaxInformation.Country); Assert.Equal(customer.Address.Country, response.TaxInformation.Country);