-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `pos`
--

-- --------------------------------------------------------

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

CREATE TABLE `categories` (
  `id` int(11) NOT NULL,
  `nama` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `categories` (`id`, `nama`) VALUES
(3, 'ROTI MANIS'),
(4, 'ROTI ASIN');

-- --------------------------------------------------------

--
-- Table structure for table `customers`
--

CREATE TABLE `customers` (
  `id` int(11) NOT NULL,
  `nama` varchar(100) NOT NULL,
  `email` varchar(50) DEFAULT NULL,
  `alamat` text DEFAULT NULL,
  `telepon` varchar(20) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `customers`
--

INSERT INTO `customers` (`id`, `nama`, `email`, `alamat`, `telepon`, `created_at`) VALUES
(1, 'afa', NULL, NULL, NULL, '2025-07-17 07:16:55'),
(2, 'ada', NULL, NULL, NULL, '2025-07-18 03:33:33');

-- --------------------------------------------------------

--
-- Table structure for table `gudang`
--

CREATE TABLE `gudang` (
  `id` int(11) NOT NULL,
  `nama` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `gudang`
--

INSERT INTO `gudang` (`id`, `nama`) VALUES
(1, 'area'),
(2, 'produksi');

-- --------------------------------------------------------

--
-- Table structure for table `items`
--

CREATE TABLE `items` (
  `id` int(11) NOT NULL,
  `barcode` varchar(100) NOT NULL,
  `nama` varchar(100) NOT NULL,
  `harga` decimal(10,2) NOT NULL,
  `stok` int(11) DEFAULT 0,
  `id_unit` int(11) DEFAULT NULL,
  `id_category` int(11) DEFAULT NULL,
  `id_gudang` int(11) DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `items`
--

INSERT INTO `items` (`id`, `barcode`, `nama`, `harga`, `stok`, `id_unit`, `id_category`, `id_gudang`, `is_active`) VALUES
(1, 'aaaaa', 'bagelan', 10000.00, 45, 2, NULL, 1, 0),
(2, 'fffff', 'lemper', 5000.00, 35, 1, NULL, 2, 0),
(3, 'bbbbb', 'onde-onde', 2000.00, 39, 1, NULL, 1, 0),
(4, 'PB07010001', 'Choco Pan', 13000.00, 100, 1, 3, 1, 1),
(5, 'PB07010002', 'Banana Splite', 15000.00, 100, 1, 3, 1, 1),
(6, 'PB07010003', 'Cranberry', 13000.00, 100, 1, 3, 1, 1),
(7, 'PB07010004', 'Beef & Cheese', 17000.00, 100, 1, 3, 1, 1),
(8, 'PB07010005', 'Longjhon Coklat Meses', 14000.00, 100, 1, 3, 1, 1),
(9, 'PB07010006', 'Longjhon Strawberry', 14000.00, 100, 1, 3, 1, 1),
(10, 'PB07010007', 'Longjhon Cheese', 14000.00, 100, 1, 3, 1, 1),
(11, 'PB07010008', 'Japanese Milk Bun', 20000.00, 100, 1, 3, 1, 1),
(12, 'PB07010009', 'Yokohama', 16000.00, 100, 1, 3, 1, 1),
(13, 'PB07010010', 'Hokaido', 22000.00, 100, 1, 3, 1, 1),
(14, 'PB07010011', 'Hokaido Cheese', 14000.00, 100, 1, 3, 1, 1),
(15, 'PB07020001', 'Korean Garlic Cheese', 12000.00, 100, 1, 4, 1, 1),
(16, 'PB07020002', 'Sosis Moza', 15000.00, 100, 1, 4, 1, 1),
(17, 'PB07020003', 'Abon Roll Pedas', 20000.00, 100, 1, 4, 1, 1),
(18, 'PB07020004', 'Abon Nori', 20000.00, 100, 1, 4, 1, 1),
(19, 'PB07020005', 'Abon Manis', 18000.00, 100, 1, 4, 1, 1),
(20, 'PB07020006', 'Sausage Bread', 14000.00, 100, 1, 4, 1, 1);

-- --------------------------------------------------------

--
-- Table structure for table `productout`
--

CREATE TABLE `productout` (
  `id` int(11) NOT NULL,
  `kode` varchar(100) DEFAULT NULL,
  `item_id` int(11) NOT NULL,
  `barcode` varchar(100) NOT NULL,
  `gudang_id` int(11) DEFAULT NULL,
  `qty` int(11) DEFAULT NULL,
  `tanggal_keluar` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `keterangan` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `productout`
--

INSERT INTO `productout` (`id`, `kode`, `item_id`, `barcode`, `gudang_id`, `qty`, `tanggal_keluar`, `keterangan`) VALUES
(1, NULL, 1, 'aaaaa', 1, 10, '2025-07-16 00:00:00', 'Basi'),
(2, 'OUT20250718-001', 1, 'aaaaa', 1, 2, '2025-07-18 00:00:00', '');

-- --------------------------------------------------------

--
-- Table structure for table `product_in`
--

CREATE TABLE `product_in` (
  `id` int(11) NOT NULL,
  `kode` varchar(30) DEFAULT NULL,
  `item_id` int(11) DEFAULT NULL,
  `barcode` varchar(50) DEFAULT NULL,
  `supplier_id` int(11) DEFAULT NULL,
  `qty` int(11) NOT NULL,
  `tanggal_masuk` datetime DEFAULT current_timestamp(),
  `id_gudang` int(11) DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `product_in`
--

INSERT INTO `product_in` (`id`, `kode`, `item_id`, `barcode`, `supplier_id`, `qty`, `tanggal_masuk`, `id_gudang`, `created_by`) VALUES
(1, NULL, 1, '', 1, 10, '2025-07-12 00:00:00', NULL, NULL),
(2, 'INV-140725-001', 3, '', 1, 10, '2025-07-14 00:00:00', 1, NULL),
(3, 'INV-150725-001', 1, '', 1, 10, '2025-07-15 00:00:00', 1, NULL),
(4, 'INV-150725-002', 3, '', 1, 10, '2025-07-15 00:00:00', 1, 1);

-- --------------------------------------------------------

--
-- Table structure for table `product_out`
--
-- Error reading structure for table pos.product_out: #1932 - Table &#039;pos.product_out&#039; doesn&#039;t exist in engine
-- Error reading data for table pos.product_out: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near &#039;FROM `pos`.`product_out`&#039; at line 1

-- --------------------------------------------------------

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

CREATE TABLE `sales` (
  `id` int(11) NOT NULL,
  `kode` varchar(100) DEFAULT NULL,
  `tanggal` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `customer_id` int(11) DEFAULT NULL,
  `total` decimal(12,2) NOT NULL,
  `payment_method` varchar(50) DEFAULT NULL,
  `user_id` int(11) NOT NULL,
  `pajak_persen` float DEFAULT 0,
  `pajak_nominal` int(11) DEFAULT 0,
  `total_bayar` int(11) DEFAULT 0,
  `dibayar` int(11) DEFAULT 0,
  `kembalian` int(11) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `sales` (`id`, `kode`, `tanggal`, `customer_id`, `total`, `payment_method`, `user_id`, `pajak_persen`, `pajak_nominal`, `total_bayar`, `dibayar`, `kembalian`) VALUES
(4, 'TRX20250712040030', '2025-07-12 00:00:00', NULL, 5000.00, 'cash', 1, 0, 0, 0, 0, 0),
(5, 'TRX20250716065737', '2025-07-16 00:00:00', NULL, 5000.00, 'cash', 1, 0, 0, 0, 0, 0),
(6, 'TRX20250716075016', '2025-07-16 00:00:00', NULL, 10000.00, 'cash', 1, 10, 1000, 11000, 11000, 0),
(7, 'TRX20250717021410', '2025-07-17 00:00:00', NULL, 10000.00, 'cash', 1, 0, 0, 10000, 10000, 0),
(8, 'TRX20250717021539', '2025-07-17 00:00:00', NULL, 5000.00, 'cash', 1, 0, 0, 5000, 5000, 0),
(9, 'TRX20250717062659', '2025-07-17 00:00:00', NULL, 2000.00, 'transfer', 1, 0, 0, 2000, 2000, 0),
(10, 'TRX20250717063529', '2025-07-17 00:00:00', NULL, 10000.00, 'cash', 1, 0, 0, 10000, 10000, 0),
(11, 'TRX20250717071655', '2025-07-17 00:00:00', 1, 5000.00, 'cash', 1, 0, 0, 5000, 5000, 0),
(13, 'TRX20250718013643', '2025-07-18 00:00:00', NULL, 5000.00, 'cash', 2, 0, 0, 5000, 10000, 5000),
(14, 'TRX20250718033333', '2025-07-18 00:00:00', 2, 5000.00, 'cash', 1, 11, 550, 5550, 5550, 0);

-- --------------------------------------------------------

--
-- Table structure for table `sale_detail`
--

CREATE TABLE `sale_detail` (
  `id` int(11) NOT NULL,
  `sale_id` int(11) DEFAULT NULL,
  `item_id` int(11) DEFAULT NULL,
  `harga` decimal(10,2) NOT NULL,
  `qty` int(11) NOT NULL,
  `subtotal` decimal(12,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `sale_detail`
--

INSERT INTO `sale_detail` (`id`, `sale_id`, `item_id`, `harga`, `qty`, `subtotal`) VALUES
(4, 4, 2, 5000.00, 1, 5000.00),
(5, 5, 2, 5000.00, 1, 5000.00),
(6, 6, 1, 10000.00, 1, 10000.00),
(7, 7, 1, 10000.00, 1, 10000.00),
(8, 8, 2, 5000.00, 1, 5000.00),
(9, 9, 3, 2000.00, 1, 2000.00),
(10, 10, 1, 10000.00, 1, 10000.00),
(11, 11, 2, 5000.00, 1, 5000.00),
(12, 13, 2, 5000.00, 1, 5000.00),
(13, 14, 2, 5000.00, 1, 5000.00);

-- --------------------------------------------------------

--
-- Table structure for table `suppliers`
--

CREATE TABLE `suppliers` (
  `id` int(11) NOT NULL,
  `nama` varchar(100) NOT NULL,
  `email` varchar(50) DEFAULT NULL,
  `kontak_person` varchar(50) DEFAULT NULL,
  `alamat` text DEFAULT NULL,
  `telepon` varchar(20) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `suppliers`
--

INSERT INTO `suppliers` (`id`, `nama`, `email`, `kontak_person`, `alamat`, `telepon`, `created_at`) VALUES
(1, 'tatang', 'tatang@supratman.com', 'budiman', 'bukit tinggi', '081', '2025-07-12 01:21:12');

-- --------------------------------------------------------

--
-- Table structure for table `taxes`
--

CREATE TABLE `taxes` (
  `id` int(11) NOT NULL,
  `nama` varchar(100) NOT NULL,
  `persen` decimal(5,2) NOT NULL,
  `aktif` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `taxes`
--

INSERT INTO `taxes` (`id`, `nama`, `persen`, `aktif`) VALUES
(1, 'PPN', 11.00, 1);

-- --------------------------------------------------------

--
-- Table structure for table `units`
--

CREATE TABLE `units` (
  `id` int(11) NOT NULL,
  `nama` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `units`
--

INSERT INTO `units` (`id`, `nama`) VALUES
(1, 'pcs'),
(2, 'pack');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `categories`
--
ALTER TABLE `categories`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `customers`
--
ALTER TABLE `customers`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `gudang`
--
ALTER TABLE `gudang`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `items`
--
ALTER TABLE `items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_unit` (`id_unit`),
  ADD KEY `id_category` (`id_category`),
  ADD KEY `id_gudang` (`id_gudang`);

--
-- Indexes for table `productout`
--
ALTER TABLE `productout`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `kode` (`kode`);

--
-- Indexes for table `product_in`
--
ALTER TABLE `product_in`
  ADD PRIMARY KEY (`id`),
  ADD KEY `item_id` (`item_id`),
  ADD KEY `supplier_id` (`supplier_id`),
  ADD KEY `id_gudang` (`id_gudang`);

--
-- Indexes for table `sales`
--
ALTER TABLE `sales`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `kode` (`kode`),
  ADD KEY `customer_id` (`customer_id`);

--
-- Indexes for table `sale_detail`
--
ALTER TABLE `sale_detail`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sale_id` (`sale_id`),
  ADD KEY `item_id` (`item_id`);

--
-- Indexes for table `suppliers`
--
ALTER TABLE `suppliers`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `taxes`
--
ALTER TABLE `taxes`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `units`
--
ALTER TABLE `units`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `categories`
--
ALTER TABLE `categories`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `customers`
--
ALTER TABLE `customers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `gudang`
--
ALTER TABLE `gudang`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `items`
--
ALTER TABLE `items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;

--
-- AUTO_INCREMENT for table `productout`
--
ALTER TABLE `productout`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `product_in`
--
ALTER TABLE `product_in`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `sales`
--
ALTER TABLE `sales`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;

--
-- AUTO_INCREMENT for table `sale_detail`
--
ALTER TABLE `sale_detail`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;

--
-- AUTO_INCREMENT for table `suppliers`
--
ALTER TABLE `suppliers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `taxes`
--
ALTER TABLE `taxes`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `units`
--
ALTER TABLE `units`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `items`
--
ALTER TABLE `items`
  ADD CONSTRAINT `items_ibfk_1` FOREIGN KEY (`id_unit`) REFERENCES `units` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `items_ibfk_2` FOREIGN KEY (`id_category`) REFERENCES `categories` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `items_ibfk_3` FOREIGN KEY (`id_gudang`) REFERENCES `gudang` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `product_in`
--
ALTER TABLE `product_in`
  ADD CONSTRAINT `product_in_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `items` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `product_in_ibfk_2` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `product_in_ibfk_3` FOREIGN KEY (`id_gudang`) REFERENCES `gudang` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `sales`
--
ALTER TABLE `sales`
  ADD CONSTRAINT `sales_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `sale_detail`
--
ALTER TABLE `sale_detail`
  ADD CONSTRAINT `sale_detail_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `sales` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `sale_detail_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `items` (`id`) ON DELETE CASCADE;
COMMIT;

