Phase 1: Standardize Payments as the Manual Bill Payment Model + Surface on Bills Detail #43
Labels
No Label
architecture
backend
bug
feature
frontend
priority:critical
priority:high
priority:low
priority:medium
priority:nice-to-have
ux
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: null/BillTracker#43
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Standardize and expose the existing
paymentstable as the canonical manual bill payment model. Addpayment_sourceandtransaction_idcolumns to the existingpaymentstable (not a new table). Then surface payment history on the Bills detail/edit page — the only real UI gap.Depends on: Nothing (first phase)
Blocks: Phase 2 (#44), Phase 4 (#46)
Parent: #42
What Already Exists
The repo has a full payment system already:
paymentstable:id,bill_id,amount(REAL dollars),paid_date,method,notes,balance_delta,deleted_at, timestamps —db/schema.sqlPOST/GET/PUT/DELETE /api/payments,GET /api/bills/:id/payments—routes/payments.jsDELETE /api/payments/:idsetsdeleted_at,POST /api/payments/:id/restoreclears itservices/paymentValidation.js—paid_date, REAL dollar amountsservices/statusService.js— partial payments handled, paid whentotalPaid >= expectedAmountTrackerPage.jsxline 544 (history), line 1075 (edit/delete modal)Do NOT create a new
bill_paymentstable. The existingpaymentstable is the payment ledger.Migration: Add Columns to Existing
paymentsTableAdd to
db/database.jsmigrations:payment_sourcecolumn not inPRAGMA table_info(payments)ALTER TABLE payments ADD COLUMN payment_source TEXT NOT NULL DEFAULT 'manual'transaction_idcolumn not inPRAGMA table_info(payments)ALTER TABLE payments ADD COLUMN transaction_id INTEGERColumn purposes
payment_source— tracks origin:manual,file_import,provider_sync. Existing rows default tomanual.transaction_id— nullable FK totransactionstable (added in Phase 2). For now, column exists but is NULL until Phase 2 creates the transactions table. Do NOT add a FK constraint yet — add it in Phase 2 when the referenced table exists.Backend Changes
Update payment creation to accept
payment_sourceDefault
payment_sourcetomanualinroutes/payments.jscreate handler. Frontend can omit it.Update payment response shapes
Include
payment_sourceandtransaction_id(null for now) in payment responses.No new endpoints needed
The existing CRUD endpoints already handle everything. This phase does not add routes.
Frontend
Add to the Bills detail/edit page (
BillModal.jsx):manualUse existing
GET /api/bills/:id/paymentsandPOST /api/paymentsendpoints.Request shape matches existing validation:
Note:
amountis a REAL dollar value (not integer cents).paid_dateis the field name (notpaidAt).Status Logic
Bill status is already derived from payments correctly:
totalPaid < expectedAmount→ partial statustotalPaid >= expectedAmount→ paidDo NOT regress partial payment support. A single payment does not mean "paid" unless the total covers the expected amount.
What This Phase Does NOT Do
transaction_idyet (added in Phase 2)Acceptance Criteria
payment_sourceandtransaction_idcolumns topaymentstablepayment_sourceandtransaction_id(null)BillModal.jsx)Next → Phase 2 (#44)
Phase 1: Manual Bill Paymentsto Phase 1: Payment History on Bills Detail PagePhase 1: Payment History on Bills Detail Pageto Phase 1: Standardize Payments as the Manual Bill Payment Model + Surface on Bills Detail