--
-- Host: localhost    Database: pos_db
-- ------------------------------------------------------


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

CREATE TABLE `categories` (
  `id` bigint 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 `categories_slug_unique` (`slug`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

INSERT INTO `categories` VALUES (1,'Buku','buku','Semua jenis buku','2026-04-14 02:57:20','2026-04-14 02:57:20'),(2,'Makanan','makanan','Semua jenis makanan','2026-04-14 02:57:20','2026-04-14 02:57:20'),(3,'Snack','snack','Camilan dan keripik','2026-04-14 02:57:20','2026-04-14 02:57:20'),(4,'Sembako','sembako','Kebutuhan pokok','2026-04-14 02:57:20','2026-04-14 02:57:20'),(5,'Rokok','rokok','Rokok dan tembakau','2026-04-14 02:57:20','2026-04-14 02:57:20'),(6,'Perawatan Diri','perawatan-diri','Sabun, sampo, dsb','2026-04-14 02:57:20','2026-04-14 02:57:20'),(7,'Lainnya','lainnya','Produk lainnya','2026-04-14 02:57:20','2026-04-14 02:57:20');

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

CREATE TABLE `failed_jobs` (
  `id` bigint 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 `failed_jobs`
--


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

CREATE TABLE `job_batches` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `total_jobs` int NOT NULL,
  `pending_jobs` int NOT NULL,
  `failed_jobs` int NOT NULL,
  `failed_job_ids` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `options` mediumtext COLLATE utf8mb4_unicode_ci,
  `cancelled_at` int DEFAULT NULL,
  `created_at` int NOT NULL,
  `finished_at` int 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 unsigned NOT NULL AUTO_INCREMENT,
  `queue` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `attempts` tinyint unsigned NOT NULL,
  `reserved_at` int unsigned DEFAULT NULL,
  `available_at` int unsigned NOT NULL,
  `created_at` int 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 `migrations`
--

CREATE TABLE `migrations` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 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_000001_add_role_to_users_table',1),(5,'2024_01_01_000002_create_categories_table',1),(6,'2024_01_01_000003_create_products_table',1),(7,'2024_01_01_000004_create_stock_movements_table',1),(8,'2024_01_01_000005_create_transactions_table',1),(9,'2024_01_01_000006_create_transaction_items_table',1),(10,'2024_01_01_000007_create_store_settings_table',1),(11,'2026_03_03_210332_create_personal_access_tokens_table',1);

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

CREATE TABLE `products` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `category_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `barcode` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `hpp` decimal(15,2) NOT NULL DEFAULT '0.00',
  `sell_price` decimal(15,2) NOT NULL DEFAULT '0.00',
  `stock` int NOT NULL DEFAULT '0',
  `min_stock` int NOT NULL DEFAULT '5',
  `unit` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pcs',
  `image` varchar(255) COLLATE utf8mb4_unicode_ci 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 `products_barcode_unique` (`barcode`),
  KEY `products_category_id_foreign` (`category_id`),
  KEY `products_barcode_category_id_is_active_index` (`barcode`,`category_id`,`is_active`),
  CONSTRAINT `products_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

INSERT INTO `products` VALUES (1,1,'BIMBINGAN KONSELING PAI (PENDIDIKAN AGAMA ISLAM) Raden Roro Wulan Ayu Wardani, S.Pd., M.M',NULL,65000.00,75000.00,199,5,'pcs','products/bFmp5JGC4uKfv2C8c3CYu9mEKLrusotrL1dGlgqN.jpg',1,'2026-04-14 03:00:14','2026-04-14 03:39:01'),(2,1,'BUKU PENELITIAN DALAM APLIKASI CLASSROOM ACTION RESEARCH (CAR) Pendidikan, Bimbingan dan Latihan Menyusun Penelitian Tindakan Kelas (PTK) Untuk Guru dan Mahasiswa',NULL,60000.00,70000.00,146,5,'pcs','products/n66PhVvqcTxLuxlPTkF8Go4Kc7XQEgjaBf5K2hSV.jpg',1,'2026-04-14 03:06:56','2026-04-14 03:39:01'),(3,1,'Classroom Management untuk Mahasiswa Jurusan Pendidikan',NULL,90000.00,102000.00,46,5,'pcs','products/GRMEukGN1E7k9STvKCg3xNbAD1PvSrqFt2CWAitJ.jpg',1,'2026-04-14 03:09:14','2026-04-14 03:39:01'),(4,1,'CYBER SOCIETY: Teknologi, Media Baru, dan Disrupsi Informasi',NULL,70000.00,80000.00,59,5,'pcs','products/Rtt0vldYTCue7B1Cb46cNbtsDWjzM7M64fJ9iyVt.jpg',1,'2026-04-14 03:23:24','2026-04-14 03:39:01'),(5,1,'Fiqih Islam Lengkap - Drs H Moh Rifai - Toha Putra -',NULL,30000.00,40000.00,49,5,'pcs','products/KAN8g5ZWnvsAP8Z7WrvuAWVyV54E8jagSgjNkrQV.jpg',1,'2026-04-14 03:31:32','2026-04-14 03:39:01'),(6,1,'Micro Teaching: Teori dan Praktik',NULL,90000.00,105000.00,69,5,'pcs','products/l7p9phGHMKScpEvPmIZRWOzOw84aqn7PM3r1WgTu.jpg',1,'2026-04-14 03:36:09','2026-04-14 03:39:01'),(7,1,'PENGEMBANGAN BAHAN AJAR PAI',NULL,50000.00,70000.00,49,5,'pcs','products/VTJsmvQ2vTzffVZARvr5OkHse6rpohN82xU3BjVs.webp',1,'2026-04-14 03:38:00','2026-04-14 03:39:01'),(8,1,'Pengembangan Kurikulum Pendidikan Agama Islam (PAI)',NULL,80000.00,90000.00,70,5,'pcs','products/FQMwCf5NgJK9aahfMyWn78ab2ibtgVC0ZzekzPVn.jpg',1,'2026-04-14 04:03:18','2026-04-14 04:03:18'),(9,1,'Inovasi Pengelolaan Lembaga Pendidikan Islam Umar, S.S., M.Pd.; Zulaehatus Sofiah, M.Pd.',NULL,90000.00,100000.00,40,5,'pcs','products/9EZBPEiDzlYn3Hm9Xx6ZuzhAUpc8Qi1v3iZzgmS7.webp',1,'2026-04-14 04:05:05','2026-04-14 04:05:05'),(10,1,'Komunikasi Pembelajaran di Era Digital',NULL,100000.00,150000.00,30,5,'pcs','products/pR3GDYKSFdB00KnJUAw3mcP7fiE1LPgBunRNNVRa.webp',1,'2026-04-14 04:06:45','2026-04-14 04:06:45'),(11,1,'Pendidikan Luar Sekolah Dr. A. Hasdiansyah, S.Pd., M.Pd., M.A; dkk',NULL,100000.00,120000.00,50,5,'pcs','products/I01I6hl193mcrrL7ZHt0ejzDMs65oEl9JeQPNxzL.webp',1,'2026-04-14 04:08:06','2026-04-14 04:08:06'),(12,1,'Menulis Paper Untuk Publikasi Ilmiah Jurnal Bereputasi Prof.Anwar Mallongi,SKM.,MSc.,Ph.D',NULL,90000.00,125000.00,77,5,'pcs','products/bXzvIy9Aqu9KfZ0vnkGyhkKRWXOq87gqmrxmeRdg.png',1,'2026-04-14 04:13:43','2026-04-14 04:13:43'),(13,1,'GURU PAI IDAMAN SISWA: Menjadi Pendidik Dirindukan, Diteladankan, dan Didoakan Penulis : Khairan Efendi, S.Pd.I, M.Pd.I',NULL,90000.00,150000.00,100,5,'pcs','products/IeA50Y9ji691nQCYcHYZeHDaHi5lHI0aHnHJJntG.png',1,'2026-04-14 04:16:40','2026-04-14 04:16:40'),(14,1,'Sejarah Pendidikan Islam Prof. Dr. H. J. Suyuthi Pulungan, M.A.',NULL,80000.00,90000.00,100,5,'pcs','products/47nA5fNqUzSDt0rPsFPAPnALeCR4LpKZF5brHDSH.png',1,'2026-04-14 04:20:05','2026-04-14 04:20:05'),(15,1,'Sosiologi Pendidikan Dr. Ajat Rukajat M.M.Pd. dan Dr. H. Agus Susanto, M.M.',NULL,100000.00,150000.00,80,5,'pcs','products/6fEWUXoof4JdXO9905yEwi27LpafA9j6CNKHB69v.jpg',1,'2026-04-14 04:22:58','2026-04-14 04:22:58');

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

CREATE TABLE `sessions` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint 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 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 `stock_movements`
--

CREATE TABLE `stock_movements` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `product_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `type` enum('in','out','adjustment') COLLATE utf8mb4_unicode_ci NOT NULL,
  `qty` int NOT NULL,
  `qty_before` int NOT NULL,
  `qty_after` int NOT NULL,
  `note` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `stock_movements_user_id_foreign` (`user_id`),
  KEY `stock_movements_product_id_type_created_at_index` (`product_id`,`type`,`created_at`),
  CONSTRAINT `stock_movements_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  CONSTRAINT `stock_movements_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `stock_movements`
--

INSERT INTO `stock_movements` VALUES (1,7,1,'out',1,50,49,'Penjualan INV-20260414-0001','2026-04-14 03:39:01','2026-04-14 03:39:01'),(2,6,1,'out',1,70,69,'Penjualan INV-20260414-0001','2026-04-14 03:39:01','2026-04-14 03:39:01'),(3,5,1,'out',1,50,49,'Penjualan INV-20260414-0001','2026-04-14 03:39:01','2026-04-14 03:39:01'),(4,4,1,'out',1,60,59,'Penjualan INV-20260414-0001','2026-04-14 03:39:01','2026-04-14 03:39:01'),(5,3,1,'out',1,47,46,'Penjualan INV-20260414-0001','2026-04-14 03:39:01','2026-04-14 03:39:01'),(6,2,1,'out',1,147,146,'Penjualan INV-20260414-0001','2026-04-14 03:39:01','2026-04-14 03:39:01'),(7,1,1,'out',1,200,199,'Penjualan INV-20260414-0001','2026-04-14 03:39:01','2026-04-14 03:39:01');

--
-- Table structure for table `transaction_items`
--

CREATE TABLE `transaction_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `transaction_id` bigint unsigned NOT NULL,
  `product_id` bigint unsigned DEFAULT NULL,
  `product_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `hpp` decimal(15,2) NOT NULL DEFAULT '0.00',
  `sell_price` decimal(15,2) NOT NULL DEFAULT '0.00',
  `qty` int NOT NULL DEFAULT '1',
  `discount_item` decimal(15,2) NOT NULL DEFAULT '0.00',
  `subtotal` decimal(15,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `transaction_items_product_id_foreign` (`product_id`),
  KEY `transaction_items_transaction_id_product_id_index` (`transaction_id`,`product_id`),
  CONSTRAINT `transaction_items_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE SET NULL,
  CONSTRAINT `transaction_items_transaction_id_foreign` FOREIGN KEY (`transaction_id`) REFERENCES `transactions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `transaction_items`
--

INSERT INTO `transaction_items` VALUES (1,1,7,'PENGEMBANGAN BAHAN AJAR PAI',50000.00,70000.00,1,0.00,70000.00,'2026-04-14 03:39:01','2026-04-14 03:39:01'),(2,1,6,'Micro Teaching: Teori dan Praktik',90000.00,105000.00,1,0.00,105000.00,'2026-04-14 03:39:01','2026-04-14 03:39:01'),(3,1,5,'Fiqih Islam Lengkap - Drs H Moh Rifai - Toha Putra -',30000.00,40000.00,1,0.00,40000.00,'2026-04-14 03:39:01','2026-04-14 03:39:01'),(4,1,4,'CYBER SOCIETY: Teknologi, Media Baru, dan Disrupsi Informasi',70000.00,80000.00,1,0.00,80000.00,'2026-04-14 03:39:01','2026-04-14 03:39:01'),(5,1,3,'Classroom Management untuk Mahasiswa Jurusan Pendidikan',90000.00,102000.00,1,0.00,102000.00,'2026-04-14 03:39:01','2026-04-14 03:39:01'),(6,1,2,'BUKU PENELITIAN DALAM APLIKASI CLASSROOM ACTION RESEARCH (CAR) Pendidikan, Bimbingan dan Latihan Menyusun Penelitian Tindakan Kelas (PTK) Untuk Guru dan Mahasiswa',60000.00,70000.00,1,0.00,70000.00,'2026-04-14 03:39:01','2026-04-14 03:39:01'),(7,1,1,'BIMBINGAN KONSELING PAI (PENDIDIKAN AGAMA ISLAM) Raden Roro Wulan Ayu Wardani, S.Pd., M.M',65000.00,75000.00,1,0.00,75000.00,'2026-04-14 03:39:01','2026-04-14 03:39:01');

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

CREATE TABLE `transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `invoice_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `subtotal` decimal(15,2) NOT NULL DEFAULT '0.00',
  `discount_amount` decimal(15,2) NOT NULL DEFAULT '0.00',
  `total` decimal(15,2) NOT NULL DEFAULT '0.00',
  `payment_method` enum('cash','transfer','hutang') COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount_paid` decimal(15,2) NOT NULL DEFAULT '0.00',
  `change_amount` decimal(15,2) NOT NULL DEFAULT '0.00',
  `status` enum('completed','voided') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'completed',
  `note` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `transactions_invoice_number_unique` (`invoice_number`),
  KEY `idx_tx_invoice` (`invoice_number`),
  KEY `idx_tx_user` (`user_id`),
  KEY `idx_tx_payment` (`payment_method`),
  KEY `idx_tx_created` (`created_at`),
  CONSTRAINT `transactions_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

INSERT INTO `transactions` VALUES (1,'INV-20260414-0001',1,542000.00,0.00,542000.00,'cash',600000.00,58000.00,'completed',NULL,'2026-04-14 03:39:00','2026-04-14 03:39:00');


