create stock and stock logs
This commit is contained in:
95
ckb.sql
95
ckb.sql
@@ -144,7 +144,7 @@ CREATE TABLE `migrations` (
|
||||
`migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`batch` int NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
@@ -153,7 +153,7 @@ CREATE TABLE `migrations` (
|
||||
|
||||
LOCK TABLES `migrations` WRITE;
|
||||
/*!40000 ALTER TABLE `migrations` DISABLE KEYS */;
|
||||
INSERT INTO `migrations` VALUES (1,'2014_10_12_100000_create_password_resets_table',1),(2,'2019_08_19_000000_create_failed_jobs_table',1),(3,'2019_12_14_000001_create_personal_access_tokens_table',1),(4,'2022_05_20_100209_create_dealers_table',1),(5,'2022_05_20_100326_create_categories_table',1),(6,'2022_05_20_100335_create_works_table',1),(7,'2022_05_20_100340_create_users_table',1),(8,'2022_05_20_100410_create_transactions_table',1),(9,'2022_05_25_024641_update_works_table',2),(10,'2022_05_25_103839_update_categories_table',3),(13,'2022_05_25_144502_update_transaction_table',4),(18,'2022_05_29_211410_update_table_works_add_shortname_field',5),(20,'2022_05_29_211531_update_dealers_table_add_pic_field',6),(21,'2022_05_29_220642_update_transactions_table_add_status_column',7),(22,'2022_05_31_003725_update_transaction_table_add_dealer_id',8),(23,'2022_06_23_215115_add_deleted_at_at_users_table',9),(24,'2022_06_23_215243_add_deleted_at_at_dealers_table',9),(25,'2022_06_23_215321_add_deleted_at_at_categories_table',9),(26,'2022_06_23_215341_add_deleted_at_at_works_table',9),(27,'2022_06_23_215404_add_deleted_at_at_transactions_table',9),(28,'2023_08_11_140743_create_roles_table',10),(29,'2023_08_11_140957_create_privileges_table',10),(30,'2023_08_11_141029_add_role_id_into_users_table',10),(31,'2023_08_11_144823_create_menus_table',10),(32,'2023_08_11_144857_add_menu_id_in_privileges_table',10),(33,'2023_08_11_145537_remove_name_in_privileges_table',10),(55,'2025_05_28_113228_create_product_categories_table',11),(56,'2025_05_28_113324_create_products_table',11),(59,'2025_06_04_101915_create_opnames_table',12),(60,'2025_06_04_103359_create_opname_details_table',12);
|
||||
INSERT INTO `migrations` VALUES (1,'2014_10_12_100000_create_password_resets_table',1),(2,'2019_08_19_000000_create_failed_jobs_table',1),(3,'2019_12_14_000001_create_personal_access_tokens_table',1),(4,'2022_05_20_100209_create_dealers_table',1),(5,'2022_05_20_100326_create_categories_table',1),(6,'2022_05_20_100335_create_works_table',1),(7,'2022_05_20_100340_create_users_table',1),(8,'2022_05_20_100410_create_transactions_table',1),(9,'2022_05_25_024641_update_works_table',2),(10,'2022_05_25_103839_update_categories_table',3),(13,'2022_05_25_144502_update_transaction_table',4),(18,'2022_05_29_211410_update_table_works_add_shortname_field',5),(20,'2022_05_29_211531_update_dealers_table_add_pic_field',6),(21,'2022_05_29_220642_update_transactions_table_add_status_column',7),(22,'2022_05_31_003725_update_transaction_table_add_dealer_id',8),(23,'2022_06_23_215115_add_deleted_at_at_users_table',9),(24,'2022_06_23_215243_add_deleted_at_at_dealers_table',9),(25,'2022_06_23_215321_add_deleted_at_at_categories_table',9),(26,'2022_06_23_215341_add_deleted_at_at_works_table',9),(27,'2022_06_23_215404_add_deleted_at_at_transactions_table',9),(28,'2023_08_11_140743_create_roles_table',10),(29,'2023_08_11_140957_create_privileges_table',10),(30,'2023_08_11_141029_add_role_id_into_users_table',10),(31,'2023_08_11_144823_create_menus_table',10),(32,'2023_08_11_144857_add_menu_id_in_privileges_table',10),(33,'2023_08_11_145537_remove_name_in_privileges_table',10),(55,'2025_05_28_113228_create_product_categories_table',11),(56,'2025_05_28_113324_create_products_table',11),(59,'2025_06_04_101915_create_opnames_table',12),(60,'2025_06_04_103359_create_opname_details_table',12),(66,'2025_06_10_135321_create_stocks_table',13),(67,'2025_06_10_135341_create_stock_logs_table',14),(68,'2025_06_10_135417_add_approval_columns_to_opnames_table',14),(69,'2025_06_10_140540_change_stock_columns_to_decimal_in_opname_details',14);
|
||||
/*!40000 ALTER TABLE `migrations` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
@@ -168,9 +168,9 @@ CREATE TABLE `opname_details` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
||||
`opname_id` bigint unsigned NOT NULL,
|
||||
`product_id` bigint unsigned NOT NULL,
|
||||
`system_stock` int NOT NULL,
|
||||
`physical_stock` int NOT NULL,
|
||||
`difference` int NOT NULL DEFAULT '0',
|
||||
`system_stock` decimal(10,2) NOT NULL,
|
||||
`physical_stock` decimal(10,2) NOT NULL,
|
||||
`difference` decimal(10,2) NOT NULL DEFAULT '0.00',
|
||||
`note` text COLLATE utf8mb4_unicode_ci,
|
||||
`deleted_at` timestamp NULL DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
@@ -189,7 +189,7 @@ CREATE TABLE `opname_details` (
|
||||
|
||||
LOCK TABLES `opname_details` WRITE;
|
||||
/*!40000 ALTER TABLE `opname_details` DISABLE KEYS */;
|
||||
INSERT INTO `opname_details` VALUES (1,1,1,66,88,22,NULL,NULL,'2025-06-05 04:27:30','2025-06-05 04:27:30'),(2,1,3,77,88,11,NULL,NULL,'2025-06-05 04:27:30','2025-06-05 04:27:30');
|
||||
INSERT INTO `opname_details` VALUES (1,1,1,0.00,10.00,10.00,'tambah produk baru',NULL,'2025-06-10 10:26:24','2025-06-10 10:26:24'),(2,2,1,0.00,30.00,30.00,'tambah baru',NULL,'2025-06-10 10:27:30','2025-06-10 10:27:30');
|
||||
/*!40000 ALTER TABLE `opname_details` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
@@ -209,12 +209,18 @@ CREATE TABLE `opnames` (
|
||||
`deleted_at` timestamp NULL DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
`status` enum('draft','pending','approved','rejected') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
|
||||
`approved_by` bigint unsigned DEFAULT NULL,
|
||||
`approved_at` timestamp NULL DEFAULT NULL,
|
||||
`rejection_note` text COLLATE utf8mb4_unicode_ci,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `opnames_dealer_id_foreign` (`dealer_id`),
|
||||
KEY `opnames_user_id_foreign` (`user_id`),
|
||||
KEY `opnames_approved_by_foreign` (`approved_by`),
|
||||
CONSTRAINT `opnames_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`),
|
||||
CONSTRAINT `opnames_dealer_id_foreign` FOREIGN KEY (`dealer_id`) REFERENCES `dealers` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `opnames_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
@@ -223,7 +229,7 @@ CREATE TABLE `opnames` (
|
||||
|
||||
LOCK TABLES `opnames` WRITE;
|
||||
/*!40000 ALTER TABLE `opnames` DISABLE KEYS */;
|
||||
INSERT INTO `opnames` VALUES (1,20,'2025-06-05',8,NULL,NULL,'2025-06-05 04:27:30','2025-06-05 04:27:30');
|
||||
INSERT INTO `opnames` VALUES (1,20,'2025-06-10',8,'test tambah product by opname',NULL,'2025-06-10 10:26:24','2025-06-10 10:26:24','approved',8,'2025-06-10 10:26:24',NULL),(2,24,'2025-06-10',8,'test tambah produk by opname',NULL,'2025-06-10 10:27:30','2025-06-10 10:27:30','approved',8,'2025-06-10 10:27:30',NULL);
|
||||
/*!40000 ALTER TABLE `opnames` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
@@ -412,6 +418,77 @@ INSERT INTO `roles` VALUES (2,'admin',NULL,'2023-08-13 11:21:43','2023-08-13 11:
|
||||
/*!40000 ALTER TABLE `roles` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `stock_logs`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `stock_logs`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `stock_logs` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
||||
`stock_id` bigint unsigned NOT NULL,
|
||||
`source_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`source_id` bigint unsigned NOT NULL,
|
||||
`previous_quantity` decimal(10,2) NOT NULL,
|
||||
`new_quantity` decimal(10,2) NOT NULL,
|
||||
`quantity_change` decimal(10,2) NOT NULL,
|
||||
`change_type` enum('increase','decrease','adjustment','no_change') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'no_change',
|
||||
`description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`user_id` bigint unsigned NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `stock_logs_stock_id_foreign` (`stock_id`),
|
||||
KEY `stock_logs_user_id_foreign` (`user_id`),
|
||||
KEY `stock_logs_source_type_source_id_index` (`source_type`,`source_id`),
|
||||
CONSTRAINT `stock_logs_stock_id_foreign` FOREIGN KEY (`stock_id`) REFERENCES `stocks` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `stock_logs_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `stock_logs`
|
||||
--
|
||||
|
||||
LOCK TABLES `stock_logs` WRITE;
|
||||
/*!40000 ALTER TABLE `stock_logs` DISABLE KEYS */;
|
||||
INSERT INTO `stock_logs` VALUES (1,1,'App\\Models\\Opname',1,0.00,10.00,10.00,'increase','Stock adjustment from auto-approved opname #1',8,'2025-06-10 10:26:24','2025-06-10 10:26:24'),(2,2,'App\\Models\\Opname',2,0.00,30.00,30.00,'increase','Stock adjustment from auto-approved opname #2',8,'2025-06-10 10:27:30','2025-06-10 10:27:30');
|
||||
/*!40000 ALTER TABLE `stock_logs` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `stocks`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `stocks`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `stocks` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
||||
`product_id` bigint unsigned NOT NULL,
|
||||
`dealer_id` bigint unsigned NOT NULL,
|
||||
`quantity` decimal(10,2) NOT NULL DEFAULT '0.00',
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `stocks_product_id_foreign` (`product_id`),
|
||||
KEY `stocks_dealer_id_foreign` (`dealer_id`),
|
||||
CONSTRAINT `stocks_dealer_id_foreign` FOREIGN KEY (`dealer_id`) REFERENCES `dealers` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `stocks_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `stocks`
|
||||
--
|
||||
|
||||
LOCK TABLES `stocks` WRITE;
|
||||
/*!40000 ALTER TABLE `stocks` DISABLE KEYS */;
|
||||
INSERT INTO `stocks` VALUES (1,1,20,10.00,'2025-06-10 10:26:24','2025-06-10 10:26:24'),(2,1,24,30.00,'2025-06-10 10:27:30','2025-06-10 10:27:30');
|
||||
/*!40000 ALTER TABLE `stocks` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `transactions`
|
||||
--
|
||||
@@ -569,4 +646,4 @@ UNLOCK TABLES;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2025-06-05 19:06:52
|
||||
-- Dump completed on 2025-06-10 18:16:53
|
||||
|
||||
Reference in New Issue
Block a user