diff --git a/src/lib/invoice-pdf.ts b/src/lib/invoice-pdf.ts index 210be87..8e8d4d7 100644 --- a/src/lib/invoice-pdf.ts +++ b/src/lib/invoice-pdf.ts @@ -403,15 +403,14 @@ export async function downloadInvoicePdf(input: InvoicePdfInput, filename: strin const descMaxW = colQtyR - colDescX - 14; const descLines = wrap(pdf, item.description || (item.kind === "expense" ? "Expense" : ""), descMaxW); const lineHeight = 12; - const blockH = Math.max(lineHeight * descLines.length + 14, item.user_name ? 32 : 26); + const blockH = Math.max(lineHeight * descLines.length + 14, item.user_initials ? 32 : 26); ensure(blockH + 4); setFont(pdf, { size: 9, color: TEXT }); pdf.text(fmtDateShort(item.work_date), colDateX, y + 12); - if (item.user_name) { + if (item.user_initials) { setFont(pdf, { size: 7.5, color: MUTED }); - const nameLines = wrap(pdf, item.user_name, colKindX - colDateX - 4); - pdf.text(nameLines[0], colDateX, y + 23); + pdf.text(item.user_initials, colDateX, y + 23); } setFont(pdf, { size: 9, color: MUTED }); diff --git a/src/routes/invoices.$invoiceId.tsx b/src/routes/invoices.$invoiceId.tsx index 2048dcc..9007577 100644 --- a/src/routes/invoices.$invoiceId.tsx +++ b/src/routes/invoices.$invoiceId.tsx @@ -445,7 +445,11 @@ function InvoiceDetail() { ) : (
{it.description}
- {it.user?.full_name &&
{it.user.full_name}
} + {(() => { + const nm: string = it.user?.full_name || it.user?.email || ""; + const init = nm.trim().split(/\s+/).map((p: string) => p[0]).filter(Boolean).slice(0, 3).join("").toUpperCase(); + return init ?
{init}
: null; + })()}
)}