diff --git a/.planning/phases/12-orders-invoices-company-matching/deferred-items.md b/.planning/phases/12-orders-invoices-company-matching/deferred-items.md index ba0dd3c..9dd193e 100644 --- a/.planning/phases/12-orders-invoices-company-matching/deferred-items.md +++ b/.planning/phases/12-orders-invoices-company-matching/deferred-items.md @@ -15,3 +15,9 @@ Out-of-scope issues discovered during execution but not fixed (per Scope Boundar `lib/types/pax8.ts` reverted to its pre-plan state. Not touched by migrations/093 or lib/types/pax8.ts. Someone completing the appgate feature branch/commit should resolve this; out of scope for Phase 12. + +## Plan 02 + +- Same pre-existing `sync-scheduler.ts:446`/`:450` TS2307 errors reproduce + unchanged after Task 1's `pax8-client.ts` edits (`listAllInvoices` / + `listAllInvoiceItems`). Confirmed unrelated to this plan's files. diff --git a/lib/services/pax8-client.ts b/lib/services/pax8-client.ts index 316a68f..a796206 100644 --- a/lib/services/pax8-client.ts +++ b/lib/services/pax8-client.ts @@ -4,7 +4,14 @@ * https://devx.pax8.com */ -import type { Pax8Company, Pax8PageEnvelope, Pax8Subscription, Pax8Product } from '@/lib/types/pax8'; +import type { + Pax8Company, + Pax8PageEnvelope, + Pax8Subscription, + Pax8Product, + Pax8Invoice, + Pax8InvoiceItem, +} from '@/lib/types/pax8'; export interface Pax8ClientConfig { clientId: string; @@ -120,4 +127,30 @@ export class Pax8Client { this.fetchJson>(`/products?page=${page}&size=${size}`), ); } + + /** + * Read-only: page through every invoice header (PAX8-08 — GET only). + * `/invoices` is the partner's own consolidated monthly bill — one row per + * billing period, not per end-customer (12-RESEARCH.md Pitfall 1). Do NOT + * add an orders-endpoint call — it is unreliable (504s) for this account + * (12-RESEARCH.md Pitfall 3). + */ + async listAllInvoices(): Promise { + return this.paginateAll((page, size) => + this.fetchJson>(`/invoices?page=${page}&size=${size}`), + ); + } + + /** + * Read-only: page through every line item of a single invoice + * (PAX8-08 — GET only). Invoice items are a per-invoice child resource — + * there is no flat `/invoice-items` endpoint (12-RESEARCH.md Pitfall 2). + */ + async listAllInvoiceItems(invoiceId: string): Promise { + return this.paginateAll((page, size) => + this.fetchJson>( + `/invoices/${invoiceId}/items?page=${page}&size=${size}`, + ), + ); + } }