-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(core): Exclude seller orders when counting promotion usage #4070
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
base: master
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughUpdated promotion-service queries to exclude Seller-type orders when counting promotion usages. Two methods—countPromotionUsagesForCustomer and countPromotionUsages—now filter out orders that are inactive and not of OrderType.Seller; an import of OrderType was added. Changes
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/core/src/service/services/promotion.service.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: e2e tests (20.x, mariadb)
- GitHub Check: e2e tests (20.x, postgres)
- GitHub Check: e2e tests (24.x, postgres)
- GitHub Check: e2e tests (20.x, sqljs)
- GitHub Check: e2e tests (24.x, mariadb)
- GitHub Check: e2e tests (24.x, sqljs)
- GitHub Check: build (24.x)
- GitHub Check: unit tests (24.x)
- GitHub Check: unit tests (20.x)
- GitHub Check: build (22.x)
- GitHub Check: build (20.x)
- GitHub Check: publish_install (macos-latest, 22.x)
- GitHub Check: publish_install (ubuntu-latest, 22.x)
- GitHub Check: publish_install (ubuntu-latest, 20.x)
- GitHub Check: publish_install (windows-latest, 20.x)
- GitHub Check: publish_install (macos-latest, 24.x)
- GitHub Check: publish_install (macos-latest, 20.x)
- GitHub Check: publish_install (windows-latest, 22.x)
- GitHub Check: publish_install (ubuntu-latest, 24.x)
- GitHub Check: publish_install (windows-latest, 24.x)
| .andWhere('order.active = :active', { active: false }) | ||
| .andWhere('order.type != :type', { type: 'Seller' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cat -n packages/core/src/service/services/promotion.service.ts | sed -n '350,375p'Repository: vendure-ecommerce/vendure
Length of output: 1465
🏁 Script executed:
fd -e "spec.ts" -e "test.ts" | grep -i promotionRepository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
git diff --name-only | grep -E "(promotion|test)"Repository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
find . -type d -name "__tests__" -o -type d -name "test" -o -type d -name "tests" | head -20Repository: vendure-ecommerce/vendure
Length of output: 144
🏁 Script executed:
rg -l "promotion" --type ts --type js | grep -i "test\|spec" | head -20Repository: vendure-ecommerce/vendure
Length of output: 1016
🏁 Script executed:
git status | grep -E "(promotion|test)"Repository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
rg "countPromotionUsages" packages/core/Repository: vendure-ecommerce/vendure
Length of output: 628
🏁 Script executed:
wc -l packages/core/e2e/promotion.e2e-spec.tsRepository: vendure-ecommerce/vendure
Length of output: 112
🏁 Script executed:
wc -l packages/core/e2e/order-promotion.e2e-spec.tsRepository: vendure-ecommerce/vendure
Length of output: 119
🏁 Script executed:
grep -n "countPromotionUsages\|order.type\|Seller" packages/core/e2e/promotion.e2e-spec.ts | head -30Repository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
grep -n "countPromotionUsages\|order.type\|Seller" packages/core/e2e/order-promotion.e2e-spec.ts | head -30Repository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
grep -n "Seller\|type.*:" packages/core/src/service/services/promotion.service.ts | head -20Repository: vendure-ecommerce/vendure
Length of output: 208
🏁 Script executed:
sed -n '340,370p' packages/core/src/service/services/promotion.service.tsRepository: vendure-ecommerce/vendure
Length of output: 1374
🏁 Script executed:
rg "countPromotionUsages" -B5 -A5 packages/core/src/service/services/promotion.service.tsRepository: vendure-ecommerce/vendure
Length of output: 1717
🏁 Script executed:
grep -n "usageCount\|usageLimit" packages/core/src/service/services/promotion.service.ts | head -20Repository: vendure-ecommerce/vendure
Length of output: 539
🏁 Script executed:
sed -n '260,285p' packages/core/src/service/services/promotion.service.tsRepository: vendure-ecommerce/vendure
Length of output: 1246
🏁 Script executed:
rg "perCustomerUsageLimit\|usageLimit" packages/core/e2e/promotion.e2e-spec.ts -A3 -B3 | head -40Repository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
rg "perCustomerUsageLimit\|usageLimit" packages/core/e2e/order-promotion.e2e-spec.ts -A3 -B3 | head -40Repository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
sed -n '1,50p' packages/core/e2e/promotion.e2e-spec.tsRepository: vendure-ecommerce/vendure
Length of output: 1889
🏁 Script executed:
rg "describe.*[Uu]sage|it.*[Uu]sage|test.*[Uu]sage" packages/core/e2e/promotion.e2e-spec.tsRepository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
rg "describe.*[Uu]sage|it.*[Uu]sage|test.*[Uu]sage" packages/core/e2e/order-promotion.e2e-spec.tsRepository: vendure-ecommerce/vendure
Length of output: 1372
🏁 Script executed:
rg "cancelled orders do not count against usage limit" -A20 packages/core/e2e/order-promotion.e2e-spec.tsRepository: vendure-ecommerce/vendure
Length of output: 2127
🏁 Script executed:
rg "per-customer usage limit|usage limit" -A30 packages/core/e2e/order-promotion.e2e-spec.ts | head -80Repository: vendure-ecommerce/vendure
Length of output: 3310
🏁 Script executed:
grep -n "Seller\|order.type" packages/core/e2e/order-promotion.e2e-spec.tsRepository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
rg "type.*Seller|Seller.*type" packages/core/e2e/ -lRepository: vendure-ecommerce/vendure
Length of output: 177
🏁 Script executed:
rg "type.*:.*order\|order.*type" packages/core/src/entity/ | grep -i sellerRepository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
grep -rn "enum.*OrderType\|type.*Seller" packages/core/src/entity/order/Repository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
fd "order.entity.ts" packages/core/src/entity/Repository: vendure-ecommerce/vendure
Length of output: 115
🏁 Script executed:
rg "OrderType|type.*string" packages/core/src/entity/order/order.entity.ts -A3 -B3 | head -40Repository: vendure-ecommerce/vendure
Length of output: 472
🏁 Script executed:
grep -rn "Seller" packages/core/src/entity/order/ | head -20Repository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
rg "enum OrderType|OrderType.*=" packages/core/ | head -20Repository: vendure-ecommerce/vendure
Length of output: 297
🏁 Script executed:
fd "generated-types.ts" packages/common/lib/ | head -5Repository: vendure-ecommerce/vendure
Length of output: 176
🏁 Script executed:
grep -rn "OrderType.*Seller\|Seller.*OrderType" packages/Repository: vendure-ecommerce/vendure
Length of output: 1243
🏁 Script executed:
cat packages/core/src/api/schema/common/order.type.graphql | grep -A5 "enum OrderType"Repository: vendure-ecommerce/vendure
Length of output: 125
🏁 Script executed:
rg "it\(.*seller.*\)" -i packages/core/e2e/order-promotion.e2e-spec.tsRepository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
sed -n '1,100p' packages/core/e2e/order-promotion.e2e-spec.ts | grep -E "describe|import"Repository: vendure-ecommerce/vendure
Length of output: 1377
🏁 Script executed:
rg "Seller.*order\|order.*Seller" packages/core/e2e/order-promotion.e2e-spec.tsRepository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
rg "multivendor\|seller" -i packages/core/e2e/order-promotion.e2e-spec.ts | head -10Repository: vendure-ecommerce/vendure
Length of output: 51
🏁 Script executed:
grep -n "describe\|it(" packages/core/e2e/order-promotion.e2e-spec.ts | grep -i "usage\|seller\|vendor"Repository: vendure-ecommerce/vendure
Length of output: 950
Test coverage is missing for the seller order exclusion filter.
The consistency between countPromotionUsagesForCustomer and countPromotionUsages is good—both now exclude seller orders from usage counts. However, existing tests cover cancelled orders and basic usage limit logic, but do not verify that seller orders are actually excluded from promotion usage calculations.
Add test cases for:
- Seller orders do not count toward per-customer usage limits
- Seller orders do not count toward global usage limits
- Regular and Aggregate order types are still counted correctly
|



Description
This PR updates
promotion-serviceto exclude seller orders when counting promotion usage. Fixes #3042Breaking changes
N/A
Screenshots
N/A
Checklist
📌 Always:
👍 Most of the time: