Skip to content

HOLD: Add admin CRUD for payments with filtering and manage registrants integration#1282

Open
maebeale wants to merge 5 commits intomainfrom
maebeale/crud-payments-index
Open

HOLD: Add admin CRUD for payments with filtering and manage registrants integration#1282
maebeale wants to merge 5 commits intomainfrom
maebeale/crud-payments-index

Conversation

@maebeale
Copy link
Collaborator

@maebeale maebeale commented Mar 1, 2026

What is the goal of this PR and why is this important?

  • Add full admin CRUD for payments, enabling tracking of financial transactions (Stripe, check, scholarship, purchase order, etc.) linked to payers, organizations, and event registrations
  • Support filtering payments by payer, organization, event, and status for quick lookups
  • Show payment status on the manage registrants page with links to filtered payment views

How did you approach the change?

Model & associations:

  • Payment belongs_to :payer (Person), optional belongs_to :organization, has_many :event_registrations
  • EventRegistration belongs_to :payment, optional: true (direct FK, not join table)
  • Organization has_many :payments, dependent: :nullify
  • Added normalizes on stripe fields to convert empty strings to nil
  • search_by_params class method for filtering by status, payer_id, organization_id, event_id

Controller & views:

  • Full CRUD with admin-only ActionPolicy authorization
  • Index with remote-select search boxes for Payer, Organization, Event, and Status dropdown
  • Form with remote-select for payer/organization and Stimulus controller for managing event registration associations
  • Manage registrants view shows payment status badges linking to payments_path(payer_id: ...)

Migrations:

  • Original payments table migration updated to include event_registrations.payment_id FK
  • Separate migrations for payment_type column and organization_id reference
  • Organization FK uses type: :integer to match organizations table PK type

Tests:

  • Payment request spec: admin CRUD + filter tests (payer_id, organization_id, event_id, status) + auth tests
  • Events request spec: manage page tests for paid/free events and payment status display
  • Model spec, factory with :with_organization trait
  • Page bg_class alignment spec updated

UI Testing Checklist

  • Visit /payments as admin — verify index renders with search filters
  • Create a new payment with payer and organization
  • Edit a payment, change organization — verify it saves
  • Create a payment without Stripe fields (payment_type: "other") — should work without validation errors
  • Filter by payer, organization, event, status on index
  • Visit manage registrants for a paid event — verify payment status badges link to filtered payments
  • Visit manage registrants for a free event — verify no payment column

Anything else to add?

  • Seeds include realistic payment data with most payments succeeded and a few in other statuses, some bundling multiple event registrations under a single payment
  • Event model now includes RemoteSearchable to support the event filter on payments index

🤖 Generated with Claude Code

maebeale and others added 4 commits March 1, 2026 09:57
…agement

Payments track financial transactions (Stripe, check, scholarship, etc.) linked
to payers, organizations, and event registrations. The index page supports
filtering by payer, organization, event, and status via remote-select search
boxes. The manage registrants view now shows payment status badges that link
to the filtered payments index for that payer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The EventRegistration model now has `belongs_to :payment` (singular)
instead of `has_many :payments`. Updated the ticket partial to match.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests were written for the old polymorphic has_many :payments model.
Updated to use belongs_to :payment (singular) and column-based
scholarship_recipient? instead of payment-type-derived scholarship?.

Also adds scholarship_tasks_completed? check to joinable? so scholarship
recipients must complete tasks before accessing videoconference links.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@maebeale maebeale changed the title Add admin CRUD for payments with filtering and manage registrants integration HOLD: Add admin CRUD for payments with filtering and manage registrants integration Mar 1, 2026
The test queried EventRegistration.last before the Turbo stream had
finished processing, causing nil. Adding a Capybara wait for the link
ensures the POST completes before the Ruby-side DB lookup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jmilljr24
Copy link
Collaborator

I think we should have a full chat about payments as well as look at using the pay gem before we get too deep in this.

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