feat: add spoils linking#19
Conversation
|
Warning Review limit reached
More reviews will be available in 50 minutes and 21 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a ChangesRaid Spoils Tracking
Admin Nav Dropdown
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for “raid spoils” by introducing a new raid_spoils ledger category, enforcing stricter backend validation for spoils classifications, and extending raid accounting calculations + UI to surface spoils received/due/status. It also refactors the member home admin navigation into a dropdown menu.
Changes:
- Add
raid_spoilsto theledger_categoryenum (schema + migration metadata). - Extend raid accounting aggregation to compute spoils received, remaining spoils due, and a spoils status.
- Update raids UI to query/display spoils entries and show spoils columns/status badges; update member home admin navigation to a dropdown.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/raid-accounting.ts | Adds spoils totals, derived fields (received/due/status), and includes raid_spoils in ledger aggregation. |
| src/db/schema.ts | Extends ledger_category enum with raid_spoils. |
| src/app/raids/page.tsx | Displays spoils in raid/client tables and raid details; broadens raid ledger entry listing to include spoils and non-manual sources. |
| src/app/page.tsx | Replaces separate admin links with an AdminNavMenu dropdown in the member header. |
| src/app/admin/quarters/[id]/transactions/actions.ts | Adds validation rules for classifying raid_spoils transfers (requires raid, inflow, treasury sources). |
| drizzle/meta/0013_snapshot.json | Updates Drizzle snapshot to reflect the new enum value. |
| drizzle/meta/_journal.json | Registers migration 0013_spoils_linking in the migration journal. |
| drizzle/0013_spoils_linking.sql | Adds raid_spoils to the Postgres enum via migration SQL. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
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 `@src/lib/raid-accounting.ts`:
- Around line 110-131: The getSpoilsStatus function checks for no_revenue before
checking if spoils were over-received, which misclassifies cases where revenue
is zero but spoils were received. Reorder the conditional checks so that the
condition checking if spoilsReceivedCents > expectedSpoilsCents is evaluated
before the revenueCents === ZERO check. This ensures that over-received spoils
are properly identified regardless of revenue status.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: d8d1fd79-0c98-46c9-9e8b-548bbb681110
📒 Files selected for processing (8)
drizzle/0013_spoils_linking.sqldrizzle/meta/0013_snapshot.jsondrizzle/meta/_journal.jsonsrc/app/admin/quarters/[id]/transactions/actions.tssrc/app/page.tsxsrc/app/raids/page.tsxsrc/db/schema.tssrc/lib/raid-accounting.ts
This pull request introduces support for tracking and displaying "raid spoils" (treasury spoils linked to raids) throughout the application. The changes span the database schema, backend logic, and frontend UI, ensuring that spoils are properly categorized, validated, and visible in raid accounting views. Additionally, the admin navigation is improved with a dropdown menu.
Raid Spoils Support
raid_spoilsvalue to theledger_categoryenum in the database to represent spoils linked to raids.classifyQuarterTransferto validate that spoils are only received by treasury accounts and require a linked raid. (src/app/admin/quarters/[id]/transactions/actions.tsR469-L475)raid_spoilsas a kind, and to surface the source of each entry. [1] [2] [3]Admin Navigation Improvements
AdminNavMenudropdown component for cleaner navigation. [1] [2] [3] [4] [5] [6]Migration Metadata
Summary by CodeRabbit
New Features
Chores