{
  "display_name": "アマゾン受注インポート",
  "description": "アマゾンからの発注情報CSVを直接インポート",
  "processor_class": "App\\Services\\Logic\\User\\CsvImport\\Processors\\AmazonOrderProcessor",
  "business_key_field": "order_number",
  "header_table": "order_headers",
  "detail_table": "order_details",
  "encoding": "SJIS-win",
  "has_header": true,
  "headers": [
    "発注日",
    "受注確認日時",
    "発注番号",
    "発注ID",
    "発注担当者名",
    "承認担当者名",
    "納品期日",
    "納品期日時間帯",
    "納品期日フラグ",
    "事業所コード",
    "納入先区分",
    "納入先コード",
    "納入先名",
    "納入先名2",
    "優版番号",
    "住所1",
    "住所2",
    "電話番号",
    "FAX番号",
    "担当者",
    "摘要1",
    "摘要2",
    "摘要3",
    "摘要4",
    "得意先名",
    "発注明細ID",
    "JANコード",
    "商品名",
    "発注数",
    "仕入単価",
    "仕入金額",
    "発注番号枝番"
  ],
  "header_fields": {
    "order_number": {
      "label": "発注番号",
      "csv_column": 2,
      "type": "string",
      "required": true,
      "description": "グルーピングキー（business_key）の前半部分。発注番号枝番と組み合わせて注文Noを生成"
    },
    "order_number_branch": {
      "label": "発注番号枝番",
      "csv_column": 31,
      "type": "integer",
      "required": true,
      "description": "グルーピングキー（business_key）の後半部分。注文No: {発注番号}-{枝番(2桁頭0埋め)}"
    }
  },
  "detail_fields": {
    "jan_code": {
      "label": "JANコード",
      "csv_column": 26,
      "type": "string",
      "required": true,
      "validation_rules": [
        "required",
        "string"
      ],
      "description": "JANコードから商品ID特定（末尾スペースはtrimして使用）"
    },
    "product_name": {
      "label": "商品名",
      "csv_column": 27,
      "type": "string",
      "required": false,
      "description": "参照用商品名（マッチング失敗時の参考情報）"
    },
    "order_qty": {
      "label": "発注数",
      "csv_column": 28,
      "type": "integer",
      "required": true,
      "min": 1,
      "validation_rules": [
        "required",
        "integer",
        "min:1"
      ],
      "description": "受注数量"
    },
    "unit_price": {
      "label": "仕入単価",
      "csv_column": 29,
      "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の商品を検索。末尾スペースをtrim",
      "on_not_found": "validation_error",
      "on_multiple": "step3_4_selection"
    },
    "customer_resolution": {
      "rule": "fixed_value",
      "config_file": "edi_amazon.php",
      "customer_code_key": "customer_code",
      "description": "得意先コード固定値（032030）をedi_amazon.php設定ファイルから取得"
    },
    "delivery_resolution": {
      "rule": "fixed_value",
      "config_file": "edi_amazon.php",
      "delivery_code_key": "delivery_code",
      "description": "配送先コード固定値（000010）をedi_amazon.php設定ファイルから取得"
    },
    "order_number_generation": {
      "rule": "composite_key",
      "format": "{order_number}-{order_number_branch:02d}",
      "description": "発注番号(C列) + '-0' + 発注番号枝番(AF列, 2桁ゼロパディング)で注文Noを生成"
    },
    "unit_price_check": {
      "rule": "compare_with_registered",
      "method": "OrderAssist::getUnitPrice",
      "action": "warning",
      "description": "CSV仕入単価と登録単価を比較し、差異がある場合は警告を表示（Step4実行結果画面）"
    },
    "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": {
    "customer_code": "032030",
    "customer_code_description": "アマゾン",
    "delivery_code": "000010",
    "delivery_code_description": "アマゾン配送先",
    "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": [
      "発注日",
      "受注確認日時",
      "発注番号",
      "発注ID",
      "発注担当者名",
      "承認担当者名",
      "納品期日",
      "納品期日時間帯",
      "納品期日フラグ",
      "事業所コード",
      "納入先区分",
      "納入先コード",
      "納入先名",
      "納入先名2",
      "優版番号",
      "住所1",
      "住所2",
      "電話番号",
      "FAX番号",
      "担当者",
      "摘要1",
      "摘要2",
      "摘要3",
      "摘要4",
      "得意先名",
      "発注明細ID",
      "JANコード",
      "商品名",
      "発注数",
      "仕入単価",
      "仕入金額",
      "発注番号枝番"
    ],
    "sample_data": [
      [
        "44:14.0",
        "07:46.7",
        "3254935A",
        "20260317143727465001",
        "鈴木ありみ",
        "岩本秀平",
        "00:00.0",
        "1",
        "1",
        "01",
        "97",
        "0110",
        "他倉庫",
        "佐倉倉庫",
        "285-0808",
        "千葉県佐倉市太田2464-11",
        "レッドウッド佐倉4F 24番バース",
        "043-497-4511",
        "",
        "古川健一様",
        "納品伝票添付指示",
        "出荷タイミング指示",
        "",
        "FAX返信先案内",
        "アマゾン",
        "20260317143727472001",
        "4950654052992",
        "GENTOS HLP-2503",
        "480",
        "4028",
        "1933440",
        "1"
      ],
      [
        "44:14.0",
        "07:46.7",
        "3254935A",
        "20260317143727465001",
        "鈴木ありみ",
        "岩本秀平",
        "00:00.0",
        "1",
        "1",
        "01",
        "97",
        "0110",
        "他倉庫",
        "佐倉倉庫",
        "285-0808",
        "千葉県佐倉市太田2464-11",
        "レッドウッド佐倉4F 24番バース",
        "043-497-4511",
        "",
        "古川健一様",
        "納品伝票添付指示",
        "出荷タイミング指示",
        "",
        "FAX返信先案内",
        "アマゾン",
        "20260317143727475002",
        "4950654053005",
        "GENTOS HLP-2504",
        "320",
        "5130",
        "1641600",
        "1"
      ]
    ]
  },
  "unused_columns": {
    "description": "取り込み対象外のカラム",
    "columns": [
      {
        "index": 0,
        "name": "発注日",
        "reason": "Excelシリアル値化で使用不可。処理日を使用"
      },
      {
        "index": 1,
        "name": "受注確認日時",
        "reason": "使用しない"
      },
      {
        "index": 3,
        "name": "発注ID",
        "reason": "使用しない"
      },
      {
        "index": 4,
        "name": "発注担当者名",
        "reason": "使用しない"
      },
      {
        "index": 5,
        "name": "承認担当者名",
        "reason": "使用しない"
      },
      {
        "index": 6,
        "name": "納品期日",
        "reason": "Excelシリアル値化で使用不可。処理日+リードタイムで計算"
      },
      {
        "index": 7,
        "name": "納品期日時間帯",
        "reason": "使用しない"
      },
      {
        "index": 8,
        "name": "納品期日フラグ",
        "reason": "使用しない"
      },
      {
        "index": 9,
        "name": "事業所コード",
        "reason": "使用しない"
      },
      {
        "index": 10,
        "name": "納入先区分",
        "reason": "使用しない"
      },
      {
        "index": 11,
        "name": "納入先コード",
        "reason": "使用しない"
      },
      {
        "index": 12,
        "name": "納入先名",
        "reason": "使用しない"
      },
      {
        "index": 13,
        "name": "納入先名2",
        "reason": "使用しない"
      },
      {
        "index": 14,
        "name": "優版番号",
        "reason": "使用しない"
      },
      {
        "index": 15,
        "name": "住所1",
        "reason": "使用しない"
      },
      {
        "index": 16,
        "name": "住所2",
        "reason": "使用しない"
      },
      {
        "index": 17,
        "name": "電話番号",
        "reason": "使用しない"
      },
      {
        "index": 18,
        "name": "FAX番号",
        "reason": "使用しない"
      },
      {
        "index": 19,
        "name": "担当者",
        "reason": "使用しない"
      },
      {
        "index": 20,
        "name": "摘要1",
        "reason": "使用しない"
      },
      {
        "index": 21,
        "name": "摘要2",
        "reason": "使用しない"
      },
      {
        "index": 22,
        "name": "摘要3",
        "reason": "使用しない"
      },
      {
        "index": 23,
        "name": "摘要4",
        "reason": "使用しない"
      },
      {
        "index": 24,
        "name": "得意先名",
        "reason": "使用しない（固定値で得意先を特定）"
      },
      {
        "index": 25,
        "name": "発注明細ID",
        "reason": "使用しない"
      },
      {
        "index": 30,
        "name": "仕入金額",
        "reason": "単価×数量で計算"
      }
    ]
  }
}
