値オブジェクト定義 / Value Objects
エンティティではないが、ドメイン上重要な意味を持つ不変の値の型定義。値オブジェクトは同一性 (ID) を持たず、値の等価性で比較される。
Money(金額)
製造業の金額計算で最も頻出する値オブジェクト。
interface Money {
/** 金額 (税抜) */
amount: number;
/** 消費税率 (例: 0.10) */
taxRate: number;
/** 通貨コード (ISO 4217) — 現行は JPY 固定 */
currency: "JPY";
}| 業務用語 | English | 使用箇所 |
|---|---|---|
| 見積金額 | Quotation Amount | Quotation.totalAmount |
| 検収金額 | Inspection Amount | DeliveryInspection.inspectionAmount |
| 発注単価 | Purchase Price | PurchaseOrder.unitPrice |
| 労務費 | Labour Cost | WorkReport.amount |
| 売掛残高 | AR Balance | ARBalance.billingAmount |
| 買掛残高 | AP Balance | APBalance.payableAmount |
ルール
- 金額計算は整数 (円単位) で行う。小数は最終表示時のみ
- 税込金額 = `amount` × (1 + `taxRate`)、端数処理は `RoundingPolicy` に従う
- 金額の加減算は同一通貨でのみ許可
Quantity(数量)
interface Quantity {
interface Quantity {
/** 数値 */
value: number;
/** 単位 (個, kg, m, 式, etc.) */
unit: string;
}| 業務用語 | English | 使用箇所 |
|---|---|---|
| 発注数 | Order Quantity | PurchaseOrder |
| 受入数 | Received Quantity | GoodsReceipt |
| 製作数 | Production Quantity | ProductionInstruction |
ルール
- 異なる単位間の演算は禁止 (型レベルで防止)
- 単位はテナントの区分マスタ (classifications) から取得
DateRange(期間)
interface DateRange {
interface DateRange {
/** 開始日 (inclusive) */
from: Date;
/** 終了日 (inclusive) */
to: Date;
}| 業務用語 | English | 使用箇所 |
|---|---|---|
| 請求期間 | Billing Period | ARBalance |
| 支払期間 | Payment Period | APBalance |
| 作業期間 | Work Period | ProductionInstruction |
ルール
- `from` <= `to` (不変条件)
- 期間の重複チェック: `a.overlaps(b)` = `a.from <= b.to && b.from <= a.to`
Address(住所)
interface Address {
interface Address {
/** 郵便番号 (ハイフンなし 7桁) */
postalCode: string;
/** 都道府県 */
prefecture: string;
/** 市区町村 */
city: string;
/** 番地 */
street: string;
/** 建物名・部屋番号 */
building?: string;
}| 業務用語 | English | 使用箇所 |
|---|---|---|
| 得意先住所 | Customer Address | Customer |
| 仕入先住所 | Supplier Address | Supplier |
| 納入先住所 | Delivery Address | DeliveryInspection |
PersonName(人名)
interface PersonName {
interface PersonName {
/** 姓 */
familyName: string;
/** 名 */
givenName: string;
/** 姓カナ */
familyNameKana: string;
/** 名カナ */
givenNameKana: string;
}ルール
- 表示順: `familyName` + `givenName` (日本語の姓名順)
- カナはカタカナで格納 (ソート用)
PhoneNumber(電話番号)
interface PhoneNumber {
interface PhoneNumber {
/** 電話番号 (ハイフンなし) */
value: string;
/** 種別 */
type: "office" | "mobile" | "fax";
}PaymentMethod(支払方法)
入金・支払の決済手段。得意先向け (入金方法) と仕入先向け (支払方法) で共通の型。
type PaymentMethod =
| "cash" // 現金
| "bank_transfer" // 銀行振込
| "check" // 小切手
| "bill" // 手形
| "offset" // 相殺
| "credit_card" // クレジットカード
| "fee" // 手数料
| "discount" // 値引き
| "prepayment" // 前払い
| "other"; // その他BillingCalculationMethod(請求計算区分)
請求金額の集計方法。得意先マスタで設定。
type BillingCalculationMethod = "per_line" | "aggregated";ExpenseCategory(費目区分)
仕入・原価計算の費目分類。テナントごとにマスタ設定。
interface ExpenseCategory {
/** 費目コード */
code: string;
/** 費目名 */
name: string;
/** 大分類: 材料費 / 外注費 / 経費 */
majorCategory: "material" | "outsourcing" | "overhead";
}SupplierClassification(仕入先区分)
仕入先の取引種別を分類する値オブジェクト。
type SupplierClassification =
| "purchaser" // 購入先 — 部材・部品の仕入
| "delivery_dest" // 納入先 — 直送先
| "subcontractor" // 外注 — 加工・製作の委託先
| "unclassified" // 未分類
| "sg_and_a" // 販売管理費 — 間接費計上用
| "internal"; // 社内部署 — 内部振替用ProcurementItemType(手配品区分)
手配品の種類を区分する値オブジェクト。
type ProcurementItemType =
| "material" // 材料
| "component" // 部品
| "purchased_item" // 購入品
| "outsourced"; // 外注InternalProcessCategory(社内工程区分)
社内作業の工程分類。労務費の原価集計に使用。
interface InternalProcessCategory {
code: string;
name: string;
}POOutputMethod(注文書出力方法)
注文書 (発注書) の送付方法。仕入先マスタで設定。
type POOutputMethod = "paper" | "fax" | "email" | "none";ClosingDayType(締日区分)
月次締め処理の締日パターン。得意先・仕入先マスタで設定。
interface ClosingDayType {
/** 締日 (1-31, 31 = 末日) */
day: number;
}PaymentTiming(支払サイト)
支払実行月のオフセット。仕入先マスタの支払条件として設定。
type PaymentTiming =
| "current_month" // 当月
| "next_month" // 翌月
| "two_months" // 翌々月
| "three_months"; // 翌々々月StatusTransition(ステータス遷移)
interface StatusTransition<S extends string> {
interface StatusTransition<S extends string> {
/** 遷移前 */
from: S;
/** 遷移後 */
to: S;
/** 遷移日時 */
transitionedAt: Date;
/** 操作者 */
actorId: string;
/** 遷移理由 (任意) */
reason?: string;
}