-- Create cash_vouchers table
CREATE TABLE IF NOT EXISTS `cash_vouchers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `voucher_no` varchar(50) NOT NULL,
  `voucher_date` date NOT NULL,
  `voucher_type` enum('receipt','payment') NOT NULL COMMENT 'receipt: from customer, payment: to supplier',
  `party_type` enum('customer','supplier') NOT NULL,
  `party_id` int(11) NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `payment_mode` varchar(50) NOT NULL DEFAULT 'cash',
  `bank_account_id` int(11) DEFAULT NULL,
  `reference_no` varchar(100) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `company_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `voucher_no` (`voucher_no`),
  KEY `company_id` (`company_id`),
  KEY `party_id` (`party_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
