260222:1053 20260222 refactor specs/ #1 03-Data-and-Storage
All checks were successful
Build and Deploy / deploy (push) Successful in 1m0s
All checks were successful
Build and Deploy / deploy (push) Successful in 1m0s
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# Session History: 2025-12-24 - Document Numbering Fixes
|
||||
|
||||
## Overview
|
||||
- **Date:** 2025-12-24
|
||||
- **Duration:** ~2 hours
|
||||
- **Focus:** Document Numbering System - Bug Fixes & Improvements
|
||||
|
||||
---
|
||||
|
||||
## Changes Made
|
||||
|
||||
### 1. Year Token Format (4-digit)
|
||||
**Files:**
|
||||
- `backend/src/modules/document-numbering/services/format.service.ts`
|
||||
|
||||
**Changes:**
|
||||
```typescript
|
||||
// Before
|
||||
'{YEAR}': year.toString().substring(2), // "25"
|
||||
'{YEAR:BE}': (year + 543).toString().substring(2), // "68"
|
||||
|
||||
// After
|
||||
'{YEAR}': year.toString(), // "2025"
|
||||
'{YEAR:BE}': (year + 543).toString(), // "2568"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 2. TypeScript Field Name Fixes
|
||||
**Files:**
|
||||
- `backend/src/modules/document-numbering/dto/preview-number.dto.ts`
|
||||
- `backend/src/modules/document-numbering/controllers/document-numbering.controller.ts`
|
||||
- `frontend/lib/api/numbering.ts`
|
||||
- `frontend/components/numbering/template-tester.tsx`
|
||||
|
||||
**Changes:**
|
||||
- `originatorId` → `originatorOrganizationId`
|
||||
- `typeId` → `correspondenceTypeId`
|
||||
|
||||
---
|
||||
|
||||
### 3. Generate Test Number Bug Fix
|
||||
**Root Cause:**
|
||||
1. API client ใช้ NextAuth `getSession()` แต่ token อยู่ใน Zustand localStorage (`auth-storage`)
|
||||
2. Response wrapper mismatch: backend ส่ง `{ data: {...} }` แต่ frontend อ่าน `res.data` โดยตรง
|
||||
|
||||
**Files:**
|
||||
- `frontend/lib/api/client.ts` - ดึง token จาก `localStorage['auth-storage']`
|
||||
- `frontend/lib/api/numbering.ts` - แก้ response unwrapping: `res.data.data || res.data`
|
||||
|
||||
---
|
||||
|
||||
### 4. Documentation
|
||||
**Files Created/Updated:**
|
||||
- `docs/document-numbering-summary.md` - Comprehensive system summary
|
||||
|
||||
---
|
||||
|
||||
## Verification Results
|
||||
|
||||
| Test | Result |
|
||||
| -------------------- | --------- |
|
||||
| Backend Build | ✅ Pass |
|
||||
| Frontend Build | ✅ Pass |
|
||||
| Generate Test Number | ✅ Working |
|
||||
|
||||
---
|
||||
|
||||
## Notes
|
||||
- Template ต้องใช้ `{YEAR:BE}` เพื่อแสดงปี พ.ศ. (ไม่ใช่ `{YEAR}`)
|
||||
- สามารถแก้ไข Template ผ่าน Admin > Numbering > Edit Template
|
||||
Reference in New Issue
Block a user