# TechTitans POS — Invoice Logo: Diagnosis & Verification (not a renderer regression)

**Date:** 2026-11-12 · **Branch:** `techtitans/integration` · Local commit only (no push/deploy).
No production renderer change (none was needed); no historical issued PDF regenerated or overwritten; no amounts,
numbering or status touched. NH POS / legacy portal untouched.

## TL;DR

The spacing refinement **did not** break logo rendering. A freshly rendered TechTitans invoice shows the uploaded
logo prominently in the top-left header with the new ~20 mm spacing fully intact. The "only the text *TechTitans*"
appearance came from the **spacing-refinement screenshots using synthetic test fixtures** (Kings Biryani — a plain
teal placeholder / no logo), while the only *real* TechTitans image in that batch was the **old-template**
`before-p1.png`. Side by side that read as "logo removed." The fix for this report is therefore **verification +
regression coverage**, not a renderer change.

## Investigation (each step from the brief)

1. **Template & `renderPdf`.** The header still renders `@if($hasLogo) <img src="{{ $logo }}" class="logo"> @endif`
   with `$hasLogo = ! empty($logo) && ($has_logo ?? false)`. `InvoiceService::renderPdf()` still builds
   `'logo' => $this->currentLogoDataUri()` and `'has_logo' => $logo !== null`. **Logo logic unchanged.**
2. **`a913a9e` (branded) vs `0519a36` (spacing).** The diff touches the logo only in CSS:
   `.logo { max-height: 72px; max-width: 240px; margin-bottom: 8px }` → `{ max-height: 70px; max-width: 230px;
   margin-bottom: 11px }`. No change to the `<img>`, to `$logo`/`$has_logo`, or to the resolver. The TechTitans
   logo is 512×97, so at `max-width:230px` it scales to ~230×44 — **well under** the 70 px cap, i.e. not clipped.
3. **HTML-margin / DomPDF change & images.** The margin fix moved the page inset onto `@page` + `html` (zeroing only
   `body`). This governs page geometry, not image decoding. Proven: scenario `s01` already renders its placeholder
   logo (solid teal box) top-left under the new margins, and the live TechTitans render below embeds the real logo.
   **No image-rendering regression.**
4. **`TenantLogoService::dataUri()`.** Still resolves: for TechTitans it returns a 16,370-char
   `data:image/png;base64,…` from the 12,259-byte private-disk PNG.
5. **Rendered-PDF source, not just HTML.** A fresh live render produced a **891 KB** PDF whose bytes contain
   `/Subtype /Image` (DomPDF image XObject). Rasterized page 1 visually shows the logo (see §4).
6. **Frozen vs fresh.** The sampled document `PF-2026-0016` is an existing proforma; its stored bytes were frozen at
   issue time. But the logo is embedded **live at render**, so re-rendering it now (equivalent to issuing a new
   invoice) shows the current logo. Historical stored PDFs are intentionally **not** rewritten.
7. **Tenant logo configuration / private storage.**
   `tenants.logo_path = tenant-logos/01a1af3d-…/55630409-…png`, file present on the private `local` disk.
8. **Dimensions / clipping / positioning.** PNG 512×97 (type 3). Header `<td width:58%>` → scaled to ~230 px wide,
   ≈44 px tall; top-left; aspect preserved; not clipped; clear space below before the business name.

## Verification — a newly rendered TechTitans invoice

Rendered live in the `techtitans` tenant context with the current template + current logo (see
`docs/techtitans/screenshots/invoice-spacing/techtitans-logo-verified-p1.png`, rasterized at 100% / full page):

| Check | Result |
|---|---|
| Actual uploaded logo visible | ✅ "TECH TITANS — EXPANDING POSSIBILITIES" top-left |
| Logo not clipped / aspect preserved | ✅ 512×97 → ~230×44, within the 70 px cap |
| Page margins | ✅ ~20 mm all sides (unchanged from the refinement) |
| Header alignment | ✅ logo + name left, PRO FORMA INVOICE + metadata + pill right |
| Company info below the logo | ✅ TechTitans · CA · phone · email |
| Navy/teal styling | ✅ preserved |
| Footer & page numbering | ✅ contact line · "Thank you…" · "Page 1 of 1" |
| Text-only fallback (no logo) | ✅ Kings Biryani renders the name only, no broken image |
| Tax / totals | ✅ unchanged (Subtotal 15.00 · Tax 13% 1.95 · Grand 16.95 · Balance 16.95) |
| Multi-page | ✅ still renders (per `s10` + the long-description test) |
| Tenant logo isolation | ✅ each PDF carries only its own tenant's bytes (existing test) |

## Regression coverage (asserts the PDF, not only the HTML)

`tests/Feature/Orders/InvoicePdfTest.php` →
**`test_logo_is_embedded_as_an_image_in_the_rendered_pdf_not_only_the_html`**: issues a with-logo and a no-logo
invoice and asserts the **rendered PDF bytes** contain `/Subtype /Image` (DomPDF raster XObject) **with** a logo and
**not** without. This closes the gap in the prior test, which only asserted `<img`/`data:` in the HTML — a necessary
but not sufficient signal that could pass even if a margin/renderer change dropped the image from the page.
(Raw byte-size isn't asserted: the embedded DejaVu font subset dwarfs a small logo, so size is noise.)

## Tests & static analysis

- `php artisan test tests/Feature/Orders/InvoicePdfTest.php` → **9 passed (33 assertions)** — includes the new
  regression test.
- **Pint:** passed on the changed test file.
- **PHPStan** (`app/Invoices`, the in-scope component): **No errors.** The project gate is `paths: [app]`; a full
  `app` run reports 21 **pre-existing** errors in unrelated modules (IPTV / Menu / Inventory) — none in `app/Invoices`
  and none introduced here (this task changed only the test file, which is outside the gate).

## Files changed

| File | Change |
|---|---|
| `tests/Feature/Orders/InvoicePdfTest.php` | New PDF-level logo regression test. |
| `docs/techtitans/screenshots/invoice-spacing/techtitans-logo-verified-p1.png` | Rendered proof: real logo + refined spacing. |
| `docs/techtitans/INVOICE-LOGO-VERIFICATION.md` | This report. |

**No production code changed** — the renderer was never broken; the logo embeds correctly for newly issued invoices.

## Commit (on `techtitans/integration`, no push)

- **Backend:** `7f7886b` — the regression test, the verification screenshot, and this report.
