GCP invoices → subsidiary Drive folder + Records Vendor Invoices tab (like Workspace)
Goal (owner, 2026-06-15)¶
GCP invoice PDFs should be filed to the subsidiary's Google Drive (14b. Vendor Invoices) and shown on Records → Vendor Invoices, exactly like Workspace invoices. Symptom: the tab shows only WORKSPACE invoice PDFs, plus "a bunch of GCP metadata that are not actually PDFs" — so GCP appears as metadata rows (likely the Cost Table scrape) instead of real filed PDFs.
Hypotheses to check¶
- The GCP cost-table metadata (Firestore Expenses/Subscriptions/Google/GCP/invoices) is surfacing on the Vendor Invoices tab as non-PDF rows, while the GCP PDF ingest (NAS gcp-invoices → ingest route → Drive 14b + File-Archive) either didn't run for these or files under a different type/doc-type so the tab doesn't render them as PDFs.
- The ingest route (pages/api/workspace/billing/ingest.ts) handles BOTH workspace + GCP; GCP may be tagged type 'workspace_invoice' or land in a different folder / File-Archive doc shape than the tab expects, so the records page shows it without a PDF link.
- Relates to [[project_gcp_billing_reconciliation]], T-034 (NAS GCP PDF scraper), the Cost Table scraper.
Resolution (2026-06-15)¶
Root cause was NOT a missing/mis-typed ingest — the GCP PDFs WERE filed correctly.
pages/api/records/vendor-invoices.ts buildGcpRows() builds GCP rows from the
cost-table metadata (listStoredInvoices) and hardcoded pdfUrl: null, never
joining to the actual PDFs. The PDFs live as File-Archive gcp_invoice docs
(Drive 14b, id == invoiceNumber, storagePath: drive:<fileId>) — 8 of them
(2025-10 → 2026-05).
Empirical diagnosis (real data):
- File-Archive: 46 workspace_invoice (44 GCS receipts/…, 2 newest drive:),
8 gcp_invoice (all drive:).
- All 8 gcp_invoice docs join to cost-table rows by invoiceNumber; older months
(2024-10 → 2025-09) have no PDF doc yet (NAS GCP PDF scraper started Oct 2025).
Fix:
- Added shared resolveVendorPdfUrl(documentId, storagePath): drive: →
/api/accounting/receipts/[id]?redirect=pdf (streams Drive bytes; the existing
Drive-aware endpoint); GCS → signed URL (unchanged). Applied to Workspace + GCP
+ manual builders.
- buildGcpRows() now loads listGcpInvoices(), maps invoiceNumber→documentId,
and attaches the streaming URL to matched months (null otherwise).
- Also fixed a LATENT bug: the 2 Drive-resident Workspace invoices were silently
null through the GCS-only getReceiptDownloadUrl.
- Refreshed stale "GCP never has PDFs" comments + the disabled-button tooltip.
Verified vs real data: 8 GCP months now expose a PDF link, 13 older stay null;
2 Workspace fixed. tsc --noEmit clean; touched-file lint clean (3 pre-existing
errors in VendorInvoicesTab unrelated to the 2-line edit).
PROMOTED 2026-06-15: commit e4935125 → nightly 336ccb29 → main 58297279.
Log¶
- 2026-06-15 created (owner). Investigating the Vendor Invoices data source + GCP vs Workspace ingest path.
- 2026-06-15 DONE. Join cost-table GCP rows → gcp_invoice Drive PDFs via resolveVendorPdfUrl; latent Workspace drive: fix. Verified. Pending promotion.