3.3 KiB
3.3 KiB
Schema v1.6.0 Migration & Document Number Fixes (2025-12-13)
Task Summary
This session focused on completing the migration to Schema v1.6.0 (Correspondence/RFA shared PK) and resolving critical bugs in the Document Numbering system.
Status
- Schema Migration: Completed (Backend & Frontend)
- Document Numbering:
- Preview Fixed (Recipient Code resolution)
- Creation Fixed (Source data mapping)
- Update Logic Fixed (Auto-regeneration on Draft edit)
Walkthrough & Changes
1. Correspondence Module
- New Entity:
CorrespondenceRecipientto handle multiple recipients (TO/CC). - Entity Update:
Correspondencenow has arecipientsrelation. - Entity Update:
CorrespondenceRevisionrenamedtitletosubject, addedbody,remarks,dueDate,schemaVersion. - Service Update:
createmethod now saves recipients and maps new revision fields. - DTO Update:
CreateCorrespondenceDtoupdated to support proper fields.
2. RFA Module
- Shared Primary Key:
Rfaentity now shares PK withCorrespondence. - Revision Update:
RfaRevisionremovedcorrespondenceId(access viarfa.correspondence.id), renamedtitletosubject, added new fields. - Item Update:
RfaItemFK column renamed torfa_revision_id. - Service Update: Only
RfaServicelogic updated to handle shared PK and new field mappings.findAllquery updated to join viarfa.correspondence.
3. Frontend Adaptation
- Type Definitions: Updated
CorrespondenceRevisionandRFAtypes to match schema v1.6.0. - Form Components:
CorrespondenceForm: Renamedtitletosubject, addedbody,remarks,dueDate.RFAForm: Renamedtitletosubject, addedbody,remarks.
- List & Detail Views: Updated accessor keys (
title->subject) and added display sections for new fields (Body, Remarks) in Detail views. - DTOs: Updated
CreateCorrespondenceDtoandCreateRFADtoto include new fields.
Bug Fixes & Refinements (Session 2)
Document Number Preview
- Issue: Preview showed
--for recipient code. - Fix:
- Implemented
customTokenssupport inDocumentNumberingService. - updated
CorrespondenceService.previewNextNumberto manually resolve recipient code fromOrganizationRepository.
- Implemented
Correspondence Creation
- Issue: Generated document number used incorrect placeholder.
- Fix: Updated
createmethod to extract recipient fromrecipientsarray instead of legacydetailsfield.
Edit Page Loading
- Issue: "Failed to load" error on Edit page.
- Fix: Corrected TypeORM relation path in
CorrespondenceService.findOnefromrecipients.organizationto propertiesrecipients.recipientOrganization.
Document Number Auto-Update
- Feature: Automatically regenerate document number when editing a Draft.
- Implementation: logic added to
updatemethod to re-calculate number iftype,discipline,project, orrecipientchanges.
Verification Results
- Backend Tests:
correspondence.service.spec.tspassed. - Frontend Tests: All 9 suites (113 tests) passed.
- Manual Verification: Verified Preview, Creation, and Edit flows.
Future Tasks
- Data Cleanup: Migration script to fix existing document numbers with missing recipient codes (e.g.,
คคง.--0001-2568->คคง.-XYZ-0001-2568).