Skip to content

feat: add spoils linking#19

Merged
ECWireless merged 3 commits into
mainfrom
codex/spoils-linking-flow
Jun 14, 2026
Merged

feat: add spoils linking#19
ECWireless merged 3 commits into
mainfrom
codex/spoils-linking-flow

Conversation

@ECWireless

@ECWireless ECWireless commented Jun 14, 2026

Copy link
Copy Markdown
Member

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

  • Added a new raid_spoils value to the ledger_category enum in the database to represent spoils linked to raids.
  • Updated backend logic in classifyQuarterTransfer to validate that spoils are only received by treasury accounts and require a linked raid. (src/app/admin/quarters/[id]/transactions/actions.tsR469-L475)
  • Modified the raid ledger entry query and mapping to include raid_spoils as a kind, and to surface the source of each entry. [1] [2] [3]
  • Added spoils-specific UI elements: new columns for spoils in raid and client tables, a badge for spoils status, and a dedicated section for treasury spoils in raid details. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
  • Updated modal and page logic to fetch and display all relevant raid ledger entries, not just manual ones, to include spoils. [1] [2] [3] [4] [5]

Admin Navigation Improvements

  • Replaced individual admin links in the member home header with a new AdminNavMenu dropdown component for cleaner navigation. [1] [2] [3] [4] [5] [6]

Migration Metadata

  • Added a new migration entry for the spoils linking change in the migration journal.

Summary by CodeRabbit

  • New Features

    • Added spoils accounting tracking with new "Spoils Received," "Spoils Due," and "Spoils Status" indicators on raid pages.
    • Added admin navigation dropdown menu for quick access to admin sections.
  • Chores

    • Updated database schema to support spoils category tracking.

Copilot AI review requested due to automatic review settings June 14, 2026 17:08
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ECWireless, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fa6a45ee-cc9d-4da4-8701-cbf0a75ebe53

📥 Commits

Reviewing files that changed from the base of the PR and between 0d195f8 and 79710ad.

📒 Files selected for processing (1)
  • src/lib/raid-accounting.ts
📝 Walkthrough

Walkthrough

Adds a raid_spoils ledger category via DB migration and schema enum, then extends the accounting library with SpoilsStatus tracking and spoils fields on existing summary types. The raids page UI and transaction classification are updated to handle spoils entries end-to-end. Separately, the home page admin nav links are consolidated into an AdminNavMenu dropdown component.

Changes

Raid Spoils Tracking

Layer / File(s) Summary
DB migration and schema enum
drizzle/0013_spoils_linking.sql, src/db/schema.ts, drizzle/meta/0013_snapshot.json, drizzle/meta/_journal.json
Adds raid_spoils to the ledger_category Postgres enum in the migration SQL, Drizzle schema, generated snapshot, and journal.
Accounting types, SpoilsStatus logic, and client rollups
src/lib/raid-accounting.ts
Exports SpoilsStatus union type, extends RaidLedgerTotals, RaidAccountingSummary, and ClientRevenueSummary with spoils fields, adds getSpoilsStatus() helper, and wires spoils aggregation into listRaidLedgerTotals and getRaidAccountingOverview.
raid_spoils classification validation
src/app/admin/quarters/[id]/transactions/actions.ts
Moves source resolution earlier in classifyQuarterTransfer and adds a raid_spoils branch enforcing raidId, inflow direction, main_safe/side_vault source, and clearing counterpartyEntityId.
Raids page spoils UI: ledger query, tables, badges, and modal wiring
src/app/raids/page.tsx
Adds SpoilsStatusBadge and SPOILS_STATUS_COPY; expands ledger query to include raid_spoils and source; updates Top Clients and Raid Accounting tables with spoils columns; inserts a Treasury Spoils ManualRaidLedgerRows section in RaidDetails; switches data-loading to listRaidLedgerEntries.

Admin Nav Dropdown

Layer / File(s) Summary
AdminNavMenu component and header breakpoint adjustments
src/app/page.tsx
Adds AdminNavMenu as a details/summary dropdown replacing inline admin links, adds ChevronDown import and ReactNode typing for AppNavLink, and shifts responsive header grid/justify classes from lg to xl.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • raid-guild/accounting#12: Both PRs modify classifyQuarterTransfer in src/app/admin/quarters/[id]/transactions/actions.ts to add category-specific ledger classification logic.
  • raid-guild/accounting#13: Both PRs extend src/lib/raid-accounting.ts and src/app/raids/page.tsx to add new dimensions to the raid accounting overview model.
  • raid-guild/accounting#18: Both PRs extend the ManualRaidLedgerKind / ledger entry kind system and corresponding ManualRaidLedgerRows rendering in src/app/raids/page.tsx.

Poem

🐇 A spoils-shaped enum arrived with care,
raid_spoils now joins the ledger fair.
The treasury tallied each inflow's share,
Badges gleam — received, pending, or bare.
Hop hop, accounting's complete, I declare! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title "feat: add spoils linking" directly summarizes the main change: introducing support for tracking and displaying raid spoils linked to raids across database, backend, and frontend layers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/spoils-linking-flow

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.

@vercel

vercel Bot commented Jun 14, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
raidguild-accounting Ready Ready Preview, Comment Jun 14, 2026 5:41pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_spoils to the ledger_category enum (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.

Comment thread src/app/raids/page.tsx Outdated
Comment thread src/app/raids/page.tsx Outdated
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ec7cbdb and 0d195f8.

📒 Files selected for processing (8)
  • drizzle/0013_spoils_linking.sql
  • drizzle/meta/0013_snapshot.json
  • drizzle/meta/_journal.json
  • src/app/admin/quarters/[id]/transactions/actions.ts
  • src/app/page.tsx
  • src/app/raids/page.tsx
  • src/db/schema.ts
  • src/lib/raid-accounting.ts

Comment thread src/lib/raid-accounting.ts
@ECWireless ECWireless merged commit f3baaae into main Jun 14, 2026
5 checks passed
@ECWireless ECWireless deleted the codex/spoils-linking-flow branch June 14, 2026 17:41
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.

2 participants