{
    "table_name": "products",
    "display_name": "商品マスタ",
    "description": "商品情報管理",
    "type": "relational_table",
    "supported_modes": [
        "insert",
        "update",
        "delete"
    ],
    "import_behavior": "all_or_nothing",
    "key_fields": [
        "product_code"
    ],
    "required_fields": [
        "stock_control_type",
        "stock_output_type",
        "is_active"
    ],
    "unique_fields": {
        "product_code": {
            "message": "商品コード「{value}」は既に使用されています",
            "table": "products",
            "column": "product_code",
            "allow_null": false
        }
    },
    "csv_format_example": {
        "description": "商品マスタCSVテンプレート（新規/更新/削除共通）",
        "headers": [
            "商品コード", "品番/規格", "商品名", "商品名索引", "商品名略称", "英語商品名", "JANコード",
            "商品区分", "セット品区分", "オープンフラグ", "粗利計算用単価変更可能フラグ", "在庫管理区分", "在庫表出力区分", "有効フラグ",
            "大分類名", "中分類名", "小分類名", "細分類名",
            "上代", "下代", "粗利算出用単価", "付属原価", "参考売価",
            "デフォルト在庫場所コード", "適正在庫数", "発注点",
            "消費税区分(販売)", "消費税区分(購買)", "税率カテゴリ",
            "本体サイズ-横(W)", "本体サイズ-高さ(H)", "本体サイズ-奥行(D)", "本体サイズ-重量(g)",
            "PKGサイズ-横(W)", "PKGサイズ-高さ(H)", "PKGサイズ-奥行(D)", "PKGサイズ-重量(g)",
            "小箱サイズ-横(W)", "小箱サイズ-高さ(H)", "小箱サイズ-奥行(D)", "小箱サイズ-重量(g)",
            "大箱サイズ-横(W)", "大箱サイズ-高さ(H)", "大箱サイズ-奥行(D)", "大箱サイズ-重量(g)",
            "容器包装_紙重量", "容器包装_プラ重量",
            "小箱入数", "大箱入数", "カートン入数", "商品性格", "販売予定日", "廃番日",
            "ロケーション(1F)", "ロケーション(3Fﾊﾞﾗ)", "ロケーション(3Fｶｰﾄﾝ)",
            "サービス項目", "GTカタログ掲載", "欠品入荷処理中",
            "終了商品フラグ", "賞味期限期間(月数)", "後継品商品名", "アイテムオプション", "備考", "販路"
        ],
        "sample_data": [
            ["#", "※この行と次の説明行は削除してからインポートしてください", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "【新規登録】商品コード, 在庫管理区分, 在庫表出力区分, 有効フラグ が必須", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "【更新】商品コード + 更新したい列のみ残し、不要な列は削除してください（空欄はNULLで更新されます）", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "【削除】商品コードのみでOK", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "---【区分値の説明】---", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "商品区分: 1=通常商品, 2=BE品, 3=部品", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "セット品区分: 1=単品, 2=セット品", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "オープンフラグ: 1=定価有り, 2=オープンプライス", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "在庫管理区分: 1=在庫管理する, 2=在庫管理しない", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "在庫表出力区分: 1=出力する, 2=出力しない", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "有効フラグ: 1=有効, 9=無効", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "粗利計算用単価変更可能フラグ: 1=変更可, 2=変更不可", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "消費税区分(販売/購買): 0=計算しない, 1=課税, 2=非課税, 3=不課税", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "税率カテゴリ: 0=標準税率, 1=軽減税率, 2=旧税率, 9=その他", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "サービス項目: 1=ON, 2=OFF", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "GTカタログ掲載: 1=掲載商品, 2=非掲載", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "欠品入荷処理中: 1=通常, 2=入荷処理中", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "終了商品フラグ: 1=通常, 2=終了商品", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["#", "日付形式: YYYY-MM-DD (例: 2025-04-01)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            ["00004151", "GT-501", "サンプル商品A", "サンプル", "サンプルA", "SAMPLE A", "4901234567890", "1", "1", "1", "2", "1", "1", "1", "ライト", "LED", "充電式", "", "1000", "500", "450", "100", "980", "W001", "100", "50", "1", "1", "0", "50.0", "30.0", "20.0", "200", "55.0", "35.0", "25.0", "250", "60.0", "40.0", "30.0", "300", "65.0", "45.0", "35.0", "350", "10.5", "5.3", "10", "20", "30", "高性能", "2025-04-01", "", "A-01", "B-02", "C-03", "2", "1", "1", "12", "", "オプション情報", "メモ"],
            ["00004878", "GT-502", "サンプル商品B", "", "", "", "", "1", "1", "", "", "2", "1", "1", "", "", "", "", "2000", "1000", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
        ]
    },
    "code_padding": {
        "product_code": 8
    },
    "foreign_key_mappings": {
        "category_lv1_name": {
            "target_field": "category_lv1_id",
            "reference_table": "categories",
            "reference_key_column": "category_name",
            "reference_value_column": "id",
            "reference_condition": "level = 1 AND is_active = 1",
            "required": false,
            "error_message": "指定された大分類名「{value}」が分類マスタ（レベル1）に存在しないか、無効な状態です。正しい大分類名を確認してください。"
        },
        "category_lv2_name": {
            "target_field": "category_lv2_id",
            "reference_table": "categories",
            "reference_key_column": "category_name",
            "reference_value_column": "id",
            "reference_condition": "level = 2 AND is_active = 1",
            "required": false,
            "error_message": "指定された中分類名「{value}」が分類マスタ（レベル2）に存在しないか、無効な状態です。正しい中分類名を確認してください。"
        },
        "category_lv3_name": {
            "target_field": "category_lv3_id",
            "reference_table": "categories",
            "reference_key_column": "category_name",
            "reference_value_column": "id",
            "reference_condition": "level = 3 AND is_active = 1",
            "required": false,
            "error_message": "指定された小分類名「{value}」が分類マスタ（レベル3）に存在しないか、無効な状態です。正しい小分類名を確認してください。"
        },
        "category_lv4_name": {
            "target_field": "category_lv4_id",
            "reference_table": "categories",
            "reference_key_column": "category_name",
            "reference_value_column": "id",
            "reference_condition": "level = 4 AND is_active = 1",
            "required": false,
            "error_message": "指定された細分類名「{value}」が分類マスタ（レベル4）に存在しないか、無効な状態です。正しい細分類名を確認してください。"
        },
        "default_unit_id": {
            "target_field": "default_unit_id",
            "reference_table": "units",
            "reference_key_column": "id",
            "reference_value_column": "id",
            "required": false,
            "error_message": "指定された単位ID「{value}」が単位マスタに存在しません。正しい単位IDを確認してください。"
        },
        "default_warehouse_code": {
            "target_field": "default_warehouse_id",
            "reference_table": "warehouses",
            "reference_key_column": "warehouse_code",
            "reference_value_column": "id",
            "required": false,
            "error_message": "指定された倉庫コード「{value}」が倉庫マスタに存在しません。正しい倉庫コードを確認してください。"
        },
        "business_type_name": {
            "target_field": "business_type_id",
            "reference_table": "business_types",
            "reference_key_column": "business_type_name",
            "reference_value_column": "id",
            "reference_condition": "is_active = 1",
            "required": false,
            "error_message": "指定された販路（業態名）「{value}」が業態マスタに存在しないか、無効な状態です。正しい業態名を確認してください。"
        }
    },
    "field_labels": {
        "id": "ID",
        "product_code": "商品コード",
        "product_type": "商品区分",
        "set_type": "セット品区分",
        "is_custom_name_allowed": "諸口区分",
        "jan_code": "JANコード",
        "product_name": "商品名",
        "product_name_kana": "商品名(ｶﾅ)",
        "product_spec": "品番/規格",
        "product_name_en": "英語商品名",
        "product_name_index": "商品名 索引",
        "product_name_abbr": "商品名 略称",
        "category_lv1_id": "大分類ID",
        "category_lv2_id": "中分類ID",
        "category_lv3_id": "小分類ID",
        "category_lv4_id": "細分類ID",
        "category_lv1_name": "大分類名",
        "category_lv2_name": "中分類名",
        "category_lv3_name": "小分類名",
        "category_lv4_name": "細分類名",
        "open_price_flag": "オープンフラグ",
        "list_price": "上代",
        "cost_price": "下代",
        "profit_calc_price": "粗利算出用単価",
        "accessory_cost_price": "付属原価",
        "reference_price": "参考売価",
        "carton_quantity": "カートン入数",
        "inner_case_quantity": "小箱入数",
        "outer_case_quantity": "大箱入数",
        "product_character": "商品性格",
        "stock_control_type": "在庫管理区分",
        "stock_output_type": "在庫表出力区分",
        "default_warehouse_id": "デフォルト在庫場所ID",
        "default_warehouse_code": "デフォルト在庫場所コード",
        "business_type_id": "販路ID",
        "business_type_name": "販路",
        "location_1f": "ロケーション(1F)",
        "location_3f_unit": "ロケーション(3Fﾊﾞﾗ)",
        "location_3f_carton": "ロケーション(3Fｶｰﾄﾝ)",
        "sales_start_date": "販売予定日",
        "discontinued_date": "廃番日",
        "is_end_of_sale": "終了商品フラグ",
        "successor_product_name": "後継品商品名",
        "default_unit_id": "デフォルト単位ID",
        "sales_tax_type": "消費税区分(販売)",
        "purchase_tax_type": "消費税区分(購買)",
        "rate_category": "税率カテゴリ",
        "expiration_months": "賞味期限期間(月数)",
        "body_width": "本体サイズ-横(W)",
        "body_height": "本体サイズ-高さ(H)",
        "body_depth": "本体サイズ-奥行(D)",
        "body_weight": "本体サイズ-重量(g)",
        "pkg_width": "PKGサイズ-横(W)",
        "pkg_height": "PKGサイズ-高さ(H)",
        "pkg_depth": "PKGサイズ-奥行(D)",
        "pkg_weight": "PKGサイズ-重量(g)",
        "inner_case_width": "小箱サイズ-横(W)",
        "inner_case_height": "小箱サイズ-高さ(H)",
        "inner_case_depth": "小箱サイズ-奥行(D)",
        "inner_case_weight": "小箱サイズ-重量(g)",
        "outer_case_width": "大箱サイズ-横(W)",
        "outer_case_height": "大箱サイズ-高さ(H)",
        "outer_case_depth": "大箱サイズ-奥行(D)",
        "outer_case_weight": "大箱サイズ-重量(g)",
        "package_weight_paper": "容器包装_紙重量",
        "package_weight_plastic": "容器包装_プラ重量",
        "reorder_point": "発注点",
        "proper_stock_quantity": "適正在庫数",
        "is_service_item": "サービス項目",
        "is_gt_catalog": "GTカタログ掲載",
        "is_backorder_processing": "欠品入荷処理中",
        "item_options": "アイテムオプション",
        "is_shipping_fee_editable": "粗利計算用単価変更可能フラグ",
        "is_active": "有効フラグ",
        "note": "備考",
        "created_by": "登録者ID",
        "updated_by": "更新者ID",
        "created_at": "登録日",
        "updated_at": "更新日",
        "deleted_at": "削除日"
    },
    "field_types": {
        "id": "bigint",
        "product_code": "varchar",
        "product_type": "int",
        "set_type": "int",
        "is_custom_name_allowed": "int",
        "jan_code": "varchar",
        "product_name": "varchar",
        "product_name_kana": "varchar",
        "product_spec": "varchar",
        "product_name_en": "varchar",
        "product_name_index": "varchar",
        "product_name_abbr": "varchar",
        "category_lv1_id": "bigint",
        "category_lv2_id": "bigint",
        "category_lv3_id": "bigint",
        "category_lv4_id": "bigint",
        "category_lv1_name": "varchar",
        "category_lv2_name": "varchar",
        "category_lv3_name": "varchar",
        "category_lv4_name": "varchar",
        "open_price_flag": "int",
        "list_price": "decimal",
        "cost_price": "decimal",
        "profit_calc_price": "decimal",
        "accessory_cost_price": "decimal",
        "reference_price": "decimal",
        "carton_quantity": "int",
        "inner_case_quantity": "int",
        "outer_case_quantity": "int",
        "product_character": "varchar",
        "stock_control_type": "int",
        "stock_output_type": "int",
        "default_warehouse_id": "bigint",
        "default_warehouse_code": "varchar",
        "business_type_id": "bigint",
        "business_type_name": "varchar",
        "location_1f": "varchar",
        "location_3f_unit": "varchar",
        "location_3f_carton": "varchar",
        "sales_start_date": "date",
        "discontinued_date": "date",
        "is_end_of_sale": "int",
        "successor_product_name": "varchar",
        "default_unit_id": "bigint",
        "sales_tax_type": "int",
        "purchase_tax_type": "int",
        "rate_category": "int",
        "expiration_months": "int",
        "body_width": "decimal",
        "body_height": "decimal",
        "body_depth": "decimal",
        "body_weight": "decimal",
        "pkg_width": "decimal",
        "pkg_height": "decimal",
        "pkg_depth": "decimal",
        "pkg_weight": "decimal",
        "inner_case_width": "decimal",
        "inner_case_height": "decimal",
        "inner_case_depth": "decimal",
        "inner_case_weight": "decimal",
        "outer_case_width": "decimal",
        "outer_case_height": "decimal",
        "outer_case_depth": "decimal",
        "outer_case_weight": "decimal",
        "package_weight_paper": "decimal",
        "package_weight_plastic": "decimal",
        "reorder_point": "decimal",
        "proper_stock_quantity": "decimal",
        "is_service_item": "int",
        "is_gt_catalog": "int",
        "is_backorder_processing": "int",
        "item_options": "varchar",
        "is_shipping_fee_editable": "int",
        "is_active": "int",
        "note": "varchar",
        "created_by": "bigint",
        "updated_by": "bigint",
        "created_at": "timestamp",
        "updated_at": "timestamp",
        "deleted_at": "timestamp"
    },
    "enum_values": {
        "product_type": {
            "1": "通常商品",
            "2": "BE品",
            "3": "部品"
        },
        "set_type": {
            "1": "単品",
            "2": "セット品"
        },
        "is_custom_name_allowed": {
            "1": "通常",
            "2": "諸口"
        },
        "open_price_flag": {
            "1": "定価有り",
            "2": "オープンプライス"
        },
        "stock_control_type": {
            "1": "在庫管理する",
            "2": "在庫管理しない"
        },
        "stock_output_type": {
            "1": "出力する",
            "2": "出力しない"
        },
        "sales_tax_type": {
            "0": "計算しない",
            "1": "課税",
            "2": "非課税",
            "3": "不課税"
        },
        "purchase_tax_type": {
            "0": "計算しない",
            "1": "課税",
            "2": "非課税",
            "3": "不課税"
        },
        "rate_category": {
            "0": "標準税率",
            "1": "軽減税率",
            "2": "旧税率",
            "9": "その他"
        },
        "is_service_item": {
            "1": "ON",
            "2": "OFF"
        },
        "is_gt_catalog": {
            "1": "掲載商品",
            "2": "非掲載"
        },
        "is_backorder_processing": {
            "1": "通常",
            "2": "入荷処理中"
        },
        "is_shipping_fee_editable": {
            "1": "変更可",
            "2": "変更不可"
        },
        "is_active": {
            "1": "有効",
            "9": "無効"
        },
        "is_end_of_sale": {
            "1": "通常",
            "2": "終了商品"
        }
    },
    "validation_rules": {
        "product_code": {
            "max_length": 40
        },
        "jan_code": {
            "max_length": 20,
            "pattern": "^\\d{8}$|^\\d{13}$",
            "message": "JANコードは8桁または13桁の数字で入力してください。入力値：「{value}」"
        },
        "product_name": {
            "max_length": 200
        },
        "product_name_kana": {
            "max_length": 200
        },
        "product_spec": {
            "max_length": 200
        },
        "product_name_en": {
            "max_length": 200
        },
        "product_name_index": {
            "max_length": 200
        },
        "product_name_abbr": {
            "max_length": 200
        },
        "product_character": {
            "max_length": 100
        },
        "stock_control_type": {
            "required": true,
            "enum": [
                1,
                2
            ]
        },
        "stock_output_type": {
            "required": true,
            "enum": [
                1,
                2
            ]
        },
        "location_1f": {
            "max_length": 100
        },
        "location_3f_unit": {
            "max_length": 100
        },
        "location_3f_carton": {
            "max_length": 100
        },
        "sales_start_date": {
            "date_format": "Y-m-d"
        },
        "discontinued_date": {
            "date_format": "Y-m-d"
        },
        "product_type": {
            "enum": [
                1,
                2,
                3
            ]
        },
        "set_type": {
            "enum": [
                1,
                2
            ]
        },
        "is_custom_name_allowed": {
            "enum": [
                1,
                2
            ]
        },
        "open_price_flag": {
            "enum": [
                1,
                2
            ]
        },
        "sales_tax_type": {
            "enum": [
                0,
                1,
                2,
                3
            ]
        },
        "purchase_tax_type": {
            "enum": [
                0,
                1,
                2,
                3
            ]
        },
        "rate_category": {
            "enum": [
                0,
                1,
                2,
                9
            ]
        },
        "is_service_item": {
            "enum": [
                1,
                2
            ]
        },
        "is_gt_catalog": {
            "enum": [
                1,
                2
            ]
        },
        "is_backorder_processing": {
            "enum": [
                1,
                2
            ]
        },
        "is_shipping_fee_editable": {
            "enum": [
                1,
                2
            ]
        },
        "is_active": {
            "required": true,
            "enum": [
                1,
                9
            ]
        },
        "is_end_of_sale": {
            "enum": [
                1,
                2
            ]
        },
        "successor_product_name": {
            "max_length": 500
        },
        "item_options": {
            "max_length": 500
        },
        "note": {
            "max_length": 500
        }
    }
}