**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%
62 lines
2.0 KiB
JSON
62 lines
2.0 KiB
JSON
{
|
|
"name": "@medusajs/tax",
|
|
"version": "0.1.0",
|
|
"description": "Medusa Tax module",
|
|
"main": "dist/index.js",
|
|
"types": "dist/index.d.ts",
|
|
"files": [
|
|
"dist"
|
|
],
|
|
"engines": {
|
|
"node": ">=16"
|
|
},
|
|
"bin": {
|
|
"medusa-tax-seed": "dist/scripts/bin/run-seed.js"
|
|
},
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "https://github.com/medusajs/medusa",
|
|
"directory": "packages/tax"
|
|
},
|
|
"publishConfig": {
|
|
"access": "public"
|
|
},
|
|
"author": "Medusa",
|
|
"license": "MIT",
|
|
"scripts": {
|
|
"watch": "tsc --build --watch",
|
|
"watch:test": "tsc --build tsconfig.spec.json --watch",
|
|
"prepublishOnly": "cross-env NODE_ENV=production tsc --build && tsc-alias -p tsconfig.json",
|
|
"build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json",
|
|
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
|
"test:integration": "jest --runInBand --forceExit -- integration-tests/**/__tests__/**/*.spec.ts",
|
|
"migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate",
|
|
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create --initial",
|
|
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create",
|
|
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:up",
|
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
|
},
|
|
"devDependencies": {
|
|
"@mikro-orm/cli": "5.9.7",
|
|
"cross-env": "^5.2.1",
|
|
"jest": "^29.6.3",
|
|
"medusa-test-utils": "^1.1.40",
|
|
"rimraf": "^3.0.2",
|
|
"ts-jest": "^29.1.1",
|
|
"ts-node": "^10.9.1",
|
|
"tsc-alias": "^1.8.6",
|
|
"typescript": "^5.1.6"
|
|
},
|
|
"dependencies": {
|
|
"@medusajs/modules-sdk": "^1.12.4",
|
|
"@medusajs/types": "^1.11.8",
|
|
"@medusajs/utils": "^1.11.1",
|
|
"@mikro-orm/core": "5.9.7",
|
|
"@mikro-orm/migrations": "5.9.7",
|
|
"@mikro-orm/postgresql": "5.9.7",
|
|
"awilix": "^8.0.0",
|
|
"dotenv": "^16.1.4",
|
|
"knex": "2.4.2"
|
|
}
|
|
}
|