Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-14892] Sales tax estimation for individuals #5045

Closed
wants to merge 19 commits into from

Conversation

jonashendrickx
Copy link
Member

@jonashendrickx jonashendrickx commented Nov 19, 2024

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-14892

📔 Objective

  • Detect the tax id type using the user's or organization's country & regular expressions.
  • Catching the StripeExceptions related to invalid tax ids and return a 400 while returning our own error codes to display a localized error message.
  • Calculate the sales tax accurately using Stripe's invoice previewing API.
  • Discounts are taken into account if an existing customer or subscription exists in Stripe when calling the invoice preview endpoint.
  • Moving supported countries by Stripe Tax to the back-end. This helps consolidate some business logic.
  • WARNING: There is impact on creating organizations as well. Given the entered tax ids are now validated differently to determine the tax id type for Stripe. Creating an organization using Families/Teams/Enterprise plan were still confirmed to be working with and without a tax id entered.

📸 Screenshots

See comment section on https://bitwarden.atlassian.net/browse/PM-13999 for recording.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link
Contributor

github-actions bot commented Nov 19, 2024

Logo
Checkmarx One – Scan Summary & Details21231eb5-5673-463f-9872-dea31dfe5d88

New Issues

Severity Issue Source File / Package Checkmarx Insight
MEDIUM CSRF /src/Api/Billing/Controllers/AccountsBillingController.cs: 83 Attack Vector
MEDIUM Missing_HSTS_Header /src/Admin/Views/Home/Index.cshtml: 14 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/AccountsBillingController.cs: 83 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/AccountsBillingController.cs: 83 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/AccountsBillingController.cs: 83 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 184 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 169 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationBillingController.cs: 166 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationBillingController.cs: 166 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 822 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationsController.cs: 105 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 822 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationsController.cs: 105 Attack Vector
LOW Log_Forging /src/Api/Auth/Controllers/AccountsController.cs: 822 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationsController.cs: 105 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationBillingController.cs: 166 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationBillingController.cs: 251 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationsController.cs: 301 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/ProviderBillingController.cs: 104 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationBillingController.cs: 166 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationBillingController.cs: 251 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationsController.cs: 301 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/ProviderBillingController.cs: 104 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationBillingController.cs: 251 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/OrganizationsController.cs: 301 Attack Vector
LOW Log_Forging /src/Api/Billing/Controllers/ProviderBillingController.cs: 104 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 402 Attack Vector
LOW Log_Forging /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 339 Attack Vector
LOW Missing_CSP_Header /src/Core/MailTemplates/Handlebars/FamiliesForEnterprise/FamiliesForEnterpriseRemovedFromFamilyUser.html.hbs: 5 Attack Vector

Fixed Issues

Severity Issue Source File / Package
MEDIUM CSRF /src/Api/AdminConsole/Public/Controllers/MembersController.cs: 95
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationsController.cs: 122
MEDIUM CSRF /src/Admin/AdminConsole/Controllers/OrganizationsController.cs: 372
MEDIUM CSRF /src/Api/Billing/Controllers/OrganizationSponsorshipsController.cs: 77
MEDIUM CSRF /src/Api/Billing/Controllers/OrganizationSponsorshipsController.cs: 163

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 77.09924% with 270 lines in your changes missing coverage. Please review.

Project coverage is 43.71%. Comparing base (77cde50) to head (7fc9d51).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...e/Services/Implementations/StripePaymentService.cs 4.31% 132 Missing and 1 partial ⚠️
...ices/Implementations/OrganizationBillingService.cs 7.40% 25 Missing ⚠️
...vices/Implementations/PremiumUserBillingService.cs 7.40% 25 Missing ⚠️
...ling/Services/Implementations/SubscriberService.cs 22.58% 23 Missing and 1 partial ⚠️
...Api/Billing/Controllers/OrganizationsController.cs 0.00% 10 Missing ⚠️
src/Core/Billing/Extensions/CurrencyExtensions.cs 0.00% 9 Missing ⚠️
...i/Billing/Controllers/AccountsBillingController.cs 0.00% 8 Missing ⚠️
src/Core/Services/Implementations/StripeAdapter.cs 14.28% 6 Missing ⚠️
...odels/Api/Responses/PreviewInvoiceResponseModel.cs 0.00% 5 Missing ⚠️
src/Core/Billing/Models/PreviewInvoiceInfo.cs 0.00% 5 Missing ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5045      +/-   ##
==========================================
+ Coverage   43.05%   43.71%   +0.65%     
==========================================
  Files        1412     1421       +9     
  Lines       64770    65757     +987     
  Branches     5919     5939      +20     
==========================================
+ Hits        27888    28746     +858     
- Misses      35649    35776     +127     
- Partials     1233     1235       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@jonashendrickx jonashendrickx marked this pull request as ready for review November 20, 2024 10:28
@jonashendrickx jonashendrickx requested a review from a team as a code owner November 20, 2024 10:28
@jonashendrickx jonashendrickx changed the title [DRAFT][PM-14892] Sales tax estimation [PM-14892] Sales tax estimation Nov 20, 2024
@jonashendrickx jonashendrickx changed the title [PM-14892] Sales tax estimation [PM-14892] Sales tax estimation for individuals Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant