1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 09:02:48 -05:00

started charging sales tax on seat/storage upgrades and auto renewals (#1034)

* started charging sales tax on seat/storage upgrades and auto renewals

* Code review fixes for auto-renewing subscriptions charging sales tax
This commit is contained in:
Addison Beck
2020-12-09 14:04:46 -05:00
committed by GitHub
parent 7d3fb55b2d
commit fee5c932db
5 changed files with 83 additions and 8 deletions

View File

@ -684,7 +684,7 @@ namespace Bit.Core.Services
// Retain original collection method
var collectionMethod = sub.CollectionMethod;
var subResponse = await subscriptionService.UpdateAsync(sub.Id, new SubscriptionUpdateOptions
var subUpdateOptions = new SubscriptionUpdateOptions
{
Items = new List<SubscriptionItemOptions>
{
@ -700,7 +700,26 @@ namespace Bit.Core.Services
DaysUntilDue = 1,
CollectionMethod = "send_invoice",
ProrationDate = prorationDate,
});
};
var customer = await new CustomerService().GetAsync(sub.CustomerId);
var taxRates = await _taxRateRepository.GetByLocationAsync(
new Bit.Core.Models.Table.TaxRate()
{
Country = customer.Address.Country,
PostalCode = customer.Address.PostalCode
}
);
var taxRate = taxRates.FirstOrDefault();
if (taxRate != null && !sub.DefaultTaxRates.Any(x => x.Equals(taxRate.Id)))
{
subUpdateOptions.DefaultTaxRates = new List<string>(1)
{
taxRate.Id
};
}
var subResponse = await subscriptionService.UpdateAsync(sub.Id, subUpdateOptions);
string paymentIntentClientSecret = null;
if (additionalStorage > 0)