mirror of
https://github.com/bitwarden/server.git
synced 2025-07-07 02:52:50 -05:00
Merge pull request #776 from bitwarden/feature/tax-info-collection
Feature/tax info collection
This commit is contained in:
@ -0,0 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class TaxInfoUpdateRequestModel : IValidatableObject
|
||||
{
|
||||
[Required]
|
||||
public string Country { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
|
||||
public virtual IEnumerable<ValidationResult> Validate (ValidationContext validationContext)
|
||||
{
|
||||
if (Country == "US" && string.IsNullOrWhiteSpace(PostalCode))
|
||||
{
|
||||
yield return new ValidationResult("Zip / postal code is required.",
|
||||
new string[] { nameof(PostalCode) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -31,6 +31,15 @@ namespace Bit.Core.Models.Api
|
||||
[EncryptedString]
|
||||
[EncryptedStringLength(1000)]
|
||||
public string CollectionName { get; set; }
|
||||
public string TaxIdNumber { get; set; }
|
||||
public string BillingAddressLine1 { get; set; }
|
||||
public string BillingAddressLine2 { get; set; }
|
||||
public string BillingAddressCity { get; set; }
|
||||
public string BillingAddressState { get; set; }
|
||||
public string BillingAddressPostalCode { get; set; }
|
||||
[Required]
|
||||
[StringLength(2)]
|
||||
public string BillingAddressCountry { get; set; }
|
||||
|
||||
public virtual OrganizationSignup ToOrganizationSignup(User user)
|
||||
{
|
||||
@ -47,7 +56,17 @@ namespace Bit.Core.Models.Api
|
||||
PremiumAccessAddon = PremiumAccessAddon,
|
||||
BillingEmail = BillingEmail,
|
||||
BusinessName = BusinessName,
|
||||
CollectionName = CollectionName
|
||||
CollectionName = CollectionName,
|
||||
TaxInfo = new TaxInfo
|
||||
{
|
||||
TaxIdNumber = TaxIdNumber,
|
||||
BillingAddressLine1 = BillingAddressLine1,
|
||||
BillingAddressLine2 = BillingAddressLine2,
|
||||
BillingAddressCity = BillingAddressCity,
|
||||
BillingAddressState = BillingAddressState,
|
||||
BillingAddressPostalCode = BillingAddressPostalCode,
|
||||
BillingAddressCountry = BillingAddressCountry,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -62,6 +81,17 @@ namespace Bit.Core.Models.Api
|
||||
yield return new ValidationResult("Payment method type required.",
|
||||
new string[] { nameof(PaymentMethodType) });
|
||||
}
|
||||
if (PlanType != PlanType.Free && string.IsNullOrWhiteSpace(BillingAddressCountry))
|
||||
{
|
||||
yield return new ValidationResult("Country required.",
|
||||
new string[] { nameof(BillingAddressCountry) });
|
||||
}
|
||||
if (PlanType != PlanType.Free && BillingAddressCountry == "US" &&
|
||||
string.IsNullOrWhiteSpace(BillingAddressPostalCode))
|
||||
{
|
||||
yield return new ValidationResult("Zip / postal code is required.",
|
||||
new string[] { nameof(BillingAddressPostalCode) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class OrganizationTaxInfoUpdateRequestModel : TaxInfoUpdateRequestModel
|
||||
{
|
||||
public string TaxId { get; set; }
|
||||
public string Line1 { get; set; }
|
||||
public string Line2 { get; set; }
|
||||
public string City { get; set; }
|
||||
public string State { get; set; }
|
||||
}
|
||||
}
|
35
src/Core/Models/Api/Response/TaxInfoResponseModel.cs
Normal file
35
src/Core/Models/Api/Response/TaxInfoResponseModel.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using Bit.Core.Models.Business;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class TaxInfoResponseModel
|
||||
{
|
||||
public TaxInfoResponseModel() { }
|
||||
|
||||
public TaxInfoResponseModel(TaxInfo taxInfo)
|
||||
{
|
||||
if (taxInfo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TaxIdNumber = taxInfo.TaxIdNumber;
|
||||
TaxIdType = taxInfo.TaxIdType;
|
||||
Line1 = taxInfo.BillingAddressLine1;
|
||||
Line2 = taxInfo.BillingAddressLine2;
|
||||
City = taxInfo.BillingAddressCity;
|
||||
State = taxInfo.BillingAddressState;
|
||||
PostalCode = taxInfo.BillingAddressPostalCode;
|
||||
Country = taxInfo.BillingAddressCountry;
|
||||
}
|
||||
|
||||
public string TaxIdNumber { get; set; }
|
||||
public string TaxIdType { get; set; }
|
||||
public string Line1 { get; set; }
|
||||
public string Line2 { get; set; }
|
||||
public string City { get; set; }
|
||||
public string State { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public string Country { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user