/*
SQLyog Ultimate v13.1.1 (64 bit)
MySQL - 8.0.30 : Database - db_dazry_app
*********************************************************************
*/



CREATE DATABASE /*!32312 IF NOT EXISTS*/`db_dazry_app` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;

USE `db_dazry_app`;

/*Table structure for table `bahan_bakus` */


CREATE TABLE `bahan_bakus` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `nama` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `satuan_pemakaian` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'kg',
  `satuan_pembelian` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'kg',
  `konversi` decimal(8,2) NOT NULL DEFAULT '1.00',
  `stok_saat_ini` decimal(10,2) NOT NULL DEFAULT '0.00',
  `harga_beli_rata2` decimal(15,2) DEFAULT NULL,
  `stok_minimum` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `bahan_bakus` */

insert  into `bahan_bakus`(`id`,`nama`,`satuan_pemakaian`,`satuan_pembelian`,`konversi`,`stok_saat_ini`,`harga_beli_rata2`,`stok_minimum`,`created_at`,`updated_at`) values 
(1,'Texapon','ml','kg',1000.00,150.00,44000.00,50,'2025-07-29 15:59:28','2025-07-29 15:59:32'),
(2,'Essense','ml','l',1000.00,50.00,20000.00,10,'2025-09-03 09:19:48','2025-09-03 09:19:54');

/*Table structure for table `bom_produk` */


CREATE TABLE `bom_produk` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `produk_jadi_id` bigint unsigned NOT NULL,
  `bahan_baku_id` bigint unsigned NOT NULL,
  `kuantitas_dibutuhkan` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `bom_produk_produk_jadi_id_bahan_baku_id_unique` (`produk_jadi_id`,`bahan_baku_id`),
  KEY `bom_produk_bahan_baku_id_foreign` (`bahan_baku_id`),
  CONSTRAINT `bom_produk_bahan_baku_id_foreign` FOREIGN KEY (`bahan_baku_id`) REFERENCES `bahan_bakus` (`id`) ON DELETE CASCADE,
  CONSTRAINT `bom_produk_produk_jadi_id_foreign` FOREIGN KEY (`produk_jadi_id`) REFERENCES `produk_jadis` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `bom_produk` */

/*Table structure for table `bom_produks` */


CREATE TABLE `bom_produks` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `produk_jadi_id` bigint unsigned DEFAULT NULL,
  `produk_setengah_jadi_id` bigint unsigned DEFAULT NULL,
  `bahan_baku_id` bigint unsigned NOT NULL,
  `kuantitas_dibutuhkan` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `bom_produks_produk_jadi_id_foreign` (`produk_jadi_id`),
  KEY `bom_produks_produk_setengah_jadi_id_foreign` (`produk_setengah_jadi_id`),
  KEY `bom_produks_bahan_baku_id_foreign` (`bahan_baku_id`),
  CONSTRAINT `bom_produks_bahan_baku_id_foreign` FOREIGN KEY (`bahan_baku_id`) REFERENCES `bahan_bakus` (`id`) ON DELETE CASCADE,
  CONSTRAINT `bom_produks_produk_jadi_id_foreign` FOREIGN KEY (`produk_jadi_id`) REFERENCES `produk_jadis` (`id`) ON DELETE CASCADE,
  CONSTRAINT `bom_produks_produk_setengah_jadi_id_foreign` FOREIGN KEY (`produk_setengah_jadi_id`) REFERENCES `produk_setengah_jadis` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `cache_locks` */

/*Table structure for table `detail_pembelian` */


CREATE TABLE `detail_pembelian` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `pembelian_id` bigint unsigned NOT NULL,
  `bahan_baku_id` bigint unsigned NOT NULL,
  `kuantitas` decimal(10,2) NOT NULL,
  `harga_satuan` decimal(15,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `detail_pembelian_pembelian_id_foreign` (`pembelian_id`),
  KEY `detail_pembelian_bahan_baku_id_foreign` (`bahan_baku_id`),
  CONSTRAINT `detail_pembelian_bahan_baku_id_foreign` FOREIGN KEY (`bahan_baku_id`) REFERENCES `bahan_bakus` (`id`),
  CONSTRAINT `detail_pembelian_pembelian_id_foreign` FOREIGN KEY (`pembelian_id`) REFERENCES `pembelian` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `detail_pembelian` */

/*Table structure for table `detail_pembelian_bahan_bakus` */


CREATE TABLE `detail_pembelian_bahan_bakus` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `pembelian_id` bigint unsigned NOT NULL,
  `bahan_baku_id` bigint unsigned NOT NULL,
  `kuantitas` decimal(10,2) NOT NULL,
  `harga_unit` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `detail_pembelian_bahan_bakus_pembelian_id_foreign` (`pembelian_id`),
  KEY `detail_pembelian_bahan_bakus_bahan_baku_id_foreign` (`bahan_baku_id`),
  CONSTRAINT `detail_pembelian_bahan_bakus_bahan_baku_id_foreign` FOREIGN KEY (`bahan_baku_id`) REFERENCES `bahan_bakus` (`id`) ON DELETE CASCADE,
  CONSTRAINT `detail_pembelian_bahan_bakus_pembelian_id_foreign` FOREIGN KEY (`pembelian_id`) REFERENCES `pembelian_bahan_bakus` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `detail_pembelian_bahan_bakus` */

/*Table structure for table `detail_pembelian_kemasans` */


CREATE TABLE `detail_pembelian_kemasans` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `pembelian_id` bigint unsigned NOT NULL,
  `kemasan_id` bigint unsigned NOT NULL,
  `kuantitas` decimal(10,2) NOT NULL,
  `harga_unit` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `detail_pembelian_kemasans_pembelian_id_foreign` (`pembelian_id`),
  KEY `detail_pembelian_kemasans_kemasan_id_foreign` (`kemasan_id`),
  CONSTRAINT `detail_pembelian_kemasans_kemasan_id_foreign` FOREIGN KEY (`kemasan_id`) REFERENCES `kemasans` (`id`) ON DELETE CASCADE,
  CONSTRAINT `detail_pembelian_kemasans_pembelian_id_foreign` FOREIGN KEY (`pembelian_id`) REFERENCES `pembelian_kemasans` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `detail_pembelian_kemasans` */

/*Table structure for table `detail_pengemasans` */


CREATE TABLE `detail_pengemasans` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `pengemasan_id` bigint unsigned NOT NULL,
  `item_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `produk_jadi_id` bigint unsigned NOT NULL,
  `jumlah` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `detail_pengemasans_pengemasan_id_foreign` (`pengemasan_id`),
  KEY `detail_pengemasans_item_type_item_id_index` (`item_type`,`produk_jadi_id`),
  KEY `detail_pengemasans_produk_jadis_id_foreign` (`produk_jadi_id`),
  CONSTRAINT `detail_pengemasans_pengemasan_id_foreign` FOREIGN KEY (`pengemasan_id`) REFERENCES `pengemasans` (`id`) ON DELETE CASCADE,
  CONSTRAINT `detail_pengemasans_produk_jadis_id_foreign` FOREIGN KEY (`produk_jadi_id`) REFERENCES `produk_jadis` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `detail_pengemasans` */

insert  into `detail_pengemasans`(`id`,`pengemasan_id`,`item_type`,`produk_jadi_id`,`jumlah`,`created_at`,`updated_at`) values 
(1,1,'pcs',3,10.00,'2025-09-04 17:40:50','2025-09-04 17:40:54');

/*Table structure for table `detail_penjualan` */


CREATE TABLE `detail_penjualan` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `penjualan_id` bigint unsigned NOT NULL,
  `produk_jadi_id` bigint unsigned NOT NULL,
  `kuantitas` decimal(10,2) NOT NULL,
  `harga_satuan` decimal(15,2) NOT NULL,
  `subtotal` decimal(15,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `detail_penjualan_penjualan_id_foreign` (`penjualan_id`),
  KEY `detail_penjualan_produk_jadi_id_foreign` (`produk_jadi_id`),
  CONSTRAINT `detail_penjualan_penjualan_id_foreign` FOREIGN KEY (`penjualan_id`) REFERENCES `penjualan` (`id`) ON DELETE CASCADE,
  CONSTRAINT `detail_penjualan_produk_jadi_id_foreign` FOREIGN KEY (`produk_jadi_id`) REFERENCES `produk_jadis` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `detail_penjualan` */

/*Table structure for table `detail_penjualan_bahan_baku` */


CREATE TABLE `detail_penjualan_bahan_baku` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `penjualan_bahan_baku_id` bigint unsigned NOT NULL,
  `bahan_baku_id` bigint unsigned NOT NULL,
  `kuantitas` decimal(15,2) NOT NULL,
  `harga_satuan` decimal(15,2) NOT NULL,
  `subtotal` decimal(15,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `detail_penjualan_bahan_baku_penjualan_bahan_baku_id_foreign` (`penjualan_bahan_baku_id`),
  KEY `detail_penjualan_bahan_baku_bahan_baku_id_foreign` (`bahan_baku_id`),
  CONSTRAINT `detail_penjualan_bahan_baku_bahan_baku_id_foreign` FOREIGN KEY (`bahan_baku_id`) REFERENCES `bahan_bakus` (`id`),
  CONSTRAINT `detail_penjualan_bahan_baku_penjualan_bahan_baku_id_foreign` FOREIGN KEY (`penjualan_bahan_baku_id`) REFERENCES `penjualan_bahan_baku` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `detail_penjualan_bahan_baku` */

/*Table structure for table `detail_penjualan_konsinyasi` */


CREATE TABLE `detail_penjualan_konsinyasi` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `penjualan_konsinyasi_id` bigint unsigned NOT NULL,
  `produk_jadi_id` bigint unsigned NOT NULL,
  `kuantitas_kirim` decimal(10,2) NOT NULL,
  `kuantitas_terjual` decimal(10,2) NOT NULL DEFAULT '0.00',
  `kuantitas_retur` decimal(10,2) NOT NULL DEFAULT '0.00',
  `harga_jual` decimal(15,2) NOT NULL,
  `subtotal_terjual` decimal(15,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `detail_penjualan_konsinyasi_penjualan_konsinyasi_id_foreign` (`penjualan_konsinyasi_id`),
  KEY `detail_penjualan_konsinyasi_produk_jadi_id_foreign` (`produk_jadi_id`),
  CONSTRAINT `detail_penjualan_konsinyasi_penjualan_konsinyasi_id_foreign` FOREIGN KEY (`penjualan_konsinyasi_id`) REFERENCES `penjualan_konsinyasi` (`id`) ON DELETE CASCADE,
  CONSTRAINT `detail_penjualan_konsinyasi_produk_jadi_id_foreign` FOREIGN KEY (`produk_jadi_id`) REFERENCES `produk_jadis` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `detail_penjualan_konsinyasi` */

insert  into `detail_penjualan_konsinyasi`(`id`,`penjualan_konsinyasi_id`,`produk_jadi_id`,`kuantitas_kirim`,`kuantitas_terjual`,`kuantitas_retur`,`harga_jual`,`subtotal_terjual`,`created_at`,`updated_at`) values 
(5,6,3,3.00,3.00,0.00,21000.00,63000.00,'2025-09-10 05:40:41','2025-09-10 09:08:58'),
(6,7,3,5.00,3.00,2.00,21000.00,63000.00,'2025-09-10 09:02:20','2025-09-10 10:31:35');

/*Table structure for table `detail_penjualan_langsung` */


CREATE TABLE `detail_penjualan_langsung` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `penjualan_langsung_id` bigint unsigned NOT NULL,
  `produk_jadi_id` bigint unsigned NOT NULL,
  `jumlah` decimal(8,2) NOT NULL,
  `harga_satuan` decimal(15,2) NOT NULL,
  `subtotal` decimal(15,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `detail_penjualan_langsung_penjualan_langsung_id_foreign` (`penjualan_langsung_id`),
  KEY `detail_penjualan_langsung_produk_jadi_id_foreign` (`produk_jadi_id`),
  CONSTRAINT `detail_penjualan_langsung_penjualan_langsung_id_foreign` FOREIGN KEY (`penjualan_langsung_id`) REFERENCES `penjualan_langsung` (`id`) ON DELETE CASCADE,
  CONSTRAINT `detail_penjualan_langsung_produk_jadi_id_foreign` FOREIGN KEY (`produk_jadi_id`) REFERENCES `produk_jadis` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `detail_penjualan_langsung` */

/*Table structure for table `detail_penjualan_piutang` */


CREATE TABLE `detail_penjualan_piutang` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `penjualan_piutang_id` bigint unsigned NOT NULL,
  `produk_jadi_id` bigint unsigned NOT NULL,
  `jumlah` decimal(8,2) NOT NULL,
  `harga_satuan` decimal(15,2) NOT NULL,
  `subtotal` decimal(15,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `detail_penjualan_piutang_penjualan_piutang_id_foreign` (`penjualan_piutang_id`),
  KEY `detail_penjualan_piutang_produk_jadi_id_foreign` (`produk_jadi_id`),
  CONSTRAINT `detail_penjualan_piutang_penjualan_piutang_id_foreign` FOREIGN KEY (`penjualan_piutang_id`) REFERENCES `penjualan_piutang` (`id`) ON DELETE CASCADE,
  CONSTRAINT `detail_penjualan_piutang_produk_jadi_id_foreign` FOREIGN KEY (`produk_jadi_id`) REFERENCES `produk_jadis` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `detail_penjualan_piutang` */

/*Table structure for table `detail_pesanan_penjualan` */


CREATE TABLE `detail_pesanan_penjualan` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `pesanan_penjualan_id` bigint unsigned NOT NULL,
  `produk_jadi_id` bigint unsigned NOT NULL,
  `kuantitas` decimal(10,2) NOT NULL,
  `harga_satuan` decimal(15,2) NOT NULL,
  `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 `detail_pesanan_penjualan_pesanan_penjualan_id_foreign` (`pesanan_penjualan_id`),
  KEY `detail_pesanan_penjualan_produk_jadi_id_foreign` (`produk_jadi_id`),
  CONSTRAINT `detail_pesanan_penjualan_pesanan_penjualan_id_foreign` FOREIGN KEY (`pesanan_penjualan_id`) REFERENCES `pesanan_penjualan` (`id`) ON DELETE CASCADE,
  CONSTRAINT `detail_pesanan_penjualan_produk_jadi_id_foreign` FOREIGN KEY (`produk_jadi_id`) REFERENCES `produk_jadis` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `detail_pesanan_penjualan` */

/*Table structure for table `detail_produksi` */


CREATE TABLE `detail_produksi` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `produksi_id` bigint unsigned NOT NULL,
  `bahan_baku_id` bigint unsigned NOT NULL,
  `kuantitas_digunakan` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `detail_produksi_produksi_id_foreign` (`produksi_id`),
  KEY `detail_produksi_bahan_baku_id_foreign` (`bahan_baku_id`),
  CONSTRAINT `detail_produksi_bahan_baku_id_foreign` FOREIGN KEY (`bahan_baku_id`) REFERENCES `bahan_bakus` (`id`) ON DELETE CASCADE,
  CONSTRAINT `detail_produksi_produksi_id_foreign` FOREIGN KEY (`produksi_id`) REFERENCES `produksi` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `detail_produksi` */

insert  into `detail_produksi`(`id`,`produksi_id`,`bahan_baku_id`,`kuantitas_digunakan`,`created_at`,`updated_at`) values 
(2,2,1,1.00,'2025-09-03 17:23:02','2025-09-03 17:23:05'),
(3,2,2,1.00,'2025-09-04 08:51:44','2025-09-04 08:51:46');

/*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;

/*Data for the table `failed_jobs` */

/*Table structure for table `hutangs` */


CREATE TABLE `hutangs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `nama_pemberi_hutang` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `jumlah` decimal(15,2) NOT NULL,
  `tanggal_pinjam` date NOT NULL,
  `tanggal_jatuh_tempo` date DEFAULT NULL,
  `status` enum('belum lunas','lunas') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'belum lunas',
  `keterangan` 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;

/*Data for the table `hutangs` */

/*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;

/*Data for the 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;

/*Data for the table `jobs` */

/*Table structure for table `kemasans` */


CREATE TABLE `kemasans` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `nama` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `satuan` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `stok_saat_ini` decimal(10,2) NOT NULL DEFAULT '0.00',
  `stok_minimum` decimal(10,2) NOT NULL DEFAULT '0.00',
  `keterangan` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `kemasans` */

insert  into `kemasans`(`id`,`nama`,`satuan`,`stok_saat_ini`,`stok_minimum`,`keterangan`,`created_at`,`updated_at`) values 
(1,'botol','pcs',10.00,5.00,'-','2025-09-03 09:55:09','2025-09-03 09:55:13');

/*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=50 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `migrations` */

insert  into `migrations`(`id`,`migration`,`batch`) 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,'2025_07_28_073026_create_roles_table',2),
(5,'2025_07_28_073246_create_bahan_baku_table',3),
(6,'2025_07_28_073433_create_produk_jadi_table',3),
(7,'2025_07_28_073536_create_pemasok_table',3),
(8,'2025_07_28_073648_create_pelanggan_table',3),
(9,'2025_07_28_073746_create_pembelian_table',3),
(10,'2025_07_28_073857_create_detail_pembelian_table',3),
(11,'2025_07_28_074007_create_pesanan_penjualan_table',3),
(12,'2025_07_28_074231_create_detail_pesanan_penjualan_table',3),
(13,'2025_07_28_074323_create_transaksi_penjualan_table',3),
(14,'2025_07_28_074432_create_pergerakan_stok_table',3),
(15,'2025_07_28_074605_create_produksi_table',3),
(17,'2025_07_28_074823_create_transaksi_kas_table',3),
(20,'2025_07_28_074716_create_bom_produk_table',4),
(23,'2025_07_31_063529_add_columns_to_produksi_table',5),
(24,'2025_07_31_063904_create_detail_produksi_table',5),
(25,'2025_07_31_070927_create_bom_produk_table',6),
(26,'2025_07_31_093211_create_detail_penjualan_table',7),
(27,'2025_08_01_062858_create_penyesuaian_stok_table',8),
(28,'2025_08_01_071450_create_pengeluaran_table',9),
(29,'2025_09_02_012425_create_master_data_tables',10),
(30,'2025_09_02_021233_create_penjualan_and_piutang_tables',11),
(31,'2025_09_02_083346_add_units_to_bahan_bakus_table',12),
(32,'2025_09_03_025357_create_kemasans_table',13),
(33,'2025_09_03_030006_create_produk_setengah_jadis_table',14),
(34,'2025_09_02_083346_add_units_to_produk_jadi_table',15),
(35,'2025_09_03_064542_create_pembelian_bahan_baku_table',16),
(36,'2025_09_03_065423_create_pembelian_kemasan_table',17),
(37,'2025_09_03_071816_create_bom_produks_table',18),
(38,'2025_09_03_093259_create_pengemasan_table',19),
(39,'2025_09_03_093260_create_pengemasan_table',20),
(40,'2025_09_04_085943_create_detail_pengemasan_table',21),
(41,'2025_09_04_100558_create_detail_pembelian_table',22),
(43,'2025_09_09_015443_create_penjualan_langsung_table',23),
(45,'2025_09_09_020721_create_penjualan_piutang_table',24),
(46,'2025_09_09_060703_create_penjualan_bahan_baku_table',25),
(47,'2025_09_09_070511_create_penjualan_konsinyasi_table',26),
(48,'2025_09_09_070645_create_detail_penjualan_konsinyasi_table',26),
(49,'2025_09_11_044726_create_hutangs_table',27);

/*Data for the table `password_reset_tokens` */

/*Table structure for table `pelanggans` */


CREATE TABLE `pelanggans` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `nama` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `alamat` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `telepon` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `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;

/*Data for the table `pelanggans` */

insert  into `pelanggans`(`id`,`nama`,`alamat`,`telepon`,`created_at`,`updated_at`) values 
(2,'budi','jambi','0811741100','2025-09-09 11:08:46','2025-09-09 11:08:49'),
(3,'widiarini','jambi','0852987765','2025-09-10 04:58:07','2025-09-10 04:58:07');

/*Table structure for table `pemasoks` */


CREATE TABLE `pemasoks` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `nama` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `alamat` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `telepon` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `pemasoks` */

/*Table structure for table `pembelian` */


CREATE TABLE `pembelian` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tanggal` date NOT NULL,
  `pemasok_id` bigint unsigned DEFAULT NULL,
  `total_harga` decimal(15,2) NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'completed',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pembelian_pemasok_id_foreign` (`pemasok_id`),
  CONSTRAINT `pembelian_pemasok_id_foreign` FOREIGN KEY (`pemasok_id`) REFERENCES `pemasoks` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `pembelian` */

/*Table structure for table `pembelian_bahan_bakus` */


CREATE TABLE `pembelian_bahan_bakus` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `pemasok_id` bigint unsigned NOT NULL,
  `bahan_baku_id` bigint unsigned NOT NULL,
  `jumlah` decimal(10,2) NOT NULL,
  `satuan` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `harga_per_satuan` decimal(15,2) NOT NULL,
  `total_harga` decimal(15,2) NOT NULL,
  `tanggal_pembelian` date NOT NULL,
  `nomor_faktur` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pembelian_bahan_baku_pemasok_id_foreign` (`pemasok_id`),
  KEY `pembelian_bahan_baku_bahan_baku_id_foreign` (`bahan_baku_id`),
  CONSTRAINT `pembelian_bahan_baku_bahan_baku_id_foreign` FOREIGN KEY (`bahan_baku_id`) REFERENCES `bahan_bakus` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pembelian_bahan_baku_pemasok_id_foreign` FOREIGN KEY (`pemasok_id`) REFERENCES `pemasoks` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `pembelian_bahan_bakus` */

/*Table structure for table `pembelian_kemasans` */


CREATE TABLE `pembelian_kemasans` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `pemasok_id` bigint unsigned NOT NULL,
  `kemasan_id` bigint unsigned NOT NULL,
  `jumlah` int NOT NULL,
  `harga_per_satuan` decimal(15,2) NOT NULL,
  `total_harga` decimal(15,2) NOT NULL,
  `tanggal_pembelian` date NOT NULL,
  `nomor_faktur` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pembelian_kemasan_pemasok_id_foreign` (`pemasok_id`),
  KEY `pembelian_kemasan_kemasan_id_foreign` (`kemasan_id`),
  CONSTRAINT `pembelian_kemasan_kemasan_id_foreign` FOREIGN KEY (`kemasan_id`) REFERENCES `kemasans` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pembelian_kemasan_pemasok_id_foreign` FOREIGN KEY (`pemasok_id`) REFERENCES `pemasoks` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `pembelian_kemasans` */

/*Table structure for table `pengeluaran` */


CREATE TABLE `pengeluaran` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tanggal` date NOT NULL,
  `kategori` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `deskripsi` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `jumlah` decimal(15,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `pengeluaran` */

/*Table structure for table `pengemasans` */


CREATE TABLE `pengemasans` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tanggal` date NOT NULL,
  `produk_setengah_jadi_id` bigint unsigned NOT NULL,
  `produk_jadi_id` bigint unsigned NOT NULL,
  `jumlah_produk_jadi` decimal(10,2) NOT NULL,
  `keterangan` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pengemasans_produk_setengah_jadi_id_foreign` (`produk_setengah_jadi_id`),
  KEY `pengemasans_produk_jadi_id_foreign` (`produk_jadi_id`),
  CONSTRAINT `pengemasans_produk_jadi_id_foreign` FOREIGN KEY (`produk_jadi_id`) REFERENCES `produk_jadis` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pengemasans_produk_setengah_jadi_id_foreign` FOREIGN KEY (`produk_setengah_jadi_id`) REFERENCES `produk_setengah_jadis` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `pengemasans` */

insert  into `pengemasans`(`id`,`tanggal`,`produk_setengah_jadi_id`,`produk_jadi_id`,`jumlah_produk_jadi`,`keterangan`,`created_at`,`updated_at`) values 
(1,'2025-09-04',1,3,1.00,'-','2025-09-04 16:20:24','2025-09-04 16:20:28');

/*Table structure for table `penjualan` */


CREATE TABLE `penjualan` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tanggal` date NOT NULL,
  `pelanggan_id` bigint unsigned NOT NULL,
  `produk_jadi_id` bigint unsigned NOT NULL,
  `jenis_penjualan` enum('langsung','piutang') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'langsung',
  `total_harga` decimal(15,2) NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'completed',
  `keterangan` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_penjualan_pelanggan` (`pelanggan_id`),
  KEY `penjualan_produk_jadi_id_foreign` (`produk_jadi_id`),
  CONSTRAINT `fk_penjualan_pelanggan` FOREIGN KEY (`pelanggan_id`) REFERENCES `pelanggans` (`id`) ON DELETE CASCADE,
  CONSTRAINT `penjualan_produk_jadi_id_foreign` FOREIGN KEY (`produk_jadi_id`) REFERENCES `produk_jadis` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `penjualan` */

/*Table structure for table `penjualan_bahan_baku` */


CREATE TABLE `penjualan_bahan_baku` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tanggal` date NOT NULL,
  `nomor_transaksi` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `pelanggan_nama` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `total_harga` decimal(15,2) NOT NULL,
  `keterangan` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `penjualan_bahan_baku_nomor_transaksi_unique` (`nomor_transaksi`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `penjualan_bahan_baku` */

insert  into `penjualan_bahan_baku`(`id`,`tanggal`,`nomor_transaksi`,`pelanggan_nama`,`total_harga`,`keterangan`,`created_at`,`updated_at`) values 
(1,'2025-09-09','001','budi',10000.00,'-','2025-09-09 13:34:56','2025-09-09 13:34:59');

/*Table structure for table `penjualan_konsinyasi` */


CREATE TABLE `penjualan_konsinyasi` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tanggal_kirim` date NOT NULL,
  `pelanggan_id` bigint unsigned NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `tanggal_penjualan` date DEFAULT NULL,
  `tanggal_retur` date DEFAULT NULL,
  `total_terjual` decimal(15,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `penjualan_konsinyasi_pelanggan_id_foreign` (`pelanggan_id`),
  CONSTRAINT `penjualan_konsinyasi_pelanggan_id_foreign` FOREIGN KEY (`pelanggan_id`) REFERENCES `pelanggans` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `penjualan_konsinyasi` */

insert  into `penjualan_konsinyasi`(`id`,`tanggal_kirim`,`pelanggan_id`,`status`,`tanggal_penjualan`,`tanggal_retur`,`total_terjual`,`created_at`,`updated_at`) values 
(6,'2025-09-10',2,'selesai','2025-09-10',NULL,21000.00,'2025-09-10 05:40:41','2025-09-10 09:08:58'),
(7,'2025-09-10',3,'terjual_sebagian','2025-09-10','2025-09-10',63000.00,'2025-09-10 09:02:20','2025-09-10 10:31:35');

/*Table structure for table `penjualan_langsung` */


CREATE TABLE `penjualan_langsung` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tanggal` date NOT NULL,
  `pelanggan_id` bigint unsigned NOT NULL,
  `total_harga` decimal(15,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `penjualan_langsung_pelanggan_id_foreign` (`pelanggan_id`),
  CONSTRAINT `penjualan_langsung_pelanggan_id_foreign` FOREIGN KEY (`pelanggan_id`) REFERENCES `pelanggans` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `penjualan_langsung` */

insert  into `penjualan_langsung`(`id`,`tanggal`,`pelanggan_id`,`total_harga`,`created_at`,`updated_at`) values 
(1,'2025-09-09',2,100000.00,'2025-09-09 11:16:13','2025-09-09 11:16:16');

/*Table structure for table `penjualan_piutang` */


CREATE TABLE `penjualan_piutang` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tanggal` date NOT NULL,
  `pelanggan_id` bigint unsigned NOT NULL,
  `total_harga` decimal(15,2) NOT NULL,
  `jatuh_tempo` date NOT NULL,
  `status_pembayaran` enum('belum lunas','lunas') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'belum lunas',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `penjualan_piutang_pelanggan_id_foreign` (`pelanggan_id`),
  CONSTRAINT `penjualan_piutang_pelanggan_id_foreign` FOREIGN KEY (`pelanggan_id`) REFERENCES `pelanggans` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `penjualan_piutang` */

insert  into `penjualan_piutang`(`id`,`tanggal`,`pelanggan_id`,`total_harga`,`jatuh_tempo`,`status_pembayaran`,`created_at`,`updated_at`) values 
(1,'2025-09-09',2,200000.00,'2025-09-09','belum lunas','2025-09-09 11:39:21','2025-09-09 11:39:25');

/*Table structure for table `penyesuaian_stok` */


CREATE TABLE `penyesuaian_stok` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tanggal` date NOT NULL,
  `item_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `item_id` bigint unsigned NOT NULL,
  `tipe_penyesuaian` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `jumlah` decimal(15,2) NOT NULL,
  `keterangan` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `penyesuaian_stok_item_type_item_id_index` (`item_type`,`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `penyesuaian_stok` */

/*Table structure for table `pergerakan_stok` */


CREATE TABLE `pergerakan_stok` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tanggal` date NOT NULL,
  `item_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `item_id` bigint unsigned NOT NULL,
  `tipe_pergerakan` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `jumlah` decimal(10,2) NOT NULL,
  `referensi_tipe` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `referensi_id` bigint unsigned DEFAULT NULL,
  `keterangan` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pergerakan_stok_item_type_item_id_index` (`item_type`,`item_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `pergerakan_stok` */

insert  into `pergerakan_stok`(`id`,`tanggal`,`item_type`,`item_id`,`tipe_pergerakan`,`jumlah`,`referensi_tipe`,`referensi_id`,`keterangan`,`created_at`,`updated_at`) values 
(1,'2025-09-09','App\\Models\\ProdukJadi',3,'keluar',3.00,'penjualan_konsinyasi',2,NULL,'2025-09-09 09:40:58','2025-09-09 09:40:58'),
(2,'2025-09-09','App\\Models\\ProdukJadi',3,'keluar',5.00,'penjualan_konsinyasi',3,NULL,'2025-09-09 09:45:06','2025-09-09 09:45:06'),
(3,'2025-09-10','App\\Models\\ProdukJadi',3,'masuk',5.00,'penjualan_konsinyasi_batal',3,NULL,'2025-09-10 04:50:59','2025-09-10 04:50:59'),
(4,'2025-09-10','App\\Models\\ProdukJadi',3,'keluar',3.00,'penjualan_konsinyasi',6,'Pengiriman konsinyasi','2025-09-10 05:40:41','2025-09-10 05:40:41'),
(5,'2025-09-10','App\\Models\\ProdukJadi',3,'keluar',5.00,'penjualan_konsinyasi',7,'Pengiriman konsinyasi','2025-09-10 09:02:20','2025-09-10 09:02:20'),
(6,'2025-09-10','App\\Models\\ProdukJadi',3,'masuk',1.00,'penjualan_konsinyasi_retur',7,'Pengembalian produk konsinyasi','2025-09-10 09:20:10','2025-09-10 09:20:10');

/*Table structure for table `pesanan_penjualan` */


CREATE TABLE `pesanan_penjualan` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `no_po` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tanggal_pesanan` date NOT NULL,
  `pelanggan_id` bigint unsigned NOT NULL,
  `tanggal_estimasi_selesai` date DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'baru',
  `total_harga` decimal(15,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `pesanan_penjualan_no_po_unique` (`no_po`),
  KEY `pesanan_penjualan_pelanggan_id_foreign` (`pelanggan_id`),
  CONSTRAINT `pesanan_penjualan_pelanggan_id_foreign` FOREIGN KEY (`pelanggan_id`) REFERENCES `pelanggans` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `pesanan_penjualan` */

/*Table structure for table `piutang` */


CREATE TABLE `piutang` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `penjualan_id` bigint unsigned NOT NULL,
  `tanggal_jatuh_tempo` date NOT NULL,
  `status_pembayaran` enum('belum_lunas','lunas') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'belum_lunas',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `piutang_penjualan_id_foreign` (`penjualan_id`),
  CONSTRAINT `piutang_penjualan_id_foreign` FOREIGN KEY (`penjualan_id`) REFERENCES `penjualan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `piutang` */

/*Table structure for table `produk_jadis` */


CREATE TABLE `produk_jadis` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `nama` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `satuan` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `stok_saat_ini` decimal(10,2) NOT NULL DEFAULT '0.00',
  `harga_pokok` decimal(10,2) NOT NULL DEFAULT '0.00',
  `harga_jual` decimal(15,2) NOT NULL,
  `stok_minimum` int NOT NULL DEFAULT '0',
  `keterangan` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '-',
  `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;

/*Data for the table `produk_jadis` */

insert  into `produk_jadis`(`id`,`nama`,`satuan`,`stok_saat_ini`,`harga_pokok`,`harga_jual`,`stok_minimum`,`keterangan`,`created_at`,`updated_at`) values 
(3,'parfum sakura','liter',98.00,20000.00,21000.00,5,'-','2025-09-03 16:21:39','2025-09-10 09:20:10');

/*Table structure for table `produk_setengah_jadis` */


CREATE TABLE `produk_setengah_jadis` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `nama` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `satuan` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `stok_saat_ini` decimal(10,2) NOT NULL DEFAULT '0.00',
  `stok_minimum` decimal(10,2) NOT NULL DEFAULT '0.00',
  `keterangan` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `produk_setengah_jadis` */

insert  into `produk_setengah_jadis`(`id`,`nama`,`satuan`,`stok_saat_ini`,`stok_minimum`,`keterangan`,`created_at`,`updated_at`) values 
(1,'parfum sakura','drum',2.00,1.00,'-','2025-09-03 16:36:34','2025-09-03 16:36:37');

/*Table structure for table `produksi` */


CREATE TABLE `produksi` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `produk_setengah_jadi_id` bigint unsigned DEFAULT NULL,
  `tanggal` date NOT NULL,
  `jumlah_produksi` decimal(10,2) NOT NULL,
  `kuantitas_produksi` decimal(10,2) NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'completed',
  `keterangan` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `produksi_produk_setengah_jadi_id_foreign` (`produk_setengah_jadi_id`),
  CONSTRAINT `produksi_produk_setengah_jadi_id_foreign` FOREIGN KEY (`produk_setengah_jadi_id`) REFERENCES `produk_setengah_jadis` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `produksi` */

insert  into `produksi`(`id`,`produk_setengah_jadi_id`,`tanggal`,`jumlah_produksi`,`kuantitas_produksi`,`status`,`keterangan`,`created_at`,`updated_at`) values 
(2,1,'2025-09-03',1.00,1.00,'completed','-','2025-09-03 16:39:34','2025-09-03 16:39:37');

/*Table structure for table `roles` */


CREATE TABLE `roles` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` 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 `roles_name_unique` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `roles` */

insert  into `roles`(`id`,`name`,`description`,`created_at`,`updated_at`) values 
(1,'admin','Administrator Sistem',NULL,NULL),
(2,'pemilik','Pemilik Usaha',NULL,NULL),
(3,'staff_produksi','Staf Bagian Produksi',NULL,NULL),
(4,'staff_penjualan','Staf Bagian Penjualan',NULL,NULL);

/*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;

/*Data for the table `sessions` */

insert  into `sessions`(`id`,`user_id`,`ip_address`,`user_agent`,`payload`,`last_activity`) values 
('50WMraBIj5IrjbND83Ywd4qqPhXmeMpZW0iM6p7n',1,'127.0.0.1','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36','YTo0OntzOjY6Il90b2tlbiI7czo0MDoicWEwekZQaXRqMWtiR3BaY0dYVG5ISkNHdDU2dERlQUVDd3dFcks2RyI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6MzE6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMC9kYXNoYm9hcmQiO31zOjY6Il9mbGFzaCI7YToyOntzOjM6Im9sZCI7YTowOnt9czozOiJuZXciO2E6MDp7fX1zOjUwOiJsb2dpbl93ZWJfNTliYTM2YWRkYzJiMmY5NDAxNTgwZjAxNGM3ZjU4ZWE0ZTMwOTg5ZCI7aToxO30=',1757642269),
('v07iX2HY2GzaK80Bvlvz1Saj6kZVs03FXhOdJwyq',1,'127.0.0.1','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36','YTo1OntzOjY6Il90b2tlbiI7czo0MDoiM0FIWUVrVmFhU21ueldYN3hVM1UxQ2JtcVlUUXU3ZHo3VnQwSkQ3RSI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6MzE6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMC9kYXNoYm9hcmQiO31zOjY6Il9mbGFzaCI7YToyOntzOjM6Im9sZCI7YTowOnt9czozOiJuZXciO2E6MDp7fX1zOjM6InVybCI7YTowOnt9czo1MDoibG9naW5fd2ViXzU5YmEzNmFkZGMyYjJmOTQwMTU4MGYwMTRjN2Y1OGVhNGUzMDk4OWQiO2k6MTt9',1757585607);

/*Table structure for table `transaksi_kas` */


CREATE TABLE `transaksi_kas` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tanggal` date NOT NULL,
  `keterangan` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tipe` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `jumlah` decimal(15,2) NOT NULL,
  `kategori` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `transaksi_kas` */

/*Table structure for table `transaksi_penjualan` */


CREATE TABLE `transaksi_penjualan` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tanggal` date NOT NULL,
  `pelanggan_id` bigint unsigned DEFAULT NULL,
  `total_bayar` decimal(15,2) NOT NULL,
  `tipe_pembayaran` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `pesanan_penjualan_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `transaksi_penjualan_pelanggan_id_foreign` (`pelanggan_id`),
  KEY `transaksi_penjualan_pesanan_penjualan_id_foreign` (`pesanan_penjualan_id`),
  CONSTRAINT `transaksi_penjualan_pelanggan_id_foreign` FOREIGN KEY (`pelanggan_id`) REFERENCES `pelanggans` (`id`),
  CONSTRAINT `transaksi_penjualan_pesanan_penjualan_id_foreign` FOREIGN KEY (`pesanan_penjualan_id`) REFERENCES `pesanan_penjualan` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

