fix(quotes): guard possibly-undefined itemAt in isQuotePdfStale

Deployment was failing at `npm run build` with:
  quote-pdf-service.ts(487,10): error TS18048: 'itemAt' is possibly 'undefined'

`itemAt` comes from `latestItem.items[0]?.updated` (row type
`{ updated?: string }`), so it's `string | undefined`, while `pdfAt`
was already narrowed to `string` by the earlier `if (!pdfAt)` guard —
comparing the two fails under strict mode.

Semantically, a quote with no active items left (all moved/removed)
has no item timestamp, and that alone shouldn't mark the PDF stale;
only the quote-level timestamp decides in that case.

Verified with a full `npm run build` (exit 0).
This commit is contained in:
Dave 2026-09-07 07:54:10 +02:00
parent 66559af422
commit 85913f5869

View file

@ -484,5 +484,9 @@ export async function isQuotePdfStale(quoteId: string): Promise<boolean> {
// matches chronological compare for ISO 8601 with consistent
// timezone offsets, which PB always emits (UTC, no fractional
// seconds). `String(a) > String(b)` is sufficient.
return itemAt > pdfAt || quoteAt > pdfAt;
//
// `itemAt` is undefined when the quote has no active items left
// (all moved/removed) — that alone doesn't make the PDF stale, so
// only the quote-level timestamp decides in that case.
return (itemAt !== undefined && itemAt > pdfAt) || quoteAt > pdfAt;
}