HrContract Docs

Contract Engine

Portable variable engine without tariff_*

Portable core under src/lib/contract-engine/. Host apps (HR, performance, leases) plug domain data in — the core never hard-codes tariff_* or user_rasa_*.

Pieces

ModuleRole
types.tsVariableProvider, overlays, signer roles
placeholders.tsRepair TinyMCE/RTL broken {{…}}, extract names
replace-variables.tsSubstitute + RTL isolation for Jalali dates / indicators
registry.tsVariableRegistry — definitions + providers
providers.tscreatePersonVariableProvider, static, computed
generation-overlays.tsModal fields (price, dates, description)

Resolve flow

  1. Author HTML template with {{person_name_family}}, {{contract_price}}, …
  2. Generate modal collects overlay keys (HR_GENERATION_OVERLAYS).
  3. VariableRegistry.resolveAll(html, ctx, forcedKeys) merges providers + overlays.
  4. replaceVariables(html, map) → frozen HTML + JSON cache on HrContract.templateVariables / contentHtml.
  5. Unsigned DOCX/PDF downloads regenerate from that frozen contentHtml (nothing written under hr-contracts/unsigned/). Signed + QR PDFs are persisted only after Emzagar completes a sign session.

Adding a new domain variable

  1. Add to src/constants/hr-document-variables.ts.
  2. Map it in createPersonVariableProvider (or a new provider).
  3. If it must be typed in the generate modal, add to HR_GENERATION_OVERLAYS.

What was left out of the extract (on purpose)

  • tariff_* resolvers / UserTariff
  • Upload-date payroll batching
  • Assessment / collector reports
  • Full Chromium PDF / DOCX pipelines (wire docx + puppeteer like performance-web when needed)