Skip to content

feat: add pdf command to save transactions as QuickBooks-rendered PDFs - #15

Merged
voska merged 4 commits into
voska:mainfrom
robschaerer:pdf-command
Oct 10, 2026
Merged

voska merged 4 commits into
voska:mainfrom
robschaerer:pdf-command

Conversation

@robschaerer

@robschaerer robschaerer commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds qbo pdf <entity> <id> [-o path], which saves a transaction as the PDF the QuickBooks API renders for it.

qbo pdf invoice 123 -o invoice-123.pdf

Note: the API rendering is not always identical to what the QuickBooks web UI prints or emails. On a real invoice, the API combined three lines that share a description into one summed line, while the PDF downloaded from the UI lists them separately. The same bytes come back at every minorversion, so this is QuickBooks' renderer, not a request option. The docs say so.

Why

The /v3/company/{realm}/{entity}/{id}/pdf endpoint is already reachable through qbo get invoice "123/pdf", but every request the client makes sends Accept: application/json, and QuickBooks answers 500 System Failure Error: No match for accept header. So there was no way to get a PDF out of the CLI.

How

  • api.Client.PDF sends Accept: application/pdf through the same OAuth client as every other call, so it uses the existing token refresh and error mapping (mapHTTPError).
  • Limited to the entities QuickBooks renders: invoice, estimate, salesreceipt, creditmemo, purchaseorder. Others are rejected with exit 2.
  • The id must be numeric, because it is interpolated into the URL path and a document number passed by mistake would silently fetch a different transaction.
  • A 200 whose body does not start with %PDF is refused rather than saved under a .pdf name.
  • --dry-run prints the request and returns before any network call.
  • Output follows the existing download command: hint on stderr, {entity, id, path, bytes} on stdout.
  • Docs: skills/qbo/SKILL.md and references/COMMANDS.md.

Testing

  • go test ./... passes. New tests cover the Accept header and path, rejection of a non-PDF 200 body, HTTP error mapping, entity support, input validation, and dry-run without network.
  • Checked against a production company: qbo pdf invoice <id> returned a 45 KB single-page PDF with the correct header, customer, lines and total (lines with identical descriptions combined, as noted above).

🤖 Generated with Claude Code

https://claude.ai/code/session_019jpxEQMLnxu4s6zSfHq8xR

robschaerer and others added 2 commits September 25, 2026 16:34
`qbo pdf <entity> <id> [-o path]` fetches GET /{entity}/{id}/pdf with
Accept: application/pdf. The endpoint is reachable through `qbo get`,
but every request there sends Accept: application/json and QuickBooks
answers 500 "No match for accept header".

Supported for invoice, estimate, salesreceipt, creditmemo and
purchaseorder. The id must be numeric (it is interpolated into the
path), and a 200 whose body is not a PDF is refused rather than saved.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jpxEQMLnxu4s6zSfHq8xR
Compared against a PDF downloaded from the QuickBooks web UI: the API
rendering combines invoice lines that share a description into one
summed line, where the UI lists them separately. The API returns the
same bytes at every minorversion, so it is the renderer, not a request
option. Say so instead of claiming it is the customer's document.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jpxEQMLnxu4s6zSfHq8xR
@voska

voska commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Thanks for this, and sorry for the wait. A dedicated qbo pdf command fits well, and the note about API rendering differing from the web UI is useful.

Please rebase onto current main; GitHub reports conflicts. The existing tests cover request headers, non-PDF responses, error mapping, input validation and dry-run behavior.

I will handle CI approval on the updated branch. Checks need to pass before merging.

@voska
voska merged commit cb41f94 into voska:main Oct 10, 2026
2 checks passed
@voska

voska commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thanks for adding this. I merged main into your branch to fix the SKILL.md conflict with the new void command.

@voska

voska commented Oct 13, 2026

Copy link
Copy Markdown
Owner

This shipped in v0.8.0: https://github.com/voska/qbo-cli/releases/tag/v0.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants