{
  "display_name": "角田EDI発注データ",
  "description": "角田からの発注情報CSVを直接インポート",
  "processor_class": "App\\Services\\Logic\\User\\CsvImport\\Processors\\KakutaOrderProcessor",
  "business_key_field": "department_no",
  "header_table": "order_headers",
  "detail_table": "order_details",
  "encoding": "SJIS-win",
  "has_header": true,
  "headers": [
    "発注部№",
    "発注№",
    "納品先",
    "納品場所",
    "発注者名",
    "商品コード",
    "仕入先№",
    "品番",
    "発注数",
    "単価",
    "金額",
    "状態",
    "発注日時",
    "有効期限",
    "納品指定日",
    "コメント",
    "伝票NO．",
    "伝票日付",
    "納品数",
    "伝票単価"
  ],
  "header_fields": {
    "department_no": {
      "label": "発注部№",
      "csv_column": 0,
      "type": "string",
      "required": true,
      "description": "グルーピングキー（business_key）として使用"
    },
    "delivery_destination": {
      "label": "納品先",
      "csv_column": 2,
      "type": "string",
      "required": true,
      "description": "得意先特定用コード（設定ファイルでcustomer_idに変換）"
    },
    "delivery_date_short": {
      "label": "納品指定日",
      "csv_column": 14,
      "type": "string",
      "required": false,
      "description": "YYMMDD形式の短縮日付（例: 260121 → 2026-01-21）"
    }
  },
  "detail_fields": {
    "order_number": {
      "label": "発注№",
      "csv_column": 1,
      "type": "string",
      "required": true,
      "max_length": 200,
      "validation_rules": [
        "required",
        "string",
        "max:200"
      ],
      "description": "伝票内明細識別用"
    },
    "jan_code": {
      "label": "商品コード",
      "csv_column": 5,
      "type": "string",
      "required": true,
      "validation_rules": [
        "required",
        "string"
      ],
      "description": "JANコードから商品ID特定"
    },
    "product_code_ref": {
      "label": "品番",
      "csv_column": 7,
      "type": "string",
      "required": false,
      "description": "参照用品番（マッチング失敗時の参考情報）"
    },
    "order_qty": {
      "label": "発注数",
      "csv_column": 8,
      "type": "integer",
      "required": true,
      "min": 1,
      "validation_rules": [
        "required",
        "integer",
        "min:1"
      ],
      "description": "受注数量"
    },
    "unit_price": {
      "label": "単価",
      "csv_column": 9,
      "type": "decimal",
      "required": true,
      "validation_rules": [
        "required",
        "numeric",
        "min:0"
      ],
      "description": "販売単価"
    }
  },
  "business_rules": {
    "jan_code_resolution": {
      "rule": "resolve_by_jan_code",
      "description": "JANコードから商品IDを解決。stock_output_type=1かつis_active=1の商品を検索",
      "on_not_found": "validation_error",
      "on_multiple": "step3_4_selection"
    },
    "customer_resolution": {
      "rule": "resolve_by_config",
      "config_file": "edi_kakuta.php",
      "config_key": "delivery_destination_to_customer_code",
      "description": "CSV納品先コードをedi_kakuta.php設定ファイルで得意先コードに変換"
    },
    "delivery_resolution": {
      "rule": "default_delivery",
      "description": "特定した得意先のデフォルト配送先（is_default=1）を採用"
    },
    "date_conversion": {
      "rule": "short_date_to_standard",
      "format": "YYMMDD",
      "description": "YYMMDD形式の短縮日付をYYYY-MM-DD形式に変換（2000年代として解釈）"
    },
    "arrival_date_calculation": {
      "rule": "auto_calculate",
      "base_date": "shipment_date",
      "method": "Assist::addLeadtimeDays",
      "description": "出荷日+リードタイム（休日考慮）で到着日を自動計算"
    },
    "quantity_validation": {
      "rule": "order_qty > 0",
      "error_message": "発注数は1以上である必要があります"
    }
  },
  "default_values": {
    "warehouse_code": "001",
    "warehouse_code_description": "東日本物流",
    "allocation_policy": 1,
    "allocation_policy_description": "通常",
    "enclosed_slip_type": "納品書",
    "enclosed_slip_type_description": "varchar文字列",
    "allocation_type": 1,
    "allocation_type_description": "完了量",
    "order_date": "TODAY",
    "order_date_description": "処理日",
    "shipment_date": "TODAY",
    "shipment_date_description": "処理日"
  },
  "csv_format_example": {
    "description": "角田発注情報CSVの直接インポート。発注部№でグルーピングし、JANコードで商品特定",
    "headers": [
      "発注部№",
      "発注№",
      "納品先",
      "納品場所",
      "発注者名",
      "商品コード",
      "仕入先№",
      "品番",
      "発注数",
      "単価",
      "金額",
      "状態",
      "発注日時",
      "有効期限",
      "納品指定日",
      "コメント",
      "伝票NO．",
      "伝票日付",
      "納品数",
      "伝票単価"
    ],
    "sample_data": [
      [
        "18",
        "A3678424",
        "18",
        "川崎",
        "角田みゆき",
        "4950654052992",
        "78",
        "HLP-2503",
        "10",
        "4452",
        "44520",
        "午後作成",
        "09:43.0",
        "999999",
        "260121",
        "",
        "",
        "0",
        "",
        ""
      ],
      [
        "18",
        "A3678425",
        "18",
        "川崎",
        "角田みゆき",
        "4950654050608",
        "78",
        "TX-3000R",
        "5",
        "6930",
        "34650",
        "午後作成",
        "10:00.0",
        "999999",
        "260121",
        "",
        "",
        "0",
        "",
        ""
      ],
      [
        "46",
        "46B41362",
        "46",
        "関東エリア",
        "某有名人J",
        "4950654039795",
        "78",
        "UT-618SB",
        "1",
        "4452",
        "4452",
        "午後作成",
        "39:02.0",
        "270109",
        "0",
        "",
        "",
        "0",
        "",
        ""
      ]
    ]
  },
  "unused_columns": {
    "description": "取り込み対象外のカラム",
    "columns": [
      {
        "index": 3,
        "name": "納品場所",
        "reason": "使用しない"
      },
      {
        "index": 4,
        "name": "発注者名",
        "reason": "使用しない"
      },
      {
        "index": 6,
        "name": "仕入先№",
        "reason": "使用しない"
      },
      {
        "index": 10,
        "name": "金額",
        "reason": "単価×数量で計算"
      },
      {
        "index": 11,
        "name": "状態",
        "reason": "使用しない"
      },
      {
        "index": 12,
        "name": "発注日時",
        "reason": "使用しない"
      },
      {
        "index": 13,
        "name": "有効期限",
        "reason": "使用しない"
      },
      {
        "index": 15,
        "name": "コメント",
        "reason": "使用しない"
      },
      {
        "index": 16,
        "name": "伝票NO．",
        "reason": "使用しない"
      },
      {
        "index": 17,
        "name": "伝票日付",
        "reason": "使用しない"
      },
      {
        "index": 18,
        "name": "納品数",
        "reason": "使用しない"
      },
      {
        "index": 19,
        "name": "伝票単価",
        "reason": "使用しない"
      }
    ]
  }
}
