Fix payment reminder payable total - #501
Conversation
Changed Files
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe send-order-payment-reminder workflow now computes the notification's total via a ChangesPayment reminder total formatting
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant Test
participant WorkflowStep as build-order-payment-reminder-notification
participant Query as container.query
participant formatTotal
Test->>Query: mock order summary/total response
Test->>WorkflowStep: invoke step with input.total
WorkflowStep->>Query: fetch order graph data
WorkflowStep->>formatTotal: compute formatted total from order
formatTotal-->>WorkflowStep: formatted total or undefined
WorkflowStep-->>Test: notification payload with data.total
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e09e0f464
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@apps/medusa-be/src/workflows/__tests__/send-order-payment-reminder.unit.spec.ts`:
- Around line 84-120: The mock setup for graph, generateOrderReceiptAttachment,
and the container.resolve stub is duplicated between the single test and the
it.each cases, so extract a shared helper to centralize it. Add a small
createStepContainer(orderOverrides) helper (or equivalent) near
send-order-payment-reminder.unit.spec.ts and reuse it in both places, keeping
the existing dependency keys like "query", "logger", and "order_receipt" intact
while allowing per-scenario overrides.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0529f94d-d403-4a1b-a704-43815b1e24fb
📒 Files selected for processing (2)
apps/medusa-be/src/workflows/__tests__/send-order-payment-reminder.unit.spec.tsapps/medusa-be/src/workflows/send-order-payment-reminder.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: Greptile Review
- GitHub Check: main
⚠️ CI failures not shown inline (1)
GitHub Check: Kilo Code Review: Kilo Code Review failed
Conclusion: failure
Review failed: The message could not be delivered
🧰 Additional context used
📓 Path-based instructions (9)
apps/medusa-be/src/workflows/**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Place business logic workflows under apps/medusa-be/src/workflows
Files:
apps/medusa-be/src/workflows/send-order-payment-reminder.tsapps/medusa-be/src/workflows/__tests__/send-order-payment-reminder.unit.spec.ts
apps/medusa-be/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)
apps/medusa-be/**/*.{ts,tsx}: Use TypeScript for type checking - runnpx tsc --noEmitfor validation
Forbidden: Non-null assertions (!) - always use type guards and validation instead
Annotate generic field access with explicitunknowntype before type guards -const v: unknown = result[field]
Don't useas Typewithout validation - always validate before casting
UseModules.*andContainerRegistrationKeys.*constants instead of hardcoding strings
Batch operations with CHUNK_SIZE to avoid unbounded operations
Extract pure functions to separate files for testability without runtime dependencies
Files:
apps/medusa-be/src/workflows/send-order-payment-reminder.tsapps/medusa-be/src/workflows/__tests__/send-order-payment-reminder.unit.spec.ts
apps/medusa-be/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)
apps/medusa-be/**/*.{ts,tsx,js,jsx}: Use Biome linter with ultracite preset - runbunx biome check --write .and always use braces in conditionals
Comments should explain 'why', never 'what' - use self-documenting code via clear naming
Always use const per declaration -const a = 1; const b = 2is correct, one variable per line
Use nullish coalescing (??) operator instead of logical OR (||) for default values
Files:
apps/medusa-be/src/workflows/send-order-payment-reminder.tsapps/medusa-be/src/workflows/__tests__/send-order-payment-reminder.unit.spec.ts
apps/medusa-be/src/workflows/*.ts
📄 CodeRabbit inference engine (apps/medusa-be/CLAUDE.md)
apps/medusa-be/src/workflows/*.ts: Workflows: UsecreateWorkflow()andcreateStep()for multi-step business logic - cannot reassign/iterate variables in workflow body
Usetransform()for data manipulation in workflows - limit to data transformations, not external side effects
Usewhen().then()for conditionals in workflows instead of imperative logic
UseuseQueryGraphStep()for Query operations within workflows
Workflows using locks: UseacquireLockStep()andreleaseLockStep()- auto-releases on error
Files:
apps/medusa-be/src/workflows/send-order-payment-reminder.ts
apps/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Import UI components using the
@techsio/ui-kitnamespace, not@libs/ui, for runtime apps
Files:
apps/medusa-be/src/workflows/send-order-payment-reminder.tsapps/medusa-be/src/workflows/__tests__/send-order-payment-reminder.unit.spec.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Run Biome linting and formatting only on changed files using 'bunx biome check --write path/to/file'
Files:
apps/medusa-be/src/workflows/send-order-payment-reminder.tsapps/medusa-be/src/workflows/__tests__/send-order-payment-reminder.unit.spec.ts
apps/medusa-be/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Medusa backend custom logic should be organized in api/, modules/, workflows/, admin/, subscribers/, and jobs/ directories under apps/medusa-be/src/
Files:
apps/medusa-be/src/workflows/send-order-payment-reminder.tsapps/medusa-be/src/workflows/__tests__/send-order-payment-reminder.unit.spec.ts
apps/**/!(medusa-be)/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use modern React patterns and React 19 for frontend applications in the monorepo
Files:
apps/medusa-be/src/workflows/send-order-payment-reminder.tsapps/medusa-be/src/workflows/__tests__/send-order-payment-reminder.unit.spec.ts
**/*.{test,spec}.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Vitest for running tests in backend and UI library projects
Files:
apps/medusa-be/src/workflows/__tests__/send-order-payment-reminder.unit.spec.ts
🔇 Additional comments (3)
apps/medusa-be/src/workflows/send-order-payment-reminder.ts (2)
19-22: LGTM!Also applies to: 156-156
35-35: 🎯 Functional CorrectnessDouble-check
QueryOrdervalidationisQueryOrderonly checksid,total, andcustomer_id, butQueryOrderalso includesdisplay_idand other receipt fields from the query.apps/medusa-be/src/workflows/__tests__/send-order-payment-reminder.unit.spec.ts (1)
1-250: LGTM!Coverage nicely exercises the
current_order_total→original_order_total→total→input.totalprecedence chain.
|
🎉 This PR is included in version 0.21.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Problem
Payment reminder emails could show a different total than the attached receipt. The workflow reloaded the order for the PDF, but the email payload still used raw
order.totalinstead of the current payable summary total.What changed
The reminder notification total is formatted from the freshly fetched order using the same summary-aware total logic.
Evidence
Added workflow coverage where raw
order.totalis stale andsummary.current_order_totalis current; notification data uses the current formatted total.Summary by CodeRabbit
New Features
Tests