{
    "table_name": "inventory_lots",
    "display_name": "ロット在庫マスタ",
    "description": "商品のロット別在庫情報管理（食品商品の賞味期限管理含む）",
    "is_active": false,
    "_comment": "在庫ロットテーブルは直接インポートではなく、inventory_adjustment/inventory_transfer経由で管理するため非表示",
    "type": "relational_table",
    "supported_modes": [
        "insert",
        "update",
        "delete"
    ],
    "key_fields": [
        "id"
    ],
    "required_fields": [
        "product_id"
    ],
    "unique_fields": {},
    "foreign_key_mappings": {
        "product_code": {
            "target_field": "product_id",
            "reference_table": "products",
            "reference_key_column": "product_code",
            "reference_value_column": "id",
            "required": true,
            "error_message": "指定された商品コード「{value}」が商品マスタに存在しません。正しい商品コードを確認してください。"
        },
        "warehouse_code": {
            "target_field": "warehouse_id",
            "reference_table": "warehouses",
            "reference_key_column": "warehouse_code",
            "reference_value_column": "id",
            "required": false,
            "error_message": "指定された倉庫コード「{value}」が倉庫マスタに存在しません。正しい倉庫コードを確認してください。"
        }
    },
    "code_padding": {
        "product_code": 8,
        "warehouse_code": 3
    },
    "composite_key_handling": {
        "update_mode": "primary_key_only",
        "delete_mode": "primary_key_only",
        "primary_key_field": "id"
    },
    "field_labels": {
        "id": "ID",
        "product_id": "商品ID",
        "product_code": "商品コード",
        "lot_number": "ロット番号",
        "expiration_date": "賞味期限",
        "warehouse_id": "倉庫ID",
        "warehouse_code": "倉庫コード",
        "quantity": "現在庫数量",
        "quantity_unit": "現在庫数量(バラ数)",
        "quantity_carton": "現在庫数量(カートン数)",
        "received_date": "最終入庫日",
        "created_by": "登録者ID",
        "updated_by": "更新者ID",
        "created_at": "登録日",
        "updated_at": "更新日",
        "deleted_at": "削除日"
    },
    "field_types": {
        "id": "bigint",
        "product_id": "bigint",
        "product_code": "varchar",
        "lot_number": "varchar",
        "expiration_date": "date",
        "warehouse_id": "bigint",
        "warehouse_code": "varchar",
        "quantity": "decimal",
        "quantity_unit": "decimal",
        "quantity_carton": "decimal",
        "received_date": "date",
        "created_by": "bigint",
        "updated_by": "bigint",
        "created_at": "timestamp",
        "updated_at": "timestamp",
        "deleted_at": "timestamp"
    },
    "enum_values": {},
    "validation_rules": {
        "product_id": {
            "required": true,
            "exists": {
                "table": "products",
                "column": "id"
            }
        },
        "lot_number": {
            "max_length": 40
        },
        "expiration_date": {
            "date_format": "Y/m/d",
            "message": "賞味期限の形式が正しくありません。「YYYY/MM/DD」の形式で入力してください。入力値：「{value}」"
        },
        "warehouse_id": {
            "exists": {
                "table": "warehouses",
                "column": "id"
            }
        },
        "quantity": {
            "numeric": true,
            "min": 0,
            "message": "現在庫数量は0以上の数値で入力してください。入力値：「{value}」"
        },
        "quantity_unit": {
            "numeric": true,
            "min": 0
        },
        "quantity_carton": {
            "numeric": true,
            "min": 0
        },
        "received_date": {
            "date_format": "Y/m/d",
            "message": "最終入庫日の形式が正しくありません。「YYYY/MM/DD」の形式で入力してください。入力値：「{value}」"
        }
    },
    "business_rules": {
        "lot_management": {
            "description": "食品商品（product_type=2 かつ stock_control_type=1）の場合、賞味期限（expiration_date）とロット番号（lot_number）の設定を推奨",
            "validation": "conditional"
        },
        "non_lot_management": {
            "description": "非食品商品の場合、expiration_date=NULL、lot_number=NULLで登録",
            "validation": "conditional"
        },
        "quantity_calculation": {
            "description": "quantity_unit と quantity_carton から quantity（バラ換算数）を自動計算する場合がある",
            "validation": "optional"
        }
    },
    "import_notes": {
        "lot_products": "食品商品（BE品）の場合、必ず賞味期限を設定してください",
        "non_lot_products": "非食品商品の場合、賞味期限は空白またはNULLにしてください",
        "warehouse_default": "倉庫コードが未指定の場合、商品マスタのデフォルト倉庫が使用されます",
        "quantity_required": "現在庫数量（quantity）は必須です。0以上の数値を入力してください"
    }
}