{{define "invoice_search_results"}} {{if .Error}}
{{.ErrorMsg}}

Search term: "{{.SearchTerm}}"

{{else if .NotFound}}
{{.ErrorMsg}}

Search term: "{{.SearchTerm}}"

{{else if .MultipleInvoices}}

Multiple Invoices Found

Found {{.TotalFound}} of {{.TotalSearched}} invoices for: "{{.SearchTerm}}"

{{if gt .FailedCount 0}}

Failed to find {{.FailedCount}} invoices: {{range $i, $id := .FailedIDs}}{{if $i}}, {{end}}{{$id}}{{end}}

{{end}}
{{range .Invoices}}

Invoice #{{.invoiceNumber}}

{{.status}}
{{with .customer}}

Customer: {{.name}}

{{end}} {{with .job}}

Job: {{.name}}

{{end}}

Total: ${{.totalPrice}}

{{range .buttons}} {{end}}
{{end}}
{{else if .invoiceNumber}}

Invoice Details

Invoice #{{.invoiceNumber}}

{{.status}}
{{with .customer}}

Customer: {{.name}}

{{end}} {{with .job}}

Job: {{.name}}

{{end}} {{with .location}}

Location: {{.name}}

{{end}}

Total Price: ${{.totalPrice}}

{{if .items}}
Items
    {{range .items}}
  • {{.description}} - ${{.totalPrice}}
  • {{end}}
{{end}}
{{range .buttons}} {{end}}
{{else}}

Unexpected response. Please try again.

{{end}} {{end}}