Files
server/src/Core/Billing/Extensions/CustomerExtensions.cs
Alex Morask 7b3e2a80f4 [PM-21092] Set tax exemption to reverse charge for non-US business-use customers (#5812)
* Set automatic tax to enabled and tax exempt to reverse where applicable when ff is on

* Fix and add tests

* Run dotnet format

* Run dotnet format

* PM-21745: Resolve defect

* PM-21770: Resolve defect

* Run dotnet format'
2025-05-19 14:53:48 -04:00

30 lines
967 B
C#

using Bit.Core.Billing.Constants;
using Stripe;
namespace Bit.Core.Billing.Extensions;
public static class CustomerExtensions
{
public static bool HasBillingLocation(this Customer customer)
=> customer is
{
Address:
{
Country: not null and not "",
PostalCode: not null and not ""
}
};
public static bool HasRecognizedTaxLocation(this Customer customer) =>
customer?.Tax?.AutomaticTax != StripeConstants.AutomaticTaxStatus.UnrecognizedLocation;
public static decimal GetBillingBalance(this Customer customer)
{
return customer != null ? customer.Balance / 100M : default;
}
public static bool ApprovedToPayByInvoice(this Customer customer)
=> customer.Metadata.TryGetValue(StripeConstants.MetadataKeys.InvoiceApproved, out var value) &&
int.TryParse(value, out var invoiceApproved) && invoiceApproved == 1;
}