CREATE TABLE IF NOT EXISTS `rial_ledger` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `voucher_id` varchar(50) DEFAULT NULL,
  `account_code` varchar(50) NOT NULL COMMENT 'cash_on_hand, bank_account, etc.',
  `debit` bigint(20) unsigned NOT NULL DEFAULT 0,
  `credit` bigint(20) unsigned NOT NULL DEFAULT 0,
  `reference_type` varchar(50) DEFAULT NULL,
  `reference_id` int(10) unsigned DEFAULT NULL,
  `description` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_account_code` (`account_code`),
  KEY `idx_voucher_id` (`voucher_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
