#+TITLE: Billing Portal — UI Implementation Tasks (Grails)
#+AUTHOR: Hermes (Grails Guru & Self-Service Portal Advisor)
* TODO Task 1: Create Bill domain class
Create ~grails-app/domain/com/flowkraft/Bill.groovy~
- Follow: existing Invoice.groovy pattern (same structure, same helpers)
- Fields: billNumber, customer info, amounts (subtotal, taxRate, taxAmount, discount, totalAmount), dueDate
- Status: draft, sent, paid, overdue, cancelled
- Payment: paidAt, paymentMethod (stripe/paypal), paymentReference
- Reminders: reminderCount (default 0), lastReminderDate (nullable)
- Value: Foundation — all views and controllers depend on this domain class
* TODO Task 2: Create BillController (Admin CRUD)
Create ~grails-app/controllers/com/flowkraft/BillController.groovy~
- Follow: InvoiceController pattern (index, show, create, save, edit, update, delete)
- Features: search by billNumber/customerName, pagination, flash messages
- Value: Admin can manage bills from the backend
* TODO Task 3: Create admin bill GSP views
Create ~grails-app/views/bill/~ (index.gsp, show.gsp, create.gsp, edit.gsp)
- Follow: existing invoice/ views — same Bootstrap 5 table, status badges, action buttons
- index.gsp: table with search, status badges (paid=green, overdue=red, draft=gray), view/edit/delete buttons
- show.gsp: full bill detail with amounts breakdown, payment info, customer info
- Value: Admin CRUD UI — bills are visible and manageable
* TODO Task 4: Create PortalBillController
Create ~grails-app/controllers/com/flowkraft/PortalBillController.groovy~
- Follow: PortalInvoiceController pattern (index, show, pay, download)
- Layout: uses portal layout (customer-facing)
- Injects: stripeService, payPalService (already exist)
- Value: Customer portal backend — lists bills, shows details, handles payments
* TODO Task 5: Create portal bill GSP views
Create ~grails-app/views/portalBill/~ (index.gsp, show.gsp, pay.gsp)
- Follow: portalInvoice/ views — match Athena’s mockups
- index.gsp: bills list with cards, status badges, “Pay Now” buttons (from Athena’s bills-list mockup)
- show.gsp: bill detail with amounts, payment status (from Athena’s bill-detail mockup)
- pay.gsp: Stripe Elements + PayPal SDK tabs (adapted from portalInvoice/pay.gsp)
- Value: Customer-facing UI — the portal homepage
* TODO Task 6: Wire payment integration for bills
Update ~grails-app/controllers/com/flowkraft/PaymentController.groovy~ (existing)
- Reuse: existing StripeService + PayPalService — they already work for invoices
- Add: bill-specific payment endpoints (create-bill-intent, capture-bill-order)
- Pattern: same flow as invoice payments, just operating on Bill instead of Invoice
- Value: Full payment flow — Stripe + PayPal working for bills
* TODO Task 7: URL mappings & navigation
Update ~grails-app/controllers/com/flowkraft/UrlMappings.groovy~ (existing)
- Add: /bill/* and /portalBill/* route mappings
- Update: portal.gsp — add “My Bills” nav link
- Update: admin layout — add “Bills” sidebar link
- Value: Bills are discoverable — users can navigate to them
* TODO Task 8: Smoke test & cleanup
- Insert test bill via BootStrap.groovy (seed data)
- Verify: admin CRUD (list, create, edit, delete), portal views (list, detail), payment flow (Stripe + PayPal)
- Cleanup: remove inherited Invoice/Payslip sample code we no longer need
- Value: Confidence — everything works end-to-end before shipping