task-d.7.4

This commit is contained in:
phaichayon
2026-07-02 14:27:51 +07:00
parent 0ae4ae3e38
commit 0c3d488d7d
27 changed files with 1024 additions and 0 deletions

91
setup/templates/README.md Normal file
View File

@@ -0,0 +1,91 @@
# ALLA OS Setup CSV Templates
This folder contains the supported static CSV template pack for Task D.7.3.
Rules:
- UTF-8 text.
- Comma delimiter.
- LF line endings.
- One header row and one safe sample row per CSV.
- No unsupported template files are generated.
- No production data, formulas, secrets, or binary references are included.
## Sample Dataset
All templates use one consistent sample dataset:
- Organization: `ALLA`
- Branch: `head_office`
- Product type: `crane`
- Currency: `THB`
- Administrator: `admin@example.com`
- Marketing: `mk.uat@example.com`
- Sales: `sales.uat@example.com`
- Manager: `manager.uat@example.com`
- CEO: `ceo.uat@example.com`
- Customer: `CUS-001`
- Lead: `LD-001`
- Opportunity: `OP-001`
- Quotation: `QT-HO-CR-2607-001`
## Import Order
| Order | File | Purpose |
| --- | --- | --- |
| 01 | `users.csv` | Setup-managed users |
| 02 | `organizations.csv` | Tenant organizations |
| 03 | `memberships.csv` | Organization memberships |
| 05 | `crm-role-assignments.csv` | CRM role assignments |
| 06 | `master-options.csv` | Generic master options |
| 07 | `branches.csv` | Branch options |
| 08 | `product-types.csv` | Product type options |
| 14 | `document-sequences.csv` | Document numbering |
| 15 | `approval-workflows.csv` | Approval workflows |
| 16 | `approval-steps.csv` | Approval workflow steps |
| 17 | `approval-matrix.csv` | Approval routing matrix |
| 30 | `customers.csv` | CRM customers |
| 32 | `contacts.csv` | Customer contacts |
| 33 | `contact-shares.csv` | Contact sharing grants |
| 34 | `leads.csv` | Marketing leads |
| 36 | `opportunities.csv` | Sales opportunities |
| 37 | `opportunity-parties.csv` | Opportunity project parties |
| 40 | `quotations.csv` | Quotation headers |
| 41 | `quotation-items.csv` | Quotation line items |
| 42 | `quotation-parties.csv` | Quotation project parties |
| 43 | `quotation-topics.csv` | Quotation topic headers |
| 44 | `quotation-topic-items.csv` | Quotation topic rows |
## Relationship Rules
- `organization_code` links rows to the organization import context.
- `user_email`, `created_by_email`, `updated_by_email`, and role-related email fields resolve to `users.email`.
- `branch_code` resolves to `ms_options` category `crm_branch`.
- `product_type_code` resolves to `ms_options` category `crm_product_type`.
- `customer_code`, `lead_code`, `opportunity_code`, and `quotation_code` are business keys within the organization.
- `topic_key` is an import-only alias linking `quotation-topics.csv` to `quotation-topic-items.csv`.
- Pipe-delimited fields, such as permission or scope lists, use `|`.
## Placeholders
These templates intentionally leave sensitive or runtime values empty:
- `users.csv` has an empty `password` sample value.
- Runtime approval and PDF artifact fields are not present.
- Binary attachment paths are not present.
## Unsupported Templates
The following files are documented but not generated because the current schema does not support them as safe first-class setup imports:
- `departments.csv`
- `teams.csv`
- `warehouses.csv`
- `sites.csv`
- `services.csv`
- `price-books.csv`
- `tax-rates.csv`
- `attachments.csv`
- `email-settings.csv`
See `docs/setup/csv-template-spec.md` and `docs/setup/import-mapping.md` for the full contract.

View File

@@ -0,0 +1,2 @@
organization_code,entity_type,workflow_code,branch_code,product_type_code,min_amount,max_amount,currency,priority,is_default,is_active,description
ALLA,quotation,quotation_standard,head_office,crane,0,5000000,THB,100,true,true,Default crane approval
1 organization_code entity_type workflow_code branch_code product_type_code min_amount max_amount currency priority is_default is_active description
2 ALLA quotation quotation_standard head_office crane 0 5000000 THB 100 true true Default crane approval

View File

@@ -0,0 +1,2 @@
organization_code,workflow_code,step_number,role_code,role_name,approval_mode,is_required,sla_hours,calendar_mode,timeout_action
ALLA,quotation_standard,1,sales_manager,Sales Manager,sequential,true,24,calendar_days,none
1 organization_code workflow_code step_number role_code role_name approval_mode is_required sla_hours calendar_mode timeout_action
2 ALLA quotation_standard 1 sales_manager Sales Manager sequential true 24 calendar_days none

View File

@@ -0,0 +1,2 @@
organization_code,workflow_code,workflow_name,entity_type,description,is_system,is_active
ALLA,quotation_standard,Quotation Standard Approval,quotation,Default quotation approval,false,true
1 organization_code workflow_code workflow_name entity_type description is_system is_active
2 ALLA quotation_standard Quotation Standard Approval quotation Default quotation approval false true

View File

@@ -0,0 +1,2 @@
organization_code,branch_code,branch_name,prefix,address,tax_id,phone,email,sort_order,is_active
ALLA,head_office,Head Office,HO,99/9 Rama IX Road Bangkok,0107558000393,02-000-0000,head.office@example.com,1,true
1 organization_code branch_code branch_name prefix address tax_id phone email sort_order is_active
2 ALLA head_office Head Office HO 99/9 Rama IX Road Bangkok 0107558000393 02-000-0000 head.office@example.com 1 true

View File

@@ -0,0 +1,2 @@
organization_code,customer_code,contact_email,shared_to_user_email,shared_by_user_email,remark,is_active
ALLA,CUS-001,anan@siam.example,sales.uat@example.com,admin@example.com,Shared for setup sample,true
1 organization_code customer_code contact_email shared_to_user_email shared_by_user_email remark is_active
2 ALLA CUS-001 anan@siam.example sales.uat@example.com admin@example.com Shared for setup sample true

View File

@@ -0,0 +1,2 @@
organization_code,customer_code,contact_name,created_by_email,position,department,phone,mobile,email,is_primary,notes,is_active
ALLA,CUS-001,Anan Sales,admin@example.com,Procurement Manager,Procurement,02-000-1001,081-000-0001,anan@siam.example,true,Primary procurement contact,true
1 organization_code customer_code contact_name created_by_email position department phone mobile email is_primary notes is_active
2 ALLA CUS-001 Anan Sales admin@example.com Procurement Manager Procurement 02-000-1001 081-000-0001 anan@siam.example true Primary procurement contact true

View File

@@ -0,0 +1,2 @@
organization_code,user_email,crm_role_code,is_primary,branch_scope_mode,branch_codes,product_type_scope_mode,product_type_codes,is_active
ALLA,admin@example.com,crm_admin,true,all,,all,,true
1 organization_code user_email crm_role_code is_primary branch_scope_mode branch_codes product_type_scope_mode product_type_codes is_active
2 ALLA admin@example.com crm_admin true all all true

View File

@@ -0,0 +1,2 @@
organization_code,customer_code,customer_name,customer_type,customer_status,created_by_email,branch_code,abbr,tax_id,address,province,district,sub_district,postal_code,country,phone,fax,email,website,lead_channel,customer_group,customer_sub_group,owner_user_email,notes,is_active
ALLA,CUS-001,Siam Manufacturing,company,active,admin@example.com,head_office,SIAM,0105555000001,100 Industrial Road,Bangkok,Bang Na,Bang Na,10260,Thailand,02-000-1000,,contact@siam.example,https://siam.example,website,industrial,factory,sales.uat@example.com,Initial setup sample customer,true
1 organization_code customer_code customer_name customer_type customer_status created_by_email branch_code abbr tax_id address province district sub_district postal_code country phone fax email website lead_channel customer_group customer_sub_group owner_user_email notes is_active
2 ALLA CUS-001 Siam Manufacturing company active admin@example.com head_office SIAM 0105555000001 100 Industrial Road Bangkok Bang Na Bang Na 10260 Thailand 02-000-1000 contact@siam.example https://siam.example website industrial factory sales.uat@example.com Initial setup sample customer true

View File

@@ -0,0 +1,2 @@
organization_code,branch_code,product_type_code,document_type,prefix,period,current_number,padding_length,format,reset_policy,is_active
ALLA,head_office,crane,quotation,QT-HO-CR-,2607,0,3,{prefix}{period}-{running},period,true
1 organization_code branch_code product_type_code document_type prefix period current_number padding_length format reset_policy is_active
2 ALLA head_office crane quotation QT-HO-CR- 2607 0 3 {prefix}{period}-{running} period true

View File

@@ -0,0 +1,2 @@
organization_code,lead_code,status,created_by_email,branch_code,customer_code,contact_email,description,project_name,project_location,lead_channel,product_type_code,priority,estimated_value,awareness_code,followup_status,lost_reason,outcome,owner_marketing_user_email,assigned_sales_owner_email,assignment_remark
ALLA,LD-001,assigned,mk.uat@example.com,head_office,CUS-001,anan@siam.example,Customer requested crane consultation,Warehouse Crane,Bangkok Warehouse,website,crane,high,1000000,google_search_website,quotation_preparation,,open,mk.uat@example.com,sales.uat@example.com,Assigned from setup sample
1 organization_code lead_code status created_by_email branch_code customer_code contact_email description project_name project_location lead_channel product_type_code priority estimated_value awareness_code followup_status lost_reason outcome owner_marketing_user_email assigned_sales_owner_email assignment_remark
2 ALLA LD-001 assigned mk.uat@example.com head_office CUS-001 anan@siam.example Customer requested crane consultation Warehouse Crane Bangkok Warehouse website crane high 1000000 google_search_website quotation_preparation open mk.uat@example.com sales.uat@example.com Assigned from setup sample

View File

@@ -0,0 +1,2 @@
organization_code,category,code,label,value,parent_category,parent_code,sort_order,is_active,metadata_json
ALLA,crm_customer_group,industrial,Industrial,industrial,,,1,true,{}
1 organization_code category code label value parent_category parent_code sort_order is_active metadata_json
2 ALLA crm_customer_group industrial Industrial industrial 1 true {}

View File

@@ -0,0 +1,2 @@
organization_code,user_email,membership_role,business_role,permissions,branch_scope_codes,product_type_scope_codes
ALLA,admin@example.com,admin,crm_admin,crm.dashboard.read|crm.role.read|crm.user_role_assignment.read,head_office,crane
1 organization_code user_email membership_role business_role permissions branch_scope_codes product_type_scope_codes
2 ALLA admin@example.com admin crm_admin crm.dashboard.read|crm.role.read|crm.user_role_assignment.read head_office crane

View File

@@ -0,0 +1,2 @@
organization_code,opportunity_code,customer_code,title,product_type_code,status,priority,created_by_email,updated_by_email,lead_code,contact_email,branch_code,description,requirement,project_name,project_location,outcome_status,lead_channel,estimated_value,chance_percent,expected_close_date,competitor,source,notes,is_hot_project,pipeline_stage,assigned_to_user_email
ALLA,OP-001,CUS-001,Warehouse Crane Expansion,crane,negotiation,high,sales.uat@example.com,sales.uat@example.com,LD-001,anan@siam.example,head_office,Crane expansion opportunity,Overhead crane with installation,Warehouse Crane,Bangkok Warehouse,open,website,1000000,70,2026-08-31,,setup,Initial setup sample opportunity,false,opportunity,sales.uat@example.com
1 organization_code opportunity_code customer_code title product_type_code status priority created_by_email updated_by_email lead_code contact_email branch_code description requirement project_name project_location outcome_status lead_channel estimated_value chance_percent expected_close_date competitor source notes is_hot_project pipeline_stage assigned_to_user_email
2 ALLA OP-001 CUS-001 Warehouse Crane Expansion crane negotiation high sales.uat@example.com sales.uat@example.com LD-001 anan@siam.example head_office Crane expansion opportunity Overhead crane with installation Warehouse Crane Bangkok Warehouse open website 1000000 70 2026-08-31 setup Initial setup sample opportunity false opportunity sales.uat@example.com

View File

@@ -0,0 +1,2 @@
organization_code,opportunity_code,customer_code,role_code,remark
ALLA,OP-001,CUS-001,end_customer,Primary project owner
1 organization_code opportunity_code customer_code role_code remark
2 ALLA OP-001 CUS-001 end_customer Primary project owner

View File

@@ -0,0 +1,2 @@
organization_code,organization_name,slug,created_by_email,tax_id,default_currency,phone,email,address,logo_url,plan,status
ALLA,ALLA Public Company Limited,alla,admin@example.com,0107558000393,THB,02-000-0000,info@example.com,99/9 Rama IX Road Bangkok,,enterprise,active
1 organization_code organization_name slug created_by_email tax_id default_currency phone email address logo_url plan status
2 ALLA ALLA Public Company Limited alla admin@example.com 0107558000393 THB 02-000-0000 info@example.com 99/9 Rama IX Road Bangkok enterprise active

View File

@@ -0,0 +1,2 @@
organization_code,product_type_code,product_type_name,document_prefix,sort_order,is_active,metadata_json
ALLA,crane,Crane,CR,1,true,{}
1 organization_code product_type_code product_type_name document_prefix sort_order is_active metadata_json
2 ALLA crane Crane CR 1 true {}

View File

@@ -0,0 +1,2 @@
organization_code,quotation_code,item_number,product_type_code,description,quantity,unit_price,total_price,unit,discount,discount_type,tax_rate,notes,sort_order
ALLA,QT-HO-CR-2607-001,1,crane,Crane installation package,1,1000000,1000000,set,0,,7,Setup sample quotation item,1
1 organization_code quotation_code item_number product_type_code description quantity unit_price total_price unit discount discount_type tax_rate notes sort_order
2 ALLA QT-HO-CR-2607-001 1 crane Crane installation package 1 1000000 1000000 set 0 7 Setup sample quotation item 1

View File

@@ -0,0 +1,2 @@
organization_code,quotation_code,customer_code,role_code,is_primary,remark
ALLA,QT-HO-CR-2607-001,CUS-001,end_customer,true,Primary quotation customer
1 organization_code quotation_code customer_code role_code is_primary remark
2 ALLA QT-HO-CR-2607-001 CUS-001 end_customer true Primary quotation customer

View File

@@ -0,0 +1,2 @@
organization_code,quotation_code,topic_key,content,sort_order
ALLA,QT-HO-CR-2607-001,scope-main,Supply and install one overhead crane system,1
1 organization_code quotation_code topic_key content sort_order
2 ALLA QT-HO-CR-2607-001 scope-main Supply and install one overhead crane system 1

View File

@@ -0,0 +1,2 @@
organization_code,quotation_code,topic_key,topic_type,title,sort_order
ALLA,QT-HO-CR-2607-001,scope-main,scope,Scope of Work,1
1 organization_code quotation_code topic_key topic_type title sort_order
2 ALLA QT-HO-CR-2607-001 scope-main scope Scope of Work 1

View File

@@ -0,0 +1,2 @@
organization_code,quotation_code,customer_code,quotation_date,quotation_type,status,currency,subtotal,total_amount,created_by_email,updated_by_email,opportunity_code,contact_email,branch_code,valid_until,project_name,project_location,attention,reference,notes,revision,parent_quotation_code,revision_remark,exchange_rate,discount,discount_type,tax_rate,tax_amount,chance_percent,is_hot_project,competitor,salesman_email,is_sent,sent_at,sent_via
ALLA,QT-HO-CR-2607-001,CUS-001,2026-07-02,crane,draft,THB,1000000,1070000,sales.uat@example.com,sales.uat@example.com,OP-001,anan@siam.example,head_office,2026-08-01,Warehouse Crane,Bangkok Warehouse,Anan Sales,SETUP-SAMPLE,Initial setup sample quotation,0,,,1,0,,7,70000,70,false,,sales.uat@example.com,false,,
1 organization_code quotation_code customer_code quotation_date quotation_type status currency subtotal total_amount created_by_email updated_by_email opportunity_code contact_email branch_code valid_until project_name project_location attention reference notes revision parent_quotation_code revision_remark exchange_rate discount discount_type tax_rate tax_amount chance_percent is_hot_project competitor salesman_email is_sent sent_at sent_via
2 ALLA QT-HO-CR-2607-001 CUS-001 2026-07-02 crane draft THB 1000000 1070000 sales.uat@example.com sales.uat@example.com OP-001 anan@siam.example head_office 2026-08-01 Warehouse Crane Bangkok Warehouse Anan Sales SETUP-SAMPLE Initial setup sample quotation 0 1 0 7 70000 70 false sales.uat@example.com false

View File

@@ -0,0 +1,255 @@
{
"version": "1.0.0",
"generatedFrom": "docs/setup/csv-template-spec.md",
"dataset": {
"organizationCode": "ALLA",
"branchCode": "head_office",
"productTypeCode": "crane",
"currency": "THB",
"administratorEmail": "admin@example.com",
"marketingEmail": "mk.uat@example.com",
"salesEmail": "sales.uat@example.com",
"managerEmail": "manager.uat@example.com",
"ceoEmail": "ceo.uat@example.com"
},
"templates": [
{
"file": "users.csv",
"seedType": "organization",
"importOrder": 1,
"supported": true,
"requiredColumns": ["email", "name", "system_role"],
"description": "Setup-managed users."
},
{
"file": "organizations.csv",
"seedType": "organization",
"importOrder": 2,
"supported": true,
"requiredColumns": ["organization_code", "organization_name", "slug", "created_by_email"],
"description": "Tenant organizations."
},
{
"file": "memberships.csv",
"seedType": "organization",
"importOrder": 3,
"supported": true,
"requiredColumns": ["organization_code", "user_email", "membership_role", "business_role"],
"description": "App-level organization memberships."
},
{
"file": "crm-role-assignments.csv",
"seedType": "organization",
"importOrder": 5,
"supported": true,
"requiredColumns": [
"organization_code",
"user_email",
"crm_role_code",
"is_primary",
"branch_scope_mode",
"product_type_scope_mode"
],
"description": "CRM role assignments and scopes."
},
{
"file": "master-options.csv",
"seedType": "foundation",
"importOrder": 6,
"supported": true,
"requiredColumns": ["organization_code", "category", "code", "label"],
"description": "Generic governed master options."
},
{
"file": "branches.csv",
"seedType": "organization",
"importOrder": 7,
"supported": true,
"requiredColumns": ["organization_code", "branch_code", "branch_name"],
"description": "Branch options mapped to ms_options category crm_branch."
},
{
"file": "product-types.csv",
"seedType": "organization",
"importOrder": 8,
"supported": true,
"requiredColumns": ["organization_code", "product_type_code", "product_type_name"],
"description": "Product type options mapped to ms_options category crm_product_type."
},
{
"file": "document-sequences.csv",
"seedType": "foundation",
"importOrder": 14,
"supported": true,
"requiredColumns": ["organization_code", "document_type", "prefix", "period"],
"description": "Document numbering configuration."
},
{
"file": "approval-workflows.csv",
"seedType": "foundation",
"importOrder": 15,
"supported": true,
"requiredColumns": ["organization_code", "workflow_code", "workflow_name", "entity_type"],
"description": "Approval workflow headers."
},
{
"file": "approval-steps.csv",
"seedType": "foundation",
"importOrder": 16,
"supported": true,
"requiredColumns": ["organization_code", "workflow_code", "step_number", "role_code", "role_name"],
"description": "Approval workflow steps."
},
{
"file": "approval-matrix.csv",
"seedType": "foundation",
"importOrder": 17,
"supported": true,
"requiredColumns": ["organization_code", "entity_type", "workflow_code", "priority", "is_default"],
"description": "Approval workflow routing matrix."
},
{
"file": "customers.csv",
"seedType": "business",
"importOrder": 30,
"supported": true,
"requiredColumns": [
"organization_code",
"customer_code",
"customer_name",
"customer_type",
"customer_status",
"created_by_email"
],
"description": "CRM customers."
},
{
"file": "contacts.csv",
"seedType": "business",
"importOrder": 32,
"supported": true,
"requiredColumns": ["organization_code", "customer_code", "contact_name", "created_by_email"],
"description": "Customer contacts."
},
{
"file": "contact-shares.csv",
"seedType": "business",
"importOrder": 33,
"supported": true,
"requiredColumns": [
"organization_code",
"customer_code",
"contact_email",
"shared_to_user_email",
"shared_by_user_email"
],
"description": "Contact sharing grants."
},
{
"file": "leads.csv",
"seedType": "business",
"importOrder": 34,
"supported": true,
"requiredColumns": ["organization_code", "lead_code", "status", "created_by_email"],
"description": "Marketing-owned leads."
},
{
"file": "opportunities.csv",
"seedType": "business",
"importOrder": 36,
"supported": true,
"requiredColumns": [
"organization_code",
"opportunity_code",
"customer_code",
"title",
"product_type_code",
"status",
"priority",
"created_by_email",
"updated_by_email"
],
"description": "Sales opportunities."
},
{
"file": "opportunity-parties.csv",
"seedType": "business",
"importOrder": 37,
"supported": true,
"requiredColumns": ["organization_code", "opportunity_code", "customer_code", "role_code"],
"description": "Opportunity project parties."
},
{
"file": "quotations.csv",
"seedType": "business",
"importOrder": 40,
"supported": true,
"requiredColumns": [
"organization_code",
"quotation_code",
"customer_code",
"quotation_date",
"quotation_type",
"status",
"currency",
"subtotal",
"total_amount",
"created_by_email",
"updated_by_email"
],
"description": "Quotation headers."
},
{
"file": "quotation-items.csv",
"seedType": "business",
"importOrder": 41,
"supported": true,
"requiredColumns": [
"organization_code",
"quotation_code",
"item_number",
"product_type_code",
"description",
"quantity",
"unit_price",
"total_price"
],
"description": "Quotation line items."
},
{
"file": "quotation-parties.csv",
"seedType": "business",
"importOrder": 42,
"supported": true,
"requiredColumns": ["organization_code", "quotation_code", "customer_code", "role_code"],
"description": "Quotation project parties."
},
{
"file": "quotation-topics.csv",
"seedType": "business",
"importOrder": 43,
"supported": true,
"requiredColumns": ["organization_code", "quotation_code", "topic_key", "topic_type", "title"],
"description": "Quotation topic headers."
},
{
"file": "quotation-topic-items.csv",
"seedType": "business",
"importOrder": 44,
"supported": true,
"requiredColumns": ["organization_code", "quotation_code", "topic_key", "content"],
"description": "Quotation topic rows."
}
],
"unsupportedTemplates": [
"departments.csv",
"teams.csv",
"warehouses.csv",
"sites.csv",
"services.csv",
"price-books.csv",
"tax-rates.csv",
"attachments.csv",
"email-settings.csv"
]
}

View File

@@ -0,0 +1,2 @@
email,name,system_role,password,active_organization_code,image_url,reset_password
admin@allaos.local,System Administrator,super_admin,gikiyd[ibKym,ALLA,,FALSE
1 email name system_role password active_organization_code image_url reset_password
2 admin@allaos.local System Administrator super_admin gikiyd[ibKym ALLA FALSE