Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@steven-tey
Copy link
Collaborator

@steven-tey steven-tey commented Dec 3, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Refined payout eligibility filtering to respect an optional cutoff period-end value.
    • Adjusted payout period boundary for current-month payouts to use the exact commission date.
    • Ensure custom payouts are now recomputed for amounts and subjected to the minimum-payout filter.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Contributor

vercel bot commented Dec 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
dub Ready Ready Preview Dec 3, 2025 4:12am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 3, 2025

Walkthrough

Adds an optional cutoff-period filter to payout updates, ensures all payouts (including custom ones) have amounts recomputed before min-payout filtering, and stops normalizing the current-month payout periodEnd to month-end (uses the raw last-commission date).

Changes

Cohort / File(s) Summary
Payout update & cutoff handling
apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts
Adds conditional periodEnd <= cutoffPeriodValue to the payout update query when cutoffPeriodValue is provided.
Eligible payout amount calculation
apps/web/lib/api/payouts/get-eligible-payouts.ts
Removes early-return for custom payouts inside cutoff handling so all payouts have amounts recomputed (summing commissions) and are then filtered by minimum payout amount.
Payout splitting period boundary
apps/web/app/(ee)/api/cron/payouts/process/split-payouts.ts
For the second/current-month payout, periodEnd is changed from endOfMonth(lastCurrentCommissionDate) to lastCurrentCommissionDate (no end-of-month normalization).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Review focus:
    • process-payouts.ts: confirm the added periodEnd <= cutoffPeriodValue condition composes correctly with existing update filters and test edge cases around inclusive/exclusive bounds.
    • get-eligible-payouts.ts: ensure recomputing amounts for custom payouts preserves intended business rules and doesn't double-count commissions.
    • split-payouts.ts: verify removing end-of-month normalization doesn't create overlap/gaps between split periods or regress reports relying on month-end boundaries.

Possibly related PRs

Suggested reviewers

  • devkiran

Poem

🐰
I hopped through code at break of dawn,
Trimmed the edges where dates are drawn,
Recounted sums, no bunny tricks—
Periods tidy, payouts fixed! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Fix splitPayouts' is partially related to the changeset—it references a real file that was modified (split-payouts.ts), but it does not fully capture the scope of changes which also include modifications to process-payouts.ts and get-eligible-payouts.ts. Consider a more descriptive title that captures the broader intent, such as 'Fix payout period handling and filtering logic' or 'Adjust payout periodEnd calculation and cutoff filtering'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-split-payouts

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 559766d and 6e40290.

📒 Files selected for processing (1)
  • apps/web/lib/api/payouts/get-eligible-payouts.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/lib/api/payouts/get-eligible-payouts.ts
⏰ 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). (1)
  • GitHub Check: build

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@steven-tey steven-tey merged commit 5fc7c3a into main Dec 3, 2025
7 of 8 checks passed
@steven-tey steven-tey deleted the fix-split-payouts branch December 3, 2025 06:00
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.

3 participants