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:
@@ -0,0 +1,69 @@
|
||||
// File: src/modules/distribution/services/transmittal-creator.service.ts
|
||||
// สร้าง Transmittal records จาก Distribution jobs (T057)
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { DistributionMatrix } from '../entities/distribution-matrix.entity';
|
||||
|
||||
/**
|
||||
* TransmittalCreatorService — ใช้ Strangler Pattern ไม่แก้ไข TransmittalService เดิม
|
||||
* สร้าง Transmittal ผ่าน existing TransmittalService หลัง distribution
|
||||
*/
|
||||
@Injectable()
|
||||
export class TransmittalCreatorService {
|
||||
private readonly logger = new Logger(TransmittalCreatorService.name);
|
||||
|
||||
constructor(
|
||||
@InjectRepository(DistributionMatrix)
|
||||
private readonly matrixRepo: Repository<DistributionMatrix>,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* สร้าง Transmittal draft จาก Distribution event (FR-019)
|
||||
* Note: actual Transmittal creation ผ่าน TransmittalModule — inject ที่ DI level
|
||||
*/
|
||||
async createFromDistribution(payload: {
|
||||
rfaPublicId: string;
|
||||
rfaRevisionPublicId: string;
|
||||
projectId: number;
|
||||
documentTypeCode: string;
|
||||
responseCode: string;
|
||||
}): Promise<{ transmittalPublicIds: string[] }> {
|
||||
const matrix = await this.matrixRepo.findOne({
|
||||
where: {
|
||||
projectId: payload.projectId,
|
||||
documentTypeCode: payload.documentTypeCode,
|
||||
isActive: true,
|
||||
},
|
||||
relations: ['recipients'],
|
||||
});
|
||||
|
||||
if (!matrix || !matrix.recipients || matrix.recipients.length === 0) {
|
||||
this.logger.log(
|
||||
`No distribution matrix found for project ${payload.projectId}, docType ${payload.documentTypeCode}`,
|
||||
);
|
||||
return { transmittalPublicIds: [] };
|
||||
}
|
||||
|
||||
// ตรวจสอบ response code filter
|
||||
if (
|
||||
matrix.responseCodeFilter &&
|
||||
matrix.responseCodeFilter.length > 0 &&
|
||||
!matrix.responseCodeFilter.includes(payload.responseCode)
|
||||
) {
|
||||
this.logger.log(
|
||||
`Response code ${payload.responseCode} not in filter — skipping distribution`,
|
||||
);
|
||||
return { transmittalPublicIds: [] };
|
||||
}
|
||||
|
||||
this.logger.log(
|
||||
`Creating Transmittal for RFA ${payload.rfaPublicId} → ${matrix.recipients.length} recipients`,
|
||||
);
|
||||
|
||||
// TODO: เรียก TransmittalService.create() เมื่อ integrate ใน Sprint ถัดไป
|
||||
// return transmittalService.createDraft({ rfaPublicId, recipients });
|
||||
|
||||
return { transmittalPublicIds: [] };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user