-- 
-- SHJ-9 売上集計結果テーブル
-- 日次売上集計データを保存するテーブル
-- 

CREATE TABLE `earnings_summary` (
  `earnings_summary_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '売上集計ID',
  `park_id` int(10) UNSIGNED NOT NULL COMMENT '駐輪場ID',
  `summary_type` varchar(255) DEFAULT NULL COMMENT '集計区分',
  `summary_start_date` date DEFAULT NULL COMMENT '集計開始日',
  `summary_end_date` date DEFAULT NULL COMMENT '集計終了日',
  `earnings_date` date DEFAULT NULL COMMENT '売上日',
  `psection_id` int(10) UNSIGNED DEFAULT NULL COMMENT '車種区分ID',
  `usertype_subject1` varchar(255) DEFAULT NULL COMMENT '規格',
  `enable_months` int(10) UNSIGNED DEFAULT NULL COMMENT '期間(月数)',
  `regular_new_count` int(10) UNSIGNED DEFAULT 0 COMMENT '期間件数',
  `regular_new_amount` decimal(10,2) DEFAULT 0.00 COMMENT '期間金額',
  `regular_new_reduction_count` int(10) UNSIGNED DEFAULT 0 COMMENT '期間成免件数',
  `regular_new_reduction_amount` decimal(10,2) DEFAULT 0.00 COMMENT '期間成免金額',
  `regular_update_count` int(10) UNSIGNED DEFAULT 0 COMMENT '更新件数',
  `regular_update_amount` decimal(10,2) DEFAULT 0.00 COMMENT '更新金額',
  `regular_update_reduction_count` int(10) UNSIGNED DEFAULT 0 COMMENT '更新成免件数',
  `regular_update_reduction_amount` decimal(10,2) DEFAULT 0.00 COMMENT '更新成免金額',
  `turnsum_count` int(10) UNSIGNED DEFAULT 0 COMMENT '残金件数',
  `turnsum` decimal(10,2) DEFAULT 0.00 COMMENT '残金',
  `refunds` decimal(10,2) DEFAULT 0.00 COMMENT '解時返戻金',
  `other_income` decimal(10,2) DEFAULT 0.00 COMMENT '分別収入',
  `other_spending` decimal(10,2) DEFAULT 0.00 COMMENT '分別支出',
  `reissue_count` int(10) UNSIGNED DEFAULT 0 COMMENT '発行件数',
  `reissue_amount` decimal(10,2) DEFAULT 0.00 COMMENT '発行金額',
  `summary_note` text DEFAULT NULL COMMENT '計備考',
  `created_at` datetime DEFAULT NULL COMMENT '登録日時',
  `updated_at` datetime DEFAULT NULL COMMENT '更新日時',
  `operator_id` int(10) UNSIGNED DEFAULT NULL COMMENT '新法・ページID',
  PRIMARY KEY (`earnings_summary_id`),
  KEY `idx_park_earnings_date` (`park_id`, `earnings_date`),
  KEY `idx_psection` (`psection_id`),
  KEY `idx_earnings_date` (`earnings_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='売上集計結果テーブル';
