('VULK.B.2','VULKANISIR B 2MM','21732.63','2025-04-24 15:01:46','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21826.90','2025-04-24 15:02:06','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21816.94','2025-04-24 15:02:32','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21840.50','2025-04-24 15:02:54','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21740.89','2025-04-24 15:03:17','Update','tm_barang',NULL),('VULK.HD2MM','VULKANISIR HD 2MM','21435.36','2025-04-24 15:03:40','Update','tm_barang',NULL),('TR.4MM','TR. 4MM','10416.52','2025-04-24 15:04:08','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21785.26','2025-04-24 15:04:31','Update','tm_barang',NULL),('VULK.HD.11','VULKANISIR HD 11X160','20646.00','2025-04-24 15:15:29','Update','tm_barang',NULL),('VULK.HD150','VULKANISIR HD 12X150','20702.95','2025-04-24 15:15:56','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20630.03','2025-04-24 15:16:21','Update','tm_barang',NULL),('VULK.B.150','VULKANISIR B 12X150','19606.26','2025-04-24 15:16:49','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19637.66','2025-04-24 15:17:16','Update','tm_barang',NULL),('VULK.MP.150','VULKANISIR MP 12X150','15141.35','2025-04-24 15:17:37','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15242.70','2025-04-24 15:18:02','Update','tm_barang',NULL),('VULK.HD1.5','VULKANISIR HD 15 X 150','19956.70','2025-04-24 15:18:25','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15011.20','2025-04-24 15:18:51','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15192.23','2025-04-24 15:19:37','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20656.79','2025-04-24 15:20:03','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19657.74','2025-04-24 15:20:29','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15058.54','2025-04-24 15:20:53','Update','tm_barang',NULL),('VULK.B.120','VULKANISIR B 10X120','19353.27','2025-04-24 15:21:17','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19645.18','2025-04-24 15:21:43','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21778.50','2025-04-24 15:22:14','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21869.24','2025-04-24 15:22:37','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21829.10','2025-04-24 15:22:58','Update','tm_barang',NULL),('VULK.B.4','VULKANISIR B 4MM','21161.12','2025-04-24 15:23:23','Update','tm_barang',NULL),('VULK.MP.4','VULKANISIR MP 4MM','12452.35','2025-04-24 15:23:46','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21870.87','2025-04-24 15:24:10','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21840.52','2025-04-25 07:20:38','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15573.39','2025-04-25 07:25:30','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19644.26','2025-04-25 07:25:57','Update','tm_barang',NULL),('VULK.C.16','VULKANISIR C 12X160','17737.71','2025-04-25 07:26:21','Update','tm_barang',NULL),('VULK.A.12X150','VULKANISIR A 12 X 150','23041.98','2025-04-25 07:26:45','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15207.90','2025-04-25 07:27:08','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15572.45','2025-04-25 07:27:39','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15267.30','2025-04-25 07:28:16','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15089.75','2025-04-25 07:28:41','Update','tm_barang',NULL),('VULK.HD.20','VULKANISIR HD 15X200','20783.59','2025-04-25 07:29:05','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20630.31','2025-04-25 07:29:31','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15349.47','2025-04-25 07:29:53','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15761.44','2025-04-25 07:30:17','Update','tm_barang',NULL),('VULK.B.200','VULKANISIR B 15X200','19229.64','2025-04-25 07:30:43','Update','tm_barang',NULL),('VULK.HD.20','VULKANISIR HD 15X200','20123.77','2025-04-25 07:31:45','Update','tm_barang',NULL),('VULK.B.120','VULKANISIR B 10X120','19249.53','2025-04-25 07:32:16','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19632.54','2025-04-25 07:32:41','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15654.50','2025-04-25 07:33:34','Update','tm_barang',NULL),('VULK.MP.19','VULKANISIR MP 15X190','15104.81','2025-04-25 07:35:08','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15251.63','2025-04-25 07:35:32','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15073.45','2025-04-25 07:36:11','Update','tm_barang',NULL),('VULK.CS.200','VULKANISIR CHASA 15X200','16598.00','2025-04-25 07:36:57','Update','tm_barang',NULL),('VULK.B.120','VULKANISIR B 10X120','19091.31','2025-04-25 07:38:19','Update','tm_barang',NULL),('VULK.A.12','VULKANISIR A 12X160','23170.12','2025-04-25 07:38:51','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20608.96','2025-04-25 07:39:18','Update','tm_barang',NULL),('VULK.B.130','VULKANISIR B 10X130','19341.66','2025-04-25 07:39:45','Update','tm_barang',NULL),('VULK.B.150','VULKANISIR B 12X150','19623.56','2025-04-25 07:40:14','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19636.76','2025-04-25 07:40:37','Update','tm_barang',NULL),('VULK.MP.19','VULKANISIR MP 15X190','15087.91','2025-04-25 07:41:01','Update','tm_barang',NULL),('VULK.C.130','VULKANISIR C 10X130','17416.57','2025-04-25 07:41:25','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21755.14','2025-04-25 07:41:59','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21770.70','2025-04-25 07:42:23','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21752.07','2025-04-25 07:42:50','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21774.08','2025-04-25 07:43:24','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21822.10','2025-04-25 07:43:48','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15602.79','2025-04-25 07:44:59','Update','tm_barang',NULL),('VULK.HD.20','VULKANISIR HD 15X200','20032.46','2025-04-25 07:45:26','Update','tm_barang',NULL),('VULK.B.200','VULKANISIR B 15X200','19129.53','2025-04-25 07:46:06','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15061.83','2025-04-25 07:46:33','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15246.04','2025-04-25 07:46:59','Update','tm_barang',NULL),('VULK.MP.2MM','VULKANISIR MP 2MM','13123.20','2025-04-25 07:47:44','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19647.65','2025-04-25 07:56:45','Update','tm_barang',NULL),('VULK.BR.160','VULKANISIR BR 12X160','28528.81','2025-04-25 08:00:24','Update','tm_barang',NULL),('VULK.C.16','VULKANISIR C 12X160','17753.75','2025-04-25 08:02:00','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15601.41','2025-04-25 08:03:14','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20683.34','2025-04-25 08:04:10','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19624.04','2025-04-25 08:04:55','Update','tm_barang',NULL),('VULK.MP.19','VULKANISIR MP 15X190','15096.51','2025-04-25 08:06:00','Update','tm_barang',NULL),('VULK.CS.12','VULKANISIR CHASA 12X160','17110.98','2025-04-25 08:06:23','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15154.83','2025-04-25 08:06:51','Update','tm_barang',NULL),('VULK.B.100','VULKANISIR B 10X100','19901.22','2025-04-25 08:07:15','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20621.95','2025-04-25 08:07:41','Update','tm_barang',NULL),('VULK.B.9X12','VULKANISIR B 9X120','19319.84','2025-04-25 08:08:08','Update','tm_barang',NULL),('VULK.B.200','VULKANISIR B 15X200','19172.01','2025-04-25 08:09:28','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19657.83','2025-04-25 08:10:08','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20639.08','2025-04-25 08:11:19','Update','tm_barang',NULL),('VULK.B.4','VULKANISIR B 4MM','21081.44','2025-04-25 08:12:10','Update','tm_barang',NULL),('VUL.B.5','VULKANISIR B 5MM','21056.93','2025-04-25 08:12:34','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21742.68','2025-04-25 08:13:00','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15484.29','2025-04-25 08:15:29','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19441.46','2025-04-25 08:15:54','Update','tm_barang',NULL),('VULK.C.20','VULKANISIR C 15X200','17369.52','2025-04-25 08:16:23','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19429.69','2025-04-25 08:16:48','Update','tm_barang',NULL),('VULK.CS.12','VULKANISIR CHASA 12X160','17222.90','2025-04-25 08:17:13','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15385.94','2025-04-25 08:17:37','Update','tm_barang',NULL),('TR.4MM','TR. 4MM','10346.02','2025-04-25 08:18:19','Update','tm_barang',NULL),('VULK.C.2MM','VULKANISIR C 2MM','16904.97','2025-04-25 08:18:42','Update','tm_barang',NULL),('VULK.HD3,5','VULKANISIR HD 3,5 MM','20812.37','2025-04-25 08:19:07','Update','tm_barang',NULL),('VULK.C.2MM','VULKANISIR C 2MM','16887.59','2025-04-25 08:19:33','Update','tm_barang',NULL),('VULK.HD3,5','VULKANISIR HD 3,5 MM','20792.44','2025-04-25 08:20:20','Update','tm_barang',NULL),('VULK.HD2MM','VULKANISIR HD 2MM','21469.81','2025-04-25 08:20:41','Update','tm_barang',NULL),('VULK.B.4','VULKANISIR B 4MM','20987.50','2025-04-25 08:21:04','Update','tm_barang',NULL),('VULK.HQ.190','VULKANISIR HQ 15X190','24324.24','2025-04-25 08:32:46','Update','tm_barang',NULL),('VULK.HD.20','VULKANISIR HD 15X200','19960.57','2025-04-25 08:33:15','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19428.35','2025-04-25 08:33:50','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20591.61','2025-04-25 08:34:14','Update','tm_barang',NULL),('VULK.C.20','VULKANISIR C 15X200','17321.70','2025-04-25 08:34:45','Update','tm_barang',NULL),('VULK.C.16','VULKANISIR C 12X160','17689.57','2025-04-25 08:35:15','Update','tm_barang',NULL),('VULK.B.200','VULKANISIR B 15X200','18935.74','2025-04-25 08:35:43','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19419.35','2025-04-25 08:36:08','Update','tm_barang',NULL),('VULK.HD.20','VULKANISIR HD 15X200','20312.97','2025-04-25 08:36:39','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20635.70','2025-04-25 08:37:08','Update','tm_barang',NULL),('VULK.TR.200','VULKANISIT TRAKTOR 15X200','12241.51','2025-04-25 08:37:49','Update','tm_barang',NULL),('VULK.TR.10','VULKANISIR TRAKTOR 10X120','12341.82','2025-04-25 08:38:12','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20552.45','2025-04-25 08:38:38','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20644.91','2025-04-25 08:39:00','Update','tm_barang',NULL),('VULK.CS.10','VULKANISIR CHASA 10X120','16943.88','2025-04-25 08:39:26','Update','tm_barang',NULL),('VULK.CS.200','VULKANISIR CHASA 15X200','16776.05','2025-04-25 08:39:54','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15341.82','2025-04-25 08:40:43','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19324.64','2025-04-25 08:41:10','Update','tm_barang',NULL),('VULK.C.20','VULKANISIR C 15X200','17141.10','2025-04-25 08:41:39','Update','tm_barang',NULL),('VULK.TR.10','VULKANISIR TRAKTOR 10X120','12421.00','2025-04-25 08:43:12','Update','tm_barang',NULL),('VULK.MP.19','VULKANISIR MP 15X190','15215.97','2025-04-25 08:43:44','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15235.41','2025-04-25 08:44:09','Update','tm_barang',NULL),('VULK.CS.150','VULKANISIR CHASA 12X150','17192.95','2025-04-25 08:44:42','Update','tm_barang',NULL),('VULK.MP.4','VULKANISIR MP 4MM','12525.10','2025-04-25 08:45:11','Update','tm_barang',NULL),('VULK.B.3','VULKANISIR B 3MM','21027.52','2025-04-25 08:45:36','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21791.23','2025-04-25 08:45:58','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15195.43','2025-04-25 08:52:01','Update','tm_barang',NULL),('VULK.HD.20','VULKANISIR HD 15X200','20261.12','2025-04-25 08:52:25','Update','tm_barang',NULL),('VULK.B.200','VULKANISIR B 15X200','19009.65','2025-04-25 08:52:49','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19315.74','2025-04-25 08:53:20','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15764.64','2025-04-25 08:53:46','Update','tm_barang',NULL),('VULK.HD150','VULKANISIR HD 12X150','20682.19','2025-04-25 08:54:27','Update','tm_barang',NULL),('VULK.MP.19','VULKANISIR MP 15X190','15198.65','2025-04-25 08:54:49','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19420.15','2025-04-25 08:55:13','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15429.88','2025-04-25 08:55:36','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15364.35','2025-04-25 08:56:01','Update','tm_barang',NULL),('VULK.CS.150','VULKANISIR CHASA 12X150','17228.24','2025-04-25 08:56:27','Update','tm_barang',NULL),('VULK.CS.200','VULKANISIR CHASA 15X200','16751.89','2025-04-25 08:56:50','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19435.59','2025-04-25 08:57:13','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15474.63','2025-04-25 08:57:36','Update','tm_barang',NULL),('VUL.B.5','VULKANISIR B 5MM','21074.35','2025-04-25 08:58:11','Update','tm_barang',NULL),('VULK.C.2MM','VULKANISIR C 2MM','16992.29','2025-04-25 08:58:41','Update','tm_barang',NULL),('VULK.CS.4MM','VULKANISIR CHASA 4MM','14477.87','2025-04-25 08:59:10','Update','tm_barang',NULL),('TR.4MM','TR. 4MM','10344.87','2025-04-25 08:59:34','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15263.40','2025-04-25 09:01:10','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15051.05','2025-04-25 09:01:36','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19618.51','2025-04-25 09:01:59','Update','tm_barang',NULL),('VULK.MP.19','VULKANISIR MP 15X190','15099.83','2025-04-25 09:02:25','Update','tm_barang',NULL),('VULK.MP.150','VULKANISIR MP 12X150','15140.48','2025-04-25 09:02:49','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15268.43','2025-04-25 09:03:10','Update','tm_barang',NULL),('VULK.HD150','VULKANISIR HD 12X150','20628.55','2025-04-25 09:03:34','Update','tm_barang',NULL),('VULK.HD.20','VULKANISIR HD 15X200','20107.92','2025-04-25 09:03:58','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20619.84','2025-04-25 09:04:23','Update','tm_barang',NULL),('VULK.C.16','VULKANISIR C 12X160','17737.35','2025-04-25 09:04:52','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19632.54','2025-04-25 09:05:15','Update','tm_barang',NULL),('VULK.MP.2MM','VULKANISIR MP 2MM','13183.43','2025-04-25 09:05:42','Update','tm_barang',NULL),('VULK.HD2MM','VULKANISIR HD 2MM','21482.82','2025-04-25 09:06:05','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21850.78','2025-04-25 09:06:33','Update','tm_barang',NULL),('VULK.C.10','VULKANISIR C 10X120','17229.21','2025-04-25 09:07:35','Update','tm_barang',NULL),('VULK.B11','VULKANISIR B 10X110','19379.20','2025-04-25 09:08:51','Update','tm_barang',NULL),('VULK.B.130','VULKANISIR B 10X130','19319.64','2025-04-25 09:09:15','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15575.22','2025-04-25 09:09:38','Update','tm_barang',NULL),('VULK.B.200','VULKANISIR B 15X200','19103.60','2025-04-25 09:10:00','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15140.36','2025-04-25 09:10:23','Update','tm_barang',NULL),('VULK.B.120','VULKANISIR B 10X120','19327.21','2025-04-25 09:10:48','Update','tm_barang',NULL),('VULK.B.130','VULKANISIR B 10X130','19415.77','2025-04-25 09:11:11','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15594.29','2025-04-25 09:11:37','Update','tm_barang',NULL),('VULK.HQ.160','VULKANISIR HQ 12X160','24679.85','2025-04-25 09:12:02','Update','tm_barang',NULL),('VULK.A.12','VULKANISIR A 12X160','23110.71','2025-04-25 09:12:27','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20648.31','2025-04-25 09:12:57','Update','tm_barang',NULL),('VULK.B.120','VULKANISIR B 10X120','19329.62','2025-04-25 09:13:21','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21840.10','2025-04-25 09:13:55','Update','tm_barang',NULL),('VULK.B.3','VULKANISIR B 3MM','21217.99','2025-04-25 09:14:18','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','22133.86','2025-04-25 09:14:40','Update','tm_barang',NULL),('SOL00059','BJ-17 (28-32)','25358.51','2025-04-25 09:14:48','Update','tm_barang',NULL),('SOL00094','BJ-020 (39-43) ','54730.42','2025-04-25 09:15:02','Update','tm_barang',NULL),('SOL00051','BJ-ADRENALIN (33-37)','29940.84','2025-04-25 09:15:17','Update','tm_barang',NULL),('SOL00052','BJ-ADRENALIN (38-42)','35422.70','2025-04-25 09:15:34','Update','tm_barang',NULL),('SOL00042','BJ-12 (39-43) ML','37458.49','2025-04-25 09:15:53','Update','tm_barang',NULL),('SOL00046','BJ-15 (39-43)','35959.14','2025-04-25 09:16:17','Update','tm_barang',NULL),('SOL00057','BJ-18 (39-43) XENDER','36237.01','2025-04-25 09:16:31','Update','tm_barang',NULL),('SOL00033','BJ-09 (39-43)','36237.01','2025-04-25 09:16:44','Update','tm_barang',NULL),('SOL00046','BJ-15 (39-43)','36032.75','2025-04-25 09:16:59','Update','tm_barang',NULL),('VULK.MP.2MM','VULKANISIR MP 2MM','13148.76','2025-04-25 09:17:38','Update','tm_barang',NULL),('SOL00059','BJ-17 (28-32)','25309.33','2025-04-25 09:17:55','Update','tm_barang',NULL),('VULK.C.2MM','VULKANISIR C 2MM','16977.44','2025-04-25 09:17:59','Update','tm_barang',NULL),('SOL00094','BJ-020 (39-43) ','54858.00','2025-04-25 09:18:08','Update','tm_barang',NULL),('SOL00057','BJ-18 (39-43) XENDER','36237.01','2025-04-25 09:18:26','Update','tm_barang',NULL),('SOL00057','BJ-18 (39-43) XENDER','36237.01','2025-04-25 09:18:50','Update','tm_barang',NULL),('SOL00051','BJ-ADRENALIN (33-37)','29999.84','2025-04-25 09:19:04','Update','tm_barang',NULL),('SOL00052','BJ-ADRENALIN (38-42)','35422.70','2025-04-25 09:19:17','Update','tm_barang',NULL),('SOL00070','BJ-18 (33-37) XENDER ','32528.47','2025-04-25 09:19:45','Update','tm_barang',NULL),('SOL00094','BJ-020 (39-43) ','54937.73','2025-04-25 09:19:58','Update','tm_barang',NULL),('SOL00033','BJ-09 (39-43)','36237.01','2025-04-25 09:20:11','Update','tm_barang',NULL),('SOL00087','KIMJON (33-37) ','37234.00','2025-04-25 09:20:30','Update','tm_barang',NULL),('SOL00046','BJ-15 (39-43)','36266.01','2025-04-25 09:20:49','Update','tm_barang',NULL),('SOL00056','BJ-18 (28-32) XENDER','25367.51','2025-04-25 09:21:28','Update','tm_barang',NULL),('SOL00094','BJ-020 (39-43) ','54743.90','2025-04-25 09:21:40','Update','tm_barang',NULL),('SOL00057','BJ-18 (39-43) XENDER','36052.13','2025-04-25 09:21:53','Update','tm_barang',NULL),('SOL00033','BJ-09 (39-43)','36237.01','2025-04-25 09:22:08','Update','tm_barang',NULL),('SOL00052','BJ-ADRENALIN (38-42)','35422.70','2025-04-25 09:22:39','Update','tm_barang',NULL),('SOL00070','BJ-18 (33-37) XENDER ','32716.23','2025-04-25 09:23:01','Update','tm_barang',NULL),('SOL00094','BJ-020 (39-43) ','55070.62','2025-04-25 09:23:16','Update','tm_barang',NULL),('SOL00051','BJ-ADRENALIN (33-37)','30001.84','2025-04-25 09:23:39','Update','tm_barang',NULL),('SOL00055','BJ-ADRENALIN (36-40)','28501.02','2025-04-25 09:23:52','Update','tm_barang',NULL),('SOL00031','BJ-08 (39-43)','37324.87','2025-04-25 09:26:12','Update','tm_barang',NULL),('SOL00094','BJ-020 (39-43) ','55096.48','2025-04-25 09:26:26','Update','tm_barang',NULL),('SOL00057','BJ-18 (39-43) XENDER','36237.01','2025-04-25 09:26:43','Update','tm_barang',NULL),('SOL00033','BJ-09 (39-43)','36237.01','2025-04-25 09:26:57','Update','tm_barang',NULL),('SOL00055','BJ-ADRENALIN (36-40)','28062.55','2025-04-25 09:27:12','Update','tm_barang',NULL),('SOL00050','BJ-ADRENALIN (28-32)','27997.79','2025-04-25 09:27:32','Update','tm_barang',NULL),('SOL00052','BJ-ADRENALIN (38-42)','35097.72','2025-04-25 09:27:50','Update','tm_barang',NULL),('SOL00094','BJ-020 (39-43) ','54915.92','2025-04-25 09:28:13','Update','tm_barang',NULL),('SOL00046','BJ-15 (39-43)','36258.94','2025-04-25 09:28:31','Update','tm_barang',NULL),('SOL00057','BJ-18 (39-43) XENDER','36379.68','2025-04-25 09:28:53','Update','tm_barang',NULL),('SOL00070','BJ-18 (33-37) XENDER ','32746.92','2025-04-25 09:34:49','Update','tm_barang',NULL),('VULK.CS.4MM','VULKANISIR CHASA 4MM','14298.36','2025-04-25 13:53:15','Update','tm_barang',NULL),('VULK.MP.4','VULKANISIR MP 4MM','12510.72','2025-04-25 13:53:37','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21807.27','2025-04-25 13:53:58','Update','tm_barang',NULL),('VULK.CS.190','VULKANISIR CHASA 15X190','16639.94','2025-04-25 14:00:04','Update','tm_barang',NULL),('VULK.C.20','VULKANISIR C 15X200','17248.10','2025-04-25 14:00:29','Update','tm_barang',NULL),('VULK.C.10X100','VULKANISIR C 10 X 100','17572.41','2025-04-25 14:00:53','Update','tm_barang',NULL),('VULK.CS.200','VULKANISIR CHASA 15X200','16614.48','2025-04-25 14:01:19','Update','tm_barang',NULL),('VULK.C.20','VULKANISIR C 15X200','17313.40','2025-04-25 14:02:03','Update','tm_barang',NULL),('VULK.B.130','VULKANISIR B 10X130','19513.83','2025-04-25 14:03:47','Update','tm_barang',NULL),('VULK.C.16','VULKANISIR C 12X160','17806.34','2025-04-25 14:04:30','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19630.73','2025-04-25 14:05:00','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15053.73','2025-04-25 14:06:15','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15580.69','2025-04-25 14:06:40','Update','tm_barang',NULL),('VULK.C.2MM','VULKANISIR C 2MM','16979.62','2025-04-25 14:07:32','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21811.39','2025-04-25 14:07:55','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21816.51','2025-04-25 14:08:18','Update','tm_barang',NULL),('TR.4MM','TR. 4MM','10401.82','2025-04-25 14:08:42','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15329.11','2025-04-25 14:19:57','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20629.83','2025-04-26 09:28:23','Update','tm_barang',NULL),('VULK.C.20','VULKANISIR C 15X200','17501.14','2025-04-26 09:29:00','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15297.56','2025-04-26 09:29:22','Update','tm_barang',NULL),('VULK.CS.12','VULKANISIR CHASA 12X160','16976.35','2025-04-26 09:29:52','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19421.80','2025-04-26 09:30:21','Update','tm_barang',NULL),('VULK.C.20','VULKANISIR C 15X200','17278.58','2025-04-26 09:30:53','Update','tm_barang',NULL),('VULK.C.10','VULKANISIR C 10X120','17463.06','2025-04-26 09:31:15','Update','tm_barang',NULL),('VULK.C.130','VULKANISIR C 10X130','17407.86','2025-04-26 09:31:39','Update','tm_barang',NULL),('VULK.C.16','VULKANISIR C 12X160','17726.98','2025-04-26 09:32:01','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20561.14','2025-04-26 09:32:25','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19410.05','2025-04-26 09:32:48','Update','tm_barang',NULL),('VULK.C.20','VULKANISIR C 15X200','17444.65','2025-04-26 09:33:11','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21811.54','2025-04-26 09:33:42','Update','tm_barang',NULL),('VULK.C.2MM','VULKANISIR C 2MM','16989.04','2025-04-26 09:34:03','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21864.49','2025-04-26 09:34:29','Update','tm_barang',NULL),('VULK.MP.2MM','VULKANISIR MP 2MM','13220.09','2025-04-26 09:34:57','Update','tm_barang',NULL),('VULK.C.2MM','VULKANISIR C 2MM','16997.40','2025-04-26 09:35:26','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21832.51','2025-04-26 09:35:50','Update','tm_barang',NULL),('BP.PLSTK','PLASTIK PEMBUNGKUS ','35500.00','2025-04-28 20:04:26','Update','tm_barang',NULL),('BB.TAGY','TA GOODYEAR ','13000.00','2025-04-28 20:08:47','Update','tm_barang',NULL),('BB.KMP','KOMPO ','26500.00','2025-04-28 20:09:44','Update','tm_barang',NULL),('BP.PLSTK','PLASTIK PEMBUNGKUS ','34000.00','2025-04-28 20:12:39','Update','tm_barang',NULL),('BP.PLSTK','PLASTIK PEMBUNGKUS ','35500.00','2025-04-28 20:12:39','Update','tm_barang',NULL),('BB.SSTN','SOSOTAN','19000.00','2025-04-28 20:17:34','Update','tm_barang',NULL),('BB.TAGY','TA GOODYEAR ','19000.00','2025-04-28 20:17:34','Update','tm_barang',NULL),('BB.TAGY','TA GOODYEAR ','17500.00','2025-04-28 20:18:58','Update','tm_barang',NULL),('BB.SSTN','SOSOTAN','19500.00','2025-04-28 20:18:58','Update','tm_barang',NULL),('BB.SSTN','SOSOTAN','19800.00','2025-04-28 20:23:34','Update','tm_barang',NULL),('BB.SSTN.KL','SOSOTAN KAWAT P.KILMI','18000.00','2025-04-28 20:24:35','Update','tm_barang',NULL),('BB.SSTN','SOSOTAN','19500.00','2025-04-28 20:28:00','Update','tm_barang',NULL),('BB.SRBK.SPN','SERBUK SPON','1500.00','2025-04-28 20:28:58','Update','tm_barang',NULL),('BB.SSTN','SOSOTAN','19800.00','2025-04-28 20:31:58','Update','tm_barang',NULL),('K.SAPI106','KARPET SAPI 14MM (122 X 240) ','243560.92','2025-04-29 15:26:10','Update','tm_barang',NULL),('K.SAPI107','KARPET SAPI 12MM (122 X 8M) ','630938.76','2025-04-29 15:26:26','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4902.71','2025-04-30 07:39:17','Update','tm_barang',NULL),('BB.STD. B','STANDART. B ','23863.44','2025-04-30 07:39:36','Update','tm_barang',NULL),('BB.STDTA','STANDART .A2','22386.60','2025-04-30 07:39:53','Update','tm_barang',NULL),('BB.STD','STANDART. A','26939.92','2025-04-30 07:40:08','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 07:40:32','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4902.71','2025-04-30 07:40:51','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4902.71','2025-04-30 07:41:12','Update','tm_barang',NULL),('BB.MLG','KARET MALANG ','3405.85','2025-04-30 07:42:09','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 07:42:24','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4902.71','2025-04-30 07:42:42','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 07:43:02','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4902.71','2025-04-30 07:43:36','Update','tm_barang',NULL),('KM.HR','KOMPON HR','7629.22','2025-04-30 07:43:54','Update','tm_barang',NULL),('KM.HR','KOMPON HR','5520.25','2025-04-30 07:44:10','Update','tm_barang',NULL),('BB.STD','STANDART. A','25381.68','2025-04-30 07:44:43','Update','tm_barang',NULL),('BB.STD. B','STANDART. B ','23863.44','2025-04-30 07:45:02','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 07:45:19','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4902.71','2025-04-30 07:45:42','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4902.71','2025-04-30 07:46:18','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5596.06','2025-04-30 07:46:38','Update','tm_barang',NULL),('BB.STDTA','STANDART .A2','22386.60','2025-04-30 07:47:11','Update','tm_barang',NULL),('BB.STD. B','STANDART. B ','23863.44','2025-04-30 07:47:27','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 07:48:00','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5595.84','2025-04-30 07:48:19','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5595.70','2025-04-30 07:48:34','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4902.71','2025-04-30 07:48:53','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3110.82','2025-04-30 07:49:13','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4902.71','2025-04-30 07:49:33','Update','tm_barang',NULL),('KM.HR','KOMPON HR','7629.22','2025-04-30 07:49:52','Update','tm_barang',NULL),('KM.HMR','KOMPON HAMMER','4313.73','2025-04-30 07:50:11','Update','tm_barang',NULL),('BB.STD','STANDART. A','26269.67','2025-04-30 07:56:03','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5137.66','2025-04-30 08:02:47','Update','tm_barang',NULL),('KM.RBSHT','KOMPON RB.SHEET','4298.32','2025-04-30 08:03:18','Update','tm_barang',NULL),('KM.RBSHT','KOMPON RB.SHEET','4309.44','2025-04-30 08:03:47','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3110.82','2025-04-30 08:04:12','Update','tm_barang',NULL),('KM.RBSHT','KOMPON RB.SHEET','4311.63','2025-04-30 08:04:50','Update','tm_barang',NULL),('BB.STD','STANDART. A','25381.68','2025-04-30 08:05:17','Update','tm_barang',NULL),('BB.STDTA','STANDART .A2','22386.60','2025-04-30 08:05:33','Update','tm_barang',NULL),('BB.STD. B','STANDART. B ','23863.44','2025-04-30 08:05:49','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5137.66','2025-04-30 08:06:34','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3110.82','2025-04-30 08:44:03','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4272.40','2025-04-30 08:44:23','Update','tm_barang',NULL),('BB.STD.BR','STANDART BR','29051.50','2025-04-30 08:44:41','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4467.05','2025-04-30 08:49:44','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 08:50:02','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5595.64','2025-04-30 08:50:18','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4467.05','2025-04-30 08:50:37','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3110.82','2025-04-30 08:50:54','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','4010.27','2025-04-30 08:51:10','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5163.71','2025-04-30 08:51:25','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5595.48','2025-04-30 08:51:42','Update','tm_barang',NULL),('BB.STD','STANDART. A','25381.68','2025-04-30 08:51:59','Update','tm_barang',NULL),('BB.STD. B','STANDART. B ','23863.44','2025-04-30 08:52:18','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 08:52:34','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5422.66','2025-04-30 08:52:53','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5595.47','2025-04-30 08:53:11','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5422.66','2025-04-30 08:53:36','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3110.82','2025-04-30 08:53:52','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5163.71','2025-04-30 08:54:10','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5017.56','2025-04-30 08:54:27','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5595.32','2025-04-30 08:54:44','Update','tm_barang',NULL),('BB.STND.BJ','STANDART BJ','29938.34','2025-04-30 08:55:01','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 08:55:41','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5595.20','2025-04-30 08:55:59','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5169.21','2025-04-30 08:56:19','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3110.82','2025-04-30 08:56:36','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3160.10','2025-04-30 08:56:52','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5168.21','2025-04-30 08:57:17','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5595.08','2025-04-30 08:57:38','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 08:58:33','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5204.58','2025-04-30 08:58:51','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 08:59:07','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.96','2025-04-30 08:59:24','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5253.11','2025-04-30 08:59:47','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3122.61','2025-04-30 09:00:05','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5231.19','2025-04-30 09:00:22','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5204.88','2025-04-30 09:00:38','Update','tm_barang',NULL),('KM.HMR','KOMPON HAMMER','4313.73','2025-04-30 09:00:54','Update','tm_barang',NULL),('KM.RBSHT','KOMPON RB.SHEET','4312.08','2025-04-30 09:01:12','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 09:01:46','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5212.92','2025-04-30 09:02:04','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 09:02:24','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5233.90','2025-04-30 09:02:42','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3117.02','2025-04-30 09:03:07','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3156.95','2025-04-30 09:03:25','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5223.06','2025-04-30 09:03:44','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5196.37','2025-04-30 09:04:00','Update','tm_barang',NULL),('KM.RBSHT','KOMPON RB.SHEET','4312.38','2025-04-30 09:04:19','Update','tm_barang',NULL),('BB.STD. B','STANDART. B ','23863.44','2025-04-30 09:04:38','Update','tm_barang',NULL),('BB.STDTA','STANDART .A2','22386.60','2025-04-30 09:04:55','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 09:05:17','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5213.18','2025-04-30 09:05:39','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.90','2025-04-30 09:05:55','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5244.13','2025-04-30 09:06:15','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3148.65','2025-04-30 09:06:36','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3375.19','2025-04-30 09:06:52','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5236.18','2025-04-30 09:07:09','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.85','2025-04-30 09:07:28','Update','tm_barang',NULL),('KM.RBSHT','KOMPON RB.SHEET','4312.58','2025-04-30 09:07:43','Update','tm_barang',NULL),('BB.STD. B','STANDART. B ','23863.44','2025-04-30 09:08:05','Update','tm_barang',NULL),('BB.STDTA','STANDART .A2','22386.60','2025-04-30 09:08:21','Update','tm_barang',NULL),('BB.STD','STANDART. A','25701.10','2025-04-30 09:08:37','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 09:09:15','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5243.97','2025-04-30 09:09:32','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.76','2025-04-30 09:09:50','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5261.20','2025-04-30 09:10:08','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3333.98','2025-04-30 09:10:28','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3409.57','2025-04-30 09:10:44','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5262.10','2025-04-30 09:11:01','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5278.47','2025-04-30 09:11:17','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.71','2025-04-30 09:11:35','Update','tm_barang',NULL),('KM.RBSHT','KOMPON RB.SHEET','4312.79','2025-04-30 09:11:51','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 09:12:20','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.63','2025-04-30 09:12:38','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5296.70','2025-04-30 09:12:56','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.58','2025-04-30 09:13:16','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5320.68','2025-04-30 09:13:37','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3355.40','2025-04-30 09:13:56','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3429.62','2025-04-30 09:14:13','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5337.41','2025-04-30 09:14:32','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.53','2025-04-30 09:14:50','Update','tm_barang',NULL),('KM.HMR','KOMPON HAMMER','4313.73','2025-04-30 09:15:06','Update','tm_barang',NULL),('BB.MLG','KARET MALANG ','3405.85','2025-04-30 09:15:30','Update','tm_barang',NULL),('BB.STD. B','STANDART. B ','23863.44','2025-04-30 09:16:01','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 09:16:24','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.50','2025-04-30 09:16:41','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5364.21','2025-04-30 09:16:58','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 09:17:16','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.45','2025-04-30 09:17:34','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5373.06','2025-04-30 09:17:55','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3390.42','2025-04-30 09:18:13','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3480.22','2025-04-30 09:18:29','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5366.63','2025-04-30 09:18:47','Update','tm_barang',NULL),('BB.STD.BR','STANDART BR','30014.17','2025-04-30 09:19:07','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 09:19:29','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.35','2025-04-30 09:19:47','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5382.26','2025-04-30 09:20:05','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 09:20:22','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.33','2025-04-30 09:20:40','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5403.73','2025-04-30 09:21:00','Update','tm_barang',NULL),('VULK.B.200','VULKANISIR B 15X200','19163.87','2025-04-30 09:32:24','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19661.39','2025-04-30 09:32:57','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20644.79','2025-04-30 09:33:27','Update','tm_barang',NULL),('VULK.A.12X150','VULKANISIR A 12 X 150','23093.76','2025-04-30 09:34:08','Update','tm_barang',NULL),('VULK.B.130','VULKANISIR B 10X130','19301.52','2025-04-30 09:34:35','Update','tm_barang',NULL),('VULK.B.120','VULKANISIR B 10X120','19266.10','2025-04-30 09:34:58','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19788.23','2025-04-30 09:35:22','Update','tm_barang',NULL),('VULK.B.200','VULKANISIR B 15X200','19140.75','2025-04-30 09:35:46','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19645.06','2025-04-30 09:36:08','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20664.16','2025-04-30 09:36:34','Update','tm_barang',NULL),('VULK.BR.160','VULKANISIR BR 12X160','28410.55','2025-04-30 09:37:14','Update','tm_barang',NULL),('VULK.B.130','VULKANISIR B 10X130','19339.10','2025-04-30 09:37:36','Update','tm_barang',NULL),('VULK.C.20','VULKANISIR C 15X200','17418.79','2025-04-30 09:41:42','Update','tm_barang',NULL),('VULK.CS.200','VULKANISIR CHASA 15X200','16562.02','2025-04-30 09:42:16','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20653.82','2025-04-30 09:42:41','Update','tm_barang',NULL),('VULK.HD3,5','VULKANISIR HD 3,5 MM','20644.06','2025-04-30 09:43:44','Update','tm_barang',NULL),('VULK.CS.2MM','VULKANISIR CHASA 2MM','15274.55','2025-04-30 09:44:10','Update','tm_barang',NULL),('VULK.MP.2MM','VULKANISIR MP 2MM','13287.24','2025-04-30 09:44:34','Update','tm_barang',NULL),('VUL.B.5','VULKANISIR B 5MM','21137.01','2025-04-30 09:44:55','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21928.48','2025-04-30 09:45:18','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21915.57','2025-04-30 09:45:38','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21850.19','2025-04-30 09:46:00','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15226.72','2025-04-30 09:46:49','Update','tm_barang',NULL),('VULK.MP.19','VULKANISIR MP 15X190','15088.56','2025-04-30 09:47:11','Update','tm_barang',NULL),('VULK.HD150','VULKANISIR HD 12X150','20502.48','2025-04-30 09:47:36','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20664.45','2025-04-30 09:48:00','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15106.73','2025-04-30 09:48:24','Update','tm_barang',NULL),('VULK.MP.150','VULKANISIR MP 12X150','15135.28','2025-04-30 09:48:49','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19724.61','2025-04-30 09:49:13','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15264.02','2025-04-30 09:49:37','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15205.01','2025-04-30 09:50:00','Update','tm_barang',NULL),('VULK.C.16','VULKANISIR C 12X160','17800.81','2025-04-30 09:50:24','Update','tm_barang',NULL),('VULK.MP.19','VULKANISIR MP 15X190','15096.61','2025-04-30 09:50:46','Update','tm_barang',NULL),('VULK.C.20','VULKANISIR C 15X200','17326.14','2025-04-30 09:51:10','Update','tm_barang',NULL),('VULK.B.200','VULKANISIR B 15X200','19230.62','2025-04-30 09:51:35','Update','tm_barang',NULL),('VULK.MP.150','VULKANISIR MP 12X150','15155.48','2025-04-30 09:52:07','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15266.08','2025-04-30 09:52:34','Update','tm_barang',NULL),('VULK.C.2MM','VULKANISIR C 2MM','16946.19','2025-04-30 09:53:11','Update','tm_barang',NULL),('VULK.CS.2MM','VULKANISIR CHASA 2MM','15183.35','2025-04-30 09:53:35','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21811.73','2025-04-30 09:54:10','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21945.72','2025-04-30 09:54:37','Update','tm_barang',NULL),('VULK.B.4','VULKANISIR B 4MM','21088.49','2025-04-30 09:55:03','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21824.04','2025-04-30 09:55:26','Update','tm_barang',NULL),('SOL00031','BJ-08 (39-43)','37318.81','2025-04-30 10:06:13','Update','tm_barang',NULL),('SOL00094','BJ-020 (39-43) ','54652.05','2025-04-30 10:06:25','Update','tm_barang',NULL),('SOL00070','BJ-18 (33-37) XENDER ','32620.80','2025-04-30 10:06:45','Update','tm_barang',NULL),('SOL00057','BJ-18 (39-43) XENDER','36320.24','2025-04-30 10:06:58','Update','tm_barang',NULL),('SOL00055','BJ-ADRENALIN (36-40)','28588.72','2025-04-30 10:07:15','Update','tm_barang',NULL),('SOL00070','BJ-18 (33-37) XENDER ','32686.63','2025-04-30 10:07:36','Update','tm_barang',NULL),('SOL00052','BJ-ADRENALIN (38-42)','34635.53','2025-04-30 10:07:50','Update','tm_barang',NULL),('SOL00046','BJ-15 (39-43)','36254.98','2025-04-30 10:08:03','Update','tm_barang',NULL),('SOL00031','BJ-08 (39-43)','37316.33','2025-04-30 10:08:45','Update','tm_barang',NULL),('SOL00094','BJ-020 (39-43) ','55070.59','2025-04-30 10:08:58','Update','tm_barang',NULL),('SOL00070','BJ-18 (33-37) XENDER ','32713.69','2025-04-30 10:09:13','Update','tm_barang',NULL),('SOL00057','BJ-18 (39-43) XENDER','36295.76','2025-04-30 10:09:26','Update','tm_barang',NULL),('SOL00055','BJ-ADRENALIN (36-40)','28313.10','2025-04-30 10:09:41','Update','tm_barang',NULL),('SOL00052','BJ-ADRENALIN (38-42)','35429.31','2025-04-30 10:09:57','Update','tm_barang',NULL),('SOL00070','BJ-18 (33-37) XENDER ','32634.01','2025-04-30 10:10:14','Update','tm_barang',NULL),('SOL00031','BJ-08 (39-43)','37152.39','2025-04-30 10:10:49','Update','tm_barang',NULL),('SOL00057','BJ-18 (39-43) XENDER','36281.07','2025-04-30 10:11:02','Update','tm_barang',NULL),('SOL00070','BJ-18 (33-37) XENDER ','32681.09','2025-04-30 10:11:17','Update','tm_barang',NULL),('SOL00094','BJ-020 (39-43) ','54896.70','2025-04-30 10:11:30','Update','tm_barang',NULL),('SOL00052','BJ-ADRENALIN (38-42)','35426.50','2025-04-30 10:11:44','Update','tm_barang',NULL),('SOL00070','BJ-18 (33-37) XENDER ','32709.77','2025-04-30 10:12:07','Update','tm_barang',NULL),('SOL00042','BJ-12 (39-43) ML','37685.51','2025-04-30 10:12:25','Update','tm_barang',NULL),('SOL00031','BJ-08 (39-43)','37219.49','2025-04-30 10:12:49','Update','tm_barang',NULL),('SOL00057','BJ-18 (39-43) XENDER','36273.11','2025-04-30 10:13:03','Update','tm_barang',NULL),('SOL00070','BJ-18 (33-37) XENDER ','32800.14','2025-04-30 10:13:17','Update','tm_barang',NULL),('SOL00094','BJ-020 (39-43) ','55127.30','2025-04-30 10:13:31','Update','tm_barang',NULL),('SOL00052','BJ-ADRENALIN (38-42)','35425.50','2025-04-30 10:13:44','Update','tm_barang',NULL),('SOL00051','BJ-ADRENALIN (33-37)','29745.23','2025-04-30 10:14:05','Update','tm_barang',NULL),('SOL00034','BJ-10 (39-43)','38309.82','2025-04-30 10:14:20','Update','tm_barang',NULL),('SOL00056','BJ-18 (28-32) XENDER','25343.40','2025-04-30 10:14:38','Update','tm_barang',NULL),('SOL00056','BJ-18 (28-32) XENDER','25183.03','2025-04-30 10:14:54','Update','tm_barang',NULL),('SOL00057','BJ-18 (39-43) XENDER','36078.66','2025-04-30 10:15:14','Update','tm_barang',NULL),('SOL00042','BJ-12 (39-43) ML','37650.58','2025-04-30 10:15:28','Update','tm_barang',NULL),('KM.CKR','KOMPON CAKAR','3437.81','2025-04-30 10:27:11','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5410.02','2025-04-30 10:27:39','Update','tm_barang',NULL),('KM.HMR','KOMPON HAMMER','4313.73','2025-04-30 10:28:05','Update','tm_barang',NULL),('BB.STD','STANDART. A','25978.85','2025-04-30 10:28:35','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 10:29:06','Update','tm_barang',NULL),('KM.KST','KOMPON KESET TAUFIQ','5594.25','2025-04-30 10:29:31','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5440.12','2025-04-30 10:29:52','Update','tm_barang',NULL),('SOL.TEBAL','OUT SOL TEBAL','5591.43','2025-04-30 10:30:09','Update','tm_barang',NULL),('KM.KS','KOMPON K.SAPI','5464.33','2025-04-30 10:30:33','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15013.94','2025-04-30 10:31:15','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15625.51','2025-04-30 10:31:50','Update','tm_barang',NULL),('VULK.C.20','VULKANISIR C 15X200','17409.47','2025-04-30 10:32:20','Update','tm_barang',NULL),('VULK.MP.19','VULKANISIR MP 15X190','15114.71','2025-04-30 10:32:44','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15623.14','2025-04-30 10:33:09','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15643.20','2025-04-30 10:33:35','Update','tm_barang',NULL),('VULK.B.130','VULKANISIR B 10X130','19356.68','2025-04-30 10:34:09','Update','tm_barang',NULL),('VULK.B.200','VULKANISIR B 15X200','19308.93','2025-04-30 10:34:32','Update','tm_barang',NULL),('VULK.HD.20','VULKANISIR HD 15X200','20226.04','2025-04-30 10:34:58','Update','tm_barang',NULL),('VULK.B.150','VULKANISIR B 12X150','19673.42','2025-04-30 10:35:19','Update','tm_barang',NULL),('VULK.B.100','VULKANISIR B 10X100','19077.04','2025-04-30 10:35:40','Update','tm_barang',NULL),('VULK.B.130','VULKANISIR B 10X130','19628.11','2025-04-30 10:36:04','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19646.78','2025-04-30 10:36:30','Update','tm_barang',NULL),('VULK.C.10','VULKANISIR C 10X120','17501.38','2025-04-30 10:36:59','Update','tm_barang',NULL),('VULK.C.130','VULKANISIR C 10X130','17481.37','2025-04-30 10:37:25','Update','tm_barang',NULL),('VULK.C.16','VULKANISIR C 12X160','17831.99','2025-04-30 10:37:49','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15698.09','2025-04-30 10:38:12','Update','tm_barang',NULL),('VULK.MP 10X130','VULKANISIR MP 10X130','15327.32','2025-04-30 10:39:27','Update','tm_barang',NULL),('VULK.TR.200','VULKANISIT TRAKTOR 15X200','12354.66','2025-04-30 10:40:44','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20656.90','2025-04-30 10:41:10','Update','tm_barang',NULL),('VULK.MP.12','VULKANISIR MP 10X120','15514.26','2025-04-30 10:41:36','Update','tm_barang',NULL),('VULK.B.200','VULKANISIR B 15X200','19212.58','2025-04-30 10:42:00','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19661.57','2025-04-30 10:42:24','Update','tm_barang',NULL),('VULK.MP.200','VULKANISIR MP 15X200','15067.43','2025-04-30 10:42:47','Update','tm_barang',NULL),('VULK.MP.16','VULKANISIR MP 12X160','15584.38','2025-04-30 10:43:11','Update','tm_barang',NULL),('VULK.BR.160','VULKANISIR BR 12X160','28306.65','2025-04-30 10:43:52','Update','tm_barang',NULL),('VULK.B','VULKANISIR B 12X160','19668.01','2025-04-30 10:44:25','Update','tm_barang',NULL),('VULK.C.16','VULKANISIR C 12X160','17717.33','2025-04-30 10:44:48','Update','tm_barang',NULL),('VULK.B.120','VULKANISIR B 10X120','19481.37','2025-04-30 10:45:12','Update','tm_barang',NULL),('VULK.BR.160','VULKANISIR BR 12X160','28367.53','2025-04-30 10:45:38','Update','tm_barang',NULL),('VULK.HD','VULKANISIR HD 12X160','20657.07','2025-04-30 10:46:48','Update','tm_barang',NULL),('VULK.HD.19','VULKANISIR HD 15X190','20340.35','2025-04-30 10:48:39','Update','tm_barang',NULL),('VULK.C.20','VULKANISIR C 15X200','17423.35','2025-04-30 10:49:04','Update','tm_barang',NULL),('VULK.CS.4MM','VULKANISIR CHASA 4MM','14413.01','2025-04-30 10:49:35','Update','tm_barang',NULL),('VULK.HD2MM','VULKANISIR HD 2MM','21432.16','2025-04-30 10:49:56','Update','tm_barang',NULL),('VULK.C.2MM','VULKANISIR C 2MM','16970.73','2025-04-30 10:50:20','Update','tm_barang',NULL),('VULK.B.2','VULKANISIR B 2MM','21922.11','2025-04-30 10:50:45','Update','tm_barang',NULL),('VULK.C.2MM','VULKANISIR C 2MM','16970.39','2025-04-30 10:51:11','Update','tm_barang',NULL),('VULK.C.2MM','VULKANISIR C 2MM','17007.20','2025-04-30 10:51:41','Update','tm_barang',NULL),('TR.4MM','TR. 4MM','10448.40','2025-04-30 10:52:03','Update','tm_barang',NULL),('CAKAR.08','CKR CIRCLE','7771.06','2025-04-30 13:17:31','Update','tm_barang',NULL),('K.SAPI02','KARPET SAPI 12MM (110X200)','114998.60','2025-04-30 13:19:02','Update','tm_barang',NULL),('CAKAR.08','CKR CIRCLE','7771.06','2025-04-30 13:19:27','Update','tm_barang',NULL),('CAKAR.08','CKR CIRCLE','7771.06','2025-04-30 13:19:43','Update','tm_barang',NULL),('CAKAR.02','CKR AIR BAG','11512.68','2025-04-30 13:19:59','Update','tm_barang',NULL),('HM.16','HAMMER 165X240','140895.36','2025-04-30 13:21:01','Update','tm_barang',NULL),('RB.SHT.06','RB.SHT.1MX10MX8MM','392707.05','2025-04-30 13:21:23','Update','tm_barang',NULL),('K.SAPI02','KARPET SAPI 12MM (110X200)','114998.60','2025-04-30 13:21:45','Update','tm_barang',NULL),('K.SAPI02','KARPET SAPI 12MM (110X200)','114998.60','2025-04-30 13:22:21','Update','tm_barang',NULL),('CAKAR.08','CKR CIRCLE','7771.06','2025-04-30 13:22:42','Update','tm_barang',NULL),('CAKARBS01','CKR BS CIRCLE','7770.01','2025-04-30 13:23:06','Update','tm_barang',NULL),('CAKAR.02','CKR AIR BAG','11512.68','2025-04-30 13:23:20','Update','tm_barang',NULL),('HM.04','HAMMER 165 X 235','121888.85','2025-04-30 13:23:38','Update','tm_barang',NULL),('K.SAPI04','KARPET SAPI 14MM (110X200)','135292.47','2025-04-30 13:24:46','Update','tm_barang',NULL),('K.SAPI02','KARPET SAPI 12MM (110X200)','114998.60','2025-04-30 13:25:40','Update','tm_barang',NULL),('K.SAPI06','KARPET SAPI 16MM (110X200)','155586.34','2025-04-30 13:26:14','Update','tm_barang',NULL),('CAKAR.08','CKR CIRCLE','7771.06','2025-04-30 13:26:34','Update','tm_barang',NULL),('CAKARBS01','CKR BS CIRCLE','7770.01','2025-04-30 13:26:48','Update','tm_barang',NULL),('HM.04','HAMMER 165 X 235','121888.85','2025-04-30 13:27:20','Update','tm_barang',NULL),('RB.SHT.75','RB.SHT.1MX6MX10MM','388150.66','2025-04-30 13:31:34','Update','tm_barang',NULL),('RB.SHT.76','RB.SHT.1MX4MX10MM','258767.11','2025-04-30 13:31:59','Update','tm_barang',NULL),('K.SAPI06','KARPET SAPI 16MM (110X200)','155586.34','2025-04-30 13:32:22','Update','tm_barang',NULL),('K.SAPI01','KARPET SAPI 12MM (122X183)','114998.60','2025-04-30 13:33:50','Update','tm_barang',NULL),('K.SAPI06','KARPET SAPI 16MM (110X200)','155586.34','2025-04-30 13:34:11','Update','tm_barang',NULL),('CAKAR.08','CKR CIRCLE','7771.06','2025-04-30 13:35:02','Update','tm_barang',NULL),('CAKARBS01','CKR BS CIRCLE','7770.01','2025-04-30 13:35:16','Update','tm_barang',NULL),('RB.SHT.09','RB.SHT.1MX10MX10MM','512226.59','2025-04-30 13:36:24','Update','tm_barang',NULL),('K.SAPI02','KARPET SAPI 12MM (110X200)','114998.60','2025-04-30 13:36:41','Update','tm_barang',NULL),('CAKAR.08','CKR CIRCLE','7771.06','2025-04-30 13:37:51','Update','tm_barang',NULL),('CAKARBS01','CKR BS CIRCLE','7770.01','2025-04-30 13:38:06','Update','tm_barang',NULL),('K.SAPI02','KARPET SAPI 12MM (110X200)','114998.60','2025-04-30 13:39:41','Update','tm_barang',NULL),('CAKAR.08','CKR CIRCLE','7771.06','2025-04-30 13:41:37','Update','tm_barang',NULL),('CAKARBS01','CKR BS CIRCLE','7770.01','2025-04-30 13:41:52','Update','tm_barang',NULL),('CAKARBS07','CKR BS AIR BAG ','11689.99','2025-04-30 13:42:30','Update','tm_barang',NULL),('K.SAPI02','KARPET SAPI 12MM (110X200)','114998.60','2025-04-30 13:43:57','Update','tm_barang',NULL),('HM.06','HAMMER 165 X 225','118841.63','2025-04-30 14:30:35','Update','tm_barang',NULL),('CAKARBS01','CKR BS CIRCLE','7770.01','2025-04-30 15:19:56','Update','tm_barang',NULL),('SOL00031','BJ-08 (39-43)','37388.95','2025-04-30 15:41:01','Update','tm_barang',NULL),('SOL00029','BJ-08 (33-37)','29994.74','2025-04-30 15:44:03','Update','tm_barang',NULL),('SOL00058','BJ-08 (36-40)','34423.79','2025-04-30 15:44:21','Update','tm_barang',NULL),('SOL00033','BJ-09 (39-43)','36237.01','2025-04-30 15:45:55','Update','tm_barang',NULL),('SOL00034','BJ-10 (39-43)','38272.80','2025-04-30 15:46:44','Update','tm_barang',NULL),('SOL00035','BJ-11 (39-43)','34871.32','2025-04-30 15:47:51','Update','tm_barang',NULL),('SOL00042','BJ-12 (39-43) ML','37646.62','2025-04-30 15:53:39','Update','tm_barang',NULL),('SOL00039','BJ-12 (33-37) HW','27686.71','2025-04-30 15:53:57','Update','tm_barang',NULL),('SOL00043','BJ-15 (28-32)','22770.14','2025-04-30 15:56:29','Update','tm_barang',NULL),('SOL00044','BJ-15 (33-37)','27563.54','2025-04-30 15:57:34','Update','tm_barang',NULL),('SOL00046','BJ-15 (39-43)','36245.47','2025-04-30 15:59:21','Update','tm_barang',NULL),('SOL00059','BJ-17 (28-32)','25243.76','2025-04-30 16:02:42','Update','tm_barang',NULL),('SOL00060','BJ-17 (33-37)','29917.13','2025-04-30 16:03:16','Update','tm_barang',NULL),('SOL00094','BJ-020 (39-43) ','55166.29','2025-04-30 16:06:55','Update','tm_barang',NULL),('SOL00084','BJ-19 (39-43) ','50258.98','2025-04-30 16:08:10','Update','tm_barang',NULL),('SOL00052','BJ-ADRENALIN (38-42)','35669.43','2025-04-30 16:17:05','Update','tm_barang',NULL),('SOL00057','BJ-18 (39-43) XENDER','36150.64','2025-04-30 16:17:56','Update','tm_barang',NULL),('SOL00056','BJ-18 (28-32) XENDER','25229.55','2025-04-30 16:19:05','Update','tm_barang',NULL),('SOL00070','BJ-18 (33-37) XENDER ','32807.85','2025-04-30 16:20:38','Update','tm_barang',NULL);

--
-- Table structure for table `tr_modx`
--

CREATE TABLE `tr_modx` (
  `NoModX` varchar(11) NOT NULL default '',
  `TglModx` datetime default NULL,
  `Keterangan` varchar(200) default NULL,
  `TglBatal` datetime default NULL,
  PRIMARY KEY  (`NoModX`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_modx`
--


--
-- Table structure for table `tr_mutasibuku`
--

CREATE TABLE `tr_mutasibuku` (
  `TransMutasiBuku` varchar(2) NOT NULL,
  `NoMutasiBuku` varchar(11) NOT NULL,
  `NoJual` varchar(11) default NULL,
  `Tanggal` datetime default NULL,
  `ItemMutasi` varchar(11) default NULL,
  `KodeCustAsal` varchar(10) default NULL,
  `KodeCustTujuan` varchar(10) default NULL,
  `KodeBrg` varchar(50) default NULL,
  `NamaBrg` varchar(50) default NULL,
  `Tahun` int(11) default NULL,
  `Semester` int(11) default NULL,
  `Jml` double default NULL,
  `Harga` double default NULL,
  `Satuan` varchar(10) default NULL,
  `Nilai` double default NULL,
  `Keterangan` text,
  `itemjual` int(11) default NULL,
  PRIMARY KEY  (`TransMutasiBuku`,`NoMutasiBuku`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_mutasibuku`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `mutasibkAdd` AFTER INSERT ON `tr_mutasibuku` FOR EACH ROW BEGIN
update tm_customer set piutang=ifnull(piutang,0)-new.nilai where kodecust=new.kodecustasal;
update tm_customer set piutang=ifnull(piutang,0)+new.nilai where kodecust=new.kodecusttujuan;
update tr_jual_d set dimutasi=ifnull(dimutasi,0)+new.jml where nojual=new.nojual and itemjual=new.itemjual;
END */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `mutasibkUpdate` AFTER UPDATE ON `tr_mutasibuku` FOR EACH ROW BEGIN
update tm_customer set piutang=ifnull(piutang,0)+old.nilai where kodecust=old.kodecustasal;
update tm_customer set piutang=ifnull(piutang,0)-old.nilai where kodecust=old.kodecusttujuan;
update tm_customer set piutang=ifnull(piutang,0)-new.nilai where kodecust=new.kodecustasal;
update tm_customer set piutang=ifnull(piutang,0)+new.nilai where kodecust=new.kodecusttujuan;
update tr_jual_d set dimutasi=ifnull(dimutasi,0)+new.jml where nojual=new.nojual and itemjual=new.itemjual;
update tr_jual_d set dimutasi=ifnull(dimutasi,0)-old.jml where nojual=old.nojual and itemjual=old.itemjual;
END */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `mutasibkDel` AFTER DELETE ON `tr_mutasibuku` FOR EACH ROW BEGIN
update tm_customer set piutang=ifnull(piutang,0)+old.nilai where kodecust=old.kodecustasal;
update tm_customer set piutang=ifnull(piutang,0)-old.nilai where kodecust=old.kodecusttujuan;
update tr_jual_d set dimutasi=ifnull(dimutasi,0)-old.jml where nojual=old.nojual and itemjual=old.itemjual;
END */;;

DELIMITER ;

--
-- Table structure for table `tr_mutasigd`
--

CREATE TABLE `tr_mutasigd` (
  `NoPindah` varchar(11) default NULL,
  `TglPindah` date default NULL,
  `ItemPindah` int(11) default NULL,
  `KodeBrg` varchar(20) default NULL,
  `TokoAsal` varchar(1) default NULL,
  `KodeGDAsal` varchar(5) default NULL,
  `TokoTujuan` varchar(1) default NULL,
  `KodeGDTujuan` varchar(5) default NULL,
  `Jumlah` double default NULL,
  `Satuan` varchar(10) default NULL,
  `Konv` double default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_mutasigd`
--


--
-- Table structure for table `tr_opnameall`
--

CREATE TABLE `tr_opnameall` (
  `TglOpname` datetime NOT NULL default '0000-00-00 00:00:00',
  `KodeBrg` varchar(20) NOT NULL,
  `JmlStock` double default NULL,
  `JmlOpname` double default NULL,
  `JmlUpdate` double default NULL,
  `KodeGd` varchar(5) NOT NULL,
  PRIMARY KEY  (`TglOpname`,`KodeBrg`),
  KEY `fk_OpnameAll1` (`KodeGd`),
  KEY `fk_OpnameAll2` (`KodeBrg`),
  CONSTRAINT `fk_OpnameAll1` FOREIGN KEY (`KodeGd`) REFERENCES `tm_gudang` (`KodeGd`),
  CONSTRAINT `fk_OpnameAll2` FOREIGN KEY (`KodeBrg`) REFERENCES `tm_barang` (`KodeBrg`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_opnameall`
--


--
-- Table structure for table `tr_pindahgd_d`
--

CREATE TABLE `tr_pindahgd_d` (
  `NoPindahGd` varchar(11) NOT NULL default '',
  `ItemDet` int(11) NOT NULL default '0',
  `KodeBrg` varchar(20) NOT NULL,
  `KodeGdAsal` varchar(5) NOT NULL,
  `KodeGdTujuan` varchar(5) NOT NULL,
  `Jumlah` double default NULL,
  `Satuan` varchar(10) NOT NULL,
  `Konv` int(11) default NULL,
  PRIMARY KEY  (`NoPindahGd`,`ItemDet`),
  KEY `fk_DetPIndahGd2` (`KodeBrg`),
  KEY `fk_DetPindahGd3` (`KodeGdAsal`),
  KEY `fk_DetPindahGd4` (`KodeGdTujuan`),
  CONSTRAINT `fk_DetPindahGd1` FOREIGN KEY (`NoPindahGd`) REFERENCES `tr_pindahgd_m` (`NoPindahGd`) ON DELETE CASCADE,
  CONSTRAINT `fk_DetPIndahGd2` FOREIGN KEY (`KodeBrg`) REFERENCES `tm_barang` (`KodeBrg`),
  CONSTRAINT `fk_DetPindahGd3` FOREIGN KEY (`KodeGdAsal`) REFERENCES `tm_gudang` (`KodeGd`),
  CONSTRAINT `fk_DetPindahGd4` FOREIGN KEY (`KodeGdTujuan`) REFERENCES `tm_gudang` (`KodeGd`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_pindahgd_d`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetPindahGdAdd` AFTER INSERT ON `tr_pindahgd_d` FOR EACH ROW BEGIN
Declare vtemp double;
Declare vJml double;
  select stockakhir-new.jumlah into vJml from tm_stockbrg where kodeGd=new.KodeGDasal and kodebrg=new.kodebrg;
     select count(*) into vtemp from tm_stockbrg where kodebrg=new.kodebrg and kodeGd= new.KodeGDTujuan;
     if vtemp = 0 then
        insert  into tm_stockbrg (kodebrg,kodegd,StockAwal,stockakhir) values (new.kodebrg,new.kodegdtujuan,0,new.Jumlah);
        Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)-new.jumlah where kodeGd= new.KodeGDAsal and kodebrg=new.kodebrg;
     else  
        Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)+new.jumlah where kodeGd= new.KodeGDTujuan and kodebrg=new.kodebrg;
        Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)-new.jumlah where kodeGd= new.KodeGDAsal and kodebrg=new.kodebrg;
     end if;
END */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetPindahGdUpdate` AFTER UPDATE ON `tr_pindahgd_d` FOR EACH ROW BEGIN
declare vtemp double;
declare vJmltujuan double;
declare vJmlasal   double;
declare vJml   double;
  select count(*) into vtemp from tm_stockbrg where kodeGd= new.KodeGDTujuan and kodebrg=new.kodebrg;
  select ifnull(stockakhir,0)-new.jumlah into vJmlAsal from tm_stockbrg where kodeGd= new.KodeGDAsal and kodebrg=new.kodebrg;
  select ifnull(stockakhir,0)-old.jumlah into vJmlTujuan from tm_stockbrg where kodeGd= old.KodeGDTujuan and kodebrg=old.kodebrg;
     if vtemp = 0 then
        insert  into tm_stockbrg (kodebrg,kodegd,StockAwal,stockakhir) values (new.kodebrg,new.kodegdtujuan,0,new.jumlah);
 
        Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)+old.Jumlah*old.konv where kodeGd= old.KodeGDasal and kodebrg=old.kodebrg;
        Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)-new.Jumlah*new.konv where kodeGd= new.KodeGDasal and kodebrg=new.kodebrg;
        Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)-old.Jumlah*old.konv where kodeGd= old.KodeGDtujuan and kodebrg=old.kodebrg;
     else
        Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)+new.Jumlah*new.konv where kodeGd= new.KodeGDTujuan and kodebrg=new.kodebrg;
        Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)+old.Jumlah*old.konv where kodeGd= old.KodeGDasal and kodebrg=old.kodebrg;
        Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)-new.Jumlah*new.konv where kodeGd= new.KodeGDasal and kodebrg=new.kodebrg;
        Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)-old.Jumlah*old.konv where kodeGd= old.KodeGDtujuan and kodebrg=old.kodebrg;
     end if;
END */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetPindahGdDelete` AFTER DELETE ON `tr_pindahgd_d` FOR EACH ROW BEGIN
declare vtemp double;
Declare vJmlTujuan double;
  select ifnull(stockakhir,0)-old.jumlah into vJmlTujuan from tm_stockbrg where kodeGd= old.KodeGDTujuan and kodebrg=old.kodebrg;
  select count(*) into vtemp from tm_stockbrg where kodeGd= old.KodeGDtujuan and kodebrg=old.kodebrg;
  
     if vtemp > 0 then
       Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)-old.Jumlah where kodeGd= old.KodeGDTujuan and kodebrg=old.kodebrg;
       Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)+old.Jumlah where kodeGd= old.KodeGDAsal and kodebrg=old.kodebrg;
     END if;
 
END */;;

DELIMITER ;

--
-- Table structure for table `tr_pindahgd_m`
--

CREATE TABLE `tr_pindahgd_m` (
  `NoPindahGd` varchar(11) NOT NULL default '',
  `TglPindahGd` datetime default NULL,
  `Keterangan` varchar(200) default NULL,
  `TglBatal` datetime default NULL,
  PRIMARY KEY  (`NoPindahGd`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_pindahgd_m`
--


--
-- Table structure for table `tr_piusem`
--

CREATE TABLE `tr_piusem` (
  `KodeCust` varchar(20) default NULL,
  `NamaCust` varchar(75) default NULL,
  `Alamat` varchar(75) default NULL,
  `Kota` varchar(50) default NULL,
  `Telp` varchar(20) default NULL,
  `Semester` varchar(20) default NULL,
  `Piutang_sem` double default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_piusem`
--


--
-- Table structure for table `tr_pobeli_d`
--

CREATE TABLE `tr_pobeli_d` (
  `NoPO` varchar(11) NOT NULL,
  `ItemPO` int(11) NOT NULL,
  `KodeBrg` varchar(20) default NULL,
  `Keterangan` varchar(100) default NULL,
  `Harga` double default NULL,
  `Disc` double default NULL,
  `Jml` double default NULL,
  `Satuan` varchar(10) NOT NULL,
  `Konv` double default NULL,
  `SdhTerima` double default NULL,
  `TglFinish` datetime default NULL,
  `Sisa` double default NULL,
  PRIMARY KEY  (`NoPO`,`ItemPO`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_pobeli_d`
--


--
-- Table structure for table `tr_pobeli_m`
--

CREATE TABLE `tr_pobeli_m` (
  `NoPO` varchar(11) NOT NULL,
  `TglPO` datetime default NULL,
  `TglBatal` datetime default NULL,
  `KodeSupp` varchar(10) default NULL,
  `Keterangan` varchar(200) default NULL,
  `DiscRp` double default NULL,
  `Tambahan` double default NULL,
  `KetTambahan` varchar(50) default NULL,
  `PPN` double default NULL,
  `PPNRps` double default NULL,
  `SyaratByr` int(11) default NULL,
  `KetSyaratByr` varchar(50) default NULL,
  `Valas` varchar(10) default NULL,
  `ExRate` double default NULL,
  `TglJt` datetime default NULL,
  PRIMARY KEY  (`NoPO`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_pobeli_m`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `poBeliAdd` AFTER INSERT ON `tr_pobeli_m` FOR EACH ROW insert into totoritas(Trans,Nobukti,TglTrans) values ("PO",new.NOPO,new.TglPO) */;;

DELIMITER ;

--
-- Table structure for table `tr_pojual_d`
--

CREATE TABLE `tr_pojual_d` (
  `NoPO` varchar(11) NOT NULL default '',
  `ItemPO` int(11) NOT NULL default '0',
  `KodeBrg` varchar(20) default NULL,
  `Keterangan` varchar(100) default NULL,
  `Harga` double default NULL,
  `Disc` double default NULL,
  `Jml` double default NULL,
  `Satuan` varchar(10) NOT NULL,
  `Konv` double default NULL,
  `SdhTerima` double default NULL,
  `TglFinish` datetime default NULL,
  PRIMARY KEY  (`NoPO`,`ItemPO`),
  KEY `fk_POJual_d2` (`KodeBrg`),
  CONSTRAINT `fk_POJual_d1` FOREIGN KEY (`NoPO`) REFERENCES `tr_pojual_m` (`NoPO`) ON DELETE CASCADE,
  CONSTRAINT `fk_POJual_d2` FOREIGN KEY (`KodeBrg`) REFERENCES `tm_barang` (`KodeBrg`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_pojual_d`
--


--
-- Table structure for table `tr_pojual_m`
--

CREATE TABLE `tr_pojual_m` (
  `NoPO` varchar(11) NOT NULL default '',
  `TglPO` datetime default NULL,
  `TglBatal` datetime default NULL,
  `KodeCust` varchar(10) default NULL,
  `Keterangan` varchar(200) default NULL,
  `DiscRp` double default NULL,
  `Tambahan` double default NULL,
  `KetTambahan` varchar(50) default NULL,
  `PPN` double default NULL,
  `PPNRps` double default NULL,
  `SyaratByr` int(11) default NULL,
  `KetSyaratByr` varchar(50) default NULL,
  `Valas` varchar(10) default NULL,
  `Exrate` double default NULL,
  `Nilai` double default NULL,
  PRIMARY KEY  (`NoPO`),
  KEY `fk_tr_POJual_m` (`KodeCust`),
  CONSTRAINT `fk_tr_POJual_m` FOREIGN KEY (`KodeCust`) REFERENCES `tm_customer` (`KodeCust`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_pojual_m`
--


--
-- Table structure for table `tr_pojualrakitan_d`
--

CREATE TABLE `tr_pojualrakitan_d` (
  `NoPO` varchar(11) NOT NULL default '',
  `ItemPO` int(11) NOT NULL default '0',
  `KodeBrg` varchar(20) default NULL,
  `Keterangan` varchar(100) default NULL,
  `Harga` double default NULL,
  `Disc` double default NULL,
  `Jml` double default NULL,
  `Satuan` varchar(10) NOT NULL,
  `Konv` double default NULL,
  `SdhTerima` double default NULL,
  `TglFinish` datetime default NULL,
  PRIMARY KEY  (`NoPO`,`ItemPO`),
  KEY `fk_POJualrakitan_d2` (`KodeBrg`),
  CONSTRAINT `fk_POJualrakitan_d1` FOREIGN KEY (`NoPO`) REFERENCES `tr_pojualrakitan_m` (`NoPO`) ON DELETE CASCADE,
  CONSTRAINT `fk_POJualrakitan_d2` FOREIGN KEY (`KodeBrg`) REFERENCES `tm_barang` (`KodeBrg`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_pojualrakitan_d`
--


--
-- Table structure for table `tr_pojualrakitan_m`
--

CREATE TABLE `tr_pojualrakitan_m` (
  `NoPO` varchar(11) NOT NULL default '',
  `TglPO` datetime default NULL,
  `TglBatal` datetime default NULL,
  `KodeCust` varchar(10) default NULL,
  `KodeRakitan` varchar(20) default NULL,
  `JmlRakitan` int(11) default NULL,
  `SdhTerima` int(11) default NULL,
  `Keterangan` varchar(200) default NULL,
  `DiscRp` double default NULL,
  `Tambahan` double default NULL,
  `KetTambahan` varchar(50) default NULL,
  `PPN` double default NULL,
  `PPNRps` double default NULL,
  `SyaratByr` int(11) default NULL,
  `KetSyaratByr` varchar(50) default NULL,
  `Valas` varchar(10) default NULL,
  `Exrate` double default NULL,
  PRIMARY KEY  (`NoPO`),
  KEY `fk_tr_POJualrakitan_m` (`KodeCust`),
  CONSTRAINT `fk_tr_POJualrakitan_m` FOREIGN KEY (`KodeCust`) REFERENCES `tm_customer` (`KodeCust`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_pojualrakitan_m`
--


--
-- Table structure for table `tr_produksijadi_d`
--

CREATE TABLE `tr_produksijadi_d` (
  `TransProd` varchar(5) default NULL,
  `NoProduksi` varchar(20) default NULL,
  `KodeProduk` varchar(15) default NULL,
  `itembrg` int(11) default NULL,
  `kodebrg` varchar(20) default NULL,
  `namabrg` varchar(50) default NULL,
  `satuan` varchar(10) default NULL,
  `kodegd` varchar(10) default NULL,
  `JmlSebelum` double default NULL,
  `jml` double default NULL,
  `Konv` double default NULL,
  `harga` double default NULL,
  `total` double default NULL,
  `disc` double default NULL,
  `discpersen` double default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_produksijadi_d`
--


--
-- Table structure for table `tr_produksijadi_m`
--

CREATE TABLE `tr_produksijadi_m` (
  `TransProd` varchar(5) default NULL,
  `NoProduksi` varchar(25) NOT NULL default '',
  `TglProduksi` date default NULL,
  `KodeMaster` varchar(15) default NULL,
  `KodeProduk` varchar(15) default NULL,
  `NamaProduk` varchar(40) default NULL,
  `Nilai` double default NULL,
  `Keterangan` varchar(100) default NULL,
  `JmlProduksi` double default NULL,
  `tukang` varchar(40) default NULL,
  `JenisProduksi` varchar(10) default NULL,
  `kodegol` varchar(15) default NULL,
  `hslproduksi` double default NULL,
  `nilaiselisih` double default NULL,
  PRIMARY KEY  (`NoProduksi`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_produksijadi_m`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `TRHasilProduksiAdd_copy` AFTER INSERT ON `tr_produksijadi_m` FOR EACH ROW BEGIN
   Update tm_stockbrg set Stockakhir =  stockakhir+new.jmlproduksi
   where kodebrg=new.kodeProduk;
   
   if (new.nilaiselisih) > 0 then
      update tm_barang set hargaavg = ( new.nilai / new.jmlproduksi ) 
      where kodebrg = new.kodeproduk;
   end if;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `TRHasilProduksiUpdate_copy` AFTER UPDATE ON `tr_produksijadi_m` FOR EACH ROW BEGIN
   Update tm_stockbrg set Stockakhir =  stockakhir-Old.jmlproduksi where kodebrg=Old.kodeProduk;
   Update tm_stockbrg set Stockakhir =  stockakhir+new.jmlproduksi where kodebrg=new.kodeProduk;
   if (new.nilaiselisih) > 0 then
      update tm_barang set hargaavg = ( new.nilai / new.jmlproduksi )
      where kodebrg = new.kodeproduk;
   end if;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `TRHasilProduksiDelete_copy` AFTER DELETE ON `tr_produksijadi_m` FOR EACH ROW BEGIN
   Update tm_stockbrg set Stockakhir =  stockakhir-Old.jmlproduksi where kodebrg=Old.kodeProduk;
end */;;

DELIMITER ;

--
-- Table structure for table `tr_produksijadi_md`
--

CREATE TABLE `tr_produksijadi_md` (
  `TransProd` varchar(5) default NULL,
  `NoProduksi` varchar(20) default NULL,
  `KodeProduk` varchar(15) default NULL,
  `itembrg` int(11) default NULL,
  `kodebrg` varchar(20) default NULL,
  `namabrg` varchar(50) default NULL,
  `satuan` varchar(10) default NULL,
  `kodegd` varchar(10) default NULL,
  `JmlSebelum` double default NULL,
  `jml` double default NULL,
  `Konv` double default NULL,
  `harga` double default NULL,
  `total` double default NULL,
  `disc` double default NULL,
  `discpersen` double default NULL,
  `BeratBrg` double default NULL,
  `TotalBerat` double default NULL,
  `BeratBrgSebelum` double default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_produksijadi_md`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetHasilProduksiAdd_copy` AFTER INSERT ON `tr_produksijadi_md` FOR EACH ROW BEGIN
  DECLARE vtemp double;
  Update tm_stockbrg set Stockakhir =  stockakhir+(new.jml)
  where kodebrg=new.kodebrg and kodeGd= new.KodeGD;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetHasilProduksiUpdate_copy` AFTER UPDATE ON `tr_produksijadi_md` FOR EACH ROW BEGIN
 
   Update tm_stockbrg set Stockakhir =  stockakhir-(Old.jml)
   where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD;
 
   Update tm_stockbrg set Stockakhir =  stockakhir+(new.jml)
   where kodebrg=new.kodebrg and kodeGd= new.KodeGD;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetHasilProduksiDelete_copy` AFTER DELETE ON `tr_produksijadi_md` FOR EACH ROW BEGIN
 
   Update tm_stockbrg set Stockakhir =  stockakhir-(Old.jml)
   where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD;
end */;;

DELIMITER ;

--
-- Table structure for table `tr_retbeli_d`
--

CREATE TABLE `tr_retbeli_d` (
  `TransRetB` varchar(2) NOT NULL default '',
  `NoRetB` varchar(11) NOT NULL default '',
  `ItemRetB` int(11) NOT NULL default '0',
  `TransBeli` varchar(2) default NULL,
  `NoBeli` varchar(11) default NULL,
  `itemBeli` int(11) default NULL,
  `KodeBrg` varchar(20) NOT NULL,
  `KodeGd` varchar(5) NOT NULL,
  `Harga` double default NULL,
  `Disc` double default NULL,
  `Jml` double default NULL,
  `Satuan` varchar(10) NOT NULL,
  `Konv` double default NULL,
  `Replaced` varchar(1) default NULL,
  `Locked` varchar(1) default NULL,
  `Direplace` double default NULL,
  `Sisa` double default NULL,
  PRIMARY KEY  (`TransRetB`,`NoRetB`,`ItemRetB`),
  KEY `fk_tr_RetBeli_d2` (`KodeGd`),
  KEY `fk_tr_RetBeli_d3` (`KodeBrg`),
  KEY `fk_tr_RetBeli_d4` (`TransBeli`,`NoBeli`,`itemBeli`),
  CONSTRAINT `fk_tr_RetBeli_d1` FOREIGN KEY (`TransRetB`, `NoRetB`) REFERENCES `tr_retbeli_m` (`TransRetB`, `NoRetB`) ON DELETE CASCADE,
  CONSTRAINT `fk_tr_RetBeli_d2` FOREIGN KEY (`KodeGd`) REFERENCES `tm_gudang` (`KodeGd`),
  CONSTRAINT `fk_tr_RetBeli_d3` FOREIGN KEY (`KodeBrg`) REFERENCES `tm_barang` (`KodeBrg`),
  CONSTRAINT `fk_tr_RetBeli_d4` FOREIGN KEY (`TransBeli`, `NoBeli`, `itemBeli`) REFERENCES `tr_beli_d` (`TransBeli`, `NoBeli`, `ItemBeli`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_retbeli_d`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetRetBeliAdd` AFTER INSERT ON `tr_retbeli_d` FOR EACH ROW BEGIN
declare vnoretb varchar(11);
DECLARE vjumlah  double; 
DECLARE vTglBatal datetime;
Declare vnobeli varchar(11);
declare vcode varchar(20);
declare vitemBeli int;
declare vtrans varchar(2);
declare vTransbeli varchar(2);
declare vKodeGd varchar(5);
 select TransRetB,NoretB,Kodebrg, ifnull(jml,0),kodegd, ifnull(TransBeli,''), ifnull(NoBeli,''), ifnull(itemBeli,0) into vtrans,vNoretB,vcode,vjumlah,vkodegd, vTransbeli, vNoBeli, vItemBeli 
 from Tr_RetBeli_d where TransRetB = new.TransRetB and NoretB = new.NoretB and ItemRetB=new.ItemretB;
 select Tglbatal into vTglbatal from Tr_RetBeli_M where new.TransRetB and NoretB = new.NoretB;
 update tm_stockbrg set stockakhir = ifnull(stockakhir,0) -new.jml where kodebrg=new.kodebrg and kodeGd= new.KodeGD; 
 
 if (vnobeli<>'') and (vTransBeli<>'') and (vItemBeli<>0) then
    update Tr_Beli_d set diretur = ifnull(diretur,0) + vJumlah where Transbeli=vTransBeli and nobeli=vnobeli and ItemBeli=vItemBeli;
 end if;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetRetBeliUpdate` AFTER UPDATE ON `tr_retbeli_d` FOR EACH ROW BEGIN
 declare vnoretb varchar(11);
 DECLARE vjumlah  double; 
 DECLARE vTglBatal datetime;
 Declare vnobeli varchar(11);
 declare vcode varchar(20);
 declare vitemBeli int;
 declare vtrans varchar(2);
 declare vTransbeli varchar(2);
 declare vKodeGd varchar(5);
  select TransRetB,NoretB,Kodebrg, ifnull(jml,0),kodegd, ifnull(TransBeli,''), ifnull(NoBeli,''), ifnull(itemBeli,0) into vtrans,vNoretB,vcode,vjumlah,vkodegd, vTransbeli, vNoBeli, vItemBeli 
  from Tr_RetBeli_d where TransRetB = new.TransRetB and NoretB = new.NoretB and ItemRetB=new.ItemretB;
  select Tglbatal into vTglbatal from Tr_RetBeli_M where new.TransRetB and NoretB = new.NoretB;
  update tm_stockbrg set stockakhir = ifnull(stockakhir,0) +Old.jml where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD; 
  update tm_stockbrg set stockakhir = ifnull(stockakhir,0) -new.jml where kodebrg=new.kodebrg and kodeGd= new.KodeGD; 
  update tr_Beli_d set diretur = ifnull(diretur,0)-Old.Jml  where Transbeli=old.TransBeli and nobeli=old.nobeli and ItemBeli=old.ItemBeli;
  update tr_Beli_d set diretur = ifnull(diretur,0)+New.Jml  where Transbeli=new.TransBeli and nobeli=new.nobeli and ItemBeli=new.ItemBeli;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetRetBeliDelete` AFTER DELETE ON `tr_retbeli_d` FOR EACH ROW BEGIN
 update tm_stockbrg set stockakhir = ifnull(stockakhir,0) +Old.jml where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD; 
 update tr_Beli_d set diretur = ifnull(diretur,0)-Old.Jml  where Transbeli=old.TransBeli and nobeli=old.nobeli and ItemBeli=old.ItemBeli;
end */;;

DELIMITER ;

--
-- Table structure for table `tr_retbeli_m`
--

CREATE TABLE `tr_retbeli_m` (
  `TransRetB` varchar(2) NOT NULL default '',
  `NoRetB` varchar(11) NOT NULL default '',
  `TglRetB` datetime default NULL,
  `TglBatal` datetime default NULL,
  `KodeSupp` varchar(10) default NULL,
  `Keterangan` varchar(200) default NULL,
  `TRansBeli` varchar(2) default NULL,
  `NoBeli` varchar(11) default NULL,
  `DiscRp` double default NULL,
  `Tambahan` double default NULL,
  `KetTambahan` varchar(50) default NULL,
  `PPN` double default NULL,
  `PPNRps` double default NULL,
  `Nilai` double default NULL,
  `Sisa` double default NULL,
  `valas` varchar(10) default NULL,
  `ExRate` double default NULL,
  PRIMARY KEY  (`TransRetB`,`NoRetB`),
  KEY `fk_tr_RetBeli_m1` (`KodeSupp`),
  KEY `fk_tr_RetBeli_m2` (`TRansBeli`,`NoBeli`),
  CONSTRAINT `fk_tr_RetBeli_m1` FOREIGN KEY (`KodeSupp`) REFERENCES `tm_supplier` (`KodeSupp`),
  CONSTRAINT `fk_tr_RetBeli_m2` FOREIGN KEY (`TRansBeli`, `NoBeli`) REFERENCES `tr_beli_m` (`TransBeli`, `NoBeli`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_retbeli_m`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trRetBeliAdd` AFTER INSERT ON `tr_retbeli_m` FOR EACH ROW BEGIN
  Update tm_Supplier set Hutang =  ifnull(hutang,0) - new.nilai * new.exrate 
  where kodesupp = new.kodesupp;
  Update tr_beli_m set sisa =  ifnull(sisa,0) - new.nilai * new.exrate 
  where TransBeli = new.TransBeli and NoBeli=New.NoBeli;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trRetBeliUpdate` AFTER UPDATE ON `tr_retbeli_m` FOR EACH ROW BEGIN
  Update tm_Supplier set Hutang =  ifnull(hutang,0) +  old.nilai *  Old.exrate 
  where kodesupp = old.kodesupp;
  
  Update tm_Supplier set Hutang =  ifnull(hutang,0) -  new.nilai *  new.exrate 
  where kodesupp = new.kodesupp;
  Update tr_beli_m set sisa =  ifnull(sisa,0) - new.nilai * new.exrate 
  where TransBeli = new.TransBeli and NoBeli=New.NoBeli;
  Update tr_beli_m set sisa =  ifnull(sisa,0) + old.nilai * old.exrate 
  where TransBeli = old.TransBeli and NoBeli=old.NoBeli;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trRetBeliDelete` AFTER DELETE ON `tr_retbeli_m` FOR EACH ROW BEGIN
  Update tm_Supplier set Hutang =  ifnull(hutang,0) + (Old.nilai * Old.exrate) 
  where kodesupp = Old.kodesupp;
  Update tr_beli_m set sisa =  ifnull(sisa,0) + old.nilai * old.exrate 
  where TransBeli = old.TransBeli and NoBeli=old.NoBeli;
end */;;

DELIMITER ;

--
-- Table structure for table `tr_retjual_d`
--

CREATE TABLE `tr_retjual_d` (
  `TransRetJ` varchar(2) NOT NULL default '',
  `NoRetJ` varchar(11) NOT NULL default '',
  `ItemRetJ` int(11) NOT NULL default '0',
  `TransJual` varchar(2) default NULL,
  `NoJual` varchar(11) default NULL,
  `ItemJual` int(11) default NULL,
  `KodeBrg` varchar(20) NOT NULL,
  `KodeGd` varchar(5) NOT NULL,
  `Harga` double default NULL,
  `Disc` double default NULL,
  `Jml` double default NULL,
  `Satuan` varchar(10) NOT NULL,
  `Konv` double default NULL,
  PRIMARY KEY  (`TransRetJ`,`NoRetJ`,`ItemRetJ`),
  KEY `fk_Tr_RetJual_D1` (`KodeGd`),
  KEY `fk_Tr_RetJual_D2` (`KodeBrg`),
  KEY `fk_Tr_RetJual_D3` (`TransJual`,`NoJual`,`ItemJual`),
  KEY `fk_Tr_RetJual_D7` (`TransJual`,`NoJual`,`ItemJual`),
  CONSTRAINT `fk_Tr_RetJual_D4` FOREIGN KEY (`TransRetJ`, `NoRetJ`) REFERENCES `tr_retjual_m` (`TransRetJ`, `NoRetJ`) ON DELETE CASCADE,
  CONSTRAINT `fk_Tr_RetJual_D5` FOREIGN KEY (`KodeGd`) REFERENCES `tm_gudang` (`KodeGd`),
  CONSTRAINT `fk_Tr_RetJual_D6` FOREIGN KEY (`KodeBrg`) REFERENCES `tm_barang` (`KodeBrg`),
  CONSTRAINT `fk_Tr_RetJual_D7` FOREIGN KEY (`TransJual`, `NoJual`, `ItemJual`) REFERENCES `tr_jual_d` (`TransJual`, `NoJual`, `ItemJual`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_retjual_d`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetREtJualAdd` AFTER INSERT ON `tr_retjual_d` FOR EACH ROW BEGIN
  Update tm_StockBrg set stockakhir = ifnull(stockakhir,0) + new.jml where kodebrg=new.kodebrg and kodeGd= new.KodeGD;
  update tr_jual_d set diretur = ifnull(diretur,0) + new.Jml  where nojual = new.nojual and TransJual=new.Transjual and ItemJual=new.ItemJual;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetREtJualUpdate` AFTER UPDATE ON `tr_retjual_d` FOR EACH ROW BEGIN
  Update tm_StockBrg set stockakhir = ifnull(stockakhir,0) - Old.jml where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD;
  Update tm_StockBrg set stockakhir = ifnull(stockakhir,0) + New.jml where kodebrg=New.kodebrg and kodeGd= New.KodeGD;
  update tr_jual_d set diretur = ifnull(diretur,0) -Old.Jml  where nojual = Old.nojual and TransJual=Old.Transjual and ItemJual=Old.ItemJual;
  update tr_jual_d set diretur = ifnull(diretur,0) +New.Jml  where nojual = New.nojual and TransJual=New.Transjual and ItemJual=New.ItemJual;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetREtJualDelete` AFTER DELETE ON `tr_retjual_d` FOR EACH ROW BEGIN
Update tm_StockBrg set stockakhir = ifnull(stockakhir,0) - Old.jml where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD;
update tr_jual_d set diretur = ifnull(diretur,0) - Old.Jml  where nojual = Old.nojual and TransJual=Old.Transjual and ItemJual=Old.ItemJual;
end */;;

DELIMITER ;

--
-- Table structure for table `tr_retjual_m`
--

CREATE TABLE `tr_retjual_m` (
  `TransRetJ` varchar(2) NOT NULL default '',
  `NoRetJ` varchar(11) NOT NULL default '',
  `TglRetJ` datetime default NULL,
  `TglBatal` datetime default NULL,
  `KodeCust` varchar(10) default NULL,
  `Keterangan` varchar(200) default NULL,
  `TRansJual` varchar(2) default NULL,
  `NoJual` varchar(11) default NULL,
  `DiscRp` double default NULL,
  `Tambahan` double default NULL,
  `KetTambahan` varchar(50) default NULL,
  `PPN` double default NULL,
  `PPNRps` double default NULL,
  `Nilai` double default NULL,
  `Valas` varchar(10) default NULL,
  `ExRate` double default NULL,
  `Sisa` double default NULL,
  PRIMARY KEY  (`TransRetJ`,`NoRetJ`),
  KEY `fk_Tr_RetJual_M1` (`KodeCust`),
  KEY `fk_Tr_RetJual_M2` (`TRansJual`,`NoJual`),
  CONSTRAINT `fk_Tr_RetJual_M1` FOREIGN KEY (`KodeCust`) REFERENCES `tm_customer` (`KodeCust`),
  CONSTRAINT `fk_Tr_RetJual_M2` FOREIGN KEY (`TRansJual`, `NoJual`) REFERENCES `tr_jual_m` (`TransJual`, `NoJual`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_retjual_m`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `TrRetJualAdd` AFTER INSERT ON `tr_retjual_m` FOR EACH ROW BEGIN
Declare vPiutang double;
Declare vSisa double;
  select ifnull(Piutang,0) into vPiutang from tm_Customer where kodeCust = new.kodeCust; 
  Update tm_Customer set Piutang =  ifnull(Piutang,0) - new.nilai * new.exrate 
  where kodeCust = new.kodeCust;
  Update tr_Jual_m set sisa =  ifnull(sisa,0) - new.nilai * new.exrate 
  where TransJual = new.TransJual and NoJual=New.NoJual;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `TrRetJualUpdate` AFTER UPDATE ON `tr_retjual_m` FOR EACH ROW BEGIN
Declare vPiutang double;
Declare vSisa double;
  select ifnull(Piutang,0) into vPiutang from tm_Customer where kodeCust = new.kodeCust; 
  Update tm_Customer set Piutang =  ifnull(Piutang,0) - new.nilai * new.exrate 
  where kodeCust = new.kodeCust;
  Update tm_Customer set Piutang =  ifnull(Piutang,0) + Old.nilai * Old.exrate 
  where kodeCust = Old.kodeCust;
  Update tr_Jual_m set sisa =  ifnull(sisa,0) - new.nilai * new.exrate 
  where TransJual = new.TransJual and NoJual=New.NoJual;
  Update tr_Jual_m set sisa =  ifnull(sisa,0) + old.nilai * old.exrate 
  where TransJual = old.TransJual and NoJual=old.NoJual;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `TrRetJualDelete` AFTER DELETE ON `tr_retjual_m` FOR EACH ROW BEGIN
Declare vSisa double;
  Update tm_Customer set Piutang =  ifnull(Piutang,0) + Old.nilai * Old.exrate 
  where kodeCust = Old.kodeCust;
  Update tr_Jual_m set sisa =  ifnull(sisa,0) + old.nilai * old.exrate 
  where TransJual = old.TransJual and NoJual=old.NoJual;
end */;;

DELIMITER ;

--
-- Table structure for table `tr_retjualr_d`
--

CREATE TABLE `tr_retjualr_d` (
  `TransRetJ` varchar(2) NOT NULL default '',
  `NoRetJ` varchar(11) NOT NULL default '',
  `ItemRetJ` int(11) NOT NULL default '0',
  `TransJual` varchar(2) default NULL,
  `NoJual` varchar(11) default NULL,
  `ItemJual` int(11) default NULL,
  `KodeBrg` varchar(20) NOT NULL,
  `KodeGd` varchar(5) NOT NULL,
  `Harga` double default NULL,
  `Disc` double default NULL,
  `Jml` double default NULL,
  `Satuan` varchar(10) NOT NULL,
  `Konv` double default NULL,
  PRIMARY KEY  (`TransRetJ`,`NoRetJ`,`ItemRetJ`),
  KEY `fk_Tr_RetJualr_D1` (`KodeGd`),
  KEY `fk_Tr_RetJualr_D2` (`KodeBrg`),
  KEY `fk_Tr_RetJualr_D3` (`TransJual`,`NoJual`,`ItemJual`),
  KEY `fk_Tr_RetJualr_D7` (`TransJual`,`NoJual`,`ItemJual`),
  CONSTRAINT `fk_Tr_RetJualr_D4` FOREIGN KEY (`TransRetJ`, `NoRetJ`) REFERENCES `tr_retjualr_m` (`TransRetJ`, `NoRetJ`) ON DELETE CASCADE,
  CONSTRAINT `fk_Tr_RetJualr_D5` FOREIGN KEY (`KodeGd`) REFERENCES `tm_gudang` (`KodeGd`),
  CONSTRAINT `fk_Tr_RetJualr_D6` FOREIGN KEY (`KodeBrg`) REFERENCES `tm_barang` (`KodeBrg`),
  CONSTRAINT `fk_Tr_RetJualr_D7` FOREIGN KEY (`TransJual`, `NoJual`, `ItemJual`) REFERENCES `tr_jualr_d` (`TransRetail`, `NoJualR`, `ItemJual`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_retjualr_d`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetREtJualRAdd` AFTER INSERT ON `tr_retjualr_d` FOR EACH ROW BEGIN
  Update tm_StockBrg set stockakhir = ifnull(stockakhir,0) + new.jml where kodebrg=new.kodebrg and kodeGd= new.KodeGD;
  update tr_jualR_d set diretur = ifnull(diretur,0) + new.Jml where nojualR = new.nojual and TransRetail=new.Transjual and ItemJual=new.ItemJual;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetREtJualRUpdate` AFTER UPDATE ON `tr_retjualr_d` FOR EACH ROW BEGIN
  Update tm_StockBrg set stockakhir = ifnull(stockakhir,0) - (old.jml-new.jml) where kodebrg=new.kodebrg and kodeGd= new.KodeGD;
  update tr_jualR_d set diretur = ifnull(diretur,0) - (new.jml-old.jml) where nojualR=new.nojual and TransRetail=new.Transjual and ItemJual=new.ItemJual;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetREtJualRDelete` AFTER DELETE ON `tr_retjualr_d` FOR EACH ROW BEGIN
  Update tm_StockBrg set stockakhir = ifnull(stockakhir,0) - old.jml 
  where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD;
  update tr_jualR_d set diretur = ifnull(diretur,0) - Old.Jml
  where nojualR=Old.nojual and TransRetail=Old.Transjual and ItemJual=Old.ItemJual;
end */;;

DELIMITER ;

--
-- Table structure for table `tr_retjualr_m`
--

CREATE TABLE `tr_retjualr_m` (
  `TransRetJ` varchar(2) NOT NULL default '',
  `NoRetJ` varchar(11) NOT NULL default '',
  `TglRetJ` datetime default NULL,
  `TglBatal` datetime default NULL,
  `NamaCust` varchar(50) default NULL,
  `Alamat` varchar(50) default NULL,
  `Kota` varchar(30) default NULL,
  `Keterangan` varchar(200) default NULL,
  `TRansJual` varchar(2) default NULL,
  `NoJual` varchar(11) default NULL,
  `DiscRp` double default NULL,
  `Tambahan` double default NULL,
  `KetTambahan` varchar(50) default NULL,
  `PPN` double default NULL,
  `PPNRps` double default NULL,
  `Nilai` double default NULL,
  `Valas` varchar(10) default NULL,
  `ExRate` double default NULL,
  `Sisa` double default NULL,
  PRIMARY KEY  (`TransRetJ`,`NoRetJ`),
  KEY `fk_Tr_RetJualR_M2` (`TRansJual`,`NoJual`),
  CONSTRAINT `fk_Tr_RetJualR_M2` FOREIGN KEY (`TRansJual`, `NoJual`) REFERENCES `tr_jualr_m` (`TransRetail`, `NoJualR`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_retjualr_m`
--


--
-- Table structure for table `tr_retjualrakitan_d`
--

CREATE TABLE `tr_retjualrakitan_d` (
  `TransRetJ` varchar(2) NOT NULL default '',
  `NoRetJ` varchar(11) NOT NULL default '',
  `ItemRetJ` int(11) NOT NULL default '0',
  `TransJual` varchar(2) default NULL,
  `NoJual` varchar(11) default NULL,
  `ItemJual` int(11) default NULL,
  `KodeBrg` varchar(20) NOT NULL,
  `KodeGd` varchar(5) NOT NULL,
  `Harga` double default NULL,
  `Disc` double default NULL,
  `Jml` double default NULL,
  `Satuan` varchar(10) NOT NULL,
  `Konv` double default NULL,
  PRIMARY KEY  (`TransRetJ`,`NoRetJ`,`ItemRetJ`),
  KEY `fk_Tr_RetJualRakitan_D1` (`KodeGd`),
  KEY `fk_Tr_RetJualRakitan_D2` (`KodeBrg`),
  KEY `fk_Tr_RetJualRakitan_D3` (`TransJual`,`NoJual`,`ItemJual`),
  KEY `fk_Tr_RetJualRakitan_D7` (`TransJual`,`NoJual`,`ItemJual`),
  CONSTRAINT `fk_Tr_RetJualRakitan_D4` FOREIGN KEY (`TransRetJ`, `NoRetJ`) REFERENCES `tr_retjualrakitan_m` (`TransRetJ`, `NoRetJ`) ON DELETE CASCADE,
  CONSTRAINT `fk_Tr_RetJualRakitan_D5` FOREIGN KEY (`KodeGd`) REFERENCES `tm_gudang` (`KodeGd`),
  CONSTRAINT `fk_Tr_RetJualRakitan_D6` FOREIGN KEY (`KodeBrg`) REFERENCES `tm_barang` (`KodeBrg`),
  CONSTRAINT `fk_Tr_RetJualRakitan_D7` FOREIGN KEY (`TransJual`, `NoJual`, `ItemJual`) REFERENCES `tr_jualrakitan_d` (`TransJual`, `NoJual`, `ItemJual`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_retjualrakitan_d`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetREtJualRakitanAdd` AFTER INSERT ON `tr_retjualrakitan_d` FOR EACH ROW BEGIN
  Update tm_StockBrg set stockakhir = ifnull(stockakhir,0) + new.jml where kodebrg=new.kodebrg and kodeGd= new.KodeGD;
  update tr_jualRakitan_d set diretur = ifnull(diretur,0) + new.Jml  where nojual = new.nojual and TransJual=new.Transjual and ItemJual=new.ItemJual;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetREtJualRakitanUpdate` AFTER UPDATE ON `tr_retjualrakitan_d` FOR EACH ROW BEGIN
  Update tm_StockBrg set stockakhir = ifnull(stockakhir,0) + new.jml where kodebrg=new.kodebrg and kodeGd= new.KodeGD;
  Update tm_StockBrg set stockakhir = ifnull(stockakhir,0) - Old.jml where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD;
  update tr_jualrakitan_d set diretur = ifnull(diretur,0) + new.Jml  where nojual = new.nojual and TransJual=new.Transjual and ItemJual=new.ItemJual;
  update tr_jualrakitan_d set diretur = ifnull(diretur,0) - Old.Jml  where nojual = Old.nojual and TransJual=Old.Transjual and ItemJual=Old.ItemJual;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `DetREtJualRakitanDelete` AFTER DELETE ON `tr_retjualrakitan_d` FOR EACH ROW BEGIN
  Update tm_StockBrg set stockakhir = ifnull(stockakhir,0) - Old.jml where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD;
  update tr_jualRakitan_d set diretur = ifnull(diretur,0) - Old.Jml  where nojual = Old.nojual and TransJual=Old.Transjual and ItemJual=Old.ItemJual;
end */;;

DELIMITER ;

--
-- Table structure for table `tr_retjualrakitan_m`
--

CREATE TABLE `tr_retjualrakitan_m` (
  `TransRetJ` varchar(2) NOT NULL default '',
  `NoRetJ` varchar(11) NOT NULL default '',
  `TglRetJ` datetime default NULL,
  `TglBatal` datetime default NULL,
  `KodeCust` varchar(10) default NULL,
  `KodeRakitan` varchar(20) default NULL,
  `jmlrakitan` int(11) default NULL,
  `Keterangan` varchar(200) default NULL,
  `TRansJual` varchar(2) default NULL,
  `NoJual` varchar(11) default NULL,
  `DiscRp` double default NULL,
  `Tambahan` double default NULL,
  `KetTambahan` varchar(50) default NULL,
  `PPN` double default NULL,
  `PPNRps` double default NULL,
  `Nilai` double default NULL,
  `Valas` varchar(10) default NULL,
  `ExRate` double default NULL,
  `Sisa` double default NULL,
  PRIMARY KEY  (`TransRetJ`,`NoRetJ`),
  KEY `fk_Tr_RetJualR_M1` (`KodeCust`),
  KEY `fk_Tr_RetJualR_M2` (`TRansJual`,`NoJual`),
  CONSTRAINT `fk_Tr_RetJualR_M3` FOREIGN KEY (`KodeCust`) REFERENCES `tm_customer` (`KodeCust`),
  CONSTRAINT `fk_Tr_RetJualR_M4` FOREIGN KEY (`TRansJual`, `NoJual`) REFERENCES `tr_jualrakitan_m` (`TransJual`, `NoJual`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_retjualrakitan_m`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `TrRetJualRakitanAdd` AFTER INSERT ON `tr_retjualrakitan_m` FOR EACH ROW BEGIN
Declare vPiutang double;
  select ifnull(Piutang,0) into vPiutang from tm_Customer where kodeCust = new.kodeCust; 
  Update tm_Customer set Piutang =  ifnull(Piutang,0) - new.nilai * new.exrate 
  where kodeCust = new.kodeCust;
  Update tr_Jualrakitan_m set sisa =  ifnull(sisa,0) - new.nilai * new.exrate 
  where TransJual = new.TransJual and NoJual=New.NoJual;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `TrRetJualRakitanUpdate` AFTER UPDATE ON `tr_retjualrakitan_m` FOR EACH ROW BEGIN
Declare vPiutang double;
  select ifnull(Piutang,0) into vPiutang from tm_Customer where kodeCust = new.kodeCust; 
 
  Update tm_Customer set Piutang =  ifnull(Piutang,0) - new.nilai * new.exrate 
  where kodeCust = new.kodeCust;
  Update tm_Customer set Piutang =  ifnull(Piutang,0) + Old.nilai * Old.exrate 
  where kodeCust = Old.kodeCust;
  Update tr_Jualrakitan_m set sisa =  ifnull(sisa,0) - new.nilai * new.exrate 
  where TransJual = new.TransJual and NoJual=New.NoJual;
  Update tr_Jualrakitan_m set sisa =  ifnull(sisa,0) + old.nilai * old.exrate 
  where TransJual = old.TransJual and NoJual=old.NoJual;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `TrRetJualRakitanDelete` AFTER DELETE ON `tr_retjualrakitan_m` FOR EACH ROW BEGIN
  Update tm_Customer set Piutang =  ifnull(Piutang,0) + Old.nilai * Old.exrate 
  where kodeCust = Old.kodeCust;
  Update tr_Jualrakitan_m set sisa =  ifnull(sisa,0) + old.nilai * old.exrate 
  where TransJual = old.TransJual and NoJual=old.NoJual;
end */;;

DELIMITER ;

--
-- Table structure for table `tr_saldocounter`
--

CREATE TABLE `tr_saldocounter` (
  `KodeShift` varchar(15) NOT NULL,
  `KodeMesin` varchar(15) NOT NULL,
  `NoClose` varchar(15) default NULL,
  `UserID` varchar(15) NOT NULL,
  `Tanggal` date NOT NULL,
  `SaldoAwal` int(11) NOT NULL,
  `SaldoAkhir` int(11) NOT NULL,
  `OverShiff` varchar(2) default NULL,
  PRIMARY KEY  (`KodeShift`,`UserID`,`Tanggal`,`KodeMesin`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_saldocounter`
--


--
-- Table structure for table `tr_savetmp`
--

CREATE TABLE `tr_savetmp` (
  `NoJualR` varchar(11) NOT NULL default '',
  `ItemJual` int(11) NOT NULL default '0',
  `KodeBrg` varchar(20) NOT NULL,
  `KodeGd` varchar(5) NOT NULL,
  `NamaBrg` varchar(50) default NULL,
  `Harga` double default NULL,
  `HargaAvg` double default NULL,
  `Disc` double default NULL,
  `DiscPersen` double default NULL,
  `Jml` double default NULL,
  `Satuan` varchar(10) NOT NULL,
  `Konv` double default NULL,
  `Jam` datetime default NULL,
  `priceedits` varchar(1) default NULL,
  `cashr` int(11) default NULL,
  `kasir` varchar(10) default NULL,
  PRIMARY KEY  (`NoJualR`,`ItemJual`),
  KEY `fk_SaveTmp` (`KodeBrg`),
  CONSTRAINT `fk_SaveTmp` FOREIGN KEY (`KodeBrg`) REFERENCES `tm_barang` (`KodeBrg`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_savetmp`
--


--
-- Table structure for table `tr_savetmpgrosir`
--

CREATE TABLE `tr_savetmpgrosir` (
  `NoJual` varchar(20) NOT NULL,
  `ItemJual` int(11) NOT NULL default '0',
  `kodebrg` varchar(15) default NULL,
  `kodegd` varchar(10) default NULL,
  `namabrg` varchar(50) default NULL,
  `harga` double default NULL,
  `hargaavg` double default NULL,
  `disc` double default NULL,
  `discpersen` double default NULL,
  `jml` double default NULL,
  `satuan` varchar(30) default NULL,
  `konv` double default NULL,
  `jam` time default NULL,
  `priceedits` double default NULL,
  `Kasir` varchar(50) default NULL,
  `Kodecust` varchar(15) default NULL,
  `NamaCust` varchar(50) default NULL,
  `AlamatCust` varchar(50) default NULL,
  PRIMARY KEY  (`NoJual`,`ItemJual`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_savetmpgrosir`
--


--
-- Table structure for table `tr_scrbayarbeli`
--

CREATE TABLE `tr_scrbayarbeli` (
  `NoBayarB` varchar(11) NOT NULL default '',
  `ItemSBayarB` int(11) NOT NULL default '0',
  `TransBeli` varchar(2) default NULL,
  `NoBeli` varchar(11) default NULL,
  `Nilai` double default NULL,
  `Valas` varchar(10) default NULL,
  `ExRate` double default NULL,
  PRIMARY KEY  (`NoBayarB`,`ItemSBayarB`),
  KEY `fk_tr_ScrBayarBeli` (`NoBayarB`),
  KEY `fk_tr_ScrBayarBeli1` (`TransBeli`,`NoBeli`),
  CONSTRAINT `fk_tr_ScrBayarBeli` FOREIGN KEY (`NoBayarB`) REFERENCES `tr_bayarbeli_m` (`NoBayarB`) ON DELETE CASCADE,
  CONSTRAINT `fk_tr_ScrBayarBeli1` FOREIGN KEY (`TransBeli`, `NoBeli`) REFERENCES `tr_beli_m` (`TransBeli`, `NoBeli`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_scrbayarbeli`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `ScrBayarBeliAdd` AFTER INSERT ON `tr_scrbayarbeli` FOR EACH ROW BEGIN
declare vTransbeli varchar (2);
DECLARE vNoBeli varchar (11);
DECLARE vNilai double; 
DECLARE vTglBatal datetime;
Declare vKodeSupp varchar(10);
declare vNoBayar varchar(11);
declare vExrate integer;
select ifnull(TransBeli,''), ifnull(NoBeli,''), ifnull(Nilai,0), ifnull(ExRate,1) into  vTransbeli, vNoBeli, vNilai ,vexrate 
from Tr_ScrBayarBeli where NoBayarB = new.NobayarB and ItemSBayarB=new.ItemSBayarB;
select Tglbatal,KodeSupp into vTglbatal,vKodeSupp from tr_BayarBeli_M where NoBayarB=new.NoBayarB;
if ifnull(vTglBatal,'')='' then
 update tr_beli_m set Sisa=ifnull(Sisa,0)-new.Nilai where NoBeli=vNoBeli and TransBeli=vTransBeli;
 update tM_Supplier set hutang= ifnull(Hutang,0)-new.Nilai*new.ExRate where KodeSupp=vKodeSupp;
END if;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `ScrBayarBeliUpdate` AFTER UPDATE ON `tr_scrbayarbeli` FOR EACH ROW BEGIN
declare vTransBelibaru varchar(2);
DECLARE vNoBeliBaru varchar(11);
DECLARE vNilaiBaru double; 
DECLARE vTglBatal datetime;
Declare vKodeSupp varchar(10);
declare vNoBayar varchar(11);
declare vExrateBaru integer;
declare vExrateLama integer;
declare vTransBelilama varchar(2);
declare vNoBeliLama varchar(11);
DECLARE vNilaiLama double; 
select ifnull(TransBeli,''), ifnull(NoBeli,''), ifnull(Nilai,0), ifnull(ExRate,1) into  vTransbeliBaru, vNoBeliBaru, vNilaiBaru ,vexrateBaru 
from Tr_ScrBayarBeli where NoBayarB = new.NobayarB and ItemSBayarB=new.ItemSBayarB;
select Tglbatal,KodeSupp into vTglbatal,vKodeSupp from tr_BayarBeli_M where NoBayarB=new.NoBayarB;
if ifnull(vTglBatal,'')='' then
 update tr_beli_m set Sisa=ifnull(Sisa,0)+Old.Nilai where NoBeli=Old.NoBeli and TransBeli=Old.TransBeli;
 update tr_beli_m set Sisa=ifnull(Sisa,0)-New.Nilai where NoBeli=New.NoBeli and TransBeli=New.TransBeli;
 update tM_Supplier set hutang= ifnull(Hutang,0)+(Old.Nilai*Old.ExRate ) where KodeSupp=vKodeSupp;
 update tM_Supplier set hutang= ifnull(Hutang,0)-(New.Nilai*New.ExRate) where KodeSupp=vKodeSupp;
END if;
end */;;

/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `ScrBayarBeliDelete` AFTER DELETE ON `tr_scrbayarbeli` FOR EACH ROW BEGIN

declare vTransBelibaru varchar(2);

DECLARE vNoBeliBaru varchar(11);

DECLARE vNilaiBaru double; 

DECLARE vTglBatal datetime;

Declare vKodeSupp varchar(10);

declare vNoBayar varchar(11);

declare vExrateBaru integer;

declare vExrateLama integer;

declare vTransBelilama varchar(2);

declare vNoBeliLama varchar(11);

DECLARE vNilaiLama double; 

select ifnull(TransBeli,''), ifnull(NoBeli,''), ifnull(Nilai,0), ifnull(ExRate,1) into  vTransbeliBaru, vNoBeliBaru, vNilaiBaru ,vexrateBaru 

from Tr_ScrBayarBeli where NoBayarB = Old.NobayarB and ItemSBayarB=old.ItemSBayarB;

select Tglbatal,KodeSupp into vTglbatal,vKodeSupp from tr_BayarBeli_M where NoBayarB=Old.NoBayarB;

if ifnull(vTglBatal,'')='' then

 update tr_beli_m set Sisa=ifnull(Sisa,0)+Old.Nilai  where NoBeli=Old.NoBeli and TransBeli=Old.TransBeli;

 update tM_Supplier set hutang= ifnull(Hutang,0)+(Old.Nilai*Old.ExRate)  where KodeSupp=vKodeSupp;

END if;

end */;;

DELIMITER ;

--
-- Table structure for table `tr_scrbayarjual`
--

CREATE TABLE `tr_scrbayarjual` (
  `NoBayarJ` varchar(11) NOT NULL default '',
  `ItemSBayarJ` int(11) NOT NULL default '0',
  `TransJual` varchar(2) default NULL,
  `NoJual` varchar(11) default NULL,
  `Nilai` double default NULL,
  `Valas` varchar(10) default NULL,
  `ExRate` double default NULL,
  PRIMARY KEY  (`NoBayarJ`,`ItemSBayarJ`),
  KEY `fk_tr_ScrBayarJual1` (`NoBayarJ`),
  KEY `fk_tr_ScrBayarJual2` (`TransJual`,`NoJual`),
  CONSTRAINT `fk_tr_ScrBayarJual3` FOREIGN KEY (`NoBayarJ`) REFERENCES `tr_bayarjual_m` (`NoBayarJ`) ON DELETE CASCADE,
  CONSTRAINT `fk_tr_ScrBayarJual4` FOREIGN KEY (`TransJual`, `NoJual`) REFERENCES `tr_jual_m` (`TransJual`, `NoJual`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_scrbayarjual`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `ScrBayarJualAdd` AFTER INSERT ON `tr_scrbayarjual` FOR EACH ROW BEGIN
declare vTransJual varchar (2);
DECLARE vNoJual varchar (11);
DECLARE vNilai double; 
DECLARE vTglBatal datetime;
Declare vKodeCust varchar(10);
declare vNoBayar varchar(11);
declare vExrate integer;
select Tglbatal,KodeCust into vTglbatal,vKodeCust from tr_BayarJual_M where NoBayarJ=new.NoBayarJ;
  Update tr_jual_m set sisa =  ifnull(sisa,0) - new.nilai * new.exrate 
  where TransJual = New.TransJual and NoJual=New.NoJual;
  Update tm_customer set piutang =  ifnull(piutang,0) - new.nilai * new.exrate 
  where KodeCust = vKodeCust;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `ScrBayarJualUpdate` AFTER UPDATE ON `tr_scrbayarjual` FOR EACH ROW BEGIN
declare vTransJual varchar (2);
DECLARE vNoJual varchar (11);
DECLARE vNilai double; 
DECLARE vTglBatal datetime;
Declare vKodeCust varchar(10);
declare vNoBayar varchar(11);
declare vExrate integer;
select Tglbatal,KodeCust into vTglbatal,vKodeCust from tr_BayarJual_M where NoBayarJ=new.NoBayarJ;
  Update tr_jual_m set sisa =  ifnull(sisa,0) - new.nilai * new.exrate 
  where TransJual = New.TransJual and NoJual=New.NoJual;
  Update tr_jual_m set sisa =  ifnull(sisa,0) + old.nilai * old.exrate 
  where TransJual = old.TransJual and NoJual = old.NoJual;
  Update tm_customer set piutang =  ifnull(piutang,0) - new.nilai * new.exrate 
  where KodeCust = vKodeCust;
  Update tm_customer set piutang =  ifnull(piutang,0) + old.nilai * old.exrate 
  where KodeCust = vKodeCust;
end */;;

/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `ScrBayarJualDelete` AFTER DELETE ON `tr_scrbayarjual` FOR EACH ROW BEGIN

declare vTransJual varchar (2);

DECLARE vNoJual varchar (11);

DECLARE vNilai double; 

DECLARE vTglBatal datetime;

Declare vKodeCust varchar(10);

declare vNoBayar varchar(11);

declare vExrate integer;

select Tglbatal,KodeCust into vTglbatal,vKodeCust from tr_BayarJual_M where NoBayarJ=Old.NoBayarJ;

  Update tr_jual_m set sisa =  ifnull(sisa,0) + old.nilai * old.exrate 

  where TransJual = old.TransJual and NoJual = old.NoJual;

 Update tm_customer set piutang =  ifnull(piutang,0) + old.nilai * old.exrate 

  where KodeCust = vKodeCust;

end */;;

DELIMITER ;

--
-- Table structure for table `tr_scrbayarjualrakitan`
--

CREATE TABLE `tr_scrbayarjualrakitan` (
  `NoBayarJ` varchar(11) NOT NULL default '',
  `ItemSBayarJ` int(11) NOT NULL default '0',
  `TransJual` varchar(2) default NULL,
  `NoJual` varchar(11) default NULL,
  `Nilai` double default NULL,
  `Valas` varchar(10) default NULL,
  `ExRate` double default NULL,
  PRIMARY KEY  (`NoBayarJ`,`ItemSBayarJ`),
  KEY `fk_tr_ScrBayarJualrakitan1` (`NoBayarJ`),
  KEY `fk_tr_ScrBayarJualrakitan2` (`TransJual`,`NoJual`),
  CONSTRAINT `fk_tr_ScrBayarJualrakitan3` FOREIGN KEY (`NoBayarJ`) REFERENCES `tr_bayarjualrakitan_m` (`NoBayarJ`) ON DELETE CASCADE,
  CONSTRAINT `fk_tr_ScrBayarJualrakitan4` FOREIGN KEY (`TransJual`, `NoJual`) REFERENCES `tr_jualrakitan_m` (`TransJual`, `NoJual`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_scrbayarjualrakitan`
--


DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `ScrBayarJualRakitanAdd` AFTER INSERT ON `tr_scrbayarjualrakitan` FOR EACH ROW BEGIN
declare vTransJual varchar (2);
DECLARE vNoJual varchar (11);
DECLARE vNilai double; 
DECLARE vTglBatal datetime;
Declare vKodeCust varchar(10);
declare vNoBayar varchar(11);
declare vExrate integer;
select Tglbatal,KodeCust into vTglbatal,vKodeCust from tr_BayarJualRakitan_M where NoBayarJ=new.NoBayarJ;
  Update tr_JualRakitan_m set sisa =  ifnull(sisa,0) - new.nilai * new.exrate 
  where TransJual = New.TransJual and NoJual=New.NoJual;
  Update tm_customer set piutang =  ifnull(piutang,0) - new.nilai * new.exrate 
  where KodeCust = vKodeCust;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `ScrBayarJualRakitanUpdate` AFTER UPDATE ON `tr_scrbayarjualrakitan` FOR EACH ROW BEGIN
declare vTransJual varchar (2);
DECLARE vNoJual varchar (11);
DECLARE vNilai double; 
DECLARE vTglBatal datetime;
Declare vKodeCust varchar(10);
declare vNoBayar varchar(11);
declare vExrate integer;
select Tglbatal,KodeCust into vTglbatal,vKodeCust from tr_BayarJualRakitan_M where NoBayarJ=new.NoBayarJ;
  Update tr_JualRakitan_m set sisa =  ifnull(sisa,0) - new.nilai * new.exrate 
  where TransJual = New.TransJual and NoJual=New.NoJual;
  Update tr_JualRakitan_m set sisa =  ifnull(sisa,0) + old.nilai * old.exrate 
  where TransJual = old.TransJual and NoJual = old.NoJual;
  Update tm_customer set piutang =  ifnull(piutang,0) - new.nilai * new.exrate 
  where KodeCust = vKodeCust;
  Update tm_customer set piutang =  ifnull(piutang,0) + old.nilai * old.exrate 
  where KodeCust = vKodeCust;
end */;;

/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `ScrBayarJualRakitanDelete` AFTER DELETE ON `tr_scrbayarjualrakitan` FOR EACH ROW BEGIN
declare vTransJual varchar (2);
DECLARE vNoJual varchar (11);
DECLARE vNilai double; 
DECLARE vTglBatal datetime;
Declare vKodeCust varchar(10);
declare vNoBayar varchar(11);
declare vExrate integer;
select Tglbatal,KodeCust into vTglbatal,vKodeCust from tr_BayarJualRakitan_M where NoBayarJ=Old.NoBayarJ;
  Update tr_JualRakitan_m set sisa =  ifnull(sisa,0) + old.nilai * old.exrate 
  where TransJual = old.TransJual and NoJual = old.NoJual;
  Update tm_customer set piutang =  ifnull(piutang,0) + old.nilai * old.exrate 
  where KodeCust = vKodeCust;
end */;;

DELIMITER ;

--
-- Table structure for table `tr_scrmodx`
--

CREATE TABLE `tr_scrmodx` (
  `NoModx` varchar(11) NOT NULL default '',
  `ItemModX` int(11) NOT NULL default '0',
  `Kodebrg` varchar(20) NOT NULL,
  `KodeGd` varchar(5) NOT NULL,
  `Jumlah` double default NULL,
  `Satuan` varchar(10) NOT NULL,
  `Konv` double default NULL,
  `BagHarga` double default NULL,
  PRIMARY KEY  (`NoModx`,`ItemModX`),
  KEY `fk_SCRModX2` (`Kodebrg`),
  KEY `fk_SCRModX3` (`KodeGd`),
  CONSTRAINT `fk_ScrModX1` FOREIGN KEY (`NoModx`) REFERENCES `tr_modx` (`NoModX`) ON DELETE CASCADE,
  CONSTRAINT `fk_SCRModX2` FOREIGN KEY (`Kodebrg`) REFERENCES `tm_barang` (`KodeBrg`),
  CONSTRAINT `fk_SCRModX3` FOREIGN KEY (`KodeGd`) REFERENCES `tm_gudang` (`KodeGd`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tr_scrmodx`
--


--
-- Table structure for table `tuser`
--

CREATE TABLE `tuser` (
  `UserId` varchar(10) NOT NULL default '0',
  `UserName` varchar(25) default NULL,
  `Password` varchar(30) default NULL,
  `HakAkses` varchar(50) default NULL,
  `SuperUser` enum('Y','N','') default NULL,
  `IpLogin` varchar(15) default NULL,
  PRIMARY KEY  (`UserId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tuser`
--

INSERT INTO `tuser` VALUES ('adm','adm','ßrãG©—;ž>‘HH ','01','N','*'),('alkes','pemindah barang','`›UAF®—IÜG9ä‰<Mó','03','N','*'),('asp','asp','	I`¨ÈE¤½#E3úc','01','Y','*'),('dimensi','dimensi','®ÞÅ’saDD“ò0,&›','01','Y','*'),('link','link','','01','Y','*'),('yenny','yenny','ÄèLÖXøL€ŽÜ5à´¸Ù','01','Y','*');

--
-- Table structure for table `tuserlevel`
--

CREATE TABLE `tuserlevel` (
  `userlevel_id` varchar(2) NOT NULL,
  `menu` varchar(6) NOT NULL,
  `status` varchar(1) default NULL,
  `Ket_level` varchar(20) default NULL,
  PRIMARY KEY  (`userlevel_id`,`menu`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tuserlevel`
--

INSERT INTO `tuserlevel` VALUES ('01','010000','1','Admin'),('01','010100','1','Admin'),('01','010200','1','Admin'),('01','010300','1','Admin'),('01','010400','1','Admin'),('01','010500','1','Admin'),('01','010600','1','Admin'),('01','010700','1','Admin'),('01','010800','1','Admin'),('01','010900','1','Admin'),('01','020000','1','Admin'),('01','020100','1','Admin'),('01','020200','1','Admin'),('01','020300','1','Admin'),('01','020400','1','Admin'),('01','020500','1','Admin'),('01','020600','1','Admin'),('01','020700','1','Admin'),('01','020800','1','Admin'),('01','020900','1','Admin'),('01','021000','0','Admin'),('01','030000','1','Admin'),('01','030100','1','Admin'),('01','040000','1','Admin'),('01','040100','1','Admin'),('01','040101','1','Admin'),('01','040102','1','Admin'),('01','040200','1','Admin'),('01','040201','1','Admin'),('01','040202','1','Admin'),('01','040300','1','Admin'),('01','040301','1','Admin'),('01','040302','1','Admin'),('01','040303','1','Admin'),('01','040304','1','Admin'),('01','040305','1','Admin'),('01','040306','1','Admin'),('01','040307','1','Admin'),('01','040308','1','Admin'),('01','040400','1','Admin'),('01','040401','1','Admin'),('01','040402','1','Admin'),('01','040500','1','Admin'),('01','040501','1','Admin'),('01','040502','1','Admin'),('01','040600','1','Admin'),('01','040601','1','Admin'),('01','040602','1','Admin'),('01','040603','1','Admin'),('01','040700','1','Admin'),('01','040701','1','Admin'),('01','040702','1','Admin'),('01','040703','1','Admin'),('01','040800','1','Admin'),('01','040801','1','Admin'),('01','040802','1','Admin'),('01','050000','1','Admin'),('01','050100','1','Admin'),('01','050101','1','Admin'),('01','050102','1','Admin'),('01','050200','1','Admin'),('01','050201','1','Admin'),('01','050202','1','Admin'),('01','050300','1','Admin'),('01','050301','1','Admin'),('01','050302','1','Admin'),('01','050400','1','Admin'),('01','050401','1','Admin'),('01','050402','1','Admin'),('01','050500','1','Admin'),('01','050501','1','Admin'),('01','050502','1','Admin'),('01','050600','1','Admin'),('01','050601','1','Admin'),('01','050602','1','Admin'),('01','050700','1','Admin'),('01','050701','1','Admin'),('01','050702','1','Admin'),('01','050800','0','Admin'),('01','050801','1','Admin'),('01','050802','1','Admin'),('01','050803','1','Admin'),('01','050900','0','Admin'),('01','050901','1','Admin'),('01','050902','1','Admin'),('01','051000','1','Admin'),('01','051001','1','Admin'),('01','051002','1','Admin'),('01','051100','1','Admin'),('01','051101','1','Admin'),('01','051102','1','Admin'),('01','060000','1','Admin'),('01','060100','1','Admin'),('01','060101','1','Admin'),('01','060102','1','Admin'),('01','060103','1','Admin'),('01','060104','1','Admin'),('01','060105','1','Admin'),('01','060106','1','Admin'),('01','060107','1','Admin'),('01','060108','1','Admin'),('01','060109','1','Admin'),('01','060200','1','Admin'),('01','060300','1','Admin'),('01','060400','1','Admin'),('01','060401','1','Admin'),('01','060402','1','Admin'),('01','060403','1','Admin'),('01','060500','1','Admin'),('01','060501','1','Admin'),('01','060502','1','Admin'),('01','060503','1','Admin'),('01','060600','1','Admin'),('01','060601','1','Admin'),('01','060602','1','Admin'),('01','060603','1','Admin'),('01','060604','1','Admin'),('01','060700','1','Admin'),('01','060701','1','Admin'),('01','060702','1','Admin'),('01','060703','1','Admin'),('01','060800','1','Admin'),('01','060801','1','Admin'),('01','060802','1','Admin'),('01','060900','1','Admin'),('01','060901','1','Admin'),('01','060902','1','Admin'),('01','060903','1','Admin'),('01','060904','1','Admin'),('01','061000','0','Admin'),('01','061001','1','Admin'),('01','061002','1','Admin'),('01','061003','1','Admin'),('01','061004','1','Admin'),('01','061100','1','Admin'),('01','061101','1','Admin'),('01','061102','1','Admin'),('01','061103','1','Admin'),('01','070000','1','Admin'),('01','070100','1','Admin'),('01','070200','1','Admin'),('01','070300','1','Admin'),('01','070400','1','Admin'),('01','070500','1','Admin'),('01','070600','1','Admin'),('01','070700','1','Admin'),('01','080000','1','Admin'),('01','080100','1','Admin'),('01','080200','1','Admin'),('01','080300','1','Admin'),('01','090000','1','Admin'),('01','090100','1','Admin'),('01','090101','1','Admin'),('01','090102','1','Admin'),('01','090200','1','Admin'),('01','090201','1','Admin'),('01','090202','1','Admin'),('01','090203','1','Admin'),('01','090300','1','Admin'),('01','090301','1','Admin'),('01','090302','1','Admin'),('01','100000','1','Admin'),('01','100101','1','Admin'),('01','100102','1','Admin'),('01','110000','1','Admin'),('02','010000','1',''),('02','010100','1',''),('02','010200','1',''),('02','010300','1',''),('02','010400','1',''),('02','010500','1',''),('02','010600','1',''),('02','010700','1',''),('02','010900','1',''),('02','020000','1',''),('02','020100','1',''),('02','020200','1',''),('02','020300','1',''),('02','020400','1',''),('02','020500','1',''),('02','020600','1',''),('02','020700','1',''),('02','020800','1',''),('02','020900','1',''),('02','021000','1','Kasir'),('02','030000','1',''),('02','030100','1',''),('02','040000','1',''),('02','040100','1',''),('02','040101','1',''),('02','040102','1',''),('02','040200','1',''),('02','040201','1',''),('02','040202','1',''),('02','040300','1',''),('02','040301','1',''),('02','040302','1',''),('02','040400','1',''),('02','040401','1',''),('02','040402','1',''),('02','040500','1',''),('02','040501','1',''),('02','040502','1',''),('02','050000','1',''),('02','050100','1',''),('02','050101','1',''),('02','050102','1',''),('02','050200','1',''),('02','050201','1',''),('02','050202','1',''),('02','050301','0','Kasir'),('02','050302','0','Kasir'),('02','050400','1',''),('02','050401','1',''),('02','050402','1',''),('02','050500','1',''),('02','050501','1',''),('02','050502','1',''),('02','050600','1',''),('02','050601','1',''),('02','050602','1',''),('02','050700','1',''),('02','050701','1',''),('02','050702','1',''),('02','050800','1',''),('02','050801','1',''),('02','050802','1',''),('02','050803','1',''),('02','050900','1',''),('02','050901','1',''),('02','050902','1',''),('02','051000','1',''),('02','051001','1',''),('02','051002','1',''),('02','051100','1','Kasir'),('02','051101','1','Kasir'),('02','051102','1','Kasir'),('02','060000','1',''),('02','060100','1',''),('02','060101','1',''),('02','060102','1',''),('02','060103','1',''),('02','060104','1',''),('02','060105','1',''),('02','060106','1',''),('02','060107','1',''),('02','060108','1',''),('02','060200','1',''),('02','060300','1',''),('02','060400','1',''),('02','060401','1',''),('02','060402','1',''),('02','060500','1',''),('02','060501','1',''),('02','060502','1',''),('02','060503','1',''),('02','060600','1',''),('02','060601','1',''),('02','060602','1',''),('02','060603','1',''),('02','060700','1',''),('02','060701','1',''),('02','060702','1',''),('02','060703','1',''),('02','060800','1',''),('02','060801','1',''),('02','060802','1',''),('02','060900','1',''),('02','060901','1','Kasir'),('02','060902','1',''),('02','060903','1',''),('02','060904','1',''),('02','061000','1',''),('02','061001','1',''),('02','061002','1',''),('02','061003','1',''),('02','061004','1',''),('02','061100','1',''),('02','061101','1',''),('02','061102','1',''),('02','070000','1',''),('02','070100','1',''),('02','070200','1',''),('02','070400','1',''),('02','070500','1',''),('02','070600','1',''),('02','080000','1',''),('02','080100','1',''),('02','080200','1',''),('02','080300','1',''),('02','090000','1',''),('02','090100','1',''),('02','090101','1',''),('02','090102','1',''),('02','090200','0','Kasir'),('02','090201','0','Kasir'),('02','090202','0','Kasir'),('02','100000','1',''),('02','110000','1',''),('03','010000','1','pemindah barang'),('03','010100','1','pemindah barang'),('03','010200','1','pemindah barang'),('03','050000','1','pemindah barang'),('03','050200','1','pemindah barang'),('03','050201','1','pemindah barang'),('03','050202','1','pemindah barang'),('03','050400','1','pemindah barang'),('03','050401','1','pemindah barang'),('03','050402','1','pemindah barang'),('03','090000','1','pemindah barang'),('03','090100','1','pemindah barang'),('03','090101','1','pemindah barang'),('03','090102','1','pemindah barang'),('03','110000','1','pemindah barang');

--
-- Table structure for table `userlog`
--

CREATE TABLE `userlog` (
  `tgllog` date NOT NULL default '0000-00-00',
  `jamlog` time NOT NULL default '00:00:00',
  `log` char(255) NOT NULL default '',
  `user` char(65) NOT NULL default '',
  `userip` char(15) NOT NULL default '',
  `userhost` char(60) NOT NULL default '',
  KEY `Index_tgl` (`tgllog`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `userlog`
--

INSERT INTO `userlog` VALUES ('2025-05-02','15:14:51','Login','asp - asp','192.168.1.60',''),('2025-05-06','09:16:05','Login','asp - asp','192.168.1.50',''),('2025-05-06','10:36:37','Login','asp - asp','192.168.1.60','');

--
-- Table structure for table `userlogbaru`
--

CREATE TABLE `userlogbaru` (
  `tgllog` date NOT NULL default '0000-00-00',
  `jamlog` time NOT NULL default '00:00:00',
  `log` char(255) NOT NULL default '',
  `user` char(65) NOT NULL default '',
  `userip` char(15) NOT NULL default '',
  `userhost` char(60) NOT NULL default '',
  KEY `Index_tgl` (`tgllog`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `userlogbaru`
--


--
-- Table structure for table `v_stockbrg`
--

CREATE TABLE `v_stockbrg` (
  `KodeBrg` varchar(50) default NULL,
  `Namabrg` varchar(200) default NULL,
  `StockAkhir` decimal(10,0) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `v_stockbrg`
--


--
-- Table structure for table `vcashflow`
--

CREATE TABLE `vcashflow` (
  `Jns_jurnal` varchar(10) default NULL,
  `Tanggal` date default NULL,
  `Tgl_Validasi` date default NULL,
  `No_bukti` varchar(14) default NULL,
  `Row_id` int(11) default NULL,
  `Keterangan` varchar(90) default NULL,
  `penerima` varchar(50) default NULL,
  `Pst` tinyint(4) default NULL,
  `Tgl_Edit` datetime default NULL,
  `User` varchar(25) default NULL,
  `Sandi_trans_id` varchar(2) default NULL,
  `Norek_Simp` varchar(10) default NULL,
  `Norek_Pinj` varchar(10) default NULL,
  `Norek_Dep` varchar(10) default NULL,
  `Status_Val` varchar(1) default NULL,
  `Status_AB` varchar(1) default NULL,
  `Nobukti_Rtl` varchar(11) default NULL,
  `Kode_perk` varchar(15) default NULL,
  `Debet` double default NULL,
  `Kode_divisi` varchar(10) default NULL,
  `Kredit` double default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `vcashflow`
--


--
-- Table structure for table `vtemp_kodebrg`
--

CREATE TABLE `vtemp_kodebrg` (
  `KodeBrg` varchar(20) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `vtemp_kodebrg`
--

INSERT INTO `vtemp_kodebrg` VALUES ('210000051'),('210000054'),('210000053'),('210000067'),('210000055'),('210000090'),('210000059'),('210000057'),('210000077'),('210000079'),('210000076'),('210000083'),('210000075'),('210000078'),('210000174'),('210000074'),('210000080'),('210000175'),('210000086'),('210000082'),('210000137'),('210000058'),('210000056'),('210000130'),('210000210'),('210000304'),('210000217'),('210000216'),('210000219'),('210000218'),('210000220'),('210000302'),('210000298'),('210000359'),('210000310'),('210000221'),('210000326'),('210000414'),('210000422'),('210000423'),('210000435'),('210000436'),('210000437'),('210000439'),('210000440'),('210000441'),('210000442'),('210000443'),('210000456'),('210000462'),('210000458'),('210000461'),('210000463'),('210000457'),('210000417'),('210000001'),('210000002'),('210000003'),('210000004'),('210000005'),('210000006'),('210000007'),('210000008'),('210000009'),('210000010'),('210000011'),('210000012'),('210000013'),('210000014'),('210000015'),('210000016'),('210000017'),('210000018'),('210000019'),('210000020'),('210000021'),('210000022'),('210000023'),('210000024'),('210000025'),('210000026'),('210000027'),('210000028'),('210000029'),('210000030'),('210000031'),('210000032'),('210000033'),('210000034'),('210000035'),('210000036'),('210000037'),('210000038'),('210000039'),('210000040'),('210000041'),('210000042'),('210000043'),('210000044'),('210000045'),('210000046'),('210000047'),('210000048'),('210000049'),('210000050'),('210000051'),('210000052'),('210000053'),('210000054'),('210000055'),('210000056'),('210000057'),('210000058'),('210000059'),('210000060'),('210000061'),('210000062'),('210000063'),('210000064'),('210000065'),('210000066'),('210000067'),('210000068'),('210000069'),('210000069'),('210000070'),('210000071'),('210000072'),('210000073'),('210000074'),('210000075'),('210000076'),('210000077'),('210000078'),('210000079'),('210000080'),('210000081'),('210000082'),('210000083'),('210000085'),('210000086'),('210000087'),('210000088'),('210000089'),('210000090'),('210000091'),('210000092'),('210000093'),('210000094'),('210000095'),('210000096'),('210000097'),('210000098'),('210000099'),('210000100'),('210000101'),('210000102'),('210000103'),('210000104'),('210000105'),('210000106'),('210000107'),('210000108'),('210000109'),('210000110'),('210000111'),('210000112'),('210000113'),('210000114'),('210000115'),('210000116'),('210000117'),('210000118'),('210000119'),('210000120'),('210000121'),('210000122'),('210000123'),('210000124'),('210000125'),('210000126'),('210000127'),('210000128'),('210000129'),('210000130'),('210000131'),('210000132'),('210000133'),('210000134'),('210000135'),('210000136'),('210000137'),('210000138'),('210000139'),('210000140'),('210000141'),('210000142'),('210000143'),('210000144'),('210000145'),('210000146'),('210000147'),('210000148'),('210000149'),('210000150'),('210000151'),('210000152'),('210000153'),('210000154'),('210000155'),('210000156'),('210000157'),('210000158'),('210000159'),('210000160'),('210000161'),('210000162'),('210000163'),('210000164'),('210000165'),('210000166'),('210000167'),('210000168'),('210000169'),('210000170'),('210000171'),('210000172'),('210000173'),('210000174'),('210000175'),('210000176'),('210000177'),('210000178'),('210000179'),('210000180'),('210000181'),('210000182'),('210000183'),('210000184'),('210000185'),('210000186'),('210000187');

--
-- Dumping routines for database 'dbbarokahjy'
--
DELIMITER ;;
/*!50003 DROP FUNCTION IF EXISTS `AngkaKeString` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `AngkaKeString`(sAngka DECIMAL(15,2)) RETURNS varchar(50) CHARSET latin1
BEGIN
	DECLARE sString VARCHAR(20);
	SELECT CONCAT(REPLACE(FORMAT(FLOOR(sAngka),0),",","."), REPLACE(RIGHT(REPLACE(FORMAT(sAngka,2),",","."),3),".",",")) INTO sString;
	RETURN sString;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP FUNCTION IF EXISTS `BuatNo` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `BuatNo`(Nama Varchar(20),Codes varchar(2),Tgl Varchar(10),Trans varchar(2),NoBaru varchar(11)) RETURNS char(11) CHARSET latin1
BEGIN
  DECLARE yy Varchar(2) DEFAULT 0;
  DECLARE mm Varchar(2) DEFAULT 0;
  DECLARE dd Varchar(2) DEFAULT 0;
  DECLARE NoInt Integer DEFAULT 0;
  DECLARE NoStr Varchar(11) DEFAULT 0;
  DECLARE Nomer Varchar(11) DEFAULT 0;
  DECLARE thn Varchar(6) DEFAULT 0;
  DECLARE TipeNo Integer DEFAULT 0;
  Set yy=Substring(tgl,3,2);
  Set mm=Substring(tgl,6,2);
  Set dd=Substring(tgl,9,2);
  Select ifnull(nilainum,1) into TipeNo from tm_setupall where groups='Nomor' and subgroups=Codes;
  If (TipeNo=0) or (TipeNo=1) then
     select if(ifnull(substring(nilaichar,3,6),0)='',0,ifnull(substring(nilaichar,3,6),0)),ifnull(nilaichar,'00') into NoInt,Nomer from tm_setupall where groups='Nomor' and subgroups=Codes;
     set thn=substring(nomer,1,2);
     if thn=yy then
        set NoInt=NoInt+1;
        set NoStr=NoInt;
        set NoBaru=concat(yy,REPEAT('0',6-length(NoStr)),NoStr);
     else
        case upper(Nama)
             when upper('Tr_Beli') then select ifnull(max(substring(noBeli,3,6)),0) into NoInt from TR_Beli_m where left(NoBeli,2)=yy and transBeli=Trans;
             when upper('Tr_HasilProduksi') then select ifnull(max(substring(noProduksi,3,6)),0) into NoInt from TR_HasilProduksi_m where left(NoProduksi,2)=yy and transProd=Trans;
             when upper('Tr_Jual') then select ifnull(max(substring(noJual,3,6)),0) into NoInt from TR_Jual_m where left(NoJual,2)=yy and TransJual=Trans;
             when upper('Tr_JualR') then select ifnull(max(substring(noJualR,3,6)),0) into NoInt from TR_JualR_m where left(NoJualR,2)=yy and TransRetail=Trans;
             when upper('Tr_JualRakitan') then select ifnull(max(substring(noJual,3,6)),0) into NoInt from TR_JualRakitan_m where left(NoJual,2)=yy and TransJual=Trans;
             when upper('Tr_BayarBeli') then select ifnull(max(substring(noBayarB,3,6)),0) into NoInt from TR_BayarBeli_m where left(NoBayarB,2)=yy;
             when upper('Tr_BayarJual') then select ifnull(max(substring(noBayarJ,3,6)),0) into NoInt from TR_BayarJual_m where left(NoBayarJ,2)=yy;
             when upper('Tr_BayarJualRakitan') then select ifnull(max(substring(noBayarJ,3,6)),0) into NoInt from TR_BayarJualRakitan_m where left(NoBayarJ,2)=yy;
             when upper('Tr_RetBeli') then select ifnull(max(substring(noRetB,3,6)),0) into NoInt from TR_RetBeli_m where left(NoRetB,2)=yy and TransRetB=Trans;
             when upper('Tr_RetJual') then select ifnull(max(substring(noRetJ,3,6)),0) into NoInt from TR_RetJual_m where left(NoRetJ,2)=yy and TransRetJ=Trans;
             when upper('Tr_RetJualR') then select ifnull(max(substring(noRetJ,3,6)),0) into NoInt from TR_RetJualR_m where left(NoRetJ,2)=yy and TransRetJ=Trans;
             when upper('Tr_RetJualRakitan') then select ifnull(max(substring(noRetJ,3,6)),0) into NoInt from TR_RetJualRakitan_m where left(NoRetJ,2)=yy and TransRetJ=Trans;
             when upper('Tr_PoJual') then select ifnull(max(substring(nopo,3,6)),0) into NoInt from TR_PoJual_m where left(NoPo,2)=yy;
             when upper('Tr_PoJualRakitan') then select ifnull(max(substring(nopo,3,6)),0) into NoInt from TR_PoJualRakitan_m where left(NoPo,2)=yy;
             when upper('Tr_PIndahGd') then select ifnull(max(substring(noPindahGd,3,6)),0) into NoInt from Tr_PindahGd_M where left(noPindahGd,2)=yy;
             when upper('Tr_BuangGd') then select ifnull(max(substring(noBuangGd,3,6)),0) into NoInt from Tr_BuangGd_M where left(noBuangGd,2)=yy;
             when upper('Close') then select ifnull(max(substring(noClose,3,6)),0) into NoInt from TR_JualR_m where left(NoJualR,2)=yy and TransRetail=Trans;
        end case;
        if NoInt=0 then
           set NoBaru = concat(yy,'000001');
        else
           set noInt = noInt + 1;
           set noStr = noInt;
           set NoBaru= concat(yy,repeat('0',6-length(NoStr)),NoStr);
        end if;
     end if;
  end if;
  If (TipeNo=2) then
     select if(ifnull(substring(nilaichar,5,4),0)='',0,ifnull(substring(nilaichar,5,4),0)),ifnull(nilaichar,'00') into NoInt,Nomer from tm_setupall where groups='Nomor' and subgroups=Codes;
     set thn=substring(nomer,1,4);
     if thn=concat(yy,mm) then
        set NoInt=NoInt+1;
        set NoStr=NoInt;
        set NoBaru=concat(yy,mm,REPEAT('0',4-length(NoStr)),NoStr);
     else
        case upper(Nama)
             when upper('Tr_Beli') then select ifnull(max(substring(noBeli,5,4)),0) into NoInt from TR_Beli_m where left(NoBeli,4)=concat(yy,mm) and transBeli=Trans;
             when upper('Tr_HasilProduksi') then select ifnull(max(substring(noProduksi,3,6)),0) into NoInt from TR_HasilProduksi_m where left(NoProduksi,2)=concat(yy,mm) and transprod=trans;
             when upper('Tr_Jual') then select ifnull(max(substring(noJual,5,4)),0) into NoInt from TR_Jual_m where left(NoJual,4)=concat(yy,mm) and TransJual=Trans;
             when upper('Tr_JualR') then select ifnull(max(substring(noJualR,5,4)),0) into NoInt from TR_JualR_m where left(NoJualR,4)=concat(yy,mm) and TransRetail=Trans;
             when upper('Tr_JualRakitan') then select ifnull(max(substring(noJual,5,4)),0) into NoInt from TR_JualRakitan_m where left(NoJual,4)=concat(yy,mm) and TransJual=Trans;
             when upper('Tr_BayarBeli') then select ifnull(max(substring(noBayarB,5,4)),0) into NoInt from TR_BayarBeli_m where left(NoBayarB,4)=concat(yy,mm);
             when upper('Tr_BayarJual') then select ifnull(max(substring(noBayarJ,5,4)),0) into NoInt from TR_BayarJual_m where left(NoBayarJ,4)=concat(yy,mm);
             when upper('Tr_BayarJualRakitan') then select ifnull(max(substring(noBayarJ,5,4)),0) into NoInt from TR_BayarJualRakitan_m where left(NoBayarJ,4)=concat(yy,mm);
             when upper('Tr_RetBeli') then select ifnull(max(substring(noRetB,5,4)),0) into NoInt from TR_RetBeli_m where left(NoRetB,4)=concat(yy,mm) and TransRetB=Trans;
             when upper('Tr_RetJual') then select ifnull(max(substring(noRetJ,5,4)),0) into NoInt from TR_RetJual_m where left(NoRetJ,4)=concat(yy,mm) and TransRetJ=Trans;
             when upper('Tr_RetJualR') then select ifnull(max(substring(noRetJ,5,4)),0) into NoInt from TR_RetJualR_m where left(NoRetJ,4)=concat(yy,mm) and TransRetJ=Trans;
             when upper('Tr_RetJualRakitan') then select ifnull(max(substring(noRetJ,5,4)),0) into NoInt from TR_RetJualRakitan_m where left(NoRetJ,4)=concat(yy,mm) and TransRetJ=Trans;
             when upper('Tr_PoJual') then select ifnull(max(substring(nopo,5,4)),0) into NoInt from TR_PoJual_m where left(NoPo,4)=concat(yy,mm);
             when upper('Tr_PoJualRakitan') then select ifnull(max(substring(nopo,5,4)),0) into NoInt from TR_PoJualRakitan_m where left(NoPo,4)=concat(yy,mm);
             when upper('Tr_PIndahGd') then select ifnull(max(substring(noPindahGd,5,4)),0) into NoInt from Tr_PindahGd_M where left(noPindahGd,4)=concat(yy,mm);
             when upper('Tr_BuangGd') then select ifnull(max(substring(noBuangGd,5,4)),0) into NoInt from Tr_BuangGd_M where left(noBuangGd,4)=concat(yy,mm);
             when upper('Close') then select ifnull(max(substring(noClose,5,4)),0) into NoInt from TR_JualR_m where left(NoJualR,4)=concat(yy,mm) and TransRetail=Trans;
       end case;
        if NoInt=0 then
           set NoBaru = concat(yy,mm,'0001');
        else
           set noInt = noInt + 1;
           set noStr = noInt;
           set NoBaru= concat(yy,mm,repeat('0',4-length(NoStr)),NoStr);
        end if;
     end if;
  end if;
 If (TipeNo=3) then
     select if(ifnull(substring(nilaichar,7,3),0)='',0,ifnull(substring(nilaichar,7,3),0)),ifnull(nilaichar,'00') into NoInt,Nomer from tm_setupall where groups='Nomor' and subgroups=Codes;
     set thn=substring(nomer,1,6);
     if thn=concat(yy,mm,dd) then
        set NoInt=NoInt+1;
        set NoStr=NoInt;
        set NoBaru=concat(yy,mm,dd,REPEAT('0',3-length(NoStr)),NoStr);
     else
        case upper(Nama)
             when upper('Tr_Beli') then select ifnull(max(substring(noBeli,7,3)),0) into NoInt from TR_Beli_m where left(NoBeli,6)=concat(yy,mm,dd) and transBeli=Trans;
             when upper('Tr_HasilProduksi') then select ifnull(max(substring(noProduksi,7,3)),0) into NoInt from TR_HasilProduksi_m where left(NoProduksi,6)=concat(yy,mm,dd) and transprod=trans;
             when upper('Tr_Jual') then select ifnull(max(substring(noJual,7,3)),0) into NoInt from TR_Jual_m where left(NoJual,6)=concat(yy,mm,dd) and TransJual=Trans;
             when upper('Tr_JualR') then select ifnull(max(substring(noJualR,7,3)),0) into NoInt from TR_JualR_m where left(NoJualR,6)=concat(yy,mm,dd) and TransRetail=Trans;
             
             when upper('Tr_bahanBaku') then select ifnull(max(substring(noBB,7,3)),0) into NoInt from tr_bbkeluar_m where left(Nobb,6)=concat(yy,mm,dd) and Transbb=Trans;
             
             when upper('Tr_JualRakitan') then select ifnull(max(substring(noJual,7,3)),0) into NoInt from TR_JualRakitan_m where left(NoJual,6)=concat(yy,mm,dd) and TransJual=Trans;
             when upper('Tr_BayarBeli') then select ifnull(max(substring(noBayarB,7,3)),0) into NoInt from TR_BayarBeli_m where left(NoBayarB,6)=concat(yy,mm,dd);
             when upper('Tr_BayarJual') then select ifnull(max(substring(noBayarJ,7,3)),0) into NoInt from TR_BayarJual_m where left(NoBayarJ,6)=concat(yy,mm,dd);
             when upper('Tr_BayarJualRakitan') then select ifnull(max(substring(noBayarJ,7,3)),0) into NoInt from TR_BayarJualRakitan_m where left(NoBayarJ,6)=concat(yy,mm,dd);
             when upper('Tr_RetBeli') then select ifnull(max(substring(noRetB,7,3)),0) into NoInt from TR_RetBeli_m where left(NoRetB,6)=concat(yy,mm,dd) and TransRetB=Trans;
             when upper('Tr_RetJual') then select ifnull(max(substring(noRetJ,7,3)),0) into NoInt from TR_RetJual_m where left(NoRetJ,6)=concat(yy,mm,dd) and TransRetJ=Trans;
             when upper('Tr_RetJualR') then select ifnull(max(substring(noRetJ,7,3)),0) into NoInt from TR_RetJualR_m where left(NoRetJ,6)=concat(yy,mm,dd) and TransRetJ=Trans;
             when upper('Tr_RetJualRakitan') then select ifnull(max(substring(noRetJ,7,3)),0) into NoInt from TR_RetJualRakitan_m where left(NoRetJ,6)=concat(yy,mm,dd) and TransRetJ=Trans;
             when upper('Tr_PoJual') then select ifnull(max(substring(nopo,7,3)),0) into NoInt from TR_PoJual_m where left(NoPo,6)=concat(yy,mm,dd);
             when upper('Tr_PoJualRakitan') then select ifnull(max(substring(nopo,7,3)),0) into NoInt from TR_PoJualRakitan_m where left(NoPo,6)=concat(yy,mm,dd);
             when upper('Tr_PIndahGd') then select ifnull(max(substring(noPindahGd,7,3)),0) into NoInt from Tr_PindahGd_M where left(noPindahGd,6)=concat(yy,mm,dd);
             when upper('Tr_BuangGd') then select ifnull(max(substring(noBuangGd,7,3)),0) into NoInt from Tr_BuangGd_M where left(noBuangGd,6)=concat(yy,mm,dd);
             when upper('Close') then select ifnull(max(substring(noClose,7,3)),0) into NoInt from TR_JualR_m where left(NoJualR,6)=concat(yy,mm,dd) and TransRetail=Trans;
      end case;
        if NoInt=0 then
           set NoBaru = concat(yy,mm,dd,'001');
        else
           set noInt = noInt + 1;
           set noStr = noInt;
           set NoBaru= concat(yy,mm,dd,repeat('0',3-length(NoStr)),NoStr);
        end if;
     end if;
  end if;
  update tm_setupall set nilaichar=NoBaru where groups='Nomor' and subgroups=codes;
  Return NoBaru;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP FUNCTION IF EXISTS `GenAnggota_id_tm_anggota` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `GenAnggota_id_tm_anggota`() RETURNS char(5) CHARSET latin1
BEGIN
  DECLARE nomor INTEGER DEFAULT 0;
  DECLARE VPK char(5) DEFAULT 0;
  SELECT IFNULL(MAX(right(Anggota_id,5)), 0)+1 INTO nomor FROM tm_anggota;
  SET vpk=INSERT('00000',6-LENGTH(nomor), length(nomor), nomor);
  RETURN concat(vPK);
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP FUNCTION IF EXISTS `Genkodebrg` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `Genkodebrg`() RETURNS char(9) CHARSET latin1
BEGIN
  DECLARE nomor INTEGER DEFAULT 0;
  DECLARE VPK char(7) DEFAULT 0;
  SELECT IFNULL(MAX(right(kodebrg,7)), 0)+1 INTO nomor FROM tm_barang where left(kodebrg,2)='21' ;
  SET vpk=INSERT('0000000',8-LENGTH(nomor), length(nomor), nomor);
  RETURN upper( concat('21',vPK));
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP FUNCTION IF EXISTS `GenKodeCust` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `GenKodeCust`(NoBk char(10)) RETURNS char(13) CHARSET latin1
BEGIN
  DECLARE nomor INTEGER DEFAULT 0;
  DECLARE VPK char(3) DEFAULT 0;
  SELECT IFNULL(MAX(right(kodecust,3)), 0)+1 INTO nomor FROM tm_customer where left(kodecust,length(nobk))=NoBk;
  SET vpk=INSERT('000',4-LENGTH(nomor), length(nomor), nomor);
  RETURN upper( concat(NoBk,vPK));
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP FUNCTION IF EXISTS `GenKodeSupp` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`link`@`%`*/ /*!50003 FUNCTION `GenKodeSupp`(NoBk char(10)) RETURNS char(13) CHARSET latin1
BEGIN
  DECLARE nomor INTEGER DEFAULT 0;
  DECLARE VPK char(10) DEFAULT 0;
  SELECT IFNULL(MAX(right(kodesupp,7)), 0)+1 INTO nomor FROM tm_supplier where left(kodesupp,length(nobk))=NoBk;
  SET vpk=INSERT('0000000',8-LENGTH(nomor), length(nomor), nomor);
  RETURN upper( concat(NoBk,vPK));
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP FUNCTION IF EXISTS `GenNoBukti` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `GenNoBukti`() RETURNS char(11) CHARSET latin1
BEGIN
  DECLARE nomor INTEGER DEFAULT 0;
  DECLARE VKW char(5) DEFAULT 0;
  DECLARE VThn char(7) DEFAULT 0;
  SELECT substring(now(),3,5) INTO VTHN ;
  SELECT IFNULL(MAX(right(No_bukti,3)), 0)+1 INTO nomor FROM Tcashflow_m where substring(Tanggal,3,5) =vthn;
  SET vKW=INSERT('000',4-LENGTH(nomor), length(nomor), nomor);
  RETURN concat(Vthn,vKw);
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP FUNCTION IF EXISTS `gennobuktijurnal` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `gennobuktijurnal`(NoBk char(10)) RETURNS char(13) CHARSET latin1
BEGIN
  DECLARE nomor INTEGER DEFAULT 0;
  DECLARE VPK char(3) DEFAULT 0;
  SELECT IFNULL(MAX(right(no_bukti,3)), 0)+1 INTO nomor FROM tJurnal where left(no_bukti,length(nobk))=NoBk;
  SET vpk=INSERT('000',4-LENGTH(nomor), length(nomor), nomor);
  RETURN concat(NoBk,vPK);
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP FUNCTION IF EXISTS `RugiLabaProduksi_Bulanan` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `RugiLabaProduksi_Bulanan`(sTglStart DATE, sTglEnd DATE) RETURNS decimal(15,2)
BEGIN
  DECLARE finished INTEGER DEFAULT 0;
	DECLARE sKodePerk CHAR(6);
	DECLARE sNamaPerk VARCHAR(100);
	DECLARE sPendapatan, sHPP, sTotHPP, sTotPendapatan, sTotBeban, sPajak, sLabaRugi DECIMAL(15,2);
	DECLARE sPendapatanDiskon, sPendapatanService, sPendapatanKas, sPendapatanTabungan, sPendapatanLain DECIMAL(15,2);
	DECLARE sJmlRow INTEGER;
	DEClARE curPerk
		CURSOR FOR 
			SELECT 
				CASE 
					WHEN g.NamaGol = "VULKANISIR" THEN "411001" 
					WHEN g.NamaGol = "OUT SOL" THEN "411002" 
					WHEN g.NamaGol = "VULK.DINGIN" THEN "411005" 
					WHEN g.NamaGol = "CAKAR" THEN "411010" 
					WHEN g.NamaGol = "HAMMER" THEN "411011" 
					WHEN g.NamaGol = "KARPET SAPI" THEN "411012" 
					WHEN g.NamaGol = "RUBBER SHEET" THEN "411006" 
				END KodePerk,
				SUM(m.Nilai), (IFNULL(b.HargaGrosir,0) * SUM(m.JmlProduksi))
			FROM tr_hasilproduksi_m m
			JOIN tm_barang b ON (m.KodeProduk = b.KodeBrg) JOIN tm_golongan g ON (b.KodeGol=g.KodeGol)
			WHERE m.TglProduksi >= sTglStart and m.TglProduksi <= sTglEnd
				AND b.JenisPersediaan = "Persediaan Barang Jadi" GROUP BY b.KodeGol;
	DECLARE CONTINUE HANDLER 
        FOR NOT FOUND SET finished = 1;
	SET sTotHPP = 0;
	SET sTotPendapatan = 0;
	SET sJmlRow = 2;
	
	DELETE FROM laprincianrugilaba WHERE Jenis = " PENDAPATAN" AND Row_id <> 1;
	DELETE FROM laprincianrugilaba WHERE Jenis = "BEBAN" AND (Row_id = 2 OR Row_id = 3 OR Row_id = 999);
	OPEN curPerk;
	getPerk: LOOP
		FETCH curPerk INTO sKodePerk, sHPP, sPendapatan;
		IF finished = 1 THEN 
			LEAVE getPerk;
		END IF;
		
		SET sTotHPP = sTotHPP + sHPP;
		IF sPendapatan > 0 THEN
			SELECT Nama_Perk INTO sNamaPerk FROM mperkiraan WHERE Tahun = YEAR(sTglStart) AND  Kode_Perk = sKodePerk;
			INSERT INTO laprincianrugilaba (Jenis, Row_id, Kode_perk, Nama_perk, Jumlah, Tot_Jumlah) VALUES
				(" PENDAPATAN", sJmlRow, sKodePerk, sNamaPerk, AngkaKeString(sPendapatan), "");
			SET sTotPendapatan = sTotPendapatan + sPendapatan;
			SET sJmlRow = sJmlRow + 1;
		END IF;
	END LOOP getPerk;
	CLOSE curPerk;
	
	SELECT SUM(Debet)- SUM(Kredit) INTO sPendapatanDiskon FROM tjurnal_d WHERE Kode_perk = 411003 AND Tanggal >= sTglStart AND Tanggal <= sTglEnd;
	IF sPendapatanDiskon > 0 THEN
		INSERT INTO laprincianrugilaba (Jenis, Row_id, Kode_perk, Nama_perk, Jumlah, Tot_Jumlah) VALUES
			(" PENDAPATAN", sJmlRow, "411003", "Pendapatan Diskon", AngkaKeString(sPendapatanDiskon), "");
		SET sTotPendapatan = sTotPendapatan + sPendapatanDiskon;
		SET sJmlRow = sJmlRow + 1;
	END IF;
	SELECT SUM(Debet)- SUM(Kredit) INTO sPendapatanService FROM tjurnal_d WHERE Kode_perk = 411004 AND Tanggal >= sTglStart AND Tanggal <= sTglEnd;
	IF sPendapatanService > 0 THEN
		INSERT INTO laprincianrugilaba (Jenis, Row_id, Kode_perk, Nama_perk, Jumlah, Tot_Jumlah) VALUES
			(" PENDAPATAN", sJmlRow, "411004", "Pendapatan Jasa Service", AngkaKeString(sPendapatanService), "");
		SET sTotPendapatan = sTotPendapatan + sPendapatanService;
		SET sJmlRow = sJmlRow + 1;
	END IF;
	SELECT SUM(Debet)- SUM(Kredit) INTO sPendapatanKas FROM tjurnal_d WHERE Kode_perk = 411007 AND Tanggal >= sTglStart AND Tanggal <= sTglEnd;
	IF sPendapatanKas > 0 THEN
		INSERT INTO laprincianrugilaba (Jenis, Row_id, Kode_perk, Nama_perk, Jumlah, Tot_Jumlah) VALUES
			(" PENDAPATAN", sJmlRow, "411007", "Pendapatan Selisih Kas Lebih", AngkaKeString(sPendapatanKas), "");
		SET sTotPendapatan = sTotPendapatan + sPendapatanKas;
		SET sJmlRow = sJmlRow + 1;
	END IF;
	SELECT SUM(Debet)- SUM(Kredit) INTO sPendapatanTabungan FROM tjurnal_d WHERE Kode_perk = 411008 AND Tanggal >= sTglStart AND Tanggal <= sTglEnd;
	IF sPendapatanTabungan > 0 THEN
		INSERT INTO laprincianrugilaba (Jenis, Row_id, Kode_perk, Nama_perk, Jumlah, Tot_Jumlah) VALUES
			(" PENDAPATAN", sJmlRow, "411008", "Pendapatan Bunga Tabungan", AngkaKeString(sPendapatanTabungan), "");
		SET sTotPendapatan = sTotPendapatan + sPendapatanTabungan;
		SET sJmlRow = sJmlRow + 1;
	END IF;
	SELECT SUM(Debet)- SUM(Kredit) INTO sPendapatanLain FROM tjurnal_d WHERE Kode_perk = 411009 AND Tanggal >= sTglStart AND Tanggal <= sTglEnd;
	IF sPendapatanLain > 0 THEN
		INSERT INTO laprincianrugilaba (Jenis, Row_id, Kode_perk, Nama_perk, Jumlah, Tot_Jumlah) VALUES
			(" PENDAPATAN", sJmlRow, "411009", "Pendapatan Lain-Lain", AngkaKeString(sPendapatanLain), "");
		SET sTotPendapatan = sTotPendapatan + sPendapatanLain;
		SET sJmlRow = sJmlRow + 1;
	END IF;
	INSERT INTO laprincianrugilaba (Jenis, Row_id, Kode_perk, Nama_perk, Jumlah, Tot_Jumlah) VALUES
		(" PENDAPATAN", sJmlRow, "", "", "", AngkaKeString(sTotPendapatan));
	INSERT INTO laprincianrugilaba (Jenis, Row_id, Kode_perk, Nama_perk, Jumlah, Tot_Jumlah) VALUES
		(" PENDAPATAN", 999, "", "TOTAL PENDAPATAN", "", AngkaKeString(sTotPendapatan));
	INSERT INTO laprincianrugilaba (Jenis, Row_id, Kode_perk, Nama_perk, Jumlah, Tot_Jumlah) VALUES
		("BEBAN", 2, "511001", "Harga Pokok Penjualan", AngkaKeString(sTotHPP), "");	
	INSERT INTO laprincianrugilaba (Jenis, Row_id, Kode_perk, Nama_perk, Jumlah, Tot_Jumlah) VALUES
		("BEBAN", 3, "", "", "", AngkaKeString(sTotHPP));	
	SELECT SUM(Debet)- SUM(Kredit) INTO sTotBeban FROM tjurnal_d WHERE Kode_perk >= 500000 AND Kode_Perk <= 599999 AND Kode_Perk <> "511001" AND Tanggal >= sTglStart AND Tanggal <= sTglEnd;
	INSERT INTO laprincianrugilaba (Jenis, Row_id, Kode_perk, Nama_perk, Jumlah, Tot_Jumlah) VALUES
		("BEBAN", 999, "", "TOTAL BEBAN", "", AngkaKeString(sTotHPP + sTotBeban));
	SELECT SUM(Debet)- SUM(Kredit) INTO sPajak FROM tjurnal_d WHERE Kode_perk >= 600000 AND Kode_Perk <= 699999 AND Tanggal >= sTglStart AND Tanggal <= sTglEnd;
	SET sLabaRugi = sTotPendapatan - sTotHPP - sTotBeban - sPajak;
	
	RETURN sLabaRugi;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `CheckJurnalUlang_BayarBeli` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `CheckJurnalUlang_BayarBeli`(sTglStart DATE)
BEGIN
  DECLARE finished INTEGER DEFAULT 0;
	DECLARE sNoTrans VARCHAR(20);
	DEClARE curTrans
		CURSOR FOR 
			SELECT x.* FROM (SELECT NoBayarB FROM tr_bayarbeli_m WHERE TglBayarB >= sTglStart) x;
	DECLARE CONTINUE HANDLER 
        FOR NOT FOUND SET finished = 1;
	OPEN curTrans;
	getTrans: LOOP
		FETCH curTrans INTO sNoTrans;
		IF finished = 1 THEN 
			LEAVE getTrans;
		END IF;
		
		CALL SimpanJurnal_BayarBeli(sNoTrans);
		
	END LOOP getTrans;
	CLOSE curTrans;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `CheckJurnalUlang_BayarGrosir` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `CheckJurnalUlang_BayarGrosir`(sTglStart DATE)
BEGIN
  DECLARE finished INTEGER DEFAULT 0;
	DECLARE sNoTrans VARCHAR(20);
	DEClARE curTrans
		CURSOR FOR 
			SELECT x.* FROM (SELECT NoBayarJ FROM tr_bayarjual_m WHERE TglBayarJ >= sTglStart) x;
	DECLARE CONTINUE HANDLER 
        FOR NOT FOUND SET finished = 1;
	OPEN curTrans;
	getTrans: LOOP
		FETCH curTrans INTO sNoTrans;
		IF finished = 1 THEN 
			LEAVE getTrans;
		END IF;
		
		CALL SimpanJurnal_BayarJual(sNoTrans);
		
	END LOOP getTrans;
	CLOSE curTrans;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `CheckJurnalUlang_Pembelian` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `CheckJurnalUlang_Pembelian`(sTglStart DATE)
BEGIN
  DECLARE finished INTEGER DEFAULT 0;
	DECLARE sNoTrans VARCHAR(20);
	DEClARE curTrans
		CURSOR FOR 
			SELECT x.* FROM (SELECT NoBeli FROM tr_beli_m WHERE TglBeli >= sTglStart) x;
	DECLARE CONTINUE HANDLER 
        FOR NOT FOUND SET finished = 1;
	OPEN curTrans;
	getTrans: LOOP
		FETCH curTrans INTO sNoTrans;
		IF finished = 1 THEN 
			LEAVE getTrans;
		END IF;
		
		CALL SimpanJurnal_Pembelian(sNoTrans);
		
	END LOOP getTrans;
	CLOSE curTrans;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteJurnal_BayarBeli` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `DeleteJurnal_BayarBeli`(sNoBayar VARCHAR(15))
BEGIN
	DECLARE NoBukti,sNoBukti VARCHAR(30); 
	
	Select No_bukti INTO sNoBukti from tjurnal_m where Jns_jurnal="JK" and Sandi_Trans_Id="YB" and Nobukti_Rtl=sNoBayar LIMIT 0,1;
    
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	SET NoBukti = CONCAT("YB",sNoBayar);
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=NoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=NoBukti;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteJurnal_BayarJual` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `DeleteJurnal_BayarJual`(sNoBayar VARCHAR(15))
BEGIN
	DECLARE NoBukti,sNoBukti VARCHAR(30);
	
	Select No_bukti INTO sNoBukti from tjurnal_m where Jns_jurnal="JK" and Sandi_Trans_Id="YJ" and Nobukti_Rtl=sNoBayar LIMIT 0,1;
    
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	SET NoBukti = CONCAT("YJ",sNoBayar);
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=NoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=NoBukti;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteJurnal_JualGrosir` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `DeleteJurnal_JualGrosir`(sNoJual VARCHAR(20))
BEGIN
	DECLARE sTglJurnal DATE;
	DECLARE sNoBukti VARCHAR(20);
	
	SELECT IFNULL(No_Bukti,""), Tgl_Validasi INTO sNoBukti, sTglJurnal FROM tjurnal_m WHERE NoBukti_Rtl=sNoJual AND Sandi_Trans_id="JT";
	DELETE FROM tjurnal_d WHERE Tanggal = sTglJurnal AND No_Bukti=sNoBukti AND LEFT(No_Bukti,2)="JT";
	DELETE FROM tjurnal_m WHERE NoBukti_Rtl=sNoJual AND Sandi_Trans_id="JT";
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteJurnal_Pembelian` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `DeleteJurnal_Pembelian`(sNoBeli VARCHAR(15), sTgl DATE)
BEGIN
  DECLARE sNoBukti, NoBukti VARCHAR(30);
	Select No_bukti INTO sNoBukti from tjurnal_m where Jns_jurnal="JK" and Sandi_Trans_Id="BT" and Nobukti_Rtl=sNoBeli LIMIT 0,1;  
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	SET NoBukti = CONCAT("BT",sNoBeli);
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=NoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=NoBukti; 
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteJurnal_PengeluaranBrg` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `DeleteJurnal_PengeluaranBrg`(sNoBB VARCHAR(15), sTgl DATE)
BEGIN
  DECLARE sNoBukti, NoBukti VARCHAR(30);
	Select No_bukti INTO sNoBukti from tjurnal where Jns_jurnal="JK" and Sandi_Trans_Id="BB" and Nobukti_Rtl=sNoBB LIMIT 0,1;  
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=sNoBukti; 
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteJurnal_Produksi` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `DeleteJurnal_Produksi`(sNoProduksi VARCHAR(15), sTgl DATE)
BEGIN
  DECLARE sNoBukti, NoBukti VARCHAR(30);
	select No_bukti INTO sNoBukti from tjurnal_m where Jns_jurnal="JK" and Sandi_Trans_Id="HP" and Nobukti_Rtl=sNoProduksi LIMIT 0,1;
  delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=sNoBukti;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `HapusJurnal_BahanKeluar` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`client`@`%`*/ /*!50003 PROCEDURE `HapusJurnal_BahanKeluar`(sNoTrans varchar(11))
BEGIN
	DECLARE NoBukti VARCHAR(30);
  DECLARE sNoBukti VARCHAR(30);
	Select No_bukti INTO sNoBukti from tjurnal_m where Jns_jurnal="JK" and Sandi_Trans_Id="BB" and Nobukti_Rtl=sNoTrans LIMIT 0,1;
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	SET NoBukti = CONCAT("BB",sNoTrans);
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=NoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=NoBukti;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `HitungStock` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`client`@`%`*/ /*!50003 PROCEDURE `HitungStock`(sKodeBrg VARCHAR(20))
BEGIN
	DECLARE sTotal DECIMAL(15,2);
	DECLARE sCekStockBrg INTEGER;
	DECLARE sNamaBrg VARCHAR(150);
	SELECT sum(masuk) - SUM(keluar) TotalStock INTO sTotal FROM (
		select 'SALDO AWAL' as nama,a.Kodebrg, IFNULL(a.saldoawal,0) as masuk, '0' as keluar from tb_saldoawal a
			where a.kodebrg=sKodeBrg
		union all
		select 'PEMBELIAN', d.kodeBrg, sum(ifnull( d.jml * d.konv ,0)) masuk, '0' keluar from tr_beli_d d, tr_beli_m m 
			where m.NoBeli = d.NoBeli
			and d.KodeBrg = sKodeBrg
			and m.TglBeli <= DATE_ADD(NOW(),INTERVAL 1 MONTH)
			GROUP BY d.KodeBrg
		union all
		select 'RETUR PEMBELIAN', d.KodeBrg, '0' masuk, sum(ifnull( d.jml * d.konv ,0)) keluar from tr_retbeli_d d, tr_retbeli_m m 
			where m.NoRetB = d.NoRetB
			and d.KodeBrg = sKodeBrg
			and m.TglRetB <= DATE_ADD(NOW(),INTERVAL 1 MONTH)
			GROUP BY d.KodeBrg
		union all 
		select 'PENJUALAN RETAIL', d.kodeBrg, '0' masuk, sum(ifnull( d.jml * IFNULL(d.Konv,1),0)) keluar from tr_jualr_d d, tr_jualr_m m 
			where m.NoJualR = d.NoJualR
			and d.KodeBrg = sKodeBrg
			and m.TglJual <= DATE_ADD(NOW(),INTERVAL 1 MONTH)
			GROUP BY d.KodeBrg
		union all
		select 'RETUR PENJUALAN RETAIL', d.KodeBrg,sum(ifnull( d.jml * IFNULL(d.Konv,1) ,0)) masuk, '0' keluar from tr_retjualr_d d, tr_retjualr_m m 
			where m.NoRetJ = d.NoRetJ
			and d.KodeBrg = sKodeBrg
			and m.TglRetJ <= DATE_ADD(NOW(),INTERVAL 1 MONTH)
			GROUP BY d.KodeBrg
		union all
		select 'PENJUALAN GROSIR', d.kodeBrg, '0' masuk,sum(ifnull( d.jml * IFNULL(d.Konv,1),0)) keluar from tr_jual_d d, tr_jual_m m 
			where m.NoJual = d.NoJual
			and d.KodeBrg = sKodeBrg
			and m.TglJual <= DATE_ADD(NOW(),INTERVAL 1 MONTH)
			GROUP BY d.KodeBrg
		union all
		select 'RETUR PENJUALAN GROSIR', d.KodeBrg,sum(ifnull( d.jml * IFNULL(d.Konv,1) ,0)) masuk, '0' keluar from tr_retjual_d d, tr_retjual_m m 
			where m.NoRetJ = d.NoRetJ
			and d.KodeBrg = sKodeBrg
			and m.TglRetJ <= DATE_ADD(NOW(),INTERVAL 1 MONTH)
			GROUP BY d.KodeBrg
		union all
		select 'koreksi lebih', d.kodeBrg, sum(ifnull( d.SelisihLebih * d.konv ,0)) masuk ,'0' keluar from tr_koreksistc_d d, tr_koreksistc_m m 
			where m.NoKoreksi = d.NoKoreksi
			and d.KodeBrg = sKodeBrg
			and m.TglKoreksi <= DATE_ADD(NOW(),INTERVAL 1 MONTH)
			GROUP BY d.KodeBrg 
		union all
		select 'koreksi kurang', d.kodeBrg,'0' masuk, sum(ifnull( d.SelisihKurang * d.konv ,0)) keluar from tr_koreksistc_d d, tr_koreksistc_m m 
			where m.NoKoreksi = d.NoKoreksi
			and d.KodeBrg = sKodeBrg
			and m.TglKoreksi <= DATE_ADD(NOW(),INTERVAL 1 MONTH)
			GROUP BY d.KodeBrg 
		union all
		select 'Produksi Bahan', d.kodeBrg, '0' masuk ,sum(ifnull( d.jml * IFNULL(d.konv,1) ,0)) keluar from tr_hasilproduksi_d d, tr_hasilproduksi_m m 
			where m.NoProduksi = d.NoProduksi
			and d.KodeBrg = sKodeBrg
			and m.TglProduksi <= DATE_ADD(NOW(),INTERVAL 1 MONTH)
			GROUP BY d.KodeBrg
		union all
		select 'Produksi Jadi', kodeProduk ,sum(ifnull(jmlproduksi,0)) masuk, '0' keluar from tr_hasilproduksi_m
			where TRUE
			and KodeProduk = sKodeBrg
			and TglProduksi <= DATE_ADD(NOW(),INTERVAL 1 MONTH)
			GROUP BY KodeProduk
	)nn ;
	UPDATE tm_stockbrg SET StockAkhir=sTotal WHERE KodeBrg=sKodeBrg;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `HitungStockGD` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`client`@`%`*/ /*!50003 PROCEDURE `HitungStockGD`(sKodeBrg VARCHAR(50))
BEGIN
	DECLARE sStock DECIMAL(15,2); 
	DECLARE sTemp INTEGER;
	DECLARE sNamaBrg VARCHAR(150);
	SET sStock = (select 
			(IFNULL(sum(a.saldoawal),0) +
			IFNULL((select sum(IFNULL(b.jml,0) * IFNULL(b.Konv,1)) from tr_beli_d b where a.kodebrg=b.kodebrg),0) -
			IFNULL((select sum(IFNULL(c.jml,0) * IFNULL(c.Konv,1)) from tr_retbeli_d c where a.kodebrg=c.kodebrg),0) -
			IFNULL((select sum(IFNULL(d.jml,0) * IFNULL(d.Konv,1)) from tr_jualr_d d where a.kodebrg=d.kodebrg),0) +
			IFNULL((select sum(IFNULL(e.jml,0) * IFNULL(e.Konv,1)) from tr_retjualr_d e where a.kodebrg=e.kodebrg),0) -
			IFNULL((select sum(IFNULL(f.jml,0) * IFNULL(f.Konv,1)) from tr_jual_d f where a.kodebrg=f.kodebrg),0) +
			IFNULL((select sum(IFNULL(g.jml,0) * IFNULL(g.Konv,1)) from tr_retjual_d g where a.kodebrg=g.KodeBrg),0) -
			IFNULL((select sum(IFNULL(h.jml,0) * IFNULL(h.Konv,1)) from tr_hasilproduksi_d h where a.kodebrg=h.KodeBrg),0) +
			IFNULL((select sum(IFNULL(i.jmlproduksi,0)) from tr_hasilproduksi_m i where a.kodebrg=i.KodeProduk),0) -
			IFNULL((select sum(IFNULL(j.SelisihKurang,0) * IFNULL(j.konv,1)) from tr_koreksistc_d j where a.kodebrg=j.kodebrg),0)+
			IFNULL((select sum(IFNULL(k.SelisihLebih,0) * IFNULL(k.konv,1)) from tr_koreksistc_d k where a.kodebrg=k.kodebrg),0) -
			IFNULL((select sum(IFNULL(l.Jml,0) * IFNULL(l.Konv,1)) FROM tr_bbkeluar_d l where a.kodebrg=l.kodebrg),0)
			)
		from tb_saldoawal a where a.kodebrg=sKodeBrg);
	SELECT COUNT(*) INTO sTemp FROM tm_stockbrg WHERE KodeBrg=sKodeBrg;
	IF (sTemp IS NULL) OR (sTemp = 0) THEN
		SELECT NamaBrg INTO sNamaBrg FROM tm_barang WHERE KodeBrg=sKodeBrg;
		INSERT INTO tm_stockbrg (KodeBrg,NamaBrg,KodeGd,StockAwal,StockAkhir) VALUES (sKodeBrg,sNamaBrg,"GD",0,sStock);
	ELSE
		UPDATE tm_stockbrg SET StockAkhir=sStock WHERE KodeBrg=sKodeBrg;
	END IF;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `HitungUlangJurnalJual` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`client`@`%`*/ /*!50003 PROCEDURE `HitungUlangJurnalJual`(sTglStart DATE,sTglEnd DATE)
BEGIN
  DECLARE finished INTEGER DEFAULT 0;
	DECLARE sNoTrans,sNoBukti VARCHAR(20);
	DECLARE sTotalAVG,sNilai DECIMAL(15,2);
	DEClARE curTrans
		CURSOR FOR 
				SELECT x.NoJual FROM (SELECT NoJual FROM tr_jual_m WHERE TglJual >= sTglStart AND TglJual <= sTglEnd) x;
	DECLARE CONTINUE HANDLER 
        FOR NOT FOUND SET finished = 1;
	OPEN curTrans;
	getTrans: LOOP
		FETCH curTrans INTO sNoTrans;
		IF finished = 1 THEN 
			LEAVE getTrans;
		END IF;
		
	  SELECT SUM(IFNULL(HargaAVG,0) * IFNULL(jml,0)) INTO sTotalAVG FROM tr_jual_d WHERE NoJual=sNoTrans;
		SELECT Nilai INTO sNilai FROM tr_jual_m WHERE NoJual=sNoTrans;
		SELECT No_Bukti INTO sNoBukti FROM tjurnal_m WHERE Sandi_trans_id="JT" AND Nobukti_Rtl=sNoTrans;
		IF sTotalAVG > 0 THEN
			UPDATE tjurnal_d SET Debet=sTotalAVG WHERE No_bukti=sNoBukti AND Kode_perk="511001";
			UPDATE tjurnal_d SET Kredit=sTotalAVG WHERE No_bukti=sNoBukti AND Row_id=3;
    END IF;
		IF sNilai > 0 THEN
			UPDATE tjurnal_d SET Debet=sNilai WHERE No_bukti=sNoBukti AND Row_id=2;
			UPDATE tjurnal_d SET Kredit=sNilai WHERE No_bukti=sNoBukti AND Row_id=4;
		END IF;
	END LOOP getTrans;
	CLOSE curTrans;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `ProsesCekStockGD` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`client`@`%`*/ /*!50003 PROCEDURE `ProsesCekStockGD`()
BEGIN
	DECLARE finished INTEGER DEFAULT 0;
	DECLARE sKodeBrg VARCHAR(20);
	DEClARE curBrg
		CURSOR FOR 
				SELECT x.KodeBrg FROM (SELECT KodeBrg FROM tb_saldoawal) x;
	DECLARE CONTINUE HANDLER 
        FOR NOT FOUND SET finished = 1;
	OPEN curBrg;
	getBrg: LOOP
		FETCH curBrg INTO sKodeBrg;
		IF finished = 1 THEN 
			LEAVE getBrg;
		END IF;
		CALL HitungStock(sKodeBrg);
		
	END LOOP getBrg;
	CLOSE curBrg;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `ProsesHitungHPP` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`client`@`%`*/ /*!50003 PROCEDURE `ProsesHitungHPP`(sTglStart DATE, sTglEnd DATE)
BEGIN
	DECLARE finished INTEGER DEFAULT 0;
	DECLARE sKodeBrg VARCHAR(20);
	DEClARE curBrg
		CURSOR FOR 
				SELECT x.KodeBrg FROM (SELECT KodeBrg FROM tm_barang) x;
	DECLARE CONTINUE HANDLER 
        FOR NOT FOUND SET finished = 1;
	OPEN curBrg;
	getBrg: LOOP
		FETCH curBrg INTO sKodeBrg;
		IF finished = 1 THEN 
			LEAVE getBrg;
		END IF;
		
	  TRUNCATE tr_kartustock;
		CALL tr_kartustock(sKodeBrg,sTglStart,sTglEnd);
		
	END LOOP getBrg;
	CLOSE curBrg;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `ProsesHitungHPPProduksi` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `ProsesHitungHPPProduksi`(sTglStart DATE, sTglEnd DATE)
BEGIN
	DECLARE finished INTEGER DEFAULT 0; 
	DECLARE sNoTrans VARCHAR(20);
	DECLARE sNilaiAVG DECIMAL(15,2);
	DEClARE curBrg
		CURSOR FOR 
				SELECT x.NoProduksi FROM (SELECT NoProduksi FROM tr_hasilproduksi_m WHERE TglProduksi >= sTglStart AND TglProduksi <= sTglEnd) x;
	DECLARE CONTINUE HANDLER 
        FOR NOT FOUND SET finished = 1;
	OPEN curBrg;
	getBrg: LOOP
		FETCH curBrg INTO sNoTrans;
		IF finished = 1 THEN 
			LEAVE getBrg;
		END IF;
		
	  SELECT SUM(Total) INTO sNilaiAVG FROM tr_hasilproduksi_d WHERE NoProduksi=sNoTrans;
		UPDATE tr_hasilproduksi_m SET Nilai=sNilaiAVG WHERE NoProduksi=sNoTrans;
		
	END LOOP getBrg;
	CLOSE curBrg;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `SimpanJurnal_BahanKeluar` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`client`@`%`*/ /*!50003 PROCEDURE `SimpanJurnal_BahanKeluar`(sNoTrans varchar(11), sKodePerk CHAR(6),sBagian VARCHAR(30))
BEGIN
	DECLARE NoBukti VARCHAR(30);
  DECLARE sNoBukti VARCHAR(30);
	DECLARE sTgl DATE;
  DECLARE sNilai DECIMAL(15,2);
	DECLARE sDivisi VARCHAR(20);
	
	IF sBagian = "Vulkanisir" THEN
		SET sDivisi = "VK";
	ELSEIF sBagian = "Sol" THEN
		SET sDivisi = "SL";
	ELSEIF sBagian = "Rubber Sheet" THEN
		SET sDivisi = "RS";
	ELSEIF sBagian = "VD" THEN
		SET sDivisi = "VD";
	ELSEIF sBagian = "Cakar" THEN
		SET sDivisi = "CK";
	ELSEIF sBagian = "Hammer" THEN
		SET sDivisi = "HM";
	ELSEIF sBagian = "Karpet Sapi" THEN
		SET sDivisi = "KS";
	ELSE
		SET sDivisi = NULL;
	END IF;
  SELECT TglBb, Nilai INTO sTgl, sNilai FROM tr_bbkeluar_m WHERE NoBB=sNoTrans;
	Select No_bukti INTO sNoBukti from tjurnal_m where Jns_jurnal="JK" and Sandi_Trans_Id="BB" and Nobukti_Rtl=sNoTrans LIMIT 0,1;
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	SET NoBukti = CONCAT("BB",sNoTrans);
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=NoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=NoBukti;
	insert into tjurnal_m (tanggal,no_bukti,keterangan,Sandi_Trans_Id,Status_Val,Nobukti_Rtl,pst,jns_jurnal,tgl_validasi,tgl_edit,user)	values 
		("0000-00-00",NoBukti,CONCAT("Pengeluaran Bahan Baku BB-",sNoTrans),"BB",0,sNoTrans,0,"JK",DATE(sTgl),now(),"ADMIN");
	insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
			(YEAR(sTgl),DATE(sTgl),NoBukti,1,sKodePerk,sNilai,0,"JK",sDivisi);
	insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
			(YEAR(sTgl),DATE(sTgl),NoBukti,2,115001,0,sNilai,"JK",sDivisi);
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `SimpanJurnal_BayarBeli` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `SimpanJurnal_BayarBeli`(sNoBayar VARCHAR(15))
BEGIN
	DECLARE NoBukti,sNoBukti VARCHAR(30);
  DECLARE sKodePerk VARCHAR(30);
  DECLARE HPP DECIMAL(15,2);
	DECLARE sTgl DATE;
	DECLARE sNamaSupp VARCHAR(100);
  DECLARE sNilai DECIMAL(15,2);
	DECLARE sJmlRow,sIndex INTEGER(4);
	
	SELECT m.TglBayarB,s.NamaSupp INTO sTgl,sNamaSupp FROM tr_bayarbeli_m m JOIN tm_supplier s ON m.KodeSupp=s.KodeSupp WHERE NoBayarB=sNoBayar;
	
	Select No_bukti INTO sNoBukti from tjurnal_m where Jns_jurnal="JK" and Sandi_Trans_Id="YB" and Nobukti_Rtl=sNoBayar LIMIT 0,1;
    
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	SET NoBukti = CONCAT("YB",sNoBayar);
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=NoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=NoBukti;
	insert into tjurnal_m (tanggal,no_bukti,keterangan,Sandi_Trans_Id,Status_Val,Nobukti_Rtl,pst,jns_jurnal,tgl_validasi,tgl_edit,user) 	values 
		("0000-00-00",NoBukti,CONCAT("Pembayaran Pembelian No: YJ-",sNoBayar," a.n ", sNamaSupp),"YB",0,sNoBayar,0,"JK",DATE(sTgl),now(),"ADMIN");
	
	SELECT COUNT(*) INTO sJmlRow FROM tr_bayarbeli_d WHERE NoBayarB=sNoBayar;
	
	
	SET sIndex=1;
	WHILE sIndex <= sJmlRow DO
		SELECT IFNULL(Bank,"111001"),Nilai INTO sKodePerk,sNilai FROM tr_bayarbeli_d WHERE NoBayarB=sNoBayar AND ItemDBayarB=sIndex;
		IF sKodePerk = '' THEN SET sKodePerk="111001"; END IF; 
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,(sIndex * 2)-1,sKodePerk,0,sNilai,"JK");
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,(sIndex * 2),"211001",sNilai,0,"JK");
		SET sIndex= sIndex + 1; 
	END WHILE;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `SimpanJurnal_BayarJual` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `SimpanJurnal_BayarJual`(sNoBayar VARCHAR(15))
BEGIN
	DECLARE NoBukti,sNoBukti VARCHAR(30);
  DECLARE sKodePerk VARCHAR(30);
  DECLARE HPP DECIMAL(15,2);
	DECLARE sTgl DATE;
	DECLARE sNamaCust VARCHAR(100);
  DECLARE sNilai DECIMAL(15,2);
	DECLARE sJmlRow,sIndex INTEGER(4);
	
	SELECT m.TglBayarJ,c.NamaCust INTO sTgl,sNamaCust FROM tr_bayarjual_m m JOIN tm_customer c ON m.KodeCust=c.KodeCust WHERE NoBayarJ=sNoBayar;
	
	Select No_bukti INTO sNoBukti from tjurnal_m where Jns_jurnal="JK" and Sandi_Trans_Id="YJ" and Nobukti_Rtl=sNoBayar LIMIT 0,1;
    
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	SET NoBukti = CONCAT("YJ",sNoBayar);
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=NoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=NoBukti;
	insert into tjurnal_m (tanggal,no_bukti,keterangan,Sandi_Trans_Id,Status_Val,Nobukti_Rtl,pst,jns_jurnal,tgl_validasi,tgl_edit,user) 	values 
		("0000-00-00",NoBukti,CONCAT("Pembayaran Penjualan No: YJ-",sNoBayar," a.n ", sNamaCust),"YJ",0,sNoBayar,0,"JK",DATE(sTgl),now(),"ADMIN");
	
	SELECT COUNT(*) INTO sJmlRow FROM tr_bayarjual_d WHERE NoBayarJ=sNoBayar;
	
	
	SET sIndex=1;
	WHILE sIndex <= sJmlRow DO
		SELECT IFNULL(Bank,"111001"),Nilai INTO sKodePerk,sNilai FROM tr_bayarjual_d WHERE NoBayarJ=sNoBayar AND ItemDBayarJ=sIndex;
		IF sKodePerk = '' THEN SET sKodePerk="111001"; END IF; 
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,(sIndex * 2)-1,sKodePerk,sNilai,0,"JK");
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,(sIndex * 2),"113001",0,sNilai,"JK");
		SET sIndex= sIndex + 1; 
	END WHILE;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `SimpanJurnal_JualGrosir` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `SimpanJurnal_JualGrosir`(sNoJual VARCHAR(20))
BEGIN
DECLARE sNoBukti,sNama,sKet,sKodeGol,sDivisi VARCHAR(100);
DECLARE sTgl,sTglJurnal DATE;
DECLARE sNilai,sHpp,sPPN,sPPNRps DECIMAL(15,2);
DECLARE sKodePerkD1,sKodePerkD2,sKodePerkD3,sKodePerkD4,sKodePerkD5,sKodePerkD6,sKodePerkD7,sKodePerkD8 CHAR(6);
DECLARE Pendapatan1,Pendapatan2,Pendapatan3,Pendapatan4,Pendapatan5,Pendapatan6,Pendapatan7,Pendapatan8 DECIMAL(15,2);
DECLARE Persediaan1, Persediaan2 DECIMAL(15,2);
DECLARE sIndex,sJmlRow, sIndexPersediaan INTEGER;
SELECT TglJual, NamaCust, Nilai, IFNULL(PPN,0), PPNRps  INTO sTgl, sNama, sNilai, sPPN, sPPNRps FROM tr_jual_m WHERE NoJual=sNoJual;
SELECT SUM(IFNULL(d.HargaAVG,0) * d.Jml), b.KodeGol INTO sHpp, sKodeGol FROM tr_jual_d d 
	JOIN tm_barang b ON d.KodeBrg=b.KodeBrg WHERE d.NoJual=sNoJual GROUP BY d.NoJual;
IF sKodeGol = "001" THEN
	SET sDivisi = "VK";
ELSEIF sKodeGol = "005" THEN
	SET sDivisi = "VD";
ELSEIF sKodeGol = "RUBBERSHEET" THEN
	SET sDivisi = "RS";
ELSEIF sKodeGol = "CAKAR" THEN
	SET sDivisi = "CK";
ELSEIF sKodeGol = "HAMMER" THEN
	SET sDivisi = "HM";
ELSEIF sKodeGol = "KARPETSAPI" THEN
	SET sDivisi = "KS";
ELSEIF sKodeGol = "003" THEN
	SET sDivisi = "SL";
ELSE
	SET sDivisi = "BK";
END IF;
SELECT IFNULL(No_Bukti,""), Tgl_Validasi INTO sNoBukti, sTglJurnal FROM tjurnal_m WHERE NoBukti_Rtl=sNoJual AND Sandi_Trans_id="JT";
IF sNoBukti <> "" THEN
	DELETE FROM tjurnal_d WHERE Tanggal = sTglJurnal AND No_Bukti=sNoBukti AND LEFT(No_Bukti,2)="JT";
	DELETE FROM tjurnal_m WHERE NoBukti_Rtl=sNoJual AND Sandi_Trans_id="JT";
ELSE
	SELECT gennobuktijurnal(CONCAT("JT",DATE_FORMAT(sTgl,"%d%m%y"))) INTO sNoBukti;
END IF;
insert into tjurnal_m (tanggal,no_bukti,keterangan,Sandi_Trans_Id,Status_Val,Nobukti_Rtl,pst,jns_jurnal,tgl_validasi,tgl_edit,user) 	values 
		("0000-00-00",sNoBukti,CONCAT("Penjualan Grosir JT-",sNoJual," , a.n ", sNama),"JT",0,sNoJual,0,"JK",DATE(sTgl),now(),"ADMIN");
insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values (YEAR(sTgl),DATE(sTgl),sNoBukti,1,"511001",sHpp,0,"JK",sDivisi);
insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values (YEAR(sTgl),DATE(sTgl),sNoBukti,2,"113001",sNilai,0,"JK",sDivisi);
SELECT COUNT(*) INTO sJmlRow FROM 
	(SELECT x.KodePerk FROM
		(SELECT CASE WHEN g.NamaGol="OLIE" THEN "115001" WHEN g.NamaGol="BAHAN PEMBANTU" THEN "115001" WHEN g.NamaGol="OBAT" THEN "115001" 
				WHEN g.NamaGol="PLASTIK" THEN "115001" WHEN g.NamaGol="KARET" THEN "115001" ELSE "115002" END KodePerk
		FROM tr_jual_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
		WHERE d.NoJual=sNoJual) x
	GROUP BY x.KodePerk) z;
	
SET sIndex=1;
WHILE sIndex <= sJmlRow DO
	SET @Idx := 0;
	IF sIndex = 1 THEN
		SELECT z.KodePerk,z.Total INTO sKodePerkD1, Persediaan1 FROM 
			(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
				(SELECT CASE WHEN g.NamaGol="OLIE" THEN "115001" WHEN g.NamaGol="BAHAN PEMBANTU" THEN "115001" WHEN g.NamaGol="OBAT" THEN "115001" 
				WHEN g.NamaGol="PLASTIK" THEN "115001" WHEN g.NamaGol="KARET" THEN "115001" ELSE "115002" END KodePerk,(d.Jml * IFNULL(d.HargaAVG,0)) Total
				FROM tr_jual_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
				WHERE d.NoJual=sNoJual) x
			GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
			(YEAR(sTgl),DATE(sTgl),sNoBukti,(sIndex + 2),sKodePerkD1,0,Persediaan1,"JK",sDivisi);
	ELSEIF sIndex = 2 THEN
		SELECT z.KodePerk,z.Total INTO sKodePerkD2, Persediaan2 FROM 
			(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
				(SELECT CASE WHEN g.NamaGol="OLIE" THEN "115001" WHEN g.NamaGol="BAHAN PEMBANTU" THEN "115001" WHEN g.NamaGol="OBAT" THEN "115001" 
				WHEN g.NamaGol="PLASTIK" THEN "115001" WHEN g.NamaGol="KARET" THEN "115001" ELSE "115002" END KodePerk,(d.Jml * IFNULL(d.HargaAVG,0)) Total
				FROM tr_jual_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
				WHERE d.NoJual=sNoJual) x
			GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
			(YEAR(sTgl),DATE(sTgl),sNoBukti,(sIndex + 2),sKodePerkD2,0,Persediaan2,"JK",sDivisi);
	END IF;
	SET sIndex= sIndex + 1; 
END WHILE;
SET sIndexPersediaan = sIndex + 1;
SELECT COUNT(*) INTO sJmlRow FROM 
	(SELECT x.KodePerk FROM
		(SELECT CASE WHEN g.NamaGolAlias="Vulkanisir Panas" THEN "411001"
				WHEN g.NamaGolAlias="Sol" THEN "411002" WHEN g.NamaGolAlias="Vulkanisir Dingin" THEN "411005"
				WHEN g.NamaGol="RUBBER SHEET" THEN "411006" WHEN g.NamaGolAlias="CAKAR" THEN "411010"
				WHEN g.NamaGolAlias="HAMMER" THEN "411011" WHEN g.NamaGolAlias="KARPET SAPI" THEN "411012" ELSE "411020" END KodePerk
			FROM tr_jual_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
			WHERE d.NoJual=sNoJual) x
	GROUP BY x.KodePerk) z;
SET sIndex=1;
WHILE sIndex <= sJmlRow DO
	SET @Idx := 0;
	IF sIndex = 1 THEN
		SELECT z.KodePerk,z.Total INTO sKodePerkD1, Pendapatan1 FROM 
			(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
				(SELECT CASE WHEN g.NamaGolAlias="Vulkanisir Panas" THEN "411001"
					WHEN g.NamaGolAlias="Sol" THEN "411002" WHEN g.NamaGolAlias="Vulkanisir Dingin" THEN "411005"
					WHEN g.NamaGol="RUBBER SHEET" THEN "411006" WHEN g.NamaGolAlias="CAKAR" THEN "411010"
					WHEN g.NamaGolAlias="HAMMER" THEN "411011" WHEN g.NamaGolAlias="KARPET SAPI" THEN "411012" ELSE "411020" END KodePerk,
					(d.Jml * (d.Harga - IFNULL(d.Disc,0))) Total
				FROM tr_jual_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
				WHERE d.NoJual=sNoJual) x
			GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
		IF sPPN > 0 THEN
			SET Pendapatan1 = ROUND(ROUND(Pendapatan1) + FLOOR((ROUND(Pendapatan1) * sPPN /100)));
			
		END IF;
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
			(YEAR(sTgl),DATE(sTgl),sNoBukti,sIndex + sIndexPersediaan,sKodePerkD1,0,ROUND(Pendapatan1),"JK",sDivisi);
	ELSEIF sIndex = 2 THEN
		SELECT z.KodePerk,z.Total INTO sKodePerkD2, Pendapatan2 FROM 
			(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
				(SELECT CASE WHEN g.NamaGolAlias="Vulkanisir Panas" THEN "411001"
					WHEN g.NamaGolAlias="Sol" THEN "411002" WHEN g.NamaGolAlias="Vulkanisir Dingin" THEN "411005"
					WHEN g.NamaGol="RUBBER SHEET" THEN "411006" WHEN g.NamaGolAlias="CAKAR" THEN "411010"
					WHEN g.NamaGolAlias="HAMMER" THEN "411011" WHEN g.NamaGolAlias="KARPET SAPI" THEN "411012" ELSE "411020" END KodePerk,
					(d.Jml * (d.Harga - IFNULL(d.Disc,0))) Total
				FROM tr_jual_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
				WHERE d.NoJual=sNoJual) x
			GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
		IF sPPN > 0 THEN
			SET Pendapatan2 = ROUND(ROUND(Pendapatan2) + FLOOR((ROUND(Pendapatan2) * sPPN /100)));
			
		END IF;
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
			(YEAR(sTgl),DATE(sTgl),sNoBukti,sIndex + sIndexPersediaan,sKodePerkD2,0,ROUND(Pendapatan2),"JK",sDivisi);
	ELSEIF sIndex = 3 THEN
		SELECT z.KodePerk,z.Total INTO sKodePerkD3, Pendapatan3 FROM 
			(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
				(SELECT CASE WHEN g.NamaGolAlias="Vulkanisir Panas" THEN "411001"
					WHEN g.NamaGolAlias="Sol" THEN "411002" WHEN g.NamaGolAlias="Vulkanisir Dingin" THEN "411005"
					WHEN g.NamaGol="RUBBER SHEET" THEN "411006" WHEN g.NamaGolAlias="CAKAR" THEN "411010"
					WHEN g.NamaGolAlias="HAMMER" THEN "411011" WHEN g.NamaGolAlias="KARPET SAPI" THEN "411012" ELSE "411020" END KodePerk,
					(d.Jml * (d.Harga - IFNULL(d.Disc,0))) Total
				FROM tr_jual_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
				WHERE d.NoJual=sNoJual) x
			GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
		IF sPPN > 0 THEN
			SET Pendapatan3 = ROUND(ROUND(Pendapatan3) + FLOOR((ROUND(Pendapatan3) * sPPN /100)));
			
		END IF;
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
			(YEAR(sTgl),DATE(sTgl),sNoBukti,sIndex + sIndexPersediaan,sKodePerkD3,0,ROUND(Pendapatan3),"JK",sDivisi);
	ELSEIF sIndex = 4 THEN
		SELECT z.KodePerk,z.Total INTO sKodePerkD4, Pendapatan4 FROM 
			(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
				(SELECT CASE WHEN g.NamaGolAlias="Vulkanisir Panas" THEN "411001"
					WHEN g.NamaGolAlias="Sol" THEN "411002" WHEN g.NamaGolAlias="Vulkanisir Dingin" THEN "411005"
					WHEN g.NamaGol="RUBBER SHEET" THEN "411006" WHEN g.NamaGolAlias="CAKAR" THEN "411010"
					WHEN g.NamaGolAlias="HAMMER" THEN "411011" WHEN g.NamaGolAlias="KARPET SAPI" THEN "411012" ELSE "411020" END KodePerk,
					(d.Jml * (d.Harga - IFNULL(d.Disc,0))) Total
				FROM tr_jual_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
				WHERE d.NoJual=sNoJual) x
			GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
		IF sPPN > 0 THEN
			SET Pendapatan4 = ROUND(ROUND(Pendapatan4) + FLOOR((ROUND(Pendapatan4) * sPPN /100)));
			
		END IF;
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
			(YEAR(sTgl),DATE(sTgl),sNoBukti,sIndex + sIndexPersediaan,sKodePerkD4,0,ROUND(Pendapatan4),"JK",sDivisi);
	ELSEIF sIndex = 5 THEN
		SELECT z.KodePerk,z.Total INTO sKodePerkD5, Pendapatan5 FROM 
			(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
				(SELECT CASE WHEN g.NamaGolAlias="Vulkanisir Panas" THEN "411001"
					WHEN g.NamaGolAlias="Sol" THEN "411002" WHEN g.NamaGolAlias="Vulkanisir Dingin" THEN "411005"
					WHEN g.NamaGol="RUBBER SHEET" THEN "411006" WHEN g.NamaGolAlias="CAKAR" THEN "411010"
					WHEN g.NamaGolAlias="HAMMER" THEN "411011" WHEN g.NamaGolAlias="KARPET SAPI" THEN "411012" ELSE "411020" END KodePerk,
					(d.Jml * (d.Harga - IFNULL(d.Disc,0))) Total
				FROM tr_jual_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
				WHERE d.NoJual=sNoJual) x
			GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
		IF sPPN > 0 THEN
			SET Pendapatan5 = ROUND(ROUND(Pendapatan5) + FLOOR((ROUND(Pendapatan5) * sPPN /100)));
			
		END IF;
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
			(YEAR(sTgl),DATE(sTgl),sNoBukti,sIndex + sIndexPersediaan,sKodePerkD5,0,ROUND(Pendapatan5),"JK",sDivisi);
	ELSEIF sIndex = 6 THEN
		SELECT z.KodePerk,z.Total INTO sKodePerkD6, Pendapatan6 FROM 
			(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
				(SELECT CASE WHEN g.NamaGolAlias="Vulkanisir Panas" THEN "411001"
					WHEN g.NamaGolAlias="Sol" THEN "411002" WHEN g.NamaGolAlias="Vulkanisir Dingin" THEN "411005"
					WHEN g.NamaGol="RUBBER SHEET" THEN "411006" WHEN g.NamaGolAlias="CAKAR" THEN "411010"
					WHEN g.NamaGolAlias="HAMMER" THEN "411011" WHEN g.NamaGolAlias="KARPET SAPI" THEN "411012" ELSE "411020" END KodePerk,
					(d.Jml * (d.Harga - IFNULL(d.Disc,0))) Total
				FROM tr_jual_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
				WHERE d.NoJual=sNoJual) x
			GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
		IF sPPN > 0 THEN
			SET Pendapatan6 = ROUND(ROUND(Pendapatan6) + FLOOR((ROUND(Pendapatan6) * sPPN /100)));
			
		END IF;
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
			(YEAR(sTgl),DATE(sTgl),sNoBukti,sIndex + sIndexPersediaan,sKodePerkD6,0,ROUND(Pendapatan6),"JK",sDivisi);
	ELSEIF sIndex = 7 THEN
		SELECT z.KodePerk,z.Total INTO sKodePerkD7, Pendapatan7 FROM 
			(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
				(SELECT CASE WHEN g.NamaGolAlias="Vulkanisir Panas" THEN "411001"
					WHEN g.NamaGolAlias="Sol" THEN "411002" WHEN g.NamaGolAlias="Vulkanisir Dingin" THEN "411005"
					WHEN g.NamaGol="RUBBER SHEET" THEN "411006" WHEN g.NamaGolAlias="CAKAR" THEN "411010"
					WHEN g.NamaGolAlias="HAMMER" THEN "411011" WHEN g.NamaGolAlias="KARPET SAPI" THEN "411012" ELSE "411020" END KodePerk,
					(d.Jml * (d.Harga - IFNULL(d.Disc,0))) Total
				FROM tr_jual_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
				WHERE d.NoJual=sNoJual) x
			GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
		IF sPPN > 0 THEN
			SET Pendapatan7 = ROUND(ROUND(Pendapatan7) + FLOOR((ROUND(Pendapatan7) * sPPN /100)));
			
		END IF;
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
			(YEAR(sTgl),DATE(sTgl),sNoBukti,sIndex + sIndexPersediaan,sKodePerkD7,0,ROUND(Pendapatan7),"JK",sDivisi);
	ELSEIF sIndex = 8 THEN
		SELECT z.KodePerk,z.Total INTO sKodePerkD8, Pendapatan8 FROM 
			(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
				(SELECT CASE WHEN g.NamaGolAlias="Vulkanisir Panas" THEN "411001"
					WHEN g.NamaGolAlias="Sol" THEN "411002" WHEN g.NamaGolAlias="Vulkanisir Dingin" THEN "411005"
					WHEN g.NamaGol="RUBBER SHEET" THEN "411006" WHEN g.NamaGolAlias="CAKAR" THEN "411010"
					WHEN g.NamaGolAlias="HAMMER" THEN "411011" WHEN g.NamaGolAlias="KARPET SAPI" THEN "411012" ELSE "411020" END KodePerk,
					(d.Jml * (d.Harga - IFNULL(d.Disc,0))) Total
				FROM tr_jual_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
				WHERE d.NoJual=sNoJual) x
			GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
		IF sPPN > 0 THEN
			SET Pendapatan8 = ROUND(ROUND(Pendapatan8) + FLOOR((ROUND(Pendapatan8) * sPPN /100)));
			
		END IF;
		insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
			(YEAR(sTgl),DATE(sTgl),sNoBukti,sIndex + sIndexPersediaan,sKodePerkD8,0,ROUND(Pendapatan8),"JK",sDivisi);
	END IF;
	SET sIndex= sIndex + 1; 
END WHILE;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `SimpanJurnal_Pembelian` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `SimpanJurnal_Pembelian`(sNoBeli  VARCHAR(15))
BEGIN
	DECLARE NoBukti VARCHAR(30);
  DECLARE sNoBukti VARCHAR(30);
  DECLARE HPP DECIMAL(15,2); 
	DECLARE sTgl DATE;
	DECLARE sNamaSupp VARCHAR(100);
  DECLARE sNilai DECIMAL(15,2);
	DECLARE sKodePerkD1,sKodePerkD2,sKodePerkD3 CHAR(6);
	DECLARE Persediaan1, Persediaan2, Persediaan3 DECIMAL(15,2);
	DECLARE sIndex,sJmlRow INTEGER;
	SELECT TglBeli,NamaSupp, Nilai  INTO sTgl,sNamaSupp, sNilai FROM tr_beli_m WHERE NoBeli=sNoBeli;
	Select No_bukti INTO sNoBukti from tjurnal_m where Jns_jurnal="JK" and Sandi_Trans_Id="BT" and Nobukti_Rtl=sNoBeli LIMIT 0,1;
    
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	SET NoBukti = CONCAT("BT",sNoBeli);
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=NoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=NoBukti;
	insert into tjurnal_m (tanggal,no_bukti,keterangan,Sandi_Trans_Id,Status_Val,Nobukti_Rtl,pst,jns_jurnal,tgl_validasi,tgl_edit,user)	values 
		("0000-00-00",NoBukti,CONCAT("Pembelian BT-",sNoBeli," , a.n ", sNamaSupp),"BT",0,sNoBeli,0,"JK",DATE(sTgl),now(),"ADMIN");
	insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal) values 
			(YEAR(sTgl),DATE(sTgl),NoBukti,1,211001,0,sNilai,"JK");
	SELECT COUNT(*) INTO sJmlRow FROM 
		(SELECT x.KodePerk FROM
			(SELECT CASE WHEN g.NamaGol="AVALAN" THEN "113003" WHEN g.NamaGol="OBAT" THEN "113001" WHEN g.NamaGol="KARET" THEN "113001" 
				WHEN g.NamaGol="BAHAN PEMBANTU" THEN "113001" ELSE "113002" END KodePerk
			FROM tr_beli_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
			WHERE d.NoBeli=sNoBeli) x
		GROUP BY x.KodePerk) z;
	SET sIndex=1;
	WHILE sIndex <= sJmlRow DO
		SET @Idx := 0;
		IF sIndex = 1 THEN
			SELECT z.KodePerk,z.Total INTO sKodePerkD1, Persediaan1 FROM 
				(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
					(SELECT CASE WHEN g.NamaGol="AVALAN" THEN "113003" WHEN g.NamaGol="OBAT" THEN "113001" WHEN g.NamaGol="KARET" THEN "113001" 
				WHEN g.NamaGol="BAHAN PEMBANTU" THEN "113001" ELSE "113002" END KodePerk,(d.Jml * IFNULL(d.Harga,0)) Total
					FROM tr_beli_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
					WHERE d.NoBeli=sNoBeli) x
				GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
			insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,(sIndex + 1),sKodePerkD1,Persediaan1,0,"JK");
		ELSEIF sIndex = 2 THEN
			SELECT z.KodePerk,z.Total INTO sKodePerkD2, Persediaan2 FROM 
				(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
					(SELECT CASE WHEN g.NamaGol="AVALAN" THEN "113003" WHEN g.NamaGol="OBAT" THEN "113001" WHEN g.NamaGol="KARET" THEN "113001" 
				WHEN g.NamaGol="BAHAN PEMBANTU" THEN "113001" ELSE "113002" END KodePerk,(d.Jml * IFNULL(d.Harga,0)) Total
					FROM tr_beli_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
					WHERE d.NoBeli=sNoBeli) x
				GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
			insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,(sIndex + 1),sKodePerkD2,Persediaan2,0,"JK");
		ELSEIF sIndex = 3 THEN
			SELECT z.KodePerk,z.Total INTO sKodePerkD3, Persediaan3 FROM 
				(SELECT x.KodePerk,SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
					(SELECT CASE WHEN g.NamaGol="AVALAN" THEN "113003" WHEN g.NamaGol="OBAT" THEN "113001" WHEN g.NamaGol="KARET" THEN "113001" 
				WHEN g.NamaGol="BAHAN PEMBANTU" THEN "113001" ELSE "113002" END KodePerk,(d.Jml * IFNULL(d.Harga,0)) Total
					FROM tr_beli_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
					WHERE d.NoBeli=sNoBeli) x
				GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
			insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,(sIndex + 1),sKodePerkD3,Persediaan3,0,"JK");
		END IF;
		SET sIndex= sIndex + 1; 
	END WHILE;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `SimpanJurnal_PengeluaranBrg` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `SimpanJurnal_PengeluaranBrg`(sNoBB VARCHAR(15))
BEGIN
	DECLARE NoBukti VARCHAR(30);
  DECLARE sNoBukti VARCHAR(30); 
  DECLARE HPP1,HPP2,HPP3 DECIMAL(15,2);
	DECLARE sTgl DATE;
	DECLARE sNama VARCHAR(100);
  DECLARE sNilai DECIMAL(15,2);
	DECLARE sKodePerkM, sKodePerkD1,sKodePerkD2,sKodePerkD3 CHAR(6);
	DECLARE sIndex,sJmlRow INTEGER;
	SELECT TglBB,Divisi, Nilai INTO sTgl,sNama, sNilai FROM tr_bbkeluar_m WHERE NoBB=sNoBB;
	Select No_bukti INTO sNoBukti from tjurnal where Jns_jurnal="JK" and Sandi_Trans_Id="BB" and Nobukti_Rtl=sNoBB LIMIT 0,1;
    
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	SET NoBukti = CONCAT("BB",sNoBB);
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=NoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=NoBukti;
	insert into tjurnal_m (tanggal,no_bukti,keterangan,Sandi_Trans_Id,Status_Val,Nobukti_Rtl,pst,jns_jurnal,tgl_validasi,tgl_edit,user) 	values 
		("0000-00-00",NoBukti,CONCAT("Pengeluaran Bahan Baku BB-",sNoBB," , Divisi: ", sNama),"BB",0,sNoBB,0,"JK",DATE(sTgl),now(),"ADMIN");
	insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,1,"531010",sNilai,0,"JK",sNama);
	SELECT COUNT(*) INTO sJmlRow FROM 
		(SELECT x.KodePerk FROM
			(SELECT CASE WHEN g.NamaGol="AVALAN" THEN "113003" WHEN g.NamaGol="OBAT" THEN "113001" WHEN g.NamaGol="KARET" THEN "113001" 
					WHEN g.NamaGol="BAHAN PEMBANTU" THEN "113001" ELSE "113002" END KodePerk
				FROM tr_bbkeluar_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
				WHERE d.NoBB=sNoBB) x
		GROUP BY x.KodePerk) z;
	SET sIndex=1;
	WHILE sIndex <= sJmlRow DO
		SET @Idx := 0;
		IF sIndex = 1 THEN
			SELECT z.KodePerk,z.Total INTO sKodePerkD1, HPP1 FROM
				(SELECT x.KodePerk, SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
					(SELECT CASE WHEN g.NamaGol="AVALAN" THEN "113003" WHEN g.NamaGol="OBAT" THEN "113001" WHEN g.NamaGol="KARET" THEN "113001" 
							WHEN g.NamaGol="BAHAN PEMBANTU" THEN "113001" ELSE "113002" END KodePerk, (d.Jml * d.HargaAVG) Total
						FROM tr_bbkeluar_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
						WHERE d.NoBB=sNoBB) x
				GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
			insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,(sIndex +1),sKodePerkD1,0,HPP1,"JK",sNama);
		ELSEIF sIndex = 2 THEN
			SELECT z.KodePerk,z.Total INTO sKodePerkD2, HPP2 FROM
				(SELECT x.KodePerk, SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
					(SELECT CASE WHEN g.NamaGol="AVALAN" THEN "113003" WHEN g.NamaGol="OBAT" THEN "113001" WHEN g.NamaGol="KARET" THEN "113001" 
							WHEN g.NamaGol="BAHAN PEMBANTU" THEN "113001" ELSE "113002" END KodePerk, (d.Jml * d.HargaAVG) Total
						FROM tr_bbkeluar_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
						WHERE d.NoBB=sNoBB) x
				GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
			insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,(sIndex +1),sKodePerkD2,0,HPP2,"JK",sNama);
		ELSEIF sIndex = 3 THEN
			SELECT z.KodePerk,z.Total INTO sKodePerkD3, HPP3 FROM
				(SELECT x.KodePerk, SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
					(SELECT CASE WHEN g.NamaGol="AVALAN" THEN "113003" WHEN g.NamaGol="OBAT" THEN "113001" WHEN g.NamaGol="KARET" THEN "113001"
							WHEN g.NamaGol="BAHAN PEMBANTU" THEN "113001" ELSE "113002" END KodePerk, (d.Jml * d.HargaAVG) Total
						FROM tr_bbkeluar_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
						WHERE d.NoBB=sNoBB) x
				GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
			insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal,divisi) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,(sIndex +1),sKodePerkD3,0,HPP3,"JK",sNama);
		END IF;
		SET sIndex= sIndex + 1; 
	END WHILE;
	
	
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `SimpanJurnal_Produksi` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `SimpanJurnal_Produksi`(sNoProduksi VARCHAR(15))
BEGIN
	DECLARE NoBukti VARCHAR(30);
  DECLARE sNoBukti VARCHAR(30); 
  DECLARE HPP1,HPP2,HPP3 DECIMAL(15,2);
	DECLARE sTgl DATE;
	DECLARE sNama,sKodeBrg VARCHAR(100);
  DECLARE sNilai,sNilaiD DECIMAL(15,2);
	DECLARE sKodePerkM, sKodePerkD1,sKodePerkD2,sKodePerkD3 CHAR(6);
	DECLARE sIndex,sJmlRow INTEGER;
	SELECT TglProduksi,KodeProduk, Nilai INTO sTgl,sKodeBrg, sNilai FROM tr_hasilproduksi_m WHERE NoProduksi=sNoProduksi;
  SELECT NamaBrg INTO sNama FROM tm_barang WHERE KodeBrg=sKodeBrg;
	Select No_bukti INTO sNoBukti from tjurnal where Jns_jurnal="JK" and Sandi_Trans_Id="HP" and Nobukti_Rtl=sNoProduksi LIMIT 0,1;
    
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=sNoBukti;
	SET NoBukti = CONCAT("HP",sNoProduksi);
	delete from tJurnal_d where Jns_Jurnal="JK" and No_bukti=NoBukti;
	delete from tJurnal_m where Jns_Jurnal="JK" and No_bukti=NoBukti;
	SELECT IF(g.NamaGol="AVALAN","113003",IF(g.NamaGOl="KARET","113001","113002")) INTO sKodePerkM
		FROM tr_hasilproduksi_m m JOIN tm_barang b ON m.KodeProduk=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
		WHERE m.NoProduksi=sNoProduksi;
	IF sKodePerkM <> "113001" THEN
	insert into tjurnal_m (tanggal,no_bukti,keterangan,Sandi_Trans_Id,Status_Val,Nobukti_Rtl,pst,jns_jurnal,tgl_validasi,tgl_edit,user) 	values 
		("0000-00-00",NoBukti,CONCAT("Produksi HP-",sNoProduksi," , Barang: ", sNama),"HP",0,sNoProduksi,0,"JK",DATE(sTgl),now(),"ADMIN");
	SELECT COUNT(*) INTO sJmlRow FROM 
		(SELECT x.KodePerk FROM
			(SELECT CASE WHEN g.NamaGol="AVALAN" THEN "113003" WHEN g.NamaGol="OBAT" THEN "113001" WHEN g.NamaGol="KARET" 
					THEN "113001" WHEN g.NamaGol="BAHAN PEMBANTU" THEN "113001" ELSE "113002" END KodePerk
				FROM tr_hasilproduksi_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
				WHERE d.NoProduksi=sNoProduksi) x
		GROUP BY x.KodePerk) z;
	SET sNilaiD=0;
	SET sIndex=1;
	WHILE sIndex <= sJmlRow DO
		SET @Idx := 0;
		IF sIndex = 1 THEN
			SELECT z.KodePerk,z.Total INTO sKodePerkD1, HPP1 FROM
				(SELECT x.KodePerk, SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
					(SELECT CASE WHEN g.NamaGol="AVALAN" THEN "113003" WHEN g.NamaGol="OBAT" THEN "113001" WHEN g.NamaGol="KARET" 
							THEN "113001" WHEN g.NamaGol="BAHAN PEMBANTU" THEN "113001" ELSE "113002" END KodePerk, (d.Jml * d.Harga) Total
						FROM tr_hasilproduksi_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
						WHERE d.NoProduksi=sNoProduksi) x
				GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
			insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,sIndex,sKodePerkD1,0,HPP1,"JK");
			SET sNilaiD=sNilaiD + HPP1;
		ELSEIF sIndex = 2 THEN
			SELECT z.KodePerk,z.Total INTO sKodePerkD2, HPP2 FROM
				(SELECT x.KodePerk, SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
					(SELECT CASE WHEN g.NamaGol="AVALAN" THEN "113003" WHEN g.NamaGol="OBAT" THEN "113001" WHEN g.NamaGol="KARET" 
							THEN "113001" WHEN g.NamaGol="BAHAN PEMBANTU" THEN "113001" ELSE "113002" END KodePerk, (d.Jml * d.Harga) Total
						FROM tr_hasilproduksi_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
						WHERE d.NoProduksi=sNoProduksi) x
				GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
			insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,sIndex,sKodePerkD2,0,HPP2,"JK");
			SET sNilaiD=sNilaiD + HPP2;
		ELSEIF sIndex = 3 THEN
			SELECT z.KodePerk,z.Total INTO sKodePerkD3, HPP3 FROM
				(SELECT x.KodePerk, SUM(x.Total) Total, @Idx:=@Idx+1 Idx1 FROM
					(SELECT CASE WHEN g.NamaGol="AVALAN" THEN "113003" WHEN g.NamaGol="OBAT" THEN "113001" WHEN g.NamaGol="KARET" 
							THEN "113001" WHEN g.NamaGol="BAHAN PEMBANTU" THEN "113001" ELSE "113002" END KodePerk, (d.Jml * d.Harga) Total
						FROM tr_hasilproduksi_d d JOIN tm_barang b ON d.KodeBrg=b.KodeBrg JOIN tm_golongan g ON b.KodeGol=g.KodeGol
						WHERE d.NoProduksi=sNoProduksi) x
				GROUP BY x.KodePerk) z WHERE z.Idx1 =sIndex;
			insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal) values 
				(YEAR(sTgl),DATE(sTgl),NoBukti,sIndex,sKodePerkD3,0,HPP3,"JK");
			SET sNilaiD=sNilaiD + HPP3;
		END IF;
		SET sIndex= sIndex + 1; 
	END WHILE;
	insert into tjurnal_d(tahun,tanggal,no_bukti,row_id,kode_perk,debet,kredit,jns_jurnal) values 
		(YEAR(sTgl),DATE(sTgl),NoBukti,sIndex,sKodePerkM,sNilaiD,0,"JK");
	END IF;
	
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `tr_kartuStock` */;;
/*!50003 SET SESSION SQL_MODE="NO_AUTO_VALUE_ON_ZERO"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`client`@`%`*/ /*!50003 PROCEDURE `tr_kartuStock`(sKodeBrg Varchar(20), sTglStart DATE, sTglEnd DATE)
BEGIN
	DECLARE finished INTEGER DEFAULT 0; 
	DECLARE sUrut,sKeterangan,sKodeGD,sTglTransaksi,sNoBukti,sTransID, sNoTransaksi, sKodeBrg1 VARCHAR(200);
	DECLARE sDebet,sKredit,sHargaAVG, sTotalAVG DECIMAL(15,2);
	 DECLARE sJmlLama, sHargaLama, sTotalLama, sTotalBaru, sHargaAVGBaru, sSaldoStock DECIMAl(15,2);
	
	DEClARE curKartu 
		CURSOR FOR 
				SELECT Urut,Kode, tanggal,debet, kredit, nobukti, TransID, NoTransaksi, KodeBrg, HargaAVG, TotalAVG
	FROM
		(
			SELECT 'D1' Urut, mst.namasupp AS Kode, mst.tglbeli AS Tanggal, ifnull(dets.jml, 0) * ifnull(konv, 1) AS Debet, 0 AS Kredit,
				concat(dets.transbeli,'-',dets.nobeli) AS nobukti, dets.TransBeli TransID,dets.Nobeli NoTransaksi, dets.KodeBrg KodeBrg,dets.Harga HargaAVG,
				dets.harga * dets.Jml TotalAVG, dets.itembeli itembukti, 0 AS Saldo
			FROM Tr_Beli_m Mst, tr_Beli_d dets
			WHERE Mst.noBeli = Dets.nobeli AND mst.transbeli = dets.transbeli AND kodebrg = sKodeBrg
			UNION ALL
			SELECT 'K1' Urut, 'RETBELI' Kode, mst.tglretb, 0 AS Debet, ifnull(ifnull(dets.jml, 0) * ifnull(konv, 1),0) Kredit,
				concat(dets.transretb,'-',dets.noretb) AS nobukti, dets.TransRetB,dets.NoRetB, dets.KodeBrg, dets.Harga, dets.Harga * dets.Jml * -1,
				dets.itemretB itembukti,0 AS Saldo
			FROM Tr_RetBeli_M Mst, Tr_RetBeli_D dets
			WHERE Mst.noretb = Dets.noretb AND mst.transretb = dets.transretb AND kodebrg = sKodeBrg
			UNION ALL
			SELECT "K2" Urut, "Bahan Produksi" Kode, mst.tglProduksi AS Tanggal, 0 AS Debet, ifnull(dets.jml, 0) * ifnull(dets.konv, 1) Kredit,
				CONCAT('HP-',dets.noProduksi) nobukti, Mst.TransProd, dets.NoProduksi,Dets.kodebrg,Dets.Harga,Dets.total,
				CAST(dets.itemBrg AS UNSIGNED) itembukti,0 AS Saldo
			FROM tr_hasilproduksi_m Mst,tr_hasilproduksi_d Dets
			WHERE Mst.NoProduksi = Dets.NoProduksi AND dets.kodebrg = sKodeBrg
			UNION ALL
			SELECT "D2" Urut, "Hasil Produksi" Kode, TglProduksi Tanggal, ifnull(JmlProduksi, 0) Debet, 0 AS Kredit, CONCAT('HP-',noProduksi) nobukti,TransProd,
				NoProduksi,KodeProduk, (Nilai / JmlProduksi), Nilai, CAST(1 AS UNSIGNED) itembukti, 0 AS Saldo
			FROM tr_hasilproduksi_m
			WHERE KodeProduk = sKodeBrg
			UNION ALL
			SELECT 'D3' Urut, 'KOREKSI STOCK' Kode, mst.tglKoreksi, ifnull(dets.selisihLebih, 0) Debet, 0 AS Kredit,
				'Opname' nobukti, NULL,dets.NoKoreksi,dets.KodeBrg,dets.Harga, dets.Harga * dets.SelisihLebih,
				dets.itemdet itembukti,ifnull(ifnull(dets.selisihLebih, 0) * ifnull(konv, 1),0) * 0 AS Saldo
			FROM tr_koreksiStc_m Mst, tr_koreksiStc_d dets
			WHERE Mst.nokoreksi = dets.nokoreksi AND ifnull(dets.selisihLebih, 0) > 0 AND kodebrg = sKodeBrg
			UNION ALL
			SELECT 'K3' Urut, 'KOREKSI STOCK' Kode, mst.tglKoreksi, 0 AS Debet, ifnull(dets.selisihKurang, 0) Kredit, 
				'Opname' nobukti, NULL,dets.NoKoreksi,dets.KodeBrg,dets.Harga, dets.Harga * dets.SelisihKurang * -1,
				dets.itemdet itembukti,ifnull(ifnull(dets.selisihKurang, 0) * ifnull(konv, 1),0) * 0 AS Saldo
			FROM tr_koreksiStc_m Mst, tr_koreksiStc_d dets
			WHERE Mst.nokoreksi = dets.nokoreksi AND ifnull(dets.selisihKurang, 0) > 0 AND kodebrg = sKodeBrg
			UNION ALL
			SELECT 'K4' Urut, concat(mst.NamaCust, ifnull(Kodesales, '')) AS Kode,	mst.tglJual, 0 AS Debet, ifnull(ifnull(dets.jml, 0) * ifnull(konv, 1),0) Kredit,
				concat(dets.transretail,'-',dets.noJualR) AS nobukti, dets.TransRetail, dets.NoJualR,dets.KodeBrg,dets.HargaAVG,dets.HargaAVG * ifnull(ifnull(dets.jml, 0) * ifnull(konv, 1),0) * -1,
				dets.itemjual itembukti, ifnull(ifnull(dets.jml, 0) * ifnull(konv, 1),0) * 0 AS Saldo
			FROM Tr_JualR_M Mst, Tr_JualR_D dets
			WHERE Mst.noJualR = Dets.nojualR AND mst.transRetail = dets.transRetail AND kodebrg = sKodeBrg
			UNION ALL
			SELECT 'D5' Urut,mst.NamaCust AS Kode,mst.tglretJ AS Tanggal,ifnull(ifnull(dets.jml, 0) * ifnull(konv, 1),0) Debet,0 AS Kredit,
				concat(dets.transRetJ,'-',dets.noRetJ) AS nobukti, dets.TransRetJ, dets.NoRetJ, dets.KodeBrg, 0, 0,
				dets.itemretJ itembukti,ifnull(ifnull(dets.jml, 0) * ifnull(konv, 1),0) * 0 AS Saldo
			FROM Tr_RetJualR_M Mst,Tr_RetJualR_D Dets
			WHERE Mst.noRetJ = Dets.noRetJ AND mst.transRetJ = dets.transRetJ AND kodebrg = sKodeBrg
			UNION ALL
			SELECT 'K6' Urut,concat(mst.NamaCust,ifnull(Kodesales, '')) AS Kode,mst.tglJual,0 AS Debet,ifnull(ifnull(dets.jml, 0) * ifnull(konv, 1),0) Kredit,
				concat(dets.transjual,'-',dets.noJual) AS nobukti, dets.TransJual, dets.NoJual, dets.KodeBrg, HargaAVG, HargaAVG * ifnull(ifnull(dets.jml, 0) * ifnull(konv, 1),0) * -1,
				dets.itemjual itembukti,ifnull(ifnull(dets.jml, 0) * ifnull(konv, 1),0) * 0 AS Saldo
			FROM Tr_Jual_M Mst, Tr_Jual_D dets
			WHERE Mst.noJual = Dets.nojual AND mst.transJual = dets.transJual AND kodebrg = sKodeBrg
			UNION ALL
			SELECT 'D7' Urut,tdr.NamaCust AS Kode,mst.tglretJ AS Tanggal,ifnull(ifnull(dets.jml, 0) * ifnull(konv, 1),0) Debet,0 AS Kredit,
				concat(dets.transRetJ,'-',dets.noRetJ) AS nobukti, dets.TransRetJ, dets.NoRetJ, dets.KodeBrg, 0,0,
				dets.itemretJ itembukti,ifnull(ifnull(dets.jml, 0) * ifnull(konv, 1),0) * 0 AS Saldo
			FROM Tr_RetJual_M Mst, tm_Customer tdr, Tr_RetJual_D Dets
			WHERE Mst.noRetJ = Dets.noRetJ AND mst.transRetJ = dets.transRetJ AND mst.KodeCust = tdr.KodeCust AND kodebrg = sKodeBrg
			UNION ALL
			SELECT 'AX' Urut,'SALDO AWAL' Kode,cast('1999-12-31' AS datetime) AS tgl,IfNull(Mst.saldoawal, 0) * IfNull(Mst.konv, 1) debs,0,
				NULL,NULL, NULL,KodeBrg,mst.HargaAVG,mst.HargaAVG * IfNull(Mst.saldoawal, 0) * IfNull(Mst.konv, 1),
				NULL,IfNull(Mst.saldoawal, 0) * IfNull(Mst.konv, 1) AS saldo
			FROM Tb_SaldoAwal Mst
			WHERE 1 = 1 AND kodebrg = sKodeBrg
	) xx
	ORDER BY Tanggal,urut,nobukti,itembukti;
	
	DECLARE CONTINUE HANDLER 
        FOR NOT FOUND SET finished = 1;
	OPEN curKartu;
	getKartu: LOOP
		FETCH curKartu INTO sUrut,sKeterangan,sTglTransaksi,sDebet,sKredit,sNoBukti,sTransID, sNoTransaksi, sKodeBrg1, sHargaAVG, sTotalAVG;
		IF finished = 1 THEN 
			LEAVE getKartu;
		END IF;
		
    SET sHargaAVGBaru=0;
		IF (sUrut="AX") AND (sDebet > 0) THEN
			UPDATE tm_barang SET HargaAVG=sHargaAVG WHERE KodeBrg=sKodeBrg1;
		ELSEIF sTransID="BT" THEN
      SET sJmlLama = (SELECT IFNULL(SUM(Debet),0) - IFNULL(SUM(Kredit),0) FROM tr_kartuStock);
      SET sHargaLama = (SELECT HargaAVG FROM tm_barang WHERE KodeBrg=sKodeBrg1);
      SET sTotalLama = (IFNULL(sJmlLama,0) * IFNULL(sHargaLama,0));
      SET sTotalBaru = (IFNULL(sDebet - sKredit,0) * IFNULL(sHargaAVG,0));
      IF sJmlLama > 0 THEN
        SET sHargaAVGBaru = ((sTotalLama + sTotalBaru) / (sJmlLama + sDebet - sKredit));
      ELSE
        SET sHargaAVGBaru = sHargaAVG;
      END IF;
      UPDATE tm_barang SET HargaAVG=sHargaAVGBaru WHERE KodeBrg=sKodeBrg1;
		ELSEIF (sUrut="D2") THEN			
      SET sJmlLama = (SELECT IFNULL(SUM(Debet),0) - IFNULL(SUM(Kredit),0) FROM tr_kartuStock);
      SET sHargaLama = (SELECT HargaAVG FROM tm_barang WHERE KodeBrg=sKodeBrg1);
      SET sTotalLama = (IFNULL(sJmlLama,0) * IFNULL(sHargaLama,0));
      SET sTotalBaru = (IFNULL(sDebet - sKredit,0) * IFNULL(sHargaAVG,0));
      IF sJmlLama > 0 THEN
        SET sHargaAVGBaru = ((sTotalLama + sTotalBaru) / (sJmlLama + sDebet - sKredit));
      ELSE
        SET sHargaAVGBaru = sHargaAVG;
      END IF;
      UPDATE tm_barang SET HargaAVG=sHargaAVGBaru WHERE KodeBrg=sKodeBrg1;
		ELSEIF (sTransID="JT") AND (DATE(sTglTransaksi) >= sTglStart) AND (DATE(sTglTransaksi) <= sTglEnd)  THEN
      UPDATE tr_jual_d SET HargaAVG=(SELECT HargaAVG FROM tm_barang WHERE KodeBrg=sKodeBrg1) WHERE NoJual=sNoTransaksi AND KodeBrg=sKodeBrg1; 
		END IF;
   SET sSaldoStock = (SELECT SUM(Debet) - SUM(Kredit) FROM tr_kartuStock) + sDebet - sKredit;
   SET sHargaAVGBaru = (SELECT HargaAVG FROM tm_barang WHERE KodeBrg=sKodeBrg1);
		INSERT INTO tr_kartustock(Urut,Keterangan,TglTransaksi,Debet,Kredit,NoBukti, TransID, NoTransaksi, KodeBrg,HargaAVG,TotalHargaAVG, SaldoStock) VALUES
			(sUrut,sKeterangan,sTglTransaksi,sDebet,sKredit,sNoBukti,sTransID, sNoTransaksi, sKodeBrg1, sHargaAVGBaru, (sHargaAVGBaru * sSaldoStock), sSaldoStock);
	END LOOP getKartu;
	CLOSE curKartu; 
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `UpdateMasterBrg_HargaGrosir_drJualGrosir` */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `UpdateMasterBrg_HargaGrosir_drJualGrosir`()
BEGIN
  DECLARE finished INTEGER DEFAULT 0;
	DECLARE sKodeBrg VARCHAR(20);
	DECLARE sHarga DECIMAL(15,2);
	DECLARE sJmlRow INTEGER;
	DEClARE curBrg
		CURSOR FOR 
			SELECT x.* FROM (SELECT KodeBrg FROM tm_barang WHERE Aktif="Y") x;
	DECLARE CONTINUE HANDLER 
        FOR NOT FOUND SET finished = 1;
	OPEN curBrg;
	getBrg: LOOP
		FETCH curBrg INTO sKodeBrg;
		IF finished = 1 THEN 
			LEAVE getBrg;
		END IF;
		SET sHarga =0;
		SELECT COUNT(*) INTO sJmlRow FROM tr_jual_d WHERE KodeBrg=sKodeBrg;
		IF sJmlRow > 0 THEN
			SELECT IFNULL(d.Harga,0) INTO sHarga FROM tr_jual_d d
				WHERE d.KodeBrg=sKodeBrg AND (d.NoJual=(SELECT MAX(NoJual) FROM tr_jual_d WHERE KodeBrg=sKodeBrg))
				GROUP BY d.KodeBrg;
			IF sHarga > 0 THEN
				UPDATE tm_barang SET HargaGrosir=sHarga WHERE KodeBrg=sKodeBrg;
			END IF;
		END IF;
	END LOOP getBrg;
	CLOSE curBrg;
END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
DELIMITER ;

--
-- Final view structure for view `tjurnal`
--

/*!50001 DROP TABLE IF EXISTS `tjurnal`*/;
/*!50001 DROP VIEW IF EXISTS `tjurnal`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `tjurnal` AS select `a`.`Jns_jurnal` AS `Jns_jurnal`,`a`.`Tanggal` AS `Tanggal`,`a`.`Tgl_Validasi` AS `Tgl_Validasi`,`a`.`No_bukti` AS `No_bukti`,`b`.`Row_id` AS `Row_id`,`a`.`Keterangan` AS `Keterangan`,`a`.`Pst` AS `Pst`,`a`.`Tgl_Edit` AS `Tgl_Edit`,`a`.`User` AS `User`,`a`.`Sandi_trans_id` AS `Sandi_trans_id`,`a`.`Norek_Simp` AS `Norek_Simp`,`a`.`Norek_Pinj` AS `Norek_Pinj`,`a`.`Norek_Dep` AS `Norek_Dep`,`a`.`Status_Val` AS `Status_Val`,`a`.`Status_AB` AS `Status_AB`,`a`.`Nobukti_Rtl` AS `Nobukti_Rtl`,`b`.`Kode_perk` AS `Kode_perk`,`b`.`Debet` AS `Debet`,`b`.`Kredit` AS `Kredit`,`b`.`divisi` AS `divisi` from (`tjurnal_m` `a` join `tjurnal_d` `b`) where ((`a`.`Jns_jurnal` = `b`.`Jns_jurnal`) and (`a`.`No_bukti` = `b`.`No_bukti`) and (`a`.`Tgl_Validasi` = `b`.`Tanggal`)) */;


