Fab Forward Dev/

DDD ドキュメント

ドメインイベントカタログ / Domain Events

各バウンデッドコンテキストで発生するドメインイベントの一覧。イベント名・トリガー・ペイロード・購読者を定義する。

見積・受注 (Quotation & Order)

イベント名Event Typeトリガー購読者
見積作成quotation.created新規見積を保存— (内部)
見積承認quotation.approved承認者が承認営業CRM (見積回答)
見積改訂quotation.revised改訂番号を発番営業CRM
受注登録order.acceptedPMS に受注を登録外注手配, 製作指示, 営業CRM
受注キャンセルorder.cancelled受注を取消外注手配, 製作指示, 売上, 営業CRM

order.accepted ペイロード

interface OrderAcceptedEvent {
  event_type: "order.accepted";
  correlation_id: string;       // Sales Deal ID
  occurred_at: string;          // ISO 8601
  payload: {
    order_number: string;       // ORDER_NO
    customer_code: string;      // TOKUISAKI_CODE
    due_date: string;           // NOUKI
    line_items: {
      product_code: string;
      quantity: number;
      unit_price: number;
    }[];
    total_amount: number;
  };
  version: 1;
}

外注手配 (Procurement)

イベント名Event Typeトリガー購読者
発注作成purchase_order.created手配データ登録— (内部)
発注発行purchase_order.issued仕入先に注文書送付営業CRM (進捗追跡)
発注完了purchase_order.fulfilled全数入荷完了原価分析

受入 (Goods Receiving)

イベント名Event Typeトリガー購読者
入荷goods.received受入処理完了買掛・支払, 原価分析, 営業CRM
入荷差異goods.discrepancy数量・品質の差異外注手配 (再発注判断)

goods.received ペイロード

interface GoodsReceivedEvent {
  event_type: "goods.received";
  correlation_id: string;
  occurred_at: string;
  payload: {
    order_number: string;
    po_number: string;
    supplier_code: string;
    items: {
      product_code: string;
      quantity_received: number;
      unit_price: number;
    }[];
  };
  version: 1;
}

製作指示・作業日報 (Internal Production)

イベント名Event Typeトリガー購読者
製作指示作成work_order.created製作指示を発行営業CRM
作業着手work_order.started作業員が着手記録営業CRM
作業完了work_order.completed作業完了を記録原価分析, 営業CRM
日報登録work_log.submitted作業日報を提出原価分析

売上・請求 (Sales & Billing)

イベント名Event Typeトリガー購読者
検収完了inspection.passed顧客検収合格原価分析, 営業CRM
検収不合格inspection.failed顧客検収不合格製作指示 (手直し)
出荷order.shipped納品書発行・発送営業CRM
請求発行invoice.issued請求書発行売掛, 営業CRM
入金確認payment.received入金消込完了売掛, 営業CRM

買掛・支払 (Accounts Payable)

イベント名Event Typeトリガー購読者
仕入計上ap_receipt.recorded仕入データ登録買掛
支払実行supplier_payment.executed仕入先への支払完了買掛
買掛締めap_balance.closed期末買掛締め処理

営業CRM (Sales)

イベント名Event Typeトリガー購読者
案件作成deal.created新規案件登録
案件ステージ変更deal.stage_changedパイプラインステージ移動日報
案件受注deal.won案件をクロージング (受注)Integration Contracts
案件失注deal.lost案件をクロージング (失注)
活動記録activity.logged活動 (電話/訪問/メール) 記録取引先メトリクス更新
日報提出daily_report.submitted日報を提出

deal.won ペイロード

interface DealWonEvent {
  event_type: "deal.won";
  occurred_at: string;
  payload: {
    deal_id: string;
    account_id: string;
    customer_code: string;
    line_items: {
      product_code: string;
      quantity: number;
      unit_price: number;
    }[];
    requested_delivery_date: string;
    total_amount: number;
  };
}

共通ヘッダー / Base Interface

interface DomainEventBase {
  event_id: string;           // UUID v7 (時系列ソート可能)
  event_type: string;         // aggregate.verb
  correlation_id: string;     // 業務トランザクション追跡用
  causation_id?: string;      // 原因イベントの event_id
  occurred_at: string;        // ISO 8601
  version: number;            // スキーマバージョン
  metadata: {
    actor_id: string;         // 操作者の employee_code
    source_context: string;   // 発行元コンテキスト名
  };
}