# Customer portal invoices and exports

## Customer portal invoices and exports

Customer portal invoices are customer-facing invoice records that a signed-in reader can
locate, inspect, and download. Document exports provide a ZIP response for authorised
attachment IDs. These routes sit outside the main application menu and are useful when you
are supporting a customer who needs an invoice or its documents.

| If you need to… | Go to |
|---|---|
| Find an invoice or narrow the invoice list | [Find and open customer invoices](#find-and-open-customer-invoices) |
| Understand the list or an invoice record | [Understand the invoice surfaces](#understand-the-invoice-surfaces) |
| Support a document download or ZIP export | [Support invoice downloads and document exports](#support-invoice-downloads-and-document-exports) |
| Diagnose an invoice-route failure | [When the invoice route fails](#when-the-invoice-route-fails) |
| Review payment-specific behaviour | Admin payments and follow-ups |

Open the customer-facing invoice list from the customer portal. The list also supports
additional pages, and each invoice reference opens its own record. Use **Download** for an
invoice document.

## Before you start

**Prerequisites**

- You are signed in for the invoice list route.
- You have the invoice identifier or enough customer information to locate the record.
- Invoice-list inputs are not required, and the invoice detail surface has no editable invoice
  fields.

The invoice detail route checks access before it opens the record. If that check fails, the
customer portal home page is the next destination. The application checks attachment read
access and read rules before it builds a ZIP response.

## Find and open customer invoices

The invoice list is the starting point for locating an existing customer-facing invoice.
Use its sort, filter, and search controls to reduce the list before opening the invoice
record.

**Prerequisites**

- You are signed in.
- You know the invoice reference, date, status, or document type you want to find.

**Steps**

1. Open the customer-facing invoice list from the customer portal.
2. Select **Sort By:** and choose one option from the table.

   | If you want to sort by… | Choose |
   |---|---|
   | Invoice date | **Date** |
   | Due date | **Due Date** |
   | Invoice reference | **Reference** |
   | Invoice status | **Status** |

3. Select **Filter By:** and choose one option from the table.

   | If you want to see… | Choose |
   |---|---|
   | All matching records | **All** |
   | Customer invoices and refunds | **Invoices** |
   | Vendor bills and refunds | **Bills** |

4. Enter a search value in **Search** when the search bar is available.
5. Select the invoice reference in the **Invoice #** column.

**Result:** The invoice list is sorted or filtered, or the selected invoice record opens.

The list can also be restricted by both a start date and an end date. When no records are
returned, the page displays `There are currently no invoices and payments for your account.`

The current invoice route displays a server error before the list controls become available:
`500: Internal Server Error`. In that state, **Sort By:** is not on screen and the invoice
list cannot be used.

## Understand the invoice surfaces

An invoice list row identifies a document through its reference, dates, status, and amount
due. An invoice record adds the document report, a download action, and communication history
for support work.

| Surface | What it provides |
|---|---|
| **Invoice #** | The invoice record link |
| **Invoice Date** | The invoice date |
| **Due Date** | The due date |
| **Status** | The invoice payment or cancellation status |
| **Amount Due** | The remaining monetary amount |
| invoice HTML | The embedded invoice report |
| Communication history | The invoice message thread |
| **Download** | The invoice document download |
| **Send message** | A message link when an invoice salesperson is present |

The invoice detail surface is for inspection and document access; it does not provide
editable invoice fields. The route can return an HTML, PDF, or text report when the matching
report type is requested. With no report parameters, it renders the invoice detail page.

## Support invoice downloads and document exports

A legal attachment is the document returned for a posted invoice. When more than one legal
attachment exists, the invoice download returns a ZIP. The direct export route also builds
a ZIP after checking attachment read access and read rules.

**Prerequisites**

- The invoice is open when you use **Download**.
- For the posted-invoice download branch, the invoice is posted.

**Steps**

1. Open the invoice record.
2. Select **Download**.
3. Check the returned document type.

   | If the request is… | The route returns… |
   |---|---|
   | A posted invoice with one legal attachment | The legal attachment |
   | A posted invoice with more than one legal attachment | A ZIP |
   | A report request for HTML, PDF, or text | The requested report |

**Result:** The invoice document or ZIP response is available for the customer-facing
document request.

## Handle invoice and access branches

Invoice branches tell you what the reader can see after filtering, opening, or requesting a
document. Use the visible status and the route outcome to choose the support path.

**Steps**

If invoice-detail access fails, the application redirects to the customer portal home page.

1. Check the invoice list outcome against the table.

   | If the list shows… | Continue with… |
   |---|---|
   | No records | The empty-list message |
   | Records | The invoice row and its status |
   | **Paid** | Document or payment follow-up support |
   | **Reversed** | Reversal support |
   | **Waiting for Payment** | Payment follow-up support |
   | **Cancelled** | Cancellation support |

2. Check whether the request included both a start date and an end date when the reader
   expects a date-restricted list.
3. Open the invoice record when access succeeds.
4. Send payment-method questions to Admin payments and follow-ups.

**Result:** You have identified the invoice branch and the next support route.

Payment-specific messages belong to the payment surface, including
`No suitable payment method could be found.` and
`If you believe that it is an error, please contact the website administrator.`

## When the invoice route fails

Use this section when the invoice route stops before the invoice list appears. The generic
invoice error message is `There was an error processing this page.`

| What you see | What it means | What to do |
|---|---|---|
| `500: Internal Server Error` | A template-rendering failure stopped the invoice list. | Record the error details for support escalation. |
| A template-rendering failure caused by a missing database field | A required database field is unavailable. | Include the database-field error details in the escalation. |
| **Sort By:** is not on screen | The list did not reach the search-bar controls. | Troubleshoot the route error before attempting sorting. |

The error page also displays **Restore previous version (soft reset).** and **Reset to initial
version (hard reset).** These are recovery controls on the error page, not invoice-list
controls.

## Know what to do next

To continue, use [Find and open customer invoices](#find-and-open-customer-invoices) to locate
the record, [Understand the invoice surfaces](#understand-the-invoice-surfaces) to review it,
and [Support invoice downloads and document exports](#support-invoice-downloads-and-document-exports)
to handle its documents.
