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

feat(tax): adds getItemTaxLines #6440

Merged
merged 8 commits into from
Feb 22, 2024
Merged

feat(tax): adds getItemTaxLines #6440

merged 8 commits into from
Feb 22, 2024

Conversation

srindom
Copy link
Collaborator

@srindom srindom commented Feb 19, 2024

What

  • Selects the correct tax line for an item given a calculation context.

For later PR

  • Consider optimizations. Some thoughts:
    • Even with global sales the number of rates in the DB is not likely to grow beyond ~1000.
    • Can large orders with hundreds of items optimize somehow?
    • Does it make sense to write a custom SQL query to do this?
  • Support combined rate.

Test cases covered
The selection of tax rates take the following priority:

  1. specific product rules - province
  2. specific product type rules - province
  3. default province rules
  4. specific product rules - country
  5. specific product type rules - country
  6. default country rules

There are test cases for each of them under the following data seed structure:

US

  • Default Rate: 2%
  • Sub-Regions
    • CA
      • Default Rate: 5%
      • Overrides
        • Reduced rate (for 3 product ids): 3%
        • Reduced rate (for product type): 1%
    • NY
      • Default rate: 6%
    • FL
      • Default rate: 4%
  • Overrides
    • None

Denmark

  • Default rate: 25%
  • Sub-Regions
    • None
  • Overrides
    • None

Germany

  • Default Rate: 19%
  • Sub-Regions
    • None
  • Overrides:
    • Reduced Rate (for product type) - 7%

Canada

  • Default rate: 5%
  • Sub-Regions
    • QC
      • Default rate: 2%
      • Overrides:
        • Reduced rate (for same product type as country reduced rate): 1%
    • BC
      • Default rate: 2%
  • Overrides
    • Reduced rate (for product id) - 3%
    • Reduced rate (for product type) - 3.5%

Copy link

changeset-bot bot commented Feb 19, 2024

⚠️ No Changeset found

Latest commit: 50077a0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Feb 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 22, 2024 4:04pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Feb 22, 2024 4:04pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Feb 22, 2024 4:04pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Feb 22, 2024 4:04pm

@srindom srindom force-pushed the feat/tax-module-lines branch from 0fc19e9 to 84174f2 Compare February 20, 2024 18:23
packages/tax/src/services/tax-module-service.ts Outdated Show resolved Hide resolved
packages/tax/src/services/tax-module-service.ts Outdated Show resolved Hide resolved
packages/tax/src/services/tax-module-service.ts Outdated Show resolved Hide resolved
packages/tax/src/services/tax-module-service.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@riqwan riqwan left a comment

Choose a reason for hiding this comment

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

Readability takes a bit of a hit here with the multi-nests. LGTM otherwise with some comments.

packages/tax/src/services/tax-module-service.ts Outdated Show resolved Hide resolved
packages/tax/src/services/tax-module-service.ts Outdated Show resolved Hide resolved
packages/tax/src/services/tax-module-service.ts Outdated Show resolved Hide resolved
Copy link
Member

@adrien2p adrien2p left a comment

Choose a reason for hiding this comment

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

to complete other comments

packages/tax/src/services/tax-module-service.ts Outdated Show resolved Hide resolved
packages/tax/src/services/tax-module-service.ts Outdated Show resolved Hide resolved
@kodiakhq kodiakhq bot merged commit 598ee6f into develop Feb 22, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants