4.3 KiB
4.3 KiB
Task H.2: PDFME Dynamic Topic Engine + Mapping Hotfix
Files Added
src/features/crm/quotations/document/server/pdfme-transforms.tssrc/features/crm/quotations/document/server/pdf-topic.type.tssrc/features/crm/quotations/document/server/pdf-topic-engine.tssrc/features/crm/quotations/document/server/topic-mapping.tsdocs/implementation/task-h2-pdfme-mapping-transform-hotfix.md
Files Modified
src/features/crm/quotations/document/server/service.tssrc/features/crm/quotations/document/types.tssrc/features/crm/quotations/components/quotation-document-preview.tsxsrc/features/foundation/document-template/server/service.tssrc/db/seeds/foundation.seed.tsscripts/verify-task-h1.jsscripts/audit-pdfme-runtime.tsdocs/implementation/technical-debt.md
Transform Utilities Added
formatPdfDate()formatPdfCurrency()formatTopicItems()normalizePdfmeTable()
Dynamic Topic Engine Added
- page-2
topicanddata_topicschemas are now treated as dynamic templates instead of static mappings - topic blocks are cloned into runtime keys like
topic_1_0anditem_topic_1_0 - topic rows are normalized into
string[][] - the closing/signature block is kept together and pushed to the next page when remaining space is too small
- long topic lists can expand page 2 into multiple generated pages
Product Topic Mapping Added
- product-type-aware topic mapping with
crane,dockdoor,solarcell, anddefaultfallbacks - alias matching allows current simplified option codes and legacy-style topic codes to resolve into PDFME-ready sections
Template Mappings Fixed
customer_att -> quotation.attentionquotation_date -> pdfme.quotation_datequotation_price -> pdfme.quotation_priceexclusion_data -> pdfme.exclusion_data- legacy
item_topicmapping is now explicitly retired from foundation seed data because dynamic topics are schema-driven
Seed Mapping Strategy After Dynamic Topic Engine
- default PDFME seed mappings now keep only static runtime fields plus safe signature placeholders
quotation_dateandquotation_priceare seeded against the preformattedpdfme.*fields with no extra format masktopic,data_topic,item_topic, and wildcard runtime keys such astopic_*/item_topic_*are retired from DB mappings- signature placeholders
app1/app2/app3and position fields are seeded with safedefaultValue: "-"until Task H.3 defines the real approval-signature strategy
PDF Generator Integration
- quotation preview data now returns a render-ready PDFME schema with injected topic pages
templateInputnow merges dynamic topic inputs with normal mapped fields- approved snapshot generation now captures the same merged topic input set used by PDF generation
- the existing PDF generator flow now consumes the render-ready schema returned by the preview service
Verification Result
npx tsc --noEmitpassedscripts/verify-task-h1.jsnow asserts:- formatted
quotation_price - formatted
quotation_date - non-empty
exclusion_data - generated dynamic topic keys in preview payload
documentData.pdfme.topic_inputs- no unresolved
{exclusion_data},{quotation_price}, and{item_topic}in approved PDF text
- formatted
- inline
tsxsmoke testing for the new engine was inconclusive because the local script loader exposed the module as a default-only object even though project typecheck succeeded - full
verify:task-h1end-to-end execution was not run in this turn because it depends on a live app server and fixture database state
Remaining PDFME Gaps
- approval signature placeholders are still not mapped to real approver names/positions
- pixel-perfect parity with the legacy layout has not been regression-tested automatically
scripts/audit-pdfme-runtime.tsstill needs a stable standalone runtime strategy if we want to use it outside the Next.js execution context
Task K Readiness
- dynamic server-side topic rendering now exists, so follow-on PDF tasks can build on runtime schema generation instead of adding more fixed placeholders
- seed data and template mapping are aligned with the current ALLA / ONVALLA templates
- the next safe step is end-to-end fixture verification against a running app plus any remaining signature-field strategy