251209:1453 Frontend: progress nest = UAT & Bug Fixing
Some checks failed
Spec Validation / validate-markdown (push) Has been cancelled
Spec Validation / validate-diagrams (push) Has been cancelled
Spec Validation / check-todos (push) Has been cancelled

This commit is contained in:
admin
2025-12-09 14:53:42 +07:00
parent 8aceced902
commit aa96cd90e3
125 changed files with 11052 additions and 785 deletions

View File

@@ -1008,10 +1008,9 @@ CREATE TABLE document_number_counters (
-- Foreign Keys
FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE,
FOREIGN KEY (originator_organization_id) REFERENCES organizations (id) ON DELETE CASCADE,
FOREIGN KEY (recipient_organization_id) REFERENCES organizations (id) ON DELETE CASCADE,
-- NOTE: recipient_organization_id uses -1 as sentinel for "all organizations"
-- Therefore NO FK constraint is applied here (would fail for -1)
FOREIGN KEY (correspondence_type_id) REFERENCES correspondence_types (id) ON DELETE CASCADE,
-- ใช้ CHECK constraint เพื่อไม่ให้ตรวจสอบเมื่อเป็น -1
CONSTRAINT fk_recipient_when_not_all FOREIGN KEY (recipient_organization_id) REFERENCES organizations (id) ON DELETE CASCADE,
-- [v1.5.1 NEW] Performance Indexes
INDEX idx_counter_lookup (
project_id,

View File

@@ -1278,7 +1278,9 @@ VALUES -- Document
(4, 142),
-- Dashboard & Notification
(4, 153),
(4, 151);
(4, 151),
-- Workflow Actions (NEW for E2E test compatibility)
(4, 123);
-- ==========================================================
-- Role 5: Viewer (Organization Scope)
@@ -1367,9 +1369,13 @@ INSERT INTO user_assignments (
)
VALUES (1, 1, 1, NULL, NULL, NULL, NULL),
-- superadmin: Global scope (organization_id = NULL)
(2, 2, 2, 1, NULL, NULL, NULL);
(2, 2, 2, 1, NULL, NULL, NULL),
-- admin: Organization scope (org_id=1 = กทท.)
(3, 3, 4, 41, NULL, NULL, 1),
-- editor01: Editor role (role_id=4) at organization 41 (คคง.), assigned by superadmin
(4, 4, 5, 10, NULL, NULL, 1);
-- admin: Organization scope
-- viewer01: Viewer role (role_id=5) at organization 10 (สคฉ.03), assigned by superadmin
-- =====================================================
-- == 4. การเชื่อมโยงโครงการกับองค์กร (project_organizations) ==
-- =====================================================
@@ -2980,3 +2986,240 @@ VALUES (
NULL,
NULL
);
-- ==========================================================
-- 20. Workflow Definitions (Unified Workflow Engine)
-- ==========================================================
INSERT INTO `workflow_definitions` (
`id`,
`workflow_code`,
`version`,
`description`,
`dsl`,
`compiled`,
`is_active`,
`created_at`,
`updated_at`
)
VALUES (
-- CORRESPONDENCE_FLOW_V1
UUID(),
'CORRESPONDENCE_FLOW_V1',
1,
'Standard Correspondence Workflow - Draft → Submit → Review → Approve/Reject',
JSON_OBJECT(
'workflow',
'CORRESPONDENCE_FLOW_V1',
'version',
1,
'states',
JSON_ARRAY(
JSON_OBJECT(
'name',
'DRAFT',
'initial',
TRUE,
'on',
JSON_OBJECT(
'SUBMIT',
JSON_OBJECT('to', 'IN_REVIEW')
)
),
JSON_OBJECT(
'name',
'IN_REVIEW',
'on',
JSON_OBJECT(
'APPROVE',
JSON_OBJECT('to', 'APPROVED'),
'REJECT',
JSON_OBJECT('to', 'REJECTED'),
'RETURN',
JSON_OBJECT('to', 'DRAFT')
)
),
JSON_OBJECT('name', 'APPROVED', 'terminal', TRUE),
JSON_OBJECT('name', 'REJECTED', 'terminal', TRUE)
)
),
JSON_OBJECT(
'initialState',
'DRAFT',
'states',
JSON_OBJECT(
'DRAFT',
JSON_OBJECT(
'initial',
TRUE,
'terminal',
false,
'transitions',
JSON_OBJECT(
'SUBMIT',
JSON_OBJECT('to', 'IN_REVIEW', 'events', JSON_ARRAY())
)
),
'IN_REVIEW',
JSON_OBJECT(
'initial',
false,
'terminal',
false,
'transitions',
JSON_OBJECT(
'APPROVE',
JSON_OBJECT('to', 'APPROVED', 'events', JSON_ARRAY()),
'REJECT',
JSON_OBJECT('to', 'REJECTED', 'events', JSON_ARRAY()),
'RETURN',
JSON_OBJECT('to', 'DRAFT', 'events', JSON_ARRAY())
)
),
'APPROVED',
JSON_OBJECT(
'initial',
false,
'terminal',
TRUE,
'transitions',
JSON_OBJECT()
),
'REJECTED',
JSON_OBJECT(
'initial',
false,
'terminal',
TRUE,
'transitions',
JSON_OBJECT()
)
)
),
TRUE,
NOW(),
NOW()
),
(
-- RFA_APPROVAL
UUID(),
'RFA_APPROVAL',
1,
'Request for Approval Workflow - Contractor Submit → Consultant Review → Owner Review',
JSON_OBJECT(
'workflow',
'RFA_APPROVAL',
'version',
1,
'states',
JSON_ARRAY(
JSON_OBJECT(
'name',
'DRAFT',
'initial',
TRUE,
'on',
JSON_OBJECT(
'SUBMIT',
JSON_OBJECT(
'to',
'CONSULTANT_REVIEW',
'require',
JSON_OBJECT('role', 'CONTRACTOR')
)
)
),
JSON_OBJECT(
'name',
'CONSULTANT_REVIEW',
'on',
JSON_OBJECT(
'APPROVE',
JSON_OBJECT('to', 'OWNER_REVIEW'),
'REJECT',
JSON_OBJECT('to', 'DRAFT')
)
),
JSON_OBJECT(
'name',
'OWNER_REVIEW',
'on',
JSON_OBJECT(
'APPROVE',
JSON_OBJECT('to', 'APPROVED'),
'REJECT',
JSON_OBJECT('to', 'CONSULTANT_REVIEW')
)
),
JSON_OBJECT('name', 'APPROVED', 'terminal', TRUE)
)
),
JSON_OBJECT(
'initialState',
'DRAFT',
'states',
JSON_OBJECT(
'DRAFT',
JSON_OBJECT(
'initial',
TRUE,
'terminal',
false,
'transitions',
JSON_OBJECT(
'SUBMIT',
JSON_OBJECT(
'target',
'CONSULTANT_REVIEW',
'events',
JSON_ARRAY()
)
)
),
'CONSULTANT_REVIEW',
JSON_OBJECT(
'initial',
false,
'terminal',
false,
'transitions',
JSON_OBJECT(
'APPROVE',
JSON_OBJECT('target', 'OWNER_REVIEW', 'events', JSON_ARRAY()),
'REJECT',
JSON_OBJECT('target', 'DRAFT', 'events', JSON_ARRAY())
)
),
'OWNER_REVIEW',
JSON_OBJECT(
'initial',
false,
'terminal',
false,
'transitions',
JSON_OBJECT(
'APPROVE',
JSON_OBJECT('target', 'APPROVED', 'events', JSON_ARRAY()),
'REJECT',
JSON_OBJECT(
'target',
'CONSULTANT_REVIEW',
'events',
JSON_ARRAY()
)
)
),
'APPROVED',
JSON_OBJECT(
'initial',
false,
'terminal',
TRUE,
'transitions',
JSON_OBJECT()
)
)
),
TRUE,
NOW(),
NOW()
);

View File

@@ -0,0 +1,7 @@
-- Patch: Add workflow.action_review permission to Editor role
-- Required for E2E tests where editor01 needs to perform workflow actions
INSERT IGNORE INTO role_permissions (role_id, permission_id)
VALUES (4, 123);
-- permission_id 123 = workflow.action_review
-- role_id 4 = Editor

View File

@@ -0,0 +1,10 @@
-- Patch: Drop FK constraint for recipient_organization_id
-- Required because -1 is used as sentinel value for "all organizations"
-- Run this on lcbp3_dev database
-- Find and drop the FK constraint(s)
-- The constraint names may vary, check with:
-- SHOW CREATE TABLE document_number_counters;
-- Drop both FK constraints
ALTER TABLE document_number_counters DROP FOREIGN KEY document_number_counters_ibfk_3;
ALTER TABLE document_number_counters DROP FOREIGN KEY fk_recipient_when_not_all;

View File

@@ -0,0 +1,82 @@
-- Patch: Fix CORRESPONDENCE_FLOW_V1 compiled data
-- The compiled JSON used 'target' but code expects 'to'
-- Run this to update existing workflow_definitions
UPDATE workflow_definitions
SET compiled = JSON_OBJECT(
'workflow',
'CORRESPONDENCE_FLOW_V1',
'version',
1,
'initialState',
'DRAFT',
'states',
JSON_OBJECT(
'DRAFT',
JSON_OBJECT(
'terminal',
false,
'transitions',
JSON_OBJECT(
'SUBMIT',
JSON_OBJECT(
'to',
'IN_REVIEW',
'requirements',
JSON_OBJECT('roles', JSON_ARRAY()),
'events',
JSON_ARRAY()
)
)
),
'IN_REVIEW',
JSON_OBJECT(
'terminal',
false,
'transitions',
JSON_OBJECT(
'APPROVE',
JSON_OBJECT(
'to',
'APPROVED',
'requirements',
JSON_OBJECT('roles', JSON_ARRAY()),
'events',
JSON_ARRAY()
),
'REJECT',
JSON_OBJECT(
'to',
'REJECTED',
'requirements',
JSON_OBJECT('roles', JSON_ARRAY()),
'events',
JSON_ARRAY()
),
'RETURN',
JSON_OBJECT(
'to',
'DRAFT',
'requirements',
JSON_OBJECT('roles', JSON_ARRAY()),
'events',
JSON_ARRAY()
)
)
),
'APPROVED',
JSON_OBJECT(
'terminal',
TRUE,
'transitions',
JSON_OBJECT()
),
'REJECTED',
JSON_OBJECT(
'terminal',
TRUE,
'transitions',
JSON_OBJECT()
)
)
)
WHERE workflow_code = 'CORRESPONDENCE_FLOW_V1';