feat(contracts): fill the AVV from the company profile #141

Merged
sharang merged 2 commits from feat/avv-autofill into main 2026-11-19 10:43:01 +00:00
Owner

A workspace with a submitted company profile and a named Geschäftsleitung now gets its AVV filled in automatically instead of the blank template.

How the PDF is made (internal/legal/avvfill)

  • The released master stays byte for byte as the first part of the file; one incremental PDF update follows. Its pin still holds.
  • The update replaces the two content streams with the blank lines: the underscores go, the value takes their place in Geist Regular at 10 pt, inside the line's tagged content (screen readers and copy-paste see "Anschrift: …").
  • Values: name with legal form, address, "Vertreten durch" (Geschäftsleitung holders), Weisung "Geschäftsleitung" (owner decision 19.11.).
  • The font is embedded as Type0/Identity-H with a ToUnicode map: any character Geist has works (Michał, Yılmaz, Łódź…) and extracts as written.
  • A value too long for its line is set smaller down to 8 pt; beyond that, or with a character Geist lacks (e.g. CJK), no auto-fill (missing: ["manual"], log line without values).
  • Deterministic, cached by master SHA + details digest. Layout pinned per master SHA; a test requires one for every released AVV master.

API (GET /v1/tenants/{id}/contracts, AVV entry)

  • filled_from: profile | staff; a staff upload still wins.
  • missing: [profile, company_name, address, management, manual] while the master is blank, for the portal hint.
  • PDF route serves the filled file (Breakpilot_Auftragsverarbeitungsvertrag_1.0.0.pdf), checking the master prefix first.

Also

  • avv-values (staff) uses the same derivation; Weisung now "Geschäftsleitung".
  • Legal form no longer doubled for "UG(haftungsbeschränkt)" written without a space.

Checked locally with synthetic details (incl. Polish/Turkish/Czech names): text extraction and rendering of pages 2 and 4 look like the rest of the document. Portal hint follows in a separate PR.

🤖 Generated with Claude Code

A workspace with a **submitted company profile** and a **named Geschäftsleitung** now gets its AVV filled in automatically instead of the blank template. **How the PDF is made** (`internal/legal/avvfill`) - The released master stays byte for byte as the first part of the file; one incremental PDF update follows. Its pin still holds. - The update replaces the two content streams with the blank lines: the underscores go, the value takes their place in Geist Regular at 10 pt, inside the line's tagged content (screen readers and copy-paste see "Anschrift: …"). - Values: name with legal form, address, "Vertreten durch" (Geschäftsleitung holders), Weisung "Geschäftsleitung" (owner decision 19.11.). - The font is embedded as Type0/Identity-H with a ToUnicode map: any character Geist has works (Michał, Yılmaz, Łódź…) and extracts as written. - A value too long for its line is set smaller down to 8 pt; beyond that, or with a character Geist lacks (e.g. CJK), no auto-fill (`missing: ["manual"]`, log line without values). - Deterministic, cached by master SHA + details digest. Layout pinned per master SHA; a test requires one for every released AVV master. **API** (`GET /v1/tenants/{id}/contracts`, AVV entry) - `filled_from: profile | staff`; a staff upload still wins. - `missing: [profile, company_name, address, management, manual]` while the master is blank, for the portal hint. - PDF route serves the filled file (`Breakpilot_Auftragsverarbeitungsvertrag_1.0.0.pdf`), checking the master prefix first. **Also** - `avv-values` (staff) uses the same derivation; Weisung now "Geschäftsleitung". - Legal form no longer doubled for "UG(haftungsbeschränkt)" written without a space. Checked locally with synthetic details (incl. Polish/Turkish/Czech names): text extraction and rendering of pages 2 and 4 look like the rest of the document. Portal hint follows in a separate PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-19 10:10:46 +00:00
feat(contracts): fill the AVV from the company profile
ci / shared (pull_request) Successful in 12s
ci / test (pull_request) Successful in 8m26s
ci / image (pull_request) Skipped
05673defd4
A workspace whose company profile is submitted and whose Geschäftsleitung is named (Verantwortliche) now sees its AVV filled in: name with legal form, address, "Vertreten durch" and, as the owner decided, "Geschäftsleitung" on the Weisung line. The new package internal/legal/avvfill writes the details onto the released master as one incremental PDF update: the two content streams holding the blank lines are replaced, the underscores dropped and the value set in their place in Geist Regular at body size, inside the line's marked content. The master's bytes stay an untouched prefix, so its pin still holds; the result is deterministic and cached by master and details digest. Layouts are pinned per master SHA-256; a test makes every released AVV master have one.

Until then the master is listed with "missing" (profile, company_name, address, management) for the portal's hint; details that do not fit the form or the Windows-1252 character set give "manual" and a log line without the values. A staff upload still wins (filled_from: staff). The admin avv-values answer uses the same derivation; its Weisung is now "Geschäftsleitung" only. The legal form is no longer appended twice when the name writes it without spaces ("UG(haftungsbeschränkt)").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang added 1 commit 2026-11-19 10:23:57 +00:00
feat(avvfill): Unicode glyphs (Identity-H) instead of Windows-1252
ci / shared (pull_request) Successful in 12s
ci / test (pull_request) Successful in 9m6s
ci / image (pull_request) Skipped
c8dd3ba4dc
With WinAnsi encoding, names like "Michał", "Yılmaz" or "Łódź" fell back to "staff fill it in", a path nobody watches yet. The value is now set as glyph ids of the embedded Geist Regular (Type0 / CIDFontType2, Identity-H) with a ToUnicode map, so any character the font has works and the text still extracts as written. Only control characters and characters without a glyph (e.g. CJK) are refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit 768c195854 into main 2026-11-19 10:43:01 +00:00
Sign in to join this conversation.