POWorkspaceagentic kit · product owner
← All runs

Export client invoice history

Author backlog · innovation-group · po-4ac9ea41

completedJira: KAN-138, KAN-139, KAN-140, KAN-141
[po-ticket-author running] Phase discovery started: restating intent and resolving ambiguities for client invoice CSV export
[po-ticket-author running] Phase discovery completed: 10 decisions resolved, 1 epic / 3 stories scoped
[po-ticket-author running] Phase story started: authoring epics and sprint-sized stories
[po-ticket-author running] Phase story completed: 1 epic, 3 sprint-sized stories with typed Jira fields
[po-ticket-author running] Phase ac started: writing Given/When/Then acceptance criteria with failure and edge paths
[po-ticket-author running] Phase ac completed: 13 Given/When/Then AC bullets, linter strict pass 0 errors. Creating Jira issues.

Backlog

Epic: Client Invoice CSV Export3 stories
  1. Filter client invoice history by date range
    • Given I am an authenticated account manager on the client detail page for any client, When the invoice history section loads for the first time, Then the From date picker value is set to the date 12 months before today and the To date picker value is set to today's date, both displayed in YYYY-MM-DD format.
    • Given I am on the client detail page with the invoice history section visible, When I set From to 2024-01-01, To to 2024-06-30, and click Apply, Then the invoice list displays only invoices with invoice_date between 2024-01-01 and 2024-06-30 inclusive and the GET /api/clients/{id}/invoices request carries query parameters from=2024-01-01 and to=2024-06-30.
    • Given I am on the client detail page with the invoice date filter visible, When I enter a From date that is later than the To date, Then the Apply button has the disabled HTML attribute and an inline message 'From date must be before To date' appears beneath the date pickers without requiring a click.
    • Given I am on the client detail page and the GET /api/clients/{id}/invoices request responds with HTTP 500, When I click Apply with a valid date range, Then the invoice list area displays the text 'Failed to load invoices. Try again.' and any previously displayed invoices are cleared from the list.
  2. Filter client invoice history by status
    • Given I am an authenticated account manager on the client detail page with the invoice history section visible, When I open the Status filter dropdown, Then the dropdown renders four checkboxes labelled 'Paid', 'Unpaid', 'Overdue', and 'Voided', all in a checked state.
    • Given all four status checkboxes are checked in the Status filter dropdown, When I uncheck 'Paid' and 'Voided' and click Apply, Then the invoice list shows only invoices whose status field equals 'unpaid' or 'overdue' and the GET /api/clients/{id}/invoices request carries the query parameter status=unpaid,overdue.
    • Given I am on the client detail page and the combination of date-range and status filters yields zero matching invoices after clicking Apply, Then the invoice list area shows the text 'No invoices match your filters.' and the Export CSV button element has the disabled HTML attribute present.
  3. Export filtered client invoice history to CSV
    • Given I am an authenticated account manager on the client detail page with at least one invoice visible in the filtered list, When I click the Export CSV button, Then the browser initiates a file download, the response Content-Disposition header contains 'attachment;filename=', and the response Content-Type header is 'text/csv' with HTTP status 200.
    • Given the CSV export completes successfully, When I open the downloaded file, Then the first row is a header row containing exactly the columns invoice_date,invoice_number,description,amount,currency,status,due_date,paid_date in that order and each subsequent data row contains a non-empty value for invoice_date, invoice_number, amount, currency, and status.
    • Given the export completes successfully for client ID abc123 with filters from=2024-01-01 and to=2024-06-30, When the file downloads, Then the filename in the Content-Disposition header is 'client-abc123-invoices-2024-01-01-2024-06-30.csv'.
    • Given the filtered invoice list contains more than 10000 matching invoices after clicking Apply, When the API response returns the total invoice count, Then the Export CSV button has the disabled HTML attribute and an inline message reads 'Filter your date range to export fewer than 10,000 invoices.' with the exact matching invoice count displayed alongside it.
    • Given an authenticated user whose role is not account_manager views the client detail page, When the invoice history section is rendered, Then no element with the text 'Export CSV' or with a button role associated with export is present in the DOM.
    • Given I am an authenticated account manager on the client detail page with a valid filtered list, When I click Export CSV and the POST /api/clients/{id}/invoices/export request responds with HTTP 500, Then no file download initiates, a toast notification with the text 'Export failed — please try again' appears within 100 ms of the error response, and the Export CSV button returns to its enabled state.