{
  "display_name": "汎用受注データ",
  "description": "様々なEDI・ECサイトからの受注データを統合インポート（角田、ヨドバシ、トラスコ、BEAM、ECAM対応）",
  "processor_class": "App\\Services\\Logic\\User\\CsvImport\\Processors\\GenericOrderProcessor",
  "business_key_field": "business_key",
  "header_table": "order_headers",
  "detail_table": "order_details",
  "header_fields": {
    "business_key": {
      "label": "グループID（同一伝票キー）",
      "type": "string",
      "required": true,
      "max_length": 50,
      "validation_rules": [
        "required",
        "string",
        "max:50"
      ],
      "description": "明細をまとめるグルーピングキー。同じ値の行が1つの受注（伝票）として登録されます"
    },
    "customer_code": {
      "label": "得意先コード",
      "type": "string",
      "required": true,
      "max_length": 20,
      "validation_rules": [
        "required",
        "string",
        "max:20"
      ],
      "description": "得意先を識別するコード"
    },
    "customer_name": {
      "label": "得意先名",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "得意先名称"
    },
    "order_date": {
      "label": "受注日",
      "type": "date",
      "required": true,
      "format": "Y-m-d",
      "validation_rules": [
        "required",
        "date"
      ],
      "description": "受注が発生した日付"
    },
    "shipment_date": {
      "label": "出荷予定日",
      "type": "date",
      "required": false,
      "format": "Y-m-d",
      "validation_rules": [
        "date"
      ],
      "description": "出荷予定日"
    },
    "delivery_date": {
      "label": "到着予定日",
      "type": "date",
      "required": false,
      "format": "Y-m-d",
      "validation_rules": [
        "date"
      ],
      "description": "到着予定日"
    },
    "reserve_deadline_date": {
      "label": "仮押さえ期限",
      "type": "date",
      "required": false,
      "format": "Y-m-d",
      "validation_rules": [
        "date"
      ],
      "description": "引当の仮押さえ期限。空欄可"
    },
    "delivery_code": {
      "label": "配送先コード",
      "type": "string",
      "required": false,
      "max_length": 20,
      "validation_rules": [
        "string",
        "max:20"
      ],
      "description": "得意先内の配送先コード。指定するとその配送先で登録。空欄の場合は得意先のデフォルト配送先（配送先名＋電話番号があればそれで検索/新規作成）"
    },
    "delivery_name": {
      "label": "配送先名",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "配送先名称"
    },
    "delivery_postal_code": {
      "label": "配送先郵便番号",
      "type": "string",
      "required": false,
      "max_length": 7,
      "validation_rules": [
        "string",
        "max:7"
      ],
      "description": "配送先の郵便番号"
    },
    "delivery_prefecture": {
      "label": "配送先都道府県",
      "type": "string",
      "required": false,
      "max_length": 20,
      "validation_rules": [
        "string",
        "max:20"
      ],
      "description": "配送先の都道府県"
    },
    "delivery_address1": {
      "label": "配送先住所1",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "配送先の住所1"
    },
    "delivery_address2": {
      "label": "配送先住所2",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "配送先の住所2"
    },
    "delivery_tel": {
      "label": "配送先電話番号",
      "type": "string",
      "required": false,
      "max_length": 20,
      "validation_rules": [
        "string",
        "max:20"
      ],
      "description": "配送先の電話番号"
    },
    "warehouse_code": {
      "label": "倉庫コード",
      "type": "string",
      "required": false,
      "max_length": 20,
      "validation_rules": [
        "string",
        "max:20"
      ],
      "description": "出荷元倉庫コード"
    },
    "allocation_policy": {
      "label": "引当ポリシー",
      "type": "integer",
      "required": false,
      "validation_rules": [
        "integer",
        "in:1,3,4,5"
      ],
      "description": "引当ポリシー（1:通常, 3:仮押さえ1週間, 4:カタログ・仮押さえ, 5:仮押さえ名入れ）。空欄の場合は1:通常"
    },
    "logistics_note": {
      "label": "物流備考",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "物流に関する備考"
    },
    "invoice_note": {
      "label": "送り状メモ",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "送り状に記載するメモ"
    },
    "delivery_note": {
      "label": "納品書メモ",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "納品書に記載するメモ"
    },
    "shipping_type": {
      "label": "発送区分",
      "type": "string",
      "required": false,
      "max_length": 50,
      "validation_rules": [
        "string",
        "max:50"
      ],
      "description": "発送区分（1_発送等）"
    },
    "sender_type": {
      "label": "荷送人区分",
      "type": "integer",
      "required": false,
      "validation_rules": [
        "integer",
        "in:1,2"
      ],
      "description": "荷送人区分（1:指定なし, 2:指定あり）"
    },
    "sender_name": {
      "label": "荷送人名",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "荷送人名称"
    },
    "sender_postal_code": {
      "label": "荷送人郵便番号",
      "type": "string",
      "required": false,
      "max_length": 10,
      "validation_rules": [
        "string",
        "max:10"
      ],
      "description": "荷送人の郵便番号"
    },
    "sender_prefecture": {
      "label": "荷送人都道府県",
      "type": "string",
      "required": false,
      "max_length": 20,
      "validation_rules": [
        "string",
        "max:20"
      ],
      "description": "荷送人の都道府県"
    },
    "sender_address1": {
      "label": "荷送人住所1",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "荷送人の住所1"
    },
    "sender_address2": {
      "label": "荷送人住所2",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "荷送人の住所2"
    },
    "sender_address3": {
      "label": "荷送人住所3",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "荷送人の住所3"
    },
    "sender_tel": {
      "label": "荷送人TEL",
      "type": "string",
      "required": false,
      "max_length": 20,
      "validation_rules": [
        "string",
        "max:20"
      ],
      "description": "荷送人の電話番号"
    },
    "sender_fax": {
      "label": "荷送人FAX",
      "type": "string",
      "required": false,
      "max_length": 20,
      "validation_rules": [
        "string",
        "max:20"
      ],
      "description": "荷送人のFAX番号"
    }
  },
  "detail_fields": {
    "product_code": {
      "label": "商品コード",
      "type": "string",
      "required": true,
      "max_length": 40,
      "validation_rules": [
        "required",
        "string",
        "max:40"
      ],
      "description": "商品を識別するコード"
    },
    "product_name": {
      "label": "商品名",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "商品名称"
    },
    "order_qty": {
      "label": "受注数量",
      "type": "decimal",
      "required": true,
      "min_value": 0.001,
      "validation_rules": [
        "required",
        "numeric",
        "min:0.001"
      ],
      "description": "受注数量"
    },
    "unit_price": {
      "label": "単価",
      "type": "decimal",
      "required": false,
      "min_value": 0,
      "validation_rules": [
        "numeric",
        "min:0"
      ],
      "description": "販売単価。空欄の場合は通常の単価決定（得意先・商品マスタから自動取得＝単価区分「通常」）で受注入力画面と同じ挙動になります。金額を入力した場合はカスタム（手入力）単価として登録されます"
    },
    "amount": {
      "label": "金額",
      "type": "decimal",
      "required": false,
      "min_value": 0,
      "validation_rules": [
        "numeric",
        "min:0"
      ],
      "description": "明細金額（数量×単価）"
    },
    "tax_type": {
      "label": "消費税区分",
      "type": "integer",
      "required": false,
      "validation_rules": [
        "integer",
        "in:1,2,3"
      ],
      "description": "消費税区分（1:課税, 2:軽減税率, 3:非課税）"
    },
    "description": {
      "label": "説明",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "明細の説明（受注入力画面の「説明」欄に対応）"
    },
    "note": {
      "label": "明細備考",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "明細の備考（受注入力画面の「備考」欄に対応）"
    },
    "catalog_number": {
      "label": "カタログNo.",
      "type": "string",
      "required": false,
      "max_length": 40,
      "validation_rules": [
        "string",
        "max:40"
      ],
      "description": "カタログNo."
    },
    "allocation_type": {
      "label": "在庫確保",
      "type": "string",
      "required": false,
      "max_length": 50,
      "validation_rules": [
        "string",
        "max:50"
      ],
      "description": "在庫引当区分（受注入力画面の「在庫引当」に対応）。1=確保する, 2=確保しない(欠品)。空欄の場合は1=確保する。在庫不足時は自動で欠品(確保しない)となります"
    },
    "order_number": {
      "label": "注文番号",
      "type": "string",
      "required": false,
      "max_length": 200,
      "validation_rules": [
        "string",
        "max:200"
      ],
      "description": "注文番号"
    }
  },
  "foreign_key_mappings": {
    "customer_code": {
      "reference_table": "customers",
      "reference_key_column": "customer_code",
      "reference_value_column": "id",
      "required": true,
      "error_message": "指定された得意先コードが存在しません"
    },
    "product_code": {
      "reference_table": "products",
      "reference_key_column": "product_code",
      "reference_value_column": "id",
      "required": true,
      "error_message": "指定された商品コードが存在しません"
    },
    "warehouse_code": {
      "reference_table": "warehouses",
      "reference_key_column": "warehouse_code",
      "reference_value_column": "id",
      "required": false,
      "strict_validation": true,
      "error_message": "指定された倉庫コードが存在しません"
    }
  },
  "code_padding": {
    "customer_code": 6,
    "product_code": 8,
    "warehouse_code": 3
  },
  "business_rules": {
    "delivery_date_validation": {
      "rule": "delivery_date >= order_date",
      "error_message": "到着予定日は受注日以降である必要があります"
    },
    "quantity_validation": {
      "rule": "order_qty > 0",
      "error_message": "受注数量は0より大きい値である必要があります"
    },
    "amount_validation": {
      "rule": "amount >= 0",
      "error_message": "金額は0以上である必要があります"
    }
  },
  "csv_format_example": {
    "description": "グループID（同一伝票キー）をキーとして、様々な形式のCSVに対応。角田、ヨドバシ、トラスコ、BEAM、ECAMの各形式をサポート。同じグループIDの行が1つの受注（伝票）としてまとまります",
    "headers": [
      "グループID（同一伝票キー）",
      "得意先コード",
      "得意先名",
      "受注日",
      "出荷予定日",
      "到着予定日",
      "仮押さえ期限",
      "配送先コード",
      "配送先名",
      "配送先郵便番号",
      "配送先都道府県",
      "配送先住所1",
      "配送先住所2",
      "配送先電話番号",
      "倉庫コード",
      "引当ポリシー",
      "物流備考",
      "送り状メモ",
      "納品書メモ",
      "発送区分",
      "荷送人区分",
      "荷送人名",
      "荷送人郵便番号",
      "荷送人都道府県",
      "荷送人住所1",
      "荷送人住所2",
      "荷送人住所3",
      "荷送人TEL",
      "荷送人FAX",
      "商品コード",
      "商品名",
      "受注数量",
      "単価",
      "金額",
      "消費税区分",
      "説明",
      "明細備考",
      "カタログNo.",
      "在庫確保",
      "注文番号"
    ],
    "sample_data": [
      ["#", "※この行と次の行は削除してからインポートしてください。【必須】: グループID, 得意先コード, 受注日, 商品コード, 受注数量 ／ グループID=同じ値の行を1つの受注（伝票）にまとめます ／ 伝票番号は自動採番されます", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
      ["#", "単価: 空欄→通常の単価決定（マスタから自動取得） / 金額入力→カスタム（手入力）単価 ／ 配送先コード: 空欄なら得意先のデフォルト配送先 ／ 在庫確保(在庫引当): 1=確保する,2=確保しない(欠品)（空欄=確保する。在庫不足時は自動で欠品(確保しない)となります） ／ 引当ポリシー: 1=通常,3=仮押さえ1週間,4=カタログ・仮押さえ,5=仮押さえ名入れ（空欄=通常） ／ 荷送人区分: 1=指定なし,2=指定あり ／ 消費税区分: 1=課税,2=軽減税率,3=非課税 ／ 日付形式: YYYY/MM/DD または YYYY-MM-DD", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
      ["20241223K1", "002220", "角田無線電機株式会社", "2024/12/23", "2024/12/23", "2024/12/25", "", "", "", "", "", "", "", "", "001", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "SNM-H132D", "ジェントス LEDヘッドライト", "1", "897", "897", "1", "", "", "", "1", "ORD-001"],
      ["20241223K2", "002220", "角田無線電機株式会社", "2024/12/23", "2024/12/23", "2024/12/25", "", "", "", "", "", "", "", "", "001", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "GH-118RG", "ジェントス LEDライト", "2", "", "", "1", "", "", "", "1", "ORD-001"]
    ]
  },
  "supported_formats": {
    "角田": {
      "description": "角田無線電機からのEDIデータ",
      "key_fields": [
        "外部ID",
        "得意先",
        "品  番",
        "アイテム",
        "数量",
        "単価/率"
      ]
    },
    "ヨドバシ": {
      "description": "ヨドバシカメラからのEDIデータ",
      "key_fields": [
        "外部ID",
        "得意先",
        "配送先",
        "商品コード",
        "アイテム",
        "数量",
        "単価"
      ]
    },
    "トラスコ": {
      "description": "トラスコ中山からのEDIデータ",
      "key_fields": [
        "外部ID",
        "顧客プロジェクト",
        "アイテム",
        "数量",
        "単価"
      ]
    },
    "BEAM": {
      "description": "BEAMからのECサイトデータ",
      "key_fields": [
        "外部ID",
        "得意先",
        "配送先",
        "アイテム",
        "数量",
        "単価"
      ]
    },
    "ECAM": {
      "description": "ECAMからのECサイトデータ",
      "key_fields": [
        "外部ID",
        "得意先",
        "配送先",
        "アイテム",
        "数量",
        "単価"
      ]
    }
  }
}