220 lines
4.9 KiB
Markdown
220 lines
4.9 KiB
Markdown
# Addendum for Task D.2: Customer Role Selection UI + Separate Project Party Field
|
|
|
|
## Context
|
|
|
|
ตอนนี้การเลือก Customer ใน Lead / Opportunity / Quotation ใช้งานได้แล้ว แต่ยังไม่ชัดว่า Customer ที่เลือกมีบทบาทอะไรในโครงการ
|
|
|
|
Business requirement ใหม่:
|
|
|
|
* Customer หลักในฟอร์มยังใช้เป็น Billing Customer ได้
|
|
* แต่ต้องมี Project Party แยกอีกชุดหนึ่ง
|
|
* Project Party ใช้บอกว่าในโครงการนี้มีบริษัทไหนทำ role อะไร
|
|
* บริษัทเดียวกันอาจมี role ต่างกันในแต่ละโครงการ
|
|
|
|
---
|
|
|
|
# UI Requirement 1: Billing Customer Field
|
|
|
|
ใน Lead / Opportunity / Quotation form ให้คง field หลัก:
|
|
|
|
```txt
|
|
Billing Customer
|
|
```
|
|
|
|
Data source:
|
|
|
|
```txt
|
|
crm_customers
|
|
```
|
|
|
|
Meaning:
|
|
|
|
```txt
|
|
ลูกค้าที่ใช้เป็นผู้ติดต่อ/ผู้ออกเอกสาร/ผู้วางบิลหลัก
|
|
```
|
|
|
|
Do not rename this field to generic Customer.
|
|
|
|
---
|
|
|
|
# UI Requirement 2: Project Party Section
|
|
|
|
เพิ่ม section แยกชื่อ:
|
|
|
|
```txt
|
|
Project Parties
|
|
```
|
|
|
|
หรือภาษาไทย:
|
|
|
|
```txt
|
|
บริษัทที่เกี่ยวข้องในโครงการ
|
|
```
|
|
|
|
ใน form/detail ของ:
|
|
|
|
```txt
|
|
Lead / Opportunity
|
|
Quotation
|
|
```
|
|
|
|
Project Party row ต้องมี field:
|
|
|
|
```txt
|
|
Customer
|
|
Role
|
|
Remark
|
|
```
|
|
|
|
Role ดึงจาก master option:
|
|
|
|
```txt
|
|
crm_project_party_role
|
|
```
|
|
|
|
Role values:
|
|
|
|
```txt
|
|
billing_customer
|
|
customer
|
|
consultant
|
|
contractor
|
|
end_customer
|
|
other
|
|
```
|
|
|
|
---
|
|
|
|
# UI Requirement 3: Add Party Flow
|
|
|
|
ใน Project Parties section ต้องมีปุ่ม:
|
|
|
|
```txt
|
|
Add Party
|
|
```
|
|
|
|
เมื่อกดให้เลือก:
|
|
|
|
```txt
|
|
Customer
|
|
Role
|
|
Remark optional
|
|
```
|
|
|
|
ถ้า customer ยังไม่มีใน master ให้ยังไม่ต้องสร้าง inline customer ใน Task นี้
|
|
ให้ใช้ customer master ที่มีอยู่ก่อน
|
|
|
|
---
|
|
|
|
# UI Requirement 4: Display Role Clearly
|
|
|
|
ทุกที่ที่แสดง Project Party ต้องแสดง role ชัดเจน เช่น:
|
|
|
|
```txt
|
|
PTT Public Company Limited
|
|
Role: End Customer
|
|
|
|
Italian Thai
|
|
Role: Contractor
|
|
|
|
AEC Consultant
|
|
Role: Consultant
|
|
```
|
|
|
|
ห้ามแสดงแค่ชื่อบริษัทโดยไม่มี role
|
|
|
|
---
|
|
|
|
# UI Requirement 5: Billing Customer Auto Add Option
|
|
|
|
เมื่อสร้าง Lead / Opportunity / Quotation แล้วเลือก Billing Customer
|
|
|
|
ให้ระบบสามารถ auto-add ลง Project Parties เป็น role:
|
|
|
|
```txt
|
|
billing_customer
|
|
```
|
|
|
|
ถ้าทำได้โดยไม่ซับซ้อน
|
|
|
|
Rules:
|
|
|
|
* ห้าม duplicate customerId + roleCode ใน entity เดียวกัน
|
|
* ถ้า billing customer มีอยู่แล้วใน Project Parties ไม่ต้องเพิ่มซ้ำ
|
|
* ถ้า user เปลี่ยน Billing Customer ให้ถาม/หรือ update ตาม business-safe behavior
|
|
|
|
ถ้า logic นี้ใหญ่เกินไป ให้ทำเป็น TODO และไม่ block Task D.2
|
|
|
|
---
|
|
|
|
# UI Requirement 6: Detail Page
|
|
|
|
ใน detail page ให้แสดงแยกชัดเจน:
|
|
|
|
```txt
|
|
Billing Customer
|
|
```
|
|
|
|
และ
|
|
|
|
```txt
|
|
Project Parties
|
|
```
|
|
|
|
ตัวอย่าง:
|
|
|
|
```txt
|
|
Billing Customer:
|
|
ABC Engineering Co., Ltd.
|
|
|
|
Project Parties:
|
|
- ABC Engineering Co., Ltd. / Billing Customer
|
|
- PTT / End Customer
|
|
- Italian Thai / Contractor
|
|
- AEC / Consultant
|
|
```
|
|
|
|
---
|
|
|
|
# UI Requirement 7: Quotation Compatibility
|
|
|
|
Quotation เดิมมี:
|
|
|
|
```txt
|
|
crm_quotation_customers
|
|
```
|
|
|
|
ให้ refactor/align กับ Project Parties
|
|
|
|
แต่ UI ต้องแสดงแบบเดียวกัน:
|
|
|
|
```txt
|
|
Billing Customer
|
|
Project Parties
|
|
```
|
|
|
|
อย่าใช้คำว่า Owner ถ้า business ไม่ใช้แล้ว
|
|
|
|
Mapping เก่า:
|
|
|
|
```txt
|
|
owner -> customer
|
|
billing -> billing_customer
|
|
consultant -> consultant
|
|
contractor -> contractor
|
|
```
|
|
|
|
---
|
|
|
|
# Definition of Done Addendum
|
|
|
|
Task D.2 จะถือว่าครบเมื่อ:
|
|
|
|
* Billing Customer เป็น field หลักแยกจาก Project Parties
|
|
* Project Parties เป็น section/table แยก
|
|
* แต่ละ Project Party มี Customer + Role + Remark
|
|
* Role ดึงจาก master option
|
|
* Detail page แสดง Billing Customer และ Project Parties แยกกัน
|
|
* Quotation compatibility mapping ไม่ทำให้ข้อมูลเก่าหาย
|
|
* ไม่มี UI ที่แสดงบริษัทเกี่ยวข้องโดยไม่บอก role
|