--
-- Host: localhost    Database: moneyexchange_richrich
-- ------------------------------------------------------


--
-- Table structure for table `bank_account_transaction_types`
--

CREATE TABLE `bank_account_transaction_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `return_credit` tinyint(1) NOT NULL DEFAULT '1',
  `order` int DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `bank_account_transaction_types_name_unique` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `bank_account_transaction_types`
--

INSERT INTO `bank_account_transaction_types` VALUES (1,'Credit',1,1,1,NULL,NULL,'2022-08-22 18:06:36','2023-06-27 07:48:27'),(2,'Debit',1,1,2,NULL,NULL,'2022-08-22 18:07:06','2023-06-27 07:48:33'),(3,'Expense',1,0,3,NULL,NULL,'2022-08-22 18:07:22','2023-06-27 07:48:41'),(4,'Others',1,0,4,NULL,NULL,'2022-08-22 18:07:36','2023-06-27 07:48:50');

--
-- Table structure for table `bank_account_transactions`
--

CREATE TABLE `bank_account_transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `bank_account_id` bigint unsigned DEFAULT NULL,
  `transaction_type` enum('in','out') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` double NOT NULL,
  `credit_before_transaction` double NOT NULL,
  `credit_after_transaction` double NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `transaction_id` bigint unsigned DEFAULT NULL,
  `transfer_id` bigint unsigned DEFAULT NULL,
  `bank_account_transaction_type_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=636 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `bank_account_transactions`
--


--
-- Table structure for table `bank_accounts`
--

CREATE TABLE `bank_accounts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `bank_id` bigint unsigned DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `bank_username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `bank_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `credit` double NOT NULL DEFAULT '0',
  `user_id` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `is_bank` tinyint(1) NOT NULL DEFAULT '1',
  `responsible_by_user_id` bigint unsigned DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `bank_accounts`
--

INSERT INTO `bank_accounts` VALUES (1,1,1,'Vault-ដុល្លា','0',0,3,NULL,'2022-08-16 07:32:35','2023-06-29 08:36:19',0,3,1),(2,1,2,'Vault-បាត','0',0,3,NULL,'2022-08-16 07:32:53','2023-06-29 08:36:19',0,3,1),(3,1,3,'Vault-រៀល','0',0,3,NULL,'2022-08-16 07:33:07','2023-06-27 08:47:26',0,3,1),(25,1,1,'Maraka-ដុល្លា','0',0,3,NULL,'2022-08-16 08:06:43','2023-06-25 02:47:45',0,11,1),(26,1,2,'Maraka-បាត','0',0,3,NULL,'2022-08-16 08:06:55','2023-06-25 02:48:07',0,11,1),(27,1,3,'Maraka-រៀល','0',0,3,NULL,'2022-08-16 08:07:08','2023-06-25 02:48:50',0,11,1),(28,1,1,'staff2-Dollas','0',0,3,NULL,'2023-07-03 09:08:23','2023-07-03 09:08:23',0,14,1),(29,1,2,'staff2-Bahts','0',0,3,NULL,'2023-07-03 09:08:23','2023-07-03 09:08:23',0,14,1),(30,1,3,'staff2-Riels','0',0,3,NULL,'2023-07-03 09:08:23','2023-07-03 09:08:23',0,14,1),(31,1,1,'staff3-Dollas','0',0,3,NULL,'2023-07-03 09:08:35','2023-07-03 09:08:35',0,15,1),(32,1,2,'staff3-Bahts','0',0,3,NULL,'2023-07-03 09:08:35','2023-07-03 09:08:35',0,15,1),(33,1,3,'staff3-Riels','0',0,3,NULL,'2023-07-03 09:08:35','2023-07-03 09:08:35',0,15,1);

--
-- Table structure for table `banks`
--

CREATE TABLE `banks` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `logo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `show_as_bank` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  UNIQUE KEY `banks_name_unique` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `banks`
--

INSERT INTO `banks` VALUES (1,'Cash',NULL,NULL,3,'2022-08-16 07:31:41','2023-06-27 08:43:00',1),(2,'ABA',NULL,NULL,3,'2022-08-16 07:31:47','2022-08-16 07:31:47',1),(3,'WING',NULL,NULL,3,'2022-08-16 07:31:51','2022-08-16 07:31:51',1),(4,'ACELEDA',NULL,NULL,3,'2022-08-16 07:31:55','2022-08-16 07:31:55',1);

--
-- Table structure for table `currencies`
--

CREATE TABLE `currencies` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `is_main_currency` tinyint(1) NOT NULL DEFAULT '0',
  `decimal_precision` smallint NOT NULL DEFAULT '2',
  `flage` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `sample_money` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `currency_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `child_currency_id` bigint unsigned DEFAULT NULL,
  `min_exchange_amount` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `currencies_name_unique` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `currencies`
--

INSERT INTO `currencies` VALUES (1,'Dollas',1,NULL,'2022-08-16 07:06:55','2023-06-27 08:44:23',1,2,'images/1660640714.usd-flage.png','images/1660633615.usd.jpg','USD',0,0),(2,'Bahts',1,NULL,'2022-08-16 07:07:43','2023-06-27 08:44:10',0,0,'images/1660633663.thai.png','images/1660633663.bath.jpg','THB',0,0),(3,'Riels',1,NULL,'2022-08-16 07:08:10','2023-06-27 08:43:57',0,0,'images/1660633690.cambodia.png','images/1660633690.riel.jpg','KHR',0,0);

--
-- Table structure for table `failed_jobs`
--

CREATE TABLE `failed_jobs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `connection` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `queue` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `exception` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `failed_jobs`
--


--
-- Table structure for table `migrations`
--

CREATE TABLE `migrations` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `migrations`
--

INSERT INTO `migrations` VALUES (1,'2014_10_11_000001_create_roles_table',1),(2,'2014_10_12_000000_create_users_table',1),(3,'2014_10_12_100000_create_password_resets_table',1),(4,'2019_08_19_000000_create_failed_jobs_table',1),(5,'2019_12_14_000001_create_personal_access_tokens_table',1),(6,'2022_06_20_151035_create_currencies_table',1),(7,'2022_06_20_154842_create_money_exchange_lists_table',1),(8,'2022_06_20_154843_create_money_exchange_rates_table',1),(9,'2022_06_20_154922_create_banks_table',1),(10,'2022_06_20_154933_create_bank_accounts_table',1),(11,'2022_06_20_154934_create_transactions_table',1),(12,'2022_06_20_154952_create_bank_account_transactions_table',1),(13,'2022_06_21_124503_create_settings_table',1),(14,'2022_07_02_141950_add_last_update_rate_date_to_money_exchange_lists_table',1),(15,'2022_07_02_183812_add_received_amount_to_transactions_table',1),(16,'2022_07_08_151818_add_is_bank_to_bank_accounts_table',1),(17,'2022_07_11_140234_add_transaction_id_to_bank_account_transactions_table',1),(18,'2022_07_17_170354_add_is_active_to_bank_accountstable',1),(19,'2022_07_26_155231_add_is_main_currency_to_currencies_table',1),(20,'2022_07_28_132549_add_decimal_precision_to_currencies_table',1),(21,'2022_08_08_115507_create_transfers_table',1),(22,'2022_08_08_174756_add_flage_to_currencies_table',1),(23,'2022_08_11_175214_add_names_to_transfers_table',1),(24,'2022_08_17_122044_add_order_to_money_exchange_lists_table',2),(25,'2022_08_22_172523_add_show_as_bank_to_banks_table',3),(26,'2022_08_22_222643_add_transfer_id_to_bank_account_transactions_table',3),(27,'2022_08_22_225926_create_bank_account_transaction_types_table',3),(28,'2022_09_10_173213_add_already_print_to_transactions_table',4),(29,'2022_10_11_151416_add_currency_code_to_currencies_table',4),(30,'2023_05_24_173403_add_parent_transaction_id_to_tables_table',4),(31,'2023_06_30_153831_add_remain_credit_to_transactions_table',5);

--
-- Table structure for table `money_exchange_lists`
--

CREATE TABLE `money_exchange_lists` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `exchange_from_currency_id` bigint unsigned DEFAULT NULL,
  `exchange_to_currency_id` bigint unsigned DEFAULT NULL,
  `calculation` enum('x','/') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'x',
  `current_rate` double(8,2) DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `last_updated_rate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `order` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `exchange_from_currency_id_exchange_to_currency_id` (`exchange_from_currency_id`,`exchange_to_currency_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `money_exchange_lists`
--

INSERT INTO `money_exchange_lists` VALUES (1,1,3,'x',4105.00,1,1,NULL,'2022-08-16 07:11:34','2022-08-30 04:05:20','2022-08-30 04:05:20',6),(2,1,2,'x',36.50,1,1,NULL,'2022-08-16 07:11:49','2023-06-29 08:22:59','2023-06-29 08:22:59',1),(3,2,3,'x',112.70,1,1,NULL,'2022-08-16 07:12:06','2022-09-03 02:03:34','2022-09-03 02:03:34',4),(4,2,1,'/',36.65,1,1,NULL,'2022-08-16 07:12:30','2022-09-02 07:23:53','2022-09-02 07:23:53',2),(5,3,1,'/',4122.00,1,1,NULL,'2022-08-16 07:15:17','2022-09-03 02:03:42','2022-09-03 02:03:42',5),(6,3,2,'/',114.00,1,1,NULL,'2022-08-16 07:15:32','2022-09-03 02:03:21','2022-09-03 02:03:21',3);

--
-- Table structure for table `money_exchange_rates`
--

CREATE TABLE `money_exchange_rates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `money_exchange_list_id` bigint unsigned DEFAULT NULL,
  `exchange_rate` double(8,2) DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=178 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `money_exchange_rates`
--


--
-- Table structure for table `roles`
--

CREATE TABLE `roles` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `roles_name_unique` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `roles`
--

INSERT INTO `roles` VALUES (1,'staff',NULL,'2022-08-16 07:03:36','2022-08-16 07:03:36'),(2,'admin',NULL,'2022-08-16 07:03:36','2022-08-16 07:03:36');

--
-- Table structure for table `settings`
--

CREATE TABLE `settings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `settings_name_unique` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `settings`
--

INSERT INTO `settings` VALUES (1,'title','Rich Rich Shop',NULL,'2022-08-16 07:03:36','2023-06-24 14:40:44'),(2,'logo','logo.png',NULL,'2022-08-16 07:03:36','2022-08-16 07:03:36'),(3,'shop_name','Rich Rich Shop',NULL,'2022-08-16 07:03:36','2023-06-24 14:40:33'),(4,'phone','097 xxx xxx',NULL,'2022-08-16 07:03:36','2023-07-03 08:35:49'),(5,'address','Poipet, Cambodia',NULL,'2022-08-16 07:03:36','2023-06-27 08:48:34');

--
-- Table structure for table `transactions`
--

CREATE TABLE `transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `customer_level` smallint NOT NULL DEFAULT '1',
  `transaction_type` enum('cash_exchange','bank_deposit','bank_withdraw','staff_deposit','staff_withdraw') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `money_exchange_list_id` bigint unsigned DEFAULT NULL,
  `bank_account_id` bigint unsigned DEFAULT NULL,
  `fee` double NOT NULL DEFAULT '0',
  `amount` double DEFAULT NULL,
  `exchange_rate` double(8,2) DEFAULT NULL,
  `remain` double NOT NULL DEFAULT '0',
  `note` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `received_amount` double NOT NULL DEFAULT '0',
  `amount_after_exchange` double NOT NULL DEFAULT '0',
  `already_print` tinyint(1) NOT NULL DEFAULT '1',
  `parent_transaction_id` bigint unsigned DEFAULT NULL,
  `credit_khr` double DEFAULT NULL,
  `credit_usd` double DEFAULT NULL,
  `credit_thb` double DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=237 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `transactions`
--


--
-- Table structure for table `transfers`
--

CREATE TABLE `transfers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `bank_id` bigint unsigned DEFAULT NULL,
  `from_bank_account_id` bigint unsigned DEFAULT NULL,
  `to_bank_account_id` bigint unsigned DEFAULT NULL,
  `sender_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `receiver_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `amount` double DEFAULT NULL,
  `fee` double NOT NULL DEFAULT '0',
  `partner_fee` double NOT NULL DEFAULT '0',
  `user_id` bigint unsigned DEFAULT NULL,
  `transaction_type` enum('transferIn','transferOut','reTransferIn','reTransferOut') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `sender_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `receiver_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `transfers`
--



