finishing QDRO section

This commit is contained in:
HotSwapp
2025-08-15 17:19:51 -05:00
parent 006ef3d7b1
commit abc7f289d1
22 changed files with 2753 additions and 46 deletions

View File

@@ -12,37 +12,37 @@ Based on the comprehensive analysis of the legacy Paradox system, this document
**Legacy Feature**: Sophisticated legal document generation with WordPerfect integration
**Current Status**: ❌ Not implemented
**Current Status**: ✅ **COMPLETED**
**Required Components**:
#### 1.1 Document Template Management
- [ ] Create `DocumentTemplate` model
- [x] Create `DocumentTemplate` model
- Template name, description, file path
- Category/area of law classification
- Status (active/inactive)
- Version tracking
- [ ] Template upload and storage system
- [ ] Template preview capabilities
- [ ] Template search and filtering
- [x] Template upload and storage system
- [x] Template preview capabilities
- [x] Template search and filtering
#### 1.2 Template Keyword/Index System
- [ ] Create `TemplateKeyword` model for searchable tags
- [ ] Keyword management interface
- [ ] Advanced template search by keywords
- [ ] Template categorization system
- [x] Create `TemplateKeyword` model for searchable tags
- [x] Keyword management interface
- [x] Advanced template search by keywords
- [x] Template categorization system
#### 1.3 Data Merge Engine
- [ ] Variable extraction from current data context
- [ ] Merge field mapping system
- [ ] Template variable substitution engine
- [ ] Support for multiple output formats (PDF, DOCX)
- [x] Variable extraction from current data context
- [x] Merge field mapping system
- [x] Template variable substitution engine
- [x] Support for multiple output formats (PDF, DOCX)
#### 1.4 Form Selection Interface
- [ ] Multi-template selection UI
- [ ] Template preview and description display
- [ ] Batch document generation
- [ ] Generated document management
- [x] Multi-template selection UI
- [x] Template preview and description display
- [ ] Batch document generation (planned for future iteration)
- [ ] Generated document management (planned for future iteration)
**API Endpoints Needed**:
```
@@ -53,6 +53,73 @@ GET /api/templates/{id}/preview
POST /api/documents/generate-batch
```
#### 1.5 Storage and Upload (DOCX/PDF)
- [x] Accept `.docx` (mergeable) and `.pdf` (static/stampable) uploads
- [x] Store originals in object storage (S3/MinIO) with server-side encryption
- [x] Persist metadata: filename, MIME type, byte size, checksum (SHA-256), uploader, created_at
- [ ] Virus scan and file-type sniffing (MIME > extension) (security enhancement for future)
- [x] Max size and extension allowlist validation
- [x] Optional tenant-aware storage prefixing (by environment/firm)
#### 1.6 Template Versioning
- [x] Create `DocumentTemplate` and `DocumentTemplateVersion` models
- `DocumentTemplate`: name, description, category, active, current_version_id
- `DocumentTemplateVersion`: template_id, semantic version, storage_path, mime_type, checksum, changelog, created_by, created_at, is_approved
- [x] Upload new versions without breaking existing merges
- [x] Ability to pin a version for a batch/job
- [x] Approval workflow for promoting a draft version to current
#### 1.7 Merge Engine (uses `FormVariable`/`ReportVariable`)
- [x] Variable syntax: `{{ variable_identifier }}` inside `.docx` templates
- [x] Resolution order (short-circuit on first hit):
1) Explicit context passed by API (e.g., file_no, customer, logged_in_user)
2) `FormVariable` by identifier → resolve via a safe, predefined repository function mapped from `query`
3) `ReportVariable` by identifier → same safe resolution
4) Built-ins/utilities (dates, formatting helpers)
- [x] Missing variable strategies: leave token, empty string, or raise warning (configurable)
- [x] Rendering engine: restricted Jinja2-like context with `docxtpl` for `.docx`
- [ ] Output formats: `.docx` (native) and `.pdf` (convert via headless LibreOffice) (PDF conversion for future iteration)
- [x] Robust error reporting: unresolved variables list, stack traces (server logs), user-friendly message
- [x] Auditing: record variables resolved and their sources (context vs `FormVariable`/`ReportVariable`)
#### 1.8 Batch Generation
- [ ] Async queue jobs for batch merges (Celery/RQ) with progress tracking (future iteration)
- [ ] Idempotency keys to avoid duplicate batches (future iteration)
- [ ] Per-item success/failure reporting; partial retry support (future iteration)
- [ ] Output bundling: store each generated document; optional ZIP download of the set (future iteration)
- [ ] Throttling and concurrency limits (future iteration)
- [ ] Audit trail: who initiated, when, template/version used, filters applied (future iteration)
#### 1.9 UI for Templates, Keywords, Previews
- [x] Templates list/detail with version history and diff of changelog
- [x] Upload new version UI with changelog and approval checkbox
- [x] Keyword/tag management (create/read/update/delete) and filter by tags/category
- [x] Variable inspector: show `{{ }}` tokens discovered in the template and their resolution source
- [x] Preview with sample data (single-record merge); show unresolved variables warning
- [ ] Batch generation wizard: choose template/version, select scope (files/customers), review count and estimated time, run asynchronously (future iteration)
#### 1.10 Additional API Endpoints
```
✅ GET /api/templates/{id}
✅ PUT /api/templates/{id}
✅ POST /api/templates/{id}/versions # upload new version
✅ GET /api/templates/{id}/versions # list versions
✅ PUT /api/templates/{id}/versions/{vid} # approve/pin version
✅ GET /api/templates/{id}/variables # introspect template tokens
✅ POST /api/templates/{id}/preview # preview merge with sample/context
⏳ POST /api/documents/jobs # start batch job (future iteration)
⏳ GET /api/documents/jobs/{job_id} # job status/progress (future iteration)
⏳ GET /api/documents/jobs/{job_id}/result # download bundle (ZIP) (future iteration)
✅ POST /api/templates/{id}/keywords # add/remove keywords
```
#### 1.11 Acceptance Criteria
- [x] Upload `.docx` template, add keywords, create v1.0.0, preview succeeds with sample data
- [x] Merge uses `FormVariable`/`ReportVariable` when identifiers match tokens
- [ ] Generate a batch of N files into PDFs; job completes with progress and downloadable ZIP (future iteration)
- [x] Version pinning respected; publishing new version does not alter prior batch outcomes
- [x] All actions logged with user and timestamp; unresolved variables surfaced in UI
### 🔴 2. QDRO (Pension Division) Module
**Legacy Feature**: Specialized module for Qualified Domestic Relations Orders