# Phase 7 — Payment Report

**Status:** Complete — awaiting approval to start Phase 8  
**Date:** 2026-10-08  

---

## Design note

No separate Finance AR module was hooked for invoice settlement. Payments are **Project-owned** on `project_invoice_payments`, updating invoice `paid_amount` / `outstanding_amount` / derived payment status. Commissioning **payment-clear** (team share) remains a separate flow and is unchanged.

Milestone invoiceability continues to use **invoiced** amounts only — payment does not change remaining invoiceable.

---

## Backend

| Item | Detail |
|------|--------|
| Migration | `2026_10_08_100000_create_project_invoice_payments_table.php` |
| Model | `ProjectInvoicePayment` |
| Enums | `ProjectInvoicePaymentStatus`, `ProjectInvoicePaymentState` |
| Service | `ProjectInvoicePaymentService` — record payment, lock invoice, reject overpay / cancelled |
| Permission | `project.invoice-payments-manage` |

| Endpoint | Purpose |
|----------|---------|
| `GET /api/v1/project/invoices/{id}/payments` | List payments for invoice |
| `POST /api/v1/project/invoices/{id}/payments` | Record payment (updates paid/outstanding) |

---

## Frontend

| Surface | Behavior |
|---------|----------|
| Invoice detail drawer | Payment list, paid/outstanding, **Record payment** form (amount, date, reference) |

---

## Tests

`ProjectInvoicePaymentApiTest` — **4 passed**

- partial payment updates outstanding  
- multiple payments can settle invoice  
- overpayment rejected  
- payment does not change milestone invoiceability  

Related: `MilestoneInvoiceabilityServiceTest` partial-invoice case still passes.  
Frontend `tsc -b` — clean.

---

## Explicitly NOT done

- Full E2E suite across Contract → Milestone → Invoice → Payment (Phase 8)  
- Finance-module ledger / bank reconciliation  
- Void/refund payment APIs  

---

## STOP

Phase 7 complete. **Awaiting explicit approval for Phase 8 — End-to-End Validation.**
