SPEC-PWF-CEC Rev 0.2.1 · 2026-08-03

Cane Agency · PWF Seriesสถาบันอ้อย · ชุดเอกสาร PWF

Process Workflows — Contractor (ผู้รับเหมา) Perspectiveกระบวนการทำงาน — มุมมองผู้รับเหมา

Documentเอกสาร
SPEC-PWF-CEC
Versionversion (เวอร์ชัน)
0.2.1 · Draftฉบับร่าง
Updatedปรับปรุงล่าสุด
2026-08-03
Parentเอกสารแม่
SPEC-PWF
WorkflowsWorkflow
WF-18…23 + the work-order state machine (Section 8)+ state machine ใบสั่งงาน (ข้อ 8)

1. Scope1. ขอบเขต

Six workflows own the contractor lifecycle from onboarding to books; the work-order state machine (Section 8) is the backbone WF-19…21 run on. Extensions land in existing workflows: WF-05 (settlement gains the settlement_offset ServicePayment), WF-06 (a service credit item may link its delivering work order), WF-13…15 (consent, scoring & origination accept contractor subjects).

workflowหกตัวคุมวงจรชีวิตผู้รับเหมาตั้งแต่ขึ้นทะเบียนถึงบัญชี; state machine ใบสั่งงาน (ข้อ 8) คือกระดูกสันหลังที่ WF-19…21 วิ่งบน ส่วนขยายลงในworkflowเดิม: WF-05 (ปิดงวดเพิ่ม ServicePayment แบบ settlement_offset), WF-06 (รายการสินเชื่อบริการลิงก์ใบสั่งงานได้), WF-13…15 (ความยินยอม การให้คะแนน การออกสินเชื่อ รับผู้ถูกประเมินแบบผู้รับเหมา)

2. WF-18 — Contractor onboarding & service listing2. WF-18 — ขึ้นทะเบียนผู้รับเหมาและลงรายการบริการ

  1. Register as a freelance individual (single account: owner + dispatcher + operator) or found a contractor tenant with a federated hierarchy (owner → dispatchers → operators).
  2. Identity verification → verified_status: id_verified; an affiliated mill/quota service arm registers with the affiliation disclosed on the profile (Q3).
  3. Publish offerings: service type (13-value taxonomy + custom), unit price range, service districts, season window; register machines into the fleet.
  4. The profile enters the directory honestly "new" — no fake stars; endorsements and onboarding missions seed trust within NFR-12.
  5. Freelance→org upgrade at any time: tenant founded, tenant_id set, contractor_id, jobs and ratings carry over (the WF-01 continuity promise).
  1. สมัครแบบฟรีแลนซ์ (บัญชีเดียวสวมทุกหมวก) หรือตั้ง tenant ผู้รับเหมาพร้อมลำดับชั้นสหพันธ์ (เจ้าของ → ผู้จัดคิว → ผู้ปฏิบัติงาน)
  2. ยืนยันตัวตน → verified_status: id_verified; หน่วยบริการในเครือโรงงาน/โควตาลงทะเบียนโดยเปิดเผยสังกัดบนโปรไฟล์ (Q3)
  3. เผยแพร่รายการบริการ: ประเภท (อนุกรมวิธาน 13 ค่า + กำหนดเอง) ช่วงราคาต่อหน่วย อำเภอบริการ ช่วงฤดู; ลงทะเบียนเครื่องจักร
  4. โปรไฟล์เข้าไดเรกทอรีแบบ "ใหม่" ตรงไปตรงมา — ไม่มีดาวปลอม; การรับรองและภารกิจแรกเข้าจุดความเชื่อถือภายใต้ NFR-12
  5. อัปเกรดฟรีแลนซ์→องค์กรได้ทุกเมื่อ: ตั้ง tenant กำหนด tenant_id โดย contractor_id งาน และคะแนนติดตัวไป (คำมั่นความต่อเนื่องแบบ WF-01)

3. WF-19 — Request → quote → award3. WF-19 — ประกาศงาน → เสนอราคา → มอบงาน

  1. A requester (cane farmer · quota farmer · mill) posts a ServiceRequest anchored to a field/crop and time window; matching_mode selects the spine:
  2. rfq — contractors quote; the requester compares price, rating, jobs and endorsements; award accepts one quote and creates the WorkOrder atomically.
  3. direct — booking an offering auto-creates the request with one pre-accepted quote at the listed price (M1).
  4. broadcast (จองด่วน, M2i) — eligible, ready-to-work types only: the job goes to verified contractors in radius at the fixed district reference price; first qualified accept wins; timeout widens the radius and re-broadcasts; no real-time surge, ever.
  5. If payment_method: escrow, the requester funds escrow — the state machine blocks scheduling until funded (Section 8).
  1. ผู้ว่าจ้าง (ลูกไร่ · หัวหน้าโควต้า · โรงงาน) โพสต์ ServiceRequest ยึดแปลง/อ้อยและช่วงเวลา; matching_mode เลือกแกน:
  2. rfq — ผู้รับเหมาเสนอราคา; ผู้ว่าจ้างเทียบราคา คะแนน จำนวนงาน และการรับรอง; การมอบงานตอบรับหนึ่งใบและสร้าง WorkOrder แบบ atomic
  3. direct — การจองรายการบริการสร้างคำขอพร้อมใบเสนอราคาตอบรับล่วงหน้าตามราคาประกาศ (M1)
  4. broadcast (จองด่วน, M2i) — เฉพาะงานประเภทพร้อมทำ: กระจายถึงผู้รับเหมายืนยันแล้วในรัศมีด้วยราคาอ้างอิงรายอำเภอคงที่; รายแรกที่ผ่านเกณฑ์ได้งาน; หมดเวลาแล้วขยายรัศมีกระจายซ้ำ; ไม่มี surge เรียลไทม์เด็ดขาด
  5. หาก payment_method: escrow ผู้ว่าจ้างเติมเงิน escrow — state machine ห้ามจัดคิวจนกว่า funded (ข้อ 8)

4. WF-20 — Dispatch & field execution4. WF-20 — จัดคิวและปฏิบัติงานภาคสนาม

  1. The dispatcher schedules the order on the calendar and issues WorkAssignments — operator + optional machine per assignment; freelancers self-assign.
  2. The crew app runs the field day: GPS check-in (en_route → working), photos, quantities — every entry appends to the immutable work_log.
  3. Completion hand-off → the requester verifies against the evidence (walk-the-field, or weigh-ticket-assisted for harvest/haulage).
  4. Verification cascades: payment release · review eligibility · FarmActivity auto-log (activity_type mapped from service_type, editable — Q7) · books posting.
  5. Decline branches to the dispute path: escrow frozen, platform_admin mediates on the work_log (Q5), resolution verifies (possibly partial) or cancels with full refund; no-show posts a strike and re-broadcasts instant jobs at the same price.
  1. ผู้จัดคิววางงานบนปฏิทินและออก WorkAssignment — ผู้ปฏิบัติงาน + เครื่องจักร (ถ้ามี) ต่อการมอบหมาย; ฟรีแลนซ์มอบหมายตนเอง
  2. แอป crew คุมวันทำงาน: เช็กอิน GPS (en_route → working) รูปถ่าย ปริมาณ — ทุกรายการต่อท้าย work_log ที่แก้ไม่ได้
  3. ส่งมอบงาน → ผู้ว่าจ้างตรวจรับเทียบหลักฐาน (เดินแปลง หรืออิงบัตรชั่งสำหรับงานตัด/ขนส่ง)
  4. การตรวจรับส่งผลต่อเนื่อง: ปล่อยเงิน · สิทธิ์รีวิว · บันทึก FarmActivity อัตโนมัติ (แมป activity_type จาก service_type แก้ได้ — Q7) · ลงบัญชี
  5. ไม่ผ่านเข้าเส้นทางพิพาท: escrow แช่แข็ง platform_admin ไกล่เกลี่ยบน work_log (Q5) ผลคือตรวจรับ (อาจบางส่วน) หรือยกเลิกคืนเงินเต็ม; งานเบี้ยวถูกบันทึกโทษและงานด่วนกระจายซ้ำที่ราคาเดิม

5. WF-21 — Service payment5. WF-21 — การชำระค่าบริการ

  1. escrow — funded at award, held through execution, released minus fee_amount (the only commissioned rail) on verification; refunded in full on cancellation.
  2. cash_recorded — recorded for record completeness, never processed, never charged.
  3. credit_financed — a เงินเกี๊ยว CreditItem pays the contractor up front; CreditItem.work_order_id closes the money↔work loop; recovery at settlement per WF-06.
  4. settlement_offset — the deduction on a settled PaymentItem posts the ServicePayment (WF-05 extension); ordering joins the PROP-003 Q4 priority stack.
  5. Every rail ends in ServicePaymentPosted → books auto-posting and the dispatch earnings view.
  1. escrow — เติมตอนมอบงาน พักระหว่างทำ ปล่อยหัก fee_amount (ช่องทางเดียวที่มีคอมมิชชัน) เมื่อตรวจรับ; คืนเต็มเมื่อยกเลิก
  2. cash_recorded — บันทึกเพื่อความครบของบันทึก ไม่ประมวลผล ไม่คิดค่าธรรมเนียม
  3. credit_financed — รายการเงินเกี๊ยวจ่ายผู้รับเหมาล่วงหน้า; CreditItem.work_order_id ปิดวงจรเงิน↔งาน; หักคืนตอนปิดงวดตาม WF-06
  4. settlement_offset — การหักบน PaymentItem ที่ปิดงวดบันทึก ServicePayment (ส่วนขยาย WF-05); ลำดับเข้ากอง Q4 ของ PROP-003
  5. ทุกช่องทางจบที่ ServicePaymentPosted → ลงบัญชีอัตโนมัติและหน้ารายได้ใน dispatch

6. WF-22 — Rating, review & endorsement6. WF-22 — คะแนน รีวิว และการรับรอง

  1. On verification the requester may publish exactly one review — completion / quality / timeliness, 1–5 each; the mean stores as score_overall (NFR-10).
  2. The contractor may post one public reply; reviews are append-only; flags route to platform_admin (removal logged, reason mandatory).
  3. Mills and quota farmers grant or withdraw Endorsements — institutional trust shown as a profile badge, feeding verified_status: endorsed.
  4. Aggregates recompute onto the Contractor record and feed marketplace ranking — which is never for sale (NFR-12).
  1. เมื่อตรวจรับ ผู้ว่าจ้างเผยแพร่รีวิวได้หนึ่งรายการ — ความสำเร็จ / คุณภาพ / ตรงเวลา อย่างละ 1–5; ค่าเฉลี่ยเก็บเป็น score_overall (NFR-10)
  2. ผู้รับเหมาตอบกลับสาธารณะได้หนึ่งครั้ง; รีวิวต่อท้ายเท่านั้น; การแจ้งลบส่งถึง platform_admin (ลบพร้อมบันทึกเหตุผล)
  3. โรงงานและหัวหน้าโควต้าให้/ถอนการรับรอง — ความเชื่อถือเชิงสถาบันเป็นตราบนโปรไฟล์ ป้อน verified_status: endorsed
  4. ค่าสรุปคำนวณใหม่ลงเรกคอร์ด Contractor และป้อนอันดับตลาด — ซึ่งไม่มีวันขาย (NFR-12)

7. WF-23 — Contractor books7. WF-23 — สมุดบัญชีผู้รับเหมา

  1. Onboarding seeds the preset chart of accounts (system accounts locked).
  2. WorkVerified auto-posts revenue + receivable; ServicePaymentPosted settles per rail — an escrow release nets the commission straight to expense.
  3. Crews quick-add expenses at job completion (fuel, meals — receipt photo); dispatch adds wages, maintenance, insurance.
  4. Reports: P&L per period / season / service line; machine profitability from line-level machine tags; simple cash flow; accountant-ready export (P2).
  5. Statements reach a bank only through a ConsentGrant carrying the books scope — never bundled (feeds WF-13…15).
  6. PROP-010 (v9.0): books widen into a full financial system — WF-36 seeds/opens the period, WF-38 adds AR/AP invoices & vouchers, WF-39 reconciles bank lines, WF-40 closes the period and issues P&L / balance sheet / trial balance / cash flow snapshots; the payer side of every ServicePayment now auto-posts uniformly (NFR-24).
  1. การขึ้นทะเบียนสร้างผังบัญชีสำเร็จรูป (บัญชีระบบล็อก)
  2. WorkVerified ลงรายได้ + ลูกหนี้อัตโนมัติ; ServicePaymentPosted ล้างตามช่องทาง — การปล่อย escrow หักคอมมิชชันเข้าค่าใช้จ่ายทันที
  3. ชุดงานเพิ่มรายจ่ายด่วนตอนปิดงาน (น้ำมัน อาหาร — ถ่ายใบเสร็จ); dispatch เพิ่มค่าแรง ซ่อมบำรุง ประกัน
  4. รายงาน: งบกำไรขาดทุนรายงวด / ฤดู / สายบริการ; กำไรรายเครื่องจักรจาก tag (แท็ก) รายการ; กระแสเงินสดอย่างง่าย; ไฟล์ส่งนักบัญชี (P2)
  5. งบการเงินถึงธนาคารทางเดียวคือ ConsentGrant ที่มี scope books — ไม่พ่วง scope อื่น (ป้อน WF-13…15)
  6. PROP-010 (v9.0): books ขยายเป็นระบบการเงินเต็ม — WF-36 seed/เปิดงวด, WF-38 เพิ่มใบแจ้งหนี้และใบสำคัญจ่าย AR/AP, WF-39 กระทบยอดธนาคาร, WF-40 ปิดงวดและออก snapshot งบกำไรขาดทุน/งบดุล/งบทดลอง/งบกระแสเงินสด; ด้านผู้จ่ายของทุก ServicePayment ลงอัตโนมัติเป็นหนึ่งเดียว (NFR-24)

8. The work-order state machine8. State machine ใบสั่งงาน

Normative in the graph (workOrderStateMachine). Parallels — never replaces — the delivery, crop and loan machines.

บรรทัดฐานอยู่ใน graph (กราฟ) (workOrderStateMachine) ทำงานคู่ขนาน — ไม่แทนที่ — state machine การส่งมอบ อ้อย และสินเชื่อ

From → Toจาก → ถึงEventเหตุการณ์Guardเงื่อนไข
awarded → scheduledScheduleSetEscrow gate: if payment_method = escrow, escrow_state must be funded; crew/machine capacity available.ประตู escrow: หากชำระแบบ escrow ต้อง funded; ชุดงาน/เครื่องจักรว่าง
awarded → cancelledCancelBefore dispatch only; funded escrow refunds in full; instant no-show posts a strike + re-broadcast at the same price.ก่อนจัดคิวเท่านั้น; escrow ที่เติมแล้วคืนเต็ม; งานด่วนเบี้ยวถูกบันทึกโทษ + กระจายซ้ำราคาเดิม
scheduled → dispatchedWorkDispatchedAssignments issued to operators (crew app).ออกการมอบหมายถึงผู้ปฏิบัติงาน (แอป crew)
dispatched → in_progressWorkStartedOperator GPS check-in at the field (work_log).เช็กอิน GPS หน้างาน (work_log)
in_progress → completedWorkCompletedwork_log evidence present; quantities recorded.มีหลักฐาน work_log; บันทึกปริมาณครบ
completed → verifiedWorkVerifiedRequester sign-off — weigh-ticket-assisted for harvest/haulage; gates payment, review, agronomy auto-log, books.ผู้ว่าจ้างตรวจรับ — อิงบัตรชั่งสำหรับงานตัด/ขนส่ง; ประตูการจ่าย รีวิว บันทึกเกษตร บัญชี
completed · verified → disputedWorkDisputedRequester declines with a mandatory reason; escrow frozen (FR-55); pending release halted.ผู้ว่าจ้างปฏิเสธพร้อมเหตุผลบังคับ; escrow แช่แข็ง (FR-55); การปล่อยที่ค้างถูกหยุด
disputed → verified · cancelledDisputeResolvedplatform_admin mediation on work_log evidence (Q5); may verify a partial quantity, or cancel with escrow refunded in full; ratings untouched (NFR-10).platform_admin ไกล่เกลี่ยบนหลักฐาน work_log (Q5); ตรวจรับบางส่วนได้ หรือยกเลิกคืน escrow เต็ม; คะแนนไม่ถูกแตะ (NFR-10)
verified → closedServicePaymentPostedPayment settled on its rail (escrow release − fee · cash recorded · credit item · settlement offset); terminal.ชำระตามช่องทาง (ปล่อย escrow − ค่าธรรมเนียม · บันทึกเงินสด · รายการสินเชื่อ · หักกลบปิดงวด); สถานะสุดท้าย

9. Revision history9. ประวัติการแก้ไข

RevDateวันที่Changeการเปลี่ยนแปลง
1.02026-07-08Initial document — renders the contractor perspective from spec-graph v5.0 (PROP-004 accepted): WF-18…23, WF-05/06/13…15 extensions, the work-order state machine (Section 8).ฉบับแรก — เรนเดอร์มุมมองผู้รับเหมาจาก spec-graph v5.0 (PROP-004 อนุมัติ): WF-18…23 ส่วนขยาย WF-05/06/13…15 และ state machine ใบสั่งงาน (ข้อ 8)
1.12026-07-08PROP-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.22026-07-09PROP-010 (GL, spec v9.0): WF-23 widens — the contractor's books become a full financial system (WF-36 onboarding, WF-38 AR/AP, WF-39 bank reconciliation, WF-40 period close & statements); the payer side of ServicePayment auto-posts uniformly (NFR-24); statements to a bank only via ConsentGrant scope books (NFR-26).PROP-010 (GL, spec v9.0): WF-23 ขยาย — books ของผู้รับเหมาเป็นระบบการเงินเต็ม (WF-36 เริ่มใช้, WF-38 AR/AP, WF-39 กระทบยอดธนาคาร, WF-40 ปิดงวดและงบ); ด้านผู้จ่าย ServicePayment ลงอัตโนมัติเป็นหนึ่งเดียว (NFR-24); งบถึงธนาคารผ่าน ConsentGrant scope books (NFR-26)
0.1.02026-07-11PROP-014 (spec v0.1.0): semantic versioning restarted at 0.1.0 (was Rev 1.2 · 2026-07-09); 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.2 · 2026-07-09); ปรับ docnav ตามการแยก gov_cluster — ย้าย GOV ไป docs/gov/ocsb/ เพิ่มพี่น้อง BOARD (กอน.)
0.2.02026-08-03PROP-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.2.12026-08-03PROP-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