-- --------------------------------------------------------
-- Host:                         127.0.0.1
-- Server version:               5.7.17-log - MySQL Community Server (GPL)
-- Server OS:                    Win64
-- HeidiSQL Version:             11.2.0.6213
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


-- Dumping database structure for posai
DROP DATABASE IF EXISTS `posai`;
CREATE DATABASE IF NOT EXISTS `posai` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `posai`;

-- Dumping structure for table posai.branches
DROP TABLE IF EXISTS `branches`;
CREATE TABLE IF NOT EXISTS `branches` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `location` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` text COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `is_default` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.branches: ~3 rows (approximately)
/*!40000 ALTER TABLE `branches` DISABLE KEYS */;
REPLACE INTO `branches` (`id`, `name`, `location`, `phone`, `email`, `address`, `is_active`, `is_default`, `created_at`, `updated_at`) VALUES
	(1, 'Main Branch', 'Nairobi CBD', '+254700000001', 'main@pos.com', 'Kenyatta Avenue, Nairobi', 1, 1, '2026-03-29 18:34:22', '2026-03-29 18:34:22'),
	(2, 'Westlands Branch', 'Westlands, Nairobi', '+254700000002', 'westlands@pos.com', 'Westlands Business Centre, Nairobi', 1, 0, '2026-03-29 18:34:22', '2026-03-29 18:34:22'),
	(3, 'Mombasa Branch', 'Mombasa CBD', '+254700000003', 'mombasa@pos.com', 'Mombasa Road, Mombasa', 1, 0, '2026-03-29 18:34:22', '2026-03-29 18:34:22');
/*!40000 ALTER TABLE `branches` ENABLE KEYS */;

-- Dumping structure for table posai.cache
DROP TABLE IF EXISTS `cache`;
CREATE TABLE IF NOT EXISTS `cache` (
  `key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiration` int(11) NOT NULL,
  PRIMARY KEY (`key`),
  KEY `cache_expiration_index` (`expiration`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.cache: ~0 rows (approximately)
/*!40000 ALTER TABLE `cache` DISABLE KEYS */;
/*!40000 ALTER TABLE `cache` ENABLE KEYS */;

-- Dumping structure for table posai.cache_locks
DROP TABLE IF EXISTS `cache_locks`;
CREATE TABLE IF NOT EXISTS `cache_locks` (
  `key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiration` int(11) NOT NULL,
  PRIMARY KEY (`key`),
  KEY `cache_locks_expiration_index` (`expiration`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.cache_locks: ~0 rows (approximately)
/*!40000 ALTER TABLE `cache_locks` DISABLE KEYS */;
/*!40000 ALTER TABLE `cache_locks` ENABLE KEYS */;

-- Dumping structure for table posai.categories
DROP TABLE IF EXISTS `categories`;
CREATE TABLE IF NOT EXISTS `categories` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `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 `categories_slug_unique` (`slug`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.categories: ~2 rows (approximately)
/*!40000 ALTER TABLE `categories` DISABLE KEYS */;
REPLACE INTO `categories` (`id`, `name`, `slug`, `description`, `is_active`, `created_at`, `updated_at`) VALUES
	(9, 'Fruits', 'fruits', NULL, 1, '2026-03-29 15:55:32', '2026-03-29 15:55:32'),
	(10, 'Food', 'food', 'food', 1, '2026-03-29 16:36:53', '2026-03-29 16:36:53');
/*!40000 ALTER TABLE `categories` ENABLE KEYS */;

-- Dumping structure for table posai.credit_payments
DROP TABLE IF EXISTS `credit_payments`;
CREATE TABLE IF NOT EXISTS `credit_payments` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint(20) unsigned NOT NULL,
  `customer_id` bigint(20) unsigned NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `balance_before` decimal(12,2) DEFAULT '0.00',
  `balance_after` decimal(12,2) DEFAULT '0.00',
  `payment_method` varchar(255) DEFAULT 'cash',
  `reference_number` varchar(255) DEFAULT NULL,
  `notes` text,
  `user_id` bigint(20) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`),
  KEY `customer_id` (`customer_id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `credit_payments_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `credit_payments_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE CASCADE,
  CONSTRAINT `credit_payments_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

-- Dumping data for table posai.credit_payments: ~0 rows (approximately)
/*!40000 ALTER TABLE `credit_payments` DISABLE KEYS */;
/*!40000 ALTER TABLE `credit_payments` ENABLE KEYS */;

-- Dumping structure for table posai.customers
DROP TABLE IF EXISTS `customers`;
CREATE TABLE IF NOT EXISTS `customers` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` text COLLATE utf8mb4_unicode_ci,
  `balance` decimal(10,2) NOT NULL DEFAULT '0.00',
  `loyalty_points` int(11) NOT NULL DEFAULT '0',
  `total_points_earned` 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`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.customers: ~1 rows (approximately)
/*!40000 ALTER TABLE `customers` DISABLE KEYS */;
REPLACE INTO `customers` (`id`, `name`, `phone`, `email`, `address`, `balance`, `loyalty_points`, `total_points_earned`, `is_active`, `created_at`, `updated_at`) VALUES
	(11, 'kelvin', '701980200', '1moonger@gmail.com', NULL, 0.00, 0, 0, 1, '2026-03-28 09:34:20', '2026-03-29 11:06:52');
/*!40000 ALTER TABLE `customers` ENABLE KEYS */;

-- Dumping structure for table posai.disposed_products
DROP TABLE IF EXISTS `disposed_products`;
CREATE TABLE IF NOT EXISTS `disposed_products` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  `quantity` int(11) NOT NULL,
  `unit_cost` decimal(12,2) DEFAULT NULL,
  `total_value` decimal(12,2) DEFAULT NULL,
  `reason` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `disposed_products_product_id_foreign` (`product_id`),
  KEY `disposed_products_user_id_foreign` (`user_id`),
  CONSTRAINT `disposed_products_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `disposed_products_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 posai.disposed_products: ~1 rows (approximately)
/*!40000 ALTER TABLE `disposed_products` DISABLE KEYS */;
REPLACE INTO `disposed_products` (`id`, `product_id`, `user_id`, `quantity`, `unit_cost`, `total_value`, `reason`, `created_at`, `updated_at`) VALUES
	(5, 29, 5, 5, 40.00, 200.00, 'rotten', '2026-03-29 19:16:30', '2026-03-29 19:16:30');
/*!40000 ALTER TABLE `disposed_products` ENABLE KEYS */;

-- Dumping structure for table posai.etims_configs
DROP TABLE IF EXISTS `etims_configs`;
CREATE TABLE IF NOT EXISTS `etims_configs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `company_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `company_npwp` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_nik` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `branches_id` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `api_url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `api_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `api_secret` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `client_id` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `client_secret` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `machine_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'POS-001',
  `register_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'REG-001',
  `serial_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_production` tinyint(1) NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '0',
  `notes` text COLLATE utf8mb4_unicode_ci,
  `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 posai.etims_configs: ~0 rows (approximately)
/*!40000 ALTER TABLE `etims_configs` DISABLE KEYS */;
/*!40000 ALTER TABLE `etims_configs` ENABLE KEYS */;

-- Dumping structure for table posai.expenses
DROP TABLE IF EXISTS `expenses`;
CREATE TABLE IF NOT EXISTS `expenses` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `category` varchar(255) NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `description` text,
  `expense_date` date NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `branch_id` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `expenses_branch_id_foreign` (`branch_id`),
  CONSTRAINT `expenses_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE SET NULL,
  CONSTRAINT `expenses_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

-- Dumping data for table posai.expenses: ~1 rows (approximately)
/*!40000 ALTER TABLE `expenses` DISABLE KEYS */;
REPLACE INTO `expenses` (`id`, `category`, `amount`, `description`, `expense_date`, `user_id`, `created_at`, `updated_at`, `branch_id`) VALUES
	(1, 'Rent', 1000.00, NULL, '2026-03-29', 5, '2026-03-29 19:26:41', '2026-03-29 19:26:41', NULL);
/*!40000 ALTER TABLE `expenses` ENABLE KEYS */;

-- Dumping structure for table posai.failed_jobs
DROP TABLE IF EXISTS `failed_jobs`;
CREATE TABLE IF NOT EXISTS `failed_jobs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.failed_jobs: ~0 rows (approximately)
/*!40000 ALTER TABLE `failed_jobs` DISABLE KEYS */;
/*!40000 ALTER TABLE `failed_jobs` ENABLE KEYS */;

-- Dumping structure for table posai.inventory_logs
DROP TABLE IF EXISTS `inventory_logs`;
CREATE TABLE IF NOT EXISTS `inventory_logs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  `supplier_id` bigint(20) unsigned DEFAULT NULL,
  `type` enum('stock_in','stock_out','adjustment','opening_balance') NOT NULL,
  `quantity` decimal(12,2) NOT NULL,
  `previous_stock` decimal(12,2) NOT NULL,
  `new_stock` decimal(12,2) NOT NULL,
  `unit_cost` decimal(10,2) DEFAULT NULL,
  `reference_number` text,
  `notes` text,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `branch_id` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_id` (`product_id`),
  KEY `user_id` (`user_id`),
  KEY `supplier_id` (`supplier_id`),
  KEY `inventory_logs_branch_id_foreign` (`branch_id`),
  CONSTRAINT `inventory_logs_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE SET NULL,
  CONSTRAINT `inventory_logs_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `inventory_logs_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `inventory_logs_ibfk_3` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8;

-- Dumping data for table posai.inventory_logs: ~1 rows (approximately)
/*!40000 ALTER TABLE `inventory_logs` DISABLE KEYS */;
REPLACE INTO `inventory_logs` (`id`, `product_id`, `user_id`, `supplier_id`, `type`, `quantity`, `previous_stock`, `new_stock`, `unit_cost`, `reference_number`, `notes`, `created_at`, `updated_at`, `branch_id`) VALUES
	(31, 29, 5, NULL, 'stock_out', 6.00, 5.00, -1.00, NULL, 'INV-20260329-000001', 'Sale', '2026-03-29 19:20:48', '2026-03-29 19:20:48', NULL);
/*!40000 ALTER TABLE `inventory_logs` ENABLE KEYS */;

-- Dumping structure for table posai.jobs
DROP TABLE IF EXISTS `jobs`;
CREATE TABLE IF NOT EXISTS `jobs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `queue` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext COLLATE utf8mb4_unicode_ci 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 posai.jobs: ~0 rows (approximately)
/*!40000 ALTER TABLE `jobs` DISABLE KEYS */;
/*!40000 ALTER TABLE `jobs` ENABLE KEYS */;

-- Dumping structure for table posai.job_batches
DROP TABLE IF EXISTS `job_batches`;
CREATE TABLE IF NOT EXISTS `job_batches` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `total_jobs` int(11) NOT NULL,
  `pending_jobs` int(11) NOT NULL,
  `failed_jobs` int(11) NOT NULL,
  `failed_job_ids` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `options` mediumtext COLLATE utf8mb4_unicode_ci,
  `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 posai.job_batches: ~0 rows (approximately)
/*!40000 ALTER TABLE `job_batches` DISABLE KEYS */;
/*!40000 ALTER TABLE `job_batches` ENABLE KEYS */;

-- Dumping structure for table posai.migrations
DROP TABLE IF EXISTS `migrations`;
CREATE TABLE IF NOT EXISTS `migrations` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=65 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.migrations: ~50 rows (approximately)
/*!40000 ALTER TABLE `migrations` DISABLE KEYS */;
REPLACE INTO `migrations` (`id`, `migration`, `batch`) VALUES
	(1, '0001_01_01_000001_create_cache_table', 1),
	(2, '0001_01_01_000002_create_jobs_table', 1),
	(3, '2024_01_01_000001_create_users_table', 1),
	(4, '2024_01_01_000002_create_categories_table', 1),
	(5, '2024_01_01_000003_create_products_table', 1),
	(6, '2024_01_01_000004_create_customers_table', 1),
	(7, '2024_01_01_000005_create_suppliers_table', 1),
	(8, '2024_01_01_000006_create_orders_table', 1),
	(9, '2024_01_01_000007_create_inventory_logs_table', 1),
	(10, '2024_01_01_000008_create_sessions_table', 1),
	(11, '2024_01_01_000009_create_permissions_table', 1),
	(12, '2026_03_24_164454_update_orders_table_for_multiple_payments', 1),
	(13, '2026_03_25_130701_add_total_paid_to_suppliers_table', 1),
	(14, '2026_03_25_131400_create_expenses_table', 1),
	(15, '2026_03_25_153423_create_opening_balances_table', 1),
	(16, '2026_03_25_160000_create_supplier_payments_table', 1),
	(17, '2026_03_25_164732_add_opening_balance_to_inventory_logs_type', 1),
	(18, '2026_03_25_170000_create_subscriptions_tables', 1),
	(19, '2026_03_25_181947_update_products_stock_quantity_to_decimal', 1),
	(20, '2026_03_25_182031_update_inventory_logs_quantity_to_decimal', 1),
	(21, '2026_03_25_190000_create_tax_configs_table', 1),
	(22, '2026_03_25_191000_add_tax_details_to_orders_table', 1),
	(23, '2026_03_25_200000_create_mpesa_configs_table', 1),
	(24, '2026_03_25_add_theme_to_users', 1),
	(25, '2026_03_26_000000_add_expiry_date_to_products_table', 1),
	(26, '2026_03_26_100000_add_loyalty_points_to_customers_table', 1),
	(27, '2026_03_26_110000_create_settings_table', 1),
	(28, '2026_03_26_120000_add_super_admin_role_to_users', 1),
	(29, '2026_03_26_130000_add_multiple_prices_to_products', 1),
	(30, '2026_03_27_000000_add_price_type_to_order_items_table', 1),
	(31, '2026_03_27_100000_create_price_adjustment_logs_table', 1),
	(44, '2026_03_27_110000_create_price_adjustment_details_table', 2),
	(45, '2026_03_27_120000_create_product_price_history_table', 2),
	(46, '2026_03_27_124603_add_credit_fields_to_orders_table', 2),
	(47, '2026_03_27_133309_add_sms_settings', 2),
	(48, '2026_03_27_135240_add_nenasasa_sms_settings', 2),
	(49, '2026_03_27_143945_add_nenasasa_oauth_settings', 2),
	(50, '2026_03_27_150000_create_user_activity_logs_table', 2),
	(51, '2026_03_27_181132_add_client_time_to_user_activity_logs_table', 2),
	(54, '2026_03_27_185832_add_client_time_to_orders_table', 3),
	(55, '2026_03_28_000001_add_manual_recording_to_mpesa_configs', 3),
	(56, '2026_03_28_083712_add_price2_price3_to_price_adjustment_details', 4),
	(57, '2026_03_28_091420_add_notes_to_opening_balances_table', 5),
	(58, '2026_03_28_120000_add_receipt_report_settings', 6),
	(59, '2026_03_29_000000_create_unit_of_measures_table', 7),
	(60, '2026_03_29_000001_add_unit_of_measure_id_to_products_table', 7),
	(61, '2026_03_29_000002_create_disposed_products_table', 8),
	(62, '2026_03_29_000003_create_branches_table', 9),
	(63, '2026_03_29_000004_add_branch_id_to_tables', 9),
	(64, '2026_03_29_000005_add_branch_id_to_products_table', 10);
/*!40000 ALTER TABLE `migrations` ENABLE KEYS */;

-- Dumping structure for table posai.mpesa_configs
DROP TABLE IF EXISTS `mpesa_configs`;
CREATE TABLE IF NOT EXISTS `mpesa_configs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `consumer_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `consumer_secret` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `shortcode` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `passkey` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `callback_url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `confirmation_url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `validation_url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '0',
  `is_production` tinyint(1) NOT NULL DEFAULT '0',
  `manual_recording` tinyint(1) NOT NULL DEFAULT '0',
  `notes` text COLLATE utf8mb4_unicode_ci,
  `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 posai.mpesa_configs: ~1 rows (approximately)
/*!40000 ALTER TABLE `mpesa_configs` DISABLE KEYS */;
REPLACE INTO `mpesa_configs` (`id`, `consumer_key`, `consumer_secret`, `shortcode`, `passkey`, `callback_url`, `confirmation_url`, `validation_url`, `is_active`, `is_production`, `manual_recording`, `notes`, `created_at`, `updated_at`) VALUES
	(1, 'admin@pos.com', 'password', '123', '123', 'http://127.0.0.1:8000/mpesa/callback', NULL, NULL, 1, 0, 1, NULL, '2026-03-28 06:36:28', '2026-03-29 05:48:18');
/*!40000 ALTER TABLE `mpesa_configs` ENABLE KEYS */;

-- Dumping structure for table posai.mpesa_transactions
DROP TABLE IF EXISTS `mpesa_transactions`;
CREATE TABLE IF NOT EXISTS `mpesa_transactions` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint(20) unsigned DEFAULT NULL,
  `transaction_type` varchar(255) DEFAULT NULL,
  `transaction_id` varchar(255) DEFAULT NULL,
  `transaction_time` varchar(255) DEFAULT NULL,
  `amount` decimal(12,2) DEFAULT '0.00',
  `msisdn` varchar(255) DEFAULT NULL,
  `sender` varchar(255) DEFAULT NULL,
  `receiver` varchar(255) DEFAULT NULL,
  `account_reference` varchar(255) DEFAULT NULL,
  `invoice_number` varchar(255) DEFAULT NULL,
  `external_reference` varchar(255) DEFAULT NULL,
  `status` varchar(255) DEFAULT 'pending',
  `raw_request` text,
  `raw_response` text,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `mpesa_transactions_transaction_id_unique` (`transaction_id`),
  KEY `order_id` (`order_id`),
  CONSTRAINT `mpesa_transactions_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;

-- Dumping data for table posai.mpesa_transactions: ~1 rows (approximately)
/*!40000 ALTER TABLE `mpesa_transactions` DISABLE KEYS */;
REPLACE INTO `mpesa_transactions` (`id`, `order_id`, `transaction_type`, `transaction_id`, `transaction_time`, `amount`, `msisdn`, `sender`, `receiver`, `account_reference`, `invoice_number`, `external_reference`, `status`, `raw_request`, `raw_response`, `created_at`, `updated_at`) VALUES
	(11, NULL, 'CustomerPayBillOnline', 'MANUAL-1774801245-8751', '2026-03-29 19:20:45', 420.00, NULL, NULL, '123', 'POS-MANUAL-1774801245', NULL, NULL, 'completed', '{"_token":"VwBNjJOYDwkVbUKtbYoVcRTYW2aBNucm9PFu473V","amount":"420","transaction_id":null,"phone":null}', '{"manual":true}', '2026-03-29 19:20:45', '2026-03-29 19:20:45');
/*!40000 ALTER TABLE `mpesa_transactions` ENABLE KEYS */;

-- Dumping structure for table posai.opening_balances
DROP TABLE IF EXISTS `opening_balances`;
CREATE TABLE IF NOT EXISTS `opening_balances` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL,
  `date` date NOT NULL,
  `amount` decimal(12,2) DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `notes` text,
  `branch_id` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `opening_balances_user_id_date_unique` (`user_id`,`date`),
  KEY `opening_balances_branch_id_foreign` (`branch_id`),
  CONSTRAINT `opening_balances_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE SET NULL,
  CONSTRAINT `opening_balances_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;

-- Dumping data for table posai.opening_balances: ~2 rows (approximately)
/*!40000 ALTER TABLE `opening_balances` DISABLE KEYS */;
REPLACE INTO `opening_balances` (`id`, `user_id`, `date`, `amount`, `created_at`, `updated_at`, `notes`, `branch_id`) VALUES
	(7, 1, '2026-03-29', 0.00, '2026-03-29 15:27:01', '2026-03-29 15:27:01', '', NULL),
	(8, 5, '2026-03-29', 0.00, '2026-03-29 15:28:07', '2026-03-29 15:28:07', '', NULL);
/*!40000 ALTER TABLE `opening_balances` ENABLE KEYS */;

-- Dumping structure for table posai.orders
DROP TABLE IF EXISTS `orders`;
CREATE TABLE IF NOT EXISTS `orders` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `invoice_number` varchar(255) NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  `customer_id` bigint(20) unsigned DEFAULT NULL,
  `client_time` timestamp NULL DEFAULT NULL,
  `subtotal` decimal(10,2) NOT NULL,
  `discount` decimal(10,2) DEFAULT '0.00',
  `discount_type` varchar(255) DEFAULT 'percentage',
  `tax` decimal(10,2) DEFAULT '0.00',
  `tax_rate` decimal(5,2) DEFAULT '0.00',
  `tax_details` json DEFAULT NULL,
  `total` decimal(10,2) NOT NULL,
  `paid_amount` decimal(12,2) DEFAULT '0.00',
  `change_amount` decimal(10,2) DEFAULT '0.00',
  `payment_method` varchar(255) DEFAULT NULL,
  `payment_methods` json DEFAULT NULL,
  `payment_type` enum('cash','credit','partial') DEFAULT 'cash',
  `credit_amount` decimal(12,2) DEFAULT '0.00',
  `due_date` date DEFAULT NULL,
  `credit_status` enum('pending','partial','paid','overdue') DEFAULT NULL,
  `status` enum('completed','pending','cancelled') DEFAULT 'completed',
  `notes` text,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `branch_id` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `orders_invoice_number_unique` (`invoice_number`),
  KEY `user_id` (`user_id`),
  KEY `customer_id` (`customer_id`),
  KEY `orders_branch_id_foreign` (`branch_id`),
  CONSTRAINT `orders_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE SET NULL,
  CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `orders_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;

-- Dumping data for table posai.orders: ~1 rows (approximately)
/*!40000 ALTER TABLE `orders` DISABLE KEYS */;
REPLACE INTO `orders` (`id`, `invoice_number`, `user_id`, `customer_id`, `client_time`, `subtotal`, `discount`, `discount_type`, `tax`, `tax_rate`, `tax_details`, `total`, `paid_amount`, `change_amount`, `payment_method`, `payment_methods`, `payment_type`, `credit_amount`, `due_date`, `credit_status`, `status`, `notes`, `created_at`, `updated_at`, `branch_id`) VALUES
	(19, 'INV-20260329-000001', 5, NULL, '2026-04-30 19:20:14', 420.00, 0.00, '0', 0.00, 0.00, '[]', 420.00, 420.00, 0.00, 'cash', '[{"amount": 0, "method": "cash"}, {"amount": 420, "method": "mpesa", "checkout_id": null}]', 'cash', 0.00, NULL, NULL, 'completed', NULL, '2026-03-29 19:20:48', '2026-03-29 19:20:48', NULL);
/*!40000 ALTER TABLE `orders` ENABLE KEYS */;

-- Dumping structure for table posai.order_items
DROP TABLE IF EXISTS `order_items`;
CREATE TABLE IF NOT EXISTS `order_items` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint(20) unsigned NOT NULL,
  `product_id` bigint(20) unsigned NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `product_sku` varchar(255) NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `price_type` varchar(255) DEFAULT NULL,
  `unit_cost` decimal(12,2) DEFAULT NULL,
  `quantity` int(11) NOT NULL,
  `subtotal` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`),
  KEY `product_id` (`product_id`),
  CONSTRAINT `order_items_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `order_items_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;

-- Dumping data for table posai.order_items: ~1 rows (approximately)
/*!40000 ALTER TABLE `order_items` DISABLE KEYS */;
REPLACE INTO `order_items` (`id`, `order_id`, `product_id`, `product_name`, `product_sku`, `price`, `price_type`, `unit_cost`, `quantity`, `subtotal`, `created_at`, `updated_at`) VALUES
	(24, 19, 29, 'Melon 100 Grams', 'Melon', 70.00, 'default', 40.00, 6, 420.00, '2026-03-29 19:20:48', '2026-03-29 19:20:48');
/*!40000 ALTER TABLE `order_items` ENABLE KEYS */;

-- Dumping structure for table posai.password_reset_tokens
DROP TABLE IF EXISTS `password_reset_tokens`;
CREATE TABLE IF NOT EXISTS `password_reset_tokens` (
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.password_reset_tokens: ~0 rows (approximately)
/*!40000 ALTER TABLE `password_reset_tokens` DISABLE KEYS */;
/*!40000 ALTER TABLE `password_reset_tokens` ENABLE KEYS */;

-- Dumping structure for table posai.permissions
DROP TABLE IF EXISTS `permissions`;
CREATE TABLE IF NOT EXISTS `permissions` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `permissions_name_unique` (`name`),
  UNIQUE KEY `permissions_slug_unique` (`slug`)
) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.permissions: ~59 rows (approximately)
/*!40000 ALTER TABLE `permissions` DISABLE KEYS */;
REPLACE INTO `permissions` (`id`, `name`, `slug`, `description`, `created_at`, `updated_at`) VALUES
	(1, 'View Dashboard', 'dashboard.view', 'Can view dashboard', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(2, 'View Products', 'products.view', 'Can view products list', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(3, 'Create Products', 'products.create', 'Can create products', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(4, 'Edit Products', 'products.edit', 'Can edit products', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(5, 'Delete Products', 'products.delete', 'Can delete products', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(6, 'View Categories', 'categories.view', 'Can view categories', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(7, 'Create Categories', 'categories.create', 'Can create categories', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(8, 'Edit Categories', 'categories.edit', 'Can edit categories', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(9, 'Delete Categories', 'categories.delete', 'Can delete categories', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(10, 'View Unit of Measures', 'unit-of-measures.view', 'Can view unit of measures', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(11, 'Create Unit of Measures', 'unit-of-measures.create', 'Can create unit of measures', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(12, 'Edit Unit of Measures', 'unit-of-measures.edit', 'Can edit unit of measures', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(13, 'Delete Unit of Measures', 'unit-of-measures.delete', 'Can delete unit of measures', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(14, 'View Customers', 'customers.view', 'Can view customers', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(15, 'Create Customers', 'customers.create', 'Can create customers', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(16, 'Edit Customers', 'customers.edit', 'Can edit customers', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(17, 'Delete Customers', 'customers.delete', 'Can delete customers', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(18, 'View Suppliers', 'suppliers.view', 'Can view suppliers', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(19, 'Create Suppliers', 'suppliers.create', 'Can create suppliers', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(20, 'Edit Suppliers', 'suppliers.edit', 'Can edit suppliers', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(21, 'Delete Suppliers', 'suppliers.delete', 'Can delete suppliers', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(22, 'Supplier Finance', 'suppliers.finance', 'Can view supplier finance', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(23, 'POS Sales', 'pos.sales', 'Can make sales', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(24, 'Opening Balance', 'opening-balance.view', 'Can view opening balance', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(25, 'Expiry Management', 'expiry.manage', 'Can manage product expiry', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(26, 'View Orders', 'orders.view', 'Can view orders', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(27, 'Cancel Orders', 'orders.cancel', 'Can cancel orders', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(28, 'View Inventory', 'inventory.view', 'Can view inventory', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(29, 'Stock In', 'inventory.stock-in', 'Can add stock', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(30, 'Price Adjustment', 'inventory.adjustment', 'Can adjust inventory', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(31, 'View Reports', 'reports.view', 'Can view reports', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(32, 'Sales Report', 'reports.sales', 'Can view sales report', '2026-03-29 19:34:27', '2026-03-29 19:34:27'),
	(33, 'Profit Report', 'reports.profit', 'Can view profit report', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(34, 'Inventory Report', 'reports.inventory', 'Can view inventory report', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(35, 'Supplier Payments Report', 'reports.supplier-payments', 'Can view supplier payments report', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(36, 'Opening Balance Report', 'reports.opening-balance', 'Can view opening balance report', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(37, 'Stock Movement Report', 'reports.stock-movement', 'Can view stock movement report', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(38, 'Cashier Report', 'reports.cashier', 'Can view cashier report', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(39, 'Cashier Sales Report', 'reports.cashier-sales', 'Can view cashier sales report', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(40, 'Disposed Products Report', 'reports.disposed', 'Can view disposed products report', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(41, 'Manage Users', 'users.manage', 'Can manage users', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(42, 'Manage Permissions', 'permissions.manage', 'Can manage user permissions', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(43, 'View Expenses', 'expenses.view', 'Can view expenses', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(44, 'Create Expenses', 'expenses.create', 'Can create expenses', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(45, 'Delete Expenses', 'expenses.delete', 'Can delete expenses', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(46, 'View Cash Flow', 'expenses.cashflow', 'Can view cash flow report', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(47, 'View Tax', 'tax.view', 'Can view tax configuration', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(48, 'Manage Tax', 'tax.manage', 'Can manage tax settings', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(49, 'View e-TIMS', 'tax.etims.view', 'Can view e-TIMS configuration', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(50, 'Manage e-TIMS', 'tax.etims.manage', 'Can manage e-TIMS settings', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(51, 'View M-Pesa', 'mpesa.view', 'Can view M-Pesa configuration', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(52, 'Manage M-Pesa', 'mpesa.manage', 'Can manage M-Pesa settings', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(53, 'View Credit', 'credit.view', 'Can view credit management', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(54, 'Manage Credit', 'credit.manage', 'Can manage credit and receive payments', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(55, 'Send Reminders', 'credit.reminders', 'Can send payment reminders', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(56, 'SMS Settings', 'settings.sms', 'Can manage SMS integration settings', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(57, 'Receipt Settings', 'settings.receipt', 'Can manage receipt and report settings', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(58, 'System Settings', 'settings.system', 'Can manage system settings', '2026-03-29 19:34:28', '2026-03-29 19:34:28'),
	(59, 'M-Pesa Access', 'mpesa.access', 'Can access M-Pesa menu', '2026-03-29 19:34:28', '2026-03-29 19:34:28');
/*!40000 ALTER TABLE `permissions` ENABLE KEYS */;

-- Dumping structure for table posai.price_adjustment_details
DROP TABLE IF EXISTS `price_adjustment_details`;
CREATE TABLE IF NOT EXISTS `price_adjustment_details` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `price_adjustment_log_id` bigint(20) unsigned NOT NULL,
  `product_id` bigint(20) unsigned NOT NULL,
  `old_cost_price` decimal(10,2) NOT NULL,
  `new_cost_price` decimal(10,2) NOT NULL,
  `old_selling_price` decimal(10,2) NOT NULL,
  `new_selling_price` decimal(10,2) NOT NULL,
  `old_price_2` decimal(10,2) DEFAULT NULL,
  `new_price_2` decimal(10,2) DEFAULT NULL,
  `old_price_3` decimal(10,2) DEFAULT NULL,
  `new_price_3` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `price_adjustment_details_price_adjustment_log_id_foreign` (`price_adjustment_log_id`),
  KEY `price_adjustment_details_product_id_foreign` (`product_id`),
  CONSTRAINT `price_adjustment_details_price_adjustment_log_id_foreign` FOREIGN KEY (`price_adjustment_log_id`) REFERENCES `price_adjustment_logs` (`id`) ON DELETE CASCADE,
  CONSTRAINT `price_adjustment_details_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

-- Dumping data for table posai.price_adjustment_details: ~0 rows (approximately)
/*!40000 ALTER TABLE `price_adjustment_details` DISABLE KEYS */;
/*!40000 ALTER TABLE `price_adjustment_details` ENABLE KEYS */;

-- Dumping structure for table posai.price_adjustment_logs
DROP TABLE IF EXISTS `price_adjustment_logs`;
CREATE TABLE IF NOT EXISTS `price_adjustment_logs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL,
  `adjustment_type` varchar(255) NOT NULL,
  `operation` varchar(255) NOT NULL,
  `price_type` varchar(255) NOT NULL,
  `adjustment_value` decimal(10,2) NOT NULL,
  `products_updated` int(11) NOT NULL,
  `notes` text,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `price_adjustment_logs_user_id_foreign` (`user_id`),
  CONSTRAINT `price_adjustment_logs_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

-- Dumping data for table posai.price_adjustment_logs: ~0 rows (approximately)
/*!40000 ALTER TABLE `price_adjustment_logs` DISABLE KEYS */;
/*!40000 ALTER TABLE `price_adjustment_logs` ENABLE KEYS */;

-- Dumping structure for table posai.products
DROP TABLE IF EXISTS `products`;
CREATE TABLE IF NOT EXISTS `products` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `category_id` bigint(20) unsigned NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `sku` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `barcode` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cost_price` decimal(10,2) NOT NULL,
  `selling_price` decimal(10,2) NOT NULL,
  `price_2` decimal(12,2) DEFAULT NULL,
  `price_3` decimal(12,2) DEFAULT NULL,
  `price_2_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'e.g., Wholesale, VIP',
  `price_3_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'e.g., Bulk, Special',
  `stock_quantity` decimal(12,2) NOT NULL,
  `low_stock_threshold` int(11) NOT NULL DEFAULT '10',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `description` text COLLATE utf8mb4_unicode_ci,
  `expiry_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `unit_of_measure_id` bigint(20) unsigned DEFAULT NULL,
  `branch_id` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `products_sku_unique` (`sku`),
  UNIQUE KEY `products_barcode_unique` (`barcode`),
  KEY `products_category_id_foreign` (`category_id`),
  KEY `products_unit_of_measure_id_foreign` (`unit_of_measure_id`),
  KEY `products_branch_id_foreign` (`branch_id`),
  CONSTRAINT `products_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE SET NULL,
  CONSTRAINT `products_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE,
  CONSTRAINT `products_unit_of_measure_id_foreign` FOREIGN KEY (`unit_of_measure_id`) REFERENCES `unit_of_measures` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.products: ~3 rows (approximately)
/*!40000 ALTER TABLE `products` DISABLE KEYS */;
REPLACE INTO `products` (`id`, `category_id`, `name`, `sku`, `barcode`, `image`, `cost_price`, `selling_price`, `price_2`, `price_3`, `price_2_name`, `price_3_name`, `stock_quantity`, `low_stock_threshold`, `is_active`, `description`, `expiry_date`, `created_at`, `updated_at`, `unit_of_measure_id`, `branch_id`) VALUES
	(27, 9, 'orange', 'orange', 'orange', 'f21dbb09-7261-4e8c-a147-c57553dfb91c.jpg', 80.00, 78.00, 50.00, 40.00, 'Price 2', 'Price 3', 0.00, 10, 1, NULL, '2026-04-01', '2026-03-29 15:56:31', '2026-03-29 18:48:41', 13, 1),
	(28, 9, 'mango', 'mango', 'mango', '0c740394-2056-40bb-acd2-c1449f975cbc.jpeg', 200.00, 156.00, 110.00, 100.00, 'Price 2', 'Price 3', 0.00, 10, 1, NULL, '2026-04-05', '2026-03-29 16:02:46', '2026-03-29 18:51:11', 1, 1),
	(29, 9, 'Melon 100 Grams', 'Melon', 'Melon', 'c0d1a6db-a5e3-4f1f-a68e-9276b22e2f0e.PNG', 40.00, 70.00, 60.00, 50.00, 'Price 2', 'Price 3', -1.00, 10, 1, NULL, '2026-04-28', '2026-03-29 16:34:57', '2026-03-29 19:20:48', 3, 1);
/*!40000 ALTER TABLE `products` ENABLE KEYS */;

-- Dumping structure for table posai.product_price_history
DROP TABLE IF EXISTS `product_price_history`;
CREATE TABLE IF NOT EXISTS `product_price_history` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned DEFAULT NULL,
  `price_adjustment_log_id` bigint(20) unsigned DEFAULT NULL,
  `old_cost_price` decimal(12,2) NOT NULL,
  `new_cost_price` decimal(12,2) NOT NULL,
  `old_selling_price` decimal(12,2) NOT NULL,
  `new_selling_price` decimal(12,2) NOT NULL,
  `reason` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_id` (`product_id`),
  CONSTRAINT `product_price_history_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;

-- Dumping data for table posai.product_price_history: ~0 rows (approximately)
/*!40000 ALTER TABLE `product_price_history` DISABLE KEYS */;
/*!40000 ALTER TABLE `product_price_history` ENABLE KEYS */;

-- Dumping structure for table posai.sessions
DROP TABLE IF EXISTS `sessions`;
CREATE TABLE IF NOT EXISTS `sessions` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint(20) unsigned DEFAULT NULL,
  `ip_address` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` text COLLATE utf8mb4_unicode_ci,
  `payload` longtext COLLATE utf8mb4_unicode_ci 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 posai.sessions: ~0 rows (approximately)
/*!40000 ALTER TABLE `sessions` DISABLE KEYS */;
/*!40000 ALTER TABLE `sessions` ENABLE KEYS */;

-- Dumping structure for table posai.settings
DROP TABLE IF EXISTS `settings`;
CREATE TABLE IF NOT EXISTS `settings` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `settings_key_unique` (`key`)
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.settings: ~27 rows (approximately)
/*!40000 ALTER TABLE `settings` DISABLE KEYS */;
REPLACE INTO `settings` (`id`, `key`, `value`, `created_at`, `updated_at`) VALUES
	(1, 'loyalty_points_ratio', '1', '2026-03-28 06:16:13', '2026-03-28 06:16:13'),
	(2, 'loyalty_points_redemption', '1', '2026-03-28 06:16:13', '2026-03-28 06:16:13'),
	(16, 'sms_provider', 'africastalking', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(17, 'sms_api_key', '', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(18, 'sms_shortcode', '', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(19, 'sms_sender_id', '', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(20, 'sms_enabled', '0', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(21, 'sms_oauth_client_id', '', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(22, 'sms_oauth_client_secret', '', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(23, 'sms_oauth_access_token', '', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(24, 'sms_oauth_refresh_token', '', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(25, 'sms_oauth_token_expires', '', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(26, 'sms_oauth_username', '', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(27, 'sms_oauth_password', '', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(28, 'sms_channel_id', '', '2026-03-28 06:25:40', '2026-03-28 06:25:40'),
	(29, 'receipt_header', 'TOKIM PHARMACY', '2026-03-28 12:37:22', '2026-03-28 13:01:41'),
	(30, 'receipt_address', 'NAKURU-NDUNDORI', '2026-03-28 12:37:22', '2026-03-28 13:01:41'),
	(31, 'receipt_phone', 'Tel: 0701-980-200', '2026-03-28 12:37:22', '2026-03-28 13:01:41'),
	(32, 'receipt_footer', '*** THANK YOU FOR YOUR BUSINESS ***', '2026-03-28 12:37:22', '2026-03-28 13:01:41'),
	(33, 'report_header', 'POS System Report', '2026-03-28 12:37:22', '2026-03-28 13:01:41'),
	(34, 'report_company', 'POS SYSTEM', '2026-03-28 12:37:22', '2026-03-28 13:01:41'),
	(35, 'report_footer', 'Generated by POS System', '2026-03-28 12:37:22', '2026-03-28 13:01:41'),
	(36, 'receipt_dev_ad', 'Powered by Destech: 0701-980-200 / destechsoftwares.co.ke', '2026-03-28 12:37:22', '2026-03-28 13:01:41'),
	(37, 'report_dev_ad', NULL, '2026-03-28 12:37:22', '2026-03-28 13:01:41'),
	(38, 'receipt_tagline', 'Your Trusted Shopping Destination Always', '2026-03-28 12:37:22', '2026-03-28 13:01:41'),
	(39, 'system_name', 'TOKIM PHARMACY', NULL, '2026-03-29 11:30:38'),
	(40, 'inactivity_timeout', '35', NULL, '2026-03-29 11:30:38');
/*!40000 ALTER TABLE `settings` ENABLE KEYS */;

-- Dumping structure for table posai.subscriptions
DROP TABLE IF EXISTS `subscriptions`;
CREATE TABLE IF NOT EXISTS `subscriptions` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `plan_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `billing_cycle_days` int(11) NOT NULL DEFAULT '30',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `description` text COLLATE utf8mb4_unicode_ci,
  `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 posai.subscriptions: ~0 rows (approximately)
/*!40000 ALTER TABLE `subscriptions` DISABLE KEYS */;
/*!40000 ALTER TABLE `subscriptions` ENABLE KEYS */;

-- Dumping structure for table posai.suppliers
DROP TABLE IF EXISTS `suppliers`;
CREATE TABLE IF NOT EXISTS `suppliers` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` text COLLATE utf8mb4_unicode_ci,
  `contact_person` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `total_paid` decimal(12,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.suppliers: ~1 rows (approximately)
/*!40000 ALTER TABLE `suppliers` DISABLE KEYS */;
REPLACE INTO `suppliers` (`id`, `name`, `phone`, `email`, `address`, `contact_person`, `is_active`, `total_paid`, `created_at`, `updated_at`) VALUES
	(6, 'Self', '00000000', 'admin@pos.com', NULL, 'Self', 1, 0.00, '2026-03-29 16:12:00', '2026-03-29 17:36:46');
/*!40000 ALTER TABLE `suppliers` ENABLE KEYS */;

-- Dumping structure for table posai.supplier_payments
DROP TABLE IF EXISTS `supplier_payments`;
CREATE TABLE IF NOT EXISTS `supplier_payments` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `supplier_id` bigint(20) unsigned NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `payment_method` varchar(255) DEFAULT 'cash',
  `reference_number` varchar(255) DEFAULT NULL,
  `notes` text,
  `payment_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `supplier_id` (`supplier_id`),
  CONSTRAINT `supplier_payments_ibfk_1` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

-- Dumping data for table posai.supplier_payments: ~0 rows (approximately)
/*!40000 ALTER TABLE `supplier_payments` DISABLE KEYS */;
/*!40000 ALTER TABLE `supplier_payments` ENABLE KEYS */;

-- Dumping structure for table posai.tax_configs
DROP TABLE IF EXISTS `tax_configs`;
CREATE TABLE IF NOT EXISTS `tax_configs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `rate` decimal(5,2) NOT NULL DEFAULT '0.00',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `is_default` tinyint(1) NOT NULL DEFAULT '0',
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'vat',
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `tax_configs_code_unique` (`code`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.tax_configs: ~1 rows (approximately)
/*!40000 ALTER TABLE `tax_configs` DISABLE KEYS */;
REPLACE INTO `tax_configs` (`id`, `name`, `code`, `rate`, `is_active`, `is_default`, `type`, `description`, `created_at`, `updated_at`) VALUES
	(1, 'vat 16%', 'vat', 16.00, 0, 1, 'vat', NULL, '2026-03-28 11:07:14', '2026-03-29 05:54:59');
/*!40000 ALTER TABLE `tax_configs` ENABLE KEYS */;

-- Dumping structure for table posai.unit_of_measures
DROP TABLE IF EXISTS `unit_of_measures`;
CREATE TABLE IF NOT EXISTS `unit_of_measures` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `abbreviation` varchar(255) COLLATE utf8mb4_unicode_ci 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`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.unit_of_measures: ~15 rows (approximately)
/*!40000 ALTER TABLE `unit_of_measures` DISABLE KEYS */;
REPLACE INTO `unit_of_measures` (`id`, `name`, `abbreviation`, `is_active`, `created_at`, `updated_at`) VALUES
	(1, 'Piece', 'pc', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(2, 'Kilogram', 'kg', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(3, 'Gram', 'g', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(4, 'Liter', 'L', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(5, 'Milliliter', 'mL', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(6, 'Meter', 'm', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(7, 'Centimeter', 'cm', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(8, 'Pack', 'pack', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(9, 'Box', 'box', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(10, 'Carton', 'ctn', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(11, 'Dozen', 'doz', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(12, 'Set', 'set', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(13, 'Pair', 'pair', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(14, 'Roll', 'roll', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48'),
	(15, 'Bundle', 'bdl', 1, '2026-03-29 15:51:48', '2026-03-29 15:51:48');
/*!40000 ALTER TABLE `unit_of_measures` ENABLE KEYS */;

-- Dumping structure for table posai.users
DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email_verified_at` timestamp NULL DEFAULT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `role` enum('super_admin','admin','cashier') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'cashier',
  `permissions` json DEFAULT NULL,
  `theme` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'system',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `subscription_id` bigint(20) unsigned DEFAULT NULL,
  `subscription_expires_at` timestamp NULL DEFAULT NULL,
  `branch_id` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_email_unique` (`email`),
  KEY `users_subscription_id_foreign` (`subscription_id`),
  KEY `users_branch_id_foreign` (`branch_id`),
  CONSTRAINT `users_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE SET NULL,
  CONSTRAINT `users_subscription_id_foreign` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table posai.users: ~3 rows (approximately)
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
REPLACE INTO `users` (`id`, `name`, `email`, `email_verified_at`, `password`, `role`, `permissions`, `theme`, `is_active`, `remember_token`, `created_at`, `updated_at`, `subscription_id`, `subscription_expires_at`, `branch_id`) VALUES
	(1, 'Super Admin', 'superadmin@pos.com', NULL, '$2y$12$ED2/FHxamjXKZguHmP81Bue7HeInga7vSQo9l9ikr11OVH5D4kdjC', 'super_admin', NULL, 'system', 1, NULL, '2026-03-28 06:17:23', '2026-03-29 18:34:22', NULL, NULL, 1),
	(5, 'Dest Test', 'dest@gmail.com', NULL, '$2y$12$384ln5eq1edmOlkVOM1aZ.M9v5Qs7gZe6zMx2qGYjiavvP0tYJtwq', 'admin', NULL, 'system', 1, NULL, '2026-03-29 15:22:36', '2026-03-29 18:34:22', NULL, NULL, 1),
	(6, 'Cashier', 'Cashier@gmail.com', NULL, '$2y$12$JvI5NYizJl1fRM2MlKNyJeawu9uSEOz0AioexoAKDKZh8i2cYDWvC', 'cashier', '["expenses.create", "products.create", "pos.sales", "inventory.stock-in", "expenses.view", "products.view"]', 'system', 1, NULL, '2026-03-29 16:43:30', '2026-03-29 19:45:21', NULL, NULL, 2);
/*!40000 ALTER TABLE `users` ENABLE KEYS */;

-- Dumping structure for table posai.user_activity_logs
DROP TABLE IF EXISTS `user_activity_logs`;
CREATE TABLE IF NOT EXISTS `user_activity_logs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL,
  `activity_type` varchar(255) NOT NULL,
  `description` text,
  `ip_address` varchar(255) DEFAULT NULL,
  `user_agent` text,
  `metadata` json DEFAULT NULL,
  `client_time` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `user_activity_logs_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=266 DEFAULT CHARSET=utf8;

-- Dumping data for table posai.user_activity_logs: ~42 rows (approximately)
/*!40000 ALTER TABLE `user_activity_logs` DISABLE KEYS */;
REPLACE INTO `user_activity_logs` (`id`, `user_id`, `activity_type`, `description`, `ip_address`, `user_agent`, `metadata`, `client_time`, `created_at`, `updated_at`) VALUES
	(224, 5, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-04-01 19:17:20', '2026-04-01 19:17:22', '2026-04-01 19:17:22'),
	(225, 5, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-04-01 19:18:40', '2026-04-30 19:18:37', '2026-04-30 19:18:37'),
	(226, 5, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-04-30 19:19:55', '2026-03-29 19:20:09', '2026-03-29 19:20:09'),
	(227, 5, 'sale', 'Completed sale - Invoice: INV-20260329-000001, Total: 420', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '{"total": 420, "order_id": 19, "items_count": 1, "invoice_number": "INV-20260329-000001"}', '2026-04-30 19:20:14', '2026-03-29 19:20:48', '2026-03-29 19:20:48'),
	(228, 5, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:27:05', '2026-03-29 19:27:06', '2026-03-29 19:27:06'),
	(229, 5, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:27:09', '2026-03-29 19:27:11', '2026-03-29 19:27:11'),
	(230, 5, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:27:36', '2026-03-29 19:27:37', '2026-03-29 19:27:37'),
	(231, 6, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:27:41', '2026-03-29 19:27:43', '2026-03-29 19:27:43'),
	(232, 6, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:28:16', '2026-03-29 19:28:17', '2026-03-29 19:28:17'),
	(233, 5, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:28:23', '2026-03-29 19:28:25', '2026-03-29 19:28:25'),
	(234, 5, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:35:11', '2026-03-29 19:35:12', '2026-03-29 19:35:12'),
	(235, 6, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:35:17', '2026-03-29 19:35:19', '2026-03-29 19:35:19'),
	(236, 6, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:36:07', '2026-03-29 19:36:08', '2026-03-29 19:36:08'),
	(237, 5, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:36:17', '2026-03-29 19:36:19', '2026-03-29 19:36:19'),
	(238, 5, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:36:37', '2026-03-29 19:36:38', '2026-03-29 19:36:38'),
	(239, 6, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:36:42', '2026-03-29 19:36:44', '2026-03-29 19:36:44'),
	(240, 6, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:38:53', '2026-03-29 19:38:54', '2026-03-29 19:38:54'),
	(241, 6, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:38:57', '2026-03-29 19:38:58', '2026-03-29 19:38:58'),
	(242, 6, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:39:41', '2026-03-29 19:39:43', '2026-03-29 19:39:43'),
	(243, 6, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:41:33', '2026-03-29 19:41:33', '2026-03-29 19:41:33'),
	(244, 5, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:41:39', '2026-03-29 19:41:40', '2026-03-29 19:41:40'),
	(245, 5, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:42:55', '2026-03-29 19:42:56', '2026-03-29 19:42:56'),
	(246, 6, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:43:04', '2026-03-29 19:43:05', '2026-03-29 19:43:05'),
	(247, 6, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:44:02', '2026-03-29 19:44:03', '2026-03-29 19:44:03'),
	(248, 5, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:44:09', '2026-03-29 19:44:12', '2026-03-29 19:44:12'),
	(249, 5, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:44:34', '2026-03-29 19:44:35', '2026-03-29 19:44:35'),
	(250, 6, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:44:40', '2026-03-29 19:44:42', '2026-03-29 19:44:42'),
	(251, 6, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:44:53', '2026-03-29 19:44:54', '2026-03-29 19:44:54'),
	(252, 5, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:44:59', '2026-03-29 19:45:01', '2026-03-29 19:45:01'),
	(253, 5, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:45:26', '2026-03-29 19:45:27', '2026-03-29 19:45:27'),
	(254, 6, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:45:33', '2026-03-29 19:45:35', '2026-03-29 19:45:35'),
	(255, 6, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:46:55', '2026-03-29 19:46:56', '2026-03-29 19:46:56'),
	(256, 5, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:47:00', '2026-03-29 19:47:02', '2026-03-29 19:47:02'),
	(257, 5, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 19:47:52', '2026-03-29 19:47:53', '2026-03-29 19:47:53'),
	(258, 6, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:48:00', '2026-03-29 19:48:02', '2026-03-29 19:48:02'),
	(259, 6, 'auto_logout', 'Session expired due to inactivity', '127.0.0.1', NULL, NULL, '2026-03-29 19:50:04', '2026-03-29 19:50:05', '2026-03-29 19:50:05'),
	(260, 6, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 19:59:47', '2026-03-29 19:59:49', '2026-03-29 19:59:49'),
	(261, 6, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 20:00:07', '2026-03-29 20:00:09', '2026-03-29 20:00:09'),
	(262, 6, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 20:01:25', '2026-03-29 20:01:26', '2026-03-29 20:01:26'),
	(263, 5, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 20:01:30', '2026-03-29 20:01:32', '2026-03-29 20:01:32'),
	(264, 5, 'logout', 'User logged out', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', '[]', '2026-03-29 20:03:55', '2026-03-29 20:03:57', '2026-03-29 20:03:57'),
	(265, 6, 'login', 'User logged in', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', NULL, '2026-03-29 20:04:02', '2026-03-29 20:04:04', '2026-03-29 20:04:04');
/*!40000 ALTER TABLE `user_activity_logs` ENABLE KEYS */;

/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;
