Cane Agency · ERD Seriesสถาบันอ้อย · ชุดเอกสาร ERD
The contractor perspective owns twelve entities across four contexts — service_marketplace (ServiceOffering, ServiceRequest, ServiceQuote, ServicePayment), work_dispatch (Contractor, WorkOrder, WorkAssignment, Machine), reputation (Review, Endorsement) and books (LedgerAccount, JournalEntry) — and shares (reads under the owner's rules): Tenant, User, Farmer, Mill, Field, Crop, Season, Quota, Truck, FarmActivity, CreditLine, CreditItem, PaymentItem, ConsentGrant, CreditAssessment. One owner per entity; this document is the deep reference for its owned set and a view of the rest. Since v9.0 (PROP-010) books extends into a full financial system: the contractor additionally shares ChartTemplate, Invoice, Receipt, PaymentVoucher, CashAccount, BankTransaction, Reconciliation, FiscalPeriod, FinancialStatement and (v12.0, PROP-011) BooksProfile (owned under the mill reference; default unified edition, upgradeable to split via the books_split entitlement) and joins the receivables and cash_management contexts (WF-36 · WF-40); its P&L already auto-posts from verified work and service payments.
มุมมองผู้รับเหมาเป็นเจ้าของ entity สิบสองตัวในสี่บริบท — service_marketplace (ServiceOffering, ServiceRequest, ServiceQuote, ServicePayment), work_dispatch (Contractor, WorkOrder, WorkAssignment, Machine), reputation (Review, Endorsement) และ books (LedgerAccount, JournalEntry) — และใช้ร่วม (อ่านตามกฎของเจ้าของ): Tenant, User, Farmer, Mill, Field, Crop, Season, Quota, Truck, FarmActivity, CreditLine, CreditItem, PaymentItem, ConsentGrant, CreditAssessment หนึ่งเจ้าของต่อหนึ่ง entity; เอกสารนี้คืออ้างอิงเชิงลึกของชุดที่เป็นเจ้าของ และเป็นมุมมองของส่วนที่เหลือ ตั้งแต่ v9.0 (PROP-010) books ขยายเป็นระบบการเงินเต็ม: ผู้รับเหมาใช้ร่วม ChartTemplate, Invoice, Receipt, PaymentVoucher, CashAccount, BankTransaction, Reconciliation, FiscalPeriod, FinancialStatement และ (v12.0, PROP-011) BooksProfile (เป็นเจ้าของภายใต้มุมมองโรงงาน; ตั้งต้นรุ่น unified อัปเกรดเป็น split ผ่านสิทธิ์ books_split) และเข้าร่วมบริบท receivables และ cash_management (WF-36 · WF-40); งบกำไรขาดทุนของผู้รับเหมาลงอัตโนมัติจากงานที่ตรวจรับและค่าบริการอยู่แล้ว
| Entity · codeEntity · รหัส | Attributesแอตทริบิวต์ | Rules (normative in the graph)กฎ (บรรทัดฐานอยู่ใน graph (กราฟ)) |
|---|---|---|
| Contractor ผู้รับเหมา CEC-##### | contractor_id, kind, tenant_id?, user_id?, name, base_province, service_area, phone, verified_status, rating_avg, rating_count, jobs_completed, member_since | kind: freelance | organization — exactly one of user_id/tenant_id set; upgrade keeps the record. Cached aggregates recomputed from Review, never edited. verified_status: unverified | id_verified | endorsed.kind: freelance | organization — กำหนด user_id/tenant_id อย่างใดอย่างหนึ่ง; อัปเกรดคงเรกคอร์ด ค่าสรุปแคชคำนวณใหม่จาก Review ห้ามแก้ตรง verified_status: unverified | id_verified | endorsed |
| ServiceOffering รายการบริการ SVO-###### | offering_id, contractor_id, service_type, custom_label?, unit, price_min, price_max, service_area, season_window?, capacity_note?, status | 13-value service taxonomy (+other with custom_label); unit: per_rai | per_ton | per_km | per_day | per_job; the listed price is a public range — the binding price lives on the quote/work order.อนุกรมวิธาน 13 ค่า (+other พร้อม custom_label); unit: per_rai | per_ton | per_km | per_day | per_job; ราคาประกาศเป็นช่วงสาธารณะ — ราคาผูกพันอยู่บนใบเสนอราคา/ใบสั่งงาน |
| ServiceRequest คำขอบริการ SRQ-######## | request_id, requester_tenant_type, requester_tenant_id, service_type, matching_mode, field_id?, crop_id?, quantity, unit, window_start, window_end, budget_max?, note?, status, awarded_quote_id? | matching_mode: rfq | direct | broadcast — broadcast powers instant dispatch (จองด่วน). Anchoring to field/crop is what later verifies the work. status: open | quoted | awarded | expired | cancelled.matching_mode: rfq | direct | broadcast — broadcast ขับจองด่วน การยึดแปลง/อ้อยคือสิ่งที่ใช้ตรวจยืนยันงาน status: open | quoted | awarded | expired | cancelled |
| ServiceQuote ใบเสนอราคา SQT-######## | quote_id, request_id, contractor_id, price, unit, terms?, valid_until, status | One accepted quote per request; acceptance creates the WorkOrder atomically.คำขอหนึ่งมีใบเสนอราคาที่ตอบรับได้ใบเดียว; การตอบรับสร้าง WorkOrder แบบ atomic |
| WorkOrder ใบสั่งงาน WKO-25##-###### | work_order_id, request_id, quote_id, contractor_id, requester_tenant_type, requester_tenant_id, service_type, field_id?, crop_id?, quantity, unit, agreed_price, payment_method, window_start, window_end, status, completed_at?, verified_by?, dispute_note? | The contract of record; status runs the work-order state machine (SPEC-PWF-CEC Section 8). Escrow gate before scheduling; verification gates payment, review, FarmActivity auto-log and books posting.สัญญาหลักฐาน; สถานะเดินตาม state machine (SPEC-PWF-CEC ข้อ 8) ประตู escrow ก่อนจัดคิว; การตรวจรับเป็นประตูการจ่าย รีวิว การบันทึก FarmActivity และการลงบัญชี |
| WorkAssignment การมอบหมายงาน WKA-######## | assignment_id, work_order_id, assignee_user_id, machine_id?, scheduled_date, progress_pct, work_log, status | work_log is append-only {ts, note?, photo?, gps?, qty_done?} — the evidence chain. status: assigned | en_route | working | done.work_log ต่อท้ายเท่านั้น {ts, note?, photo?, gps?, qty_done?} — สายหลักฐาน status: assigned | en_route | working | done |
| Machine เครื่องจักร MCH-##### | machine_id, contractor_id, machine_type, brand_model?, capacity_note?, plate_no?, year?, status | machine_type: harvester | tractor | truck | sprayer_drone | drip_rig | solar_pump_rig | implement | other. Reference target of the bank's machine collateral.machine_type: harvester | tractor | truck | sprayer_drone | drip_rig | solar_pump_rig | implement | other เป้าอ้างอิงหลักประกัน machine ของธนาคาร |
| ServicePayment การชำระค่าบริการ SPY-######## | payment_id, work_order_id, payer_tenant_type, payer_tenant_id, payee_contractor_id, amount, fee_amount?, method, escrow_state?, credit_item_id?, payment_item_id?, status, paid_at? | Four rails: escrow | cash_recorded | credit_financed | settlement_offset; escrow lifecycle funded | held | released | refunded; commission (fee_amount) on escrow only (NFR-11).สี่ช่องทาง: escrow | cash_recorded | credit_financed | settlement_offset; วงจร escrow funded | held | released | refunded; คอมมิชชัน (fee_amount) เฉพาะ escrow (NFR-11) |
| Review รีวิว RVW-######## | review_id, work_order_id, contractor_id, rater_tenant_type, rater_tenant_id, score_completion, score_quality, score_timeliness, score_overall, comment?, reply?, replied_at?, created_at, status | Append-only. Exactly one per verified order, authored by its requester (NFR-10); one public contractor reply; removal by platform_admin only, reason logged.ต่อท้ายเท่านั้น หนึ่งรีวิวต่อใบสั่งงานที่ตรวจรับ เขียนโดยผู้ว่าจ้าง (NFR-10); ผู้รับเหมาตอบกลับสาธารณะได้หนึ่งครั้ง; ลบได้เฉพาะ platform_admin พร้อมบันทึกเหตุผล |
| Endorsement การรับรอง END-###### | endorsement_id, contractor_id, endorser_tenant_type, endorser_tenant_id, season_id?, note?, granted_at, status | endorser_tenant_type: sugar_factory | quota_farmer; withdrawable any time, append-only history.endorser_tenant_type: sugar_factory | quota_farmer; ถอนได้ทุกเมื่อ ประวัติต่อท้าย |
| LedgerAccount บัญชีแยกประเภท LGA-##### | account_id, owner_tenant_type, owner_tenant_id, code, name_th, name_en?, account_class, system_flag, status | account_class: asset | liability | equity | income | expense; system accounts locked; keyed by owner tenant — deliberately tenant-agnostic.account_class: asset | liability | equity | income | expense; บัญชีระบบล็อก; คีย์ด้วยผู้เป็นเจ้าของ — จงใจไม่ผูกกลุ่ม |
| JournalEntry รายการสมุดรายวัน JRN-######## | entry_id, owner_tenant_type, owner_tenant_id, entry_date, memo?, source_type, source_id?, lines, status, reversal_of? | Append-only double entry; lines {account_id, debit?, credit?, machine_id?, work_order_id?, service_type?} must balance; corrections post reversals (NFR-13).บัญชีคู่แบบต่อท้าย; lines {account_id, debit?, credit?, machine_id?, work_order_id?, service_type?} ต้องสมดุล; แก้ไขด้วยรายการกลับ (NFR-13) |
Scoped view of the platform model from this perspective, rendered from the graph (entities · relationships · dataModeling, v0.4.0). Solid boxes are entities documented at full depth in this family — bold = primary key, gold = foreign key. Dashed boxes are shared entities; the label names their home document. Cardinalities read at each line end.
มุมมองเฉพาะด้านของ model ทั้ง platform render จาก graph (entities · relationships · dataModeling, v0.4.0) กล่องเส้นทึบคือ entity ที่บันทึกเชิงลึกในเอกสารตระกูลนี้ — ตัวหนา = primary key, สีทอง = foreign key กล่องเส้นประคือ entity ที่ใช้ร่วม โดยป้ายระบุเอกสาร home; อ่าน cardinality ที่ปลายเส้นแต่ละด้าน
| Edgeเส้นเชื่อม | Cardinalityภาวะเชิงจำนวน | Ruleกฎ |
|---|---|---|
| Tenant → Contractor | 0..1 — 0..1 | A contractor tenant is represented by exactly one Contractor (kind = organization).tenant ผู้รับเหมามี Contractor หนึ่งเรกคอร์ด (kind = organization) |
| User → Contractor | 0..1 — 0..1 | A freelance contractor is one individual account (kind = freelance).ฟรีแลนซ์คือบัญชีบุคคลเดียว (kind = freelance) |
| Contractor → ServiceOffering · ServiceQuote · WorkOrder · Machine · Endorsement | 1 — 0..* | Ownership edges; at most one active endorsement per (contractor, endorser).เส้นความเป็นเจ้าของ; การรับรอง active ได้อย่างมากหนึ่งรายการต่อ (ผู้รับเหมา, ผู้รับรอง) |
| Farmer → ServiceRequest | 1 — 0..* | Requester polymorphic (cane_farmer | quota_farmer via Farmer, sugar_factory via Tenant).ผู้ขอเป็นแบบหลายรูป (cane_farmer | quota_farmer ผ่าน Farmer, sugar_factory ผ่าน Tenant) |
| Field → ServiceRequest | 0..1 — 0..* | Demand anchors to a real field (and optionally its crop).อุปสงค์ยึดกับแปลงจริง (และอ้อยของแปลงถ้ามี) |
| ServiceRequest → ServiceQuote → WorkOrder | 1 — 0..* · 0..1 — 0..1 | RFQ collects quotes; one accepted quote creates the order atomically; broadcast auto-accepts the first qualified acceptance.RFQ รวบใบเสนอราคา; ใบที่ตอบรับสร้างใบสั่งงานแบบ atomic; broadcast รับรายแรกที่ผ่านเกณฑ์อัตโนมัติ |
| WorkOrder → WorkAssignment | 1 — 1..* | At least one assignment; freelancers self-assign; optional machine per assignment.อย่างน้อยหนึ่งการมอบหมาย; ฟรีแลนซ์มอบหมายตนเอง; เครื่องจักรต่อการมอบหมายไม่บังคับ |
| WorkOrder → ServicePayment · Review · FarmActivity | 1 — 0..* · 1 — 0..1 · 0..1 — 0..* | Escrow release requires verified; one review per verified order; verification auto-logs the matching FarmActivity.ปล่อย escrow ต้อง verified; หนึ่งรีวิวต่อใบสั่งงานที่ตรวจรับ; การตรวจรับบันทึก FarmActivity อัตโนมัติ |
| CreditItem → WorkOrder | 0..1 — 0..1 | A financed service item links the เงินเกี๊ยว money to the delivering work order.รายการสินเชื่อบริการลิงก์เงินเกี๊ยวกับใบสั่งงานที่ส่งมอบจริง |
| PaymentItem → ServicePayment | 1 — 0..* | Settlement offset posts the matching ServicePayment; ordering joins the PROP-003 Q4 priority stack.การหักกลบตอนปิดงวดบันทึก ServicePayment ที่ตรงกัน; ลำดับเข้าร่วมกอง Q4 ของ PROP-003 |
| Machine → Collateral | 0..1 — 0..* | collateral_type: machine — the equipment loan is secured by the machine itself.collateral_type: machine — สินเชื่อเครื่องจักรค้ำด้วยตัวเครื่องเอง |
| Contractor → LedgerAccount → JournalEntry | 1 — 0..* · 1 — 0..* | Books owner keyed polymorphically; journal lines reference same-owner accounts and must balance.เจ้าของบัญชีคีย์แบบหลายรูป; รายการสมุดรายวันอ้างบัญชีเจ้าของเดียวกันและต้องสมดุล |
| Entity | Changeการเปลี่ยนแปลง |
|---|---|
| Tenant | tenant_type gains contractor.tenant_type เพิ่ม contractor |
| CreditItem | Optional work_order_id? — financed service ↔ delivering work order.เพิ่ม work_order_id? — บริการผ่านสินเชื่อ ↔ ใบสั่งงานที่ส่งมอบ |
| FarmActivity | Optional work_order_id? + performed_by_contractor_id?; auto-logged on verification.เพิ่ม work_order_id? + performed_by_contractor_id?; บันทึกอัตโนมัติเมื่อตรวจรับ |
| ConsentGrant | grantor_tenant_type gains contractor; scope gains work_history | ratings | fleet | earnings | books (books never bundled).grantor_tenant_type เพิ่ม contractor; scope เพิ่ม work_history | ratings | fleet | earnings | books (books ไม่พ่วงกับ scope อื่น) |
| CreditAssessment · LoanProduct · Collateral | Subject/borrower kinds gain contractor; collateral_type gains machine.ผู้ถูกประเมิน/ผู้กู้เพิ่ม contractor; collateral_type เพิ่ม machine |
| Truck | Optional operator_contractor_id? (Q6) — contractor-driven trucks traceable through delivery; a contractor's own vehicles live in Machine.เพิ่ม operator_contractor_id? (Q6) — รถที่ผู้รับเหมาเดินรถตามรอยได้ตลอดการส่งมอบ; ยานพาหนะของผู้รับเหมาเองอยู่ใน Machine |
Normative physical model for the 10 entities homed in this document, rendered from the graph's dataModeling block. Types derive from typeConventions (first rule wins): money = bigint satang · weights = integer kg · tonnage = numeric(12,3) · timestamps = timestamptz UTC · ids = uuid v7. Every FK is indexed by convention (ON DELETE RESTRICT); listed indexes are additional. Enum value sets live in the graph's entity and state-machine notes.
Model เชิงกายภาพที่เป็นบรรทัดฐานของ entity ทั้ง 10 รายการที่ home อยู่ในเอกสารนี้ render จาก block dataModeling ใน graph ชนิดข้อมูลอนุมานจาก typeConventions (กติกาแรกที่เข้าเป็นผล): เงิน = bigint สตางค์ · น้ำหนัก = integer กก. · ตัน = numeric(12,3) · เวลา = timestamptz UTC · id = uuid v7 ทุก FK มี index ตามข้อตกลง (ON DELETE RESTRICT); index ที่ระบุคือส่วนเพิ่ม ชุดค่า enum อยู่ในหมายเหตุ entity และ state machine ของ graph
| ColumnColumn | Typeชนิด | Null | Defaultค่าตั้งต้น | Key / refKey / อ้างอิง |
|---|---|---|---|---|
| contractor_id | uuid | — | uuid_v7() | PK |
| tenant_id | uuid | — | — | FK → tenant |
| name | text | — | — | |
| base_province | smallint | — | — | Province enum · TIS 1099-2548 (PROP-047) |
| service_area | jsonb | — | — | |
| phone | text | — | — | |
| verified_status | text (enum) | — | — | |
| rating_avg | numeric(3,2) | — | — | |
| rating_count | integer | — | — | |
| jobs_completed | integer | — | — | |
| member_since | date | — | — |
| ColumnColumn | Typeชนิด | Null | Defaultค่าตั้งต้น | Key / refKey / อ้างอิง |
|---|---|---|---|---|
| offering_id | uuid | — | uuid_v7() | PK |
| contractor_id | uuid | — | — | FK → contractor |
| service_type | text (enum) | — | — | |
| custom_label | text | ✓ | — | |
| unit | text | — | — | |
| price_min | bigint (satang) | — | — | |
| price_max | bigint (satang) | — | — | |
| service_area | jsonb | — | — | |
| season_window | text | ✓ | — | |
| capacity_note | text | ✓ | — | |
| status | text (enum) | — | — |
| ColumnColumn | Typeชนิด | Null | Defaultค่าตั้งต้น | Key / refKey / อ้างอิง |
|---|---|---|---|---|
| request_id | uuid | — | uuid_v7() | PK |
| requester_tenant_id | uuid | — | — | FK → tenant |
| service_type | text (enum) | — | — | |
| matching_mode | text (enum) | — | — | |
| field_id | uuid | ✓ | — | FK → field |
| crop_id | uuid | ✓ | — | FK → crop |
| quantity | numeric(12,2) | — | — | |
| unit | text | — | — | |
| window_start | date | — | — | |
| window_end | date | — | — | |
| budget_max | bigint (satang) | ✓ | — | |
| note | text | ✓ | — | |
| status | text (enum) | — | — | |
| awarded_quote_id | uuid | ✓ | — | FK → service_quote |
| ColumnColumn | Typeชนิด | Null | Defaultค่าตั้งต้น | Key / refKey / อ้างอิง |
|---|---|---|---|---|
| quote_id | uuid | — | uuid_v7() | PK |
| request_id | uuid | — | — | FK → service_request |
| contractor_id | uuid | — | — | FK → contractor |
| price | bigint (satang) | — | — | |
| unit | text | — | — | |
| terms | text | ✓ | — | |
| valid_until | text | — | — | |
| status | text (enum) | — | — |
| ColumnColumn | Typeชนิด | Null | Defaultค่าตั้งต้น | Key / refKey / อ้างอิง |
|---|---|---|---|---|
| work_order_id | uuid | — | uuid_v7() | PK |
| request_id | uuid | — | — | FK → service_request |
| quote_id | uuid | — | — | FK → service_quote |
| contractor_id | uuid | — | — | FK → contractor |
| requester_tenant_id | uuid | — | — | FK → tenant |
| service_type | text (enum) | — | — | |
| field_id | uuid | ✓ | — | FK → field |
| crop_id | uuid | ✓ | — | FK → crop |
| quantity | numeric(12,2) | — | — | |
| unit | text | — | — | |
| agreed_price | bigint (satang) | — | — | |
| payment_method | text (enum) | — | — | |
| window_start | date | — | — | |
| window_end | date | — | — | |
| status | text (enum) | — | — | |
| completed_at | timestamptz | ✓ | — | |
| verified_by | uuid | ✓ | — | FK → membership |
| dispute_note | text | ✓ | — |
| ColumnColumn | Typeชนิด | Null | Defaultค่าตั้งต้น | Key / refKey / อ้างอิง |
|---|---|---|---|---|
| assignment_id | uuid | — | uuid_v7() | PK |
| work_order_id | uuid | — | — | FK → work_order |
| assignee_membership_id | uuid | — | — | FK → membership |
| machine_id | uuid | ✓ | — | FK → machine |
| scheduled_date | date | — | — | |
| progress_pct | numeric(5,2) | — | — | |
| work_log | jsonb | — | — | |
| status | text (enum) | — | — |
| ColumnColumn | Typeชนิด | Null | Defaultค่าตั้งต้น | Key / refKey / อ้างอิง |
|---|---|---|---|---|
| machine_id | uuid | — | uuid_v7() | PK |
| contractor_id | uuid | — | — | FK → contractor |
| machine_type | text (enum) | — | — | |
| brand_model | text | ✓ | — | |
| capacity_note | text | ✓ | — | |
| plate_no | text | ✓ | — | |
| year | integer | ✓ | — | |
| status | text (enum) | — | — |
| ColumnColumn | Typeชนิด | Null | Defaultค่าตั้งต้น | Key / refKey / อ้างอิง |
|---|---|---|---|---|
| payment_id | uuid | — | uuid_v7() | PK |
| work_order_id | uuid | — | — | FK → work_order |
| payer_tenant_id | uuid | — | — | FK → tenant |
| payee_contractor_id | uuid | — | — | FK → contractor |
| amount | bigint (satang) | — | — | |
| fee_amount | bigint (satang) | ✓ | — | |
| method | text (enum) | — | — | |
| escrow_state | text (enum) | ✓ | — | |
| credit_item_id | uuid | ✓ | — | FK → credit_item |
| payment_item_id | uuid | ✓ | — | FK → payment_item |
| status | text (enum) | — | — | |
| paid_at | timestamptz | ✓ | — |
| ColumnColumn | Typeชนิด | Null | Defaultค่าตั้งต้น | Key / refKey / อ้างอิง |
|---|---|---|---|---|
| review_id | uuid | — | uuid_v7() | PK |
| work_order_id | uuid | — | — | FK → work_order |
| contractor_id | uuid | — | — | FK → contractor |
| rater_tenant_id | uuid | — | — | FK → tenant |
| score_completion | integer | — | — | |
| score_quality | integer | — | — | |
| score_timeliness | integer | — | — | |
| score_overall | integer | — | — | |
| comment | text | ✓ | — | |
| reply | text | ✓ | — | |
| replied_at | timestamptz | ✓ | — | |
| created_at | timestamptz | — | now() | |
| status | text (enum) | — | — |
| ColumnColumn | Typeชนิด | Null | Defaultค่าตั้งต้น | Key / refKey / อ้างอิง |
|---|---|---|---|---|
| endorsement_id | uuid | — | uuid_v7() | PK |
| contractor_id | uuid | — | — | FK → contractor |
| endorser_tenant_id | uuid | — | — | FK → tenant |
| season_id | uuid | ✓ | — | FK → season |
| note | text | ✓ | — | |
| granted_at | timestamptz | — | — | |
| status | text (enum) | — | — |
One row per entity in this perspective. Mutability: mutable · immutable_
หนึ่งแถวต่อ entity ในมุมมองนี้ Mutability: mutable · immutable_
| Entity | Tableตาราง | PK | Unique | Key indexesIndex หลัก | Mutability | PDPA | Profile |
|---|---|---|---|---|---|---|---|
| Contractor | contractor | contractor_id | (tenant_id) | (base_province,verified_status) (service_area (gin)) | mutable | personal | Section 6ข้อ 6 |
| ServiceOffering | service_offering | offering_id | (contractor_id,service_type,custom_label) | (service_type,status) | mutable | operational | Section 6ข้อ 6 |
| ServiceRequest | service_request | request_id | — | (requester_tenant_id,status) (service_type,status,window_start) (field_id) | immutable_ | operational | Section 6ข้อ 6 |
| ServiceQuote | service_quote | quote_id | (request_id,contractor_id) | (status,valid_until) | immutable_ | operational | Section 6ข้อ 6 |
| WorkOrder | work_order | work_order_id | (quote_id (partial: not null)) | (contractor_id,status) (requester_tenant_id,status) (window_start) | immutable_ | operational | Section 6ข้อ 6 |
| WorkAssignment | work_assignment | assignment_id | — | (work_order_id,scheduled_date) (assignee_membership_id,scheduled_date) (machine_id) | mutable | operational | Section 6ข้อ 6 |
| Machine | machine | machine_id | (plate_no (partial: not null)) | (contractor_id,status) | mutable | operational | Section 6ข้อ 6 |
| ServicePayment | service_payment | payment_id | — | (work_order_id) (payer_tenant_id) (escrow_state (partial: held)) (credit_item_id) | immutable_ | operational | Section 6ข้อ 6 |
| Review | review | review_id | (work_order_id) | (contractor_id,created_at) (status) | immutable_ | operational | Section 6ข้อ 6 |
| Endorsement | endorsement | endorsement_id | (contractor_id,endorser_tenant_id,season_id) | — | immutable_ | operational | Section 6ข้อ 6 |
| LedgerAccount | ledger_account | account_id | (owner_tenant_id,code) | (account_class) (template_id) (cash_account_id) | mutable | operational | SPEC-ERD-MILL |
| JournalEntry | journal_entry | entry_id | (owner_tenant_id,source_type,source_id (partial: auto-posted)) | (owner_tenant_id,entry_date) (reversal_of) | append_ | operational | SPEC-ERD-MILL |
Transaction boundaries touching this perspective, from graph dataModeling.aggregates. Inside a boundary the stated invariants commit atomically in one database transaction; across boundaries effects flow through domain events (eventual consistency). Repository and unit-of-work lifetimes for these aggregates are specified in the sibling SPEC-DDD document (scoped per request — see the component lifetime map).
ขอบเขต transaction ที่เกี่ยวกับมุมมองนี้ จาก dataModeling.aggregates ใน graph ภายในขอบเขต invariant ที่ระบุ commit แบบ atomic ใน database transaction เดียว; ข้ามขอบเขตผลไหลผ่าน domain event (eventual consistency) lifetime ของ repository และ unit of work ของ aggregate เหล่านี้กำหนดในเอกสาร SPEC-DDD พี่น้อง (scoped ต่อคำขอ — ดูผัง lifetime ของ component)
| Aggregate root | Membersสมาชิก | Context | Transaction ruleกติกา transaction |
|---|---|---|---|
| Contractor | Contractor · ServiceOffering · Machine | work_dispatch | Profile, offerings and machines mutate under the contractor's verification status; rating_avg/rating_count are denormalized from Review events (eventual).โปรไฟล์ บริการ และเครื่องจักรแก้ภายใต้สถานะการยืนยันของผู้รับเหมา; rating_avg/rating_count denormalize จาก Review event (eventual) |
| ServiceRequest | ServiceRequest · ServiceQuote | service_marketplace | Awarding sets awarded_quote_id and flips winning/losing quote statuses in one transaction.การมอบงานตั้ง awarded_quote_id และสลับสถานะ quote ที่ชนะ/แพ้ใน transaction เดียว |
| WorkOrder | WorkOrder · WorkAssignment · ServicePayment | work_dispatch | Transitions follow the work-order state machine; escrow state changes commit with the order status; verified completion gates review eligibility (FR-55).เปลี่ยนสถานะตาม state machine ของ work order; สถานะ escrow commit พร้อมสถานะงาน; การจบงานที่ยืนยันแล้วเป็นเงื่อนไขให้รีวิวได้ (FR-55) |
| Review | Review | reputation | One review per work order; reply/status only after creation.หนึ่งรีวิวต่อ work order; ตอบกลับ/สถานะแก้ได้หลังสร้างเท่านั้น |
| Endorsement | Endorsement | reputation | One endorsement per endorser per contractor per season; revocation is a status change.หนึ่งการรับรองต่อผู้รับรองต่อผู้รับเหมาต่อฤดู; การถอนเป็นการเปลี่ยนสถานะ |
| LedgerAccount | LedgerAccount | books | Per-tenant chart row; system_flag accounts are template-seeded and rename-only.แถวผังบัญชีราย tenant; บัญชี system_flag seed จาก template แก้ได้เฉพาะชื่อ |
| JournalEntry | JournalEntry | books | Every entry balances (Σ debit = Σ credit inside lines) — validated before commit; corrections are reversals (reversal_of), never edits; auto-posts are idempotent per source (NFR-24).ทุก entry ดุล (Σ เดบิต = Σ เครดิตใน lines) — ตรวจก่อน commit; การแก้ไขคือการกลับรายการ (reversal_of) ไม่ใช่การแก้; การลงอัตโนมัติ idempotent ต่อแหล่ง (NFR-24) |
| Rev | Dateวันที่ | Changeการเปลี่ยนแปลง |
|---|---|---|
| 1.0 | 2026-07-08 | Initial document — renders the contractor perspective from spec-graph v5.0 (PROP-004 accepted): 12 owned entities, marketplace/dispatch/reputation/books relationships, changed shared entities.ฉบับแรก — เรนเดอร์มุมมองผู้รับเหมาจาก spec-graph v5.0 (PROP-004 อนุมัติ): entity ที่เป็นเจ้าของ 12 ตัว ความสัมพันธ์ตลาด/จัดงาน/ชื่อเสียง/บัญชี และ entity ใช้ร่วมที่เปลี่ยน |
| 1.1 | 2026-07-08 | PROP-005 (FED, spec v6.0): perspective re-keyed from customer group to capacity (document code unchanged); identity defers to the federation context (Person · Tenant · TenantCapacity · Membership); every *_tenant_type + *_tenant_id pair collapses to tenant_id.PROP-005 (FED, spec (สเปก) v6.0): มุมมองเปลี่ยนคีย์จากกลุ่มลูกค้าเป็น capacity (รหัสเอกสารคงเดิม); อัตลักษณ์อ้างอิงบริบท federation (Person · Tenant · TenantCapacity · Membership); คู่ *_tenant_type + *_tenant_id ทั้งหมดยุบเป็น tenant_id |
| 1.2 | 2026-07-09 | PROP-010 (GL, spec v9.0): the contractor's books grow into a full financial system — shares the new ChartTemplate / Invoice / Receipt / PaymentVoucher / CashAccount / BankTransaction / Reconciliation / FiscalPeriod / FinancialStatement (mill-owned reference); joins receivables/cash_management (WF-36 · WF-40); the payer side of ServicePayment now auto-posts uniformly (NFR-24…26).PROP-010 (GL, spec v9.0): books ของผู้รับเหมาขยายเป็นระบบการเงินเต็ม — ใช้ร่วม ChartTemplate / Invoice / Receipt / PaymentVoucher / CashAccount / BankTransaction / Reconciliation / FiscalPeriod / FinancialStatement (อ้างอิงมุมมองโรงงาน); เข้าร่วม receivables/cash_management (WF-36 · WF-40); ด้านผู้จ่ายของ ServicePayment ลงอัตโนมัติอย่างเป็นหนึ่งเดียว (NFR-24…26) |
| 1.3 | 2026-07-10 | PROP-011 (GL, spec v12.0): the contractor shares BooksProfile — default unified edition (P&L-first), upgradeable to split via the books_split entitlement; edition/view are packaging over the same ledger (NFR-32).PROP-011 (GL, spec v12.0): ผู้รับเหมาใช้ร่วม BooksProfile — ตั้งต้นรุ่น unified (เน้นงบกำไรขาดทุน) อัปเกรดเป็น split ผ่านสิทธิ์ books_split; รุ่น/มุมมองเป็นการจัดแพ็กเกจบนบัญชีเดียวกัน (NFR-32) |
| 0.1.0 | 2026-07-11 | PROP-014 (spec v0.1.0): semantic versioning restarted at 0.1.0 (was Rev 1.3 · 2026-07-10); docnav updated for the gov_cluster split — GOV re-homed to docs/gov/ocsb/, new BOARD (กอน.) sibling added.PROP-014 (spec v0.1.0): รีสตาร์ท semantic versioning ที่ 0.1.0 (เดิม Rev 1.3 · 2026-07-10); ปรับ docnav ตามการแยก gov_cluster — ย้าย GOV ไป docs/gov/ocsb/ เพิ่มพี่น้อง BOARD (กอน.) |
| 0.2.0 | 2026-07-13 | PROP-018 (spec v0.4.0): comprehensive perspective data modeling — scoped entity-relationship diagrams (Fig. 1–2), column-level persistence profiles for the 10 home entities (Section 6), keys / indexes / mutability & PDPA classes (Section 7) and aggregate consistency boundaries (Section 8) — all rendered from the graph's new dataModeling block.PROP-018 (spec v0.4.0): การ model ข้อมูลรายมุมมองฉบับครบ — แผนภาพความสัมพันธ์ entity เฉพาะมุมมอง (ภาพที่ 1–2), persistence profile ระดับ column ของ entity ที่ home อยู่ฉบับนี้ 10 รายการ (ข้อ 6), key / index / ชั้น mutability และ PDPA (ข้อ 7) และขอบเขตความสอดคล้องของ aggregate (ข้อ 8) ทั้งหมด render จาก block ใหม่ dataModeling ใน graph |
| 0.3.0 | 2026-07-23 | PROP-047 (spec v0.19.0): Contractor.base_province re-typed text → smallint carrying the Province enum code (TIS 1099-2548); registry in the shared kernel, CHECK generated from the enum — no reference table / FK / seed. Index (base_province, verified_status) unchanged in shape; the service_area jsonb array carries enum codes, not names.PROP-047 (spec v0.19.0): Contractor.base_province เปลี่ยนชนิดจาก text → smallint เก็บรหัส enum Province (มอก. 1099-2548); ทะเบียนอยู่ใน shared kernel, CHECK generate จาก enum — ไม่มีตารางอ้างอิง / FK / seed index (base_province, verified_status) รูปทรงเดิม; array แบบ jsonb ของ service_area เก็บรหัส enum ไม่ใช่ชื่อ |
| 0.4.0 | 2026-08-03 | PROP-073 (spec v0.47.0): one word — Tenant. Party → Tenant, party_id (and every prefixed form) → tenant_id, PartyCapacity/PartyQualification/PartyFounded → Tenant*, party context/switcher → tenant context/switcher, cross-party → cross-tenant, organisation → organization, and ผู้เล่น retired as the Thai gloss (the Latin word tenant instead, R-THAI). Hold list untouched: counterparty · third party · tripartite working group · Person*/person_id; display codes and token claims were held by R-NULL for one release and then MOVED at v0.47.1 on client decision (C-1), because no token has ever been SIGNED — no auth exists in the built ocsb/ocsf prototypes — and the only printed codes were eight fixture strings in apps/ocsf/fund-shell.jsx, swept in the same pass: PTY- → TNT-, TCA- → TCA-, TQL- → TQL-, claim tnt → tnt, claim dep → dep. Carried in the same pass: the PROP-075 rectification — the retired directory noun domain becomes department (A-82 R-ONETREE) and the dangling A-86/A-87/A-88 citations are re-pointed at the ids they were actually given, A-81/A-82/A-83.PROP-073 (spec v0.47.0): คำเดียว — Tenant Party → Tenant, party_id ทุกรูป → tenant_id, PartyCapacity/PartyQualification/PartyFounded → Tenant*, cross-party → cross-tenant และเลิกใช้ ผู้เล่น เป็นคำแทนวัตถุนี้ในภาษาไทย (ใช้คำละติน tenant ตาม R-THAI) รายการห้ามแตะไม่ถูกแตะ: คู่สัญญา · third party · คณะทำงานไตรภาคี · Person*/person_id รอบเดียวกันแก้ค้างจาก PROP-075: domain → department (A-82) และแก้การอ้าง A-86/A-87/A-88 ที่ไม่มีอยู่จริงเป็น A-81/A-82/A-83 |
| 0.4.1 | 2026-08-03 | PROP-073 PATCH 1 (spec v0.47.1 / v0.47.2 / v0.47.3 as applicable): the identifiers v0.47.0 had held, moved on client decision. PTY-######## → TNT-######## · PCA-######## → TCA-######## · PQL-######## → TQL-######## · token claim pty → tnt · token claim dom → dep (v0.47.1, C-1 — R-NULL had held them as a stored VALUE and a wire format; reversed because no token has ever been signed and the only printed codes were fixture strings). quota_org_officer → quota_officer · lead_org_officer → lead_officer (v0.47.2, C-2 — org is organization abbreviated, not a resemblance). The retired role LABEL swept as a phrase family and quota organization naming the tenant → quota group / กลุ่มโควตา (v0.47.3). All retired forms are in the FR-396 crosswalk and refused in new text by NFR-142.PROP-073 PATCH 1 (spec v0.47.1 / v0.47.2 / v0.47.3 ตามที่เกี่ยวข้อง): ตัวระบุที่ v0.47.0 คงไว้ ถูกย้ายตามการตัดสินของลูกค้า PTY- → TNT- · PCA- → TCA- · PQL- → TQL- · claim pty → tnt · claim dom → dep (v0.47.1, C-1) · quota_org_officer → quota_officer · lead_org_officer → lead_officer (v0.47.2, C-2) · ป้ายชื่อบทบาทที่เลิกใช้และ องค์กรโควตา ที่เรียก tenant → กลุ่มโควตา (v0.47.3) ทุกรูปที่เลิกใช้อยู่ในตารางแปลง FR-396 |