SPEC-DDD-FIN Rev 0.4.1 · 2026-08-03

Cane Agency · Specification · Perspective documentสถาบันอ้อย · เอกสารข้อกำหนด · เอกสารรายมุมมอง

Department Logic — Financial Institution Perspectiveตรรกะโดเมน — มุมมองสถาบันการเงิน

Documentเอกสาร
SPEC-DDD-FIN
Versionversion (เวอร์ชัน)
0.4.1 · Draftฉบับร่าง
Updatedปรับปรุงล่าสุด
2026-08-03
Parentเอกสารแม่
SPEC-DDD
Perspectiveมุมมอง
Financial institution (ธนาคาร)สถาบันการเงิน (ธนาคาร)
Siblingsเอกสารพี่น้อง
SPEC-ERD-FIN · SPEC-PWF-FIN

1. Purpose1. วัตถุประสงค์

This document defines the bank's two bounded contexts — Credit & Risk and Bank Lending — their aggregates and invariants, the events they publish and consume, and the ubiquitous language of regulated cane lending. It mirrors SPEC-DDD and graph/spec-graph.json. Both contexts are strictly downstream readers of the platform core, gated by ConsentGrant (PDPA, NFR-08); every credit decision is reproducible and explainable (NFR-09).

เอกสารนี้นิยามสองบริบทของธนาคาร — Credit & Risk และ Bank Lending — แอกกริเกตและกฎคงที่ เหตุการณ์ที่ผลิตและบริโภค และภาษากลางของการปล่อยกู้อ้อยที่ถูกกำกับ สะท้อน SPEC-DDD และ graph/spec-graph.json ทั้งสองบริบทเป็นผู้อ่านปลายน้ำของแกนกลางอย่างเคร่งครัด กำกับด้วย ConsentGrant (PDPA, NFR-08); ทุกการตัดสินใจสินเชื่อทำซ้ำและอธิบายได้ (NFR-09)

2. Bounded contexts2. ขอบเขตบริบท

ContextบริบทOwnsเป็นเจ้าของResponsibility & relationshipความรับผิดชอบและความสัมพันธ์
Credit & Risk
เครดิตและความเสี่ยง
ConsentGrant · CreditAssessmentA downstream reader of the whole platform core, gated by ConsentGrant. Assembles the consented feature snapshot and produces the cane-specific score consumed by Bank Lending. Owns consent lifecycle and model/decision governance (NFR-08/09).ผู้อ่านปลายน้ำของแกนกลางทั้งหมด กำกับด้วย ConsentGrant ประกอบ snapshot (สแนปช็อต) คุณลักษณะที่ได้รับความยินยอมและผลิตคะแนนเฉพาะอ้อยที่ Bank Lending บริโภค ดูแลวงจรความยินยอมและการกำกับ model (โมเดล)/การตัดสินใจ (NFR-08/09)
Bank Lending
สินเชื่อสถาบันการเงิน
LoanProduct · LoanApplication · LoanAccount · Collateral · LoanLedgerEntryFormal bank lending, separate from เงินเกี๊ยว. Consumes the score from Credit & Risk and the settlement-offset contract from Settlement; produces the loan lifecycle and its append-only ledger. FinancialInstitution is owned by network_identity (as Mill).การปล่อยกู้ธนาคารทางการ แยกจากเงินเกี๊ยว บริโภคคะแนนจาก Credit & Risk และสัญญาการหักกลบจาก Settlement; ผลิตวงจรสินเชื่อและสมุดบัญชีแบบต่อท้าย FinancialInstitution เป็นของ network_identity (เช่นเดียวกับ Mill)

3. Context map — the bank as reader3. แผนที่บริบท — ธนาคารในฐานะผู้อ่าน

corePlatform coreแกนกลางdelivery · quality · quota · repaymentส่งมอบ · คุณภาพ · โควตา · ชำระคืน
→
gateCredit & Riskเครดิตและความเสี่ยงconsent → scoreยินยอม → คะแนน
→
downstreamBank Lendingสินเชื่อoriginate · disburse · repayออก · เบิก · ชำระ
→
contractSettlementการปิดงวดreceivable offsetหักลูกหนี้

4. Aggregates & invariants4. แอกกริเกตและกฎคงที่

Aggregate (root)แอกกริเกต (ราก)ContextบริบทInvariantsกฎคงที่
ConsentGrantCredit & RiskScoped to (grantor × grantee FI × scope) with an expiry; append-only — revocation posts a superseding record; status = active only while now < expires_at and not revoked; a bank read resolves only against an active grant covering the requested scope, and every resolved access is logged (NFR-08).จำกัดขอบเขตต่อ (ผู้ให้ × FI ผู้รับ × scope) พร้อมวันหมดอายุ; ต่อท้ายเท่านั้น — การเพิกถอนบันทึกระเบียนแทนที่; status = active เฉพาะเมื่อ now < expires_at และยังไม่เพิกถอน; ธนาคารอ่านได้เฉพาะเมื่อมีความยินยอมที่ใช้งานครอบคลุม scope และบันทึกทุกการเข้าถึง (NFR-08)
CreditAssessmentCredit & RiskRequires an active ConsentGrant covering the subject; freezes model_ver + factors_snapshot at assessment time (immutable); a re-score posts a new assessment; an approved application must reference one; declines carry decision_reasons (NFR-09).ต้องมี ConsentGrant active ครอบคลุมผู้ถูกประเมิน; ตรึง model_ver + factors_snapshot ณ เวลาประเมิน (แก้ไม่ได้); การให้คะแนนใหม่บันทึกเป็นรายการใหม่; คำขอที่อนุมัติต้องอ้างการประเมิน; การปฏิเสธมี decision_reasons (NFR-09)
LoanApplicationBank LendingCannot enter scoring without a covering ConsentGrant; approved requires an assessment_id and any product-required collateral; status only moves forward; withdrawn/rejected open no account.เข้าสู่ scoring ไม่ได้ถ้าไม่มี ConsentGrant คุ้มครอง; approved ต้องมี assessment_id และหลักประกันที่ผลิตภัณฑ์กำหนด; สถานะเดินหน้าอย่างเดียว; ถอน/ปฏิเสธไม่เปิดบัญชี
LoanAccount (owns LoanLedgerEntry, Collateral)Bank LendingOpened only from an approved application; outstanding_amt is derived from the append-only ledger and never edited; status follows the loan state machine (SPEC-PWF-FIN Section 8) and never skips; a delivery_receivable pledge routes settlement-offset repayments ahead of เงินเกี๊ยว; write-offs post as ledger entries.เปิดจากคำขอที่อนุมัติเท่านั้น; outstanding_amt คำนวณจากสมุดต่อท้ายและไม่แก้ทับ; สถานะเดินตาม state machine สินเชื่อ (SPEC-PWF-FIN ข้อ 8) ไม่ข้ามขั้น; การจำนำ delivery_receivable ส่งการชำระแบบหักกลบก่อนเงินเกี๊ยว; การตัดหนี้สูญบันทึกเป็นรายการบัญชี
LoanProductBank LendingBelongs to one FI; borrower_kinds ⊆ {cane_farmer, quota_farmer, sugar_factory}; principal_min ≤ principal_max; a subsidy scheme is recorded in subsidy_note, never as a separate price.สังกัด FI เดียว; borrower_kinds ⊆ {cane_farmer, quota_farmer, sugar_factory}; principal_min ≤ principal_max; โครงการอุดหนุนบันทึกใน subsidy_note ไม่ใช่ราคาแยก

5. Aggregate boundaries & transaction rules5. ขอบเขต aggregate และกติกา transaction

The normative consistency boundaries of this perspective's home contexts (credit_risk · lending), rendered from graph dataModeling.aggregates (v0.4.0, PROP-018). The prose invariants above stay explanatory; the rules here are the transactional contract an implementation must enforce. Column-level persistence for every member entity lives in the sibling SPEC-ERD family (see the Data column).

ขอบเขตความสอดคล้องเชิงบรรทัดฐานของ context ที่ home อยู่มุมมองนี้ (credit_risk · lending) render จาก dataModeling.aggregates ใน graph (v0.4.0, PROP-018) คำอธิบาย invariant ข้างบนคงไว้เพื่อความเข้าใจ; กติกาในส่วนนี้คือสัญญาเชิง transaction ที่ implementation ต้องบังคับใช้ ส่วน persistence ระดับ column ของ entity สมาชิกทุกตัวอยู่ในตระกูล SPEC-ERD พี่น้อง (ดู column ข้อมูล)

credit_risklendingConsentGrantการให้ความยินยอมแบ่งปันข้อมูลCreditAssessmentการประเมินเครดิตLoanProductผลิตภัณฑ์สินเชื่อLoanApplicationคำขอสินเชื่อCollateralLoanAccountบัญชีสินเชื่อLoanLedgerEntry
Fig. 1 — Consistency boundaries of credit_risk · lending: one box per aggregate — title = root, rows = member entities. Everything inside a box commits in one database transaction; everything between boxes flows through domain events.ภาพที่ 1 — ขอบเขตความสอดคล้องของ credit_risk · lending: หนึ่งกล่องต่อ aggregate — ชื่อกล่อง = root, รายการในกล่อง = entity สมาชิก ทุกอย่างในกล่อง commit ใน database transaction เดียว; ระหว่างกล่องไหลผ่าน domain event
Aggregate rootMembersสมาชิกContextTransaction ruleกติกา transactionDataข้อมูล
ConsentGrantConsentGrantcredit_riskTerms frozen at grant; only status (active → expired/revoked) transitions. Every consent-gated read re-evaluates the grant in-request.เงื่อนไขตรึงตอนให้ความยินยอม; เปลี่ยนได้เฉพาะสถานะ (active → expired/revoked) การอ่านที่ต้องใช้ความยินยอมตรวจ grant ซ้ำทุกคำขอERD-FIN
CreditAssessmentCreditAssessmentcredit_riskImmutable snapshot — factors_snapshot + model_ver make every decision reproducible (NFR-09).snapshot แก้ไขไม่ได้ — factors_snapshot + model_ver ทำให้ทุกการตัดสินใจทำซ้ำได้ (NFR-09)ERD-FIN
LoanProductLoanProductlendingReference root — product terms version by row; live applications pin their product row.root อ้างอิง — เงื่อนไขผลิตภัณฑ์แยกตามแถว; ใบสมัครที่ค้างอยู่ตรึงแถวผลิตภัณฑ์ของตนERD-FIN
LoanApplicationLoanApplication · CollaterallendingDecision transitions freeze the application; application-stage collateral closes with the decision (loan state machine).การตัดสินใจตรึงใบสมัคร; หลักประกันชั้นใบสมัครปิดพร้อมการตัดสินใจ (state machine สินเชื่อ)ERD-FIN
LoanAccountLoanAccount · LoanLedgerEntrylendingoutstanding_amt = principal − Σ repayment entries, updated in the same transaction as each appended entry.outstanding_amt = เงินต้น − Σ รายการชำระ ปรับใน transaction เดียวกับรายการที่ appendERD-FIN

6. Component lifetime map6. ผัง lifetime ของ component

The DI registration contract for this perspective's contexts, from graph dataModeling.lifecycles — vocabulary singleton | scoped (per request / unit of work) | transient (.NET, per the PROP-005 ASP.NET Core foundation). Platform-wide conventions (DbContext, repositories, handlers, caches, hosted jobs) are stated once in SPEC-DDD and bind here unless a row below overrides them; the rows list the notable components an implementation must wire per context.

สัญญาการลงทะเบียน DI ของ context ในมุมมองนี้ จาก dataModeling.lifecycles ใน graph — ใช้ศัพท์ singleton | scoped (ต่อคำขอ / unit of work) | transient (.NET ตามรากฐาน ASP.NET Core ของ PROP-005) กติการวมทั้ง platform (DbContext, repository, handler, cache, hosted job) ประกาศครั้งเดียวใน SPEC-DDD และมีผลที่นี่เว้นแต่แถวด้านล่างกำหนดต่าง; แถวในตารางคือ component สำคัญที่ implementation ต้องต่อสายราย context

credit_risk เครดิตและความเสี่ยง

events producedevent ที่ผลิต ConsentGranted · ConsentRevoked · CreditAssessmentCompleted

ComponentKindชนิดLifetimeRationaleเหตุผล
ConsentGatedepartment_policyscopedRe-evaluates ConsentGrant per request — PDPA NFR-08; never cached across requests.ตรวจ ConsentGrant ซ้ำทุกคำขอ — PDPA NFR-08; ไม่ cache ข้ามคำขอ
ScoringModeldomain_servicesingletonImmutable versioned model (model_ver) — reproducibility NFR-09.model ตรึง version (model_ver) — ทำซ้ำได้ NFR-09
AssessmentSnapshotWriterapp_servicescopedFreezes factors_snapshot with the score.ตรึง factors_snapshot พร้อมคะแนน

lending สินเชื่อสถาบันการเงิน

events producedevent ที่ผลิต LoanApplicationSubmitted · LoanApproved · LoanRejected · LoanDisbursed · DeliveryReceivableAssigned · LoanRepaymentPosted · LoanDelinquent · LoanRestructured · LoanWrittenOff

ComponentKindชนิดLifetimeRationaleเหตุผล
Loan repositoriesrepositoryscoped—
AmortizationCalculatorcalculatortransient—
DisbursementSagaapp_servicescopedAccount opening + first ledger entry atomic; repay_source wiring to PaymentItem offsets.เปิดบัญชี + รายการ ledger แรกแบบ atomic; ต่อสาย repay_source เข้าการหักจาก PaymentItem

7. Domain events7. เหตุการณ์โดเมน

Eventเหตุการณ์Producerผู้ผลิตConsumersผู้บริโภค
ConsentGranted / ConsentRevokedCredit & RiskBank Lending, Finance portal, Mobile app, NotificationsBank Lending, portal สินเชื่อ, แอปมือถือ, การแจ้งเตือน
CreditAssessmentCompletedCredit & RiskBank Lending, Finance portal, ReportsBank Lending, portal สินเชื่อ, รายงาน
LoanApplicationSubmittedBank LendingCredit & Risk, Finance portal
LoanApproved / LoanRejectedBank LendingFinance portal, Mobile app, Notificationsportal สินเชื่อ, แอปมือถือ, การแจ้งเตือน
LoanDisbursedBank LendingSettlement, Mobile app, ReportsSettlement, แอปมือถือ, รายงาน
DeliveryReceivableAssignedBank LendingSettlement, PortalSettlement, portal
LoanRepaymentPostedBank LendingFinance portal, Mobile app, Statementsportal สินเชื่อ, แอปมือถือ, ใบแจ้งยอด
LoanDelinquent / LoanRestructured / LoanWrittenOffBank LendingFinance portal, Reportsportal สินเชื่อ, รายงาน

The core's existing PaymentPosted additionally triggers LoanRepaymentPosted when the settled delivery carries an assigned receivable; PaymentPosted keeps its original contract.

PaymentPosted เดิมของแกนกลางกระตุ้น LoanRepaymentPosted เพิ่มเมื่อการส่งมอบที่ปิดงวดมีการโอนสิทธิลูกหนี้; PaymentPosted คงสัญญาเดิม

8. Ubiquitous language (finance)8. ภาษากลาง (การเงิน)

ThaiไทยEnglishอังกฤษMeaningความหมาย
การให้ความยินยอมconsent grantScoped, time-boxed, revocable authorization (ConsentGrant) to read a tenant's platform data (NFR-08).การอนุญาตที่จำกัดขอบเขต มีอายุ เพิกถอนได้ (ConsentGrant) ในการอ่านข้อมูลของฝ่ายหนึ่ง (NFR-08)
คะแนนเครดิตcredit score / assessmentCane-specific alternative-data score (CreditAssessment); auditable via model_ver + factors_snapshot.คะแนนจากข้อมูลทางเลือกเฉพาะอ้อย (CreditAssessment); ตรวจสอบได้ด้วย model_ver + factors_snapshot
หลักประกันcollateralSecurity for a loan: standing crop, quota, delivery receivable, land, contract, or clean.หลักประกันสินเชื่อ: อ้อยยืนต้น โควตา ลูกหนี้การค้า ที่ดิน สัญญา หรือไม่มีหลักประกัน
ลูกหนี้การค้าdelivery receivableA mill's future PaymentItem pledged as collateral; enables settlement-offset repayment.PaymentItem ในอนาคตของโรงงานที่นำมาจำนำ; ทำให้ชำระคืนแบบหักกลบตอนปิดงวดได้
การหักกลบตอนปิดงวดsettlement offsetRepaying a loan from the deduction on a settled PaymentItem rather than in cash.ชำระสินเชื่อจากการหักใน PaymentItem ที่ปิดงวด แทนเงินสด
หนี้ไม่ก่อให้เกิดรายได้non-performing loan (NPL)A loan impaired after prolonged delinquency; may be restructured or written off.สินเชื่อด้อยคุณภาพหลังค้างชำระนาน; อาจปรับโครงสร้างหรือตัดหนี้สูญ
สินเชื่อห่วงโซ่อุปทานsupply-chain financeA bank LoanAccount that wholesale-funds a mill/quota-org via CreditLine.funding_account_id.LoanAccount ที่ให้ทุนขายส่งแก่โรงงาน/องค์กรโควต้าผ่าน CreditLine.funding_account_id
ธ.ก.ส. · เครดิตบูโร · ธปท.BAAC · NCB · BoTThe rural lender (fi_type state_bank), the credit-history registry, and the central-bank supervisor a lender reports within (F8).ผู้ให้กู้ชนบท (fi_type state_bank), ทะเบียนประวัติเครดิต, และธนาคารกลางผู้กำกับที่ผู้ให้กู้รายงาน (F8)

9. Related documents9. เอกสารที่เกี่ยวข้อง

10. Revision history10. ประวัติการแก้ไข

RevฉบับDateวันที่Changesการเปลี่ยนแปลง
1.02026-07-07Initial version — PROP-003 (spec v4.0): Credit & Risk + Bank Lending contexts, aggregates & invariants, 12 lending events, finance ubiquitous languageฉบับแรก — PROP-003 (spec (สเปก) v4.0): บริบท Credit & Risk + Bank Lending แอกกริเกตและกฎคงที่ เหตุการณ์สินเชื่อ 12 รายการ ภาษากลางการเงิน
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
0.1.02026-07-11PROP-014 (spec v0.1.0): semantic versioning restarted at 0.1.0 (was Rev 1.1 · 2026-07-08); 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.1 · 2026-07-08); ปรับ docnav ตามการแยก gov_cluster — ย้าย GOV ไป docs/gov/ocsb/ เพิ่มพี่น้อง BOARD (กอน.)
0.2.02026-07-13PROP-018 P2 (spec v0.4.0): aggregate map figure + normative aggregate boundaries & transaction rules (Section 5) and the DI component lifetime map (Section 6) for credit_risk · lending — rendered from the graph's dataModeling block (aggregates · lifecycles).PROP-018 P2 (spec v0.4.0): ภาพผัง aggregate + ขอบเขต aggregate และกติกา transaction เชิงบรรทัดฐาน (ข้อ 5) และผัง lifetime ของ component แบบ DI (ข้อ 6) ของ credit_risk · lending — render จาก block dataModeling ใน graph (aggregates · lifecycles)
0.3.02026-07-28PROP-037 applied (spec v0.29.0) — Section 3 gains the reliability-extract rail: scope reliability_score is the single door by which a platform score reaches Credit & Risk, as an aggregate extract, gate-checked per request and logged to the farmer.apply PROP-037 (spec v0.29.0) — ข้อ 3 เพิ่มเส้นทาง reliability extract: scope reliability_score เป็นประตูเดียวที่คะแนนของ platform เข้าสู่ Credit & Risk
0.4.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.4.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