--- name: form-engine description: Template engine render 8 form hợp đồng ra .docx/.xlsx giống 100% mẫu gốc. Gen mã HĐ theo RG-001. Dùng khi export HĐ, upload template mới, debug render lỗi format. when-to-use: - "export contract to word" - "render template docx" - "xuất đơn đặt hàng excel" - "gen mã hợp đồng" - "upload template mới" --- # Form Engine Skill > **Phase 2 deliverable.** Hiện tại skill này là PLACEHOLDER. ## Context Xem đầy đủ ở [`docs/forms-spec.md`](../../../docs/forms-spec.md): - 8 form (6 .docx/.doc + 1 .xlsx + 1 .docx quy định) - Mã HĐ format theo SOL-CCM-RG-001: `{Project}/{Type}/SOL&{Partner}/{Seq}` và biến thể - 3 file `.doc` cần convert qua Word COM / LibreOffice headless trước khi parse ## Tech stack dự kiến - **.docx render:** DocumentFormat.OpenXml (free, verbose) hoặc Aspose.Words (phí, dễ) - **.xlsx render:** EPPlus (free non-commercial) hoặc ClosedXML (free) - **PDF preview:** wkhtmltopdf hoặc LibreOffice `--convert-to pdf` ## Code pointers (sẽ có sau Phase 2) - `src/Backend/SolutionErp.Application/Forms/Services/IFormRenderer.cs` - `src/Backend/SolutionErp.Infrastructure/Forms/DocxRenderer.cs` - `src/Backend/SolutionErp.Infrastructure/Forms/XlsxRenderer.cs` - `src/Backend/SolutionErp.Infrastructure/Services/ContractCodeGenerator.cs`