{
  "display_name": "売上訂正データ",
  "description": "売上訂正伝票（slip_type=4）のCSVをインポート。在庫処理は行われません。売上伝票番号は自動採番されます。",
  "processor_class": "App\\Services\\Logic\\User\\CsvImport\\Processors\\SalesCorrectionProcessor",
  "business_key_field": "slip_number",
  "header_table": "sales_headers",
  "detail_table": "sales_details",
  "header_fields": {
    "slip_number": {
      "label": "グルーピングキー",
      "type": "string",
      "required": false,
      "max_length": 50,
      "description": "同じ伝票にまとめる行のグルーピング用キー（実際の伝票番号は自動採番されます。マッピングしない場合は1行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": "得意先名称（上様の場合に入る）"
    },
    "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": "物流に関する備考"
    },
    "delivery_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:直送）"
    }
  },
  "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,
      "validation_rules": [
        "required",
        "numeric"
      ],
      "description": "出荷数量（訂正のためマイナス値も可、0は不可）"
    },
    "unit_price": {
      "label": "単価",
      "type": "decimal",
      "required": false,
      "validation_rules": [
        "numeric"
      ],
      "description": "販売単価（空の場合は自動取得。訂正のためマイナス値も可）"
    },
    "amount": {
      "label": "金額",
      "type": "decimal",
      "required": false,
      "validation_rules": [
        "numeric"
      ],
      "description": "明細金額（数量×単価。訂正のためマイナス値も可）"
    },
    "description": {
      "label": "説明",
      "type": "string",
      "required": false,
      "max_length": 500,
      "validation_rules": [
        "string",
        "max:500"
      ],
      "description": "明細の説明"
    },
    "order_number": {
      "label": "注文No",
      "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": {
    "quantity_validation": {
      "rule": "shipment_qty != 0",
      "error_message": "出荷数量は0以外の値である必要があります（マイナス値可）"
    },
    "inventory_skip_notice": {
      "info": "売上訂正伝票（slip_type=4）のため、在庫処理は実行されません"
    }
  },
  "csv_format_example": {
    "description": "売上訂正伝票をインポートするためのCSVフォーマット例。slip_type=4、line_type=4で自動登録されます。在庫処理は行われません。※売上伝票番号は自動採番されます。※明細区分（line_type）は常に4（訂正）が設定されます。※消費税区分はデフォルトで1（課税）が設定されます。",
    "headers": [
      "グルーピングキー",
      "得意先コード",
      "得意先名",
      "売上日",
      "出荷日",
      "到着日",
      "倉庫コード",
      "配送先名",
      "配送先郵便番号",
      "配送先都道府県",
      "配送先住所1",
      "配送先住所2",
      "配送先電話番号",
      "物流備考",
      "メモ(納品書)",
      "発送区分",
      "商品コード",
      "商品名",
      "出荷数量",
      "単価",
      "金額",
      "説明",
      "注文No"
    ],
    "sample_data": [
      ["#", "※この行と次の行は削除してからインポートしてください。【必須】: 得意先コード, 売上日, 商品コード, 出荷数量 / グルーピングキーは任意（同じ値の行が1伝票にまとまります。空欄の場合は1行1伝票）", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
      ["#", "発送区分: 1=発送, 2=直送 / ※売上伝票番号は自動採番 / ※明細区分は常に4(訂正) / ※消費税区分は自動で1(課税)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
      ["G001", "002220", "角田無線電機株式会社", "2025/01/06", "2025/01/06", "2025/01/08", "01", "", "", "", "", "", "", "", "同梱希望", "1", "SNM-H132D", "ジェントス LEDヘッドライト", "10", "897", "8970", "訂正理由：単価誤り", "PO-20250106-01"],
      ["G001", "002220", "角田無線電機株式会社", "2025/01/06", "2025/01/06", "2025/01/08", "01", "", "", "", "", "", "", "", "同梱希望", "1", "GH-118RG", "ジェントス LEDライト", "5", "1500", "7500", "", "PO-20250106-02"]
    ]
  }
}
