--
-- Host: 127.0.0.1    Database: alhilkkw_business_soug_hanana
-- ------------------------------------------------------


--
-- Table structure for table `business_settings`
--

CREATE TABLE `business_settings` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `business_name` varchar(255) DEFAULT NULL,
  `business_address` text DEFAULT NULL,
  `business_phone` varchar(20) DEFAULT NULL,
  `business_email` varchar(255) DEFAULT NULL,
  `business_website` varchar(255) DEFAULT NULL,
  `business_logo` varchar(255) DEFAULT NULL,
  `invoice_prefix` varchar(10) NOT NULL DEFAULT 'INV',
  `invoice_number_start` int(11) NOT NULL DEFAULT 1000,
  `current_invoice_number` int(11) NOT NULL DEFAULT 1000,
  `receipt_prefix` varchar(10) NOT NULL DEFAULT 'RCP',
  `receipt_number_start` int(11) NOT NULL DEFAULT 1000,
  `current_receipt_number` int(11) NOT NULL DEFAULT 1000,
  `default_tax_rate` decimal(5,2) NOT NULL DEFAULT 0.00,
  `tax_label` varchar(50) NOT NULL DEFAULT 'Tax',
  `currency_symbol` varchar(10) NOT NULL DEFAULT 'CFA',
  `currency_code` varchar(3) NOT NULL DEFAULT 'XOF',
  `business_registration_number` varchar(255) DEFAULT NULL,
  `tax_identification_number` varchar(255) DEFAULT NULL,
  `invoice_footer_note` text DEFAULT NULL,
  `receipt_footer_note` text DEFAULT NULL,
  `show_logo_on_invoice` tinyint(1) NOT NULL DEFAULT 1,
  `show_logo_on_receipt` tinyint(1) NOT NULL DEFAULT 1,
  `date_format` varchar(20) NOT NULL DEFAULT 'd/m/Y',
  `time_format` varchar(20) NOT NULL DEFAULT 'H:i:s',
  `starting_year` int(11) NOT NULL DEFAULT 2026,
  `active_fiscal_year_id` bigint(20) unsigned DEFAULT NULL,
  `view_fiscal_year_id` bigint(20) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `business_settings`
--

INSERT INTO `business_settings` VALUES
(1,'S-H Business',NULL,NULL,NULL,NULL,NULL,'INV',1000,1017,'RCP',1000,1000,0.00,'Tax','CFA','XOF',NULL,NULL,NULL,NULL,1,1,'d/m/Y','H:i:s',2026,NULL,NULL,'2026-04-10 13:00:32','2026-04-20 18:01:31');

--
-- Table structure for table `cache`
--

CREATE TABLE `cache` (
  `key` varchar(255) NOT NULL,
  `value` mediumtext NOT NULL,
  `expiration` int(11) NOT NULL,
  PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `cache`
--


--
-- Table structure for table `cache_locks`
--

CREATE TABLE `cache_locks` (
  `key` varchar(255) NOT NULL,
  `owner` varchar(255) NOT NULL,
  `expiration` int(11) NOT NULL,
  PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `cache_locks`
--


--
-- Table structure for table `cashier_balances`
--

CREATE TABLE `cashier_balances` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL,
  `current_balance` decimal(15,2) NOT NULL DEFAULT 0.00,
  `total_sales` decimal(15,2) NOT NULL DEFAULT 0.00,
  `total_withdrawals` decimal(15,2) NOT NULL DEFAULT 0.00,
  `total_expenses` decimal(15,2) NOT NULL DEFAULT 0.00,
  `last_updated_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `cashier_balances_user_id_unique` (`user_id`),
  KEY `cashier_balances_user_id_index` (`user_id`),
  CONSTRAINT `cashier_balances_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `cashier_balances`
--

INSERT INTO `cashier_balances` VALUES
(1,1,129000.00,129000.00,0.00,0.00,'2026-04-20 17:44:11','2026-04-10 16:29:31','2026-04-20 17:44:11'),
(2,2,57000.00,57000.00,0.00,0.00,'2026-04-20 18:00:56','2026-04-14 14:37:19','2026-04-20 18:00:56');

--
-- Table structure for table `cashier_transactions`
--

CREATE TABLE `cashier_transactions` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL,
  `type` enum('sale','sale_edit','sale_cancel','withdrawal','expense') NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `direction` enum('credit','debit') NOT NULL,
  `description` text NOT NULL,
  `reference_id` bigint(20) unsigned DEFAULT NULL,
  `reference_type` varchar(255) DEFAULT NULL,
  `balance_before` decimal(15,2) NOT NULL,
  `balance_after` decimal(15,2) NOT NULL,
  `metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`metadata`)),
  `transaction_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `cashier_transactions_user_id_transaction_date_index` (`user_id`,`transaction_date`),
  KEY `cashier_transactions_type_transaction_date_index` (`type`,`transaction_date`),
  KEY `cashier_transactions_reference_id_reference_type_index` (`reference_id`,`reference_type`),
  CONSTRAINT `cashier_transactions_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `cashier_transactions`
--

INSERT INTO `cashier_transactions` VALUES
(1,1,'sale',15000.00,'credit','Loan payment received: INV-1001',1,'Sale',0.00,15000.00,'{\"sale_id\":1,\"sale_number\":\"INV-1001\",\"customer\":\"Teyba Oumar\",\"payment_type\":\"loan_payment\"}','2026-04-10 16:29:31','2026-04-10 16:29:31','2026-04-10 16:29:31'),
(2,1,'sale',12000.00,'credit','Sale completed: INV-1002',2,'Sale',15000.00,27000.00,'{\"sale_id\":2,\"sale_number\":\"INV-1002\",\"customer\":\"Aicha Bechir\",\"payment_method\":\"cash\",\"is_partial\":false}','2026-04-10 16:31:24','2026-04-10 16:31:24','2026-04-10 16:31:24'),
(3,1,'sale',78000.00,'credit','Sale completed: INV-1003',3,'Sale',27000.00,105000.00,'{\"sale_id\":3,\"sale_number\":\"INV-1003\",\"customer\":null,\"payment_method\":\"cash\",\"is_partial\":false}','2026-04-12 15:17:23','2026-04-12 15:17:23','2026-04-12 15:17:23'),
(4,1,'sale',15000.00,'credit','Sale completed: INV-1004',4,'Sale',105000.00,120000.00,'{\"sale_id\":4,\"sale_number\":\"INV-1004\",\"customer\":\"Asma Oumar\",\"payment_method\":\"cash\",\"is_partial\":true}','2026-04-12 15:29:21','2026-04-12 15:29:21','2026-04-12 15:29:21'),
(5,2,'sale',12000.00,'credit','Sale completed: INV-1005',5,'Sale',0.00,12000.00,'{\"sale_id\":5,\"sale_number\":\"INV-1005\",\"customer\":\"Fatime\",\"payment_method\":\"cash\",\"is_partial\":false}','2026-04-14 14:37:19','2026-04-14 14:37:19','2026-04-14 14:37:19'),
(6,2,'sale',10000.00,'credit','Sale completed: INV-1006',6,'Sale',12000.00,22000.00,'{\"sale_id\":6,\"sale_number\":\"INV-1006\",\"customer\":\"Zenouba\",\"payment_method\":\"cash\",\"is_partial\":false}','2026-04-14 14:37:42','2026-04-14 14:37:42','2026-04-14 14:37:42'),
(7,2,'sale',25000.00,'credit','Sale completed: INV-1007',7,'Sale',22000.00,47000.00,'{\"sale_id\":7,\"sale_number\":\"INV-1007\",\"customer\":null,\"payment_method\":\"cash\",\"is_partial\":false}','2026-04-15 13:36:16','2026-04-15 13:36:16','2026-04-15 13:36:16'),
(8,2,'sale',10000.00,'credit','Sale completed: INV-1008',8,'Sale',47000.00,57000.00,'{\"sale_id\":8,\"sale_number\":\"INV-1008\",\"customer\":null,\"payment_method\":\"cash\",\"is_partial\":false}','2026-04-15 13:36:33','2026-04-15 13:36:33','2026-04-15 13:36:33'),
(9,1,'sale',7000.00,'credit','Loan payment received: INV-1004',4,'Sale',120000.00,127000.00,'{\"sale_id\":4,\"sale_number\":\"INV-1004\",\"customer\":\"Asma Oumar\",\"payment_type\":\"loan_payment\"}','2026-04-19 05:16:07','2026-04-19 05:16:07','2026-04-19 05:16:07'),
(10,1,'sale',2000.00,'credit','Loan payment received: INV-1004',4,'Sale',127000.00,129000.00,'{\"sale_id\":4,\"sale_number\":\"INV-1004\",\"customer\":\"Asma Oumar\",\"payment_type\":\"loan_payment\"}','2026-04-20 17:44:11','2026-04-20 17:44:11','2026-04-20 17:44:11'),
(11,2,'sale',15000.00,'credit','Sale completed: INV-1015',15,'Sale',57000.00,72000.00,'{\"sale_id\":15,\"sale_number\":\"INV-1015\",\"customer\":\"Fatime\",\"payment_method\":\"cash\",\"is_partial\":false}','2026-04-20 17:58:45','2026-04-20 17:58:45','2026-04-20 17:58:45'),
(12,2,'sale_cancel',15000.00,'debit','Sale cancelled/refunded: INV-1015',15,'Sale',72000.00,57000.00,'{\"sale_id\":15,\"sale_number\":\"INV-1015\",\"reason\":\"Sale cancelled\\/refunded\"}','2026-04-20 18:00:56','2026-04-20 18:00:56','2026-04-20 18:00:56');

--
-- Table structure for table `categories`
--

CREATE TABLE `categories` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `image` varchar(255) DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `categories_is_active_index` (`is_active`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` VALUES
(1,'Bags',NULL,NULL,1,'2026-04-10 13:18:30','2026-04-10 13:18:30'),
(2,'Electronics',NULL,NULL,1,'2026-04-10 13:18:41','2026-04-10 13:18:41');

--
-- Table structure for table `clients`
--

CREATE TABLE `clients` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `phone` varchar(30) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `clients_phone_unique` (`phone`),
  KEY `clients_name_index` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `clients`
--

INSERT INTO `clients` VALUES
(1,'Bon','---',NULL,NULL,NULL,1,'2026-04-18 17:36:37','2026-04-20 17:53:52'),
(2,'Nadia','60 58 05 26',NULL,NULL,NULL,1,'2026-04-20 17:55:03','2026-04-20 17:55:03'),
(3,'Nadia\'s Clients','99 58 05 26',NULL,NULL,NULL,1,'2026-04-20 17:56:12','2026-04-20 17:56:12'),
(4,'Khadidja Oumar','61',NULL,NULL,NULL,1,'2026-04-20 17:56:56','2026-04-20 17:56:56'),
(5,'Fatime','62',NULL,NULL,NULL,1,'2026-04-20 17:58:45','2026-04-20 17:58:45'),
(6,'Asia','63',NULL,NULL,NULL,1,'2026-04-20 17:59:07','2026-04-20 17:59:07');

--
-- Table structure for table `expense_types`
--

CREATE TABLE `expense_types` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `color` varchar(7) NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `expense_types_name_unique` (`name`),
  UNIQUE KEY `expense_types_color_unique` (`color`),
  KEY `expense_types_is_active_name_index` (`is_active`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `expense_types`
--


--
-- Table structure for table `expenses`
--

CREATE TABLE `expenses` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `expense_type_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  `title` varchar(255) NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `description` text DEFAULT NULL,
  `expense_date` date NOT NULL,
  `receipt_number` varchar(255) DEFAULT NULL,
  `payment_method` varchar(255) NOT NULL DEFAULT 'cash',
  `status` enum('pending','approved','rejected') NOT NULL DEFAULT 'pending',
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `expenses_expense_date_status_index` (`expense_date`,`status`),
  KEY `expenses_expense_type_id_status_index` (`expense_type_id`,`status`),
  KEY `expenses_user_id_expense_date_index` (`user_id`,`expense_date`),
  CONSTRAINT `expenses_expense_type_id_foreign` FOREIGN KEY (`expense_type_id`) REFERENCES `expense_types` (`id`),
  CONSTRAINT `expenses_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `expenses`
--


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

CREATE TABLE `failed_jobs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `uuid` varchar(255) NOT NULL,
  `connection` text NOT NULL,
  `queue` text NOT NULL,
  `payload` longtext NOT NULL,
  `exception` longtext 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 `fiscal_years`
--

CREATE TABLE `fiscal_years` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 0,
  `is_closed` tinyint(1) NOT NULL DEFAULT 0,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `fiscal_years`
--


--
-- Table structure for table `job_batches`
--

CREATE TABLE `job_batches` (
  `id` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `total_jobs` int(11) NOT NULL,
  `pending_jobs` int(11) NOT NULL,
  `failed_jobs` int(11) NOT NULL,
  `failed_job_ids` longtext NOT NULL,
  `options` mediumtext DEFAULT NULL,
  `cancelled_at` int(11) DEFAULT NULL,
  `created_at` int(11) NOT NULL,
  `finished_at` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `job_batches`
--


--
-- Table structure for table `jobs`
--

CREATE TABLE `jobs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `queue` varchar(255) NOT NULL,
  `payload` longtext NOT NULL,
  `attempts` tinyint(3) unsigned NOT NULL,
  `reserved_at` int(10) unsigned DEFAULT NULL,
  `available_at` int(10) unsigned NOT NULL,
  `created_at` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `jobs_queue_index` (`queue`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `jobs`
--


--
-- Table structure for table `loan_histories`
--

CREATE TABLE `loan_histories` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `sale_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned DEFAULT NULL,
  `action` enum('created','payment_made','fully_paid','edited','cancelled') NOT NULL,
  `old_amount` decimal(15,2) DEFAULT NULL,
  `new_amount` decimal(15,2) DEFAULT NULL,
  `payment_amount` decimal(15,2) DEFAULT NULL,
  `reason` varchar(255) DEFAULT NULL,
  `metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`metadata`)),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `loan_histories_sale_id_foreign` (`sale_id`),
  KEY `loan_histories_user_id_foreign` (`user_id`),
  CONSTRAINT `loan_histories_sale_id_foreign` FOREIGN KEY (`sale_id`) REFERENCES `sales` (`id`) ON DELETE CASCADE,
  CONSTRAINT `loan_histories_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `loan_histories`
--

INSERT INTO `loan_histories` VALUES
(1,1,1,'created',0.00,25000.00,NULL,'Loan created from POS sale',NULL,'2026-04-10 13:22:52','2026-04-10 13:22:52'),
(2,1,1,'payment_made',25000.00,10000.00,15000.00,'Payment received',NULL,'2026-04-10 16:29:34','2026-04-10 16:29:34'),
(3,4,1,'created',0.00,9000.00,NULL,'Loan created from POS sale',NULL,'2026-04-12 15:29:21','2026-04-12 15:29:21'),
(4,9,2,'created',0.00,30000.00,NULL,'Loan created from POS sale',NULL,'2026-04-15 13:37:19','2026-04-15 13:37:19'),
(5,4,2,'payment_made',9000.00,2000.00,7000.00,'Payment received',NULL,'2026-04-19 05:16:08','2026-04-19 05:16:08'),
(6,4,2,'fully_paid',2000.00,0.00,2000.00,'Payment received',NULL,'2026-04-20 17:44:12','2026-04-20 17:44:12'),
(7,10,2,'created',0.00,20000.00,NULL,'Loan created from POS sale',NULL,'2026-04-20 17:49:56','2026-04-20 17:49:56'),
(8,11,2,'created',0.00,50000.00,NULL,'Loan created from POS sale',NULL,'2026-04-20 17:50:31','2026-04-20 17:50:31'),
(9,12,2,'created',0.00,20000.00,NULL,'Loan created from POS sale',NULL,'2026-04-20 17:55:03','2026-04-20 17:55:03'),
(10,13,2,'created',0.00,50000.00,NULL,'Loan created from POS sale',NULL,'2026-04-20 17:56:12','2026-04-20 17:56:12'),
(11,14,2,'created',0.00,15000.00,NULL,'Loan created from POS sale',NULL,'2026-04-20 17:56:56','2026-04-20 17:56:56'),
(12,16,2,'created',0.00,15000.00,NULL,'Loan created from POS sale',NULL,'2026-04-20 17:59:07','2026-04-20 17:59:07'),
(13,17,2,'created',0.00,15000.00,NULL,'Loan created from POS sale',NULL,'2026-04-20 18:01:31','2026-04-20 18:01:31');

--
-- Table structure for table `loan_payments`
--

CREATE TABLE `loan_payments` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `sale_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `payment_method` enum('cash','card','mobile_payment') NOT NULL,
  `notes` text DEFAULT NULL,
  `balance_before` decimal(15,2) NOT NULL,
  `balance_after` decimal(15,2) NOT NULL,
  `payment_date` datetime NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `loan_payments_sale_id_foreign` (`sale_id`),
  KEY `loan_payments_user_id_foreign` (`user_id`),
  CONSTRAINT `loan_payments_sale_id_foreign` FOREIGN KEY (`sale_id`) REFERENCES `sales` (`id`) ON DELETE CASCADE,
  CONSTRAINT `loan_payments_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `loan_payments`
--

INSERT INTO `loan_payments` VALUES
(1,1,1,15000.00,'cash',NULL,25000.00,10000.00,'2026-04-10 19:29:31','2026-04-10 16:29:31','2026-04-10 16:29:31'),
(2,4,2,7000.00,'cash',NULL,9000.00,2000.00,'2026-04-19 08:16:07','2026-04-19 05:16:07','2026-04-19 05:16:07'),
(3,4,2,2000.00,'cash',NULL,2000.00,0.00,'2026-04-20 20:44:11','2026-04-20 17:44:11','2026-04-20 17:44:11');

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

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

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

INSERT INTO `migrations` VALUES
(1,'0001_01_01_000000_create_users_table',1),
(2,'0001_01_01_000001_create_cache_table',1),
(3,'0001_01_01_000002_create_jobs_table',1),
(4,'2024_01_01_000008_create_categories_table',1),
(5,'2025_08_20_204847_add_two_factor_columns_to_users_table',1),
(6,'2025_08_20_204856_create_personal_access_tokens_table',1),
(7,'2025_08_21_174432_create_products_table',1),
(8,'2025_08_21_174528_create_product_inventories_table',1),
(9,'2025_08_21_174637_create_product_histories_table',1),
(10,'2025_08_21_174721_create_sales_table',1),
(11,'2025_08_21_174757_create_sale_items_table',1),
(12,'2025_08_21_174838_create_product_variants_table',1),
(13,'2025_08_26_161417_create_sale_histories_table',1),
(14,'2025_09_03_142120_create_proformas_table',1),
(15,'2025_09_03_142121_create_proforma_items_table',1),
(16,'2025_09_07_121232_create_expense_types_table',1),
(17,'2025_09_07_121233_create_expenses_table',1),
(18,'2025_09_07_153315_create_cashier_balances_table',1),
(19,'2025_09_10_093456_add_loan_fields_to_sales_table',1),
(20,'2025_09_10_093456_create_loan_histories_table',1),
(21,'2025_09_10_093456_create_loan_payments_table',1),
(22,'2025_09_12_181425_create_business_settings_table',1),
(23,'2025_09_27_194618_create_permission_tables',1),
(24,'2025_10_31_164515_create_markets_table',1),
(25,'2025_11_27_135818_create_push_subscriptions_table',1),
(26,'2026_04_05_000001_add_starting_year_to_business_settings',1),
(27,'2026_04_05_220918_create_fiscal_years_table',1),
(28,'2026_04_07_071928_add_endpoint_hash_to_push_subscriptions',1);

--
-- Table structure for table `model_has_permissions`
--

CREATE TABLE `model_has_permissions` (
  `permission_id` bigint(20) unsigned NOT NULL,
  `model_type` varchar(255) NOT NULL,
  `model_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`permission_id`,`model_id`,`model_type`),
  KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`),
  CONSTRAINT `model_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `model_has_permissions`
--


--
-- Table structure for table `model_has_roles`
--

CREATE TABLE `model_has_roles` (
  `role_id` bigint(20) unsigned NOT NULL,
  `model_type` varchar(255) NOT NULL,
  `model_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`role_id`,`model_id`,`model_type`),
  KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`),
  CONSTRAINT `model_has_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `model_has_roles`
--

INSERT INTO `model_has_roles` VALUES
(1,'App\\Models\\User',2);

--
-- Table structure for table `password_reset_tokens`
--

CREATE TABLE `password_reset_tokens` (
  `email` varchar(255) NOT NULL,
  `token` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `password_reset_tokens`
--


--
-- Table structure for table `permissions`
--

CREATE TABLE `permissions` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `guard_name` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `permissions_name_guard_name_unique` (`name`,`guard_name`)
) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `permissions`
--

INSERT INTO `permissions` VALUES
(1,'view dashboard','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(2,'refresh dashboard','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(3,'view dashboard stats','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(4,'view users','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(5,'create users','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(6,'edit users','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(7,'delete users','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(8,'assign roles','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(9,'view roles','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(10,'create roles','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(11,'edit roles','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(12,'delete roles','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(13,'view categories','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(14,'create categories','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(15,'edit categories','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(16,'delete categories','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(17,'toggle category status','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(18,'view products','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(19,'create products','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(20,'edit products','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(21,'delete products','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(22,'manage product stock','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(23,'view product analytics','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(24,'access pos','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(25,'process sales','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(26,'cancel sales','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(27,'view sales history','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(28,'view sale details','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(29,'edit sales','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(30,'print receipts','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(31,'export sales','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(32,'view sale history','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(33,'view reports','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(34,'export reports','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(35,'generate advanced reports','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(36,'view business settings','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(37,'edit business settings','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(38,'view expenses','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(39,'create expenses','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(40,'edit expenses','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(41,'delete expenses','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(42,'approve expenses','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(43,'view loans','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(44,'manage loan payments','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(45,'mark loans paid','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(46,'view proformas','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(47,'create proformas','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(48,'edit proformas','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(49,'delete proformas','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(50,'confirm proformas','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(51,'cancel proformas','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(52,'view cashier','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(53,'process withdrawals','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(54,'view cashier history','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(55,'export cashier reports','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(56,'view cashier balance','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(57,'view expense types','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(58,'create expense types','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(59,'edit expense types','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(60,'delete expense types','web','2026-04-10 14:58:44','2026-04-10 14:58:44');

--
-- Table structure for table `personal_access_tokens`
--

CREATE TABLE `personal_access_tokens` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `tokenable_type` varchar(255) NOT NULL,
  `tokenable_id` bigint(20) unsigned NOT NULL,
  `name` text NOT NULL,
  `token` varchar(64) NOT NULL,
  `abilities` text DEFAULT NULL,
  `last_used_at` timestamp NULL DEFAULT NULL,
  `expires_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `personal_access_tokens_token_unique` (`token`),
  KEY `personal_access_tokens_tokenable_type_tokenable_id_index` (`tokenable_type`,`tokenable_id`),
  KEY `personal_access_tokens_expires_at_index` (`expires_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `personal_access_tokens`
--


--
-- Table structure for table `product_histories`
--

CREATE TABLE `product_histories` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint(20) unsigned NOT NULL,
  `action` varchar(50) NOT NULL,
  `description` text NOT NULL,
  `user_id` bigint(20) unsigned DEFAULT NULL,
  `data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`data`)),
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_histories_product_id_created_at_index` (`product_id`,`created_at`),
  KEY `product_histories_action_index` (`action`),
  KEY `product_histories_user_id_index` (`user_id`),
  CONSTRAINT `product_histories_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `product_histories_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `product_histories`
--

INSERT INTO `product_histories` VALUES
(1,1,'created','Product created',1,'{\"name\":\"Bags\",\"description\":null,\"barcode\":\"PRD092846\",\"category_id\":\"1\",\"product_type\":\"market\",\"unit\":\"pcs\",\"cost_price\":\"5600.00\",\"selling_price\":\"12000.00\",\"expiry_date\":null,\"is_active\":true,\"alert_quantity\":1,\"weight\":null,\"length\":null,\"width\":null,\"height\":null,\"updated_at\":\"2026-04-10T16:20:37.000000Z\",\"created_at\":\"2026-04-10T16:20:37.000000Z\",\"id\":1}','143.105.161.121','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36','2026-04-10 13:20:37','2026-04-10 13:20:37'),
(2,1,'stock_added','Added 12 units - Initial stock',1,'{\"quantity\":12,\"reason\":\"Initial stock\",\"previous_stock\":0,\"new_stock\":12,\"notes\":\"Product creation\"}','143.105.161.121','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36','2026-04-10 13:20:37','2026-04-10 13:20:37'),
(3,2,'created','Product created',1,'{\"name\":\"Astronot\",\"description\":null,\"barcode\":\"PRD000749\",\"category_id\":\"2\",\"product_type\":\"market\",\"unit\":\"pcs\",\"cost_price\":\"12000.00\",\"selling_price\":\"25000.00\",\"expiry_date\":null,\"is_active\":true,\"alert_quantity\":1,\"weight\":null,\"length\":null,\"width\":null,\"height\":null,\"updated_at\":\"2026-04-10T16:22:24.000000Z\",\"created_at\":\"2026-04-10T16:22:24.000000Z\",\"id\":2}','143.105.161.121','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36','2026-04-10 13:22:24','2026-04-10 13:22:24'),
(4,2,'stock_added','Added 10 units - Initial stock',1,'{\"quantity\":10,\"reason\":\"Initial stock\",\"previous_stock\":0,\"new_stock\":10,\"notes\":\"Product creation\"}','143.105.161.121','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36','2026-04-10 13:22:24','2026-04-10 13:22:24'),
(5,2,'stock_removed','Removed 1 units - Sale',1,'{\"quantity\":1,\"reason\":\"Sale\",\"previous_stock\":10,\"new_stock\":9,\"sale_id\":1,\"sale_number\":\"INV-1001\"}','143.105.161.121','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36','2026-04-10 13:22:52','2026-04-10 13:22:52'),
(6,1,'stock_removed','Removed 1 units - Sale',1,'{\"quantity\":1,\"reason\":\"Sale\",\"previous_stock\":12,\"new_stock\":11,\"sale_id\":2,\"sale_number\":\"INV-1002\"}','154.73.161.230','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/29.0 Chrome/136.0.0.0 Mobile Safari/537.36','2026-04-10 16:31:24','2026-04-10 16:31:24'),
(7,1,'stock_removed','Removed 7 units - Sale',1,'{\"quantity\":7,\"reason\":\"Sale\",\"previous_stock\":11,\"new_stock\":4,\"sale_id\":3,\"sale_number\":\"INV-1003\"}','154.73.161.83','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Mobile Safari/537.36','2026-04-12 15:17:23','2026-04-12 15:17:23'),
(8,1,'stock_removed','Removed 2 units - Sale',1,'{\"quantity\":2,\"reason\":\"Sale\",\"previous_stock\":4,\"new_stock\":2,\"sale_id\":4,\"sale_number\":\"INV-1004\"}','154.73.161.83','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Mobile Safari/537.36','2026-04-12 15:29:21','2026-04-12 15:29:21'),
(9,1,'stock_removed','Removed 1 units - Sale',2,'{\"quantity\":1,\"reason\":\"Sale\",\"previous_stock\":2,\"new_stock\":1,\"sale_id\":5,\"sale_number\":\"INV-1005\"}','154.73.160.191','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Mobile Safari/537.36','2026-04-14 14:37:19','2026-04-14 14:37:19'),
(10,1,'stock_removed','Removed 1 units - Sale',2,'{\"quantity\":1,\"reason\":\"Sale\",\"previous_stock\":1,\"new_stock\":0,\"sale_id\":6,\"sale_number\":\"INV-1006\"}','154.73.160.191','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Mobile Safari/537.36','2026-04-14 14:37:42','2026-04-14 14:37:42'),
(11,1,'price_changed','Product pricing updated',2,'{\"old_prices\":{\"cost_price\":\"5600.00\",\"selling_price\":\"12000.00\",\"discount_price\":null},\"new_prices\":{\"cost_price\":\"6200.00\",\"selling_price\":\"12500.00\",\"discount_price\":null}}','154.73.163.54','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Mobile Safari/537.36','2026-04-14 15:27:40','2026-04-14 15:27:40'),
(12,1,'updated','Product updated',2,'{\"name\":{\"old\":\"Bags\",\"new\":\"Bags-2\"},\"cost_price\":{\"old\":\"5600.00\",\"new\":\"6200\"},\"selling_price\":{\"old\":\"12000.00\",\"new\":\"12500.00\"}}','154.73.163.54','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Mobile Safari/537.36','2026-04-14 15:27:40','2026-04-14 15:27:40'),
(13,1,'stock_added','Added 15 units - Restock - New shipment',2,'{\"quantity\":15,\"reason\":\"Restock - New shipment\",\"previous_stock\":0,\"new_stock\":15,\"notes\":null}','154.73.163.54','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Mobile Safari/537.36','2026-04-14 15:28:17','2026-04-14 15:28:17'),
(14,1,'stock_removed','Removed 2 units - Sale',2,'{\"quantity\":2,\"reason\":\"Sale\",\"previous_stock\":15,\"new_stock\":13,\"sale_id\":7,\"sale_number\":\"INV-1007\"}','143.105.161.94','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Mobile Safari/537.36','2026-04-15 13:36:16','2026-04-15 13:36:16'),
(15,1,'stock_removed','Removed 1 units - Sale',2,'{\"quantity\":1,\"reason\":\"Sale\",\"previous_stock\":13,\"new_stock\":12,\"sale_id\":8,\"sale_number\":\"INV-1008\"}','143.105.161.94','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Mobile Safari/537.36','2026-04-15 13:36:33','2026-04-15 13:36:33'),
(16,1,'stock_removed','Removed 2 units - Sale',2,'{\"quantity\":2,\"reason\":\"Sale\",\"previous_stock\":12,\"new_stock\":10,\"sale_id\":9,\"sale_number\":\"INV-1009\"}','143.105.161.94','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Mobile Safari/537.36','2026-04-15 13:37:19','2026-04-15 13:37:19'),
(17,3,'created','Product created',2,'{\"name\":\"Bags 3\",\"description\":null,\"barcode\":\"PRD139272\",\"category_id\":\"1\",\"product_type\":\"market\",\"unit\":\"pcs\",\"cost_price\":\"7500.00\",\"selling_price\":\"10000.00\",\"expiry_date\":null,\"is_active\":true,\"alert_quantity\":1,\"weight\":null,\"length\":null,\"width\":null,\"height\":null,\"updated_at\":\"2026-04-20T20:45:55.000000Z\",\"created_at\":\"2026-04-20T20:45:55.000000Z\",\"id\":3}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 17:45:55','2026-04-20 17:45:55'),
(18,3,'stock_added','Added 15 units - Initial stock',2,'{\"quantity\":15,\"reason\":\"Initial stock\",\"previous_stock\":0,\"new_stock\":15,\"notes\":\"Product creation\"}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 17:45:55','2026-04-20 17:45:55'),
(19,3,'stock_removed','Removed 2 units - Sale',2,'{\"quantity\":2,\"reason\":\"Sale\",\"previous_stock\":15,\"new_stock\":13,\"sale_id\":10,\"sale_number\":\"INV-1010\"}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 17:49:55','2026-04-20 17:49:55'),
(20,3,'stock_removed','Removed 5 units - Sale',2,'{\"quantity\":5,\"reason\":\"Sale\",\"previous_stock\":13,\"new_stock\":8,\"sale_id\":11,\"sale_number\":\"INV-1011\"}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 17:50:31','2026-04-20 17:50:31'),
(21,3,'stock_added','Added 5 units - Sale cancelled/refunded',2,'{\"quantity\":5,\"reason\":\"Error\",\"previous_stock\":8,\"new_stock\":13,\"sale_id\":11,\"sale_number\":\"INV-1011\"}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 17:51:49','2026-04-20 17:51:49'),
(22,3,'stock_added','Added 2 units - Sale cancelled/refunded',2,'{\"quantity\":2,\"reason\":\"Error\",\"previous_stock\":13,\"new_stock\":15,\"sale_id\":10,\"sale_number\":\"INV-1010\"}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 17:52:33','2026-04-20 17:52:33'),
(23,3,'stock_removed','Removed 2 units - Sale',2,'{\"quantity\":2,\"reason\":\"Sale\",\"previous_stock\":15,\"new_stock\":13,\"sale_id\":12,\"sale_number\":\"INV-1012\"}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 17:55:03','2026-04-20 17:55:03'),
(24,3,'stock_removed','Removed 5 units - Sale',2,'{\"quantity\":5,\"reason\":\"Sale\",\"previous_stock\":13,\"new_stock\":8,\"sale_id\":13,\"sale_number\":\"INV-1013\"}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 17:56:12','2026-04-20 17:56:12'),
(25,3,'stock_removed','Removed 1 units - Sale',2,'{\"quantity\":1,\"reason\":\"Sale\",\"previous_stock\":8,\"new_stock\":7,\"sale_id\":14,\"sale_number\":\"INV-1014\"}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 17:56:56','2026-04-20 17:56:56'),
(26,3,'stock_removed','Removed 1 units - Sale',2,'{\"quantity\":1,\"reason\":\"Sale\",\"previous_stock\":7,\"new_stock\":6,\"sale_id\":15,\"sale_number\":\"INV-1015\"}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 17:58:45','2026-04-20 17:58:45'),
(27,3,'stock_removed','Removed 1 units - Sale',2,'{\"quantity\":1,\"reason\":\"Sale\",\"previous_stock\":6,\"new_stock\":5,\"sale_id\":16,\"sale_number\":\"INV-1016\"}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 17:59:07','2026-04-20 17:59:07'),
(28,3,'stock_added','Added 1 units - Sale cancelled/refunded',2,'{\"quantity\":1,\"reason\":\"Error\",\"previous_stock\":5,\"new_stock\":6,\"sale_id\":15,\"sale_number\":\"INV-1015\"}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 18:00:56','2026-04-20 18:00:56'),
(29,3,'stock_removed','Removed 1 units - Sale',2,'{\"quantity\":1,\"reason\":\"Sale\",\"previous_stock\":6,\"new_stock\":5,\"sale_id\":17,\"sale_number\":\"INV-1017\"}','154.73.113.145','Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36','2026-04-20 18:01:31','2026-04-20 18:01:31');

--
-- Table structure for table `product_inventories`
--

CREATE TABLE `product_inventories` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint(20) unsigned NOT NULL,
  `current_stock` int(11) NOT NULL DEFAULT 0,
  `reserved_stock` int(11) NOT NULL DEFAULT 0,
  `available_stock` int(11) NOT NULL DEFAULT 0,
  `last_stock_update` timestamp NULL DEFAULT NULL,
  `last_updated_by` bigint(20) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_inventories_last_updated_by_foreign` (`last_updated_by`),
  KEY `product_inventories_product_id_index` (`product_id`),
  KEY `product_inventories_available_stock_index` (`available_stock`),
  CONSTRAINT `product_inventories_last_updated_by_foreign` FOREIGN KEY (`last_updated_by`) REFERENCES `users` (`id`),
  CONSTRAINT `product_inventories_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `product_inventories`
--

INSERT INTO `product_inventories` VALUES
(1,1,10,0,10,'2026-04-15 13:37:18',2,'2026-04-10 13:20:37','2026-04-15 13:37:18'),
(2,2,9,0,9,'2026-04-10 13:22:52',1,'2026-04-10 13:22:24','2026-04-10 13:22:52'),
(3,3,5,0,5,'2026-04-20 18:01:31',2,'2026-04-20 17:45:55','2026-04-20 18:01:31');

--
-- Table structure for table `product_variants`
--

CREATE TABLE `product_variants` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint(20) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `value` varchar(255) NOT NULL,
  `sku` varchar(255) NOT NULL,
  `price_adjustment` decimal(8,2) NOT NULL DEFAULT 0.00,
  `stock_quantity` int(11) NOT NULL DEFAULT 0,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `product_variants_sku_unique` (`sku`),
  KEY `product_variants_product_id_is_active_index` (`product_id`,`is_active`),
  CONSTRAINT `product_variants_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `product_variants`
--


--
-- Table structure for table `products`
--

CREATE TABLE `products` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `barcode` varchar(255) DEFAULT NULL,
  `category_id` bigint(20) unsigned NOT NULL,
  `product_type` enum('market','store') NOT NULL,
  `unit` varchar(50) NOT NULL,
  `alert_quantity` int(11) NOT NULL DEFAULT 1,
  `cost_price` decimal(10,2) NOT NULL,
  `selling_price` decimal(10,2) NOT NULL,
  `discount_price` decimal(10,2) DEFAULT NULL,
  `image` varchar(255) DEFAULT NULL,
  `expiry_date` date DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `weight` decimal(8,3) DEFAULT NULL,
  `length` decimal(8,2) DEFAULT NULL,
  `width` decimal(8,2) DEFAULT NULL,
  `height` decimal(8,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `products_barcode_unique` (`barcode`),
  KEY `products_product_type_is_active_index` (`product_type`,`is_active`),
  KEY `products_category_id_is_active_index` (`category_id`,`is_active`),
  KEY `products_barcode_index` (`barcode`),
  KEY `products_is_active_index` (`is_active`),
  KEY `products_expiry_date_index` (`expiry_date`),
  KEY `products_product_type_index` (`product_type`),
  CONSTRAINT `products_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `products`
--

INSERT INTO `products` VALUES
(1,'Bags-2',NULL,'PRD092846',1,'market','pcs',1,6200.00,12500.00,NULL,NULL,NULL,1,NULL,NULL,NULL,NULL,'2026-04-10 13:20:37','2026-04-14 15:27:40',NULL),
(2,'Astronot',NULL,'PRD000749',2,'market','pcs',1,12000.00,25000.00,NULL,NULL,NULL,1,NULL,NULL,NULL,NULL,'2026-04-10 13:22:24','2026-04-10 13:22:24',NULL),
(3,'Bags 3',NULL,'PRD139272',1,'market','pcs',1,7500.00,10000.00,NULL,NULL,NULL,1,NULL,NULL,NULL,NULL,'2026-04-20 17:45:55','2026-04-20 17:45:55',NULL);

--
-- Table structure for table `proforma_items`
--

CREATE TABLE `proforma_items` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `proforma_id` bigint(20) unsigned NOT NULL,
  `product_id` bigint(20) unsigned NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `product_barcode` varchar(255) DEFAULT NULL,
  `quantity` int(11) NOT NULL,
  `unit_price` decimal(10,2) NOT NULL,
  `tax_rate` decimal(5,2) NOT NULL DEFAULT 0.00,
  `tax_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `discount_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `total_amount` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `proforma_items_proforma_id_index` (`proforma_id`),
  KEY `proforma_items_product_id_index` (`product_id`),
  CONSTRAINT `proforma_items_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`),
  CONSTRAINT `proforma_items_proforma_id_foreign` FOREIGN KEY (`proforma_id`) REFERENCES `proformas` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `proforma_items`
--


--
-- Table structure for table `proformas`
--

CREATE TABLE `proformas` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `proforma_number` varchar(255) NOT NULL,
  `proforma_type` enum('market','store') NOT NULL,
  `customer_name` varchar(255) DEFAULT NULL,
  `customer_phone` varchar(20) DEFAULT NULL,
  `customer_email` varchar(255) DEFAULT NULL,
  `subtotal` decimal(10,2) NOT NULL DEFAULT 0.00,
  `tax_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `discount_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `total_amount` decimal(10,2) NOT NULL,
  `status` enum('draft','sent','confirmed','expired','cancelled') NOT NULL DEFAULT 'draft',
  `notes` text DEFAULT NULL,
  `created_by` bigint(20) unsigned NOT NULL,
  `confirmed_by` bigint(20) unsigned DEFAULT NULL,
  `confirmed_at` timestamp NULL DEFAULT NULL,
  `sale_id` bigint(20) unsigned DEFAULT NULL,
  `expires_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `proformas_proforma_number_unique` (`proforma_number`),
  KEY `proformas_confirmed_by_foreign` (`confirmed_by`),
  KEY `proformas_sale_id_foreign` (`sale_id`),
  KEY `proformas_proforma_type_status_index` (`proforma_type`,`status`),
  KEY `proformas_created_at_index` (`created_at`),
  KEY `proformas_status_index` (`status`),
  KEY `proformas_created_by_index` (`created_by`),
  KEY `proformas_expires_at_index` (`expires_at`),
  CONSTRAINT `proformas_confirmed_by_foreign` FOREIGN KEY (`confirmed_by`) REFERENCES `users` (`id`),
  CONSTRAINT `proformas_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`),
  CONSTRAINT `proformas_sale_id_foreign` FOREIGN KEY (`sale_id`) REFERENCES `sales` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `proformas`
--


--
-- Table structure for table `role_has_permissions`
--

CREATE TABLE `role_has_permissions` (
  `permission_id` bigint(20) unsigned NOT NULL,
  `role_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`permission_id`,`role_id`),
  KEY `role_has_permissions_role_id_foreign` (`role_id`),
  CONSTRAINT `role_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `role_has_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `role_has_permissions`
--

INSERT INTO `role_has_permissions` VALUES
(1,1),
(1,2),
(1,3),
(1,4),
(2,1),
(2,2),
(2,3),
(3,1),
(3,2),
(3,3),
(4,1),
(4,2),
(5,1),
(5,2),
(6,1),
(6,2),
(7,1),
(7,2),
(8,1),
(8,2),
(9,1),
(9,2),
(10,1),
(10,2),
(11,1),
(11,2),
(12,1),
(12,2),
(13,1),
(13,2),
(13,3),
(13,4),
(14,1),
(14,2),
(14,3),
(15,1),
(15,2),
(15,3),
(16,1),
(16,2),
(17,1),
(17,2),
(17,3),
(18,1),
(18,2),
(18,3),
(18,4),
(19,1),
(19,2),
(19,3),
(20,1),
(20,2),
(20,3),
(21,1),
(21,2),
(22,1),
(22,2),
(22,3),
(22,4),
(23,1),
(23,2),
(23,3),
(24,1),
(24,2),
(24,3),
(24,4),
(25,1),
(25,2),
(25,3),
(25,4),
(26,1),
(26,2),
(27,1),
(27,2),
(27,3),
(27,4),
(28,1),
(28,2),
(28,3),
(28,4),
(29,1),
(29,2),
(29,3),
(30,1),
(30,2),
(30,3),
(30,4),
(31,1),
(31,2),
(31,3),
(32,1),
(32,2),
(32,3),
(33,1),
(33,2),
(33,3),
(33,4),
(34,1),
(34,2),
(34,3),
(35,1),
(35,2),
(36,1),
(36,2),
(37,1),
(37,2),
(38,1),
(38,2),
(38,3),
(39,1),
(39,2),
(39,3),
(40,1),
(40,2),
(40,3),
(41,1),
(41,2),
(42,1),
(42,2),
(43,1),
(43,2),
(43,3),
(43,4),
(44,1),
(44,2),
(44,3),
(44,4),
(45,1),
(45,2),
(46,1),
(46,2),
(46,3),
(46,4),
(47,1),
(47,2),
(47,3),
(47,4),
(48,1),
(48,2),
(48,3),
(48,4),
(49,1),
(49,2),
(49,4),
(50,1),
(50,4),
(51,1),
(51,4),
(52,1),
(52,2),
(52,3),
(52,4),
(53,1),
(53,2),
(53,3),
(53,4),
(54,1),
(54,2),
(54,3),
(55,1),
(55,2),
(56,1),
(56,2),
(56,3),
(56,4),
(57,1),
(57,2),
(57,3),
(57,4),
(58,1),
(58,2),
(58,3),
(59,1),
(59,2),
(59,3),
(60,1),
(60,2);

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

CREATE TABLE `roles` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `guard_name` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `roles_name_guard_name_unique` (`name`,`guard_name`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

INSERT INTO `roles` VALUES
(1,'Super Admin','web','2026-04-10 14:58:44','2026-04-10 14:58:44'),
(2,'Admin','web','2026-04-10 14:58:45','2026-04-10 14:58:45'),
(3,'Manager','web','2026-04-10 14:58:45','2026-04-10 14:58:45'),
(4,'Seller','web','2026-04-10 14:58:45','2026-04-10 14:58:45');

--
-- Table structure for table `sale_histories`
--

CREATE TABLE `sale_histories` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `sale_id` bigint(20) unsigned NOT NULL,
  `action` varchar(255) NOT NULL,
  `changes` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`changes`)),
  `old_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`old_values`)),
  `new_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`new_values`)),
  `reason` text DEFAULT NULL,
  `user_id` bigint(20) unsigned DEFAULT NULL,
  `user_name` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sale_histories_sale_id_created_at_index` (`sale_id`,`created_at`),
  KEY `sale_histories_action_index` (`action`),
  KEY `sale_histories_user_id_foreign` (`user_id`),
  CONSTRAINT `sale_histories_sale_id_foreign` FOREIGN KEY (`sale_id`) REFERENCES `sales` (`id`) ON DELETE CASCADE,
  CONSTRAINT `sale_histories_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `sale_histories`
--

INSERT INTO `sale_histories` VALUES
(1,1,'created',NULL,NULL,'{\"sale_number\":\"INV-1001\",\"sale_type\":\"market\",\"customer_name\":\"Teyba Oumar\",\"customer_phone\":\"---\",\"customer_email\":null,\"subtotal\":\"25000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"25000.00\",\"paid_amount\":\"0.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"sale_date\":\"2026-04-10T16:22:52.000000Z\",\"cashier_id\":1,\"is_loan\":true,\"loan_amount\":\"25000.00\",\"collected_amount\":\"0.00\",\"payment_status\":\"unpaid\",\"updated_at\":\"2026-04-10T16:22:52.000000Z\",\"created_at\":\"2026-04-10T16:22:52.000000Z\",\"id\":1}','Sale created through POS',1,'admin','2026-04-10 13:22:52','2026-04-10 13:22:52'),
(2,1,'payment_received','{\"payment_status\":{\"old\":\"unpaid\",\"new\":\"partial\"},\"loan_amount\":{\"old\":\"25000.00\",\"new\":\"10000.00\"},\"collected_amount\":{\"old\":\"0.00\",\"new\":\"15000.00\"}}',NULL,'{\"payment_amount\":15000,\"payment_method\":\"cash\",\"payment_notes\":null,\"balance_after\":10000}','Payment received: 15,000 CFA via Cash',1,'admin','2026-04-10 16:29:31','2026-04-10 16:29:31'),
(3,2,'created',NULL,NULL,'{\"sale_number\":\"INV-1002\",\"sale_type\":\"market\",\"customer_name\":\"Aicha Bechir\",\"customer_phone\":\"---\",\"customer_email\":null,\"subtotal\":\"12000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"12000.00\",\"paid_amount\":\"12000.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"sale_date\":\"2026-04-10T19:31:24.000000Z\",\"cashier_id\":1,\"is_loan\":false,\"loan_amount\":\"0.00\",\"collected_amount\":\"12000.00\",\"payment_status\":\"paid\",\"updated_at\":\"2026-04-10T19:31:24.000000Z\",\"created_at\":\"2026-04-10T19:31:24.000000Z\",\"id\":2}','Sale created through POS',1,'admin','2026-04-10 16:31:24','2026-04-10 16:31:24'),
(4,3,'created',NULL,NULL,'{\"sale_number\":\"INV-1003\",\"sale_type\":\"market\",\"customer_name\":null,\"customer_phone\":null,\"customer_email\":null,\"subtotal\":\"78050.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"50.00\",\"total_amount\":\"78000.00\",\"paid_amount\":\"78000.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"sale_date\":\"2026-04-12T18:17:23.000000Z\",\"cashier_id\":1,\"is_loan\":false,\"loan_amount\":\"0.00\",\"collected_amount\":\"78000.00\",\"payment_status\":\"paid\",\"updated_at\":\"2026-04-12T18:17:23.000000Z\",\"created_at\":\"2026-04-12T18:17:23.000000Z\",\"id\":3}','Sale created through POS',1,'admin','2026-04-12 15:17:23','2026-04-12 15:17:23'),
(5,4,'created',NULL,NULL,'{\"sale_number\":\"INV-1004\",\"sale_type\":\"market\",\"customer_name\":\"Asma Oumar\",\"customer_phone\":\"---\",\"customer_email\":null,\"subtotal\":\"24000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"24000.00\",\"paid_amount\":\"15000.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"sale_date\":\"2026-04-12T18:29:21.000000Z\",\"cashier_id\":1,\"is_loan\":true,\"loan_amount\":\"9000.00\",\"collected_amount\":\"15000.00\",\"payment_status\":\"partial\",\"updated_at\":\"2026-04-12T18:29:21.000000Z\",\"created_at\":\"2026-04-12T18:29:21.000000Z\",\"id\":4}','Sale created through POS',1,'admin','2026-04-12 15:29:21','2026-04-12 15:29:21'),
(6,5,'created',NULL,NULL,'{\"sale_number\":\"INV-1005\",\"sale_type\":\"market\",\"customer_name\":\"Fatime\",\"customer_phone\":\"---\",\"customer_email\":null,\"subtotal\":\"12000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"12000.00\",\"paid_amount\":\"12000.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"sale_date\":\"2026-04-14T17:37:19.000000Z\",\"cashier_id\":2,\"is_loan\":false,\"loan_amount\":\"0.00\",\"collected_amount\":\"12000.00\",\"payment_status\":\"paid\",\"updated_at\":\"2026-04-14T17:37:19.000000Z\",\"created_at\":\"2026-04-14T17:37:19.000000Z\",\"id\":5}','Sale created through POS',2,'Ayoub Oumar','2026-04-14 14:37:19','2026-04-14 14:37:19'),
(7,6,'created',NULL,NULL,'{\"sale_number\":\"INV-1006\",\"sale_type\":\"market\",\"customer_name\":\"Zenouba\",\"customer_phone\":\"---\",\"customer_email\":null,\"subtotal\":\"10000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"10000.00\",\"paid_amount\":\"10000.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"sale_date\":\"2026-04-14T17:37:42.000000Z\",\"cashier_id\":2,\"is_loan\":false,\"loan_amount\":\"0.00\",\"collected_amount\":\"10000.00\",\"payment_status\":\"paid\",\"updated_at\":\"2026-04-14T17:37:42.000000Z\",\"created_at\":\"2026-04-14T17:37:42.000000Z\",\"id\":6}','Sale created through POS',2,'Ayoub Oumar','2026-04-14 14:37:42','2026-04-14 14:37:42'),
(8,7,'created',NULL,NULL,'{\"sale_number\":\"INV-1007\",\"sale_type\":\"market\",\"customer_name\":null,\"customer_phone\":null,\"customer_email\":null,\"subtotal\":\"25000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"25000.00\",\"paid_amount\":\"25000.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"sale_date\":\"2026-04-15T16:36:16.000000Z\",\"cashier_id\":2,\"is_loan\":false,\"loan_amount\":\"0.00\",\"collected_amount\":\"25000.00\",\"payment_status\":\"paid\",\"updated_at\":\"2026-04-15T16:36:16.000000Z\",\"created_at\":\"2026-04-15T16:36:16.000000Z\",\"id\":7}','Sale created through POS',2,'Ayoub Oumar','2026-04-15 13:36:16','2026-04-15 13:36:16'),
(9,8,'created',NULL,NULL,'{\"sale_number\":\"INV-1008\",\"sale_type\":\"market\",\"customer_name\":null,\"customer_phone\":null,\"customer_email\":null,\"subtotal\":\"10000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"10000.00\",\"paid_amount\":\"10000.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"sale_date\":\"2026-04-15T16:36:32.000000Z\",\"cashier_id\":2,\"is_loan\":false,\"loan_amount\":\"0.00\",\"collected_amount\":\"10000.00\",\"payment_status\":\"paid\",\"updated_at\":\"2026-04-15T16:36:32.000000Z\",\"created_at\":\"2026-04-15T16:36:32.000000Z\",\"id\":8}','Sale created through POS',2,'Ayoub Oumar','2026-04-15 13:36:33','2026-04-15 13:36:33'),
(10,9,'created',NULL,NULL,'{\"sale_number\":\"INV-1009\",\"sale_type\":\"market\",\"customer_name\":\"Soumayya\",\"customer_phone\":\"---\",\"customer_email\":null,\"subtotal\":\"30000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"30000.00\",\"paid_amount\":\"0.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"sale_date\":\"2026-04-15T16:37:18.000000Z\",\"cashier_id\":2,\"is_loan\":true,\"loan_amount\":\"30000.00\",\"collected_amount\":\"0.00\",\"payment_status\":\"unpaid\",\"updated_at\":\"2026-04-15T16:37:18.000000Z\",\"created_at\":\"2026-04-15T16:37:18.000000Z\",\"id\":9}','Sale created through POS',2,'Ayoub Oumar','2026-04-15 13:37:19','2026-04-15 13:37:19'),
(11,4,'payment_received','{\"loan_amount\":{\"old\":\"9000.00\",\"new\":\"2000.00\"},\"collected_amount\":{\"old\":\"15000.00\",\"new\":\"22000.00\"}}',NULL,'{\"payment_amount\":7000,\"payment_method\":\"cash\",\"payment_notes\":null,\"balance_after\":2000}','Payment received: 7,000 CFA via Cash',2,'Ayoub Oumar','2026-04-19 05:16:07','2026-04-19 05:16:07'),
(12,9,'updated','{\"customer_name\":{\"old\":\"Soumayya\",\"new\":\"Sim Sim\"},\"customer_phone\":{\"old\":\"---\",\"new\":\"----\"}}',NULL,'{\"id\":9,\"sale_number\":\"INV-1009\",\"sale_type\":\"market\",\"customer_name\":\"Sim Sim\",\"customer_phone\":\"----\",\"customer_email\":null,\"subtotal\":\"30000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"30000.00\",\"loan_amount\":\"30000.00\",\"collected_amount\":\"0.00\",\"is_loan\":true,\"paid_amount\":\"0.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"payment_status\":\"unpaid\",\"sale_status\":\"completed\",\"notes\":null,\"cashier_id\":\"2\",\"client_id\":\"1\",\"sale_date\":\"2026-04-19T11:19:31.000000Z\",\"created_at\":\"2026-04-15T16:37:18.000000Z\",\"updated_at\":\"2026-04-19T08:19:31.000000Z\",\"items\":[{\"id\":9,\"sale_id\":\"9\",\"product_id\":\"1\",\"product_name\":\"Bags-2\",\"product_barcode\":null,\"quantity\":2,\"unit_price\":\"15000.00\",\"tax_rate\":\"0.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"30000.00\",\"created_at\":\"2026-04-15T16:37:19.000000Z\",\"updated_at\":\"2026-04-15T16:37:19.000000Z\"}],\"cashier\":{\"id\":2,\"name\":\"Ayoub Oumar\",\"email\":\"ayoub.oumar919@gmail.com\",\"user_type\":\"admin\",\"is_active\":true,\"preferred_language\":\"en\",\"email_verified_at\":\"2026-04-14T10:26:40.000000Z\",\"two_factor_confirmed_at\":null,\"current_team_id\":null,\"profile_photo_path\":null,\"created_at\":\"2026-04-14T10:26:40.000000Z\",\"updated_at\":\"2026-04-14T10:26:40.000000Z\",\"profile_photo_url\":\"https:\\/\\/ui-avatars.com\\/api\\/?name=A+O&color=7F9CF5&background=EBF4FF\"}}','Sale updated from POS interface',2,'Ayoub Oumar','2026-04-19 05:19:31','2026-04-19 05:19:31'),
(13,4,'payment_received','{\"payment_status\":{\"old\":\"partial\",\"new\":\"paid\"},\"loan_amount\":{\"old\":\"2000.00\",\"new\":\"0.00\"},\"collected_amount\":{\"old\":\"22000.00\",\"new\":\"24000.00\"},\"is_loan\":{\"old\":true,\"new\":false}}',NULL,'{\"payment_amount\":2000,\"payment_method\":\"cash\",\"payment_notes\":null,\"balance_after\":0}','Payment received: 2,000 CFA via Cash',2,'Ayoub Oumar','2026-04-20 17:44:11','2026-04-20 17:44:11'),
(14,10,'created',NULL,NULL,'{\"sale_number\":\"INV-1010\",\"sale_type\":\"market\",\"customer_name\":\"Naddoya\",\"customer_phone\":\"---\",\"customer_email\":null,\"subtotal\":\"20000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"20000.00\",\"paid_amount\":\"0.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"client_id\":1,\"sale_date\":\"2026-04-20T20:49:55.000000Z\",\"cashier_id\":2,\"is_loan\":true,\"loan_amount\":\"20000.00\",\"collected_amount\":\"0.00\",\"payment_status\":\"unpaid\",\"updated_at\":\"2026-04-20T20:49:55.000000Z\",\"created_at\":\"2026-04-20T20:49:55.000000Z\",\"id\":10}','Sale created through POS',2,'Ayoub Oumar','2026-04-20 17:49:55','2026-04-20 17:49:55'),
(15,11,'created',NULL,NULL,'{\"sale_number\":\"INV-1011\",\"sale_type\":\"market\",\"customer_name\":\"Clien de Nadia\",\"customer_phone\":\"---\",\"customer_email\":null,\"subtotal\":\"50000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"50000.00\",\"paid_amount\":\"0.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"client_id\":1,\"sale_date\":\"2026-04-20T20:50:31.000000Z\",\"cashier_id\":2,\"is_loan\":true,\"loan_amount\":\"50000.00\",\"collected_amount\":\"0.00\",\"payment_status\":\"unpaid\",\"updated_at\":\"2026-04-20T20:50:31.000000Z\",\"created_at\":\"2026-04-20T20:50:31.000000Z\",\"id\":11}','Sale created through POS',2,'Ayoub Oumar','2026-04-20 17:50:31','2026-04-20 17:50:31'),
(16,11,'cancelled','{\"sale_status\":{\"old\":\"completed\",\"new\":\"cancelled\"},\"payment_status\":{\"old\":\"unpaid\",\"new\":\"refunded\"}}',NULL,'{\"id\":11,\"sale_number\":\"INV-1011\",\"sale_type\":\"market\",\"customer_name\":\"Clien de Nadia\",\"customer_phone\":\"---\",\"customer_email\":null,\"subtotal\":\"50000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"50000.00\",\"loan_amount\":\"50000.00\",\"collected_amount\":\"0.00\",\"is_loan\":true,\"paid_amount\":\"0.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"payment_status\":\"refunded\",\"sale_status\":\"cancelled\",\"notes\":\"\\n\\nCancelled: Error\",\"cashier_id\":\"2\",\"client_id\":\"1\",\"sale_date\":\"2026-04-20T20:50:31.000000Z\",\"created_at\":\"2026-04-20T20:50:31.000000Z\",\"updated_at\":\"2026-04-20T20:51:49.000000Z\",\"items\":[{\"id\":11,\"sale_id\":\"11\",\"product_id\":\"3\",\"product_name\":\"Bags 3\",\"product_barcode\":null,\"quantity\":5,\"unit_price\":\"10000.00\",\"tax_rate\":\"0.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"50000.00\",\"created_at\":\"2026-04-20T20:50:31.000000Z\",\"updated_at\":\"2026-04-20T20:50:31.000000Z\",\"product\":{\"id\":3,\"name\":\"Bags 3\",\"description\":null,\"barcode\":\"PRD139272\",\"category_id\":\"1\",\"product_type\":\"market\",\"unit\":\"pcs\",\"alert_quantity\":1,\"cost_price\":\"7500.00\",\"selling_price\":\"10000.00\",\"discount_price\":null,\"image\":null,\"expiry_date\":null,\"is_active\":true,\"weight\":null,\"length\":null,\"width\":null,\"height\":null,\"created_at\":\"2026-04-20T20:45:55.000000Z\",\"updated_at\":\"2026-04-20T20:45:55.000000Z\",\"deleted_at\":null,\"inventory\":{\"id\":3,\"product_id\":\"3\",\"current_stock\":13,\"reserved_stock\":0,\"available_stock\":13,\"last_stock_update\":\"2026-04-20T20:51:49.000000Z\",\"last_updated_by\":2,\"created_at\":\"2026-04-20T20:45:55.000000Z\",\"updated_at\":\"2026-04-20T20:51:49.000000Z\"}}}],\"cashier\":{\"id\":2,\"name\":\"Ayoub Oumar\",\"email\":\"ayoub.oumar919@gmail.com\",\"user_type\":\"admin\",\"is_active\":true,\"preferred_language\":\"en\",\"email_verified_at\":\"2026-04-14T10:26:40.000000Z\",\"two_factor_confirmed_at\":null,\"current_team_id\":null,\"profile_photo_path\":null,\"created_at\":\"2026-04-14T10:26:40.000000Z\",\"updated_at\":\"2026-04-14T10:26:40.000000Z\",\"profile_photo_url\":\"https:\\/\\/ui-avatars.com\\/api\\/?name=A+O&color=7F9CF5&background=EBF4FF\"}}','Error',2,'Ayoub Oumar','2026-04-20 17:51:49','2026-04-20 17:51:49'),
(17,10,'cancelled','{\"sale_status\":{\"old\":\"completed\",\"new\":\"cancelled\"},\"payment_status\":{\"old\":\"unpaid\",\"new\":\"refunded\"}}',NULL,'{\"id\":10,\"sale_number\":\"INV-1010\",\"sale_type\":\"market\",\"customer_name\":\"Naddoya\",\"customer_phone\":\"---\",\"customer_email\":null,\"subtotal\":\"20000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"20000.00\",\"loan_amount\":\"20000.00\",\"collected_amount\":\"0.00\",\"is_loan\":true,\"paid_amount\":\"0.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"payment_status\":\"refunded\",\"sale_status\":\"cancelled\",\"notes\":\"\\n\\nCancelled: Error\",\"cashier_id\":\"2\",\"client_id\":\"1\",\"sale_date\":\"2026-04-20T20:49:55.000000Z\",\"created_at\":\"2026-04-20T20:49:55.000000Z\",\"updated_at\":\"2026-04-20T20:52:33.000000Z\",\"items\":[{\"id\":10,\"sale_id\":\"10\",\"product_id\":\"3\",\"product_name\":\"Bags 3\",\"product_barcode\":null,\"quantity\":2,\"unit_price\":\"10000.00\",\"tax_rate\":\"0.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"20000.00\",\"created_at\":\"2026-04-20T20:49:55.000000Z\",\"updated_at\":\"2026-04-20T20:49:55.000000Z\",\"product\":{\"id\":3,\"name\":\"Bags 3\",\"description\":null,\"barcode\":\"PRD139272\",\"category_id\":\"1\",\"product_type\":\"market\",\"unit\":\"pcs\",\"alert_quantity\":1,\"cost_price\":\"7500.00\",\"selling_price\":\"10000.00\",\"discount_price\":null,\"image\":null,\"expiry_date\":null,\"is_active\":true,\"weight\":null,\"length\":null,\"width\":null,\"height\":null,\"created_at\":\"2026-04-20T20:45:55.000000Z\",\"updated_at\":\"2026-04-20T20:45:55.000000Z\",\"deleted_at\":null,\"inventory\":{\"id\":3,\"product_id\":\"3\",\"current_stock\":15,\"reserved_stock\":0,\"available_stock\":15,\"last_stock_update\":\"2026-04-20T20:52:33.000000Z\",\"last_updated_by\":2,\"created_at\":\"2026-04-20T20:45:55.000000Z\",\"updated_at\":\"2026-04-20T20:52:33.000000Z\"}}}],\"cashier\":{\"id\":2,\"name\":\"Ayoub Oumar\",\"email\":\"ayoub.oumar919@gmail.com\",\"user_type\":\"admin\",\"is_active\":true,\"preferred_language\":\"en\",\"email_verified_at\":\"2026-04-14T10:26:40.000000Z\",\"two_factor_confirmed_at\":null,\"current_team_id\":null,\"profile_photo_path\":null,\"created_at\":\"2026-04-14T10:26:40.000000Z\",\"updated_at\":\"2026-04-14T10:26:40.000000Z\",\"profile_photo_url\":\"https:\\/\\/ui-avatars.com\\/api\\/?name=A+O&color=7F9CF5&background=EBF4FF\"}}','Error',2,'Ayoub Oumar','2026-04-20 17:52:33','2026-04-20 17:52:33'),
(18,12,'created',NULL,NULL,'{\"sale_number\":\"INV-1012\",\"sale_type\":\"market\",\"customer_name\":\"Nadia\",\"customer_phone\":\"60 58 05 26\",\"customer_email\":null,\"subtotal\":\"20000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"20000.00\",\"paid_amount\":\"0.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"client_id\":2,\"sale_date\":\"2026-04-20T20:55:03.000000Z\",\"cashier_id\":2,\"is_loan\":true,\"loan_amount\":\"20000.00\",\"collected_amount\":\"0.00\",\"payment_status\":\"unpaid\",\"updated_at\":\"2026-04-20T20:55:03.000000Z\",\"created_at\":\"2026-04-20T20:55:03.000000Z\",\"id\":12}','Sale created through POS',2,'Ayoub Oumar','2026-04-20 17:55:03','2026-04-20 17:55:03'),
(19,13,'created',NULL,NULL,'{\"sale_number\":\"INV-1013\",\"sale_type\":\"market\",\"customer_name\":\"Nadia\'s Clients\",\"customer_phone\":\"99 58 05 26\",\"customer_email\":null,\"subtotal\":\"50000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"50000.00\",\"paid_amount\":\"0.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"client_id\":3,\"sale_date\":\"2026-04-20T20:56:12.000000Z\",\"cashier_id\":2,\"is_loan\":true,\"loan_amount\":\"50000.00\",\"collected_amount\":\"0.00\",\"payment_status\":\"unpaid\",\"updated_at\":\"2026-04-20T20:56:12.000000Z\",\"created_at\":\"2026-04-20T20:56:12.000000Z\",\"id\":13}','Sale created through POS',2,'Ayoub Oumar','2026-04-20 17:56:12','2026-04-20 17:56:12'),
(20,14,'created',NULL,NULL,'{\"sale_number\":\"INV-1014\",\"sale_type\":\"market\",\"customer_name\":\"Khadidja Oumar\",\"customer_phone\":\"61\",\"customer_email\":null,\"subtotal\":\"15000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"15000.00\",\"paid_amount\":\"0.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"client_id\":4,\"sale_date\":\"2026-04-20T20:56:56.000000Z\",\"cashier_id\":2,\"is_loan\":true,\"loan_amount\":\"15000.00\",\"collected_amount\":\"0.00\",\"payment_status\":\"unpaid\",\"updated_at\":\"2026-04-20T20:56:56.000000Z\",\"created_at\":\"2026-04-20T20:56:56.000000Z\",\"id\":14}','Sale created through POS',2,'Ayoub Oumar','2026-04-20 17:56:56','2026-04-20 17:56:56'),
(21,15,'created',NULL,NULL,'{\"sale_number\":\"INV-1015\",\"sale_type\":\"market\",\"customer_name\":\"Fatime\",\"customer_phone\":\"62\",\"customer_email\":null,\"subtotal\":\"15000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"15000.00\",\"paid_amount\":\"15000.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"client_id\":5,\"sale_date\":\"2026-04-20T20:58:45.000000Z\",\"cashier_id\":2,\"is_loan\":false,\"loan_amount\":\"0.00\",\"collected_amount\":\"15000.00\",\"payment_status\":\"paid\",\"updated_at\":\"2026-04-20T20:58:45.000000Z\",\"created_at\":\"2026-04-20T20:58:45.000000Z\",\"id\":15}','Sale created through POS',2,'Ayoub Oumar','2026-04-20 17:58:45','2026-04-20 17:58:45'),
(22,16,'created',NULL,NULL,'{\"sale_number\":\"INV-1016\",\"sale_type\":\"market\",\"customer_name\":\"Asia\",\"customer_phone\":\"63\",\"customer_email\":null,\"subtotal\":\"15000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"15000.00\",\"paid_amount\":\"0.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"client_id\":6,\"sale_date\":\"2026-04-20T20:59:07.000000Z\",\"cashier_id\":2,\"is_loan\":true,\"loan_amount\":\"15000.00\",\"collected_amount\":\"0.00\",\"payment_status\":\"unpaid\",\"updated_at\":\"2026-04-20T20:59:07.000000Z\",\"created_at\":\"2026-04-20T20:59:07.000000Z\",\"id\":16}','Sale created through POS',2,'Ayoub Oumar','2026-04-20 17:59:07','2026-04-20 17:59:07'),
(23,15,'cancelled','{\"sale_status\":{\"old\":\"completed\",\"new\":\"cancelled\"},\"payment_status\":{\"old\":\"paid\",\"new\":\"refunded\"}}',NULL,'{\"id\":15,\"sale_number\":\"INV-1015\",\"sale_type\":\"market\",\"customer_name\":\"Fatime\",\"customer_phone\":\"62\",\"customer_email\":null,\"subtotal\":\"15000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"15000.00\",\"loan_amount\":\"0.00\",\"collected_amount\":\"15000.00\",\"is_loan\":false,\"paid_amount\":\"15000.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"payment_status\":\"refunded\",\"sale_status\":\"cancelled\",\"notes\":\"\\n\\nCancelled: Error\",\"cashier_id\":\"2\",\"client_id\":\"5\",\"sale_date\":\"2026-04-20T20:58:45.000000Z\",\"created_at\":\"2026-04-20T20:58:45.000000Z\",\"updated_at\":\"2026-04-20T21:00:56.000000Z\",\"items\":[{\"id\":15,\"sale_id\":\"15\",\"product_id\":\"3\",\"product_name\":\"Bags 3\",\"product_barcode\":null,\"quantity\":1,\"unit_price\":\"15000.00\",\"tax_rate\":\"0.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"15000.00\",\"created_at\":\"2026-04-20T20:58:45.000000Z\",\"updated_at\":\"2026-04-20T20:58:45.000000Z\",\"product\":{\"id\":3,\"name\":\"Bags 3\",\"description\":null,\"barcode\":\"PRD139272\",\"category_id\":\"1\",\"product_type\":\"market\",\"unit\":\"pcs\",\"alert_quantity\":1,\"cost_price\":\"7500.00\",\"selling_price\":\"10000.00\",\"discount_price\":null,\"image\":null,\"expiry_date\":null,\"is_active\":true,\"weight\":null,\"length\":null,\"width\":null,\"height\":null,\"created_at\":\"2026-04-20T20:45:55.000000Z\",\"updated_at\":\"2026-04-20T20:45:55.000000Z\",\"deleted_at\":null,\"inventory\":{\"id\":3,\"product_id\":\"3\",\"current_stock\":6,\"reserved_stock\":0,\"available_stock\":6,\"last_stock_update\":\"2026-04-20T21:00:56.000000Z\",\"last_updated_by\":2,\"created_at\":\"2026-04-20T20:45:55.000000Z\",\"updated_at\":\"2026-04-20T21:00:56.000000Z\"}}}],\"cashier\":{\"id\":2,\"name\":\"Ayoub Oumar\",\"email\":\"ayoub.oumar919@gmail.com\",\"user_type\":\"admin\",\"is_active\":true,\"preferred_language\":\"en\",\"email_verified_at\":\"2026-04-14T10:26:40.000000Z\",\"two_factor_confirmed_at\":null,\"current_team_id\":null,\"profile_photo_path\":null,\"created_at\":\"2026-04-14T10:26:40.000000Z\",\"updated_at\":\"2026-04-14T10:26:40.000000Z\",\"profile_photo_url\":\"https:\\/\\/ui-avatars.com\\/api\\/?name=A+O&color=7F9CF5&background=EBF4FF\"}}','Error',2,'Ayoub Oumar','2026-04-20 18:00:56','2026-04-20 18:00:56'),
(24,17,'created',NULL,NULL,'{\"sale_number\":\"INV-1017\",\"sale_type\":\"market\",\"customer_name\":\"Fatime\",\"customer_phone\":\"62\",\"customer_email\":null,\"subtotal\":\"15000.00\",\"tax_amount\":\"0.00\",\"discount_amount\":\"0.00\",\"total_amount\":\"15000.00\",\"paid_amount\":\"0.00\",\"change_amount\":\"0.00\",\"payment_method\":\"cash\",\"sale_status\":\"completed\",\"notes\":null,\"client_id\":5,\"sale_date\":\"2026-04-20T21:01:31.000000Z\",\"cashier_id\":2,\"is_loan\":true,\"loan_amount\":\"15000.00\",\"collected_amount\":\"0.00\",\"payment_status\":\"unpaid\",\"updated_at\":\"2026-04-20T21:01:31.000000Z\",\"created_at\":\"2026-04-20T21:01:31.000000Z\",\"id\":17}','Sale created through POS',2,'Ayoub Oumar','2026-04-20 18:01:31','2026-04-20 18:01:31');

--
-- Table structure for table `sale_items`
--

CREATE TABLE `sale_items` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `sale_id` bigint(20) unsigned NOT NULL,
  `product_id` bigint(20) unsigned NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `product_barcode` varchar(255) DEFAULT NULL,
  `quantity` int(11) NOT NULL,
  `unit_price` decimal(10,2) NOT NULL,
  `tax_rate` decimal(5,2) NOT NULL DEFAULT 0.00,
  `tax_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `discount_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `total_amount` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sale_items_sale_id_index` (`sale_id`),
  KEY `sale_items_product_id_index` (`product_id`),
  CONSTRAINT `sale_items_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`),
  CONSTRAINT `sale_items_sale_id_foreign` FOREIGN KEY (`sale_id`) REFERENCES `sales` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `sale_items`
--

INSERT INTO `sale_items` VALUES
(1,1,2,'Astronot',NULL,1,25000.00,0.00,0.00,0.00,25000.00,'2026-04-10 13:22:52','2026-04-10 13:22:52'),
(2,2,1,'Bags',NULL,1,12000.00,0.00,0.00,0.00,12000.00,'2026-04-10 16:31:24','2026-04-10 16:31:24'),
(3,3,1,'Bags',NULL,7,11150.00,0.00,0.00,50.00,78000.00,'2026-04-12 15:17:23','2026-04-12 15:17:23'),
(4,4,1,'Bags',NULL,2,12000.00,0.00,0.00,0.00,24000.00,'2026-04-12 15:29:21','2026-04-12 15:29:21'),
(5,5,1,'Bags',NULL,1,12000.00,0.00,0.00,0.00,12000.00,'2026-04-14 14:37:19','2026-04-14 14:37:19'),
(6,6,1,'Bags',NULL,1,10000.00,0.00,0.00,0.00,10000.00,'2026-04-14 14:37:42','2026-04-14 14:37:42'),
(7,7,1,'Bags-2',NULL,2,12500.00,0.00,0.00,0.00,25000.00,'2026-04-15 13:36:16','2026-04-15 13:36:16'),
(8,8,1,'Bags-2',NULL,1,10000.00,0.00,0.00,0.00,10000.00,'2026-04-15 13:36:33','2026-04-15 13:36:33'),
(9,9,1,'Bags-2',NULL,2,15000.00,0.00,0.00,0.00,30000.00,'2026-04-15 13:37:19','2026-04-15 13:37:19'),
(10,10,3,'Bags 3',NULL,2,10000.00,0.00,0.00,0.00,20000.00,'2026-04-20 17:49:55','2026-04-20 17:49:55'),
(11,11,3,'Bags 3',NULL,5,10000.00,0.00,0.00,0.00,50000.00,'2026-04-20 17:50:31','2026-04-20 17:50:31'),
(12,12,3,'Bags 3',NULL,2,10000.00,0.00,0.00,0.00,20000.00,'2026-04-20 17:55:03','2026-04-20 17:55:03'),
(13,13,3,'Bags 3',NULL,5,10000.00,0.00,0.00,0.00,50000.00,'2026-04-20 17:56:12','2026-04-20 17:56:12'),
(14,14,3,'Bags 3',NULL,1,15000.00,0.00,0.00,0.00,15000.00,'2026-04-20 17:56:56','2026-04-20 17:56:56'),
(15,15,3,'Bags 3',NULL,1,15000.00,0.00,0.00,0.00,15000.00,'2026-04-20 17:58:45','2026-04-20 17:58:45'),
(16,16,3,'Bags 3',NULL,1,15000.00,0.00,0.00,0.00,15000.00,'2026-04-20 17:59:07','2026-04-20 17:59:07'),
(17,17,3,'Bags 3',NULL,1,15000.00,0.00,0.00,0.00,15000.00,'2026-04-20 18:01:31','2026-04-20 18:01:31');

--
-- Table structure for table `sales`
--

CREATE TABLE `sales` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `sale_number` varchar(255) NOT NULL,
  `sale_type` enum('market','store') NOT NULL,
  `customer_name` varchar(255) DEFAULT NULL,
  `customer_phone` varchar(20) DEFAULT NULL,
  `customer_email` varchar(255) DEFAULT NULL,
  `subtotal` decimal(10,2) NOT NULL DEFAULT 0.00,
  `tax_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `discount_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `total_amount` decimal(10,2) NOT NULL,
  `loan_amount` decimal(15,2) DEFAULT NULL,
  `collected_amount` decimal(15,2) NOT NULL DEFAULT 0.00,
  `is_loan` tinyint(1) NOT NULL DEFAULT 0,
  `paid_amount` decimal(10,2) NOT NULL,
  `change_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `payment_method` enum('cash','card','mobile_payment') NOT NULL,
  `payment_status` enum('paid','partial','unpaid','refunded') NOT NULL DEFAULT 'paid',
  `sale_status` enum('completed','pending','cancelled','refunded') NOT NULL DEFAULT 'completed',
  `notes` text DEFAULT NULL,
  `cashier_id` bigint(20) unsigned NOT NULL,
  `client_id` bigint(20) unsigned DEFAULT NULL,
  `sale_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `sales_sale_number_unique` (`sale_number`),
  KEY `sales_sale_type_sale_status_index` (`sale_type`,`sale_status`),
  KEY `sales_sale_date_index` (`sale_date`),
  KEY `sales_payment_status_index` (`payment_status`),
  KEY `sales_cashier_id_index` (`cashier_id`),
  KEY `sales_client_id_foreign` (`client_id`),
  CONSTRAINT `sales_cashier_id_foreign` FOREIGN KEY (`cashier_id`) REFERENCES `users` (`id`),
  CONSTRAINT `sales_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `sales`
--

INSERT INTO `sales` VALUES
(1,'INV-1001','market','Bon','---',NULL,25000.00,0.00,0.00,25000.00,10000.00,15000.00,1,0.00,0.00,'cash','partial','completed',NULL,1,1,'2026-04-20 20:53:52','2026-04-10 13:22:52','2026-04-20 17:53:52'),
(2,'INV-1002','market','Bon','---',NULL,12000.00,0.00,0.00,12000.00,0.00,12000.00,0,12000.00,0.00,'cash','paid','completed',NULL,1,1,'2026-04-20 20:53:52','2026-04-10 16:31:24','2026-04-20 17:53:52'),
(3,'INV-1003','market',NULL,NULL,NULL,78050.00,0.00,50.00,78000.00,0.00,78000.00,0,78000.00,0.00,'cash','paid','completed',NULL,1,NULL,'2026-04-12 15:17:23','2026-04-12 15:17:23','2026-04-12 15:17:23'),
(4,'INV-1004','market','Bon','---',NULL,24000.00,0.00,0.00,24000.00,0.00,24000.00,0,15000.00,0.00,'cash','paid','completed',NULL,1,1,'2026-04-20 20:53:52','2026-04-12 15:29:21','2026-04-20 17:53:52'),
(5,'INV-1005','market','Bon','---',NULL,12000.00,0.00,0.00,12000.00,0.00,12000.00,0,12000.00,0.00,'cash','paid','completed',NULL,2,1,'2026-04-20 20:53:52','2026-04-14 14:37:19','2026-04-20 17:53:52'),
(6,'INV-1006','market','Bon','---',NULL,10000.00,0.00,0.00,10000.00,0.00,10000.00,0,10000.00,0.00,'cash','paid','completed',NULL,2,1,'2026-04-20 20:53:52','2026-04-14 14:37:42','2026-04-20 17:53:52'),
(7,'INV-1007','market',NULL,NULL,NULL,25000.00,0.00,0.00,25000.00,0.00,25000.00,0,25000.00,0.00,'cash','paid','completed',NULL,2,NULL,'2026-04-15 13:36:16','2026-04-15 13:36:16','2026-04-15 13:36:16'),
(8,'INV-1008','market',NULL,NULL,NULL,10000.00,0.00,0.00,10000.00,0.00,10000.00,0,10000.00,0.00,'cash','paid','completed',NULL,2,NULL,'2026-04-15 13:36:32','2026-04-15 13:36:32','2026-04-15 13:36:32'),
(9,'INV-1009','market','Bon','----',NULL,30000.00,0.00,0.00,30000.00,30000.00,0.00,1,0.00,0.00,'cash','unpaid','completed',NULL,2,1,'2026-04-20 20:53:52','2026-04-15 13:37:18','2026-04-20 17:53:52'),
(10,'INV-1010','market','Bon','---',NULL,20000.00,0.00,0.00,20000.00,20000.00,0.00,1,0.00,0.00,'cash','refunded','cancelled','\n\nCancelled: Error',2,1,'2026-04-20 20:53:52','2026-04-20 17:49:55','2026-04-20 17:53:52'),
(11,'INV-1011','market','Bon','---',NULL,50000.00,0.00,0.00,50000.00,50000.00,0.00,1,0.00,0.00,'cash','refunded','cancelled','\n\nCancelled: Error',2,1,'2026-04-20 20:53:52','2026-04-20 17:50:31','2026-04-20 17:53:52'),
(12,'INV-1012','market','Nadia','60 58 05 26',NULL,20000.00,0.00,0.00,20000.00,20000.00,0.00,1,0.00,0.00,'cash','unpaid','completed',NULL,2,2,'2026-04-20 17:55:03','2026-04-20 17:55:03','2026-04-20 17:55:03'),
(13,'INV-1013','market','Nadia\'s Clients','99 58 05 26',NULL,50000.00,0.00,0.00,50000.00,50000.00,0.00,1,0.00,0.00,'cash','unpaid','completed',NULL,2,3,'2026-04-20 17:56:12','2026-04-20 17:56:12','2026-04-20 17:56:12'),
(14,'INV-1014','market','Khadidja Oumar','61',NULL,15000.00,0.00,0.00,15000.00,15000.00,0.00,1,0.00,0.00,'cash','unpaid','completed',NULL,2,4,'2026-04-20 17:56:56','2026-04-20 17:56:56','2026-04-20 17:56:56'),
(15,'INV-1015','market','Fatime','62',NULL,15000.00,0.00,0.00,15000.00,0.00,15000.00,0,15000.00,0.00,'cash','refunded','cancelled','\n\nCancelled: Error',2,5,'2026-04-20 21:00:56','2026-04-20 17:58:45','2026-04-20 18:00:56'),
(16,'INV-1016','market','Asia','63',NULL,15000.00,0.00,0.00,15000.00,15000.00,0.00,1,0.00,0.00,'cash','unpaid','completed',NULL,2,6,'2026-04-20 17:59:07','2026-04-20 17:59:07','2026-04-20 17:59:07'),
(17,'INV-1017','market','Fatime','62',NULL,15000.00,0.00,0.00,15000.00,15000.00,0.00,1,0.00,0.00,'cash','unpaid','completed',NULL,2,5,'2026-04-20 18:01:31','2026-04-20 18:01:31','2026-04-20 18:01:31');

--
-- Table structure for table `sessions`
--

CREATE TABLE `sessions` (
  `id` varchar(255) NOT NULL,
  `user_id` bigint(20) unsigned DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `payload` longtext NOT NULL,
  `last_activity` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `sessions_user_id_index` (`user_id`),
  KEY `sessions_last_activity_index` (`last_activity`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `sessions`
--


--
-- Table structure for table `withdrawals`
--

CREATE TABLE `withdrawals` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `reason` text DEFAULT NULL,
  `status` enum('completed','cancelled') NOT NULL DEFAULT 'completed',
  `balance_before` decimal(15,2) NOT NULL,
  `balance_after` decimal(15,2) NOT NULL,
  `withdrawal_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `withdrawals_user_id_withdrawal_date_index` (`user_id`,`withdrawal_date`),
  KEY `withdrawals_status_withdrawal_date_index` (`status`,`withdrawal_date`),
  CONSTRAINT `withdrawals_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `withdrawals`
--



