-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `rpgwlfnf_ledger`
--

-- --------------------------------------------------------

--
-- Table structure for table `accounts`
--

CREATE TABLE `accounts` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `account_name` varchar(100) NOT NULL,
  `address` text DEFAULT NULL,
  `phone_no` varchar(15) DEFAULT NULL,
  `account_type` enum('CUSTOMER','SUPPLIER','EXPENSE','INCOME','ASSETS','INVESTMENTS','BANK','CASH') NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `accounts`
--

INSERT INTO `accounts` (`id`, `user_id`, `account_name`, `address`, `phone_no`, `account_type`, `created_at`) VALUES
(7, 5, 'Smartways', '', '9061620953', 'CUSTOMER', '2025-10-11 07:36:39'),
(8, 7, 'Smile technogies', NULL, '9656000144', 'CUSTOMER', '2025-10-12 23:18:31'),
(10, 5, 'Transportation expenses', '', '', 'EXPENSE', '2025-10-17 03:03:10'),
(13, 4, 'isha', 'noida', '7896541236', 'EXPENSE', '2025-10-18 00:10:32'),
(14, 4, 'Nee', 'Test', '1245405454', 'EXPENSE', '2025-10-18 00:13:12'),
(15, 6, 'Naman', NULL, NULL, 'CUSTOMER', '2025-10-18 00:37:09'),
(16, 6, 'Neeraj', NULL, NULL, 'BANK', '2025-10-18 00:37:35'),
(17, 5, 'smile techcnologies', 'kattappana', '9656000144', 'CUSTOMER', '2025-10-18 00:44:56'),
(18, 5, 'windot', 'kattappana', '9656000144', 'SUPPLIER', '2025-10-18 00:50:13'),
(19, 5, 'Cash in hand', NULL, NULL, 'CASH', '2025-10-18 02:34:49'),
(20, 19, 'SMILE TEST', NULL, NULL, 'CUSTOMER', '2025-10-18 03:27:00'),
(21, 19, 'TEST 123', NULL, NULL, 'SUPPLIER', '2025-10-18 03:29:21'),
(22, 6, 'rohan', '', '', 'EXPENSE', '2025-10-25 23:52:16'),
(23, 6, 'rajesh', '', '', 'INCOME', '2025-10-25 23:52:59'),
(24, 6, 'vipin', 'dsfds', NULL, 'ASSETS', '2025-10-27 14:00:43'),
(25, 6, 'suman', 'dgdtyrt', '56564564', 'INVESTMENTS', '2025-10-27 14:00:59'),
(26, 6, 'pankaj', 'dyty', '564567698', 'CASH', '2025-10-27 14:01:22'),
(27, 6, 'ritik', 'dsgdg', '5465464564', 'SUPPLIER', '2025-10-27 14:02:37');

-- --------------------------------------------------------

--
-- Table structure for table `account_ledgers`
--

CREATE TABLE `account_ledgers` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `account_id` int(11) NOT NULL,
  `date` date NOT NULL,
  `description` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL,
  `transaction_id` int(11) DEFAULT NULL,
  `debit` decimal(12,2) NOT NULL DEFAULT 0.00,
  `credit` decimal(12,2) NOT NULL DEFAULT 0.00,
  `file` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `account_ledgers`
--

INSERT INTO `account_ledgers` (`id`, `user_id`, `account_id`, `date`, `description`, `transaction_id`, `debit`, `credit`, `file`, `created_at`) VALUES
(15, 6, 15, '2025-10-27', '', 1, '500.00', '0.00', NULL, '2025-10-27 14:03:17'),
(16, 6, 15, '2025-10-27', '', 1, '0.00', '500.00', NULL, '2025-10-27 14:03:17'),
(17, 6, 15, '2025-10-27', '', 2, '0.00', '400.00', NULL, '2025-10-27 14:03:30'),
(18, 6, 15, '2025-10-27', '', 2, '400.00', '0.00', NULL, '2025-10-27 14:03:30'),
(19, 6, 16, '2025-10-27', '', 3, '5000.00', '0.00', NULL, '2025-10-27 14:04:44'),
(20, 6, 16, '2025-10-27', '', 3, '0.00', '5000.00', NULL, '2025-10-27 14:04:44'),
(21, 6, 16, '2025-10-27', '', 4, '0.00', '600.00', NULL, '2025-10-27 14:05:00'),
(22, 6, 16, '2025-10-27', '', 4, '600.00', '0.00', NULL, '2025-10-27 14:05:00');

-- --------------------------------------------------------

--
-- Table structure for table `account_ledgers_old`
--

CREATE TABLE `account_ledgers_old` (
  `id` int(11) NOT NULL,
  `account_id` int(11) NOT NULL,
  `date` date NOT NULL,
  `description` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL,
  `amount` decimal(12,2) NOT NULL DEFAULT 0.00,
  `payment` decimal(12,2) NOT NULL DEFAULT 0.00,
  `file` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `account_ledgers_old`
--

INSERT INTO `account_ledgers_old` (`id`, `account_id`, `date`, `description`, `amount`, `payment`, `file`, `created_at`) VALUES
(7, 7, '2025-10-11', '', '0.00', '500.00', NULL, '2025-10-11 13:11:54'),
(9, 7, '2025-10-11', '', '0.00', '30.00', NULL, '2025-10-11 17:27:51'),
(10, 7, '2025-10-12', '', '100.00', '0.00', NULL, '2025-10-12 12:05:07'),
(11, 8, '2025-10-13', 'Eee', '7988.00', '0.00', NULL, '2025-10-13 04:50:00'),
(12, 8, '2025-10-13', 'Eee', '7988.00', '0.00', NULL, '2025-10-13 04:50:03'),
(13, 8, '2025-10-13', '', '453.00', '0.00', NULL, '2025-10-13 04:50:31'),
(14, 8, '2025-10-13', '', '0.00', '533.00', NULL, '2025-10-13 04:50:38'),
(16, 10, '2025-10-17', 'Paid for transportation', '0.00', '150.00', NULL, '2025-10-17 08:37:53'),
(19, 18, '2025-10-18', 'bill', '7500.00', '0.00', NULL, '2025-10-18 06:20:28'),
(20, 18, '2025-10-18', '', '0.00', '5000.00', NULL, '2025-10-18 06:20:35'),
(21, 17, '2025-10-18', 'bill', '2500.00', '0.00', NULL, '2025-10-18 06:22:19'),
(22, 18, '2025-10-18', '10 pc battery', '2300.00', '0.00', NULL, '2025-10-18 08:02:27'),
(23, 17, '2025-10-18', 'Cash', '1000.00', '0.00', NULL, '2025-10-18 08:03:12'),
(24, 19, '2025-10-18', 'Cash received from aman', '5000.00', '0.00', NULL, '2025-10-18 08:05:12'),
(25, 19, '2025-10-18', 'Cash paid to ziva', '0.00', '1000.00', NULL, '2025-10-18 08:05:36'),
(26, 20, '2025-10-18', 'HKJ', '1000.00', '0.00', NULL, '2025-10-18 08:58:13'),
(27, 20, '2025-10-18', '', '500.00', '0.00', NULL, '2025-10-18 08:58:32'),
(28, 21, '2025-10-18', '', '1000.00', '0.00', NULL, '2025-10-18 08:59:33'),
(29, 21, '2025-10-18', '', '0.00', '350.00', NULL, '2025-10-18 08:59:42'),
(30, 15, '2025-10-26', '', '100.00', '0.00', NULL, '2025-10-26 05:23:57'),
(31, 15, '2025-10-26', '', '200.00', '0.00', NULL, '2025-10-26 05:24:14');

-- --------------------------------------------------------

--
-- Table structure for table `account_transactions`
--

CREATE TABLE `account_transactions` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `date` date NOT NULL,
  `account_id` int(11) NOT NULL,
  `cash_bank_account_id` int(11) DEFAULT NULL,
  `amount` decimal(15,2) NOT NULL DEFAULT 0.00,
  `description` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_on` datetime DEFAULT current_timestamp(),
  `updated_on` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `account_transactions`
--

INSERT INTO `account_transactions` (`id`, `user_id`, `date`, `account_id`, `cash_bank_account_id`, `amount`, `description`, `created_on`, `updated_on`) VALUES
(1, 6, '2025-10-27', 15, 0, '500.00', '', '2025-10-27 19:33:17', '2025-10-27 19:33:17'),
(2, 6, '2025-10-27', 15, 26, '400.00', '', '2025-10-27 19:33:30', '2025-10-27 19:33:30'),
(3, 6, '2025-10-27', 16, 19, '5000.00', '', '2025-10-27 19:34:44', '2025-10-27 19:34:44'),
(4, 6, '2025-10-27', 16, 0, '600.00', '', '2025-10-27 19:35:00', '2025-10-27 19:35:00');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `accounts`
--
ALTER TABLE `accounts`
  ADD PRIMARY KEY (`id`),
  ADD KEY `accounts_user_id_foreign` (`user_id`);

--
-- Indexes for table `account_ledgers`
--
ALTER TABLE `account_ledgers`
  ADD PRIMARY KEY (`id`),
  ADD KEY `account_ledgers_account_id_foreign` (`account_id`);

--
-- Indexes for table `account_ledgers_old`
--
ALTER TABLE `account_ledgers_old`
  ADD PRIMARY KEY (`id`),
  ADD KEY `account_ledgers_account_id_foreign` (`account_id`);

--
-- Indexes for table `account_transactions`
--
ALTER TABLE `account_transactions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `account_id` (`account_id`),
  ADD KEY `cash_bank_account_id` (`cash_bank_account_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `accounts`
--
ALTER TABLE `accounts`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28;

--
-- AUTO_INCREMENT for table `account_ledgers`
--
ALTER TABLE `account_ledgers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;

--
-- AUTO_INCREMENT for table `account_ledgers_old`
--
ALTER TABLE `account_ledgers_old`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=32;

--
-- AUTO_INCREMENT for table `account_transactions`
--
ALTER TABLE `account_transactions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `accounts`
--
ALTER TABLE `accounts`
  ADD CONSTRAINT `accounts_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `account_ledgers`
--
ALTER TABLE `account_ledgers`
  ADD CONSTRAINT `account_ledgers_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE;
COMMIT;

