{
  "display_name": "汎用売上データ",
  "description": "様々な売上データCSVを統合インポート",
  "processor_class": "App\\Services\\Logic\\User\\CsvImport\\Processors\\BusinessSalesProcessor",
  "business_key_field": "slip_number",
  "header_table": "sales_headers",
  "detail_table": "sales_details",
  "header_fields": {
    "slip_number": {
      "label": "売上伝票番号",
      "type": "string",
      "required": true,
      "max_length": 12,
      "validation_rules": [
        "required",
        "string",
        "max:12"
      ],
      "description": "売上伝票を一意に識別する番号"
    },
    "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": "得意先名称（上様の場合に入る）"
    },
    "sales_date": {
      "label": "売上日",
      "type": "date",
      "required": true,
      "format": "Y-m-d",
      "validation_rules": [
        "required",
        "date"
      ],
      "description": "売上が発生した日付"
    },
    "shipment_actual_date": {
      "label": "出荷日",
      "type": "date",
      "required": false,
      "format": "Y-m-d",
      "validation_rules": [
        "date"
      ],
      "description": "実際の出荷日"
    },
    "arrival_date": {
      "label": "到着日",
      "type": "date",
      "required": false,
      "format": "Y-m-d",
      "validation_rules": [
        "date"
      ],
      "description": "到着日"
    },
    "warehouse_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": 10,
      "validation_rules": [
        "string",
        "max:10"
      ],
      "description": "配送先の郵便番号"
    },
    "delivery_prefecture": {
      "label": "配送先都道府県",
      "type": "string",
      "required": false,
      "max_length": 50,
      "validation_rules": [
        "string",
        "max:50"
      ],
      "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": "配送先の電話番号"
    },
    "logistics_note": {
      "label": "物流備考",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "物流に関する備考"
    },
    "shipping_type": {
      "label": "発送区分",
      "type": "integer",
      "required": false,
      "validation_rules": [
        "integer",
        "in:1,2"
      ],
      "description": "発送区分（1:発送, 2:直送）"
    },
    "sender_type": {
      "label": "荷送人区分",
      "type": "integer",
      "required": false,
      "validation_rules": [
        "integer",
        "in:1,2"
      ],
      "description": "荷送人区分（1:指定なし, 2:指定あり）"
    },
    "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番号"
    },
    "invoice_note_1": {
      "label": "送り状記事1",
      "type": "string",
      "required": false,
      "max_length": 100,
      "validation_rules": [
        "string",
        "max:100"
      ],
      "description": "送り状記事1"
    },
    "invoice_note_2": {
      "label": "送り状記事2",
      "type": "string",
      "required": false,
      "max_length": 100,
      "validation_rules": [
        "string",
        "max:100"
      ],
      "description": "送り状記事2"
    },
    "invoice_note_3": {
      "label": "送り状記事3",
      "type": "string",
      "required": false,
      "max_length": 100,
      "validation_rules": [
        "string",
        "max:100"
      ],
      "description": "送り状記事3"
    },
    "invoice_note_4": {
      "label": "送り状記事4",
      "type": "string",
      "required": false,
      "max_length": 100,
      "validation_rules": [
        "string",
        "max:100"
      ],
      "description": "送り状記事4"
    },
    "invoice_note_5": {
      "label": "送り状記事5",
      "type": "string",
      "required": false,
      "max_length": 100,
      "validation_rules": [
        "string",
        "max:100"
      ],
      "description": "送り状記事5"
    }
  },
  "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": "商品名称"
    },
    "shipment_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": "明細金額（数量×単価）"
    },
    "line_type": {
      "label": "明細区分",
      "type": "integer",
      "required": false,
      "validation_rules": [
        "integer",
        "in:1,2,3,4,5"
      ],
      "description": "明細区分（1:通常, 2:値引, 3:政策値引, 4:訂正, 5:返品）",
      "default": 1
    },
    "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": "明細の説明"
    }
  },
  "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": {
    "sales_date_validation": {
      "rule": "sales_date <= today",
      "error_message": "売上日は過去日または当日である必要があります"
    },
    "quantity_validation": {
      "rule": "shipment_qty > 0",
      "error_message": "出荷数量は0より大きい値である必要があります"
    },
    "line_type_validation": {
      "rule": "line_type IN (1,2,3,4,5)",
      "error_message": "明細区分は1(通常)、2(値引)、3(政策値引)、4(訂正)、5(返品)のいずれかである必要があります"
    }
  },
  "csv_format_example": {
    "description": "売上伝票番号をキーとして、様々な形式のCSVに対応",
    "headers": [
      "売上伝票番号",
      "得意先コード",
      "得意先名",
      "売上日",
      "出荷日",
      "到着日",
      "倉庫コード",
      "配送先名",
      "配送先郵便番号",
      "配送先都道府県",
      "配送先住所1",
      "配送先住所2",
      "配送先電話番号",
      "物流備考",
      "発送区分",
      "荷送人区分",
      "荷送人郵便番号",
      "荷送人都道府県",
      "荷送人住所1",
      "荷送人住所2",
      "荷送人住所3",
      "荷送人TEL",
      "荷送人FAX",
      "送り状記事1",
      "送り状記事2",
      "送り状記事3",
      "送り状記事4",
      "送り状記事5",
      "商品コード",
      "商品名",
      "出荷数量",
      "単価",
      "金額",
      "明細区分",
      "消費税区分",
      "説明"
    ],
    "sample_data": [
      ["#", "※この行と次の行は削除してからインポートしてください。【必須】: 売上伝票番号, 得意先コード, 売上日, 商品コード, 出荷数量", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
      ["#", "発送区分: 1=発送, 2=直送 / 荷送人区分: 1=指定なし, 2=指定あり / 明細区分: 1=通常, 2=値引, 3=政策値引, 4=訂正, 5=返品 / 消費税区分: 1=課税, 2=軽減, 3=非課税", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
      ["U2501060001", "002220", "角田無線電機株式会社", "2025/01/06", "2025/01/06", "2025/01/08", "01", "", "", "", "", "", "", "", "1", "", "", "", "", "", "", "", "", "", "", "", "", "", "SNM-H132D", "ジェントス LEDヘッドライト", "10", "897", "8970", "1", "1", ""],
      ["U2501060001", "002220", "角田無線電機株式会社", "2025/01/06", "2025/01/06", "2025/01/08", "01", "", "", "", "", "", "", "", "1", "", "", "", "", "", "", "", "", "", "", "", "", "", "GH-118RG", "ジェントス LEDライト", "5", "1500", "7500", "1", "1", ""],
      ["U2501060002", "092481", "株式会社ヨドバシカメラ", "2025/01/06", "2025/01/06", "", "01", "YAC川崎", "210-0023", "神奈川県", "川崎市川崎区小川町1-1", "", "044-XXX-XXXX", "", "1", "", "", "", "", "", "", "", "", "", "", "", "", "", "RX-323D", "ジェントス 充電式ライト", "20", "1200", "24000", "1", "1", ""]
    ]
  }
}
