4.4 KiB
4.4 KiB
Task G - Quotation Document Preview Foundation
Files Added
src/features/foundation/document-template/types.tssrc/features/foundation/document-template/service.tssrc/features/foundation/document-template/queries.tssrc/features/foundation/document-template/mutations.tssrc/features/foundation/document-template/server/service.tssrc/features/foundation/document-template/components/template-settings.tsxsrc/features/crm/quotations/document/types.tssrc/features/crm/quotations/document/service.tssrc/features/crm/quotations/document/queries.tssrc/features/crm/quotations/document/server/service.tssrc/features/crm/quotations/components/quotation-document-preview.tsxsrc/app/api/crm/quotations/[id]/document-data/route.tssrc/app/api/crm/quotations/[id]/document-preview/route.tssrc/app/api/crm/document-templates/route.tssrc/app/api/crm/document-templates/[id]/route.tssrc/app/api/crm/document-templates/[id]/versions/route.tsdrizzle/0006_worried_mordo.sql
Files Modified
src/db/schema.tssrc/db/seeds/foundation.seed.tssrc/lib/auth/rbac.tssrc/config/nav-config.tssrc/app/dashboard/crm/settings/templates/page.tsxsrc/app/dashboard/crm/quotations/[id]/page.tsxsrc/features/crm/quotations/components/quotation-detail.tsxsrc/features/crm/quotations/api/mutations.tssrc/features/foundation/approval/mutations.tsdocs/implementation/technical-debt.md
Schema Added
crm_document_templatescrm_document_template_versionscrm_document_template_mappingscrm_document_template_table_columns
API Routes Added
GET /api/crm/quotations/[id]/document-dataGET /api/crm/quotations/[id]/document-previewGET/POST /api/crm/document-templatesGET/PATCH/DELETE /api/crm/document-templates/[id]GET/POST /api/crm/document-templates/[id]/versions
Preview UI Added
- Replaced quotation
Document Previewplaceholder with a production preview tab backed by real quotation data, template resolution, and mapped preview payloads. - Added watermark/status behavior for non-approved quotations through normalized
watermarkStatus. - Preview now shows:
- quotation header
- customer block
- project info
- items table
- price summary
- scope / exclusion / payment topics
- approval block
- signature placeholders
Template Settings UI Added
- Replaced
/dashboard/crm/settings/templatesplaceholder with a production listing page. - Current UI is intentionally lightweight and read-focused:
- template name and description
- default badge
- active/inactive badge
- file type
- latest version
- version count
- mapping count
Template Seed Added
- Foundation seed now upserts a default quotation
pdfmetemplate per organization. - Seed picks template JSON by organization name:
ALLA_template_pdfme_fainal3.jsonONVALLA_template_pdfme_fainal3.json
- If the organization name does not match either branch, the seed falls back to a minimal schema payload.
- Seed also creates baseline placeholder mappings and a table mapping for quotation line items.
Mapping Resolver Added
resolveTemplateForDocument()resolveTemplateMappings()mapDocumentDataToTemplateInput()
Behavior:
- resolves by
documentType + productType + fileType - falls back to
defaultproduct type when no specific product template exists - maps dot-path source fields into scalar, multiline, or table-ready template input
Approved Snapshot Prep Added
prepareApprovedQuotationSnapshot(quotationId, organizationId)
Output contains:
quotationIdapprovedAtdocumentDatatemplateVersionIdtemplateInput
Remaining Risks
- Mapping CRUD UI is not implemented yet, so template mappings remain seed-driven and read-only.
pdfmepreview is not canvas-accurate rendering; current preview is an application-native document view using the normalized document snapshot.- Template resolution currently uses
productType: defaultfor quotation preview. Product-specific template selection can be added later once the business rule is finalized. - No binary PDF generation, storage, or approved PDF URL persistence yet.
Task H Readiness
Task G leaves the repo ready for:
- actual
pdfmegeneration service integration - approved PDF snapshot persistence
- template version publishing workflow
- mapping editor or admin maintenance UI
- product-specific template resolution rules