mirror of
https://github.com/bitwarden/server
synced 2025-12-21 18:53:41 +00:00
[PM-14894] Drop Tax Rate tables - Stage 1 (#5236)
This commit is contained in:
@@ -9,7 +9,6 @@ public class StripeAdapter : IStripeAdapter
|
||||
private readonly Stripe.SubscriptionService _subscriptionService;
|
||||
private readonly Stripe.InvoiceService _invoiceService;
|
||||
private readonly Stripe.PaymentMethodService _paymentMethodService;
|
||||
private readonly Stripe.TaxRateService _taxRateService;
|
||||
private readonly Stripe.TaxIdService _taxIdService;
|
||||
private readonly Stripe.ChargeService _chargeService;
|
||||
private readonly Stripe.RefundService _refundService;
|
||||
@@ -27,7 +26,6 @@ public class StripeAdapter : IStripeAdapter
|
||||
_subscriptionService = new Stripe.SubscriptionService();
|
||||
_invoiceService = new Stripe.InvoiceService();
|
||||
_paymentMethodService = new Stripe.PaymentMethodService();
|
||||
_taxRateService = new Stripe.TaxRateService();
|
||||
_taxIdService = new Stripe.TaxIdService();
|
||||
_chargeService = new Stripe.ChargeService();
|
||||
_refundService = new Stripe.RefundService();
|
||||
@@ -196,16 +194,6 @@ public class StripeAdapter : IStripeAdapter
|
||||
return _planService.GetAsync(id, options);
|
||||
}
|
||||
|
||||
public Task<Stripe.TaxRate> TaxRateCreateAsync(Stripe.TaxRateCreateOptions options)
|
||||
{
|
||||
return _taxRateService.CreateAsync(options);
|
||||
}
|
||||
|
||||
public Task<Stripe.TaxRate> TaxRateUpdateAsync(string id, Stripe.TaxRateUpdateOptions options)
|
||||
{
|
||||
return _taxRateService.UpdateAsync(id, options);
|
||||
}
|
||||
|
||||
public Task<Stripe.TaxId> TaxIdCreateAsync(string id, Stripe.TaxIdCreateOptions options)
|
||||
{
|
||||
return _taxIdService.CreateAsync(id, options);
|
||||
|
||||
@@ -19,7 +19,6 @@ using Microsoft.Extensions.Logging;
|
||||
using Stripe;
|
||||
using PaymentMethod = Stripe.PaymentMethod;
|
||||
using StaticStore = Bit.Core.Models.StaticStore;
|
||||
using TaxRate = Bit.Core.Entities.TaxRate;
|
||||
|
||||
namespace Bit.Core.Services;
|
||||
|
||||
@@ -33,7 +32,6 @@ public class StripePaymentService : IPaymentService
|
||||
private readonly ITransactionRepository _transactionRepository;
|
||||
private readonly ILogger<StripePaymentService> _logger;
|
||||
private readonly Braintree.IBraintreeGateway _btGateway;
|
||||
private readonly ITaxRateRepository _taxRateRepository;
|
||||
private readonly IStripeAdapter _stripeAdapter;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly IFeatureService _featureService;
|
||||
@@ -43,7 +41,6 @@ public class StripePaymentService : IPaymentService
|
||||
public StripePaymentService(
|
||||
ITransactionRepository transactionRepository,
|
||||
ILogger<StripePaymentService> logger,
|
||||
ITaxRateRepository taxRateRepository,
|
||||
IStripeAdapter stripeAdapter,
|
||||
Braintree.IBraintreeGateway braintreeGateway,
|
||||
IGlobalSettings globalSettings,
|
||||
@@ -53,7 +50,6 @@ public class StripePaymentService : IPaymentService
|
||||
{
|
||||
_transactionRepository = transactionRepository;
|
||||
_logger = logger;
|
||||
_taxRateRepository = taxRateRepository;
|
||||
_stripeAdapter = stripeAdapter;
|
||||
_btGateway = braintreeGateway;
|
||||
_globalSettings = globalSettings;
|
||||
@@ -1778,50 +1774,6 @@ public class StripePaymentService : IPaymentService
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<TaxRate> CreateTaxRateAsync(TaxRate taxRate)
|
||||
{
|
||||
var stripeTaxRateOptions = new TaxRateCreateOptions()
|
||||
{
|
||||
DisplayName = $"{taxRate.Country} - {taxRate.PostalCode}",
|
||||
Inclusive = false,
|
||||
Percentage = taxRate.Rate,
|
||||
Active = true
|
||||
};
|
||||
var stripeTaxRate = await _stripeAdapter.TaxRateCreateAsync(stripeTaxRateOptions);
|
||||
taxRate.Id = stripeTaxRate.Id;
|
||||
await _taxRateRepository.CreateAsync(taxRate);
|
||||
return taxRate;
|
||||
}
|
||||
|
||||
public async Task UpdateTaxRateAsync(TaxRate taxRate)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(taxRate.Id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await ArchiveTaxRateAsync(taxRate);
|
||||
await CreateTaxRateAsync(taxRate);
|
||||
}
|
||||
|
||||
public async Task ArchiveTaxRateAsync(TaxRate taxRate)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(taxRate.Id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var updatedStripeTaxRate = await _stripeAdapter.TaxRateUpdateAsync(
|
||||
taxRate.Id,
|
||||
new TaxRateUpdateOptions() { Active = false }
|
||||
);
|
||||
if (!updatedStripeTaxRate.Active)
|
||||
{
|
||||
taxRate.Active = false;
|
||||
await _taxRateRepository.ArchiveAsync(taxRate);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> AddSecretsManagerToSubscription(
|
||||
Organization org,
|
||||
StaticStore.Plan plan,
|
||||
|
||||
Reference in New Issue
Block a user