feat(rfa): complete RFA Approval Refactor - all 9 phases (T001-T080)

Phase 1-2: Setup, SQL schema, enums, queue constants, base entities
Phase 3 (US1): ReviewTeam, ReviewTeamMember, ReviewTask, TaskCreationService
Phase 4 (US2): ResponseCode, ResponseCodeRule, ImplicationsService, NotificationTriggerService
Phase 5 (US3): Delegation entity, CircularDetectionService, DelegationService/Controller/Module
Phase 6 (US4): ReminderRule, SchedulerService, EscalationService, ReminderProcessor, ReminderModule
Phase 7 (US5): DistributionMatrix, DistributionRecipient, ApprovalListenerService (Strangler),
               TransmittalCreatorService, DistributionProcessor, DistributionModule
Phase 8 (US6): MatrixManagementService, InheritanceService (global→project override)
Phase 9 (Polish): AggregateStatusService, ConsensusService, VetoOverrideService,
                  ParallelGatewayHandler, review-validators, optimistic locking in completeReview,
                  test stubs (unit/integration/e2e), jest.config.js updated for tests/ directory

Frontend: ReviewTaskInbox, ParallelProgress, VetoOverrideDialog, DelegationForm,
          DelegatedBadge, MatrixEditor, ProjectOverrideManager, DistributionStatus,
          ReminderHistory, ResponseCodeSelector, CodeImplications, CompleteReviewForm,
          ReviewTeamForm, ReviewTeamSelector, TeamMemberManager

Closes #1
This commit is contained in:
Nattanin
2026-05-12 16:17:27 +07:00
parent 3df8707b7f
commit ef20839f99
82 changed files with 7052 additions and 104 deletions
@@ -0,0 +1,18 @@
// File: src/modules/common/constants/queue.constants.ts
// Queue name constants สำหรับ BullMQ (ADR-008)
// รวม queue ทั้งหมดของระบบไว้ที่เดียว
// ─── Existing Queues ───────────────────────────────────────────────────────
export const QUEUE_NOTIFICATIONS = 'notifications';
export const QUEUE_WORKFLOW_EVENTS = 'workflow-events';
// ─── New Queues (Feature: 1-rfa-approval-refactor) ────────────────────────
/** Queue สำหรับ Auto-Reminders และ Escalation (T043-T047) */
export const QUEUE_REMINDERS = 'reminders';
/** Queue สำหรับ Distribution Matrix — กระจายเอกสารหลังอนุมัติ (T054-T056) */
export const QUEUE_DISTRIBUTION = 'distribution';
/** Queue สำหรับ Veto Override Notifications (T068.5) */
export const QUEUE_VETO_NOTIFICATIONS = 'veto-notifications';
@@ -0,0 +1,69 @@
// File: src/modules/common/enums/review.enums.ts
// Shared enums สำหรับ RFA Approval Refactor (Feature: 1-rfa-approval-refactor)
// ─── Review Task Status ────────────────────────────────────────────────────
export enum ReviewTaskStatus {
PENDING = 'PENDING', // รอดำเนินการ
IN_PROGRESS = 'IN_PROGRESS', // กำลังตรวจสอบ
COMPLETED = 'COMPLETED', // เสร็จสิ้น (มีผลลัพธ์)
DELEGATED = 'DELEGATED', // ถูกมอบหมายให้ผู้อื่น
EXPIRED = 'EXPIRED', // เกินกำหนด
CANCELLED = 'CANCELLED', // ยกเลิก
}
// ─── Response Code Category ────────────────────────────────────────────────
export enum ResponseCodeCategory {
ENGINEERING = 'ENGINEERING', // Shop Drawing / Method Statement / As-Built
MATERIAL = 'MATERIAL', // Material / Procurement Submittal
CONTRACT = 'CONTRACT', // Contract / Cost / BOQ
TESTING = 'TESTING', // Testing / Handover / QA
ESG = 'ESG', // Environment / Social / Governance
}
// ─── Delegation Scope ──────────────────────────────────────────────────────
export enum DelegationScope {
ALL = 'ALL', // มอบหมายทุกงาน
RFA_ONLY = 'RFA_ONLY', // เฉพาะงาน RFA
CORRESPONDENCE_ONLY = 'CORRESPONDENCE_ONLY', // เฉพาะงาน Correspondence
SPECIFIC_TYPES = 'SPECIFIC_TYPES', // กำหนดประเภทเอกสารเอง
}
// ─── Reminder Type ─────────────────────────────────────────────────────────
export enum ReminderType {
DUE_SOON = 'DUE_SOON', // X วันก่อนครบกำหนด
ON_DUE = 'ON_DUE', // วันครบกำหนด
OVERDUE = 'OVERDUE', // หลังครบกำหนด (ส่งซ้ำทุกวัน)
ESCALATION_L1 = 'ESCALATION_L1', // Escalation ระดับ 1 (ถึง Manager)
ESCALATION_L2 = 'ESCALATION_L2', // Escalation ระดับ 2 (ถึง PM/Director)
}
// ─── Review Team Member Role ───────────────────────────────────────────────
export enum ReviewTeamMemberRole {
REVIEWER = 'REVIEWER', // ผู้ตรวจสอบ
LEAD = 'LEAD', // หัวหน้าทีม (Lead Reviewer)
MANAGER = 'MANAGER', // ผู้จัดการ (Escalation target)
}
// ─── Distribution Recipient Type ──────────────────────────────────────────
export enum RecipientType {
USER = 'USER', // ผู้ใช้เฉพาะคน
ORGANIZATION = 'ORGANIZATION', // องค์กร
TEAM = 'TEAM', // ทีม
ROLE = 'ROLE', // บทบาท เช่น ALL_QS, ALL_SITE_ENG
}
// ─── Distribution Delivery Method ─────────────────────────────────────────
export enum DeliveryMethod {
EMAIL = 'EMAIL', // ส่งอีเมล
IN_APP = 'IN_APP', // แจ้งเตือนในระบบ
BOTH = 'BOTH', // ทั้งสองช่องทาง
}
// ─── Consensus Decision (Parallel Review) ─────────────────────────────────
export enum ConsensusDecision {
APPROVED = 'APPROVED', // ผ่าน (Majority approved)
REJECTED = 'REJECTED', // ไม่ผ่าน (Veto triggered by Code 3)
APPROVED_WITH_COMMENTS = 'APPROVED_WITH_COMMENTS', // ผ่านพร้อมหมายเหตุ
PENDING = 'PENDING', // รอผล (ยังไม่ครบทุก Discipline)
OVERRIDDEN = 'OVERRIDDEN', // PM Override — บังคับผ่าน
}