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-13999] Show estimated tax for taxable countries #12145

Merged

Conversation

jonashendrickx
Copy link
Member

@jonashendrickx jonashendrickx commented Nov 25, 2024

🎟️ Tracking

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

📔 Objective

  • Use Stripe for the sales tax estimation using the customer's tax id, postal code and country.
  • Display any errors returned by the backend
  • Restore and display any previously saved tax information or billing information.
  • Supports the AC-2476-deprecate-stripe-sources-api feature flag in both enabled/disabled state.
  • Removed duplicate sections related to updating tax information or billing information
  • Ability to enter tax information for consumers in individual plans.

📸 Screenshots

Bot postal code & country fields are required. Note that the checkbox to include a tax id is removed.

image

It also listens for additional fields, such as plan, billing interval, additional storage, additional seats, machine accounts, etc.

image

Tax id codes are validated by our backend using regular expressions to resolve the tax id type based on the selected country:

image

Error messages by Stripe are also handled now, example is not available.

image

⏰ 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

@jonashendrickx jonashendrickx requested a review from a team as a code owner November 25, 2024 14:06
Copy link

codecov bot commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 6.41892% with 277 lines in your changes missing coverage. Please review.

Project coverage is 33.83%. Comparing base (3db5bea) to head (3f8e14e).
Report is 56 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...s/web/src/app/billing/shared/tax-info.component.ts 7.40% 50 Missing ⚠️
...ling/organizations/organization-plans.component.ts 0.00% 46 Missing ⚠️
...ax-information/manage-tax-information.component.ts 7.69% 35 Missing and 1 partial ⚠️
...ling/organizations/change-plan-dialog.component.ts 0.00% 35 Missing ⚠️
...yment-dialog/adjust-payment-dialog-v2.component.ts 25.92% 19 Missing and 1 partial ⚠️
...-payment-dialog/adjust-payment-dialog.component.ts 18.18% 18 Missing ⚠️
...pp/billing/individual/premium/premium.component.ts 0.00% 15 Missing ⚠️
...billing/individual/premium/premium-v2.component.ts 0.00% 13 Missing ⚠️
...c/billing/models/response/tax-id-types.response.ts 0.00% 13 Missing ⚠️
libs/common/src/billing/services/tax.service.ts 0.00% 10 Missing ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12145      +/-   ##
==========================================
+ Coverage   33.48%   33.83%   +0.34%     
==========================================
  Files        2877     2892      +15     
  Lines       89902    91668    +1766     
  Branches    17109    17697     +588     
==========================================
+ Hits        30104    31015     +911     
- Misses      57419    58236     +817     
- Partials     2379     2417      +38     

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

@jonashendrickx jonashendrickx requested a review from a team as a code owner November 26, 2024 10:30
.then((invoice) => {
this.estimatedTax = invoice.taxAmount;
})
.catch((error) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting the error handling logic into a separate method. This keeps your main logic clear and makes it easier to manage errors

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually keep them inline unless I need to reference the code elsewhere.

if (!this.taxInfoComponent.country || !this.taxInfoComponent.postalCode) {
return;
}
const request: PreviewIndividualInvoiceRequest = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If previewIndividualInvoice returns a promise, using async/await can improve readability and eliminate the need for .then() and .catch() chaining

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had looked into that, but then I get a linting error: Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator where I am subscribing to value changes calling refreshSalesTax().

message: this.i18nService.t("taxInfoUpdated"),
});
})
.catch((error) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of mixing async/await with .then() and .catch(), use async/await consistently to improve readability and also consider extracting the error

this.total = invoice.totalAmount;
})
.catch((error) => {
this.toastService.showToast({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider centralizing the error handling logic for better maintainability

Copy link
Contributor

github-actions bot commented Dec 2, 2024

Logo
Checkmarx One – Scan Summary & Details34662c04-c162-417c-8c13-257f2cd3a280

New Issues

Severity Issue Source File / Package Checkmarx Insight
LOW Client_JQuery_Deprecated_Symbols /apps/cli/src/service-container/service-container.ts: 876 Attack Vector

Fixed Issues

Severity Issue Source File / Package
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/password-health-members.component.html: 50
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/password-health-members.component.html: 45
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/password-health-members.component.html: 50
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/password-health-members.component.html: 55
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/password-health-members-uri.component.html: 45
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/password-health-members-uri.component.html: 40
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/password-health-members-uri.component.html: 35
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/password-health-members-uri.component.html: 40
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/password-health.component.html: 45
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/password-health.component.html: 45
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/password-health.component.html: 50
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/password-health.component.html: 40
LOW Client_DOM_Open_Redirect /apps/web/src/app/billing/organizations/payment-method/organization-payment-method.component.ts: 145
LOW Client_DOM_Open_Redirect /apps/web/src/app/billing/organizations/payment-method/organization-payment-method.component.ts: 175
LOW Client_DOM_Open_Redirect /apps/web/src/app/billing/shared/payment-method.component.ts: 147
LOW Client_DOM_Open_Redirect /apps/web/src/app/billing/shared/payment-method.component.ts: 173

@jonashendrickx jonashendrickx merged commit 1dce7f5 into main Dec 4, 2024
72 of 73 checks passed
@jonashendrickx jonashendrickx deleted the PM-13999-Show-estimated-tax-for-taxable-countries branch December 4, 2024 10:45
@jonashendrickx jonashendrickx restored the PM-13999-Show-estimated-tax-for-taxable-countries branch December 4, 2024 14:30
jonashendrickx added a commit that referenced this pull request Dec 4, 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.

4 participants