


DELIMITER $$
CREATE PROCEDURE `proc_delete_unit_safe` (IN `p_unit_id` CHAR(10), IN `p_productid` CHAR(30))   BEGIN
  DECLARE v_total BIGINT DEFAULT 0;
  -- hitung pemakaian (pakai query dinamis seperti sebelumnya)
  SET SESSION group_concat_max_len = 1000000;

  IF @sql IS NOT NULL AND @sql <> '' THEN
    SET @sql = CONCAT('SELECT SUM(c) INTO @total_used FROM (', @sql, ') x;');
    PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
    SET v_total = IFNULL(@total_used,0);
  END IF;
  SELECT v_total AS total_used;
END$$

CREATE PROCEDURE `proc_rename_unit_cascade` (IN `p_old_name` CHAR(10), IN `p_new_name` VARCHAR(10), IN `p_productid` CHAR(30))   BEGIN
  DECLARE done INT DEFAULT 0;
  DECLARE v_table VARCHAR(64);

  DECLARE cur CURSOR FOR
    SELECT c1.TABLE_NAME
    FROM INFORMATION_SCHEMA.COLUMNS c1
    JOIN INFORMATION_SCHEMA.COLUMNS c2
      ON c2.TABLE_SCHEMA = c1.TABLE_SCHEMA
     AND c2.TABLE_NAME   = c1.TABLE_NAME
     AND c2.COLUMN_NAME  = 'productid'
    WHERE c1.TABLE_SCHEMA = DATABASE()
      AND c1.COLUMN_NAME  = 'unit'
    GROUP BY c1.TABLE_NAME;

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

  START TRANSACTION;

  OPEN cur;

  read_loop: LOOP
    FETCH cur INTO v_table;
    IF done = 1 THEN
      LEAVE read_loop;
    END IF;

    SET @sql = CONCAT(
      'UPDATE `', REPLACE(v_table,'`','``'), '` ',
      'SET `unit` = ', QUOTE(p_new_name),
      ' WHERE `unit` = ', QUOTE(p_old_name),
      ' AND `productid` = ', QUOTE(p_productid)
    );

    PREPARE s FROM @sql;
    EXECUTE s;
    DEALLOCATE PREPARE s;
  END LOOP;

  CLOSE cur;

  COMMIT;
END$$

CREATE PROCEDURE `sp_sales_pivot_month_division` (IN `p_from` DATE, IN `p_to` DATE)   BEGIN
  DECLARE v_cols LONGTEXT;
  DECLARE v_sql  LONGTEXT;

  SET @from := p_from;
  SET @to_exclusive := DATE_ADD(p_to, INTERVAL 1 DAY);

  SET SESSION group_concat_max_len = 1000000;

  /* 2. Query utama + kolom TOTAL */
  IF v_cols IS NULL OR v_cols = '' THEN
    SET v_sql = 'SELECT NULL AS `month`, NULL AS `Total` WHERE ? IS NOT NULL AND ? IS NOT NULL AND 1=0';
  ELSE
    SET v_sql = CONCAT(
      'SELECT DATE_FORMAT(s.salesdate, ''%b-%y'') AS `month`, ',
      v_cols, ',
      SUM(IF(s.kind=0, s.salestotal, -s.salestotal)) AS `Total`
      FROM sales s
      JOIN division d ON d.id = s.division
      WHERE s.salesdate >= ? AND s.salesdate < ?
      GROUP BY DATE_FORMAT(s.salesdate, ''%b-%y'')
      ORDER BY DATE_FORMAT(s.salesdate, ''%Y-%m'')'
    );
  END IF;

  SET @sql := v_sql;
  PREPARE stmt FROM @sql;
  EXECUTE stmt USING @from, @to_exclusive;
  DEALLOCATE PREPARE stmt;
END$$

CREATE PROCEDURE `sp_sales_pivot_year_division` (IN `p_year_from` INT, IN `p_year_to` INT)   BEGIN
  DECLARE v_cols LONGTEXT;
  DECLARE v_sql  LONGTEXT;

  SET @year_from := p_year_from;
  SET @year_to   := p_year_to;

  SET SESSION group_concat_max_len = 1000000;

  /* 2. Query utama + kolom TOTAL */
  IF v_cols IS NULL OR v_cols = '' THEN

    SET v_sql = 'SELECT NULL AS `year`, NULL AS `Total` WHERE ? IS NOT NULL AND ? IS NOT NULL AND 1=0';

  ELSE

    SET v_sql = CONCAT(
      'SELECT 
         YEAR(s.salesdate) AS `year`, ',
         v_cols, ',
         SUM(IF(s.kind=0, s.salestotal, -s.salestotal)) AS `Total`
       FROM sales s
       JOIN division d ON d.id = s.division
       WHERE YEAR(s.salesdate) BETWEEN ? AND ?
       GROUP BY YEAR(s.salesdate)
       ORDER BY YEAR(s.salesdate)'
    );

  END IF;
  SET @sql := v_sql;
  PREPARE stmt FROM @sql;
  IF v_cols IS NULL OR v_cols = '' THEN
    EXECUTE stmt;
  ELSE
    EXECUTE stmt USING @year_from, @year_to;
  END IF;

  DEALLOCATE PREPARE stmt;

END$$

DELIMITER ;

CREATE TABLE `account` (
  `id` char(30) NOT NULL DEFAULT '',
  `name` varchar(150) NOT NULL DEFAULT '',
  `accountgroup` char(30) NOT NULL DEFAULT '',
  `accountcategory` tinyint(4) NOT NULL DEFAULT 0,
  `accounttype` tinyint(4) DEFAULT NULL,
  `isgroup` tinyint(1) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `account` (`id`, `name`, `accountgroup`, `accountcategory`, `accounttype`, `isgroup`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('1', 'ASET', '', 0, 1, 1, 'admin', '', '2024-05-05 00:06:29'),
('10', 'Aset Lancar', '1', 0, 1, 1, 'admin', '', '2024-05-05 00:06:29'),
('101', 'Kas', '10', 0, 1, 1, 'admin', '', '2024-02-05 16:29:27'),
('101.001', 'Kas', '101', 0, 1, 0, 'admin', '', '2024-02-05 14:57:04'),
('101.002', 'Kas Kecil', '101', 0, 1, 0, 'admin', '', '2024-06-25 21:44:17'),
('101.003', 'Kas kasir POS', '101', 0, 1, 0, 'admin', '', '2024-02-05 14:57:04'),
('102', 'Bank', '10', 0, 1, 1, 'admin', '', '2024-02-05 16:29:27'),
('102.001', 'Bank A', '102', 0, 1, 0, 'admin', '', '2024-02-05 14:57:04'),
('102.002', 'Bank B', '102', 0, 1, 0, 'admin', '', '2024-02-05 14:57:04'),
('102.003', 'Bank C', '102', 0, 1, 0, 'admin', '', '2024-02-05 14:57:04'),
('103', 'Surat-surat Berharga', '10', 0, 5, 1, 'admin', '', '2024-02-05 16:29:27'),
('103.001', 'Deposito', '103', 0, 5, 0, 'admin', '', '2024-02-05 14:57:04'),
('103.002', 'Surat berharga pasar uang', '103', 0, 5, 0, 'admin', '', '2024-02-05 14:57:04'),
('103.999', 'Surat berharga lain-lain', '103', 0, 5, 0, 'admin', '', '2024-02-05 14:57:04'),
('104', 'Piutang Dagang', '10', 0, 2, 1, 'admin', '', '2024-02-05 16:29:27'),
('104.001', 'Piutang dagang umum', '104', 0, 2, 0, 'admin', '', '2024-02-05 14:57:04'),
('104.002', 'Piutang dagang area 1', '104', 0, 2, 0, 'admin', '', '2024-02-05 14:57:04'),
('104.003', 'Piutang dagang area 2', '104', 0, 2, 0, 'admin', '', '2024-02-05 14:57:04'),
('104.004', 'Piutang dagang area 3', '104', 0, 2, 0, 'admin', '', '2024-02-05 14:57:04'),
('105', 'Piutang Lain-lain', '10', 0, 3, 1, 'admin', '', '2024-02-05 16:29:27'),
('105.001', 'Pinjaman karyawan', '105', 0, 3, 0, 'admin', '', '2024-02-05 14:57:04'),
('105.002', 'Pinjaman salesman', '105', 0, 3, 0, 'admin', '', '2024-02-05 14:57:04'),
('105.003', 'Pinjaman teknisi', '105', 0, 3, 0, 'admin', '', '2024-02-05 14:57:04'),
('105.999', 'Piutang lain-lain', '105', 0, 3, 0, 'admin', '', '2024-02-05 14:57:04'),
('106', 'Uang Muka', '10', 0, 3, 1, 'admin', '', '2024-02-05 16:29:27'),
('106.001', 'Uang muka pembelian', '106', 0, 3, 0, 'admin', '', '2024-02-05 14:57:04'),
('106.999', 'Uang muka lain-lain', '106', 0, 3, 0, 'admin', '', '2024-02-05 14:57:04'),
('107', 'Persediaan', '10', 0, 4, 1, 'admin', '', '2024-02-05 16:29:27'),
('107.001', 'Persediaan kelompok 1.1.1', '107', 0, 4, 0, 'admin', '', '2024-02-05 14:57:04'),
('107.002', 'Persediaan kelompok 2.1', '107', 0, 4, 0, 'admin', '', '2024-02-05 14:57:04'),
('107.003', 'Persediaan kelompok 2.2', '107', 0, 4, 0, 'admin', '', '2024-02-05 14:57:04'),
('107.999', 'Ayat silang transfer persediaan antar divisi', '107', 0, 4, 0, 'admin', '', '2024-02-05 14:57:04'),
('108', 'Pajak Dibayar Dimuka', '10', 0, 6, 1, 'admin', '', '2024-02-05 16:29:27'),
('108.001', 'Pajak penghasilan pasal 25', '108', 0, 6, 0, 'admin', '', '2024-02-05 14:57:04'),
('108.002', 'PPN Masukan', '108', 0, 6, 0, 'admin', '', '2024-07-17 14:25:30'),
('109', 'Beban Dibayar Dimuka', '10', 0, 6, 1, 'admin', '', '2024-02-05 16:29:27'),
('109.001', 'Beban sewa dibayar dimuka', '109', 0, 6, 0, 'admin', '', '2024-02-05 14:57:04'),
('109.002', 'Beban asuransi dibayar dimuka', '109', 0, 6, 0, 'admin', '', '2024-02-05 14:57:04'),
('11', 'Aset Tidak Lancar', '1', 0, 8, 1, 'admin', '', '2024-05-05 00:06:16'),
('111', 'Tanah', '11', 0, 8, 1, 'admin', '', '2024-02-05 16:29:27'),
('111.001', 'Hp. tanah', '111', 0, 8, 0, 'admin', '', '2024-05-05 00:06:19'),
('112', 'Gedung', '11', 0, 8, 1, 'admin', '', '2024-02-05 16:29:27'),
('112.001', 'Hp. gedung', '112', 0, 8, 0, 'admin', '', '2024-02-05 14:57:04'),
('112.002', 'Ak. penyusutan gedung', '112', 0, 9, 0, 'admin', '', '2024-02-05 14:57:04'),
('113', 'Peralatan Kantor', '11', 0, 8, 1, 'admin', '', '2024-02-05 16:29:27'),
('113.001', 'Hp. peralatan kantor', '113', 0, 8, 0, 'admin', '', '2024-02-05 14:57:04'),
('113.002', 'Ak. penyusutan peralatan kantor', '113', 0, 9, 0, 'admin', '', '2024-02-05 14:57:04'),
('114', 'Kendaraan', '11', 0, 8, 1, 'admin', '', '2024-02-05 16:29:27'),
('114.001', 'Hp. kendaraan', '114', 0, 8, 0, 'admin', '', '2024-02-05 14:57:04'),
('114.002', 'Ak. penyusutan kendaraan', '114', 0, 9, 0, 'admin', '', '2024-02-05 14:57:04'),
('115', 'Beban Ditangguhkan', '11', 0, 8, 1, 'admin', '', '2024-02-05 16:29:27'),
('115.001', 'Beban pra operasional', '115', 0, 8, 0, 'admin', '', '2024-02-05 14:57:04'),
('115.002', 'Beban bunga ditangguhkan', '115', 0, 8, 0, 'admin', '', '2024-02-05 14:57:04'),
('116', 'Goodwill', '11', 0, 8, 1, 'admin', '', '2024-02-05 16:29:27'),
('116.001', 'Izin HAKI produk perusahaan', '116', 0, 8, 0, 'admin', '', '2024-05-04 18:20:14'),
('2', 'LIABILITAS', '', 1, 10, 1, 'admin', '', '2026-04-09 04:51:05'),
('20', 'Hutang Lancar', '2', 1, 10, 1, 'admin', '', '2024-02-05 16:29:27'),
('20.001', 'Hutang dagang luar negeri', '20', 1, 10, 0, 'admin', '', '2024-02-05 14:57:04'),
('20.002', 'Hutang dagang dalam negeri', '20', 1, 10, 0, 'admin', '', '2024-02-05 14:57:04'),
('20.003', 'Pendapatan diterima dimuka', '20', 1, 11, 0, 'admin', '', '2024-02-05 14:57:04'),
('20.004', 'Hutang Deviden', '20', 1, 11, 0, 'admin', '', '2024-02-05 14:57:04'),
('20.005', 'Uang Muka Penjualan', '20', 1, 11, 0, 'admin', '', '2024-02-05 14:57:04'),
('20.006', 'Titipan beban pembayaran pihak ketiga', '20', 1, 11, 0, 'admin', '', '2024-02-05 14:57:04'),
('20.007', 'Hutang Belum Ditagih', '20', 1, 11, 0, 'admin', 'admin', '2026-03-14 16:39:01'),
('21', 'Beban Yang Masih Harus Dibayar', '2', 1, 12, 1, 'admin', '', '2024-02-05 16:29:27'),
('21.001', 'Beban gaji yang masih harus dibayar', '21', 1, 12, 0, 'admin', '', '2024-02-05 14:57:04'),
('21.999', 'Beban lain-lain yang masih harus dibayar', '21', 1, 12, 0, 'admin', '', '2024-02-05 14:57:04'),
('22', 'Hutang Pajak', '2', 1, 13, 1, 'admin', '', '2024-02-05 16:29:27'),
('22.001', 'Hutang pajak penghasilan', '22', 1, 13, 0, 'admin', '', '2024-02-05 14:57:04'),
('22.002', 'PPN Keluaran', '22', 1, 13, 0, 'admin', '', '2024-07-17 14:25:30'),
('23', 'Hutang Bank', '2', 1, 27, 1, 'admin', '', '2024-02-05 16:29:27'),
('23.001', 'Hutang bank A - pokok', '23', 1, 27, 0, 'admin', '', '2024-02-05 14:57:04'),
('23.002', 'Hutang bank A - bunga', '23', 1, 27, 0, 'admin', '', '2024-02-05 14:57:04'),
('23.003', 'Hutang bank B - pokok', '23', 1, 27, 0, 'admin', '', '2024-02-05 14:57:04'),
('23.004', 'Hutang bank B - bunga', '23', 1, 27, 0, 'admin', '', '2024-02-05 14:57:04'),
('24', 'Liabilitas Jangka Panjang', '2', 1, 28, 1, 'admin', '', '2026-04-09 04:51:16'),
('24.001', 'Hutang bank A - pokok', '24', 1, 27, 0, 'admin', '', '2024-02-05 14:57:04'),
('24.002', 'Hutang bank A - bunga', '24', 1, 27, 0, 'admin', '', '2024-02-05 14:57:04'),
('24.003', 'Hutang bank B - pokok', '24', 1, 27, 0, 'admin', '', '2024-02-05 14:57:04'),
('24.004', 'Hutang bank B - bunga', '24', 1, 27, 0, 'admin', '', '2024-02-05 14:57:04'),
('24.005', 'Hutang lembaga keuangan lainnya', '24', 1, 27, 0, 'admin', '', '2024-02-05 14:57:04'),
('3', 'EKUITAS', '', 2, 17, 1, 'admin', '', '2024-05-05 00:05:57'),
('300', 'Modal Saham', '3', 2, 17, 1, 'admin', '', '2024-02-05 16:29:27'),
('300.001', 'Modal Tn. A', '300', 2, 17, 0, 'admin', '', '2024-02-05 14:57:04'),
('300.002', 'Modal Tn. B', '300', 2, 17, 0, 'admin', '', '2024-02-05 14:57:04'),
('301', 'Laba ditahan', '3', 2, 17, 1, 'admin', '', '2024-02-05 16:29:27'),
('301.001', 'Laba ditahan periode lalu', '301', 2, 17, 0, 'admin', '', '2024-02-05 14:57:04'),
('301.002', 'Laba periode berjalan', '301', 2, 17, 0, 'admin', '', '2024-02-05 14:57:04'),
('302', 'Revaluasi aset tetap', '3', 2, 17, 1, 'admin', '', '2024-02-05 16:29:27'),
('302.001', 'Revaluasi tanah', '302', 2, 17, 0, 'admin', '', '2024-05-04 18:19:58'),
('302.002', 'Revaluasi bangunan gedung', '302', 2, 17, 0, 'admin', '', '2024-05-04 18:19:59'),
('303', 'Deviden', '3', 2, 17, 1, 'admin', '', '2024-02-05 16:29:27'),
('303.001', 'Deviden Tn. A', '303', 2, 17, 0, 'admin', '', '2024-02-05 14:57:04'),
('303.002', 'Deviden Tn. B', '303', 2, 17, 0, 'admin', '', '2024-02-05 14:57:04'),
('4', 'Pendapatan Kotor', '', 3, 18, 1, 'admin', '', '2024-05-04 23:32:25'),
('40', 'Penjualan Bersih', '4', 3, 18, 1, 'admin', '', '2024-05-04 23:32:35'),
('401', 'Penjualan Kelompok A', '40', 3, 18, 1, 'admin', '', '2024-02-05 16:29:27'),
('401.001', 'Pendapatan penjualan', '401', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('401.002', 'Retur penjualan', '401', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('401.003', 'Potongan penjualan', '401', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('401.004', 'Debet/kredit memo penjualan', '401', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('401.005', 'Potongan retur penjualan', '401', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('401.006', 'Pendapatan konsinyasi', '401', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('402', 'Penjualan Kelompok B', '40', 3, 18, 1, 'admin', '', '2024-02-05 16:29:27'),
('402.001', 'Pendapatan penjualan', '402', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('402.002', 'Retur penjualan', '402', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('402.003', 'Potongan penjualan', '402', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('402.004', 'Debet/kredit memo penjualan', '402', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('402.005', 'Potongan retur penjualan', '402', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('402.006', 'Pendapatan konsinyasi', '402', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('403', 'Penjualan Kelompok C', '40', 3, 18, 1, 'admin', '', '2024-02-05 16:29:27'),
('403.001', 'Pendapatan penjualan', '403', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('403.002', 'Retur penjualan', '403', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('403.003', 'Diskon penjualan', '403', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('403.004', 'Debet/kredit memo penjualan', '403', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('403.005', 'Potongan retur penjualan', '403', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('403.006', 'Pendapatan konsinyasi', '403', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('408', 'Potongan Tunai Penjualan', '40', 3, 22, 1, 'admin', '', '2024-05-04 23:34:56'),
('408.001', 'Potongan tunai', '408', 3, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('408.002', 'Potongan tunai pembayaran bank A', '408', 3, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('408.003', 'Potongan tunai pembayaran bank B', '408', 3, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('408.004', 'Potongan tunai pembayaran bank C', '408', 3, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('409', 'Diskon Penjualan Pelanggan', '40', 3, 22, 1, 'admin', '', '2024-05-04 23:35:04'),
('409.001', 'Diskon penjualan umum', '409', 3, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('409.002', 'Diskon penjualan area 1', '409', 3, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('409.003', 'Diskon penjualan area 2', '409', 3, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('409.004', 'Diskon penjualan area 3', '409', 3, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('410', 'Pendapatan Jasa', '40', 3, 18, 1, 'admin', '', '2024-02-05 16:29:27'),
('410.001', 'Pendapatan Servis', '410', 3, 18, 0, 'admin', '', '2024-02-05 14:57:04'),
('5', 'Harga Pokok Penjualan', '', 3, 20, 1, 'admin', '', '2024-05-04 23:32:38'),
('501', 'HPP Kelompok Produk', '5', 3, 20, 1, 'admin', '', '2024-02-05 16:29:27'),
('501.001', 'HPP kelompok 1.1.1', '501', 3, 20, 0, 'admin', '', '2024-02-05 14:57:04'),
('501.002', 'HPP kelompok 2.1', '501', 3, 20, 0, 'admin', '', '2024-02-05 14:57:04'),
('501.003', 'HPP kelompok 2.2', '501', 3, 20, 0, 'admin', '', '2024-02-05 14:57:04'),
('502', 'Diskon Pembelian Pemasok', '5', 3, 20, 1, 'admin', '', '2024-02-05 16:29:27'),
('502.001', 'Diskon pembelian pemasok umum', '502', 3, 20, 0, 'admin', '', '2024-02-05 14:57:04'),
('502.002', 'Diskon pembelian pemasok luar negeri', '502', 3, 20, 0, 'admin', '', '2024-02-05 14:57:04'),
('502.003', 'Diskon pembelian pemasok dalam negeri', '502', 3, 20, 0, 'admin', '', '2024-02-05 14:57:04'),
('503', 'Biaya-biaya Pembelian', '5', 3, 20, 1, 'admin', '', '2024-02-05 16:29:27'),
('503.001', 'Biaya angkut', '503', 3, 20, 0, 'admin', '', '2024-02-05 14:57:04'),
('503.002', 'Biaya ekspedisi', '503', 3, 20, 0, 'admin', '', '2024-02-05 14:57:04'),
('504', 'Hadiah dan Bonus Pembelian', '5', 3, 20, 1, 'admin', '', '2024-02-05 16:29:27'),
('504.001', 'Hadiah dan Bonus Pembelian', '504', 3, 20, 0, 'admin', '', '2024-02-05 14:57:04'),
('6', 'Beban Operasi', '', 4, 22, 1, 'admin', '', '2024-05-04 23:32:45'),
('601', 'Beban Penjualan', '6', 4, 22, 1, 'admin', '', '2024-02-05 16:29:27'),
('601.001', 'Beban penjualan konsinyasi', '601', 4, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('601.002', 'Beban penjualan berhadiah', '601', 4, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('601.003', 'Beban kemasan', '601', 4, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('601.004', 'Beban pengiriman penjualan', '601', 4, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('601.005', 'Beban piutang tak tertagih', '601', 4, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('601.006', 'Beban penjualan lain-lain', '601', 4, 22, 0, 'admin', '', '2024-02-05 14:57:04'),
('602', 'Beban Pemasaran', '6', 4, 23, 1, 'admin', '', '2024-02-05 16:29:27'),
('602.001', 'Beban iklan dan promosi', '602', 4, 23, 0, 'admin', '', '2024-02-05 14:57:04'),
('602.002', 'Beban promosi', '602', 4, 23, 0, 'admin', '', '2024-02-05 14:57:04'),
('602.003', 'Biaya riset dan pengembangan', '602', 4, 23, 0, 'admin', '', '2024-02-05 14:57:04'),
('602.004', 'Biaya operasional salesman', '602', 4, 23, 0, 'admin', '', '2024-02-05 14:57:04'),
('602.005', 'Beban pemasaran lain-lain', '602', 4, 23, 0, 'admin', '', '2024-02-05 14:57:04'),
('603', 'Beban Administrasi dan Umum', '6', 4, 21, 1, 'admin', '', '2024-02-05 16:29:27'),
('603.001', 'Beban alat tulis kantor', '603', 4, 21, 0, 'admin', '', '2024-02-05 14:57:04'),
('603.002', 'Beban transportasi', '603', 4, 21, 0, 'admin', '', '2024-02-05 14:57:04'),
('603.003', 'Beban telepon', '603', 4, 21, 0, 'admin', '', '2024-02-05 14:57:04'),
('603.004', 'Beban listrik', '603', 4, 21, 0, 'admin', '', '2024-02-05 14:57:04'),
('603.005', 'Beban perizinan', '603', 4, 21, 0, 'admin', '', '2024-02-05 14:57:04'),
('603.006', 'Beban akomodasi dinas kantor', '603', 4, 21, 0, 'admin', '', '2024-02-05 14:57:04'),
('603.007', 'Beban pos dan materai', '603', 4, 21, 0, 'admin', '', '2024-02-05 14:57:04'),
('603.008', 'Beban dapur kantor', '603', 4, 21, 0, 'admin', '', '2024-02-05 14:57:04'),
('603.009', 'Beban keamanan dan kebersihan', '603', 4, 21, 0, 'admin', '', '2024-02-05 14:57:04'),
('603.999', 'Beban administrasi umum lain-lain', '603', 4, 21, 0, 'admin', '', '2024-02-05 14:57:04'),
('604', 'Biaya Tenaga Kerja', '6', 4, 24, 1, 'admin', '', '2024-02-05 16:29:27'),
('604.001', 'Gaji karyawan tetap', '604', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('604.002', 'Lembur karyawan tetap', '604', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('604.003', 'Bonus karyawan tetap', '604', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('604.004', 'Gaji karyawan tidak tetap', '604', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('604.005', 'Lembur karyawan tidak tetap', '604', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('604.006', 'Bonus karyawan tidak tetap', '604', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('604.007', 'Kesehatan karyawan', '604', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('604.008', 'Beban asuransi karyawan', '604', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('604.009', 'Beban konsumsi karyawan', '604', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('604.010', 'Beban pelatihan karyawan', '604', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('604.999', 'Beban tenaga kerja lain-lain', '604', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('605', 'Beban Penyusutan', '6', 4, 24, 1, 'admin', '', '2024-02-05 16:29:27'),
('605.001', 'Beban penyusutan gedung', '605', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('605.002', 'Beban penyusutan kendaraan', '605', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('605.003', 'Beban penyusutan peralatan kantor', '605', 4, 24, 0, 'admin', '', '2024-02-05 14:57:04'),
('7', 'Pendapatan di Luar Usaha', '', 3, 19, 1, 'admin', '', '2024-05-04 23:32:53'),
('701', 'Pendapatan (Beban) Lain-lain', '7', 3, 19, 1, 'admin', '', '2024-02-05 16:29:27'),
('701.001', 'Pendapatan jasa giro dan bunga tabungan', '701', 3, 19, 0, 'admin', '', '2024-02-05 14:57:04'),
('701.002', 'Laba/rugi selisih kurs', '701', 3, 19, 0, 'admin', '', '2024-02-05 14:57:04'),
('701.003', 'Diskon Pembayaran', '701', 3, 19, 0, 'admin', '', '2024-02-05 14:57:04'),
('701.004', 'Laba/rugi penghapusan hutang', '701', 3, 19, 0, 'admin', '', '2024-02-05 14:57:04'),
('701.005', 'Laba/rugi penghapusan piutang', '701', 3, 19, 0, 'admin', '', '2024-02-05 14:57:04'),
('701.006', 'Laba/rugi selisih kas', '701', 3, 19, 0, 'admin', 'admin', '2024-06-25 08:07:19'),
('701.099', 'Pendapatan lain-lain', '701', 3, 19, 0, 'admin', '', '2024-02-05 14:57:04'),
('701.101', 'Beban administrasi bank dan pajak jasa giro', '701', 3, 19, 0, 'admin', '', '2024-02-05 14:57:04'),
('701.199', 'Beban lain-lain', '701', 3, 19, 0, 'admin', '', '2024-02-05 14:57:04'),
('8', 'Beban di Luar Usaha', '', 4, 26, 1, 'admin', '', '2024-05-04 23:33:00'),
('801', 'Beban Bunga Bank', '8', 4, 26, 1, 'admin', '', '2024-02-05 16:29:27'),
('801.001', 'Beban bunga bank A', '801', 4, 26, 0, 'admin', '', '2024-02-05 14:57:04'),
('801.002', 'Beban bunga bank B', '801', 4, 26, 0, 'admin', '', '2024-02-05 14:57:04'),
('9', 'Pajak Penghasilan', '', 4, 30, 1, 'admin', '', '2024-05-04 23:33:04'),
('901', 'Beban Pajak Penghasilan', '9', 4, 30, 1, 'admin', '', '2024-02-05 16:29:27'),
('901.001', 'Beban Pajak Penghasilan', '901', 4, 30, 0, 'admin', '', '2024-02-05 14:57:04');

CREATE TABLE `address` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `addresslabel` varchar(50) NOT NULL DEFAULT 'Rumah',
  `country` int(11) NOT NULL DEFAULT 0,
  `countryname` varchar(50) NOT NULL DEFAULT '',
  `province` int(11) NOT NULL DEFAULT 0,
  `provincename` varchar(50) NOT NULL DEFAULT '',
  `city` int(11) NOT NULL DEFAULT 0,
  `cityname` varchar(50) NOT NULL DEFAULT '',
  `subdistrict` int(11) NOT NULL DEFAULT 0,
  `subdistrictname` varchar(50) NOT NULL DEFAULT '',
  `address` text DEFAULT NULL,
  `postal_code` varchar(50) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `attendance` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `employeeid` char(30) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `checkin` datetime DEFAULT NULL,
  `checkout` datetime DEFAULT NULL,
  `notes` varchar(255) DEFAULT '',
  `workinghourid` bigint(20) NOT NULL,
  `late` int(11) DEFAULT NULL,
  `overtime` float DEFAULT NULL,
  `workinghour` float DEFAULT NULL,
  `imagecheckin` varchar(255) DEFAULT '[]',
  `imagecheckout` varchar(255) DEFAULT '[]',
  `latitudecheckin` float DEFAULT NULL,
  `longitudecheckin` float DEFAULT NULL,
  `latitudecheckout` float DEFAULT NULL,
  `longitudecheckout` float DEFAULT NULL,
  `kioskdeviceid` bigint(20) UNSIGNED DEFAULT NULL,
  `verifymethod` varchar(30) NOT NULL DEFAULT '',
  `verifyscore` decimal(10,6) DEFAULT NULL,
  `verifylivenessscore` decimal(10,6) DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `cancelled` tinyint(1) NOT NULL DEFAULT 0,
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `attendancekioskdevice` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `employeegroup` varchar(512) NOT NULL DEFAULT '[]',
  `locationname` varchar(150) NOT NULL DEFAULT '',
  `latitude` decimal(10,7) NOT NULL DEFAULT 0.0000000,
  `longitude` decimal(10,7) NOT NULL DEFAULT 0.0000000,
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `engineprovider` varchar(30) NOT NULL DEFAULT 'face_api',
  `adminpin` varchar(10) NOT NULL DEFAULT '0000',
  `scanidwithcamera` smallint(6) NOT NULL DEFAULT 0,
  `allowplaceholderverify` smallint(6) NOT NULL DEFAULT 0,
  `engineconfig` text NOT NULL DEFAULT '',
  `additionalinfo` mediumtext NOT NULL DEFAULT '',
  `notes` varchar(255) DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `attendancekioskdevice` (`id`, `name`, `employeegroup`, `locationname`, `latitude`, `longitude`, `isactive`, `engineprovider`, `adminpin`, `scanidwithcamera`, `allowplaceholderverify`, `engineconfig`, `additionalinfo`, `notes`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Default Attendance Kiosk', '[]', '', 0.0000000, 0.0000000, 1, 'face_api', '0000', 1, 0, '', '<div style=\"font-family: Arial, sans-serif; color: #1f2937; line-height: 1.5;\"><h3 style=\"margin: 0 0 8px; font-size: 18px;\">Welcome to the Attendance Kiosk</h3><p style=\"margin: 0 0 10px;\">Please follow these steps before submitting your attendance:</p><ol style=\"margin: 0 0 10px 18px; padding: 0;\"><li>Scan or enter your employee ID.</li><li>Look at the camera and follow the verification instruction.</li><li>Wait for the confirmation message before leaving.</li></ol><p style=\"margin: 0; font-size: 13px; color: #4b5563;\">If you need help, please contact your supervisor or HR team.</p></div>', '', 'system', 'system', '2026-05-16 16:49:38');

CREATE TABLE `attendanceverifylog` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `employeeid` char(30) NOT NULL DEFAULT '',
  `attendanceid` bigint(20) UNSIGNED DEFAULT NULL,
  `kioskdeviceid` bigint(20) UNSIGNED DEFAULT NULL,
  `mode` varchar(20) NOT NULL DEFAULT '',
  `matchscore` decimal(10,6) DEFAULT NULL,
  `livenessscore` decimal(10,6) DEFAULT NULL,
  `challenge` varchar(100) NOT NULL DEFAULT '',
  `result` varchar(30) NOT NULL DEFAULT '',
  `snapshot` varchar(255) DEFAULT '',
  `notes` varchar(255) DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `createdat` datetime NOT NULL DEFAULT current_timestamp(),
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `authorityrequest` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `userid` char(16) NOT NULL DEFAULT '',
  `touserid` char(16) NOT NULL DEFAULT '',
  `kind` char(6) NOT NULL DEFAULT '',
  `reference` char(30) NOT NULL DEFAULT '',
  `memo` varchar(50) NOT NULL DEFAULT '',
  `approved` tinyint(1) NOT NULL,
  `daterequest` datetime NOT NULL,
  `dateapproved` datetime DEFAULT NULL,
  `done` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `authors` (
  `id` char(30) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `address` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `authors` (`id`, `name`, `address`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('p1', 'Tidak disebutkan', '', 'admin', '', '2024-02-05 14:57:04'),
('p2', 'Pengarang A', '', 'admin', '', '2024-02-05 14:57:04'),
('p3', 'Pengarang B', '', 'admin', '', '2024-02-05 14:57:04');

CREATE TABLE `cogs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `division` char(10) DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `qty` double NOT NULL DEFAULT 0,
  `cost` double NOT NULL DEFAULT 0,
  `cogs` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `countries` (
  `id` char(3) NOT NULL DEFAULT '',
  `country` varchar(100) NOT NULL DEFAULT '',
  `isactive` smallint(6) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `countries` (`id`, `country`, `isactive`) VALUES
('ABW', 'Aruba', 0),
('AGO', 'Angola', 0),
('AIA', 'Anguilla', 0),
('ALB', 'Albania', 0),
('AND', 'Andorra', 0),
('ANT', 'Netherlands Antilles', 0),
('ARE', 'United Arab Emirates', 0),
('ARG', 'Argentina', 0),
('ARM', 'Armenia', 0),
('ASM', 'American Samoa', 0),
('ATA', 'Antarctica', 0),
('ATF', 'French Southern Lands', 0),
('ATG', 'Antigua and Barbuda', 0),
('AUS', 'Australia', 0),
('AUT', 'Austria', 0),
('AZE', 'Azerbaijan', 0),
('BDI', 'Burundi', 0),
('BEL', 'Belgium', 0),
('BEN', 'Benin', 0),
('BFA', 'Burkina Faso', 0),
('BGD', 'Bangladesh', 0),
('BGR', 'Bulgaria', 0),
('BHR', 'Bahrain', 0),
('BHS', 'Bahamas', 0),
('BIH', 'Bosnia and Herzegovina', 0),
('BLM', 'Saint Barthélemy', 0),
('BLR', 'Belarus', 0),
('BLZ', 'Belize', 0),
('BMU', 'Bermuda', 0),
('BOL', 'Bolivia', 0),
('BRA', 'Brazil', 0),
('BRB', 'Barbados', 0),
('BRN', 'Brunei Darussalam', 0),
('BTN', 'Bhutan', 0),
('BVT', 'Bouvet Island', 0),
('BWA', 'Botswana', 0),
('CAF', 'Central African Republic', 0),
('CAN', 'Canada', 0),
('CCK', 'Cocos (Keeling) Islands', 0),
('CHE', 'Switzerland', 0),
('CHL', 'Chile', 0),
('CHN', 'China', 0),
('CIV', 'Côte d\'Ivoire', 0),
('CMR', 'Cameroon', 0),
('COD', 'Congo (Kinshasa)', 0),
('COG', 'Congo (Brazzaville)', 0),
('COK', 'Cook Islands', 0),
('COL', 'Colombia', 0),
('COM', 'Comoros', 0),
('CPV', 'Cape Verde', 0),
('CRI', 'Costa Rica', 0),
('CUB', 'Cuba', 0),
('CXR', 'Christmas Island', 0),
('CYM', 'Cayman Islands', 0),
('CYP', 'Cyprus', 0),
('CZE', 'Czech Republic', 0),
('DEU', 'Germany', 0),
('DJI', 'Djibouti', 0),
('DMA', 'Dominica', 0),
('DNK', 'Denmark', 0),
('DOM', 'Dominican Republic', 0),
('DZA', 'Algeria', 0),
('ECU', 'Ecuador', 0),
('EGY', 'Egypt', 0),
('ERI', 'Eritrea', 0),
('ESH', 'Western Sahara', 0),
('ESP', 'Spain', 0),
('EST', 'Estonia', 0),
('ETH', 'Ethiopia', 0),
('FIN', 'Finland', 0),
('FJI', 'Fiji', 0),
('FLK', 'Falkland Islands', 0),
('FRA', 'France', 0),
('FRO', 'Faroe Islands', 0),
('FSM', 'Micronesia', 0),
('GAB', 'Gabon', 0),
('GBR', 'United Kingdom', 0),
('GEO', 'Georgia', 0),
('GGY', 'Guernsey', 0),
('GHA', 'Ghana', 0),
('GIB', 'Gibraltar', 0),
('GIN', 'Guinea', 0),
('GLP', 'Guadeloupe', 0),
('GMB', 'Gambia', 0),
('GNB', 'Guinea-Bissau', 0),
('GNQ', 'Equatorial Guinea', 0),
('GRC', 'Greece', 0),
('GRD', 'Grenada', 0),
('GRL', 'Greenland', 0),
('GTM', 'Guatemala', 0),
('GUF', 'French Guiana', 0),
('GUM', 'Guam', 0),
('GUY', 'Guyana', 0),
('HKG', 'Hong Kong', 0),
('HMD', 'Heard and McDonald Islands', 0),
('HND', 'Honduras', 0),
('HRV', 'Croatia', 0),
('HTI', 'Haiti', 0),
('HUN', 'Hungary', 0),
('IDN', 'Indonesia', 1),
('IMN', 'Isle of Man', 0),
('IND', 'India', 0),
('IOT', 'British Indian Ocean Territory', 0),
('IRL', 'Ireland', 0),
('IRN', 'Iran', 0),
('IRQ', 'Iraq', 0),
('ISL', 'Iceland', 0),
('ISR', 'Israel', 0),
('ITA', 'Italy', 0),
('JAM', 'Jamaica', 0),
('JEY', 'Jersey', 0),
('JOR', 'Jordan', 0),
('JPN', 'Japan', 0),
('KAZ', 'Kazakhstan', 0),
('KEN', 'Kenya', 0),
('KGZ', 'Kyrgyzstan', 0),
('KHM', 'Cambodia', 0),
('KIR', 'Kiribati', 0),
('KNA', 'Saint Kitts and Nevis', 0),
('KOR', 'Korea, South', 0),
('KWT', 'Kuwait', 0),
('LAO', 'Laos', 0),
('LBN', 'Lebanon', 0),
('LBR', 'Liberia', 0),
('LBY', 'Libya', 0),
('LCA', 'Saint Lucia', 0),
('LIE', 'Liechtenstein', 0),
('LKA', 'Sri Lanka', 0),
('LSO', 'Lesotho', 0),
('LTU', 'Lithuania', 0),
('LUX', 'Luxembourg', 0),
('LVA', 'Latvia', 0),
('MAC', 'Macau', 0),
('MAF', 'Saint Martin (French part)', 0),
('MAR', 'Morocco', 0),
('MCO', 'Monaco', 0),
('MDA', 'Moldova', 0),
('MDG', 'Madagascar', 0),
('MDV', 'Maldives', 0),
('MEX', 'Mexico', 0),
('MHL', 'Marshall Islands', 0),
('MKD', 'Macedonia', 0),
('MLI', 'Mali', 0),
('MLT', 'Malta', 0),
('MMR', 'Myanmar', 0),
('MNE', 'Montenegro', 0),
('MNG', 'Mongolia', 0),
('MNP', 'Northern Mariana Islands', 0),
('MOZ', 'Mozambique', 0),
('MRT', 'Mauritania', 0),
('MSR', 'Montserrat', 0),
('MTQ', 'Martinique', 0),
('MUS', 'Mauritius', 0),
('MWI', 'Malawi', 0),
('MYS', 'Malaysia', 0),
('MYT', 'Mayotte', 0),
('NAM', 'Namibia', 0),
('NCL', 'New Caledonia', 0),
('NER', 'Niger', 0),
('NFK', 'Norfolk Island', 0),
('NGA', 'Nigeria', 0),
('NIC', 'Nicaragua', 0),
('NIU', 'Niue', 0),
('NLD', 'Netherlands', 0),
('NOR', 'Norway', 0),
('NPL', 'Nepal', 0),
('NRU', 'Nauru', 0),
('NZL', 'New Zealand', 0),
('OMN', 'Oman', 0),
('PAK', 'Pakistan', 0),
('PAN', 'Panama', 0),
('PCN', 'Pitcairn', 0),
('PER', 'Peru', 0),
('PHL', 'Philippines', 0),
('PLW', 'Palau', 0),
('PNG', 'Papua New Guinea', 0),
('POL', 'Poland', 0),
('PRI', 'Puerto Rico', 0),
('PRK', 'Korea, North', 0),
('PRT', 'Portugal', 0),
('PRY', 'Paraguay', 0),
('PSE', 'Palestine', 0),
('PYF', 'French Polynesia', 0),
('QAT', 'Qatar', 0),
('REU', 'Reunion', 0),
('ROU', 'Romania', 0),
('RUS', 'Russian Federation', 0),
('RWA', 'Rwanda', 0),
('SAU', 'Saudi Arabia', 0),
('SDN', 'Sudan', 0),
('SEN', 'Senegal', 0),
('SGP', 'Singapore', 0),
('SGS', 'South Georgia and South Sandwich Islands', 0),
('SHN', 'Saint Helena', 0),
('SJM', 'Svalbard and Jan Mayen Islands', 0),
('SLB', 'Solomon Islands', 0),
('SLE', 'Sierra Leone', 0),
('SLV', 'El Salvador', 0),
('SMR', 'San Marino', 0),
('SOM', 'Somalia', 0),
('SPM', 'Saint Pierre and Miquelon', 0),
('SRB', 'Serbia', 0),
('STP', 'Sao Tome and Principe', 0),
('SUR', 'Suriname', 0),
('SVK', 'Slovakia', 0),
('SVN', 'Slovenia', 0),
('SWE', 'Sweden', 0),
('SWZ', 'Swaziland', 0),
('SYC', 'Seychelles', 0),
('SYR', 'Syria', 0),
('TCA', 'Turks and Caicos Islands', 0),
('TCD', 'Chad', 0),
('TGO', 'Togo', 0),
('THA', 'Thailand', 0),
('TJK', 'Tajikistan', 0),
('TKL', 'Tokelau', 0),
('TKM', 'Turkmenistan', 0),
('TLS', 'Timor-Leste', 0),
('TON', 'Tonga', 0),
('TTO', 'Trinidad and Tobago', 0),
('TUN', 'Tunisia', 0),
('TUR', 'Turkey', 0),
('TUV', 'Tuvalu', 0),
('TWN', 'Taiwan', 0),
('TZA', 'Tanzania', 0),
('UGA', 'Uganda', 0),
('UKR', 'Ukraine', 0),
('UMI', 'United States Minor Outlying Islands', 0),
('URY', 'Uruguay', 0),
('USA', 'United States of America', 0),
('UZB', 'Uzbekistan', 0),
('VAT', 'Vatican City', 0),
('VCT', 'Saint Vincent and the Grenadines', 0),
('VEN', 'Venezuela', 0),
('VGB', 'Virgin Islands, British', 0),
('VIR', 'Virgin Islands, U.S.', 0),
('VNM', 'Vietnam', 0),
('VUT', 'Vanuatu', 0),
('WLF', 'Wallis and Futuna Islands', 0),
('WSM', 'Samoa', 0),
('YEM', 'Yemen', 0),
('ZAF', 'South Africa', 0),
('ZMB', 'Zambia', 0),
('ZWE', 'Zimbabwe', 0);

CREATE TABLE `currencies` (
  `id` char(3) NOT NULL DEFAULT '',
  `name` varchar(45) NOT NULL DEFAULT '',
  `symbol` varchar(5) NOT NULL DEFAULT '',
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `rate` double NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `currencies` (`id`, `name`, `symbol`, `isactive`, `rate`) VALUES
('AFN', 'Afghanis', '؋', 0, 1),
('ALL', 'Leke', 'Lek', 0, 1),
('ANG', 'Guilders', 'ƒ', 0, 1),
('ARS', 'Pesos', '$', 0, 1),
('AUD', 'Dollars', '$', 0, 1),
('AWG', 'Guilders', 'ƒ', 0, 1),
('AZN', 'New Manats', 'ман', 0, 1),
('BAM', 'Convertible Marka', 'KM', 0, 1),
('BBD', 'Dollars', '$', 0, 1),
('BGN', 'Leva', 'лв', 0, 1),
('BMD', 'Dollars', '$', 0, 1),
('BND', 'Dollars', '$', 0, 1),
('BOB', 'Bolivianos', '$b', 0, 1),
('BRL', 'Reais', 'R$', 0, 1),
('BSD', 'Dollars', '$', 0, 1),
('BWP', 'Pula', 'P', 0, 1),
('BYR', 'Rubles', 'p.', 0, 1),
('BZD', 'Dollars', 'BZ$', 0, 1),
('CAD', 'Dollars', '$', 0, 1),
('CHF', 'Switzerland Francs', 'CHF', 0, 1),
('CLP', 'Pesos', '$', 0, 1),
('CNY', 'Yuan Renminbi', '¥', 0, 1),
('COP', 'Pesos', '$', 0, 1),
('CRC', 'ColÃƒÆ’Ã‚Â³n', '₡', 0, 1),
('CUP', 'Pesos', '₱', 0, 1),
('CZK', 'Koruny', 'Kč', 0, 1),
('DKK', 'Kroner', 'kr', 0, 1),
('DOP', 'Pesos', 'RD$', 0, 1),
('EGP', 'Pounds', '£', 0, 1),
('EUR', 'Euro', '€', 0, 1),
('FJD', 'Dollars', '$', 0, 1),
('FKP', 'Pounds', '£', 0, 1),
('GBP', 'Pounds', '£', 0, 1),
('GGP', 'Pounds', '£', 0, 1),
('GHC', 'Cedis', '¢', 0, 1),
('GIP', 'Pounds', '£', 0, 1),
('GTQ', 'Quetzales', 'Q', 0, 1),
('GYD', 'Dollars', '$', 0, 1),
('HKD', 'Dollars', '$', 0, 1),
('HNL', 'Lempiras', 'L', 0, 1),
('HRK', 'Kuna', 'kn', 0, 1),
('HUF', 'Forint', 'Ft', 0, 1),
('IDR', 'Rupiah', 'Rp', 1, 1),
('ILS', 'New Shekels', '₪', 0, 1),
('IMP', 'Pounds', '£', 0, 1),
('INR', 'Rupees', '₹', 0, 1),
('IRR', 'Rials', '﷼', 0, 1),
('ISK', 'Kronur', 'kr', 0, 1),
('JEP', 'Pounds', '£', 0, 1),
('JMD', 'Dollars', 'J$', 0, 1),
('JPY', 'Yen', '¥', 0, 1),
('KGS', 'Soms', 'лв', 0, 1),
('KHR', 'Riels', '៛', 0, 1),
('KPW', 'Won', '₩', 0, 1),
('KRW', 'Won', '₩', 0, 1),
('KYD', 'Dollars', '$', 0, 1),
('KZT', 'Tenge', 'лв', 0, 1),
('LAK', 'Kips', '₭', 0, 1),
('LBP', 'Pounds', '£', 0, 1),
('LKR', 'Rupees', '₨', 0, 1),
('LRD', 'Dollars', '$', 0, 1),
('LTL', 'Litai', 'Lt', 0, 1),
('LVL', 'Lati', 'Ls', 0, 1),
('MKD', 'Denars', 'ден', 0, 1),
('MNT', 'Tugriks', '₮', 0, 1),
('MUR', 'Rupees', '₨', 0, 1),
('MXN', 'Pesos', '$', 0, 1),
('MYR', 'Ringgits', 'RM', 0, 1),
('MZN', 'Meticais', 'MT', 0, 1),
('NAD', 'Dollars', '$', 0, 1),
('NGN', 'Nairas', '₦', 0, 1),
('NIO', 'Cordobas', 'C$', 0, 1),
('NOK', 'Krone', 'kr', 0, 1),
('NPR', 'Rupees', '₨', 0, 1),
('NZD', 'Dollars', '$', 0, 1),
('OMR', 'Rials', '﷼', 0, 1),
('PAB', 'Balboa', 'B/.', 0, 1),
('PEN', 'Nuevos Soles', 'S/.', 0, 1),
('PHP', 'Pesos', 'Php', 0, 1),
('PKR', 'Rupees', '₨', 0, 1),
('PLN', 'Zlotych', 'zł', 0, 1),
('PYG', 'Guarani', 'Gs', 0, 1),
('QAR', 'Rials', '﷼', 0, 1),
('RON', 'New Lei', 'lei', 0, 1),
('RSD', 'Dinars', 'Дин.', 0, 1),
('RUB', 'Rubles', 'руб', 0, 1),
('SAR', 'Riyals', '﷼', 0, 1),
('SBD', 'Dollars', '$', 0, 1),
('SCR', 'Rupees', '₨', 0, 1),
('SEK', 'Kronor', 'kr', 0, 1),
('SGD', 'Dollars', '$', 0, 1),
('SHP', 'Pounds', '£', 0, 1),
('SOS', 'Shillings', 'S', 0, 1),
('SRD', 'Dollars', '$', 0, 1),
('SVC', 'Colones', '$', 0, 1),
('SYP', 'Pounds', '£', 0, 1),
('THB', 'Baht', '฿', 0, 1),
('TRL', 'Liras', '£', 0, 1),
('TRY', 'Lira', '₺', 0, 1),
('TTD', 'Dollars', 'TT$', 0, 1),
('TVD', 'Dollars', '$', 0, 1),
('TWD', 'New Dollars', 'NT$', 0, 1),
('UAH', 'Hryvnia', '₴', 0, 1),
('USD', 'Dollars', '$', 0, 1),
('UYU', 'Pesos', '$U', 0, 1),
('UZS', 'Sums', 'лв', 0, 1),
('VEF', 'Bolivares Fuertes', 'Bs', 0, 1),
('VND', 'Dong', '₫', 0, 1),
('XCD', 'Dollars', '$', 0, 1),
('YER', 'Rials', '﷼', 0, 1),
('ZAR', 'Rand', 'R', 0, 1),
('ZWD', 'Zimbabwe Dollars', 'Z$', 0, 1);

CREATE TABLE `customerbalance` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `customerid` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `customerdisplay` (
  `id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL DEFAULT '',
  `intervalplay` int(11) NOT NULL DEFAULT 8,
  `duration` int(11) NOT NULL DEFAULT 1,
  `bgclass` varchar(50) NOT NULL DEFAULT '',
  `published` int(11) NOT NULL DEFAULT 1,
  `slideheight` int(11) NOT NULL DEFAULT 500,
  `showarrow` int(11) NOT NULL DEFAULT 1,
  `shownavigation` int(11) NOT NULL DEFAULT 1,
  `autoplay` int(11) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `customerdisplay` (`id`, `name`, `intervalplay`, `duration`, `bgclass`, `published`, `slideheight`, `showarrow`, `shownavigation`, `autoplay`) VALUES
(1, 'Customer Display 2', 8, 1, '', 1, 864, 0, 0, 1);

CREATE TABLE `customerdp` (
  `transid` char(30) NOT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `customerid` char(30) DEFAULT NULL,
  `customername` varchar(100) NOT NULL DEFAULT '',
  `customeraddress` varchar(200) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `paymenttype` int(10) UNSIGNED DEFAULT NULL,
  `downpaymenttype` int(10) UNSIGNED NOT NULL,
  `kind` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `customergiro` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `transid` char(30) NOT NULL DEFAULT '',
  `transidref` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `customerid` char(30) NOT NULL DEFAULT '',
  `customername` varchar(100) NOT NULL DEFAULT '',
  `customeraddress` varchar(200) NOT NULL DEFAULT '',
  `accepted` smallint(6) NOT NULL DEFAULT 0,
  `duedate` datetime DEFAULT NULL,
  `accepteddate` datetime DEFAULT NULL,
  `giroin` double NOT NULL DEFAULT 0,
  `giroout` double NOT NULL DEFAULT 0,
  `paymenttype` int(10) UNSIGNED NOT NULL,
  `paymentref` varchar(100) NOT NULL DEFAULT '',
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `division` char(10) NOT NULL DEFAULT '',
  `kind` smallint(6) NOT NULL DEFAULT 0,
  `jtid` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `customergroup` (
  `id` char(30) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `salesdiscrules` text DEFAULT NULL,
  `salesproductrewardrules` text DEFAULT NULL,
  `salespointrewardrules` text DEFAULT NULL,
  `paymentdiscrules` text DEFAULT NULL,
  `receivableacc` char(30) NOT NULL DEFAULT '',
  `rewardacc` char(30) NOT NULL DEFAULT '',
  `salesdiscacc` char(30) NOT NULL DEFAULT '',
  `gainlossreceivableacc` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `customergroup` (`id`, `description`, `salesdiscrules`, `salesproductrewardrules`, `salespointrewardrules`, `paymentdiscrules`, `receivableacc`, `rewardacc`, `salesdiscacc`, `gainlossreceivableacc`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('c11', 'GROSIR AREA 1', '[]', '[]', '[]', '[]', '104.002', '601.002', '409.002', '701.005', 'admin', '', '2025-12-03 20:58:07'),
('c12', 'GROSIR AREA 2', '[]', '[]', '[]', '[]', '104.003', '601.002', '409.003', '701.005', 'admin', '', '2025-12-03 20:58:07'),
('c13', 'GROSIR AREA 3', '[]', '[]', '[]', '[]', '104.004', '601.002', '409.004', '701.005', 'admin', '', '2025-12-03 20:58:07'),
('c21', 'TUNAI AREA 1', '[]', '[]', '[]', '[]', '104.001', '601.002', '409.002', '701.005', 'admin', '', '2025-12-03 20:58:07'),
('c22', 'TUNAI AREA 2', '[]', '[]', '[]', '[]', '104.001', '601.002', '409.003', '701.005', 'admin', '', '2025-12-03 20:58:07');

CREATE TABLE `customerguide` (
  `id` char(30) NOT NULL DEFAULT '',
  `name` varchar(50) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `customerid` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `image` blob DEFAULT NULL,
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `customernote` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `customerid` char(30) NOT NULL DEFAULT '',
  `customername` varchar(100) NOT NULL DEFAULT '',
  `customeraddress` varchar(200) NOT NULL DEFAULT '',
  `customercreditlimit` double NOT NULL DEFAULT 0,
  `customercreditlimittype` tinyint(4) NOT NULL DEFAULT 0,
  `customernoteid` char(5) NOT NULL DEFAULT '',
  `notes` text DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `customernotes` (
  `id` char(5) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `customernotes` (`id`, `name`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('001', 'Umum', 'admin', '', '2024-02-05 14:57:09');

CREATE TABLE `deliveryorder` (
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `salesorder` char(30) NOT NULL DEFAULT '',
  `salesdate` date DEFAULT NULL,
  `salestime` time DEFAULT NULL,
  `kind` int(11) NOT NULL DEFAULT 0,
  `customerid` char(30) NOT NULL DEFAULT '',
  `customername` varchar(100) NOT NULL DEFAULT '',
  `customeraddress` varchar(200) NOT NULL DEFAULT '',
  `salesmanid` char(30) NOT NULL DEFAULT '',
  `salesmanname` varchar(100) NOT NULL DEFAULT '',
  `shipto` text DEFAULT NULL,
  `memo` text DEFAULT NULL,
  `memoedit` text DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `shipment` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `packed` int(11) NOT NULL DEFAULT 0,
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `deliveryorderdetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `qty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `deliveryorderrewarddetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `qty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `departement` (
  `id` char(10) NOT NULL DEFAULT '',
  `name` varchar(50) NOT NULL DEFAULT '',
  `description` varchar(150) NOT NULL DEFAULT '',
  `isactive` smallint(5) UNSIGNED NOT NULL DEFAULT 1,
  `division` char(10) NOT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `departement` (`id`, `name`, `description`, `isactive`, `division`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('D1101', 'Departemen Pusat 1-1', '', 1, 'D11', 'admin', '', '2024-05-16 02:15:15'),
('D1102', 'Departemen Pusat 1-2', '', 1, 'D11', 'admin', '', '2024-05-16 02:15:17'),
('D1103', 'Departemen Produksi I', '', 1, 'D11', 'admin', '', '2024-07-12 21:16:23'),
('D1201', 'Departemen Cabang 1-1', '', 1, 'D12', 'admin', '', '2024-05-16 02:15:19'),
('D1204', 'Departemen Produksi II', '', 1, 'D11', 'admin', '', '2024-07-12 21:16:32'),
('DE23', 'Departemen Cabang 1', '', 1, 'D12', 'admin', '', '2026-04-11 07:02:59'),
('DE7', 'Departemen 1-2', '', 1, 'D12', 'admin', '', '2026-04-11 07:03:36');

CREATE TABLE `depreciationrecords` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `fixedassetid` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `journalid` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `discountdays` (
  `adate` date NOT NULL,
  `description` varchar(100) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `division` (
  `id` char(10) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `acumsalesdisc` smallint(6) NOT NULL DEFAULT 1,
  `updlastsalesmanidtocust` smallint(6) NOT NULL DEFAULT 0,
  `frmsupplierdpid` varchar(20) NOT NULL DEFAULT '',
  `frmpurchaserequisitionid` varchar(20) NOT NULL DEFAULT '',
  `frmpurchaseorderid` varchar(20) NOT NULL DEFAULT '',
  `frmgoodsreceiptid` varchar(20) NOT NULL DEFAULT '',
  `frmpurchaseid` varchar(20) NOT NULL DEFAULT '',
  `frmpurchasereturnid` varchar(20) NOT NULL DEFAULT '',
  `frmpurchasepaymentid` varchar(20) NOT NULL DEFAULT '',
  `frmpayableadjustid` varchar(20) NOT NULL DEFAULT '',
  `frmcustomerdpid` varchar(20) NOT NULL DEFAULT '',
  `frmsalesorderid` varchar(20) NOT NULL DEFAULT '',
  `frmdeliveryorderid` varchar(20) NOT NULL DEFAULT '',
  `frmsalesid` varchar(20) NOT NULL DEFAULT '',
  `frmtaxid` varchar(30) NOT NULL DEFAULT '',
  `frmsalesreturnid` varchar(20) NOT NULL DEFAULT '',
  `frmsalespaymentid` varchar(20) NOT NULL DEFAULT '',
  `frmreceivableadjustid` varchar(20) NOT NULL DEFAULT '',
  `frmrentalreturnid` varchar(20) NOT NULL DEFAULT '',
  `frminventoryid` varchar(20) NOT NULL DEFAULT '',
  `frmjournalentryid` varchar(20) NOT NULL DEFAULT '',
  `frmmanufactureid` varchar(20) NOT NULL DEFAULT '',
  `frmpayrollid` varchar(20) NOT NULL DEFAULT '',
  `supplierdpidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `purchaserequisitionidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `purchaseorderidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `goodsreceiptidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `purchaseidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `purchasereturnidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `purchasepaymentidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `payableadjustidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `customerdpidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `salesorderidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `deliveryorderidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `salesidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `taxidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `salesreturnidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `salespaymentidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `receivableadjustidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `rentalreturnidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `inventoryidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `journalentryidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `manufactureidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `payrollidno` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `retainedearningacc` char(30) NOT NULL DEFAULT '',
  `exchangerateacc` char(30) NOT NULL DEFAULT '',
  `profitlossdiffcashacc` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `division` (`id`, `description`, `acumsalesdisc`, `updlastsalesmanidtocust`, `frmsupplierdpid`, `frmpurchaserequisitionid`, `frmpurchaseorderid`, `frmgoodsreceiptid`, `frmpurchaseid`, `frmpurchasereturnid`, `frmpurchasepaymentid`, `frmpayableadjustid`, `frmcustomerdpid`, `frmsalesorderid`, `frmdeliveryorderid`, `frmsalesid`, `frmtaxid`, `frmsalesreturnid`, `frmsalespaymentid`, `frmreceivableadjustid`, `frmrentalreturnid`, `frminventoryid`, `frmjournalentryid`, `frmmanufactureid`, `frmpayrollid`, `supplierdpidno`, `purchaserequisitionidno`, `purchaseorderidno`, `goodsreceiptidno`, `purchaseidno`, `purchasereturnidno`, `purchasepaymentidno`, `payableadjustidno`, `customerdpidno`, `salesorderidno`, `deliveryorderidno`, `salesidno`, `taxidno`, `salesreturnidno`, `salespaymentidno`, `receivableadjustidno`, `rentalreturnidno`, `inventoryidno`, `journalentryidno`, `manufactureidno`, `payrollidno`, `retainedearningacc`, `exchangerateacc`, `profitlossdiffcashacc`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('D11', 'DIVISI PUSAT', 0, 1, 'I/PD-######', 'I/RQ-######', 'I/PO-######', 'I/GR-######', 'I/PC-######', 'I/PR-######', 'I/PP-######', 'I/SA-######', 'I/SD-######', 'I/SO-######', 'I/DO-######', 'I/SL-######', '010.000-######', 'I/SR-######', 'I/SP-######', 'I/CA-######', 'I/RR-######', 'I/IM-######', 'I/JT-######', 'I/MRP-######', 'I/PY-######', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, '301.002', '701.002', '701.006', 'admin', 'admin', '2026-04-16 11:50:11'),
('D12', 'DIVISI CABANG', 0, 1, 'II/PD-######', 'II/RQ-######', 'II/PO-######', 'II/GR-######', 'II/PC-######', 'II/PR-######', 'II/PP-######', 'II/SA-######', 'II/SD-######', 'II/SO-######', 'II/DO-######', 'II/SL-######', '010.000-######', 'II/SR-######', 'II/SP-######', 'II/CA-######', 'I/RR-######', 'II/IM-######', 'II/JT-######', 'II/MF-%0:6.6d', 'II/PY-######', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, '301.002', '701.002', '701.006', 'admin', 'admin', '2026-04-04 04:43:20');

CREATE TABLE `employeeface` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `employeeid` char(30) NOT NULL DEFAULT '',
  `templatedata` mediumtext DEFAULT NULL,
  `templateversion` varchar(50) NOT NULL DEFAULT '',
  `qualityscore` decimal(10,6) DEFAULT NULL,
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `notes` varchar(255) DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `employeefaceenrollment` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `employeeid` char(30) NOT NULL DEFAULT '',
  `snapshot1` varchar(255) DEFAULT '',
  `snapshot2` varchar(255) DEFAULT '',
  `snapshot3` varchar(255) DEFAULT '',
  `qualityscore` decimal(10,6) DEFAULT NULL,
  `status` varchar(30) NOT NULL DEFAULT 'draft',
  `notes` varchar(255) DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `employeegroup` (
  `id` char(30) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `employeegroup` (`id`, `description`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('EG-001', 'HEAD OFFICE', 'admin', 'admin', '2024-02-06 09:48:56'),
('EG-002', 'STORE', 'admin', 'admin', '2024-02-06 09:48:59');

CREATE TABLE `employeesalaries` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `employeeid` char(30) NOT NULL DEFAULT '',
  `salaryid` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `kind` int(11) NOT NULL DEFAULT 1 COMMENT '1=fixed, 2=input, 3=formula',
  `defaultvalue` double NOT NULL DEFAULT 0,
  `formula` text NOT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `weight` int(11) NOT NULL DEFAULT 0,
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `excratehistories` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `id` char(3) NOT NULL DEFAULT '',
  `rate` double NOT NULL DEFAULT 1,
  `user` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `factories` (
  `id` char(30) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `address` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `factories` (`id`, `name`, `address`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('P1', 'Tidak disebutkan', '', 'admin', '', '2024-02-05 14:57:05'),
('P2', 'Pabrik A', '', 'admin', '', '2026-03-14 21:43:32'),
('P3', 'Pabrik B', '', 'admin', '', '2026-03-14 21:43:36'),
('P4', 'PABRIK C', '', '', '', '2026-03-14 21:43:41'),
('P5', 'PABRIK D', '', '', '', '2024-07-03 08:57:18'),
('P6', 'PABRIK E', '', '', '', '2024-07-03 08:57:18');

CREATE TABLE `filteroperands` (
  `id` int(11) NOT NULL,
  `fieldtype` varchar(50) NOT NULL DEFAULT '0',
  `value` varchar(50) NOT NULL DEFAULT '0',
  `label` varchar(50) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `filteroperands` (`id`, `fieldtype`, `value`, `label`) VALUES
(1, 'text', '', ''),
(2, 'text', '=', '='),
(3, 'text', 'like', 'like'),
(4, 'date', '', ''),
(5, 'date', '=', '='),
(6, 'date', 'between', 'between'),
(7, 'date', '>=', '>='),
(8, 'date', '<=', '<='),
(9, 'datetime', '', ''),
(10, 'datetime', '=', '='),
(11, 'datetime', 'between', 'between'),
(12, 'datetime', '>=', '>='),
(13, 'datetime', '<=', '<='),
(14, 'time', '', ''),
(15, 'time', '=', '='),
(16, 'time', 'between', 'between'),
(17, 'time', '>=', '>='),
(18, 'time', '<=', '<='),
(19, 'decimal', '', ''),
(20, 'decimal', '=', '='),
(21, 'decimal', 'between', 'between'),
(22, 'decimal', '>=', '>='),
(23, 'decimal', '<=', '<='),
(24, 'decimal', '<', '<'),
(25, 'decimal', '>', '>'),
(26, 'integer', '', ''),
(27, 'integer', '=', '='),
(28, 'integer', 'between', 'between'),
(29, 'integer', '>=', '>='),
(30, 'integer', '<=', '<='),
(31, 'integer', '<', '<'),
(32, 'integer', '>', '>');

CREATE TABLE `fixedasset` (
  `id` char(30) NOT NULL DEFAULT '',
  `name` varchar(50) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `fagroup` char(30) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `acquisitiondate` date DEFAULT NULL,
  `cost` double NOT NULL DEFAULT 0,
  `usefullife` double NOT NULL DEFAULT 0,
  `depreciationrate` double NOT NULL DEFAULT 0,
  `salvagevalue` double NOT NULL DEFAULT 0,
  `currentvalue` double NOT NULL DEFAULT 0,
  `journalid` varchar(30) NOT NULL DEFAULT '',
  `journaldate` datetime NOT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `active` smallint(6) NOT NULL DEFAULT 1,
  `accountid` char(30) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `fixedassetdepreciation` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` date DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `journalid` char(30) NOT NULL DEFAULT '',
  `memo` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `fixedassetdispose` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `fixedassetid` char(30) NOT NULL DEFAULT '',
  `name` varchar(50) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `acquisitiondate` date DEFAULT NULL,
  `cost` double NOT NULL DEFAULT 0,
  `usefullife` double NOT NULL DEFAULT 0,
  `depreciationrate` double NOT NULL DEFAULT 0,
  `salvagevalue` double NOT NULL DEFAULT 0,
  `bookedvalue` double NOT NULL DEFAULT 0,
  `currentvalue` double NOT NULL DEFAULT 0,
  `journalid` varchar(30) NOT NULL DEFAULT '',
  `journaldate` datetime NOT NULL,
  `salesprice` double NOT NULL DEFAULT 0,
  `profitloss` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `active` smallint(6) NOT NULL DEFAULT 1,
  `accountid` char(30) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `fixedassetgroup` (
  `id` char(30) NOT NULL DEFAULT '',
  `name` varchar(50) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `depreciationmethod` smallint(6) NOT NULL DEFAULT 0,
  `fixedassetacc` char(30) NOT NULL DEFAULT '',
  `depreciationacc` char(30) NOT NULL DEFAULT '',
  `expenseacc` char(30) NOT NULL DEFAULT '',
  `gainlostacc` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `fixedassetgroup` (`id`, `name`, `description`, `depreciationmethod`, `fixedassetacc`, `depreciationacc`, `expenseacc`, `gainlostacc`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('FA001', 'TANAH', '', 0, '111.001', '111.001', '605.001', '701.099', 'admin', '', '2024-05-20 18:03:34'),
('FA002', 'BANGUNAN', '', 0, '112.001', '112.002', '605.001', '701.099', 'admin', 'admin', '2024-05-21 17:35:10'),
('FA003', 'PERALATAN KANTOR', '', 1, '113.001', '113.002', '605.003', '701.099', 'admin', '', '2024-05-20 18:03:39'),
('FA004', 'KENDARAAN', '', 1, '114.001', '114.002', '605.002', '701.099', 'admin', '', '2024-05-20 18:03:42');

CREATE TABLE `goodsreceipt` (
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `purchaseorder` char(30) NOT NULL DEFAULT '',
  `purchasedate` date DEFAULT NULL,
  `purchasetime` time DEFAULT NULL,
  `kind` int(11) NOT NULL DEFAULT 0,
  `supplierid` char(30) NOT NULL DEFAULT '',
  `suppliername` varchar(100) NOT NULL DEFAULT '',
  `supplieraddress` varchar(200) NOT NULL DEFAULT '',
  `purchaser` char(30) NOT NULL DEFAULT '',
  `purchasername` varchar(100) NOT NULL DEFAULT '',
  `memo` text DEFAULT NULL,
  `memoedit` text DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `shipment` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `goodsreceiptdetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `qty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `goodsreceiptrewarddetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `qty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `groupid` (
  `id` char(30) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `customerid` char(30) NOT NULL DEFAULT '',
  `supplierid` char(30) NOT NULL DEFAULT '',
  `salesmanid` char(30) NOT NULL DEFAULT '',
  `servicedoerid` char(30) NOT NULL DEFAULT '',
  `employeeid` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `holidays` (
  `adate` date NOT NULL,
  `description` varchar(100) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `holidays` (`adate`, `description`) VALUES
('2011-02-01', 'Tahun baru Masehi'),
('2011-02-03', 'Tahun baru Imlek'),
('2011-02-15', 'Maulid Nabi Muhammad SAW'),
('2011-03-05', 'Tahun baru Saka'),
('2011-04-22', 'Wafat Yesus Kristus'),
('2011-05-17', 'Hari raya Waisak'),
('2011-06-02', 'Kenaikan Yesus Kristus'),
('2011-06-29', 'Isra\' Mi\'raj Nabi Muhammad SAW'),
('2011-08-17', 'Hari Kemerdekaan RI'),
('2011-08-30', 'Hari raya Idul Fitri'),
('2011-08-31', 'Hari raya Idul Fitri'),
('2011-11-06', 'Hari raya Idul Adha'),
('2011-11-27', 'Tahun baru Hijriyah'),
('2011-12-25', 'Hari raya Natal');

CREATE TABLE `inputpayablebal` (
  `id` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `accountid` char(30) NOT NULL DEFAULT '',
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `inputreceivablebal` (
  `id` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `accountid` char(30) NOT NULL DEFAULT '',
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `inventory` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `invin` double NOT NULL DEFAULT 0,
  `invout` double NOT NULL DEFAULT 0,
  `transtype` tinyint(4) NOT NULL DEFAULT 0,
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `inventoryadjust` (
  `id` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `accountid` char(30) NOT NULL DEFAULT '',
  `memo` varchar(250) NOT NULL DEFAULT '',
  `memoedit` varchar(250) NOT NULL DEFAULT '',
  `posted` smallint(6) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `inventoryadjustdetail` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `unit` char(10) NOT NULL DEFAULT '',
  `cogs` double NOT NULL DEFAULT 0,
  `recorded` double NOT NULL DEFAULT 0,
  `physical` double NOT NULL DEFAULT 0,
  `inqty` double DEFAULT 0,
  `outqty` double DEFAULT 0,
  `invalue` double DEFAULT 0,
  `outvalue` double DEFAULT 0,
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `inventoryin` (
  `id` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `accountid` char(30) NOT NULL DEFAULT '',
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `inventoryindetail` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `usesn` smallint(6) NOT NULL DEFAULT 0,
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `unit` char(10) NOT NULL DEFAULT '',
  `qty` double DEFAULT 0,
  `unitqty` double DEFAULT 0,
  `cogs` double DEFAULT 0,
  `subtotal` double DEFAULT 0,
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `inventorymoving` (
  `id` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `fromdivision` char(10) NOT NULL DEFAULT '',
  `fromdepartement` char(10) NOT NULL DEFAULT '',
  `todivision` char(10) NOT NULL DEFAULT '',
  `todepartement` char(10) NOT NULL DEFAULT '',
  `approved` int(11) NOT NULL DEFAULT 1,
  `memo` varchar(250) NOT NULL DEFAULT '',
  `memoedit` varchar(250) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `inventorymovingdetail` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `usesn` smallint(6) NOT NULL DEFAULT 0,
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `unit` char(10) NOT NULL DEFAULT '',
  `qty` double DEFAULT 0,
  `unitqty` double DEFAULT 0,
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `inventoryout` (
  `id` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `accountid` char(30) NOT NULL DEFAULT '',
  `accountname` varchar(150) NOT NULL DEFAULT '',
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `inventoryoutdetail` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `usesn` smallint(6) NOT NULL DEFAULT 0,
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `unit` char(10) NOT NULL DEFAULT '',
  `qty` double DEFAULT 0,
  `unitqty` double DEFAULT 0,
  `cogs` double DEFAULT 0,
  `subtotal` double DEFAULT 0,
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `journal` (
  `jtid` varchar(30) NOT NULL DEFAULT '',
  `jtdate` date DEFAULT NULL,
  `jttime` time DEFAULT NULL,
  `memo` varchar(100) NOT NULL DEFAULT '',
  `memoedit` varchar(100) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `journalvalue` double NOT NULL DEFAULT 0,
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `approved` int(11) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `journalclose` (
  `jtid` varchar(30) NOT NULL DEFAULT '',
  `jtdate` date DEFAULT NULL,
  `jttime` time DEFAULT NULL,
  `accountid` char(30) NOT NULL DEFAULT '',
  `accountname` varchar(150) NOT NULL DEFAULT '',
  `journalvalue` double NOT NULL DEFAULT 0,
  `memo` varchar(100) NOT NULL DEFAULT '',
  `memoedit` varchar(100) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `journalexpense` (
  `jtid` varchar(30) NOT NULL DEFAULT '',
  `jtdate` date DEFAULT NULL,
  `jttime` time DEFAULT NULL,
  `paymenttype` int(10) UNSIGNED NOT NULL,
  `approved` int(11) NOT NULL DEFAULT 1,
  `journalvalue` double NOT NULL DEFAULT 0,
  `memo` varchar(100) NOT NULL DEFAULT '',
  `memoedit` varchar(100) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `journalexpensedetail` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `jtid` varchar(30) NOT NULL DEFAULT '',
  `memo` varchar(100) NOT NULL DEFAULT '',
  `accountid` char(30) NOT NULL DEFAULT '',
  `accountname` varchar(150) NOT NULL DEFAULT '',
  `value` double NOT NULL DEFAULT 0,
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `journalrevenue` (
  `jtid` varchar(30) NOT NULL DEFAULT '',
  `jtdate` date DEFAULT NULL,
  `jttime` time DEFAULT NULL,
  `paymenttype` int(10) UNSIGNED NOT NULL,
  `approved` int(11) NOT NULL DEFAULT 1,
  `journalvalue` double NOT NULL DEFAULT 0,
  `memo` varchar(100) NOT NULL DEFAULT '',
  `memoedit` varchar(100) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `journalrevenuedetail` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `jtid` varchar(30) NOT NULL DEFAULT '',
  `memo` varchar(100) NOT NULL DEFAULT '',
  `accountid` char(30) NOT NULL DEFAULT '',
  `accountname` varchar(150) NOT NULL DEFAULT '',
  `value` double NOT NULL DEFAULT 0,
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `journaltrans` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `jtid` varchar(30) NOT NULL DEFAULT '',
  `jtdate` datetime DEFAULT NULL,
  `memo` varchar(100) NOT NULL DEFAULT '',
  `accountid` char(30) NOT NULL DEFAULT '',
  `accountname` varchar(150) NOT NULL DEFAULT '',
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `division` char(10) NOT NULL DEFAULT '',
  `reftransaction` char(50) NOT NULL DEFAULT '',
  `approved` int(11) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `langoverrides` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `lang` varchar(20) NOT NULL,
  `langkey` varchar(255) NOT NULL,
  `value` text NOT NULL,
  `usercreate` varchar(100) DEFAULT NULL,
  `useredit` varchar(100) DEFAULT NULL,
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `logtransactions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `userid` char(16) NOT NULL DEFAULT '',
  `summary` tinytext NOT NULL,
  `transtimestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  `fromtransaction` varchar(100) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `mrpbomcomponent` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `mrpproduct` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '0',
  `qty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `mrpbomcomponent` (`id`, `mrpproduct`, `productid`, `productname`, `qty`, `unit`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(3, '33002', '11003', 'PRODUK 3', 1, 'PCS', 'admin', 'admin', '2026-04-16 11:57:28'),
(4, '33002', '11004', 'PRODUK 5', 1, 'PCS', 'admin', 'admin', '2026-04-16 11:57:34');

CREATE TABLE `mrpbomoperation` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `mrpproduct` char(30) NOT NULL DEFAULT '0',
  `operationid` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `name` varchar(100) NOT NULL DEFAULT '',
  `unitoperation` varchar(10) NOT NULL DEFAULT '',
  `labourcost` double NOT NULL DEFAULT 0,
  `duration` double NOT NULL DEFAULT 0,
  `unitduration` varchar(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `mrpbomoperation` (`id`, `mrpproduct`, `operationid`, `name`, `unitoperation`, `labourcost`, `duration`, `unitduration`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(4, '33002', 1, 'Potong Pola', 'PCS', 2000, 10, 'Menit', 'admin', '', '2024-07-09 20:00:06'),
(5, '33002', 2, 'Jahit Badan', 'PCS', 4000, 15, 'Menit', 'admin', '', '2024-07-09 20:00:14'),
(6, '33002', 3, 'Jahit Lengan', 'PCS', 3000, 5, 'Menit', 'admin', '', '2024-07-09 20:00:20');

CREATE TABLE `mrpoperation` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `unitoperation` varchar(10) NOT NULL DEFAULT '',
  `labourcost` double NOT NULL DEFAULT 0,
  `duration` double NOT NULL DEFAULT 0,
  `unitduration` varchar(10) NOT NULL DEFAULT '',
  `workcenter` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `wageaccount` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `mrpoperation` (`id`, `name`, `unitoperation`, `labourcost`, `duration`, `unitduration`, `workcenter`, `isactive`, `wageaccount`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Potong Pola', 'PCS', 2000, 10, 'Menit', 1, 1, '21.001', 'admin', '', '2024-09-05 01:18:45'),
(2, 'Jahit Badan', 'PCS', 4000, 15, 'Menit', 1, 1, '21.001', 'admin', '', '2024-09-05 01:18:45'),
(3, 'Jahit Lengan', 'PCS', 3000, 5, 'Menit', 1, 1, '21.001', 'admin', '', '2024-09-05 01:18:45');

CREATE TABLE `mrporder` (
  `transid` char(30) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `workcenter` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `createfromsales` tinyint(4) NOT NULL DEFAULT 1,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesproduct` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `qtyorder` double NOT NULL DEFAULT 0,
  `qtyfail` double NOT NULL DEFAULT 0,
  `qtyproduced` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `memo` text NOT NULL,
  `orderdate` datetime DEFAULT NULL,
  `startdate` datetime DEFAULT NULL,
  `expfinishdate` datetime DEFAULT NULL,
  `deadlinedate` datetime DEFAULT NULL,
  `realfinishdate` datetime DEFAULT NULL,
  `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=order, 1=ready, 2=process, 3=finish, 4=release',
  `oldcogs` double NOT NULL DEFAULT 0,
  `newcogs` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `mrpordercomponent` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `mrporder` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '0',
  `qty` double NOT NULL DEFAULT 0,
  `totalqty` double NOT NULL DEFAULT 0,
  `riilqty` double NOT NULL DEFAULT 0,
  `diffqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `cogs` double NOT NULL DEFAULT 0,
  `subtotal` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `mrpworkcenter` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `productiondepartement` char(10) NOT NULL DEFAULT '',
  `storedepartement` char(10) NOT NULL DEFAULT '',
  `memo` text NOT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `mrpworkcenter` (`id`, `name`, `division`, `productiondepartement`, `storedepartement`, `memo`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Produksi I', 'D11', 'D1103', 'D1102', '', 'admin', '', '2024-07-11 20:29:34'),
(2, 'Produksi II', 'D11', 'D1204', 'D1102', '', 'admin', '', '2024-07-11 20:31:06');

CREATE TABLE `mrpworkorder` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `mrporder` char(30) NOT NULL DEFAULT '',
  `operationid` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `name` varchar(100) NOT NULL DEFAULT '',
  `qtyorder` double NOT NULL DEFAULT 0,
  `qtyfail` double NOT NULL DEFAULT 0,
  `qtyproduced` double NOT NULL DEFAULT 0,
  `unitoperation` varchar(10) NOT NULL DEFAULT '',
  `labourcost` double NOT NULL DEFAULT 0,
  `totallabourcost` double NOT NULL DEFAULT 0,
  `duration` double NOT NULL DEFAULT 0,
  `totalduration` double NOT NULL DEFAULT 0,
  `unitduration` varchar(10) NOT NULL DEFAULT '',
  `orderdate` datetime DEFAULT NULL,
  `startdate` datetime DEFAULT NULL,
  `expfinishdate` datetime DEFAULT NULL,
  `deadlinedate` datetime DEFAULT NULL,
  `realfinishdate` datetime DEFAULT NULL,
  `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=order, 1=ready, 2=process, 3=finish',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `mrpworkorderemployee` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `workorderid` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `employeeid` char(30) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `qty` double NOT NULL DEFAULT 0,
  `unitoperation` varchar(10) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `onlinepayments` (
  `id` int(11) NOT NULL,
  `order_id` varchar(100) NOT NULL,
  `gateway` varchar(50) NOT NULL,
  `amount` decimal(18,8) NOT NULL,
  `currency` varchar(10) NOT NULL,
  `status` enum('pending','paid','failed','cancelled') NOT NULL DEFAULT 'pending',
  `transaction_reference` varchar(255) NOT NULL DEFAULT '',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `payableadjust` (
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `supplierid` char(30) NOT NULL DEFAULT '',
  `suppliername` varchar(100) NOT NULL DEFAULT '',
  `supplieraddress` varchar(200) NOT NULL DEFAULT '',
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `expensestype` int(10) UNSIGNED NOT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `memo` varchar(250) NOT NULL DEFAULT '',
  `memoedit` varchar(250) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `payablepayment` (
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `supplierid` char(30) NOT NULL DEFAULT '',
  `suppliername` varchar(100) NOT NULL DEFAULT '',
  `supplieraddress` varchar(200) NOT NULL DEFAULT '',
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `paymenttype` int(10) UNSIGNED NOT NULL,
  `kind` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `refpayment` varchar(30) NOT NULL DEFAULT '',
  `amount` double NOT NULL DEFAULT 0,
  `discountvalue` double NOT NULL DEFAULT 0,
  `netpayment` double NOT NULL DEFAULT 0,
  `memo` varchar(250) NOT NULL DEFAULT '',
  `memoedit` varchar(250) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `accepted` smallint(6) NOT NULL DEFAULT 0,
  `duedate` date DEFAULT NULL,
  `accepteddate` date DEFAULT NULL,
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `paymentdiscrules` (
  `id` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `description` varchar(100) NOT NULL DEFAULT '',
  `displayname` varchar(20) NOT NULL DEFAULT '',
  `formula` text DEFAULT NULL,
  `kind` int(11) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `paymenttype` (
  `id` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `name` varchar(50) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `paymentacc` char(30) NOT NULL DEFAULT '',
  `cashdiscacc` char(30) NOT NULL DEFAULT '',
  `expenseacc` char(30) NOT NULL DEFAULT '',
  `defexpense` float NOT NULL DEFAULT 0,
  `kind` smallint(6) NOT NULL DEFAULT 0,
  `qrcode` varchar(255) NOT NULL DEFAULT '[]',
  `pointpayment` double NOT NULL DEFAULT 0,
  `isactive` int(11) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `paymenttype` (`id`, `name`, `description`, `paymentacc`, `cashdiscacc`, `expenseacc`, `defexpense`, `kind`, `qrcode`, `pointpayment`, `isactive`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Tunai', '', '101.003', '408.001', '20.006', 0, 0, '[]', 0, 1, 'admin', 'admin', '2024-06-25 21:45:03'),
(2, 'Cheque', '', '101.001', '408.002', '20.006', 0, 1, '[]', 0, 1, 'admin', '', '2024-02-05 14:57:05'),
(3, 'Bank A', '', '102.001', '408.003', '20.006', 0, 2, '[{\"img\":\"http:\\/\\/acosysv8\\/api\\/assets\\/paymenttype\\/1715074870433.jpeg\",\"caption\":\"\",\"subtitle\":\"\"}]', 0, 1, 'admin', 'admin', '2024-05-07 09:41:15'),
(4, 'Giro Bank B', '', '102.002', '408.004', '20.006', 0, 3, '[]', 0, 1, 'admin', '', '2024-02-05 14:57:05'),
(5, 'Uang Muka Penjualan', '', '20.005', '408.004', '20.006', 0, 4, '[]', 0, 1, 'admin', 'admin', '2024-04-26 04:27:06'),
(6, 'Uang Muka Pembelian', '', '106.001', '408.004', '20.006', 0, 5, '[]', 0, 1, 'admin', 'admin', '2024-04-30 06:17:05'),
(7, 'Bank B', '', '102.001', '408.003', '20.006', 0, 2, '[{\"img\":\"http:\\/\\/acosysv8\\/api\\/assets\\/paymenttype\\/1715074870433.jpeg\",\"caption\":\"\",\"subtitle\":\"\"}]', 0, 1, 'admin', 'admin', '2024-06-03 04:04:20');

CREATE TABLE `pointofsales` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(50) NOT NULL DEFAULT '',
  `productgroup` text NOT NULL,
  `paymenttype` text NOT NULL,
  `paymentdefault` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `customerdefault` char(30) NOT NULL DEFAULT '',
  `salesmandefault` char(30) NOT NULL DEFAULT '',
  `servicedoerdefault` char(30) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `shipment` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `postingsummary` int(11) NOT NULL DEFAULT 0,
  `user` char(16) NOT NULL DEFAULT '',
  `openingdate` datetime DEFAULT NULL,
  `closingdate` datetime DEFAULT NULL,
  `status` int(11) DEFAULT 0,
  `printcashier` int(11) DEFAULT NULL,
  `printorder` text DEFAULT NULL,
  `frmsalesid` varchar(50) DEFAULT '',
  `currentsalesid` int(11) DEFAULT 0,
  `beginningbalance` double DEFAULT 0,
  `currentbalance` double DEFAULT 0,
  `endbalance` double DEFAULT 0,
  `showcategory` int(11) DEFAULT 1,
  `cacheproduct` int(11) DEFAULT NULL,
  `layout` int(11) DEFAULT 0,
  `showimage` int(11) DEFAULT 0,
  `usetable` int(11) DEFAULT 0,
  `orderfromvisitor` int(11) NOT NULL DEFAULT 0,
  `tables` text DEFAULT NULL,
  `autoprint` int(11) DEFAULT 1,
  `autofillpayment` int(11) DEFAULT 0,
  `customerdisplayconnect` int(11) DEFAULT 0,
  `slideid` int(11) DEFAULT 0,
  `printdensity` int(11) DEFAULT 0,
  `printasimage` int(11) DEFAULT 0,
  `paperwidth` float DEFAULT 80,
  `orderdesign` varchar(100) NOT NULL DEFAULT 'posorder.posorder',
  `cashierdesign` varchar(100) NOT NULL DEFAULT 'poscashier.poscashier',
  `reportdesign` varchar(100) NOT NULL DEFAULT 'posreport.posreport',
  `sourcecash` char(30) NOT NULL DEFAULT '',
  `barcodedecoder` int(11) NOT NULL DEFAULT 0,
  `barcodedecoderformat` varchar(50) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `pointofsales` (`id`, `name`, `productgroup`, `paymenttype`, `paymentdefault`, `customerdefault`, `salesmandefault`, `servicedoerdefault`, `division`, `departement`, `shipment`, `postingsummary`, `user`, `openingdate`, `closingdate`, `status`, `printcashier`, `printorder`, `frmsalesid`, `currentsalesid`, `beginningbalance`, `currentbalance`, `endbalance`, `showcategory`, `cacheproduct`, `layout`, `showimage`, `usetable`, `orderfromvisitor`, `tables`, `autoprint`, `autofillpayment`, `customerdisplayconnect`, `slideid`, `printdensity`, `printasimage`, `paperwidth`, `orderdesign`, `cashierdesign`, `reportdesign`, `sourcecash`, `barcodedecoder`, `barcodedecoderformat`) VALUES
(1, 'POS DENGAN MEJA', '[11,21,22,23]', '[\"1\",\"3\",\"7\"]', 1, 'C201', 'SL001', 'SD001', 'D11', 'D1101', 1, 1, '', '2026-03-16 07:41:41', NULL, 0, 1, '[\"1\"]', 'POS/I/########', 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, '[\"1\",\"2\",\"3\"]', 1, 0, 0, 1, 0, 0, 80, 'posorder-2.json', 'poscashier-2.json', 'posreport-1.json', '101.001', 0, ''),
(2, 'POS 2', '[\"11\",\"21\",\"22\"]', '[\"1\",\"3\"]', 1, 'C201', 'SL001', 'SD001', 'D11', 'D1101', 1, 0, '', '2026-04-08 14:49:07', NULL, 0, 1, '[\"0\"]', 'POS/II/########', 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, '[]', 1, 0, 0, 1, 0, 0, 80, 'posorder-1.json', 'poscashier-1.json', 'posreport-1.json', '101.001', 0, ''),
(3, 'POS HOTEL', '[11,21,22]', '[\"1\",\"3\"]', 1, 'C201', 'SL002', 'SD001', 'D11', 'D1101', 1, 0, '', '2026-03-21 02:35:50', '2024-06-28 15:05:09', 0, 1, '[]', 'POS/III/########', 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, '[\"4\",\"5\",\"6\"]', 1, 0, 0, 1, 1, 0, 80, 'posorder-1.json', 'poscashier-1.json', 'posreport-1.json', '101.001', 0, '');

CREATE TABLE `poshistories` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(50) NOT NULL DEFAULT '',
  `posid` bigint(20) UNSIGNED NOT NULL,
  `user` char(16) NOT NULL DEFAULT '',
  `openingdate` datetime DEFAULT NULL,
  `closingdate` datetime DEFAULT NULL,
  `beginningbalance` double DEFAULT 0,
  `endbalance` double DEFAULT 0,
  `diffcash` double DEFAULT 0,
  `invoicecount` int(11) NOT NULL DEFAULT 0,
  `productcount` int(11) NOT NULL DEFAULT 0,
  `rewardcount` int(11) NOT NULL DEFAULT 0,
  `customercount` int(11) NOT NULL DEFAULT 0,
  `totalsales` double NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `posprintcashier` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(50) NOT NULL DEFAULT '',
  `apsserver` varchar(50) NOT NULL DEFAULT '',
  `active` int(11) NOT NULL DEFAULT 1,
  `apsandroid` int(11) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `posprintcashier` (`id`, `name`, `apsserver`, `active`, `apsandroid`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Printer 1', 'Printer 1', 1, 0, 'admin', 'admin', '2026-02-05 14:03:12');

CREATE TABLE `posprintorder` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(50) NOT NULL DEFAULT '',
  `apsserver` varchar(50) NOT NULL DEFAULT '',
  `productgroup` text NOT NULL,
  `active` int(11) NOT NULL DEFAULT 1,
  `apsandroid` int(11) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `posprintorder` (`id`, `name`, `apsserver`, `productgroup`, `active`, `apsandroid`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Printer Dapur 1', 'Printer 1', '[\"11\",\"21\",\"22\"]', 1, 0, 'admin', 'admin', '2026-02-05 14:03:21');

CREATE TABLE `postable` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `guestcount` int(11) NOT NULL DEFAULT 0,
  `visitorname` varchar(50) NOT NULL DEFAULT '',
  `isactive` int(11) DEFAULT 1,
  `tablegroup` bigint(20) UNSIGNED DEFAULT 0,
  `isrent` int(11) DEFAULT 0,
  `customerid` char(30) DEFAULT '',
  `productid` char(30) DEFAULT '',
  `timeunit` char(10) DEFAULT '',
  `secondtimeunit` char(10) DEFAULT '',
  `notiftimebeforefinish` double DEFAULT 0,
  `limittimestart` double DEFAULT 0,
  `limittimefinish` double DEFAULT 0,
  `minrentperiod` double DEFAULT 0,
  `commandstart` varchar(1000) DEFAULT '',
  `commandwarning` varchar(1000) DEFAULT '',
  `commandfinish` varchar(1000) DEFAULT '',
  `rentqty` double NOT NULL DEFAULT 0,
  `starttime` datetime DEFAULT NULL,
  `finishtime` datetime DEFAULT NULL,
  `unlimited` int(11) DEFAULT 0,
  `salesid` char(30) DEFAULT '',
  `isordervisitor` int(11) NOT NULL DEFAULT 0,
  `firstorder` int(11) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `postable` (`id`, `name`, `guestcount`, `visitorname`, `isactive`, `tablegroup`, `isrent`, `customerid`, `productid`, `timeunit`, `secondtimeunit`, `notiftimebeforefinish`, `limittimestart`, `limittimefinish`, `minrentperiod`, `commandstart`, `commandwarning`, `commandfinish`, `rentqty`, `starttime`, `finishtime`, `unlimited`, `salesid`, `isordervisitor`, `firstorder`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Meja 1', 0, '', 1, 1, 0, 'C201', '40001', 'hour', 'minute', 10, 0, 0, 0, 'C:\\ffmpeg\\bin\\ffplay.exe -nodisp -autoexit -loglevel quiet C:\\ffmpeg\\audio\\1.mp3', 'C:\\ffmpeg\\bin\\ffplay.exe -nodisp -autoexit -loglevel quiet C:\\ffmpeg\\audio\\2.mp3', 'C:\\ffmpeg\\bin\\ffplay.exe -nodisp -autoexit -loglevel quiet C:\\ffmpeg\\audio\\3.mp3', 0, NULL, NULL, 0, '', 0, 0, '', '', '2026-02-05 14:13:28'),
(2, 'Meja 2', 0, '', 1, 1, 0, 'C201', '40001', 'day', 'hour', 10, 14, 12, 3, 'C:\\ffmpeg\\bin\\ffplay.exe -nodisp -autoexit -loglevel quiet C:\\ffmpeg\\audio\\1.mp3', 'C:\\ffmpeg\\bin\\ffplay.exe -nodisp -autoexit -loglevel quiet C:\\ffmpeg\\audio\\2.mp3', 'C:\\ffmpeg\\bin\\ffplay.exe -nodisp -autoexit -loglevel quiet C:\\ffmpeg\\audio\\3.mp3', 0, NULL, NULL, 0, '', 0, 0, '', 'admin', '2026-02-05 14:11:45'),
(3, 'Meja 3', 0, '', 1, 1, 0, 'C201', '40001', 'day', 'hour', 2, 14, 12, 3, 'C:\\ffmpeg\\bin\\ffplay.exe -nodisp -autoexit -loglevel quiet C:\\ffmpeg\\audio\\1.mp3', 'C:\\ffmpeg\\bin\\ffplay.exe -nodisp -autoexit -loglevel quiet C:\\ffmpeg\\audio\\2.mp3', 'C:\\ffmpeg\\bin\\ffplay.exe -nodisp -autoexit -loglevel quiet C:\\ffmpeg\\audio\\3.mp3', 0, NULL, NULL, 0, '', 0, 0, '', 'admin', '2024-08-22 10:31:08'),
(4, 'Kamar 1', 0, 'WAHONO', 1, 2, 1, 'C201', '40002', 'day', 'hour', 2, 14, 12, 3, '', '', '', 0, NULL, NULL, 0, '', 0, 1, '', 'admin', '2026-04-09 05:06:15'),
(5, 'Kamar 2', 0, 'palupi', 1, 2, 1, 'C201', '40002', 'day', 'hour', 2, 14, 12, 3, '', '', '', 0, NULL, NULL, 0, '', 0, 1, '', 'admin', '2026-04-09 05:06:15'),
(6, 'Kamar 3', 0, 'www', 1, 2, 1, 'C201', '40002', 'day', 'hour', 2, 14, 12, 3, '', '', '', 0, NULL, NULL, 0, '', 0, 1, '', 'admin', '2026-04-09 05:06:15');

CREATE TABLE `postablegroup` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(50) NOT NULL DEFAULT '',
  `isactive` int(11) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `postablegroup` (`id`, `name`, `isactive`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'GROUP 1', 1, '', 'admin', '2024-07-19 08:58:25'),
(2, 'GROUP 2', 1, 'admin', '', '2024-07-19 08:53:06');

CREATE TABLE `product` (
  `id` char(30) NOT NULL DEFAULT '',
  `aliasid` char(30) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `description` text NOT NULL,
  `productgroup` char(30) NOT NULL DEFAULT '',
  `supplier` char(30) NOT NULL DEFAULT '',
  `category` tinyint(4) DEFAULT 0 COMMENT '0=INVENTORY, 1=SERVICE',
  `factory` char(30) NOT NULL DEFAULT '',
  `brand` char(5) NOT NULL DEFAULT '',
  `usesn` smallint(6) NOT NULL DEFAULT 0,
  `minimum` double NOT NULL DEFAULT 0,
  `maximum` double NOT NULL DEFAULT 0,
  `minimumreorder` double NOT NULL DEFAULT 0,
  `defaultreorder` double NOT NULL DEFAULT 0,
  `taxtype` tinyint(4) NOT NULL DEFAULT 0,
  `author` char(30) NOT NULL DEFAULT '',
  `dwidth` double NOT NULL DEFAULT 0,
  `dheight` double NOT NULL DEFAULT 0,
  `dlength` double NOT NULL DEFAULT 0,
  `weight` double NOT NULL DEFAULT 0,
  `salesdiscrules` text DEFAULT NULL,
  `salesmancommrules` text DEFAULT NULL,
  `salesproductrewardrules` text DEFAULT NULL,
  `salespointrewardrules` text DEFAULT NULL,
  `servicedoercommrules` text DEFAULT NULL,
  `inventoryacc` char(30) NOT NULL DEFAULT '',
  `cogsacc` char(30) NOT NULL DEFAULT '',
  `salesacc` char(30) NOT NULL DEFAULT '',
  `salesdiscacc` char(30) NOT NULL DEFAULT '',
  `salesreturnacc` char(30) NOT NULL DEFAULT '',
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `image` varchar(255) DEFAULT '[]',
  `availableinpos` int(11) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `product` (`id`, `aliasid`, `name`, `description`, `productgroup`, `supplier`, `category`, `factory`, `brand`, `usesn`, `minimum`, `maximum`, `minimumreorder`, `defaultreorder`, `taxtype`, `author`, `dwidth`, `dheight`, `dlength`, `weight`, `salesdiscrules`, `salesmancommrules`, `salesproductrewardrules`, `salespointrewardrules`, `servicedoercommrules`, `inventoryacc`, `cogsacc`, `salesacc`, `salesdiscacc`, `salesreturnacc`, `isactive`, `usercreate`, `useredit`, `updatetimestamp`, `image`, `availableinpos`) VALUES
('11001', '', 'PRODUK 1', '<p><br></p>', '11', 'S001', 0, 'P1', 'B001', 0, 0, 100, 10, 20, 1, 'p1', 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '107.001', '501.001', '401.001', '401.003', '401.002', 1, 'admin', 'admin', '2026-04-16 11:54:06', '[]', 1),
('11002', '', 'PRODUK 2', '<p><br></p>', '11', 'S001', 0, 'P1', 'B002', 0, 0, 100, 10, 100, 0, 'p1', 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '107.001', '501.001', '401.001', '401.003', '401.002', 1, 'admin', 'admin', '2026-02-02 17:21:22', '[]', 1),
('11003', '', 'PRODUK 3', '<p><br></p>', '11', 'S001', 0, 'P1', 'B001', 0, 0, 100, 10, 20, 1, 'p1', 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '107.001', '501.001', '401.001', '401.003', '401.002', 1, 'admin', 'admin', '2026-02-05 13:26:41', '[]', 1),
('11004', '', 'PRODUK 5', '', '11', 'S001', 0, 'P1', 'B001', 0, 0, 100, 10, 20, 1, 'p1', 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '107.001', '501.001', '401.001', '401.003', '401.002', 1, 'admin', 'admin', '2026-04-28 11:44:06', '[]', 1),
('21002', '', 'HADIAH 1', '', '21', 'S005', 0, 'P1', 'B002', 0, 0, 0, 0, 0, 0, 'p1', 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '107.002', '501.002', '402.001', '402.003', '402.002', 1, 'admin', 'admin', '2026-04-11 07:25:57', '[]', 1),
('22001', '', 'JASA SERVICE', '', '22', 'S001', 1, 'P1', 'B002', 0, 0, 0, 0, 0, 0, 'p1', 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '107.003', '501.003', '403.001', '403.003', '403.002', 1, 'admin', 'admin', '2025-12-03 20:58:07', '[]', 1),
('33001', '', 'PAKET 1', '', '21', 'S001', 2, 'P1', 'B002', 0, 0, 0, 0, 0, 0, 'p1', 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '107.002', '501.002', '402.001', '402.003', '402.002', 1, 'admin', 'admin', '2026-01-16 14:12:12', '[]', 1),
('33002', '', 'PRODUKSI 1', '', '11', 'S003', 0, 'P1', 'B001', 0, 0, 100, 10, 20, 1, 'p1', 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '107.001', '501.001', '401.001', '401.003', '401.002', 1, 'admin', 'admin', '2025-12-03 20:58:07', '[]', 1),
('40001', '', 'SEWA MEJA 1', '', '22', 'S001', 1, 'P1', 'B002', 0, 0, 0, 0, 0, 0, 'p1', 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '107.003', '501.003', '403.001', '403.003', '403.002', 1, 'admin', 'admin', '2025-12-03 20:58:07', '[]', 1),
('40002', '', 'SEWA KAMAR 1', '', '22', 'S001', 1, 'P1', 'B002', 0, 0, 0, 0, 0, 0, 'p1', 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '107.003', '501.003', '403.001', '403.003', '403.002', 1, 'admin', 'admin', '2025-12-03 20:58:07', '[]', 1);

CREATE TABLE `productassemble` (
  `id` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `unit` char(10) NOT NULL DEFAULT '',
  `qty` double DEFAULT 0,
  `cogs` double DEFAULT 0,
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `productassembledetail` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `unit` char(10) NOT NULL DEFAULT '',
  `qty` double DEFAULT 0,
  `cogs` double DEFAULT 0,
  `subtotal` double DEFAULT 0,
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `productbrand` (
  `id` char(5) NOT NULL DEFAULT '',
  `name` varchar(45) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `productbrand` (`id`, `name`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('B001', 'ABC', '', 'admin', '2024-05-01 14:16:22'),
('B002', 'Tidak disebutkan', '', 'admin', '2024-02-05 14:57:05');

CREATE TABLE `productdisassemble` (
  `id` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `unit` char(10) NOT NULL DEFAULT '',
  `qty` double DEFAULT 0,
  `cogs` double DEFAULT 0,
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `productdisassembledetail` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `unit` char(10) NOT NULL DEFAULT '',
  `qty` double DEFAULT 0,
  `cogs` double DEFAULT 0,
  `subtotal` double DEFAULT 0,
  `memo` varchar(200) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `productgroup` (
  `id` char(30) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `salesdiscrules` text DEFAULT NULL,
  `salesmancommrules` text DEFAULT NULL,
  `salesproductrewardrules` text DEFAULT NULL,
  `salespointrewardrules` text DEFAULT NULL,
  `servicedoercommrules` text DEFAULT NULL,
  `inventoryacc` char(30) NOT NULL DEFAULT '',
  `cogsacc` char(30) DEFAULT '',
  `salesacc` char(30) NOT NULL DEFAULT '',
  `salesdiscacc` char(30) NOT NULL DEFAULT '',
  `salesreturnacc` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `productgroup` (`id`, `name`, `salesdiscrules`, `salesmancommrules`, `salesproductrewardrules`, `salespointrewardrules`, `servicedoercommrules`, `inventoryacc`, `cogsacc`, `salesacc`, `salesdiscacc`, `salesreturnacc`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('11', 'KELOMPOK 1', '[]', '[]', '[]', '[]', '[]', '107.001', '501.001', '401.001', '401.003', '401.002', 'admin', 'admin', '2025-12-03 20:58:07'),
('21', 'KELOMPOK 2', '[]', '[]', '[]', '[]', '[]', '107.002', '501.002', '402.001', '402.003', '402.002', 'admin', 'admin', '2025-12-03 20:58:07'),
('22', 'KELOMPOK 3', '[]', '[]', '[]', '[]', '[]', '107.003', '501.003', '403.001', '403.003', '403.002', 'admin', 'admin', '2025-12-03 20:58:07'),
('23', 'PENYEWAAN', '[]', '[]', '[]', '[]', '[]', '107.003', '501.003', '403.001', '403.003', '403.002', 'admin', 'admin', '2025-12-03 20:58:07'),
('MK001', 'Manajemen Kendaraan', '[]', '[]', '[]', '[]', '[]', '101.001', '101.001', '101.001', '101.001', '101.001', 'admin', 'admin', '2026-04-11 06:25:18');

CREATE TABLE `productpackage` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `packageid` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `qty` double NOT NULL DEFAULT 0,
  `cogs` double NOT NULL DEFAULT 0,
  `subtotal` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `productpackage` (`transid`, `packageid`, `productid`, `productname`, `qty`, `cogs`, `subtotal`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, '33001', '11001', 'PRODUK 1', 2, 900, 1800, 'admin', '', '2024-04-22 03:56:50'),
(2, '33001', '11002', 'PRODUK 2', 1, 9500, 9500, 'admin', '', '2024-04-22 03:56:50');

CREATE TABLE `productsalesvariant` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `extraprice` double NOT NULL DEFAULT 0,
  `productgroup` char(30) NOT NULL DEFAULT '',
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchase` (
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `purchaseorder` char(30) NOT NULL DEFAULT '',
  `purchasedate` date DEFAULT NULL,
  `purchasetime` time DEFAULT NULL,
  `kind` int(11) NOT NULL DEFAULT 0,
  `purchasetype` smallint(6) NOT NULL DEFAULT 0 COMMENT '0=CASH, 1=CASH ON DELIVERY, 2=CREDIT',
  `earlydiscdays` int(11) NOT NULL DEFAULT 0,
  `earlydiscvalue` double NOT NULL DEFAULT 0,
  `duedays` int(11) NOT NULL DEFAULT 0,
  `supplierid` char(30) NOT NULL DEFAULT '',
  `suppliername` varchar(100) NOT NULL DEFAULT '',
  `supplieraddress` varchar(200) NOT NULL DEFAULT '',
  `suppliercreditlimit` double NOT NULL DEFAULT 0,
  `suppliertaxid` varchar(50) NOT NULL DEFAULT '',
  `supplierbalance` double NOT NULL DEFAULT 0,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `purchaser` char(30) NOT NULL DEFAULT '',
  `purchasername` varchar(100) NOT NULL DEFAULT '',
  `purchasepercentdisc` double NOT NULL DEFAULT 0,
  `returnpercentdisc` double NOT NULL DEFAULT 0,
  `purchasevaluedisc` double NOT NULL DEFAULT 0,
  `returnvaluedisc` double NOT NULL DEFAULT 0,
  `pointbalance` double NOT NULL DEFAULT 0,
  `purchasepoint` double NOT NULL DEFAULT 0,
  `returnpoint` double NOT NULL DEFAULT 0,
  `currpointbalance` double NOT NULL DEFAULT 0,
  `purchasetotal` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `memoedit` text DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `shipment` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `dateaccepted` datetime DEFAULT NULL,
  `accepted` smallint(6) NOT NULL DEFAULT 1,
  `paidinfull` smallint(6) NOT NULL DEFAULT 0,
  `paidinfulldate` date DEFAULT NULL,
  `paidinfullref` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchasedetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `usesn` int(11) NOT NULL DEFAULT 0,
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `purchaseqty` double NOT NULL DEFAULT 0,
  `returnqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `price` double NOT NULL DEFAULT 0,
  `grossamount` double NOT NULL DEFAULT 0,
  `taxid` tinyint(4) NOT NULL DEFAULT 0,
  `purchasetax` double NOT NULL DEFAULT 0,
  `returntax` double NOT NULL DEFAULT 0,
  `percentdisc` varchar(50) NOT NULL DEFAULT '',
  `discformula` varchar(50) NOT NULL DEFAULT '',
  `valuedisc` double NOT NULL DEFAULT 0,
  `netamount` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchaseexpenses` (
  `id` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `name` varchar(50) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `purchaseexpacc` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `purchaseexpenses` (`id`, `name`, `description`, `purchaseexpacc`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Ongkos Angkut', '', '503.001', 'admin', '', '2024-02-05 14:57:06'),
(2, 'Ekspedisi', '', '503.002', 'admin', '', '2024-02-05 14:57:06');

CREATE TABLE `purchaseexpensesdetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `kind` int(11) NOT NULL DEFAULT 0,
  `purchaseexpid` int(10) UNSIGNED NOT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchaseextratax` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `purchaseqty` double NOT NULL DEFAULT 0,
  `returnqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `grossamount` double NOT NULL DEFAULT 0,
  `taxid` tinyint(4) NOT NULL DEFAULT 0,
  `purchasetax` double NOT NULL DEFAULT 0,
  `returntax` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchaseorder` (
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `purchaserequisition` char(30) NOT NULL DEFAULT '',
  `purchasedate` date DEFAULT NULL,
  `purchasetime` time DEFAULT NULL,
  `kind` int(11) NOT NULL DEFAULT 0,
  `purchasetype` smallint(6) NOT NULL DEFAULT 0 COMMENT '0=CASH, 1=CASH ON DELIVERY, 2=CREDIT',
  `earlydiscdays` int(11) NOT NULL DEFAULT 0,
  `earlydiscvalue` double NOT NULL DEFAULT 0,
  `duedays` int(11) NOT NULL DEFAULT 0,
  `supplierid` char(30) NOT NULL DEFAULT '',
  `suppliername` varchar(100) NOT NULL DEFAULT '',
  `supplieraddress` varchar(200) NOT NULL DEFAULT '',
  `suppliercreditlimit` double NOT NULL DEFAULT 0,
  `suppliertaxid` varchar(50) NOT NULL DEFAULT '',
  `supplierbalance` double NOT NULL DEFAULT 0,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `purchaser` char(30) NOT NULL DEFAULT '',
  `purchasername` varchar(100) NOT NULL DEFAULT '',
  `purchasepercentdisc` double NOT NULL DEFAULT 0,
  `returnpercentdisc` double NOT NULL DEFAULT 0,
  `purchasevaluedisc` double NOT NULL DEFAULT 0,
  `returnvaluedisc` double NOT NULL DEFAULT 0,
  `pointbalance` double NOT NULL DEFAULT 0,
  `purchasepoint` double NOT NULL DEFAULT 0,
  `returnpoint` double NOT NULL DEFAULT 0,
  `currpointbalance` double NOT NULL DEFAULT 0,
  `purchasetotal` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `memoedit` text DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `shipment` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `dateaccepted` datetime DEFAULT NULL,
  `accepted` smallint(6) NOT NULL DEFAULT 1,
  `paidinfull` smallint(6) NOT NULL DEFAULT 0,
  `paidinfulldate` date DEFAULT NULL,
  `paidinfullref` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchaseorderdetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `usesn` int(11) NOT NULL DEFAULT 0,
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `purchaseqty` double NOT NULL DEFAULT 0,
  `returnqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `price` double NOT NULL DEFAULT 0,
  `grossamount` double NOT NULL DEFAULT 0,
  `taxid` tinyint(4) NOT NULL DEFAULT 0,
  `purchasetax` double NOT NULL DEFAULT 0,
  `returntax` double NOT NULL DEFAULT 0,
  `percentdisc` varchar(50) NOT NULL DEFAULT '',
  `discformula` varchar(50) NOT NULL DEFAULT '',
  `valuedisc` double NOT NULL DEFAULT 0,
  `netamount` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchaseorderexpensesdetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `kind` int(11) NOT NULL DEFAULT 0,
  `purchaseexpid` int(10) UNSIGNED NOT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchaseorderextratax` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `purchaseqty` double NOT NULL DEFAULT 0,
  `returnqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `grossamount` double NOT NULL DEFAULT 0,
  `taxid` tinyint(4) NOT NULL DEFAULT 0,
  `purchasetax` double NOT NULL DEFAULT 0,
  `returntax` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchaseorderpayments` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `discountpercent` double NOT NULL DEFAULT 0,
  `discountvalue` double NOT NULL DEFAULT 0,
  `duedate` date DEFAULT NULL,
  `accepted` smallint(6) NOT NULL DEFAULT 0,
  `kind` smallint(6) NOT NULL DEFAULT 0,
  `paymenttype` int(10) UNSIGNED NOT NULL,
  `refpayment` varchar(30) NOT NULL,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchaseorderpoint` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `supplier` char(30) NOT NULL DEFAULT '',
  `qtyin` double NOT NULL DEFAULT 0,
  `qtyout` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchaseorderrewarddetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `purchaseqty` double NOT NULL DEFAULT 0,
  `returnqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `price` double NOT NULL DEFAULT 0,
  `grossamount` double NOT NULL DEFAULT 0,
  `taxid` tinyint(4) NOT NULL DEFAULT 0,
  `purchasetax` double NOT NULL DEFAULT 0,
  `returntax` double NOT NULL DEFAULT 0,
  `netamount` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchasepayments` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `discountpercent` double NOT NULL DEFAULT 0,
  `discountvalue` double NOT NULL DEFAULT 0,
  `duedate` date DEFAULT NULL,
  `accepted` smallint(6) NOT NULL DEFAULT 0,
  `kind` smallint(6) NOT NULL DEFAULT 0,
  `paymenttype` int(10) UNSIGNED NOT NULL,
  `refpayment` varchar(30) NOT NULL,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchasepoint` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `supplier` char(30) NOT NULL DEFAULT '',
  `qtyin` double NOT NULL DEFAULT 0,
  `qtyout` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchaserequisition` (
  `requisitionid` char(30) NOT NULL DEFAULT '',
  `requisitionidref` char(30) NOT NULL DEFAULT '',
  `requisitiondate` date DEFAULT NULL,
  `requisitiontime` time DEFAULT NULL,
  `requisitionstatus` int(11) NOT NULL DEFAULT 0,
  `approvaluser` char(16) NOT NULL DEFAULT '',
  `approvalusername` varchar(100) NOT NULL DEFAULT '',
  `requisitiontotal` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `memoedit` text DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchaserequisitiondetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `requisitionid` char(30) NOT NULL DEFAULT '',
  `requisitionidref` char(30) NOT NULL DEFAULT '',
  `supplierid` char(30) NOT NULL DEFAULT '',
  `suppliername` varchar(100) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `availablestock` double NOT NULL DEFAULT 0,
  `requestqty` double NOT NULL DEFAULT 0,
  `orderedqty` double NOT NULL DEFAULT 0,
  `remainingqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `estprice` double NOT NULL DEFAULT 0,
  `estamount` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `purchaserewarddetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `purchaseqty` double NOT NULL DEFAULT 0,
  `returnqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `price` double NOT NULL DEFAULT 0,
  `grossamount` double NOT NULL DEFAULT 0,
  `taxid` tinyint(4) NOT NULL DEFAULT 0,
  `purchasetax` double NOT NULL DEFAULT 0,
  `returntax` double NOT NULL DEFAULT 0,
  `netamount` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `receivableadjust` (
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `customerid` char(30) NOT NULL DEFAULT '',
  `customername` varchar(100) NOT NULL DEFAULT '',
  `customeraddress` varchar(200) NOT NULL DEFAULT '',
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `expensestype` int(10) UNSIGNED NOT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `memo` varchar(250) NOT NULL DEFAULT '',
  `memoedit` varchar(250) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `receivablepayment` (
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `customerid` char(30) NOT NULL DEFAULT '',
  `customername` varchar(100) NOT NULL DEFAULT '',
  `customeraddress` varchar(200) NOT NULL DEFAULT '',
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `paymenttype` int(10) UNSIGNED NOT NULL,
  `kind` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `refpayment` varchar(30) NOT NULL DEFAULT '',
  `amount` double NOT NULL DEFAULT 0,
  `discountvalue` double NOT NULL DEFAULT 0,
  `netpayment` double NOT NULL DEFAULT 0,
  `memo` varchar(250) NOT NULL DEFAULT '',
  `memoedit` varchar(250) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `accepted` smallint(6) NOT NULL DEFAULT 0,
  `duedate` date DEFAULT NULL,
  `accepteddate` date DEFAULT NULL,
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `religions` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `religions` (`id`, `name`) VALUES
(1, 'Unset');

CREATE TABLE `rentalreturn` (
  `transid` char(30) NOT NULL DEFAULT '',
  `salesid` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `customerid` char(30) NOT NULL DEFAULT '',
  `customername` varchar(100) NOT NULL DEFAULT '',
  `customeraddress` varchar(200) NOT NULL DEFAULT '',
  `invoicenotpaid` double NOT NULL DEFAULT 0,
  `totalpayment` double NOT NULL DEFAULT 0,
  `receivablebalance` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `memoedit` text DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `rentalreturndetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `rentalreturnid` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `qty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `roles` (
  `id` varchar(50) NOT NULL,
  `name` varchar(50) NOT NULL DEFAULT '',
  `menus` text DEFAULT NULL,
  `defaultdivision` char(10) DEFAULT NULL,
  `lockdivision` int(11) NOT NULL DEFAULT 0,
  `defaultcustomer` char(30) DEFAULT NULL,
  `lockcustomer` int(11) NOT NULL DEFAULT 0,
  `defaultsupplier` char(30) DEFAULT NULL,
  `locksupplier` int(11) NOT NULL DEFAULT 0,
  `defaultdepartement` char(10) DEFAULT NULL,
  `lockdepartement` int(11) NOT NULL DEFAULT 0,
  `defaultsalesman` char(30) DEFAULT NULL,
  `locksalesman` int(11) NOT NULL DEFAULT 0,
  `defaultservicedoer` char(30) DEFAULT NULL,
  `lockservicedoer` int(11) NOT NULL DEFAULT 0,
  `approvaljournal` int(11) NOT NULL DEFAULT 0,
  `approvalinvmoving` int(11) NOT NULL DEFAULT 1,
  `defaultcurrency` char(3) DEFAULT NULL,
  `lockcurrency` int(11) NOT NULL DEFAULT 0,
  `defaultemployee` char(10) DEFAULT NULL,
  `lockemployee` int(11) NOT NULL DEFAULT 0,
  `defaultshipment` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `lockshipment` int(11) NOT NULL DEFAULT 0,
  `defaultpayment` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `lockpayment` int(11) NOT NULL DEFAULT 0,
  `useextratax` int(11) NOT NULL DEFAULT 0,
  `usesnproduct` int(11) NOT NULL DEFAULT 0,
  `closepos` int(11) NOT NULL DEFAULT 1,
  `showsalespricehistory` int(11) NOT NULL DEFAULT 1,
  `showpurchasepricehistory` int(11) NOT NULL DEFAULT 1,
  `lockdatetime` int(11) NOT NULL DEFAULT 0,
  `locksalesprice` int(11) NOT NULL DEFAULT 0,
  `locksalesdisc` int(11) NOT NULL DEFAULT 0,
  `sellbelowcogs` int(11) NOT NULL DEFAULT 0,
  `productgroup` text DEFAULT NULL,
  `customergroup` text DEFAULT NULL,
  `suppliergroup` text DEFAULT NULL,
  `employeegroup` text DEFAULT NULL,
  `salesmangroup` text DEFAULT NULL,
  `servicedoergroup` text DEFAULT NULL,
  `divisionlist` text DEFAULT NULL,
  `departementlist` text DEFAULT NULL,
  `useotherstax` smallint(6) NOT NULL DEFAULT 0,
  `checkinventoryavailable` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `roles` (`id`, `name`, `menus`, `defaultdivision`, `lockdivision`, `defaultcustomer`, `lockcustomer`, `defaultsupplier`, `locksupplier`, `defaultdepartement`, `lockdepartement`, `defaultsalesman`, `locksalesman`, `defaultservicedoer`, `lockservicedoer`, `approvaljournal`, `approvalinvmoving`, `defaultcurrency`, `lockcurrency`, `defaultemployee`, `lockemployee`, `defaultshipment`, `lockshipment`, `defaultpayment`, `lockpayment`, `useextratax`, `usesnproduct`, `closepos`, `showsalespricehistory`, `showpurchasepricehistory`, `lockdatetime`, `locksalesprice`, `locksalesdisc`, `sellbelowcogs`, `productgroup`, `customergroup`, `suppliergroup`, `employeegroup`, `salesmangroup`, `servicedoergroup`, `divisionlist`, `departementlist`, `useotherstax`, `checkinventoryavailable`) VALUES
('accounting', 'Accounting', '[\"\\/login\",\"options\",\"generalgroup\",\"\\/report\\/repgirosupplier\",\"\\/report\\/repgirocustomer\",\"\\/report\\/analysiscenter\",\"helpgroup\",\"\\/documentation\",\"activation\",\"tutorial\",\"\\/updateversion\",\"aboutacosys\",\"\\/logout\",\"myprofile\",\"\\/apsconfig\",\"\\/dashboard\",\"\\/aboutapp\",\"helpgroup-about\",\"accountinggroup\",\"accountinggroup-journals\",\"\\/form\\/journal\",\"\\/form\\/journalrevenue\",\"\\/form\\/journalexpense\",\"\\/form\\/approvejournal\",\"\\/form\\/account\",\"\\/form\\/closingbook\",\"accountinggroup-cash\",\"\\/form\\/suppliergiro\",\"\\/form\\/customergiro\",\"accountinggroup-reports\",\"\\/report\\/journalreport\",\"\\/report\\/generalledger\",\"\\/report\\/balancesheet\",\"\\/report\\/profitlossstatement\",\"\\/report\\/cashflow\",\"\\/report\\/repchangeequity\",\"\\/report\\/exportefaktur\",\"fixedassetgroup\",\"\\/form\\/fixedasset\",\"\\/form\\/fixedassetgroup\",\"\\/form\\/fixedassetdepreciation\",\"\\/form\\/fixedassetdispose\",\"\\/report\\/repfixedasset\",\"payrollgroup\",\"payrollgroup-attendance\",\"\\/attendance\",\"\\/attendancekiosk\",\"payrollgroup-attendance-setup\",\"\\/attendancekioskenrollment\",\"\\/form\\/attendancekioskdevice\",\"\\/form\\/workinghours\",\"\\/form\\/listholiday\",\"payrollgroup-operations\",\"\\/form\\/salaryintake\",\"\\/form\\/salariescalc\",\"payrollgroup-master\",\"\\/form\\/salarystructure\",\"\\/form\\/salaries\",\"\\/form\\/employee\",\"\\/form\\/employeegroup\",\"payrollreportgroup\",\"\\/report\\/attendance\",\"\\/report\\/sheetattendance\",\"\\/report\\/attendancesummary\",\"\\/report\\/salaryslip\",\"\\/report\\/salarysummary\",\"\\/report\\/salarypertype\",\"vehiclegroup-master\",\"vehiclegroup\",\"manufacturegroup\",\"manufacturegroup-operations\",\"\\/form\\/mrporder\",\"manufacturegroup-setup\",\"\\/form\\/mrpworkcenter\",\"mrpreportgroup\",\"\\/report\\/mrporder\",\"\\/report\\/massmrporder\",\"\\/report\\/mrporderprogress\",\"\\/report\\/mrporderdeadline\",\"\\/report\\/workorder\",\"\\/report\\/workorderemployee\",\"\\/report\\/workorderoperation\",\"\\/report\\/workorderdeadline\",\"\\/report\\/workorderlate\",\"\\/form\\/domrpworkorder\",\"\\/form\\/mrpoperation\",\"productgroup\",\"productgroup-catalog\",\"\\/customerinformation\",\"\\/form\\/product\",\"\\/form\\/productgroup\",\"\\/form\\/productbrand\",\"\\/form\\/authors\",\"\\/form\\/factories\",\"productgroup-stock\",\"\\/form\\/inventorymoving\",\"\\/form\\/inventoryin\",\"\\/form\\/inventoryout\",\"\\/form\\/inventoryadjust\",\"productgroup-pricing\",\"\\/masspricing\",\"\\/report\\/printproductbarcode\",\"\\/report\\/printproductlabel\",\"productreportgroup\",\"\\/report\\/productpricelist\",\"\\/report\\/repinventorybal\",\"\\/report\\/repinventorybalnosn\",\"\\/report\\/repinventorybalnocogs\",\"\\/report\\/repinventorybalnosncogs\",\"\\/report\\/repglobalinventory\",\"\\/report\\/inventorydetail\",\"\\/report\\/producthistories\",\"\\/report\\/cogshistories\",\"\\/report\\/repinventorymovingsummary\",\"\\/report\\/repinventorymoving\",\"\\/report\\/repinventoryin\",\"\\/report\\/repinventoryout\",\"\\/report\\/inventoryadjust\",\"\\/report\\/inventorybalanceloc\",\"purchasegroup\",\"purchasegroup-procurement\",\"\\/form\\/supplierdp\",\"\\/form\\/purchaserequisition\",\"\\/form\\/purchaseorder\",\"\\/masspurchaseorder\",\"\\/form\\/goodsreceipt\",\"purchasegroup-transactions\",\"\\/form\\/purchase\",\"\\/form\\/purchasereturn\",\"\\/form\\/payablepayment\",\"\\/form\\/payableadjust\",\"purchasegroup-master\",\"\\/form\\/supplier\",\"\\/form\\/suppliergroup\",\"\\/form\\/purchaseexpenses\",\"\\/form\\/inputpayablebal\",\"purchasereportgroup\",\"\\/report\\/purchasesummary\",\"\\/report\\/purchasedivtransprod\",\"\\/report\\/purchasedivdeptprod\",\"\\/report\\/purchasedivsupprod\",\"\\/report\\/purchasedivpurprod\",\"\\/report\\/purchaseperproductgroup\",\"\\/report\\/purchaseperproductbrand\",\"\\/report\\/purchasedivshipmenttrans\",\"\\/report\\/purchasereturnsummary\",\"\\/report\\/purchasereturndivtransprod\",\"\\/report\\/purchasereturndivdeptprod\",\"\\/report\\/purchasereturndivsupprod\",\"\\/report\\/purchasereturndivpurprod\",\"\\/report\\/purchaseorder\",\"\\/report\\/purchaserequisition\",\"\\/report\\/purchaserequisitionpersupplier\",\"\\/report\\/goodsreceipt\",\"\\/report\\/repgoodsreceiptsummary\",\"\\/report\\/reppurchasepayment\",\"\\/report\\/reppurchaseanalysbyproduct\",\"\\/report\\/reppurchaseanalysis\",\"\\/report\\/reppurchaseanalysbyminreorder\",\"\\/report\\/repsupplierdp\",\"\\/report\\/repsupplierbalance\",\"\\/report\\/repsupplierbalancesummary\",\"\\/report\\/reppayablepayment\",\"\\/report\\/payableadjust\",\"\\/report\\/supplierhistories\",\"salesgroup\",\"salesgroup-orders\",\"\\/form\\/customerdp\",\"\\/form\\/salesorder\",\"\\/form\\/deliveryorder\",\"\\/form\\/sales\",\"\\/form\\/rentalreturn\",\"\\/shop\",\"salespos\",\"\\/posstart\",\"\\/form\\/pointofsales\",\"\\/tableorder\",\"\\/form\\/posprintcashier\",\"\\/form\\/posprintorder\",\"\\/form\\/postablegroup\",\"\\/form\\/postable\",\"\\/report\\/printqrcodetable\",\"\\/form\\/productsalesvariant\",\"\\/form\\/customerdisplay\",\"salesgroup-receivable\",\"\\/form\\/salesreturn\",\"\\/form\\/receivablepayment\",\"\\/massreceivablepayment\",\"\\/form\\/receivableadjust\",\"salesgroup-master\",\"\\/form\\/customer\",\"\\/form\\/customergroup\",\"\\/form\\/salesman\",\"\\/form\\/salesmangroup\",\"\\/form\\/servicedoer\",\"\\/form\\/servicedoergroup\",\"\\/form\\/salesexpenses\",\"\\/form\\/customernote\",\"\\/form\\/customernotestype\",\"\\/form\\/inputreceivablebal\",\"salesreportgroup\",\"\\/report\\/salessummary\",\"\\/report\\/salesdivtransprod\",\"\\/report\\/salesdivdeptprod\",\"\\/report\\/salesdivcustprod\",\"\\/report\\/salesdivsalesmanprod\",\"\\/report\\/salesdivservicedoerprod\",\"\\/report\\/salesdivshipmentprod\",\"\\/report\\/salesdivshipmenttransaction\",\"\\/report\\/salesperproductgroup\",\"\\/report\\/salesperproductbrand\",\"\\/report\\/renttransaction\",\"\\/report\\/analyzeperbrand\",\"\\/report\\/salesreturnsummary\",\"\\/report\\/salesreturndivtransprod\",\"\\/report\\/salesreturndivdeptprod\",\"\\/report\\/salesreturndivcustprod\",\"\\/report\\/salesreturndivsalesmanprod\",\"\\/report\\/salesreturndivservicedoerprod\",\"\\/report\\/salesorder\",\"\\/report\\/salesorderpersalesman\",\"\\/report\\/salesorderdivtransprod\",\"\\/report\\/deliveryorder\",\"\\/report\\/dopercustomerso\",\"\\/report\\/repsalespayment\",\"\\/report\\/salestrenddays\",\"\\/report\\/salestrendmonths\",\"\\/report\\/repcustomerpoint\",\"\\/report\\/repcustomerdp\",\"\\/report\\/customerreward\",\"\\/report\\/customerrewarddetail\",\"\\/report\\/repcustomerbalance\",\"\\/report\\/repcustomerbalancesummary\",\"\\/report\\/repreceivablepayment\",\"\\/report\\/repbilltosummary\",\"\\/report\\/receivableadjust\",\"\\/report\\/customernotes\",\"\\/report\\/customerhistories\",\"reportsanalyticsgroup\",\"\\/analystcenter\",\"\\/custommenu\",\"schoolgroup\",\"schoolgroup-operations\",\"\\/report\\/classanalysist\",\"\\/form\\/schoolscoringinput\",\"\\/form\\/schoolstudentsextrascore\",\"schoolgroup-master\",\"\\/form\\/schoollevel\",\"\\/form\\/schoolperiod\",\"\\/form\\/schoolscoringtype\",\"\\/form\\/schoollessongroup\",\"\\/form\\/schoollesson\",\"\\/form\\/schoolextrascoregroup\",\"\\/form\\/schoolextrascore\",\"\\/form\\/schoolexam\",\"\\/form\\/schoolclass\",\"\\/form\\/schoolstudentstatus\",\"\\/form\\/schoolstudentdorm\",\"\\/form\\/schoolstudent\",\"\\/form\\/schoolteacher\",\"schoolreportgroup\",\"\\/report\\/studentreport\",\"\\/report\\/studentreportparent\",\"\\/report\\/liststudent\",\"\\/report\\/listteacher\",\"\\/report\\/listlesson\",\"schoolfinance\",\"schoolfinance-transactions\",\"\\/form\\/schoolstudentpayment\",\"\\/form\\/schoolstudentpaymentschedule\",\"schoolfinance-setup\",\"\\/form\\/schoolpaymentgroup\",\"\\/form\\/schoolpayment\",\"\\/form\\/schoolpaymentpackage\",\"schoolfinancereportgroup\",\"\\/report\\/studentpayment\",\"\\/report\\/studentpaymentparent\",\"\\/report\\/receivablestudent\"]', 'D11', 0, 'C201', 0, 'S001', 0, 'D1101', 0, 'SL001', 0, 'SD001', 0, 0, 1, 'IDR', 0, 'E-001', 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '[]', '[]', '[]', 0, 1),
('administrator', 'Administrator', '[\"supplierdp\",\"purchaserequisition\",\"purchaseorder\",\"goodsreceipt\",\"purchase\",\"purchasereturn\",\"payablepayment\",\"payableadjust\",\"repsalesconsignsummary\",\"purchasesummary\",\"purchasedivtransprod\",\"purchasedivdeptprod\",\"purchasedivsupprod\",\"purchasedivpurprod\",\"purchaseperproductgroup\",\"purchaseperproductbrand\",\"purchasedivshipmenttrans\",\"purchasereturnsummary\",\"purchasereturndivtransprod\",\"purchasereturndivdeptprod\",\"purchasereturndivsupprod\",\"purchasereturndivpurprod\",\"repgoodsreceiptsummary\",\"purchaseanalysis\",\"reppurchaseanalysbyproduct\",\"reppurchaseanalysbyminreorder\",\"repsupplierdp\",\"repsupplierbalance\",\"repsupplierbalancesummary\",\"reppayablepayment\",\"supplierhistories\",\"listofemployee\",\"listofpurchaseexpenses\",\"inputpayablebal\",\"journal\",\"approvejournal\",\"journalreport\",\"generalledger\",\"balancesheet\",\"profitlossstatement\",\"cashflow\",\"repchangeequity\",\"exportefaktur\",\"repgirosupplier\",\"repgirocustomer\",\"analysiscenter\",\"fixedassetmng\",\"fixedassetdepr\",\"repfixedasset\",\"closingbook\",\"help\",\"activation\",\"tutorial\",\"checkupdates\",\"aboutacosys\",\"inventorymoving\",\"assembly\",\"disassembly\",\"sellingpackage\",\"repinventoryout\",\"inventoryadjust\",\"repinventorybal\",\"repinventorybalnosn\",\"repinventorybalnocogs\",\"repinventorybalnosncogs\",\"repglobalinventory\",\"inventorydetail\",\"producthistories\",\"repinventorymovingsummary\",\"repinventorymoving\",\"inventorybalanceloc\",\"productmanagement\",\"masspricing\",\"\\/form\\/units\",\"printlabel\",\"inputinventorybal\",\"\\/login\",\"\\/changepassword\",\"\\/options\",\"\\/changedate\",\"\\/changelanguage\",\"\\/form\\/authorityrequest\",\"\\/form\\/groupid\",\"\\/form\\/discountdays\",\"listofpaymentdiscrules\",\"\\/form\\/salesmancommrules\",\"\\/form\\/servicedoercommrules\",\"\\/synctransferproduct\",\"\\/syncreceiveproduct\",\"\\/syncexportdata\",\"\\/syncimportdatas\",\"\\/maintenance\",\"\\/form\\/logtransaction\",\"\\/dashboard\",\"productsearch\",\"synchronizegroup\",\"purchaseconsigngroup\",\"salesquote\",\"salesorder\",\"deliveryorder\",\"sales\",\"packinggroup\",\"processpacking\",\"unpacked\",\"packed\",\"postingpos\",\"salesreturn\",\"receivablepayment\",\"massreceivable\",\"receivableadjust\",\"customernotes2\",\"pullcustomerpoint\",\"salesconsigngroup\",\"inpsoldconsign\",\"repsalesconsigncustomer\",\"salessummary\",\"salesdivtransprod\",\"salesdivdeptprod\",\"salesdivcustprod\",\"listofcustomer\",\"listofcustomerguide\",\"listofsalesman\",\"listofservicedoer\",\"listofsalesexpenses\",\"customernotestype\",\"inputreceivablebal\",\"rentgroup\",\"rentaltransaction\",\"rentreportgroup\",\"statusproduct\",\"reservation\",\"listofrentproductstatus\",\"listofrentproduct\",\"salaryintake\",\"masspayroll\",\"salariescalc\",\"salesmancommission\",\"servicedoercommission\",\"listofemployeelevel\",\"listofsalaries\",\"listholiday\",\"salesdivsalesmanprod\",\"salesdivservicedoerprod\",\"salesdivshipmentprod\",\"salesdivshipmenttransaction\",\"salesperproductgroup\",\"salesperproductbrand\",\"salescustdivtransprod\",\"analyzeperbrand\",\"salesreturnsummary\",\"salesreturndivtransprod\",\"salesreturndivdeptprod\",\"salesreturndivcustprod\",\"salesreturndivsalesmanprod\",\"salesreturndivservicedoerprod\",\"salesorderpersalesman\",\"salesorderdivtransprod\",\"dopercustomerso\",\"repsalespayment\",\"repcustomerpoint\",\"repcustomerdp\",\"customerreward\",\"customerrewarddetail\",\"repcustomerbalance\",\"repcustomerbalancesummary\",\"repreceivablepayment\",\"repbilltosummary\",\"customerhistories\",\"myprofile\",\"changepassword\",\"options\",\"changedate\",\"changelanguage\",\"maintenance\",\"form\\/logtransaction\",\"\\/form\\/paymentdiscrules\",\"synctransferproduct\",\"syncreceiveproduct\",\"syncexportdata\",\"syncimportdatas\",\"\\/form\\/printdesign\",\"\\/admin\\/reports\",\"\\/form\\/employeelevel\",\"\\/form\\/report\",\"\\/form\\/repsalesconsignsummary\",\"\\/report\\/purchaseanalysis\",\"\\/form\\/salesquote\",\"\\/form\\/salespos\",\"\\/form\\/processpacking\",\"\\/form\\/unpacked\",\"\\/form\\/packed\",\"\\/form\\/postingpos\",\"\\/form\\/massreceivable\",\"\\/form\\/customernotes2\",\"\\/form\\/pullcustomerpoint\",\"\\/form\\/inpsoldconsign\",\"\\/report\\/repsalesconsignsummary\",\"\\/report\\/repsalesconsigncustomer\",\"\\/report\\/salescustdivtransprod\",\"\\/report\\/salesquote\",\"\\/report\\/customernotes2\",\"\\/form\\/fixedassetmng\",\"\\/form\\/fixedassetdepr\",\"\\/report\\/analysiscenter\",\"\\/report\\/repgirocustomer\",\"\\/report\\/repgirosupplier\",\"\\/form\\/rentaltransaction\",\"\\/form\\/listofrentproduct\",\"\\/report\\/statusproduct\",\"\\/report\\/reservation\",\"\\/report\\/listofrentproductstatus\",\"\\/report\\/rentaltransaction\",\"\\/report\\/assembly\",\"\\/report\\/disassembly\",\"\\/documentation\",\"\\/form\\/productassemble\",\"\\/form\\/productdisassemble\",\"\\/pointofsales\",\"\\/form\\/mrpworkorder\",\"\\/report\\/mrpworkorder\",\"\\/form\\/mrpbomoperation\",\"\\/report\\/mrporderready\",\"\\/report\\/mrporderinprogress\",\"\\/report\\/mrporderexpected\",\"\\/report\\/mrporderfinish\",\"\\/report\\/workorderready\",\"\\/report\\/workorderinprogress\",\"\\/report\\/workorderfinish\",\"\\/report\\/workorderexpected\",\"\\/report\\/workorderemployeeoperation\",\"\\/form\\/servicedoercommission\",\"\\/form\\/salesmancommission\",\"\\/logout\",\"\\/customreports\",\"\\/apsconfig\",\"\\/form\\/vehicleassignment\",\"\\/form\\/vehicleodometer\",\"\\/form\\/vehiclemaintenancepart\",\"\\/form\\/vehiclefuellog\",\"equitygroup\",\"\\/dashboardequity\",\"\\/stocksell\",\"\\/form\\/equitydividendcalc\",\"\\/form\\/equitydividendwithdrawal\",\"equityreportgroup\",\"\\/report\\/stockvaluation\",\"\\/report\\/stockhistories\",\"\\/report\\/stockholders\",\"\\/form\\/equitysettings\",\"salesgroup\",\"salesgroup-orders\",\"\\/form\\/customerdp\",\"\\/form\\/salesorder\",\"\\/form\\/deliveryorder\",\"\\/form\\/sales\",\"\\/form\\/rentalreturn\",\"\\/shop\",\"salespos\",\"\\/posstart\",\"\\/form\\/pointofsales\",\"\\/tableorder\",\"\\/form\\/posprintcashier\",\"\\/form\\/posprintorder\",\"\\/form\\/postablegroup\",\"\\/form\\/postable\",\"\\/report\\/printqrcodetable\",\"\\/form\\/productsalesvariant\",\"\\/form\\/customerdisplay\",\"salesgroup-receivable\",\"\\/form\\/salesreturn\",\"\\/form\\/receivablepayment\",\"\\/massreceivablepayment\",\"\\/form\\/receivableadjust\",\"salesgroup-master\",\"\\/form\\/customer\",\"\\/form\\/customergroup\",\"\\/form\\/salesman\",\"\\/form\\/salesmangroup\",\"\\/form\\/servicedoer\",\"\\/form\\/servicedoergroup\",\"\\/form\\/salesexpenses\",\"\\/form\\/customernote\",\"\\/form\\/customernotestype\",\"\\/form\\/inputreceivablebal\",\"salesreportgroup\",\"\\/report\\/salessummary\",\"\\/report\\/salesdivtransprod\",\"\\/report\\/salesdivdeptprod\",\"\\/report\\/salesdivcustprod\",\"\\/report\\/salesdivsalesmanprod\",\"\\/report\\/salesdivservicedoerprod\",\"\\/report\\/salesdivshipmentprod\",\"\\/report\\/salesdivshipmenttransaction\",\"\\/report\\/salesperproductgroup\",\"\\/report\\/salesperproductbrand\",\"\\/report\\/renttransaction\",\"\\/report\\/analyzeperbrand\",\"\\/report\\/salesreturnsummary\",\"\\/report\\/salesreturndivtransprod\",\"\\/report\\/salesreturndivdeptprod\",\"\\/report\\/salesreturndivcustprod\",\"\\/report\\/salesreturndivsalesmanprod\",\"\\/report\\/salesreturndivservicedoerprod\",\"\\/report\\/salesorder\",\"\\/report\\/salesorderpersalesman\",\"\\/report\\/salesorderdivtransprod\",\"\\/report\\/deliveryorder\",\"\\/report\\/dopercustomerso\",\"\\/report\\/repsalespayment\",\"\\/report\\/salestrenddays\",\"\\/report\\/salestrendmonths\",\"\\/report\\/repcustomerpoint\",\"\\/report\\/repcustomerdp\",\"\\/report\\/customerreward\",\"\\/report\\/customerrewarddetail\",\"\\/report\\/repcustomerbalance\",\"\\/report\\/repcustomerbalancesummary\",\"\\/report\\/repreceivablepayment\",\"\\/report\\/repbilltosummary\",\"\\/report\\/receivableadjust\",\"\\/report\\/customernotes\",\"\\/report\\/customerhistories\",\"reportsanalyticsgroup\",\"\\/analystcenter\",\"\\/custommenu\",\"purchasegroup\",\"purchasegroup-procurement\",\"\\/form\\/supplierdp\",\"\\/form\\/purchaserequisition\",\"\\/form\\/purchaseorder\",\"\\/masspurchaseorder\",\"\\/form\\/goodsreceipt\",\"purchasegroup-transactions\",\"\\/form\\/purchase\",\"\\/form\\/purchasereturn\",\"\\/form\\/payablepayment\",\"\\/form\\/payableadjust\",\"purchasegroup-master\",\"\\/form\\/purchaseexpenses\",\"\\/form\\/inputpayablebal\",\"purchasereportgroup\",\"\\/report\\/purchasesummary\",\"\\/report\\/purchasedivtransprod\",\"\\/report\\/purchasedivdeptprod\",\"\\/report\\/purchasedivsupprod\",\"\\/report\\/purchasedivpurprod\",\"\\/report\\/purchaseperproductgroup\",\"\\/report\\/purchaseperproductbrand\",\"\\/report\\/purchasedivshipmenttrans\",\"\\/report\\/purchasereturnsummary\",\"\\/report\\/purchasereturndivtransprod\",\"\\/report\\/purchasereturndivdeptprod\",\"\\/report\\/purchasereturndivsupprod\",\"\\/report\\/purchasereturndivpurprod\",\"\\/report\\/purchaseorder\",\"\\/report\\/purchaserequisition\",\"\\/report\\/purchaserequisitionpersupplier\",\"\\/report\\/goodsreceipt\",\"\\/report\\/repgoodsreceiptsummary\",\"\\/report\\/reppurchasepayment\",\"\\/report\\/reppurchaseanalysbyproduct\",\"\\/report\\/reppurchaseanalysis\",\"\\/report\\/reppurchaseanalysbyminreorder\",\"\\/report\\/repsupplierdp\",\"\\/report\\/repsupplierbalance\",\"\\/report\\/repsupplierbalancesummary\",\"\\/report\\/reppayablepayment\",\"\\/report\\/payableadjust\",\"\\/report\\/supplierhistories\",\"productgroup\",\"productgroup-catalog\",\"\\/customerinformation\",\"\\/form\\/product\",\"\\/form\\/productgroup\",\"\\/form\\/productbrand\",\"\\/form\\/authors\",\"\\/form\\/factories\",\"productgroup-stock\",\"\\/form\\/inventorymoving\",\"\\/form\\/inventoryin\",\"\\/form\\/inventoryout\",\"\\/form\\/inventoryadjust\",\"productgroup-pricing\",\"\\/masspricing\",\"\\/report\\/printproductbarcode\",\"\\/report\\/printproductlabel\",\"productreportgroup\",\"\\/report\\/productpricelist\",\"\\/report\\/repinventorybal\",\"\\/report\\/repinventorybalnosn\",\"\\/report\\/repinventorybalnocogs\",\"\\/report\\/repinventorybalnosncogs\",\"\\/report\\/repglobalinventory\",\"\\/report\\/inventorydetail\",\"\\/report\\/producthistories\",\"\\/report\\/cogshistories\",\"\\/report\\/repinventorymovingsummary\",\"\\/report\\/repinventorymoving\",\"\\/report\\/repinventoryin\",\"\\/report\\/repinventoryout\",\"\\/report\\/inventoryadjust\",\"\\/report\\/inventorybalanceloc\",\"accountinggroup\",\"accountinggroup-journals\",\"\\/form\\/journal\",\"\\/form\\/journalrevenue\",\"\\/form\\/journalexpense\",\"\\/form\\/approvejournal\",\"\\/form\\/account\",\"\\/form\\/closingbook\",\"accountinggroup-cash\",\"\\/form\\/suppliergiro\",\"\\/form\\/customergiro\",\"accountinggroup-reports\",\"\\/report\\/journalreport\",\"\\/report\\/generalledger\",\"\\/report\\/balancesheet\",\"\\/report\\/profitlossstatement\",\"\\/report\\/cashflow\",\"\\/report\\/repchangeequity\",\"\\/report\\/exportefaktur\",\"fixedassetgroup\",\"\\/form\\/fixedasset\",\"\\/form\\/fixedassetgroup\",\"\\/form\\/fixedassetdepreciation\",\"\\/form\\/fixedassetdispose\",\"\\/report\\/repfixedasset\",\"manufacturegroup\",\"manufacturegroup-operations\",\"\\/form\\/mrporder\",\"manufacturegroup-setup\",\"\\/form\\/mrpworkcenter\",\"mrpreportgroup\",\"\\/report\\/mrporder\",\"\\/report\\/massmrporder\",\"\\/report\\/mrporderprogress\",\"\\/report\\/mrporderdeadline\",\"\\/report\\/workorder\",\"\\/report\\/workorderemployee\",\"\\/report\\/workorderoperation\",\"\\/report\\/workorderdeadline\",\"\\/report\\/workorderlate\",\"\\/form\\/domrpworkorder\",\"\\/form\\/mrpoperation\",\"payrollgroup\",\"payrollgroup-attendance\",\"\\/attendance\",\"\\/attendancekiosk\",\"payrollgroup-attendance-setup\",\"\\/attendancekioskenrollment\",\"\\/form\\/attendancekioskdevice\",\"\\/form\\/workinghours\",\"\\/form\\/listholiday\",\"payrollgroup-operations\",\"\\/form\\/salaryintake\",\"\\/form\\/salariescalc\",\"payrollgroup-master\",\"\\/form\\/salarystructure\",\"\\/form\\/salaries\",\"payrollreportgroup\",\"\\/report\\/attendance\",\"\\/report\\/sheetattendance\",\"\\/report\\/attendancesummary\",\"\\/report\\/salaryslip\",\"\\/report\\/salarysummary\",\"\\/report\\/salarypertype\",\"vehiclegroup\",\"vehiclegroup-operations\",\"\\/form\\/vehicletrip\",\"\\/form\\/vehicleroute\",\"\\/form\\/vehiclemaintenance\",\"\\/form\\/vehicledocument\",\"vehiclegroup-master\",\"\\/form\\/vehicle\",\"\\/form\\/vehiclebrand\",\"\\/form\\/vehiclefueltype\",\"\\/form\\/vehicletype\",\"\\/form\\/vehiclemodel\",\"\\/form\\/vehiclemaintenancecategory\",\"\\/form\\/employee\",\"\\/form\\/employeegroup\",\"\\/form\\/supplier\",\"\\/form\\/suppliergroup\",\"vehiclereportgroup\",\"\\/report\\/vehicleroute\",\"\\/report\\/vehiclefuellog\",\"\\/report\\/vehiclemaintenance\",\"\\/report\\/vehiclemaintenancepart\",\"schoolgroup\",\"schoolgroup-operations\",\"\\/report\\/classanalysist\",\"\\/form\\/schoolscoringinput\",\"\\/form\\/schoolstudentsextrascore\",\"schoolgroup-master\",\"\\/form\\/schoollevel\",\"\\/form\\/schoolperiod\",\"\\/form\\/schoolscoringtype\",\"\\/form\\/schoollessongroup\",\"\\/form\\/schoollesson\",\"\\/form\\/schoolextrascoregroup\",\"\\/form\\/schoolextrascore\",\"\\/form\\/schoolexam\",\"\\/form\\/schoolclass\",\"\\/form\\/schoolstudentstatus\",\"\\/form\\/schoolstudentdorm\",\"\\/form\\/schoolstudent\",\"\\/form\\/schoolteacher\",\"schoolreportgroup\",\"\\/report\\/studentreport\",\"\\/report\\/studentreportparent\",\"\\/report\\/liststudent\",\"\\/report\\/listteacher\",\"\\/report\\/listlesson\",\"schoolfinance\",\"schoolfinance-transactions\",\"\\/form\\/schoolstudentpayment\",\"\\/form\\/schoolstudentpaymentschedule\",\"schoolfinance-setup\",\"\\/form\\/schoolpaymentgroup\",\"\\/form\\/schoolpayment\",\"\\/form\\/schoolpaymentpackage\",\"schoolfinancereportgroup\",\"\\/report\\/studentpayment\",\"\\/report\\/studentpaymentparent\",\"\\/report\\/receivablestudent\",\"generalgroup\",\"generalgroup-organization\",\"\\/form\\/company\",\"\\/form\\/division\",\"\\/form\\/departement\",\"generalgroup-access\",\"\\/form\\/users\",\"\\/form\\/roles\",\"generalgroup-business-setup\",\"\\/form\\/paymenttype\",\"\\/form\\/taxes\",\"\\/form\\/shipments\",\"generalgroup-system\",\"\\/displayconfig\",\"\\/form\\/themecolors\",\"rulesgroup\",\"\\/form\\/salesdiscrules\",\"\\/form\\/salesproductrewardrules\",\"\\/form\\/salespointrewardrules\",\"generalgroup-design\",\"\\/printdesigner\",\"\\/reportdesigner\",\"generalgroup-localization\",\"\\/form\\/countries\",\"\\/form\\/currencies\",\"\\/form\\/religions\",\"\\/form\\/langoverrides\",\"generalgroup-maintenance\",\"\\/backuprestore\",\"\\/form\\/logtransactions\",\"helpgroup\",\"helpgroup-resources\",\"https:\\/\\/acosys.co.id\\/doc\",\"https:\\/\\/www.youtube.com\\/playlist?list=PLjfTJHP3hmCdHX7ff9d-wTy1PhKiAYlTz\",\"helpgroup-about\",\"\\/updateversion\",\"\\/aboutapp\"]', 'D11', 0, 'C101', 0, 'S001', 0, 'D1101', 0, 'SL001', 0, 'SD001', 0, 0, 1, 'IDR', 0, 'E-001', 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '[]', '[]', '[]', 0, 1),
('cashier', 'Cashier', '[\"\\/login\",\"\\/changepassword\",\"\\/options\",\"\\/changelanguage\",\"salesgroup\",\"sales\",\"salespos\",\"postingpos\",\"helpgroup\",\"help\",\"tutorial\",\"aboutacosys\",\"\\/form\\/salespos\",\"\\/form\\/postingpos\",\"\\/posstart\",\"myprofile\",\"\\/logout\",\"\\/apsconfig\",\"\\/aboutapp\",\"https:\\/\\/www.youtube.com\\/playlist?list=PLjfTJHP3hmCdHX7ff9d-wTy1PhKiAYlTz\",\"\\/documentation\",\"helpgroup-about\",\"helpgroup-resources\",\"\\/attendance\",\"payrollgroup-attendance\",\"payrollgroup\"]', 'D11', 0, 'C201', 0, 'S001', 0, 'D1101', 0, 'SL001', 0, 'SD001', 0, 0, 0, 'IDR', 0, 'E-001', 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '[]', '[]', '[]', 0, 1),
('hrd', 'Human Resource Development', '[\"\\/login\",\"myprofile\",\"options\",\"\\/form\\/masspayroll\",\"\\/form\\/salesmancommission\",\"\\/form\\/servicedoercommission\",\"\\/form\\/employeelevel\",\"helpgroup\",\"\\/documentation\",\"activation\",\"tutorial\",\"aboutacosys\",\"generalgroup\",\"\\/logout\",\"\\/apsconfig\",\"https:\\/\\/www.youtube.com\\/playlist?list=PLjfTJHP3hmCdHX7ff9d-wTy1PhKiAYlTz\",\"\\/aboutapp\",\"helpgroup-resources\",\"helpgroup-about\",\"payrollgroup\",\"payrollgroup-attendance\",\"\\/attendance\",\"\\/attendancekiosk\",\"payrollgroup-attendance-setup\",\"\\/attendancekioskenrollment\",\"\\/form\\/attendancekioskdevice\",\"\\/form\\/workinghours\",\"\\/form\\/listholiday\",\"payrollgroup-operations\",\"\\/form\\/salaryintake\",\"\\/form\\/salariescalc\",\"payrollgroup-master\",\"\\/form\\/salarystructure\",\"\\/form\\/salaries\",\"payrollreportgroup\",\"\\/report\\/attendance\",\"\\/report\\/sheetattendance\",\"\\/report\\/attendancesummary\",\"\\/report\\/salaryslip\",\"\\/report\\/salarysummary\",\"\\/report\\/salarypertype\",\"\\/dashboard\"]', 'D11', 0, 'C201', 0, 'S001', 0, 'D1101', 0, 'SL001', 0, 'SD001', 0, 0, 0, 'IDR', 0, 'E-001', 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '[]', '[]', '[]', 0, 1),
('purchasing', 'Purchasing', '[\"\\/login\",\"myprofile\",\"options\",\"purchaseconsigngroup\",\"\\/form\\/repsalesconsignsummary\",\"\\/report\\/repgirosupplier\",\"masspricing\",\"productsearch\",\"helpgroup\",\"\\/documentation\",\"tutorial\",\"aboutacosys\",\"\\/logout\",\"\\/apsconfig\",\"\\/dashboard\",\"\\/aboutapp\",\"https:\\/\\/www.youtube.com\\/playlist?list=PLjfTJHP3hmCdHX7ff9d-wTy1PhKiAYlTz\",\"payrollgroup\",\"\\/attendance\",\"\\/form\\/salaryintake\",\"\\/form\\/salariescalc\",\"payrollreportgroup\",\"\\/report\\/attendance\",\"\\/report\\/sheetattendance\",\"\\/report\\/attendancesummary\",\"\\/report\\/salaryslip\",\"\\/report\\/salarysummary\",\"\\/report\\/salarypertype\",\"\\/form\\/salarystructure\",\"\\/form\\/salaries\",\"\\/form\\/workinghours\",\"\\/form\\/listholiday\",\"generalgroup\",\"\\/form\\/company\",\"\\/displayconfig\",\"\\/form\\/themecolors\",\"\\/form\\/users\",\"\\/form\\/roles\",\"\\/form\\/division\",\"\\/form\\/departement\",\"\\/form\\/paymenttype\",\"\\/form\\/taxes\",\"\\/form\\/shipments\",\"\\/printdesigner\",\"\\/reportdesigner\",\"rulesgroup\",\"\\/form\\/salesdiscrules\",\"\\/form\\/salesproductrewardrules\",\"\\/form\\/salespointrewardrules\",\"\\/form\\/countries\",\"\\/form\\/currencies\",\"\\/form\\/religions\",\"\\/backuprestore\",\"\\/form\\/logtransactions\",\"helpgroup-about\",\"helpgroup-resources\",\"vehiclegroup-master\",\"vehiclegroup\",\"payrollgroup-attendance\",\"payrollgroup-operations\",\"payrollgroup-master\",\"payrollgroup-attendance-setup\",\"generalgroup-organization\",\"generalgroup-system\",\"generalgroup-access\",\"generalgroup-business-setup\",\"generalgroup-design\",\"generalgroup-localization\",\"generalgroup-maintenance\",\"purchasegroup\",\"purchasegroup-procurement\",\"\\/form\\/supplierdp\",\"\\/form\\/purchaserequisition\",\"\\/form\\/purchaseorder\",\"\\/masspurchaseorder\",\"\\/form\\/goodsreceipt\",\"purchasegroup-transactions\",\"\\/form\\/purchase\",\"\\/form\\/purchasereturn\",\"\\/form\\/payablepayment\",\"\\/form\\/payableadjust\",\"purchasegroup-master\",\"\\/form\\/supplier\",\"\\/form\\/suppliergroup\",\"\\/form\\/employee\",\"\\/form\\/employeegroup\",\"\\/form\\/purchaseexpenses\",\"\\/form\\/inputpayablebal\",\"purchasereportgroup\",\"\\/report\\/purchasesummary\",\"\\/report\\/purchasedivtransprod\",\"\\/report\\/purchasedivdeptprod\",\"\\/report\\/purchasedivsupprod\",\"\\/report\\/purchasedivpurprod\",\"\\/report\\/purchaseperproductgroup\",\"\\/report\\/purchaseperproductbrand\",\"\\/report\\/purchasedivshipmenttrans\",\"\\/report\\/purchasereturnsummary\",\"\\/report\\/purchasereturndivtransprod\",\"\\/report\\/purchasereturndivdeptprod\",\"\\/report\\/purchasereturndivsupprod\",\"\\/report\\/purchasereturndivpurprod\",\"\\/report\\/purchaseorder\",\"\\/report\\/purchaserequisition\",\"\\/report\\/purchaserequisitionpersupplier\",\"\\/report\\/goodsreceipt\",\"\\/report\\/repgoodsreceiptsummary\",\"\\/report\\/reppurchasepayment\",\"\\/report\\/reppurchaseanalysbyproduct\",\"\\/report\\/reppurchaseanalysis\",\"\\/report\\/reppurchaseanalysbyminreorder\",\"\\/report\\/repsupplierdp\",\"\\/report\\/repsupplierbalance\",\"\\/report\\/repsupplierbalancesummary\",\"\\/report\\/reppayablepayment\",\"\\/report\\/payableadjust\",\"\\/report\\/supplierhistories\",\"productgroup\",\"productgroup-catalog\",\"\\/customerinformation\",\"\\/form\\/product\",\"\\/form\\/productgroup\",\"\\/form\\/productbrand\",\"\\/form\\/authors\",\"\\/form\\/factories\",\"productgroup-stock\",\"\\/form\\/inventorymoving\",\"\\/form\\/inventoryin\",\"\\/form\\/inventoryout\",\"\\/form\\/inventoryadjust\",\"productgroup-pricing\",\"\\/masspricing\",\"\\/report\\/printproductbarcode\",\"\\/report\\/printproductlabel\",\"productreportgroup\",\"\\/report\\/productpricelist\",\"\\/report\\/repinventorybal\",\"\\/report\\/repinventorybalnosn\",\"\\/report\\/repinventorybalnocogs\",\"\\/report\\/repinventorybalnosncogs\",\"\\/report\\/repglobalinventory\",\"\\/report\\/inventorydetail\",\"\\/report\\/producthistories\",\"\\/report\\/cogshistories\",\"\\/report\\/repinventorymovingsummary\",\"\\/report\\/repinventorymoving\",\"\\/report\\/repinventoryin\",\"\\/report\\/repinventoryout\",\"\\/report\\/inventoryadjust\",\"\\/report\\/inventorybalanceloc\",\"reportsanalyticsgroup\",\"\\/analystcenter\",\"\\/custommenu\"]', 'D11', 0, 'C201', 0, 'S001', 0, 'D1101', 0, 'SL001', 0, 'SD001', 0, 0, 1, 'IDR', 0, 'E-001', 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '[]', '[]', '[]', 0, 1),
('sales', 'Sales', '[\"packinggroup\",\"\\/form\\/processpacking\",\"\\/form\\/unpacked\",\"\\/form\\/packed\",\"\\/form\\/salespos\",\"\\/form\\/postingpos\",\"generalgroup\",\"\\/login\",\"myprofile\",\"options\",\"helpgroup\",\"\\/documentation\",\"tutorial\",\"aboutacosys\",\"\\/dashboard\",\"\\/form\\/massreceivable\",\"\\/form\\/pullcustomerpoint\",\"\\/logout\",\"\\/apsconfig\",\"https:\\/\\/www.youtube.com\\/playlist?list=PLjfTJHP3hmCdHX7ff9d-wTy1PhKiAYlTz\",\"\\/aboutapp\",\"helpgroup-resources\",\"helpgroup-about\",\"salesgroup\",\"salesgroup-orders\",\"\\/form\\/customerdp\",\"\\/form\\/salesorder\",\"\\/form\\/deliveryorder\",\"\\/form\\/sales\",\"\\/form\\/rentalreturn\",\"\\/shop\",\"salespos\",\"\\/posstart\",\"\\/form\\/pointofsales\",\"\\/tableorder\",\"\\/form\\/posprintcashier\",\"\\/form\\/posprintorder\",\"\\/form\\/postablegroup\",\"\\/form\\/postable\",\"\\/report\\/printqrcodetable\",\"\\/form\\/productsalesvariant\",\"\\/form\\/customerdisplay\",\"salesgroup-receivable\",\"\\/form\\/salesreturn\",\"\\/form\\/receivablepayment\",\"\\/massreceivablepayment\",\"\\/form\\/receivableadjust\",\"salesgroup-master\",\"\\/form\\/customer\",\"\\/form\\/customergroup\",\"\\/form\\/salesman\",\"\\/form\\/salesmangroup\",\"\\/form\\/servicedoer\",\"\\/form\\/servicedoergroup\",\"\\/form\\/salesexpenses\",\"\\/form\\/customernote\",\"\\/form\\/customernotestype\",\"\\/form\\/inputreceivablebal\",\"salesreportgroup\",\"\\/report\\/salessummary\",\"\\/report\\/salesdivtransprod\",\"\\/report\\/salesdivdeptprod\",\"\\/report\\/salesdivcustprod\",\"\\/report\\/salesdivsalesmanprod\",\"\\/report\\/salesdivservicedoerprod\",\"\\/report\\/salesdivshipmentprod\",\"\\/report\\/salesdivshipmenttransaction\",\"\\/report\\/salesperproductgroup\",\"\\/report\\/salesperproductbrand\",\"\\/report\\/renttransaction\",\"\\/report\\/analyzeperbrand\",\"\\/report\\/salesreturnsummary\",\"\\/report\\/salesreturndivtransprod\",\"\\/report\\/salesreturndivdeptprod\",\"\\/report\\/salesreturndivcustprod\",\"\\/report\\/salesreturndivsalesmanprod\",\"\\/report\\/salesreturndivservicedoerprod\",\"\\/report\\/salesorder\",\"\\/report\\/salesorderpersalesman\",\"\\/report\\/salesorderdivtransprod\",\"\\/report\\/deliveryorder\",\"\\/report\\/dopercustomerso\",\"\\/report\\/repsalespayment\",\"\\/report\\/salestrenddays\",\"\\/report\\/salestrendmonths\",\"\\/report\\/repcustomerpoint\",\"\\/report\\/repcustomerdp\",\"\\/report\\/customerreward\",\"\\/report\\/customerrewarddetail\",\"\\/report\\/repcustomerbalance\",\"\\/report\\/repcustomerbalancesummary\",\"\\/report\\/repreceivablepayment\",\"\\/report\\/repbilltosummary\",\"\\/report\\/receivableadjust\",\"\\/report\\/customernotes\",\"\\/report\\/customerhistories\"]', 'D11', 0, 'C201', 0, 'S001', 0, 'D1101', 0, 'SL001', 0, 'SD001', 0, 0, 1, 'IDR', 0, 'E-001', 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '[]', '[]', '[]', 0, 1),
('visitor', 'Visitor', '[\"\\/login\",\"helpgroup\",\"help\",\"tutorial\",\"checkupdates\",\"aboutacosys\",\"myprofile\",\"changepassword\",\"\\/documentation\",\"https:\\/\\/www.youtube.com\\/playlist?list=PLjfTJHP3hmCdHX7ff9d-wTy1PhKiAYlTz\",\"\\/aboutapp\"]', 'D11', 0, 'C201', 0, 'S001', 0, 'D1101', 0, 'SL001', 0, 'SD001', 0, 0, 0, 'IDR', 0, 'E-001', 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '[]', '[]', '[]', '[]', '[]', '[]', '[]', '[]', 0, 0);

CREATE TABLE `salaries` (
  `id` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `name` varchar(100) NOT NULL DEFAULT '',
  `description` varchar(200) NOT NULL DEFAULT '',
  `account` char(30) NOT NULL DEFAULT '',
  `kind` int(11) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `salaries` (`id`, `name`, `description`, `account`, `kind`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(0, 'Penarikan gaji', '', '21.001', 0, 'admin', '', '2024-02-05 14:57:07'),
(1, 'Gaji pokok', '', '604.001', 1, 'admin', '', '2024-02-05 14:57:07'),
(2, 'Komisi salesman', '', '604.001', 2, 'admin', '', '2024-02-05 14:57:07'),
(3, 'Komisi pelaksana jasa', '', '604.001', 3, 'admin', '', '2024-02-05 14:57:07'),
(4, 'Tunjangan', '', '604.001', 4, 'admin', '', '2024-02-05 14:57:07'),
(5, 'Absensi', '', '604.001', 5, 'admin', '', '2024-02-05 14:57:07');

CREATE TABLE `salariesrecord` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `refid` char(30) NOT NULL DEFAULT '',
  `employeeid` char(30) NOT NULL DEFAULT '',
  `salaryid` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `salaryname` varchar(100) NOT NULL DEFAULT '',
  `kind` int(11) NOT NULL DEFAULT 1 COMMENT '1=fixed, 2=input, 3=formula',
  `formula` text NOT NULL,
  `variables` text NOT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `transdate` datetime DEFAULT NULL,
  `posted` int(11) DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salarypayments` (
  `transid` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `transtime` time DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `employeeid` char(30) NOT NULL DEFAULT '',
  `employeename` varchar(100) NOT NULL DEFAULT '',
  `employeeaddress` varchar(200) NOT NULL DEFAULT '',
  `salarybalance` double NOT NULL DEFAULT 0,
  `salaryid` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `paymentvalue` double NOT NULL DEFAULT 0,
  `paymenttype` int(10) UNSIGNED NOT NULL,
  `refpayment` varchar(30) NOT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salaryperiod` (
  `id` char(30) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `fromdate` datetime DEFAULT NULL,
  `todate` datetime DEFAULT NULL,
  `posted` tinyint(1) NOT NULL DEFAULT 0,
  `division` varchar(10) NOT NULL DEFAULT '',
  `accountid` char(30) NOT NULL DEFAULT '',
  `postingdate` datetime DEFAULT NULL,
  `employeegroup` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salaryperioddetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `salaryperiod` char(30) NOT NULL DEFAULT '',
  `employeeid` char(30) NOT NULL DEFAULT '',
  `employeename` varchar(100) DEFAULT '',
  `postingdate` datetime DEFAULT NULL,
  `totalsalary` double DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salarystructure` (
  `id` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `description` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `salarystructure` (`id`, `description`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'MANAGEMENT LEVEL 1', 'admin', '', '2024-02-05 14:57:05'),
(2, 'MANAGEMENT LEVEL 2', 'admin', '', '2024-02-05 14:57:05');

CREATE TABLE `salarystructuredetail` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `salarystructure` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `salaryid` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `kind` int(11) NOT NULL DEFAULT 1 COMMENT '1=fixed, 2=input, 3=formula',
  `defaultvalue` double NOT NULL DEFAULT 0,
  `formula` text NOT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `weight` int(11) NOT NULL DEFAULT 0,
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `sales` (
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `salesorder` char(30) NOT NULL DEFAULT '',
  `salesdate` date DEFAULT NULL,
  `salestime` time DEFAULT NULL,
  `kind` int(11) NOT NULL DEFAULT 1,
  `salestype` smallint(6) NOT NULL DEFAULT 0 COMMENT '0=CASH, 1=CASH ON DELIVERY, 2=CREDIT',
  `earlydiscdays` int(11) NOT NULL DEFAULT 0,
  `earlydiscvalue` double NOT NULL DEFAULT 0,
  `duedays` int(11) NOT NULL DEFAULT 0,
  `customerid` char(30) NOT NULL DEFAULT '',
  `customername` varchar(100) NOT NULL DEFAULT '',
  `customeraddress` varchar(200) NOT NULL DEFAULT '',
  `customercreditlimit` double NOT NULL DEFAULT 0,
  `customercreditlimittype` tinyint(4) NOT NULL DEFAULT 0,
  `customertaxid` varchar(50) NOT NULL DEFAULT '',
  `customertaxable` smallint(6) NOT NULL DEFAULT 0,
  `customerbalance` double NOT NULL DEFAULT 0,
  `pricelevel` smallint(6) NOT NULL DEFAULT 1,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `salesmanid` char(30) NOT NULL DEFAULT '',
  `billto` char(30) NOT NULL DEFAULT '',
  `billtoname` varchar(100) NOT NULL DEFAULT '',
  `billtocreditlimit` double NOT NULL DEFAULT 0,
  `salesmanname` varchar(100) NOT NULL DEFAULT '',
  `shipto` text DEFAULT NULL,
  `salespercentdisc` double NOT NULL DEFAULT 0,
  `returnpercentdisc` double NOT NULL DEFAULT 0,
  `salesvaluedisc` double NOT NULL DEFAULT 0,
  `returnvaluedisc` double NOT NULL DEFAULT 0,
  `pointbalance` double NOT NULL DEFAULT 0,
  `salespoint` double NOT NULL DEFAULT 0,
  `returnpoint` double NOT NULL DEFAULT 0,
  `currpointbalance` double NOT NULL DEFAULT 0,
  `salestotal` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `memoedit` text DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `taxprinted` smallint(6) NOT NULL DEFAULT 0,
  `shipment` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `dateaccepted` datetime DEFAULT NULL,
  `accepted` smallint(6) NOT NULL DEFAULT 1,
  `paidinfull` smallint(6) NOT NULL DEFAULT 0,
  `paidinfulldate` date DEFAULT NULL,
  `paidinfullref` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `posted` smallint(6) NOT NULL DEFAULT 1,
  `packed` int(11) NOT NULL DEFAULT 0,
  `posid` int(11) NOT NULL DEFAULT 0,
  `renttrans` int(11) NOT NULL DEFAULT 0,
  `rentaltime` int(11) NOT NULL DEFAULT 0,
  `rentaltimeunit` varchar(10) NOT NULL DEFAULT '',
  `rentfinishtime` datetime DEFAULT NULL,
  `rentfinishstatus` int(11) DEFAULT 0,
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesdetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `usesn` int(11) NOT NULL DEFAULT 0,
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `salesqty` double NOT NULL DEFAULT 0,
  `returnqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `price` double NOT NULL DEFAULT 0,
  `grossamount` double NOT NULL DEFAULT 0,
  `taxid` tinyint(4) NOT NULL DEFAULT 0,
  `salestax` double NOT NULL DEFAULT 0,
  `returntax` double NOT NULL DEFAULT 0,
  `percentdisc` varchar(50) NOT NULL DEFAULT '',
  `discformula` varchar(50) NOT NULL DEFAULT '',
  `valuedisc` double NOT NULL DEFAULT 0,
  `netamount` double NOT NULL DEFAULT 0,
  `cogs` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `servicedoerid` char(30) NOT NULL DEFAULT '',
  `servicedoername` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesdiscrules` (
  `id` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `description` varchar(100) NOT NULL DEFAULT '',
  `displayname` varchar(20) NOT NULL DEFAULT '',
  `formula` text DEFAULT NULL,
  `category` int(11) NOT NULL DEFAULT 0,
  `kind` int(11) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `salesdiscrules` (`id`, `description`, `displayname`, `formula`, `category`, `kind`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'DISKON HARGA', 'DISC 1', 'product.brand==\"abc\" ? unit.salesprice1*0.75 : unit.salesprice1', 0, 0, 'admin', 'admin', '2024-05-01 19:14:41'),
(2, 'DISKON PERSEN', 'DISC 2', '(detail.salesqty*detail.unitqty>=24) ? 25 : ((detail.salesqty*detail.unitqty>=12) ? 20 : 0)', 0, 1, 'admin', '', '2024-05-02 02:55:20'),
(3, 'DISKON FAKTUR', 'DISC 3', 'salesgross>5000 ? 10 : 0', 1, 1, 'admin', '', '2024-05-02 00:06:41'),
(4, 'Diskon bertingkat 30%+40%+50%', '30%+40%+50%', 'stackeddiscount(30, 40, 5)', 0, 1, 'admin', '', '2025-08-27 13:32:38');

CREATE TABLE `salesexpenses` (
  `id` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `name` varchar(50) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `salesexpacc` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `salesexpenses` (`id`, `name`, `description`, `salesexpacc`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Ongkos Kuli', '', '701.099', 'admin', '', '2024-02-05 14:57:07'),
(2, 'Ekspedisi', '', '701.099', 'admin', '', '2024-02-05 14:57:07');

CREATE TABLE `salesexpensesdetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `kind` int(11) NOT NULL DEFAULT 0,
  `salesexpid` int(10) UNSIGNED NOT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesextratax` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `salesqty` double NOT NULL DEFAULT 0,
  `returnqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `grossamount` double NOT NULL DEFAULT 0,
  `taxid` tinyint(4) NOT NULL DEFAULT 0,
  `salestax` double NOT NULL DEFAULT 0,
  `returntax` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesman` (
  `id` char(30) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `salesmangroup` char(30) NOT NULL DEFAULT '',
  `address` varchar(200) NOT NULL DEFAULT '',
  `telephone` varchar(50) NOT NULL DEFAULT '',
  `faximile` varchar(50) NOT NULL DEFAULT '',
  `mobilephone` varchar(50) NOT NULL DEFAULT '',
  `category` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=PERSONAL, 1=COMPANY',
  `contactperson` varchar(100) NOT NULL DEFAULT '',
  `religion` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `birthdate` date DEFAULT NULL,
  `sex` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=MALE, 1=FEMALE',
  `email` varchar(100) NOT NULL DEFAULT '',
  `website` varchar(100) NOT NULL DEFAULT '',
  `creditlimit` double NOT NULL DEFAULT 0,
  `registerdate` date DEFAULT NULL,
  `activeuntil` date DEFAULT '2099-12-31',
  `country` char(3) NOT NULL DEFAULT '',
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `commisionrules` text DEFAULT NULL,
  `payablecommacc` char(30) NOT NULL DEFAULT '',
  `expensecommacc` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `image` varchar(255) DEFAULT '[]'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `salesman` (`id`, `name`, `salesmangroup`, `address`, `telephone`, `faximile`, `mobilephone`, `category`, `contactperson`, `religion`, `birthdate`, `sex`, `email`, `website`, `creditlimit`, `registerdate`, `activeuntil`, `country`, `isactive`, `commisionrules`, `payablecommacc`, `expensecommacc`, `usercreate`, `useredit`, `updatetimestamp`, `image`) VALUES
('SL001', 'Tidak disebutkan', 'S11', '', '', '', '', 0, '', 1, NULL, 0, '', '', 0, '2012-06-10', '2099-12-31', 'IDN', 1, '[]', '105.002', '602.004', 'admin', '', '2025-12-03 20:58:07', '[]'),
('SL002', 'Salesman A', 'S11', '', '', '', '', 0, '', 1, NULL, 0, '', '', 0, '2012-06-10', '2099-12-31', 'IDN', 1, '[]', '105.002', '602.004', 'admin', '', '2025-12-03 20:58:07', '[]'),
('SL003', 'Salesman B', 'S11', '', '', '', '', 0, '', 1, NULL, 0, '', '', 0, '2012-06-10', '2099-12-31', 'IDN', 1, '[]', '105.002', '602.004', 'admin', '', '2025-12-03 20:58:07', '[]');

CREATE TABLE `salesmancommperiod` (
  `id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `fromdate` date DEFAULT NULL,
  `fromtime` time DEFAULT NULL,
  `todate` date DEFAULT NULL,
  `totime` time DEFAULT NULL,
  `minsalesretur` tinyint(1) NOT NULL DEFAULT 1,
  `onlypaidsales` tinyint(1) NOT NULL DEFAULT 0,
  `onlyproductpaid` tinyint(1) NOT NULL DEFAULT 0,
  `onlyacceptedpaid` tinyint(1) NOT NULL DEFAULT 1,
  `accumrules` tinyint(1) NOT NULL DEFAULT 0,
  `includereceivable` tinyint(1) NOT NULL DEFAULT 1,
  `mintransdisc` tinyint(1) NOT NULL DEFAULT 1,
  `minproductdisc` tinyint(1) NOT NULL DEFAULT 1,
  `onlypaidinfull` tinyint(1) NOT NULL DEFAULT 0,
  `notlatereceivables` tinyint(1) NOT NULL DEFAULT 0,
  `posted` tinyint(1) NOT NULL DEFAULT 0,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `division` varchar(10) NOT NULL DEFAULT '',
  `formula` text DEFAULT NULL,
  `refid` char(30) NOT NULL DEFAULT '',
  `postdate` date DEFAULT NULL,
  `posttime` time DEFAULT NULL,
  `salaryid` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `groups` varchar(100) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesmancommrules` (
  `id` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `description` varchar(100) NOT NULL DEFAULT '',
  `displayname` varchar(20) NOT NULL DEFAULT '',
  `category` int(11) NOT NULL DEFAULT 0,
  `formula` text DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `salesmancommrules` (`id`, `description`, `displayname`, `category`, `formula`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'KOMISI 1', 'KOM1', 0, 'v.SalesReal*0.2', 'admin', '', '2024-02-05 14:57:08'),
(2, 'KOMISI 2', 'KOM2', 0, 'v.SalesReal*0.25', 'admin', '', '2024-02-05 14:57:08');

CREATE TABLE `salesmancommvar` (
  `varname` char(10) NOT NULL DEFAULT '',
  `varvalue` double NOT NULL DEFAULT 0,
  `description` varchar(50) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesmancommvarrecords` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `periodid` bigint(20) UNSIGNED NOT NULL,
  `varname` char(10) NOT NULL DEFAULT '',
  `varvalue` double NOT NULL DEFAULT 0,
  `description` varchar(50) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesmandetail` (
  `groupid` char(30) NOT NULL DEFAULT '',
  `salesmanid` char(30) NOT NULL DEFAULT '',
  `salesmanname` varchar(100) NOT NULL DEFAULT '',
  `percent` double NOT NULL DEFAULT 0,
  `memo` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesmangroup` (
  `id` char(30) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `commisionrules` text DEFAULT NULL,
  `payablecommacc` char(30) NOT NULL DEFAULT '',
  `expensecommacc` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `salesmangroup` (`id`, `description`, `commisionrules`, `payablecommacc`, `expensecommacc`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('S11', 'Internal Kantor', '[]', '105.002', '602.004', 'admin', '', '2025-12-03 20:58:07'),
('S2', 'SALESMAN II', '[]', '105.002', '602.004', 'admin', '', '2025-12-03 20:58:07');

CREATE TABLE `salesmanrecorddetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `periodid` bigint(20) UNSIGNED NOT NULL,
  `salesmanid` char(30) NOT NULL DEFAULT '',
  `salesmanname` varchar(100) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `salestargetqty` double NOT NULL DEFAULT 0,
  `salestargetvalue` double NOT NULL DEFAULT 0,
  `salesrealqty` double NOT NULL DEFAULT 0,
  `salesrealvalue` double NOT NULL DEFAULT 0,
  `percentqty` double NOT NULL DEFAULT 0,
  `percentvalue` double NOT NULL DEFAULT 0,
  `profit` double NOT NULL DEFAULT 0,
  `commission` double NOT NULL DEFAULT 0,
  `kind` int(11) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesmanrecords` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `periodid` bigint(20) UNSIGNED NOT NULL,
  `salesmanid` char(30) NOT NULL DEFAULT '',
  `salesmanname` varchar(100) NOT NULL DEFAULT '',
  `salesmanaddress` varchar(200) NOT NULL DEFAULT '',
  `receivable` double NOT NULL DEFAULT 0,
  `salestarget` double NOT NULL DEFAULT 0,
  `salesreal` double NOT NULL DEFAULT 0,
  `salespaid` double NOT NULL DEFAULT 0,
  `salespaymentaccepted` double NOT NULL DEFAULT 0,
  `percent` double NOT NULL DEFAULT 0,
  `profit` double NOT NULL DEFAULT 0,
  `commission` double NOT NULL DEFAULT 0,
  `productcommission` double NOT NULL DEFAULT 0,
  `receivablecommission` double NOT NULL DEFAULT 0,
  `totalcommission` double NOT NULL DEFAULT 0,
  `commissionpaid` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesorder` (
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `salesdate` date DEFAULT NULL,
  `salestime` time DEFAULT NULL,
  `kind` int(11) NOT NULL DEFAULT 0,
  `salestype` smallint(6) NOT NULL DEFAULT 0 COMMENT '0=CASH, 1=CASH ON DELIVERY, 2=CREDIT',
  `earlydiscdays` int(11) NOT NULL DEFAULT 0,
  `earlydiscvalue` double NOT NULL DEFAULT 0,
  `duedays` int(11) NOT NULL DEFAULT 0,
  `customerid` char(30) NOT NULL DEFAULT '',
  `customername` varchar(100) NOT NULL DEFAULT '',
  `customeraddress` varchar(200) NOT NULL DEFAULT '',
  `customercreditlimit` double NOT NULL DEFAULT 0,
  `customercreditlimittype` tinyint(4) NOT NULL DEFAULT 0,
  `customertaxid` varchar(50) NOT NULL DEFAULT '',
  `customertaxable` smallint(6) NOT NULL DEFAULT 0,
  `customerbalance` double NOT NULL DEFAULT 0,
  `pricelevel` smallint(6) NOT NULL DEFAULT 1,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `salesmanid` char(30) NOT NULL DEFAULT '',
  `billto` char(30) NOT NULL DEFAULT '',
  `billtoname` varchar(100) NOT NULL DEFAULT '',
  `billtocreditlimit` double NOT NULL DEFAULT 0,
  `salesmanname` varchar(100) NOT NULL DEFAULT '',
  `shipto` text DEFAULT NULL,
  `salespercentdisc` double NOT NULL DEFAULT 0,
  `returnpercentdisc` double NOT NULL DEFAULT 0,
  `salesvaluedisc` double NOT NULL DEFAULT 0,
  `returnvaluedisc` double NOT NULL DEFAULT 0,
  `pointbalance` double NOT NULL DEFAULT 0,
  `salespoint` double NOT NULL DEFAULT 0,
  `returnpoint` double NOT NULL DEFAULT 0,
  `currpointbalance` double NOT NULL DEFAULT 0,
  `salestotal` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `memoedit` text DEFAULT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `taxprinted` smallint(6) NOT NULL DEFAULT 0,
  `shipment` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `dateaccepted` datetime DEFAULT NULL,
  `accepted` smallint(6) NOT NULL DEFAULT 1,
  `paidinfull` smallint(6) NOT NULL DEFAULT 0,
  `paidinfulldate` date DEFAULT NULL,
  `paidinfullref` char(30) NOT NULL DEFAULT '',
  `taxprint` tinyint(1) NOT NULL DEFAULT 0,
  `taxprintid` varchar(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `posted` smallint(6) NOT NULL DEFAULT 1,
  `packed` int(11) NOT NULL DEFAULT 0,
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesorderdetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `usesn` int(11) NOT NULL DEFAULT 0,
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `salesqty` double NOT NULL DEFAULT 0,
  `returnqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `price` double NOT NULL DEFAULT 0,
  `grossamount` double NOT NULL DEFAULT 0,
  `taxid` tinyint(4) NOT NULL DEFAULT 0,
  `salestax` double NOT NULL DEFAULT 0,
  `returntax` double NOT NULL DEFAULT 0,
  `percentdisc` varchar(50) NOT NULL DEFAULT '',
  `discformula` varchar(50) NOT NULL DEFAULT '',
  `valuedisc` double NOT NULL DEFAULT 0,
  `netamount` double NOT NULL DEFAULT 0,
  `cogs` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `servicedoerid` char(30) NOT NULL DEFAULT '',
  `servicedoername` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesorderexpensesdetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `kind` int(11) NOT NULL DEFAULT 0,
  `salesexpid` int(10) UNSIGNED NOT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesorderextratax` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `salesqty` double NOT NULL DEFAULT 0,
  `returnqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `grossamount` double NOT NULL DEFAULT 0,
  `taxid` tinyint(4) NOT NULL DEFAULT 0,
  `salestax` double NOT NULL DEFAULT 0,
  `returntax` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesorderpayments` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `discountpercent` double NOT NULL DEFAULT 0,
  `discountvalue` double NOT NULL DEFAULT 0,
  `expensepercent` double NOT NULL DEFAULT 0,
  `expensevalue` double NOT NULL DEFAULT 0,
  `duedate` date DEFAULT NULL,
  `accepted` smallint(6) NOT NULL DEFAULT 0,
  `kind` smallint(6) NOT NULL DEFAULT 0,
  `paymenttype` int(10) UNSIGNED NOT NULL,
  `refpayment` varchar(30) NOT NULL,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesorderpoint` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `customer` char(30) NOT NULL DEFAULT '',
  `qtyin` double NOT NULL DEFAULT 0,
  `qtyout` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salesorderrewarddetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `salesqty` double NOT NULL DEFAULT 0,
  `returnqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `price` double NOT NULL DEFAULT 0,
  `grossamount` double NOT NULL DEFAULT 0,
  `taxid` tinyint(4) NOT NULL DEFAULT 0,
  `salestax` double NOT NULL DEFAULT 0,
  `returntax` double NOT NULL DEFAULT 0,
  `netamount` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salespayments` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `discountpercent` double NOT NULL DEFAULT 0,
  `discountvalue` double NOT NULL DEFAULT 0,
  `expensepercent` double NOT NULL DEFAULT 0,
  `expensevalue` double NOT NULL DEFAULT 0,
  `duedate` date DEFAULT NULL,
  `accepted` smallint(6) NOT NULL DEFAULT 0,
  `kind` smallint(6) NOT NULL DEFAULT 0,
  `paymenttype` int(10) UNSIGNED NOT NULL,
  `pointtotal` double NOT NULL DEFAULT 0,
  `pointpayment` double NOT NULL DEFAULT 0,
  `refpayment` varchar(30) NOT NULL,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salespoint` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `customer` char(30) NOT NULL DEFAULT '',
  `qtyin` double NOT NULL DEFAULT 0,
  `qtyout` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `salespointrewardrules` (
  `id` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `description` varchar(100) NOT NULL DEFAULT '',
  `displayname` varchar(20) NOT NULL DEFAULT '',
  `formula` text DEFAULT NULL COMMENT 'TO GET POINT',
  `category` int(11) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `salespointrewardrules` (`id`, `description`, `displayname`, `formula`, `category`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Point Plus', 'Poin 1', 'detail.salesqty*detail.unitqty>=24 ? 1 : 0', 0, 'admin', '', '2024-05-02 18:46:32'),
(2, 'Point Transaksi', 'Poin 2', '(sales.salestotal - (sales.salestotal  % 10000)) / 10000', 1, 'admin', '', '2024-05-02 02:52:10');

CREATE TABLE `salesproductrewardrules` (
  `id` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `description` varchar(100) NOT NULL DEFAULT '',
  `displayname` varchar(20) DEFAULT '',
  `formula` text DEFAULT NULL COMMENT 'TO GET PRODUCT REWARD QUANTITY',
  `category` int(11) NOT NULL DEFAULT 0,
  `productid` char(30) NOT NULL DEFAULT '',
  `unit` char(10) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `salesproductrewardrules` (`id`, `description`, `displayname`, `formula`, `category`, `productid`, `unit`, `departement`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Bonus 1', 'BNS 1', 'detail.salesqty*detail.unitqty>=24 ? 2 : (detail.salesqty*detail.unitqty>=12 ? 1 : 0)', 0, '21002', 'PCS', 'D1102', 'admin', 'admin', '2026-04-16 11:58:16'),
(2, 'Bonus 2', 'BNS 2', 'sales.salestotal>100000 ? 1 : 0', 1, '21002', 'PCS', 'D1101', 'admin', 'admin', '2026-04-16 11:58:09'),
(3, 'Bonus 3', 'BNS UNI', 'product.factory==\'P2\' && salestotal>=10000 ? 1 : 0', 0, '21002', 'PCS', 'D1102', 'admin', 'admin', '2026-04-16 11:58:23');

CREATE TABLE `salesrewarddetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `transdate` datetime DEFAULT NULL,
  `salesid` char(30) NOT NULL DEFAULT '',
  `salesidref` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `productname` varchar(100) NOT NULL DEFAULT '',
  `snproduct` varchar(100) NOT NULL DEFAULT '',
  `expireddate` date DEFAULT NULL,
  `salesqty` double NOT NULL DEFAULT 0,
  `returnqty` double NOT NULL DEFAULT 0,
  `unit` char(10) NOT NULL DEFAULT '',
  `unitqty` double NOT NULL DEFAULT 0,
  `price` double NOT NULL DEFAULT 0,
  `grossamount` double NOT NULL DEFAULT 0,
  `taxid` tinyint(4) NOT NULL DEFAULT 0,
  `salestax` double NOT NULL DEFAULT 0,
  `returntax` double NOT NULL DEFAULT 0,
  `netamount` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `departement` char(10) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolclass` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `description` text NOT NULL,
  `schoollevel` char(50) NOT NULL DEFAULT '',
  `logo` varchar(255) NOT NULL DEFAULT '[]',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoolclass` (`id`, `name`, `description`, `schoollevel`, `logo`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('I', 'Kelas I', '<p>Kelas I</p>', 'SMP', '[]', 'admin', 'admin', '2024-12-04 17:04:21'),
('II', 'Kelas II', '<p>Kelas II</p>', 'SMP', '[]', 'admin', 'admin', '2024-12-04 16:59:57'),
('III', 'Kelas III', '<p>Kelas III</p>', 'SMP', '[]', 'admin', 'admin', '2024-12-04 17:04:11');

CREATE TABLE `schoolexam` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `shortname` varchar(50) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoolexam` (`id`, `name`, `shortname`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('UAS', 'Ujian Akhir Semester', 'UAS', 'admin', '', '2024-12-07 19:22:32'),
('UTS', 'Ujian Tengah Semester', 'UTS', 'admin', '', '2024-12-07 19:22:35');

CREATE TABLE `schoolextrascore` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(100) DEFAULT '',
  `description` text DEFAULT NULL,
  `extrascoregroup` char(50) DEFAULT NULL,
  `scoringtype` bigint(20) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolextrascoregroup` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(50) DEFAULT '',
  `description` text DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoollesson` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(100) DEFAULT '',
  `description` text DEFAULT NULL,
  `lessongroup` char(50) DEFAULT '',
  `scoringtype` bigint(20) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoollesson` (`id`, `name`, `description`, `lessongroup`, `scoringtype`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('A1', 'Pendidikan Agama dan Budi Pekerti', '', 'A', 1, 'admin', 'admin', '2024-12-07 19:21:38'),
('A2', 'Pendidikan Pancasila dan Kewarganegaraan', '', 'A', 1, 'admin', '', '2024-12-07 19:21:45'),
('A3', 'Bahasa Indonesia', '', 'A', 1, 'admin', '', '2024-12-07 19:22:01'),
('A4', 'Matematika', '', 'A', 1, 'admin', '', '2024-12-07 19:22:04'),
('A5', 'Ilmu Pengetahuan Alam', '', 'A', 1, 'admin', '', '2024-12-07 19:22:06'),
('A6', 'Ilmu Pengetahuan Sosial', '', 'A', 1, 'admin', '', '2024-12-07 19:22:09'),
('A7', 'Bahasa Inggris', '', 'A', 1, 'admin', '', '2024-12-07 19:22:11'),
('B1', 'Seni Budaya', '', 'B', 1, 'admin', '', '2024-12-07 19:20:29'),
('B2', 'Pendidikan Jasmani, Olahraga dan Kesehatan', '', 'B', 1, 'admin', '', '2024-12-07 19:20:43'),
('B3', 'Prakarya', '', 'B', 1, 'admin', '', '2024-12-07 19:20:53'),
('B4', 'Bahasa Daerah', '', 'B', 1, 'admin', 'admin', '2024-12-07 19:21:28'),
('B5', 'Informatika', '', 'B', 1, 'admin', '', '2024-12-07 19:21:16');

CREATE TABLE `schoollessonclass` (
  `id` bigint(20) NOT NULL,
  `schoolsubclass` char(50) NOT NULL DEFAULT '',
  `schoollesson` char(50) NOT NULL DEFAULT '',
  `schoollessonname` varchar(100) NOT NULL DEFAULT '0',
  `schoolteacher` char(50) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoollessonclass` (`id`, `schoolsubclass`, `schoollesson`, `schoollessonname`, `schoolteacher`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(5, 'I-A', 'A1', 'Pendidikan Agama dan Budi Pekerti', 'G001', 'admin', '', '2024-12-07 20:14:29'),
(6, 'I-A', 'A2', 'Pendidikan Pancasila dan Kewarganegaraan', 'G001', 'admin', '', '2024-12-07 20:16:47'),
(7, 'I-A', 'A3', 'Bahasa Indonesia', 'G001', 'admin', '', '2024-12-07 20:16:52');

CREATE TABLE `schoollessongroup` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(50) DEFAULT '',
  `description` text DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoollessongroup` (`id`, `name`, `description`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('A', 'Kelompok A', '<p>Tentang mata pelajaran kelompok A</p>', 'admin', 'admin', '2024-12-07 19:19:47'),
('B', 'Kelompok B', '<p>Tentang mata pelajaran kelompok B</p>', 'admin', 'admin', '2024-12-04 17:39:13');

CREATE TABLE `schoollessonteacher` (
  `id` bigint(20) NOT NULL,
  `schoollesson` char(50) NOT NULL DEFAULT '',
  `schoollessonname` varchar(100) NOT NULL DEFAULT '',
  `schoolsubclass` char(50) NOT NULL DEFAULT '',
  `schoolteacher` char(50) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoollessonteacher` (`id`, `schoollesson`, `schoollessonname`, `schoolsubclass`, `schoolteacher`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(3, 'A1', 'Pendidikan Agama dan Budi Pekerti', 'I-A', 'G001', 'admin', '', '2024-12-07 19:25:42'),
(4, 'B4', 'Bahasa Daerah', 'I-A', 'G001', 'admin', '', '2024-12-07 19:25:44'),
(5, 'B4', 'Bahasa Daerah', 'I-A', 'G001', 'admin', '', '2024-12-07 19:27:10'),
(6, 'A3', 'Bahasa Indonesia', 'I-A', 'G001', 'admin', '', '2024-12-07 19:27:18'),
(7, 'A5', 'Ilmu Pengetahuan Alam', 'I-A', 'G002', 'admin', '', '2024-12-07 19:27:30'),
(8, 'B5', 'Informatika', 'I-A', 'G002', 'admin', '', '2024-12-07 19:27:36'),
(9, 'A4', 'Matematika', 'I-A', 'G002', 'admin', '', '2024-12-07 19:27:41'),
(10, 'B3', 'Prakarya', 'I-A', 'G002', 'admin', '', '2024-12-07 19:27:46'),
(11, 'A7', 'Bahasa Inggris', 'I-A', 'G002', 'admin', '', '2024-12-07 19:27:55'),
(12, 'A6', 'Ilmu Pengetahuan Sosial', 'I-A', 'G003', 'admin', '', '2024-12-07 19:28:05'),
(13, 'B1', 'Seni Budaya', 'I-A', 'G003', 'admin', '', '2024-12-07 19:28:14'),
(14, 'B1', 'Seni Budaya', 'I-A', 'G004', 'admin', '', '2024-12-07 19:39:19'),
(15, 'B3', 'Prakarya', 'I-A', 'G004', 'admin', '', '2024-12-07 19:39:26');

CREATE TABLE `schoollevel` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `description` text NOT NULL,
  `logo` varchar(255) NOT NULL DEFAULT '[]',
  `headmaster` char(50) NOT NULL DEFAULT '',
  `country` char(3) NOT NULL DEFAULT '',
  `provincename` varchar(50) NOT NULL DEFAULT '',
  `cityname` varchar(50) NOT NULL DEFAULT '',
  `subdistrictname` varchar(50) NOT NULL DEFAULT '',
  `address` varchar(200) NOT NULL DEFAULT '',
  `postcode` varchar(10) NOT NULL DEFAULT '',
  `telephone` varchar(45) NOT NULL DEFAULT '',
  `email` varchar(100) NOT NULL DEFAULT '',
  `website` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoollevel` (`id`, `name`, `description`, `logo`, `headmaster`, `country`, `provincename`, `cityname`, `subdistrictname`, `address`, `postcode`, `telephone`, `email`, `website`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('SMP', 'SMP', '<p>Tentang sekolah ini</p>', '[]', 'G001', 'IDN', 'Lampung', 'Bandar Lampung', '', '', '', '', '', '', 'admin', '', '2024-12-04 16:57:34');

CREATE TABLE `schoolpayment` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(100) DEFAULT '',
  `paymentgroup` char(50) DEFAULT '',
  `receivableacc` char(30) NOT NULL DEFAULT '',
  `unearnedrevenueacc` char(30) NOT NULL DEFAULT '',
  `revenueacc` char(30) NOT NULL DEFAULT '',
  `paymentdiscacc` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolpaymentgroup` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(100) DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolpaymentpackage` (
  `id` bigint(20) NOT NULL,
  `schoolsubclass` text NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolpaymentpackagedetail` (
  `id` bigint(20) NOT NULL,
  `schoolpaymentpackage` bigint(20) NOT NULL DEFAULT 0,
  `schoolpayment` char(50) NOT NULL DEFAULT '',
  `schoolpaymentname` varchar(100) NOT NULL DEFAULT '',
  `required` int(11) NOT NULL DEFAULT 0,
  `total` double NOT NULL DEFAULT 0,
  `instalment` double NOT NULL DEFAULT 0,
  `weight` int(11) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolperiod` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `periodbegin` date DEFAULT NULL,
  `periodend` date DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoolperiod` (`id`, `name`, `periodbegin`, `periodend`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('2024-Semester-1', 'Semester 1 Tahun Ajaran 2024', '2024-09-18', '2024-12-05', 'admin', '', '2024-12-04 17:24:08');

CREATE TABLE `schoolscoringtype` (
  `id` bigint(20) NOT NULL,
  `name` varchar(50) DEFAULT '',
  `description` text DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoolscoringtype` (`id`, `name`, `description`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Formatif', '', 'admin', 'admin', '2024-12-04 18:08:43');

CREATE TABLE `schoolscoringtyperange` (
  `id` bigint(20) NOT NULL,
  `schoolscoringtype` bigint(20) NOT NULL DEFAULT 0,
  `minvalue` float DEFAULT 1,
  `maxvalue` float DEFAULT 1,
  `shortdescription` varchar(100) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoolscoringtyperange` (`id`, `schoolscoringtype`, `minvalue`, `maxvalue`, `shortdescription`, `description`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 1, 0, 59, 'E', '', 'admin', '', '2024-12-04 18:06:26'),
(2, 1, 60, 69, 'D', '', 'admin', '', '2024-12-04 18:07:53'),
(3, 1, 70, 79, 'C', '', 'admin', '', '2024-12-04 18:08:10'),
(4, 1, 80, 89, 'B', 'Ananda berhasil dan mencapai nilai tinggi, pertahakan terus ya', 'admin', '', '2024-12-04 19:43:00'),
(5, 1, 90, 100, 'A', 'Ananda berhasil dan mencapai nilai tertinggi, pertahakan terus', 'admin', '', '2024-12-04 19:42:47');

CREATE TABLE `schoolstudent` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(200) NOT NULL DEFAULT '',
  `schoolclass` char(50) NOT NULL DEFAULT '',
  `schoolsubclass` char(50) NOT NULL DEFAULT '',
  `country` char(3) NOT NULL DEFAULT '',
  `provincename` varchar(50) NOT NULL DEFAULT '',
  `cityname` varchar(50) NOT NULL DEFAULT '',
  `subdistrictname` varchar(50) NOT NULL DEFAULT '',
  `address` varchar(200) NOT NULL DEFAULT '',
  `postcode` varchar(10) NOT NULL DEFAULT '',
  `telephone` varchar(45) NOT NULL DEFAULT '',
  `email` varchar(100) NOT NULL DEFAULT '',
  `website` varchar(100) NOT NULL DEFAULT '',
  `photo` varchar(255) DEFAULT '[]',
  `motto` varchar(200) NOT NULL DEFAULT '',
  `religion` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `birthdate` date DEFAULT NULL,
  `sex` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=MALE, 1=FEMALE',
  `registerdate` datetime DEFAULT NULL,
  `activeuntil` datetime DEFAULT '2099-12-31 00:00:00',
  `status` bigint(20) NOT NULL DEFAULT 1,
  `dorm` bigint(20) NOT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoolstudent` (`id`, `name`, `schoolclass`, `schoolsubclass`, `country`, `provincename`, `cityname`, `subdistrictname`, `address`, `postcode`, `telephone`, `email`, `website`, `photo`, `motto`, `religion`, `birthdate`, `sex`, `registerdate`, `activeuntil`, `status`, `dorm`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('S0001', 'Siswa 1', 'I', 'I-A', 'IDN', '', '', '', '', '', '', '', '', '[]', '', 1, '2024-12-05', 0, '2020-01-14 00:00:00', '2099-12-31 00:00:00', 1, 1, 'admin', 'admin', '2024-12-17 05:52:24'),
('S0002', 'Siswa 2', 'I', 'I-A', 'IDN', '', '', '', '', '', '', '', '', '[]', '', 1, '2020-01-15', 1, '2020-06-13 00:00:00', '2024-12-13 00:00:00', 1, 1, 'admin', 'admin', '2024-12-17 05:52:24'),
('S0003', 'Siswa 3', 'I', 'I-A', 'IDN', '', '', '', '', '', '', '', '', '[]', '', 1, '2020-01-15', 0, '2020-06-13 00:00:00', '2024-12-13 00:00:00', 1, 1, 'admin', 'admin', '2024-12-17 05:52:24');

CREATE TABLE `schoolstudentdorm` (
  `id` bigint(20) NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `dormheadmaster` char(50) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoolstudentdorm` (`id`, `name`, `dormheadmaster`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Non Asrama', 'G001', 'admin', '', '2024-12-26 19:46:46');

CREATE TABLE `schoolstudentpayment` (
  `id` bigint(20) NOT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `jtid` varchar(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `schoolsubclass` char(50) NOT NULL DEFAULT '',
  `schoolstudent` char(50) NOT NULL DEFAULT '',
  `schoolstudentname` varchar(100) NOT NULL DEFAULT '',
  `paymenttype` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `kind` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
  `totalpayment` double NOT NULL DEFAULT 0,
  `accepted` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `memo` varchar(255) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolstudentpaymentdetail` (
  `id` bigint(20) NOT NULL,
  `parent` bigint(20) NOT NULL DEFAULT 0,
  `schoolstudent` char(50) NOT NULL DEFAULT '',
  `schoolsubclass` char(50) NOT NULL DEFAULT '',
  `schoolpayment` char(50) NOT NULL DEFAULT '',
  `schoolpaymentname` varchar(100) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `payment` double NOT NULL DEFAULT 0,
  `discount` double NOT NULL DEFAULT 0,
  `subtotal` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolstudentpaymentschedule` (
  `id` bigint(20) NOT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `jtid` varchar(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `schoolsubclass` char(50) NOT NULL DEFAULT '',
  `schoolstudent` char(50) NOT NULL DEFAULT '',
  `schoolstudentname` varchar(100) NOT NULL DEFAULT '',
  `schoolpaymentpackage` bigint(20) NOT NULL DEFAULT 0,
  `schoolpaymentpackagename` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolstudentscore` (
  `id` bigint(20) NOT NULL,
  `schoolteacher` char(50) NOT NULL DEFAULT '',
  `schoolsubclass` char(50) NOT NULL DEFAULT '',
  `schoolperiod` char(50) NOT NULL DEFAULT '',
  `schoollesson` char(50) NOT NULL DEFAULT '',
  `schoolexam` char(50) NOT NULL DEFAULT '',
  `scoringtype` bigint(20) NOT NULL DEFAULT 0,
  `description` char(255) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolstudentscoredetail` (
  `id` bigint(20) NOT NULL,
  `schoolstudentscore` bigint(20) NOT NULL DEFAULT 0,
  `schoolteacher` char(50) NOT NULL DEFAULT '',
  `schoolsubclass` char(50) NOT NULL DEFAULT '',
  `schoolperiod` char(50) NOT NULL DEFAULT '',
  `schoollesson` char(50) NOT NULL DEFAULT '',
  `scoringtype` bigint(20) NOT NULL DEFAULT 0,
  `schoolexam` char(50) NOT NULL DEFAULT '',
  `schoolstudent` char(50) NOT NULL DEFAULT '',
  `schoolstudentname` varchar(200) NOT NULL DEFAULT '',
  `lessonscore` float NOT NULL DEFAULT 0,
  `description` text NOT NULL,
  `shortdescription` varchar(100) NOT NULL DEFAULT '0',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolstudentsextrascore` (
  `id` bigint(20) NOT NULL,
  `schoolteacher` char(50) NOT NULL DEFAULT '',
  `schoolsubclass` char(50) NOT NULL DEFAULT '',
  `schoolperiod` char(50) NOT NULL DEFAULT '',
  `schoolextrascoregroup` char(50) NOT NULL DEFAULT '',
  `schoolextrascore` char(50) NOT NULL DEFAULT '',
  `schoolexam` char(50) NOT NULL DEFAULT '',
  `scoringtype` bigint(20) NOT NULL DEFAULT 0,
  `description` char(255) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolstudentsextrascoredetail` (
  `id` bigint(20) NOT NULL,
  `schoolstudentsextrascore` bigint(20) NOT NULL DEFAULT 0,
  `schoolteacher` char(50) NOT NULL DEFAULT '',
  `schoolsubclass` char(50) NOT NULL DEFAULT '',
  `schoolperiod` char(50) NOT NULL DEFAULT '',
  `schoolextrascore` char(50) NOT NULL DEFAULT '',
  `scoringtype` bigint(20) NOT NULL DEFAULT 0,
  `schoolexam` char(50) NOT NULL DEFAULT '',
  `schoolstudent` char(50) NOT NULL DEFAULT '',
  `schoolstudentname` varchar(200) NOT NULL DEFAULT '',
  `lessonscore` float NOT NULL DEFAULT 0,
  `description` text NOT NULL,
  `shortdescription` varchar(100) NOT NULL DEFAULT '0',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolstudentstatus` (
  `id` bigint(20) NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoolstudentstatus` (`id`, `name`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Aktif', 'admin', '', '2024-12-09 17:55:41'),
(2, 'Lulus', 'admin', '', '2024-12-09 17:55:50'),
(3, 'Drop Out', 'admin', '', '2024-12-09 17:55:56'),
(4, 'Pindah Sekolah', 'admin', '', '2024-12-09 17:56:04');

CREATE TABLE `schoolstupaymentscheduledetail` (
  `id` bigint(20) NOT NULL,
  `parent` bigint(20) NOT NULL DEFAULT 0,
  `schoolstudent` char(50) NOT NULL DEFAULT '',
  `schoolsubclass` char(50) NOT NULL DEFAULT '',
  `schoolpayment` char(50) NOT NULL DEFAULT '',
  `schoolpaymentname` varchar(100) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `required` int(11) NOT NULL DEFAULT 0,
  `total` double NOT NULL DEFAULT 0,
  `instalment` double NOT NULL DEFAULT 0,
  `weight` int(11) NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `schoolsubclass` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `description` text NOT NULL,
  `schoolclass` char(50) NOT NULL DEFAULT '',
  `homeroomteacher` char(50) NOT NULL DEFAULT '',
  `headofclass` varchar(200) NOT NULL DEFAULT '',
  `logo` varchar(255) NOT NULL DEFAULT '[]',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoolsubclass` (`id`, `name`, `description`, `schoolclass`, `homeroomteacher`, `headofclass`, `logo`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('I-A', 'Kelas I-A', '<p>Tentang kelas I A</p>', 'I', 'G001', '', '[]', 'admin', 'admin', '2024-12-07 20:21:26'),
('I-B', 'Kelas I-B', '', 'I', 'G001', '', '[]', 'admin', '', '2024-12-04 17:20:33'),
('II', 'Kelas II', '', 'II', 'G001', '', '[]', 'admin', '', '2024-12-04 17:20:56'),
('III', 'Kelas III', '', 'III', 'G001', '', '[]', 'admin', '', '2024-12-04 17:21:13');

CREATE TABLE `schoolteacher` (
  `id` char(50) NOT NULL DEFAULT '',
  `name` varchar(200) NOT NULL DEFAULT '',
  `country` char(3) NOT NULL DEFAULT '',
  `provincename` varchar(50) NOT NULL DEFAULT '',
  `cityname` varchar(50) NOT NULL DEFAULT '',
  `subdistrictname` varchar(50) NOT NULL DEFAULT '',
  `address` varchar(200) NOT NULL DEFAULT '',
  `postcode` varchar(10) NOT NULL DEFAULT '',
  `telephone` varchar(45) NOT NULL DEFAULT '',
  `email` varchar(100) NOT NULL DEFAULT '',
  `website` varchar(100) NOT NULL DEFAULT '',
  `photo` varchar(255) DEFAULT '[]',
  `motto` varchar(200) NOT NULL DEFAULT '',
  `signature` varchar(255) NOT NULL DEFAULT '[]',
  `isactive` int(11) NOT NULL DEFAULT 1,
  `userid` char(16) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `religion` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `birthdate` date DEFAULT NULL,
  `sex` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=MALE, 1=FEMALE',
  `registerdate` datetime DEFAULT NULL,
  `activeuntil` datetime DEFAULT '2099-12-31 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `schoolteacher` (`id`, `name`, `country`, `provincename`, `cityname`, `subdistrictname`, `address`, `postcode`, `telephone`, `email`, `website`, `photo`, `motto`, `signature`, `isactive`, `userid`, `usercreate`, `useredit`, `updatetimestamp`, `religion`, `birthdate`, `sex`, `registerdate`, `activeuntil`) VALUES
('G001', 'Guru A', 'IDN', '', '', '', '', '', '', '', '', '[]', '', '[]', 1, '', '', 'admin', '2024-12-07 19:23:14', 1, '2024-12-16', 0, '2024-12-10 00:00:00', '2099-12-31 00:00:00'),
('G002', 'Guru B', 'IDN', '', '', '', '', '', '', '', '', '[]', '', '[]', 1, '', '', 'admin', '2024-12-07 19:47:53', 1, '2024-12-16', 1, '2024-12-10 00:00:00', '2099-12-31 00:00:00'),
('G003', 'Guru C', 'IDN', '', '', '', '', '', '', '', '', '[]', '', '[]', 1, '', '', 'admin', '2024-12-07 19:23:18', 1, '2024-12-16', 0, '2024-12-10 00:00:00', '2099-12-31 00:00:00'),
('G004', 'Guru D', 'IDN', '', '', '', '', '', '', '', '', '[]', '', '[]', 1, '', '', 'admin', '2024-12-07 19:26:47', 1, '2024-12-16', 1, '2024-12-10 00:00:00', '2099-12-31 00:00:00'),
('G005', 'Guru E', 'IDN', '', '', '', '', '', '', '', '', '[]', '', '[]', 1, '', '', 'admin', '2024-12-07 19:27:03', 1, '2024-12-16', 0, '2024-12-10 00:00:00', '2099-12-31 00:00:00');

CREATE TABLE `servicedoer` (
  `id` char(30) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `servicedoergroup` char(30) NOT NULL DEFAULT '',
  `address` varchar(200) NOT NULL DEFAULT '',
  `telephone` varchar(50) NOT NULL DEFAULT '',
  `faximile` varchar(50) NOT NULL DEFAULT '',
  `mobilephone` varchar(50) NOT NULL DEFAULT '',
  `category` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=PERSONAL, 1=COMPANY',
  `religion` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `birthdate` datetime DEFAULT NULL,
  `sex` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=MALE, 1=FEMALE',
  `email` varchar(100) NOT NULL DEFAULT '',
  `country` char(3) NOT NULL DEFAULT '',
  `registerdate` date DEFAULT NULL,
  `activeuntil` date NOT NULL DEFAULT '2999-12-31',
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `commisionrules` text DEFAULT NULL,
  `payablecommacc` char(30) NOT NULL DEFAULT '',
  `expensecommacc` char(30) NOT NULL DEFAULT '',
  `contactperson` varchar(100) NOT NULL DEFAULT '',
  `website` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `image` varchar(255) DEFAULT '[]'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `servicedoer` (`id`, `name`, `servicedoergroup`, `address`, `telephone`, `faximile`, `mobilephone`, `category`, `religion`, `birthdate`, `sex`, `email`, `country`, `registerdate`, `activeuntil`, `isactive`, `commisionrules`, `payablecommacc`, `expensecommacc`, `contactperson`, `website`, `usercreate`, `useredit`, `updatetimestamp`, `image`) VALUES
('SD001', 'TEKNISI I', 'T11', '', '', '', '', 0, 1, NULL, 0, '', 'IDN', '2012-06-10', '2099-12-31', 1, '[]', '105.003', '604.999', '', '', 'admin', '', '2025-12-03 20:58:07', '[]'),
('SD002', 'TEKNISI II', 'T11', '', '', '', '', 0, 1, NULL, 0, '', 'IDN', '2012-06-10', '2099-12-31', 1, '[]', '105.003', '604.999', '', '', 'admin', '', '2025-12-03 20:58:07', '[]');

CREATE TABLE `servicedoercommperiod` (
  `id` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `fromdate` date DEFAULT NULL,
  `fromtime` time DEFAULT NULL,
  `todate` date DEFAULT NULL,
  `totime` time DEFAULT NULL,
  `minsalesretur` tinyint(1) NOT NULL DEFAULT 1,
  `accumrules` tinyint(1) NOT NULL DEFAULT 0,
  `minproductdisc` tinyint(1) NOT NULL DEFAULT 1,
  `posted` tinyint(1) NOT NULL DEFAULT 0,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `division` varchar(10) NOT NULL DEFAULT '',
  `formula` text DEFAULT NULL,
  `refid` char(30) NOT NULL DEFAULT '',
  `postdate` date DEFAULT NULL,
  `posttime` time DEFAULT NULL,
  `salaryid` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `groups` varchar(100) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `servicedoercommrules` (
  `id` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `description` varchar(100) NOT NULL DEFAULT '',
  `displayname` varchar(20) NOT NULL DEFAULT '',
  `category` int(11) NOT NULL DEFAULT 0,
  `formula` text DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `servicedoercommrules` (`id`, `description`, `displayname`, `category`, `formula`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'fee 1', 'fee1', 0, 'v.SalesReal*0.1', 'admin', '', '2024-02-05 14:57:08'),
(2, 'fee 2', 'fee2', 0, 'v.SalesReal*0.2', 'admin', '', '2024-02-05 14:57:08');

CREATE TABLE `servicedoercommvar` (
  `varname` char(10) NOT NULL DEFAULT '',
  `varvalue` double NOT NULL DEFAULT 0,
  `description` varchar(50) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `servicedoercommvarrecords` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `periodid` bigint(20) UNSIGNED NOT NULL,
  `varname` char(10) NOT NULL DEFAULT '',
  `varvalue` double NOT NULL DEFAULT 0,
  `description` varchar(50) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `servicedoerdetail` (
  `groupid` char(30) NOT NULL DEFAULT '',
  `servicedoerid` char(30) NOT NULL DEFAULT '',
  `percent` double NOT NULL DEFAULT 0,
  `memo` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `servicedoergroup` (
  `id` char(30) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `commisionrules` text DEFAULT NULL,
  `payablecommacc` char(30) NOT NULL DEFAULT '',
  `expensecommacc` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `servicedoergroup` (`id`, `description`, `commisionrules`, `payablecommacc`, `expensecommacc`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('T11', 'DIVISI I', '[]', '105.003', '604.999', 'admin', '', '2025-12-03 20:58:07');

CREATE TABLE `servicedoerrecorddetail` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `periodid` bigint(20) UNSIGNED NOT NULL,
  `servicedoerid` char(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `salestargetqty` double NOT NULL DEFAULT 0,
  `salestargetvalue` double NOT NULL DEFAULT 0,
  `salesrealqty` double NOT NULL DEFAULT 0,
  `salesrealvalue` double NOT NULL DEFAULT 0,
  `percentqty` double NOT NULL DEFAULT 0,
  `percentvalue` double NOT NULL DEFAULT 0,
  `profit` double NOT NULL DEFAULT 0,
  `commission` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `servicedoerrecords` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `periodid` bigint(20) UNSIGNED NOT NULL,
  `servicedoerid` char(30) NOT NULL DEFAULT '',
  `salestarget` double NOT NULL DEFAULT 0,
  `salesreal` double NOT NULL DEFAULT 0,
  `percent` double NOT NULL DEFAULT 0,
  `profit` double NOT NULL DEFAULT 0,
  `commission` double NOT NULL DEFAULT 0,
  `productcommission` double NOT NULL DEFAULT 0,
  `totalcommission` double NOT NULL DEFAULT 0,
  `commissionpaid` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `shipments` (
  `id` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `name` varchar(50) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `shipments` (`id`, `name`, `description`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Umum', '', 'admin', '', '2024-11-17 02:19:54'),
(2, 'TIKI', '', 'admin', '', '2024-11-17 02:18:57'),
(3, 'KILAT POS', '', 'admin', '', '2024-11-17 02:18:55'),
(22, 'J&T', '', 'admin', '', '2026-04-11 07:04:45');

CREATE TABLE `slidedata` (
  `id` bigint(20) NOT NULL,
  `slideid` int(11) NOT NULL DEFAULT 0,
  `type` int(11) NOT NULL DEFAULT 1,
  `image` text DEFAULT NULL,
  `video` varchar(100) NOT NULL DEFAULT '',
  `backgroundclass` varchar(50) NOT NULL DEFAULT '',
  `animation` text DEFAULT NULL,
  `weight` int(11) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `slidedata` (`id`, `slideid`, `type`, `image`, `video`, `backgroundclass`, `animation`, `weight`) VALUES
(1, 1, 1, '[{\"img\":\"\\/api\\/assets\\/slidedata\\/17493440710349.webp\",\"caption\":\"\",\"subtitle\":\"\"}]', '', '', '{\"effectin\":\"random\",\"effectout\":\"random\",\"effectexist\":\"rubberBand\",\"infinite\":false}', 1),
(2, 1, 1, '[{\"img\":\"\\/api\\/assets\\/slidedata\\/17493441451288.webp\",\"caption\":\"\",\"subtitle\":\"\"}]', '', '', '{\"effectin\":\"random\",\"effectout\":\"random\",\"effectexist\":\"rubberBand\",\"infinite\":false}', 1);

CREATE TABLE `slideelements` (
  `id` bigint(20) NOT NULL,
  `type` int(11) NOT NULL DEFAULT 1,
  `html` text DEFAULT NULL,
  `image` text DEFAULT NULL,
  `animation` text DEFAULT NULL,
  `position` int(11) NOT NULL DEFAULT 1,
  `slidedataid` bigint(20) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `slideelements` (`id`, `type`, `html`, `image`, `animation`, `position`, `slidedataid`) VALUES
(1, 1, '<h2><span class=\"__se__t-shadow\" style=\"color: rgb(250, 224, 212)\">Promo Akhir Tahun</span></h2>', '[]', '{\"effectin\":\"random\",\"effectout\":\"random\",\"effectexist\":\"shakeX\",\"infinite\":true}', 1, 2);

CREATE TABLE `supplier` (
  `id` char(30) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `suppliergroup` char(30) NOT NULL DEFAULT '',
  `address` varchar(200) NOT NULL DEFAULT '',
  `telephone` varchar(50) NOT NULL DEFAULT '',
  `faximile` varchar(50) NOT NULL DEFAULT '',
  `mobilephone` varchar(50) NOT NULL DEFAULT '',
  `category` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=PERSONAL, 1=COMPANY',
  `contactperson` varchar(100) NOT NULL DEFAULT '',
  `religion` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `birthdate` date DEFAULT NULL,
  `sex` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=MALE, 1=FEMALE',
  `email` varchar(100) NOT NULL DEFAULT '',
  `website` varchar(100) NOT NULL DEFAULT '',
  `country` char(3) NOT NULL DEFAULT '',
  `creditlimit` double NOT NULL DEFAULT 0,
  `registerdate` date DEFAULT NULL,
  `activeuntil` date NOT NULL DEFAULT '2099-12-31',
  `taxid` varchar(50) NOT NULL DEFAULT '',
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `payableacc` char(30) NOT NULL DEFAULT '',
  `accruedpayableacc` char(30) NOT NULL,
  `rewardacc` char(30) NOT NULL,
  `purchasediscacc` char(30) NOT NULL DEFAULT '',
  `gainlosspayableacc` char(30) NOT NULL DEFAULT '',
  `termofpayment` varchar(30) NOT NULL DEFAULT '' COMMENT '2/10, n/30\nCOD (Cash On Delivery)',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `image` varchar(255) DEFAULT '[]'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `supplier` (`id`, `name`, `suppliergroup`, `address`, `telephone`, `faximile`, `mobilephone`, `category`, `contactperson`, `religion`, `birthdate`, `sex`, `email`, `website`, `country`, `creditlimit`, `registerdate`, `activeuntil`, `taxid`, `isactive`, `payableacc`, `accruedpayableacc`, `rewardacc`, `purchasediscacc`, `gainlosspayableacc`, `termofpayment`, `usercreate`, `useredit`, `updatetimestamp`, `image`) VALUES
('Deler TOYOTA', 'Auto 2000 ', 'b2', 'Raden Intan Bandar Lampung', '', '', '', 0, '', 1, '2026-04-11', 0, '', '', 'IDN', 0, '2026-04-11', '2026-04-11', '', 1, '20.002', '20.007', '504.001', '502.003', '701.004', '', 'admin', '', '2026-04-11 06:21:46', '[]'),
('Deller Daihatsu', 'V2026', 'b2', 'Way Halim', '', '', '', 0, '', 1, '2026-04-11', 0, '', '', 'IDN', 0, '2026-04-11', '2026-04-11', '', 1, '20.002', '20.007', '504.001', '502.003', '701.004', '', 'admin', 'admin', '2026-04-11 06:59:53', '[]'),
('S001', 'PEMASOK A', 'a2', 'SURABAYA', '-', '', '', 0, '-', 1, NULL, 0, '', '', 'IDN', 5000000, '2010-07-12', '2099-12-31', '', 1, '20.001', '20.007', '504.001', '502.002', '701.004', '10/30 N/40', 'admin', 'admin', '2026-03-14 17:26:38', '[]'),
('S002', 'PEMASOK B', 'a2', 'BANDUNG', '-', '', '', 1, '-', 1, NULL, 0, '', '', 'IDN', 1000000, '2010-07-12', '2099-12-31', '', 1, '20.001', '20.007', '504.001', '502.002', '701.004', '', 'admin', 'admin', '2026-03-14 17:26:38', '[]'),
('S003', 'PEMASOK C', 'a1', 'LAMPUNG', '', '', '', 0, '-', 1, NULL, 0, '', '', 'IDN', 10000000, '2010-07-12', '2099-12-31', '', 1, '20.001', '20.007', '504.001', '502.002', '701.004', '', 'admin', '', '2026-03-14 17:26:38', '[]'),
('S004', 'PEMASOK D', 'b1', 'JAKARTA', '', '', '', 0, '', 1, NULL, 0, '', '', 'IDN', 0, '2010-07-12', '2099-12-31', '', 1, '20.001', '20.007', '504.001', '502.003', '701.004', '', 'admin', '', '2026-03-14 17:26:38', '[]'),
('S005', 'PEMASOK E', 'b1', 'TANGGERANG', '', '', '', 0, '', 1, NULL, 0, '', '', 'IDN', 0, '2010-07-12', '2099-12-31', '', 1, '20.001', '20.007', '504.001', '502.003', '701.004', '', 'admin', '', '2026-03-14 17:26:38', '[]');

CREATE TABLE `supplierbalance` (
  `transid` bigint(20) UNSIGNED NOT NULL,
  `purchaseid` char(30) NOT NULL DEFAULT '',
  `purchaseidref` char(30) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `supplierid` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `supplierdp` (
  `transid` char(30) NOT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `supplierid` char(30) DEFAULT NULL,
  `suppliername` varchar(100) NOT NULL DEFAULT '',
  `supplieraddress` varchar(200) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `paymenttype` int(10) UNSIGNED DEFAULT NULL,
  `downpaymenttype` int(10) UNSIGNED NOT NULL,
  `kind` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `debit` double NOT NULL DEFAULT 0,
  `credit` double NOT NULL DEFAULT 0,
  `memo` text DEFAULT NULL,
  `printed` smallint(6) NOT NULL DEFAULT 0,
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `suppliergiro` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `transid` char(30) NOT NULL DEFAULT '',
  `transidref` char(30) NOT NULL DEFAULT '',
  `transdate` datetime DEFAULT NULL,
  `supplierid` char(30) NOT NULL DEFAULT '',
  `suppliername` varchar(100) NOT NULL DEFAULT '',
  `supplieraddress` varchar(200) NOT NULL DEFAULT '',
  `accepted` smallint(6) NOT NULL DEFAULT 0,
  `duedate` datetime DEFAULT NULL,
  `accepteddate` datetime DEFAULT NULL,
  `giroin` double NOT NULL DEFAULT 0,
  `giroout` double NOT NULL DEFAULT 0,
  `paymenttype` int(10) UNSIGNED NOT NULL,
  `paymentref` varchar(100) NOT NULL DEFAULT '',
  `currtrans` char(3) NOT NULL DEFAULT '',
  `ratedefault` double NOT NULL DEFAULT 0,
  `rateused` double NOT NULL DEFAULT 0,
  `division` char(10) NOT NULL DEFAULT '',
  `kind` smallint(6) NOT NULL DEFAULT 0,
  `jtid` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `suppliergroup` (
  `id` char(30) NOT NULL DEFAULT '',
  `description` varchar(100) NOT NULL DEFAULT '',
  `payableacc` char(30) NOT NULL DEFAULT '',
  `accruedpayableacc` char(30) NOT NULL DEFAULT '',
  `rewardacc` char(30) NOT NULL DEFAULT '',
  `purchasediscacc` char(30) NOT NULL DEFAULT '',
  `gainlosspayableacc` char(30) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `suppliergroup` (`id`, `description`, `payableacc`, `accruedpayableacc`, `rewardacc`, `purchasediscacc`, `gainlosspayableacc`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('a1', 'Singapura', '20.001', '20.007', '504.001', '502.002', '701.004', 'admin', '', '2026-03-14 17:26:38'),
('a2', 'Malaysia', '20.001', '20.007', '504.001', '502.002', '701.004', 'admin', '', '2026-03-14 17:26:38'),
('b1', 'Jakarta', '20.002', '20.007', '504.001', '502.003', '701.004', 'admin', '', '2026-03-14 17:26:38'),
('b2', 'Lampung', '20.002', '20.007', '504.001', '502.003', '701.004', 'admin', 'admin', '2026-03-14 17:26:38');

CREATE TABLE `tableroles` (
  `id` bigint(20) NOT NULL,
  `tablename` varchar(50) NOT NULL DEFAULT '',
  `roles` varchar(50) NOT NULL DEFAULT '0',
  `allowedit` int(11) NOT NULL DEFAULT 1,
  `allowdelete` int(11) NOT NULL DEFAULT 1,
  `onlyselfdata` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `taxes` (
  `id` tinyint(4) NOT NULL DEFAULT 0,
  `name` varchar(20) NOT NULL DEFAULT '',
  `description` varchar(50) NOT NULL DEFAULT '',
  `percent` double NOT NULL DEFAULT 0,
  `inclusive` smallint(6) NOT NULL DEFAULT 0,
  `tax_code` varchar(10) NOT NULL DEFAULT '01',
  `taxoutacc` char(30) DEFAULT NULL,
  `taxinacc` char(30) DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `taxes` (`id`, `name`, `description`, `percent`, `inclusive`, `tax_code`, `taxoutacc`, `taxinacc`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(0, 'Non Pajak', 'Tidak dikenakan pajak', 0, 0, '01', '22.002', '108.002', 'admin', '', '2026-05-12 16:35:49'),
(1, 'PPN', 'Pajak Pertambahan Nilai', 11, 0, '01', '22.002', '108.002', 'admin', '', '2026-05-12 16:35:49'),
(2, 'PPN (inc)', 'Pajak Pertambahan Nilai Inklusif', 11, 1, '01', '22.002', '108.002', 'admin', '', '2026-05-12 16:35:49'),
(3, 'PPNBM', 'Pajak Pertambahan Nilai Barang Mewah', 40, 0, '01', '22.002', '108.002', 'admin', '', '2026-05-12 16:35:49');

CREATE TABLE `themecolors` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `primarycolor` varchar(7) NOT NULL DEFAULT '#027BE3',
  `secondarycolor` varchar(7) NOT NULL DEFAULT '#26A69A',
  `accentcolor` varchar(7) NOT NULL DEFAULT '#9C27B0',
  `darkcolor` varchar(7) NOT NULL DEFAULT '#1d1d1d',
  `positivecolor` varchar(7) NOT NULL DEFAULT '#21BA45',
  `negativecolor` varchar(7) NOT NULL DEFAULT '#C10015',
  `infocolor` varchar(7) NOT NULL DEFAULT '#31CCEC',
  `warningcolor` varchar(7) NOT NULL DEFAULT '#F2C037',
  `themename` varchar(50) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `themecolors` (`id`, `primarycolor`, `secondarycolor`, `accentcolor`, `darkcolor`, `positivecolor`, `negativecolor`, `infocolor`, `warningcolor`, `themename`) VALUES
(1, '#027BE3', '#26A69A', '#9C27B0', '#1e2b45', '#21BA45', '#C10015', '#31CCEC', '#F2C037', 'Default'),
(2, '#1ab863', '#0f9689', '#94fa05', '#25382c', '#12dbd5', '#9e0b1c', '#1ba7f7', '#f5bb1b', 'Green'),
(3, '#a8a41b', '#c26d1d', '#a9f037', '#544b23', '#21BA45', '#C10015', '#7adcf0', '#d4d63a', 'Brown'),
(4, '#770e87', '#76347d', '#c642eb', '#2b1c2b', '#d39adb', '#f21839', '#f252b0', '#6f2073', 'Purple'),
(5, '#990c24', '#b56219', '#f51414', '#140404', '#8bb518', '#C10015', '#853a47', '#ebb944', 'Dark red'),
(6, '#f7b705', '#a8914f', '#e0c475', '#694e03', '#d1a326', '#f55920', '#9c9e24', '#F2C037', 'Yellow'),
(7, '#6f7478', '#9ba8a7', '#a78cab', '#2b2a2a', '#4e9c60', '#e3293f', '#7f9599', '#c7b689', 'Black'),
(8, '#4d918f', '#1f998d', '#500ead', '#1e2b45', '#21cca1', '#b5071c', '#50bcfa', '#F2C037', 'Tosca'),
(9, '#1ab863', '#a0e381', '#94fa05', '#25382c', '#e0d42b', '#826d70', '#7dff03', '#f5bb1b', 'Green Custom');

CREATE TABLE `trackemployee` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `employeeid` char(30) NOT NULL DEFAULT '',
  `attendanceid` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
  `name` varchar(100) NOT NULL DEFAULT '',
  `checkin` datetime DEFAULT NULL,
  `checkout` datetime DEFAULT NULL,
  `notes` varchar(255) DEFAULT '',
  `workinghour` float DEFAULT NULL,
  `imagecheckin` varchar(255) DEFAULT '[]',
  `imagecheckout` varchar(255) DEFAULT '[]',
  `latitudecheckin` float DEFAULT NULL,
  `longitudecheckin` float DEFAULT NULL,
  `latitudecheckout` float DEFAULT NULL,
  `longitudecheckout` float DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `trexpenses` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `accountid` char(30) NOT NULL DEFAULT '',
  `fromdate` date DEFAULT NULL,
  `todate` date DEFAULT NULL,
  `exptarget` double NOT NULL DEFAULT 0,
  `expreal` double NOT NULL DEFAULT 0,
  `percent` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `trproduct` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `productid` char(30) NOT NULL DEFAULT '',
  `fromdate` date DEFAULT NULL,
  `todate` date DEFAULT NULL,
  `salestarget` double NOT NULL DEFAULT 0,
  `salesreal` double NOT NULL DEFAULT 0,
  `percent` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `trrevenues` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `accountid` char(30) NOT NULL DEFAULT '',
  `fromdate` date DEFAULT NULL,
  `todate` date DEFAULT NULL,
  `revtarget` double NOT NULL DEFAULT 0,
  `revreal` double NOT NULL DEFAULT 0,
  `percent` double NOT NULL DEFAULT 0,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `units` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` char(10) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `quantity` double NOT NULL DEFAULT 1,
  `costprice` double NOT NULL DEFAULT 0,
  `purchasedisc` double NOT NULL DEFAULT 0,
  `purchasetax` double NOT NULL DEFAULT 0,
  `netpurchase` double NOT NULL DEFAULT 0,
  `salesprice1` double NOT NULL DEFAULT 0,
  `salesprice2` double NOT NULL DEFAULT 0,
  `salesprice3` double NOT NULL DEFAULT 0,
  `salesprice4` double NOT NULL DEFAULT 0,
  `salesprice5` double NOT NULL DEFAULT 0,
  `salesprice6` double NOT NULL DEFAULT 0,
  `salesprice7` double NOT NULL DEFAULT 0,
  `salesdiscqty1` double NOT NULL DEFAULT 0,
  `salesdiscprice1` double NOT NULL DEFAULT 0,
  `salesdiscqty2` double NOT NULL DEFAULT 0,
  `salesdiscprice2` double NOT NULL DEFAULT 0,
  `salesdiscqty3` double NOT NULL DEFAULT 0,
  `salesdiscprice3` double NOT NULL DEFAULT 0,
  `salesdisc` double NOT NULL DEFAULT 0,
  `salesdiscformula` varchar(50) NOT NULL DEFAULT '',
  `divisionid` varchar(512) NOT NULL DEFAULT '[]',
  `departementid` varchar(512) NOT NULL DEFAULT '[]',
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `units` (`id`, `name`, `productid`, `quantity`, `costprice`, `purchasedisc`, `purchasetax`, `netpurchase`, `salesprice1`, `salesprice2`, `salesprice3`, `salesprice4`, `salesprice5`, `salesprice6`, `salesprice7`, `salesdiscqty1`, `salesdiscprice1`, `salesdiscqty2`, `salesdiscprice2`, `salesdiscqty3`, `salesdiscprice3`, `salesdisc`, `salesdiscformula`, `divisionid`, `departementid`, `isactive`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'PCS', '11001', 1, 1000, 0, 110, 1110, 1400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', 'admin', '2026-04-28 11:44:24'),
(2, 'KG', '11002', 1, 9000, 0, 0, 9000, 15000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', 'admin', '2026-03-14 16:28:39'),
(4, 'PCS', '21002', 1, 1000, 0, 0, 1000, 1200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', 'admin', '2024-03-11 19:29:47'),
(5, 'PCS', '22001', 1, 0, 0, 0, 0, 5000, 0, 0, 0, 0, 0, 0, 12, 4800, 24, 4750, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', '', '2024-05-02 04:19:09'),
(8, 'LSN', '11001', 12, 12000, 0, 0, 12000, 15000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', 'admin', '2026-04-28 11:44:35'),
(9, 'PCS', '33001', 1, 0, 0, 0, 0, 15000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', '', '2024-04-22 03:56:51'),
(10, 'PCS', '11003', 1, 1200, 60, 125.4, 1265.4, 1400, 1350, 0, 0, 0, 0, 0, 12, 1300, 24, 1250, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', 'admin', '2026-02-02 16:08:53'),
(11, 'LSN', '11003', 12, 12000, 0, 0, 12000, 15000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', '', '2026-02-02 16:46:55'),
(12, 'PCS', '11004', 1, 1000, 0, 110, 1110, 1400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', 'admin', '2026-04-28 11:44:05'),
(13, 'LSN', '11004', 12, 12000, 0, 0, 12000, 15000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', '', '2026-02-02 16:47:04'),
(15, 'PCS', '33002', 1, 118000, 0, 0, 118000, 150000, 0, 0, 0, 0, 0, 0, 12, 145000, 24, 140000, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', 'admin', '2024-06-28 17:02:04'),
(16, 'LSN', '33002', 12, 1416000, 0, 0, 1416000, 1750000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', 'admin', '2024-07-16 09:09:15'),
(18, 'JAM', '40001', 1, 0, 0, 0, 0, 50000, 0, 0, 0, 0, 0, 0, 3, 45000, 0, 0, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', '', '2024-08-12 10:51:40'),
(20, 'MALAM', '40002', 1, 0, 0, 0, 0, 200000, 0, 0, 0, 0, 0, 0, 3, 190000, 0, 0, 0, 0, 0, '', '[\"*\"]', '[\"*\"]', 1, 'admin', '', '2024-08-12 10:56:57');

CREATE TABLE `vehicle` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `platenumber` varchar(20) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `modelid` bigint(20) UNSIGNED NOT NULL,
  `division` char(10) DEFAULT NULL,
  `departement` char(10) DEFAULT NULL,
  `defaultdriverid` char(30) DEFAULT NULL,
  `fueltypeid` char(10) NOT NULL DEFAULT '',
  `ownershiptype` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=owned, 1=leased, 2=rented, 3=employee_owned',
  `vehiclestatus` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=active, 1=in_service, 2=inactive, 3=disposed',
  `odometerunit` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=km, 1=mi',
  `currentodometer` double NOT NULL DEFAULT 0,
  `hourused` int(11) NOT NULL DEFAULT 0,
  `yearmanufacture` int(11) NOT NULL DEFAULT 0,
  `yearmodel` int(11) NOT NULL DEFAULT 0,
  `vin` varchar(50) NOT NULL DEFAULT '',
  `chassisnumber` varchar(50) NOT NULL DEFAULT '',
  `enginenumber` varchar(50) NOT NULL DEFAULT '',
  `licensenumber` varchar(50) NOT NULL DEFAULT '',
  `color` varchar(30) NOT NULL DEFAULT '',
  `transmissiontype` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=manual, 1=automatic, 2=cvt, 9=other',
  `acquisitiondate` date DEFAULT NULL,
  `disposaldate` date DEFAULT NULL,
  `purchasevalue` double NOT NULL DEFAULT 0,
  `insurancenumber` varchar(50) NOT NULL DEFAULT '',
  `insuranceexpirydate` date DEFAULT NULL,
  `registrationexpirydate` date DEFAULT NULL,
  `inspectionexpirydate` date DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vehiclebrand` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `notes` varchar(255) NOT NULL DEFAULT '',
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `vehiclebrand` (`id`, `name`, `notes`, `isactive`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Toyota', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(2, 'Honda', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(3, 'Suzuki', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(4, 'Mitsubishi', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(5, 'Nissan', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(6, 'Isuzu', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(7, 'Ford', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(8, 'Mercedes-Benz', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(9, 'HINO', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(11, 'Tesla', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(12, 'Yamaha', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(13, 'Kawasaki', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(14, 'TVS', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(15, 'Bajaj', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(16, 'Caterpillar', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(17, 'Komatsu', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(18, 'Hitachi', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(19, 'Volvo', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(20, 'Kobelco', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(21, 'John Deere', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(22, 'XCMG', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(23, 'SANY', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(24, 'Hyundai', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(25, 'Samsung', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(26, 'Wuling', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(27, 'Daewoo', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(28, 'Rolls-Royce', '', 1, 'admin', '', '2026-04-02 00:04:57'),
(29, 'Daihatsu', '', 1, 'admin', 'admin', '2026-04-14 07:50:10');

CREATE TABLE `vehicledocument` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `vehicleid` bigint(20) UNSIGNED NOT NULL,
  `documenttype` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=registration, 1=insurance, 2=inspection, 3=lease, 4=permit, 9=other',
  `documentnumber` varchar(50) NOT NULL DEFAULT '',
  `issueddate` date DEFAULT NULL,
  `expirydate` date DEFAULT NULL,
  `reminderdate` date DEFAULT NULL,
  `amount` double NOT NULL DEFAULT 0,
  `notes` varchar(255) NOT NULL DEFAULT '',
  `images` text NOT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vehiclefuellog` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `division` char(10) DEFAULT '',
  `departement` char(10) DEFAULT '',
  `vehicleid` bigint(20) UNSIGNED NOT NULL,
  `tripid` varchar(30) DEFAULT '',
  `driverid` char(30) DEFAULT NULL,
  `vendorid` char(30) DEFAULT NULL,
  `fueltypeid` char(10) NOT NULL DEFAULT '',
  `transdatetime` datetime DEFAULT NULL,
  `odometervalue` double NOT NULL DEFAULT 0,
  `quantity` double NOT NULL DEFAULT 0,
  `unitprice` double NOT NULL DEFAULT 0,
  `totalamount` double NOT NULL DEFAULT 0,
  `fulltank` smallint(6) NOT NULL DEFAULT 0,
  `stationname` varchar(100) NOT NULL DEFAULT '',
  `receiptnumber` varchar(50) NOT NULL DEFAULT '',
  `notes` varchar(255) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vehiclefueltype` (
  `id` char(10) NOT NULL DEFAULT '',
  `name` varchar(50) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `notes` varchar(255) NOT NULL DEFAULT '',
  `expenseacc` char(30) NOT NULL,
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `vehiclefueltype` (`id`, `name`, `productid`, `notes`, `expenseacc`, `isactive`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
('PRT', 'Pertalite', '11001', '', '603.002', 1, 'admin', 'admin', '2026-04-10 05:53:12'),
('PTX', 'Pertamax', '11002', '', '603.002', 1, 'admin', 'admin', '2026-04-11 06:31:48'),
('SLR', 'Solar', '11002', '', '603.002', 1, 'admin', 'admin', '2026-04-10 05:53:12');

CREATE TABLE `vehiclemaintenance` (
  `id` varchar(30) NOT NULL DEFAULT '',
  `division` char(10) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `vehicleid` bigint(20) UNSIGNED NOT NULL,
  `categoryid` bigint(20) UNSIGNED NOT NULL,
  `vendorid` char(30) DEFAULT NULL,
  `requestedby` char(30) DEFAULT NULL,
  `servicedatetime` datetime DEFAULT NULL,
  `completedatetime` datetime DEFAULT NULL,
  `odometervalue` double NOT NULL DEFAULT 0,
  `maintenancetype` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=preventive, 1=corrective, 2=emergency',
  `complaint` text DEFAULT NULL,
  `diagnosis` text DEFAULT NULL,
  `workperformed` text DEFAULT NULL,
  `laborcost` double NOT NULL DEFAULT 0,
  `partscost` double NOT NULL DEFAULT 0,
  `othercost` double NOT NULL DEFAULT 0,
  `totalcost` double NOT NULL DEFAULT 0,
  `nextservicedate` date DEFAULT NULL,
  `nextserviceodometer` double NOT NULL DEFAULT 0,
  `maintenancestatus` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=draft, 1=approved, 2=done, 3=cancelled',
  `notes` text DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vehiclemaintenancecategory` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `intervaldays` int(11) NOT NULL DEFAULT 0,
  `intervaldistance` double NOT NULL DEFAULT 0,
  `expenseacc` char(30) NOT NULL DEFAULT '',
  `notes` varchar(255) NOT NULL DEFAULT '',
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `vehiclemaintenancecategory` (`id`, `name`, `intervaldays`, `intervaldistance`, `expenseacc`, `notes`, `isactive`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Balancing', 0, 0, '603.002', '', 1, 'admin', 'admin', '2026-04-11 07:27:47'),
(2, 'Ganti Oli', 1, 5000, '603.002', '', 1, 'admin', 'admin', '2026-04-11 07:27:56'),
(3, 'Over Haul', 0, 0, '603.002', '', 1, 'admin', 'admin', '2026-04-11 07:28:05'),
(4, 'Servis Besar', 0, 50000, '603.002', '', 1, 'admin', '', '2026-04-11 04:17:29'),
(5, 'Servis Bodi dan Cat', 0, 0, '603.002', '', 1, 'admin', '', '2026-04-11 04:17:29'),
(6, 'Servis Menengah ', 0, 40000, '603.002', '', 1, 'admin', '', '2026-04-11 04:17:29'),
(7, 'Spooring', 0, 0, '603.002', '', 1, 'admin', 'admin', '2026-04-11 07:28:14'),
(8, 'Servis Ringan', 90, 5000, '603.002', '', 1, 'admin', 'admin', '2026-04-11 07:28:26');

CREATE TABLE `vehiclemaintenancepart` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `maintenanceid` varchar(30) NOT NULL DEFAULT '',
  `productid` char(30) NOT NULL DEFAULT '',
  `description` varchar(150) NOT NULL DEFAULT '',
  `quantity` double NOT NULL DEFAULT 0,
  `unitname` varchar(20) NOT NULL DEFAULT '',
  `unitcost` double NOT NULL DEFAULT 0,
  `subtotal` double NOT NULL DEFAULT 0,
  `notes` varchar(255) NOT NULL DEFAULT '',
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vehiclemodel` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `brandid` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `vehicletypeid` bigint(20) UNSIGNED NOT NULL,
  `defaultfueltypeid` char(10) DEFAULT NULL,
  `seatcapacity` int(11) NOT NULL DEFAULT 0,
  `loadcapacitykg` double NOT NULL DEFAULT 0,
  `fueltankcapacity` double NOT NULL DEFAULT 0,
  `notes` varchar(255) NOT NULL DEFAULT '',
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `vehiclemodel` (`id`, `brandid`, `name`, `vehicletypeid`, `defaultfueltypeid`, `seatcapacity`, `loadcapacitykg`, `fueltankcapacity`, `notes`, `isactive`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 1, 'Avanza 1.3', 2, 'PRT', 7, 450, 45, '', 1, 'admin', 'admin', '2026-04-16 12:00:00'),
(2, 29, 'Xenia 1.3', 2, 'PRT', 7, 450, 43, '', 1, 'admin', 'admin', '2026-04-16 12:00:00'),
(3, 2, 'Brio 1.2', 2, 'PRT', 5, 350, 35, '', 1, 'admin', 'admin', '2026-04-16 12:00:00'),
(4, 3, 'Carry Pick Up 1.5', 9, 'PRT', 2, 1000, 42, '', 1, 'admin', 'admin', '2026-04-16 12:00:00'),
(5, 29, 'Gran Max Pick Up 1.5', 9, 'PRT', 2, 1500, 43, '', 1, 'admin', 'admin', '2026-04-16 12:00:00'),
(6, 4, 'L300 Pick Up Diesel', 9, 'SLR', 2, 1200, 47, '', 1, 'admin', 'admin', '2026-04-16 12:00:00'),
(7, 6, 'Traga Box', 10, 'SLR', 2, 1500, 50, '', 1, 'admin', 'admin', '2026-04-16 12:00:00'),
(8, 9, 'Dutro 130 HD', 7, 'SLR', 3, 6000, 100, '', 1, 'admin', 'admin', '2026-04-16 12:00:00'),
(9, 1, 'Hiace Premio', 8, 'SLR', 12, 1000, 70, '', 1, 'admin', 'admin', '2026-04-16 12:00:00'),
(10, 12, 'NMAX 155', 4, 'PTX', 2, 160, 7.1, '', 1, 'admin', 'admin', '2026-04-16 12:00:00');

CREATE TABLE `vehicleroute` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `routelengthkm` double NOT NULL DEFAULT 0,
  `notes` varchar(255) NOT NULL DEFAULT '',
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `vehicleroute` (`id`, `name`, `routelengthkm`, `notes`, `isactive`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Gudang - Distributor', 10, '', 1, 'admin', 'admin', '2026-04-11 06:32:52'),
(2, 'Kantor - Gudang', 31, '', 1, 'admin', '', '2026-04-11 06:42:24');

CREATE TABLE `vehicletrip` (
  `id` varchar(30) NOT NULL,
  `division` char(10) NOT NULL DEFAULT '',
  `departement` char(10) NOT NULL DEFAULT '',
  `vehicleid` bigint(20) UNSIGNED NOT NULL,
  `fueltypeid` char(10) NOT NULL DEFAULT '',
  `driverid` char(30) NOT NULL DEFAULT '',
  `transdate` date DEFAULT NULL,
  `startdatetime` datetime DEFAULT NULL,
  `enddatetime` datetime DEFAULT NULL,
  `tripdurationhour` int(11) NOT NULL DEFAULT 0,
  `routeid` bigint(20) UNSIGNED DEFAULT NULL,
  `routelengthkm` double NOT NULL DEFAULT 0,
  `loadquantity` int(11) NOT NULL DEFAULT 0,
  `purpose` varchar(255) NOT NULL DEFAULT '',
  `customername` varchar(100) NOT NULL DEFAULT '',
  `odometerstart` double NOT NULL DEFAULT 0,
  `odometerend` double NOT NULL DEFAULT 0,
  `distancetotal` double NOT NULL DEFAULT 0,
  `fuelqtyused` double NOT NULL DEFAULT 0,
  `fuelcosttotal` double NOT NULL DEFAULT 0,
  `tripstatus` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=draft, 1=ongoing, 2=done, 3=cancelled',
  `notes` text DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `vehicletype` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `notes` varchar(255) NOT NULL DEFAULT '',
  `isactive` smallint(6) NOT NULL DEFAULT 1,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `vehicletype` (`id`, `name`, `notes`, `isactive`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Bus', '', 1, '', '', '2026-03-31 06:48:22'),
(2, 'Car', '', 1, '', '', '2026-03-31 06:48:22'),
(3, 'Heavy Equipment', '', 1, '', '', '2026-03-31 06:48:22'),
(4, 'Motorcycle', '', 1, '', '', '2026-03-31 06:48:22'),
(5, 'Other', '', 1, '', '', '2026-03-31 06:48:22'),
(6, 'TAG BOAT', '', 1, 'admin', '', '2026-03-31 06:56:04'),
(7, 'Truck', '', 1, '', '', '2026-03-31 06:48:22'),
(8, 'Van', '', 1, '', '', '2026-03-31 06:48:22'),
(9, 'Pick Up', '', 1, 'admin', '', '2026-04-11 04:21:46'),
(10, 'Pick Up Box', '', 1, 'admin', '', '2026-04-11 04:22:12'),
(11, 'Truck Box', '', 1, 'admin', '', '2026-04-11 04:22:51'),
(12, 'Blindvan', '', 1, 'admin', '', '2026-04-11 04:26:58');

CREATE TABLE `version` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `version` char(20) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `version` (`id`, `version`, `updatetimestamp`) VALUES
(1, '8.1.5400', '2026-05-28 21:09:56');

CREATE TABLE `virtualtrans` (
  `id` int(11) NOT NULL,
  `transaction_id` char(50) NOT NULL,
  `userid` char(50) NOT NULL,
  `operation` enum('insert','update','delete') NOT NULL,
  `table_name` varchar(64) NOT NULL,
  `sql_text` text NOT NULL,
  `bindings` longtext NOT NULL,
  `delete_files` text NOT NULL,
  `created_at` datetime DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `vw_salesdiscrules` (
`key_type` varchar(1)
,`value` varchar(73)
,`label` varchar(73)
);
CREATE TABLE `vw_salespointrewardrules` (
`key_type` varchar(1)
,`value` varchar(73)
,`label` varchar(73)
);

CREATE TABLE `workinghours` (
  `id` bigint(20) NOT NULL,
  `name` varchar(50) NOT NULL DEFAULT '',
  `startcheckin` time DEFAULT NULL,
  `endcheckout` time DEFAULT NULL,
  `latecheckin` time DEFAULT NULL,
  `overtime` time DEFAULT NULL,
  `enableinputstart` time DEFAULT NULL,
  `enableinputend` time DEFAULT NULL,
  `employeegroup` tinytext DEFAULT NULL,
  `usercreate` char(16) NOT NULL DEFAULT '',
  `useredit` char(16) NOT NULL DEFAULT '',
  `updatetimestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `workinghours` (`id`, `name`, `startcheckin`, `endcheckout`, `latecheckin`, `overtime`, `enableinputstart`, `enableinputend`, `employeegroup`, `usercreate`, `useredit`, `updatetimestamp`) VALUES
(1, 'Jam Kerja Normal', '08:00:00', '18:00:00', '08:11:00', '19:59:00', '02:00:00', '17:00:00', '[\"EG-001\",\"EG-002\"]', 'admin', 'admin', '2025-05-14 20:10:41');


ALTER TABLE `account`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `address`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `attendance`
  ADD PRIMARY KEY (`id`),
  ADD KEY `employeeid` (`employeeid`),
  ADD KEY `kioskdeviceid` (`kioskdeviceid`),
  ADD KEY `verifymethod` (`verifymethod`);

ALTER TABLE `attendancekioskdevice`
  ADD PRIMARY KEY (`id`),
  ADD KEY `isactive` (`isactive`);

ALTER TABLE `attendanceverifylog`
  ADD PRIMARY KEY (`id`),
  ADD KEY `employeeid` (`employeeid`),
  ADD KEY `attendanceid` (`attendanceid`),
  ADD KEY `kioskdeviceid` (`kioskdeviceid`),
  ADD KEY `result` (`result`);

ALTER TABLE `authorityrequest`
  ADD PRIMARY KEY (`id`),
  ADD KEY `userid` (`userid`),
  ADD KEY `touserid` (`touserid`);

ALTER TABLE `authors`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `cogs`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `productid` (`productid`) USING BTREE,
  ADD KEY `FK_cogs_division` (`division`);

ALTER TABLE `countries`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `currencies`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `customerbalance`
  ADD PRIMARY KEY (`transid`) USING BTREE,
  ADD KEY `customerid` (`customerid`) USING BTREE,
  ADD KEY `FK_customerbalance_division` (`division`);

ALTER TABLE `customerdisplay`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `customerdp`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `division` (`division`),
  ADD KEY `customerid` (`customerid`),
  ADD KEY `paymenttype` (`paymenttype`),
  ADD KEY `downpaymenttype` (`downpaymenttype`);

ALTER TABLE `customergiro`
  ADD PRIMARY KEY (`id`),
  ADD KEY `customerid` (`customerid`),
  ADD KEY `division` (`division`),
  ADD KEY `paymenttype` (`paymenttype`);

ALTER TABLE `customergroup`
  ADD PRIMARY KEY (`id`),
  ADD KEY `receivableacc` (`receivableacc`),
  ADD KEY `rewardacc` (`rewardacc`),
  ADD KEY `salesdiscacc` (`salesdiscacc`),
  ADD KEY `gainlossreceivableacc` (`gainlossreceivableacc`);

ALTER TABLE `customerguide`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `customernote`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `division` (`division`),
  ADD KEY `customerid` (`customerid`),
  ADD KEY `customernote_ibfk_3` (`customernoteid`);

ALTER TABLE `customernotes`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `deliveryorder`
  ADD PRIMARY KEY (`salesid`),
  ADD KEY `division` (`division`),
  ADD KEY `salesmanid` (`salesmanid`),
  ADD KEY `customerid` (`customerid`),
  ADD KEY `shipment` (`shipment`);

ALTER TABLE `deliveryorderdetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `productid` (`productid`),
  ADD KEY `departement` (`departement`),
  ADD KEY `salesidref` (`salesidref`);

ALTER TABLE `deliveryorderrewarddetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `salesidref` (`salesidref`),
  ADD KEY `productid` (`productid`),
  ADD KEY `departement` (`departement`);

ALTER TABLE `departement`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_departement_1` (`division`);

ALTER TABLE `depreciationrecords`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `fixedassetid` (`fixedassetid`);

ALTER TABLE `discountdays`
  ADD PRIMARY KEY (`adate`);

ALTER TABLE `division`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_division_1` (`retainedearningacc`),
  ADD KEY `FK_division_2` (`exchangerateacc`),
  ADD KEY `FK_division_3` (`profitlossdiffcashacc`);

ALTER TABLE `employeeface`
  ADD PRIMARY KEY (`id`),
  ADD KEY `employeeid` (`employeeid`),
  ADD KEY `employeeid_isactive` (`employeeid`,`isactive`);

ALTER TABLE `employeefaceenrollment`
  ADD PRIMARY KEY (`id`),
  ADD KEY `employeeid` (`employeeid`),
  ADD KEY `status` (`status`);

ALTER TABLE `employeegroup`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `employeesalaries`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `employeeid` (`employeeid`) USING BTREE,
  ADD KEY `salaryid` (`salaryid`) USING BTREE;

ALTER TABLE `excratehistories`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `excratehistories_ibfk_1` (`id`);

ALTER TABLE `factories`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `filteroperands`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `fixedasset`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fagroup` (`fagroup`),
  ADD KEY `division` (`division`),
  ADD KEY `departement` (`departement`),
  ADD KEY `accountid` (`accountid`) USING BTREE;

ALTER TABLE `fixedassetdepreciation`
  ADD PRIMARY KEY (`transid`) USING BTREE,
  ADD KEY `division` (`division`) USING BTREE;

ALTER TABLE `fixedassetdispose`
  ADD PRIMARY KEY (`transid`) USING BTREE,
  ADD KEY `division` (`division`) USING BTREE,
  ADD KEY `departement` (`departement`) USING BTREE,
  ADD KEY `accountid` (`accountid`) USING BTREE;

ALTER TABLE `fixedassetgroup`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fixedassetacc` (`fixedassetacc`),
  ADD KEY `depreciationacc` (`depreciationacc`),
  ADD KEY `expenseacc` (`expenseacc`),
  ADD KEY `gainlostacc` (`gainlostacc`);

ALTER TABLE `goodsreceipt`
  ADD PRIMARY KEY (`purchaseid`),
  ADD KEY `division` (`division`),
  ADD KEY `purchaser` (`purchaser`),
  ADD KEY `supplierid` (`supplierid`),
  ADD KEY `shipment` (`shipment`);

ALTER TABLE `goodsreceiptdetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `productid` (`productid`),
  ADD KEY `departement` (`departement`),
  ADD KEY `purchaseidref` (`purchaseidref`);

ALTER TABLE `goodsreceiptrewarddetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `purchaseidref` (`purchaseidref`),
  ADD KEY `productid` (`productid`),
  ADD KEY `departement` (`departement`);

ALTER TABLE `groupid`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `holidays`
  ADD PRIMARY KEY (`adate`);

ALTER TABLE `inputpayablebal`
  ADD PRIMARY KEY (`id`),
  ADD KEY `division` (`division`),
  ADD KEY `accountid` (`accountid`);

ALTER TABLE `inputreceivablebal`
  ADD PRIMARY KEY (`id`),
  ADD KEY `division` (`division`),
  ADD KEY `accountid` (`accountid`);

ALTER TABLE `inventory`
  ADD PRIMARY KEY (`id`),
  ADD KEY `departement` (`departement`),
  ADD KEY `division` (`division`),
  ADD KEY `productid` (`productid`);

ALTER TABLE `inventoryadjust`
  ADD PRIMARY KEY (`id`),
  ADD KEY `inventoryadjust_ibfk_1` (`division`),
  ADD KEY `FK_inventoryadjust_departement` (`departement`),
  ADD KEY `FK_inventoryadjust_account` (`accountid`);

ALTER TABLE `inventoryadjustdetail`
  ADD PRIMARY KEY (`id`),
  ADD KEY `productid` (`productid`),
  ADD KEY `transid` (`transid`),
  ADD KEY `inventoryadjustdetail_ibfk_5` (`unit`);

ALTER TABLE `inventoryin`
  ADD PRIMARY KEY (`id`),
  ADD KEY `division` (`division`),
  ADD KEY `departement` (`departement`),
  ADD KEY `accountid` (`accountid`);

ALTER TABLE `inventoryindetail`
  ADD PRIMARY KEY (`id`),
  ADD KEY `productid` (`productid`),
  ADD KEY `transid` (`transid`),
  ADD KEY `inventoryindetail_ibfk_3` (`unit`);

ALTER TABLE `inventorymoving`
  ADD PRIMARY KEY (`id`),
  ADD KEY `inventorymoving_ibfk_1` (`fromdivision`),
  ADD KEY `inventorymoving_ibfk_2` (`fromdepartement`),
  ADD KEY `inventorymoving_ibfk_3` (`todivision`),
  ADD KEY `inventorymoving_ibfk_4` (`todepartement`);

ALTER TABLE `inventorymovingdetail`
  ADD PRIMARY KEY (`id`),
  ADD KEY `productid` (`productid`),
  ADD KEY `transid` (`transid`),
  ADD KEY `inventorymovingdetail_ibfk_3` (`unit`);

ALTER TABLE `inventoryout`
  ADD PRIMARY KEY (`id`),
  ADD KEY `division` (`division`),
  ADD KEY `departement` (`departement`),
  ADD KEY `accountid` (`accountid`);

ALTER TABLE `inventoryoutdetail`
  ADD PRIMARY KEY (`id`),
  ADD KEY `productid` (`productid`),
  ADD KEY `transid` (`transid`),
  ADD KEY `inventoryoutdetail_ibfk_3` (`unit`);

ALTER TABLE `journal`
  ADD PRIMARY KEY (`jtid`),
  ADD KEY `division` (`division`);

ALTER TABLE `journalclose`
  ADD PRIMARY KEY (`jtid`),
  ADD KEY `division` (`division`),
  ADD KEY `accountid` (`accountid`);

ALTER TABLE `journalexpense`
  ADD PRIMARY KEY (`jtid`),
  ADD KEY `division` (`division`),
  ADD KEY `paymenttype` (`paymenttype`);

ALTER TABLE `journalexpensedetail`
  ADD PRIMARY KEY (`id`),
  ADD KEY `accountid` (`accountid`),
  ADD KEY `journalexpensedetail_ibfk_2` (`jtid`);

ALTER TABLE `journalrevenue`
  ADD PRIMARY KEY (`jtid`),
  ADD KEY `division` (`division`),
  ADD KEY `paymenttype` (`paymenttype`);

ALTER TABLE `journalrevenuedetail`
  ADD PRIMARY KEY (`id`),
  ADD KEY `accountid` (`accountid`),
  ADD KEY `journalrevenuedetail_ibfk_2` (`jtid`);

ALTER TABLE `journaltrans`
  ADD PRIMARY KEY (`id`),
  ADD KEY `accountid` (`accountid`),
  ADD KEY `division` (`division`);

ALTER TABLE `langoverrides`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_lang_overrides_lang_key` (`lang`,`langkey`),
  ADD KEY `idx_lang_overrides_lang` (`lang`),
  ADD KEY `idx_lang_overrides_key` (`langkey`);

ALTER TABLE `logtransactions`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `mrpbomcomponent`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_mrpbomcomponent_product` (`productid`),
  ADD KEY `FK_mrpbomcomponent_product_2` (`mrpproduct`);

ALTER TABLE `mrpbomoperation`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_mrpbomoperation_mrpoperation` (`operationid`),
  ADD KEY `FK_mrpbomoperation_product` (`mrpproduct`);

ALTER TABLE `mrpoperation`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_mrpoperation_mrpworkcenter` (`workcenter`),
  ADD KEY `FK_mrpoperation_wageaccount` (`wageaccount`);

ALTER TABLE `mrporder`
  ADD PRIMARY KEY (`transid`) USING BTREE,
  ADD KEY `FK_mrporder_product` (`productid`) USING BTREE,
  ADD KEY `FK_mrporder_division` (`division`),
  ADD KEY `FK_mrporder_departement` (`departement`);

ALTER TABLE `mrpordercomponent`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_mrpordercomponent_product` (`productid`) USING BTREE,
  ADD KEY `FK_mrpordercomponent_mrporder` (`mrporder`) USING BTREE;

ALTER TABLE `mrpworkcenter`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_mrpworkcenter_division` (`division`) USING BTREE,
  ADD KEY `FK_mrpworkcenter_productiondepartement` (`productiondepartement`) USING BTREE,
  ADD KEY `FK_mrpworkcenter_storedepartement` (`storedepartement`) USING BTREE;

ALTER TABLE `mrpworkorder`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_mrpworkorder_mrpoperation` (`operationid`) USING BTREE,
  ADD KEY `FK_mrpworkorder_mrporder` (`mrporder`);

ALTER TABLE `mrpworkorderemployee`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_mrpworkorderemployee_mrpworkorder` (`workorderid`),
  ADD KEY `FK_mrpworkorderemployee_employee` (`employeeid`);

ALTER TABLE `onlinepayments`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `payableadjust`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `division` (`division`),
  ADD KEY `supplierid` (`supplierid`),
  ADD KEY `expensestype` (`expensestype`);

ALTER TABLE `payablepayment`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `division` (`division`),
  ADD KEY `supplierid` (`supplierid`),
  ADD KEY `paymenttype` (`paymenttype`);

ALTER TABLE `paymentdiscrules`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `paymenttype`
  ADD PRIMARY KEY (`id`),
  ADD KEY `paymenttype_ibfk_1` (`paymentacc`),
  ADD KEY `paymenttype_ibfk_2` (`cashdiscacc`),
  ADD KEY `paymenttype_ibfk_3` (`expenseacc`);

ALTER TABLE `pointofsales`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_pointofsales_paymenttype` (`paymentdefault`),
  ADD KEY `FK_pointofsales_customer` (`customerdefault`),
  ADD KEY `FK_pointofsales_salesman` (`salesmandefault`),
  ADD KEY `FK_pointofsales_division` (`division`),
  ADD KEY `FK_pointofsales_departement` (`departement`),
  ADD KEY `FK_pointofsales_shipments` (`shipment`),
  ADD KEY `FK_pointofsales_servicedoer` (`servicedoerdefault`),
  ADD KEY `FK_pointofsales_account` (`sourcecash`);

ALTER TABLE `poshistories`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_poshistories_posid` (`posid`) USING BTREE;

ALTER TABLE `posprintcashier`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `posprintorder`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `postable`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_postable_customer` (`customerid`),
  ADD KEY `FK_postable_postablegroup` (`tablegroup`);

ALTER TABLE `postablegroup`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `product`
  ADD PRIMARY KEY (`id`),
  ADD KEY `author` (`author`),
  ADD KEY `factory` (`factory`),
  ADD KEY `supplier` (`supplier`),
  ADD KEY `productgroup` (`productgroup`),
  ADD KEY `taxtype` (`taxtype`),
  ADD KEY `cogsacc` (`cogsacc`),
  ADD KEY `inventoryacc` (`inventoryacc`),
  ADD KEY `salesacc` (`salesacc`),
  ADD KEY `salesdiscacc` (`salesdiscacc`),
  ADD KEY `salesreturnacc` (`salesreturnacc`),
  ADD KEY `brand` (`brand`);

ALTER TABLE `productassemble`
  ADD PRIMARY KEY (`id`),
  ADD KEY `division` (`division`),
  ADD KEY `departement` (`departement`),
  ADD KEY `productid` (`productid`),
  ADD KEY `productassemble_ibfk_4` (`unit`);

ALTER TABLE `productassembledetail`
  ADD PRIMARY KEY (`id`),
  ADD KEY `productid` (`productid`),
  ADD KEY `transid` (`transid`),
  ADD KEY `productassembledetail_ibfk_3` (`unit`);

ALTER TABLE `productbrand`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `productdisassemble`
  ADD PRIMARY KEY (`id`),
  ADD KEY `division` (`division`),
  ADD KEY `departement` (`departement`),
  ADD KEY `productid` (`productid`),
  ADD KEY `productdisassemble_ibfk_4` (`unit`);

ALTER TABLE `productdisassembledetail`
  ADD PRIMARY KEY (`id`),
  ADD KEY `productid` (`productid`),
  ADD KEY `transid` (`transid`),
  ADD KEY `productdisassembledetail_ibfk_3` (`unit`);

ALTER TABLE `productgroup`
  ADD PRIMARY KEY (`id`),
  ADD KEY `cogsacc` (`cogsacc`),
  ADD KEY `inventoryacc` (`inventoryacc`),
  ADD KEY `salesacc` (`salesacc`),
  ADD KEY `salesdiscacc` (`salesdiscacc`),
  ADD KEY `salesreturnacc` (`salesreturnacc`);

ALTER TABLE `productpackage`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `packageid` (`packageid`),
  ADD KEY `productid` (`productid`);

ALTER TABLE `productsalesvariant`
  ADD PRIMARY KEY (`id`),
  ADD KEY `productgroup` (`productgroup`);

ALTER TABLE `purchase`
  ADD PRIMARY KEY (`purchaseid`),
  ADD KEY `division` (`division`),
  ADD KEY `purchaser` (`purchaser`),
  ADD KEY `supplierid` (`supplierid`),
  ADD KEY `shipment` (`shipment`);

ALTER TABLE `purchasedetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `productid` (`productid`),
  ADD KEY `taxid` (`taxid`),
  ADD KEY `departement` (`departement`),
  ADD KEY `purchaseidref` (`purchaseidref`);

ALTER TABLE `purchaseexpenses`
  ADD PRIMARY KEY (`id`),
  ADD KEY `purchaseexpacc` (`purchaseexpacc`);

ALTER TABLE `purchaseexpensesdetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `purchaseexpid` (`purchaseexpid`),
  ADD KEY `purchaseidref` (`purchaseidref`);

ALTER TABLE `purchaseextratax`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `productid` (`productid`),
  ADD KEY `taxid` (`taxid`),
  ADD KEY `purchaseidref` (`purchaseidref`);

ALTER TABLE `purchaseorder`
  ADD PRIMARY KEY (`purchaseid`),
  ADD KEY `division` (`division`),
  ADD KEY `purchaser` (`purchaser`),
  ADD KEY `supplierid` (`supplierid`),
  ADD KEY `shipment` (`shipment`);

ALTER TABLE `purchaseorderdetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `productid` (`productid`),
  ADD KEY `taxid` (`taxid`),
  ADD KEY `departement` (`departement`),
  ADD KEY `purchaseidref` (`purchaseidref`);

ALTER TABLE `purchaseorderexpensesdetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `purchaseexpid` (`purchaseexpid`),
  ADD KEY `purchaseidref` (`purchaseidref`);

ALTER TABLE `purchaseorderextratax`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `productid` (`productid`),
  ADD KEY `taxid` (`taxid`),
  ADD KEY `purchaseidref` (`purchaseidref`);

ALTER TABLE `purchaseorderpayments`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `purchaseidref` (`purchaseidref`),
  ADD KEY `paymenttype` (`paymenttype`);

ALTER TABLE `purchaseorderpoint`
  ADD PRIMARY KEY (`transid`) USING BTREE,
  ADD KEY `purchaseid` (`purchaseid`) USING BTREE,
  ADD KEY `purchaseidref` (`purchaseidref`) USING BTREE,
  ADD KEY `supplier` (`supplier`) USING BTREE;

ALTER TABLE `purchaseorderrewarddetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `purchaseidref` (`purchaseidref`),
  ADD KEY `productid` (`productid`),
  ADD KEY `departement` (`departement`);

ALTER TABLE `purchasepayments`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `purchaseidref` (`purchaseidref`),
  ADD KEY `paymenttype` (`paymenttype`);

ALTER TABLE `purchasepoint`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `purchaseidref` (`purchaseidref`),
  ADD KEY `supplier` (`supplier`);

ALTER TABLE `purchaserequisition`
  ADD PRIMARY KEY (`requisitionid`),
  ADD KEY `division` (`division`),
  ADD KEY `approvaluser` (`approvaluser`);

ALTER TABLE `purchaserequisitiondetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `requisitionid` (`requisitionid`),
  ADD KEY `requisitionidref` (`requisitionidref`),
  ADD KEY `supplierid` (`supplierid`),
  ADD KEY `departement` (`departement`),
  ADD KEY `productid` (`productid`);

ALTER TABLE `purchaserewarddetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `purchaseid` (`purchaseid`),
  ADD KEY `purchaseidref` (`purchaseidref`),
  ADD KEY `productid` (`productid`),
  ADD KEY `departement` (`departement`);

ALTER TABLE `receivableadjust`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `division` (`division`),
  ADD KEY `customerid` (`customerid`),
  ADD KEY `expensestype` (`expensestype`);

ALTER TABLE `receivablepayment`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `division` (`division`),
  ADD KEY `customerid` (`customerid`),
  ADD KEY `paymenttype` (`paymenttype`);

ALTER TABLE `religions`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `rentalreturn`
  ADD PRIMARY KEY (`transid`) USING BTREE,
  ADD KEY `division` (`division`) USING BTREE,
  ADD KEY `customerid` (`customerid`) USING BTREE,
  ADD KEY `FK_rentalreturn_sales` (`salesid`) USING BTREE;

ALTER TABLE `rentalreturndetail`
  ADD PRIMARY KEY (`transid`) USING BTREE,
  ADD KEY `rentalreturnid` (`rentalreturnid`) USING BTREE,
  ADD KEY `productid` (`productid`) USING BTREE,
  ADD KEY `departement` (`departement`) USING BTREE;

ALTER TABLE `roles`
  ADD PRIMARY KEY (`id`),
  ADD KEY `division_ibfk` (`defaultdivision`),
  ADD KEY `departement_ibfk` (`defaultdepartement`),
  ADD KEY `customer_ibfk` (`defaultcustomer`),
  ADD KEY `supplier_ibfk` (`defaultsupplier`),
  ADD KEY `salesman_ibfk` (`defaultsalesman`),
  ADD KEY `servicedoer_ibfk` (`defaultservicedoer`),
  ADD KEY `currency_ibfk` (`defaultcurrency`),
  ADD KEY `employee_ibfk` (`defaultemployee`),
  ADD KEY `shipment_ibfk` (`defaultshipment`),
  ADD KEY `payment_ibfk` (`defaultpayment`);

ALTER TABLE `salaries`
  ADD PRIMARY KEY (`id`),
  ADD KEY `salaries_ibfk_1` (`account`);

ALTER TABLE `salariesrecord`
  ADD PRIMARY KEY (`transid`) USING BTREE,
  ADD KEY `employeeid` (`employeeid`) USING BTREE,
  ADD KEY `salaryid` (`salaryid`) USING BTREE;

ALTER TABLE `salarypayments`
  ADD PRIMARY KEY (`transid`) USING BTREE,
  ADD KEY `division` (`division`),
  ADD KEY `employeeid` (`employeeid`),
  ADD KEY `salaryid` (`salaryid`),
  ADD KEY `paymenttype` (`paymenttype`);

ALTER TABLE `salaryperiod`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `salaryperiod_ibfk_2` (`division`) USING BTREE,
  ADD KEY `salaryperiod_ibfk_1` (`employeegroup`) USING BTREE,
  ADD KEY `FK_salaryperiod_account` (`accountid`);

ALTER TABLE `salaryperioddetail`
  ADD PRIMARY KEY (`transid`) USING BTREE,
  ADD KEY `employeeid` (`employeeid`) USING BTREE;

ALTER TABLE `salarystructure`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `salarystructuredetail`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `salaryid` (`salaryid`) USING BTREE,
  ADD KEY `employeelevel` (`salarystructure`) USING BTREE;

ALTER TABLE `sales`
  ADD PRIMARY KEY (`salesid`),
  ADD KEY `division` (`division`),
  ADD KEY `salesmanid` (`salesmanid`),
  ADD KEY `customerid` (`customerid`),
  ADD KEY `shipment` (`shipment`),
  ADD KEY `sales_ibfk_5` (`billto`);

ALTER TABLE `salesdetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `productid` (`productid`),
  ADD KEY `taxid` (`taxid`),
  ADD KEY `departement` (`departement`),
  ADD KEY `salesidref` (`salesidref`),
  ADD KEY `servicedoerid` (`servicedoerid`);

ALTER TABLE `salesdiscrules`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `salesexpenses`
  ADD PRIMARY KEY (`id`),
  ADD KEY `salesexpacc` (`salesexpacc`);

ALTER TABLE `salesexpensesdetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `salesexpid` (`salesexpid`),
  ADD KEY `salesidref` (`salesidref`);

ALTER TABLE `salesextratax`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `productid` (`productid`),
  ADD KEY `taxid` (`taxid`),
  ADD KEY `salesidref` (`salesidref`);

ALTER TABLE `salesman`
  ADD PRIMARY KEY (`id`),
  ADD KEY `salesmangroup` (`salesmangroup`),
  ADD KEY `payablecommacc` (`payablecommacc`),
  ADD KEY `expensecommacc` (`expensecommacc`);

ALTER TABLE `salesmancommperiod`
  ADD PRIMARY KEY (`id`),
  ADD KEY `salesmancommperiod_ibfk_1` (`salaryid`),
  ADD KEY `salesmancommperiod_ibfk_2` (`division`);

ALTER TABLE `salesmancommrules`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `salesmancommvar`
  ADD PRIMARY KEY (`varname`);

ALTER TABLE `salesmancommvarrecords`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesmancommvarrecords_ibfk_1` (`periodid`);

ALTER TABLE `salesmandetail`
  ADD PRIMARY KEY (`groupid`,`salesmanid`),
  ADD KEY `salesmanid` (`salesmanid`);

ALTER TABLE `salesmangroup`
  ADD PRIMARY KEY (`id`),
  ADD KEY `payablecommacc` (`payablecommacc`),
  ADD KEY `expensecommacc` (`expensecommacc`);

ALTER TABLE `salesmanrecorddetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesmanid` (`salesmanid`),
  ADD KEY `productid` (`productid`),
  ADD KEY `salesmanrecorddetail_ibfk_3` (`periodid`);

ALTER TABLE `salesmanrecords`
  ADD PRIMARY KEY (`id`),
  ADD KEY `salesmanid` (`salesmanid`),
  ADD KEY `salesmanrecords_ibfk_2` (`periodid`);

ALTER TABLE `salesorder`
  ADD PRIMARY KEY (`salesid`),
  ADD KEY `division` (`division`),
  ADD KEY `salesmanid` (`salesmanid`),
  ADD KEY `customerid` (`customerid`),
  ADD KEY `shipment` (`shipment`);

ALTER TABLE `salesorderdetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `productid` (`productid`),
  ADD KEY `taxid` (`taxid`),
  ADD KEY `departement` (`departement`),
  ADD KEY `salesidref` (`salesidref`),
  ADD KEY `servicedoerid` (`servicedoerid`);

ALTER TABLE `salesorderexpensesdetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `salesexpid` (`salesexpid`),
  ADD KEY `salesidref` (`salesidref`);

ALTER TABLE `salesorderextratax`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `productid` (`productid`),
  ADD KEY `taxid` (`taxid`),
  ADD KEY `salesidref` (`salesidref`);

ALTER TABLE `salesorderpayments`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `salesidref` (`salesidref`),
  ADD KEY `paymenttype` (`paymenttype`);

ALTER TABLE `salesorderpoint`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `salesidref` (`salesidref`),
  ADD KEY `customer` (`customer`);

ALTER TABLE `salesorderrewarddetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `salesidref` (`salesidref`),
  ADD KEY `productid` (`productid`),
  ADD KEY `departement` (`departement`);

ALTER TABLE `salespayments`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `salesidref` (`salesidref`),
  ADD KEY `paymenttype` (`paymenttype`);

ALTER TABLE `salespoint`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `salesidref` (`salesidref`),
  ADD KEY `customer` (`customer`);

ALTER TABLE `salespointrewardrules`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `salesproductrewardrules`
  ADD PRIMARY KEY (`id`),
  ADD KEY `productid` (`productid`),
  ADD KEY `departement` (`departement`);

ALTER TABLE `salesrewarddetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `salesid` (`salesid`),
  ADD KEY `salesidref` (`salesidref`),
  ADD KEY `productid` (`productid`),
  ADD KEY `departement` (`departement`);

ALTER TABLE `schoolclass`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_schoolclass_schoollevel` (`schoollevel`);

ALTER TABLE `schoolexam`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `schoolextrascore`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_schoolextrascore_schoolscoringtype` (`scoringtype`),
  ADD KEY `FK_schoolextrascore_schoolextrascoregroup` (`extrascoregroup`);

ALTER TABLE `schoolextrascoregroup`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `schoollesson`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_schoollesson_schoolscoringtype` (`scoringtype`),
  ADD KEY `FK_schoollesson_schoollessongroup` (`lessongroup`);

ALTER TABLE `schoollessonclass`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_schoollessonclass_schoolsubclass` (`schoolsubclass`),
  ADD KEY `FK_schoollessonclass_schoollesson` (`schoollesson`),
  ADD KEY `FK_schoollessonclass_schoolteacher` (`schoolteacher`);

ALTER TABLE `schoollessongroup`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `schoollessonteacher`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_schoollessonteacher_schoolsubclass` (`schoolsubclass`) USING BTREE,
  ADD KEY `FK_schoollessonteacher_schoollesson` (`schoollesson`) USING BTREE,
  ADD KEY `FK_schoollessonteacher_schoolteacher` (`schoolteacher`);

ALTER TABLE `schoollevel`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_schoollevel_schoolteacher` (`headmaster`);

ALTER TABLE `schoolpayment`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_schoolpayment_schoolpaymentgroup` (`paymentgroup`) USING BTREE,
  ADD KEY `FK_schoolpayment_receivable` (`receivableacc`),
  ADD KEY `FK_schoolpayment_revenue` (`revenueacc`),
  ADD KEY `FK_schoolpayment_account` (`unearnedrevenueacc`),
  ADD KEY `FK_schoolpayment_account_2` (`paymentdiscacc`);

ALTER TABLE `schoolpaymentgroup`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `schoolpaymentpackage`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `schoolpaymentpackagedetail`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_schoolpaymentpackagedetail_schoolpaymentpackage` (`schoolpaymentpackage`) USING BTREE,
  ADD KEY `FK_schoolpaymentpackagedetail_schoolpayment` (`schoolpayment`) USING BTREE;

ALTER TABLE `schoolperiod`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `schoolscoringtype`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `schoolscoringtyperange`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_schoolscoringtyperange_schoolscoringtype` (`schoolscoringtype`);

ALTER TABLE `schoolstudent`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_schoolstudent_schoolclass` (`schoolclass`),
  ADD KEY `FK_schoolstudent_schoolsubclass` (`schoolsubclass`),
  ADD KEY `FK_schoolstudent_schoolstudentstatus` (`status`),
  ADD KEY `FK_schoolstudent_schoolstudentdorm` (`dorm`) USING BTREE;

ALTER TABLE `schoolstudentdorm`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_schoolstudentdorm_schoolteacher` (`dormheadmaster`);

ALTER TABLE `schoolstudentpayment`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `school` (`schoolstudent`) USING BTREE,
  ADD KEY `FK_schoolstudentpayment_schoolsubclass` (`schoolsubclass`) USING BTREE,
  ADD KEY `FK_schoolstudentpayment_division` (`division`) USING BTREE,
  ADD KEY `FK_schoolstudentpayment_paymenttype` (`paymenttype`);

ALTER TABLE `schoolstudentpaymentdetail`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `school` (`schoolstudent`) USING BTREE,
  ADD KEY `FK_schoolstudentpaymentdetail_schoolpayment` (`schoolpayment`) USING BTREE,
  ADD KEY `FK_schoolstudentpaymentdetail_schoolsubclass` (`schoolsubclass`) USING BTREE,
  ADD KEY `FK_schoolstudentpaymentdetail_schoolstudentpayment` (`parent`);

ALTER TABLE `schoolstudentpaymentschedule`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `school` (`schoolstudent`) USING BTREE,
  ADD KEY `FK_schoolstudentpaymentschedule_schoolpaymentpackage` (`schoolpaymentpackage`) USING BTREE,
  ADD KEY `FK_schoolstudentpaymentschedule_schoolsubclass` (`schoolsubclass`) USING BTREE,
  ADD KEY `FK_schoolstudentpaymentschedule_division` (`division`);

ALTER TABLE `schoolstudentscore`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_schoolstudentscore_schoolsubclass` (`schoolsubclass`) USING BTREE,
  ADD KEY `FK_schoolstudentscore_schoollesson` (`schoollesson`) USING BTREE,
  ADD KEY `FK_schoolstudentscore_schoolteacher` (`schoolteacher`) USING BTREE,
  ADD KEY `FK_schoolstudentscore_schoolperiod` (`schoolperiod`),
  ADD KEY `FK_schoolstudentscore_schoolscoringtype` (`scoringtype`),
  ADD KEY `FK_schoolstudentscore_schoolexam` (`schoolexam`);

ALTER TABLE `schoolstudentscoredetail`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_schoolstudentscoredetail_schoolsubclass` (`schoolsubclass`) USING BTREE,
  ADD KEY `FK_schoolstudentscoredetail_schoollesson` (`schoollesson`) USING BTREE,
  ADD KEY `FK_schoolstudentscoredetail_schoolteacher` (`schoolteacher`) USING BTREE,
  ADD KEY `FK_schoolstudentscoredetail_schoolstudent` (`schoolstudent`) USING BTREE,
  ADD KEY `FK_schoolstudentscoredetail_schoolperiod` (`schoolperiod`) USING BTREE,
  ADD KEY `FK_schoolstudentscoredetail_scoringtype` (`scoringtype`) USING BTREE,
  ADD KEY `FK_schoolstudentscoredetail_schoolexam` (`schoolexam`),
  ADD KEY `FK_schoolstudentscoredetail_schoolstudentscore` (`schoolstudentscore`);

ALTER TABLE `schoolstudentsextrascore`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_schoolstudentsextrascore_schoolsubclass` (`schoolsubclass`) USING BTREE,
  ADD KEY `FK_schoolstudentsextrascore_schoolextrascore` (`schoolextrascore`) USING BTREE,
  ADD KEY `FK_schoolstudentsextrascore_schoolextrascoregroup` (`schoolextrascoregroup`) USING BTREE,
  ADD KEY `FK_schoolstudentsextrascore_schoolteacher` (`schoolteacher`) USING BTREE,
  ADD KEY `FK_schoolstudentsextrascore_schoolperiod` (`schoolperiod`),
  ADD KEY `FK_schoolstudentsextrascore_schoolscoringtype` (`scoringtype`),
  ADD KEY `FK_schoolstudentsextrascore_schoolexam` (`schoolexam`);

ALTER TABLE `schoolstudentsextrascoredetail`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_schoolstudentsextrascoredetail_schoolsubclass` (`schoolsubclass`) USING BTREE,
  ADD KEY `FK_schoolstudentsextrascoredetail_schoolextrascore` (`schoolextrascore`) USING BTREE,
  ADD KEY `FK_schoolstudentsextrascoredetail_schoolteacher` (`schoolteacher`) USING BTREE,
  ADD KEY `FK_schoolstudentsextrascoredetail_schoolstudent` (`schoolstudent`) USING BTREE,
  ADD KEY `FK_schoolstudentsextrascoredetail_schoolperiod` (`schoolperiod`) USING BTREE,
  ADD KEY `FK_schoolstudentsextrascoredetail_scoringtype` (`scoringtype`) USING BTREE,
  ADD KEY `FK_schoolstudentsextrascoredetail_schoolexam` (`schoolexam`),
  ADD KEY `FK_schoolstudentsextrascoredetail_schoolstudentsextrascore` (`schoolstudentsextrascore`);

ALTER TABLE `schoolstudentstatus`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `schoolstupaymentscheduledetail`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `school` (`schoolstudent`) USING BTREE,
  ADD KEY `FK_schoolstudentpayment_schoolpayment` (`schoolpayment`) USING BTREE,
  ADD KEY `FK_schoolstupaymentscheddetail_schoolsubclass` (`schoolsubclass`);

ALTER TABLE `schoolsubclass`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `FK_schoolsubclass_schoolclass` (`schoolclass`),
  ADD KEY `FK_schoolsubclass_schoolteacher` (`homeroomteacher`);

ALTER TABLE `schoolteacher`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `servicedoer`
  ADD PRIMARY KEY (`id`),
  ADD KEY `servicedoergroup` (`servicedoergroup`),
  ADD KEY `payablecommacc` (`payablecommacc`),
  ADD KEY `expensecommacc` (`expensecommacc`);

ALTER TABLE `servicedoercommperiod`
  ADD PRIMARY KEY (`id`),
  ADD KEY `servicedoercommperiod_ibfk_1` (`salaryid`),
  ADD KEY `servicedoercommperiod_ibfk_2` (`division`);

ALTER TABLE `servicedoercommrules`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `servicedoercommvar`
  ADD PRIMARY KEY (`varname`);

ALTER TABLE `servicedoercommvarrecords`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `servicedoercommvarrecords_ibfk_1` (`periodid`);

ALTER TABLE `servicedoerdetail`
  ADD PRIMARY KEY (`groupid`,`servicedoerid`),
  ADD KEY `servicedoerid` (`servicedoerid`);

ALTER TABLE `servicedoergroup`
  ADD PRIMARY KEY (`id`),
  ADD KEY `payablecommacc` (`payablecommacc`),
  ADD KEY `expensecommacc` (`expensecommacc`);

ALTER TABLE `servicedoerrecorddetail`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `servicedoerid` (`servicedoerid`),
  ADD KEY `productid` (`productid`),
  ADD KEY `servicedoerrecorddetail_ibfk_3` (`periodid`);

ALTER TABLE `servicedoerrecords`
  ADD PRIMARY KEY (`id`),
  ADD KEY `servicedoerid` (`servicedoerid`),
  ADD KEY `servicedoerrecords_ibfk_2` (`periodid`);

ALTER TABLE `shipments`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `slidedata`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_slidedata_slide` (`slideid`) USING BTREE;

ALTER TABLE `slideelements`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_slideelements_slidedata` (`slidedataid`);

ALTER TABLE `supplier`
  ADD PRIMARY KEY (`id`),
  ADD KEY `suppliergroup` (`suppliergroup`),
  ADD KEY `payableacc` (`payableacc`),
  ADD KEY `rewardacc` (`rewardacc`),
  ADD KEY `purchasediscacc` (`purchasediscacc`),
  ADD KEY `gainlosspayableacc` (`gainlosspayableacc`),
  ADD KEY `supplier_ibfk_6` (`accruedpayableacc`);

ALTER TABLE `supplierbalance`
  ADD PRIMARY KEY (`transid`) USING BTREE,
  ADD KEY `supplierid` (`supplierid`) USING BTREE,
  ADD KEY `FK_supplierbalance_division` (`division`);

ALTER TABLE `supplierdp`
  ADD PRIMARY KEY (`transid`),
  ADD KEY `division` (`division`),
  ADD KEY `supplierid` (`supplierid`),
  ADD KEY `paymenttype` (`paymenttype`),
  ADD KEY `downpaymenttype` (`downpaymenttype`);

ALTER TABLE `suppliergiro`
  ADD PRIMARY KEY (`id`),
  ADD KEY `supplierid` (`supplierid`),
  ADD KEY `division` (`division`),
  ADD KEY `paymenttype` (`paymenttype`);

ALTER TABLE `suppliergroup`
  ADD PRIMARY KEY (`id`),
  ADD KEY `payableacc` (`payableacc`),
  ADD KEY `rewardacc` (`rewardacc`),
  ADD KEY `purchasediscacc` (`purchasediscacc`),
  ADD KEY `gainlosspayableacc` (`gainlosspayableacc`),
  ADD KEY `suppliergroup_ibfk_6` (`accruedpayableacc`);

ALTER TABLE `tableroles`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_tableroles_roles` (`roles`);

ALTER TABLE `taxes`
  ADD PRIMARY KEY (`id`),
  ADD KEY `taxoutacc` (`taxoutacc`),
  ADD KEY `taxinacc` (`taxinacc`);

ALTER TABLE `themecolors`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `trackemployee`
  ADD PRIMARY KEY (`id`) USING BTREE,
  ADD KEY `employeeid` (`employeeid`) USING BTREE,
  ADD KEY `FK_trackemployee_attendance` (`attendanceid`);

ALTER TABLE `trexpenses`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `trproduct`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `trrevenues`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `units`
  ADD PRIMARY KEY (`id`),
  ADD KEY `productid` (`productid`);

ALTER TABLE `vehicle`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_vehicle_platenumber` (`platenumber`),
  ADD KEY `idx_vehicle_modelid` (`modelid`),
  ADD KEY `idx_vehicle_division` (`division`),
  ADD KEY `idx_vehicle_departement` (`departement`),
  ADD KEY `idx_vehicle_defaultdriverid` (`defaultdriverid`),
  ADD KEY `idx_vehicle_fueltypeid` (`fueltypeid`);

ALTER TABLE `vehiclebrand`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `vehicledocument`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_vehicledocument_vehicleid` (`vehicleid`);

ALTER TABLE `vehiclefuellog`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_vehiclefuellog_vehicleid` (`vehicleid`),
  ADD KEY `idx_vehiclefuellog_driverid` (`driverid`),
  ADD KEY `idx_vehiclefuellog_vendorid` (`vendorid`),
  ADD KEY `idx_vehiclefuellog_fueltypeid` (`fueltypeid`),
  ADD KEY `idx_vehiclefuellog_transdatetime` (`transdatetime`),
  ADD KEY `idx_vehiclefuellog_tripid` (`tripid`) USING BTREE,
  ADD KEY `idx_vehiclefuellog_division` (`division`) USING BTREE,
  ADD KEY `idx_vehiclefuellog_departement` (`departement`) USING BTREE;

ALTER TABLE `vehiclefueltype`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_vehiclefueltype_product` (`productid`),
  ADD KEY `FK_vehiclefueltype_expenseacc` (`expenseacc`);

ALTER TABLE `vehiclemaintenance`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_vehiclemaintenance_vehicleid` (`vehicleid`),
  ADD KEY `idx_vehiclemaintenance_categoryid` (`categoryid`),
  ADD KEY `idx_vehiclemaintenance_vendorid` (`vendorid`),
  ADD KEY `idx_vehiclemaintenance_requestedby` (`requestedby`),
  ADD KEY `idx_vehiclemaintenance_servicedatetime` (`servicedatetime`),
  ADD KEY `idx_vehiclemaintenance_division` (`division`),
  ADD KEY `idx_vehiclemaintenance_departement` (`departement`);

ALTER TABLE `vehiclemaintenancecategory`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_vehiclemaintenancecategory_account` (`expenseacc`);

ALTER TABLE `vehiclemaintenancepart`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_vehiclemaintenancepart_maintenanceid` (`maintenanceid`),
  ADD KEY `idx_vehiclemaintenancepart_productid` (`productid`);

ALTER TABLE `vehiclemodel`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_vehiclemodel_brandid` (`brandid`),
  ADD KEY `idx_vehiclemodel_defaultfueltypeid` (`defaultfueltypeid`),
  ADD KEY `idx_vehiclemodel_vehicletypeid` (`vehicletypeid`);

ALTER TABLE `vehicleroute`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `vehicletrip`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_vehicletrip_vehicleid` (`vehicleid`),
  ADD KEY `idx_vehicletrip_driverid` (`driverid`),
  ADD KEY `idx_vehicletrip_tripdate` (`transdate`),
  ADD KEY `idx_vehicletrip_routeid` (`routeid`),
  ADD KEY `idx_vehicletrip_fueltypeid` (`fueltypeid`) USING BTREE,
  ADD KEY `idx_vehicletrip_division` (`division`),
  ADD KEY `idx_vehicletrip_departement` (`departement`);

ALTER TABLE `vehicletype`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `version`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `virtualtrans`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `workinghours`
  ADD PRIMARY KEY (`id`);


ALTER TABLE `address`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `attendance`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `attendancekioskdevice`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

ALTER TABLE `attendanceverifylog`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `authorityrequest`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `cogs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `customerbalance`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `customerdisplay`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

ALTER TABLE `customergiro`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `customernote`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `deliveryorderdetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `deliveryorderrewarddetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `depreciationrecords`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `employeeface`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `employeefaceenrollment`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `employeesalaries`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `excratehistories`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `filteroperands`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=33;

ALTER TABLE `fixedassetdepreciation`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `fixedassetdispose`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `goodsreceiptdetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `goodsreceiptrewarddetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `inventory`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `inventoryadjustdetail`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `inventoryindetail`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `inventorymovingdetail`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `inventoryoutdetail`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `journalexpensedetail`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `journalrevenuedetail`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `journaltrans`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `langoverrides`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `logtransactions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `mrpbomcomponent`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

ALTER TABLE `mrpbomoperation`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

ALTER TABLE `mrpoperation`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

ALTER TABLE `mrpordercomponent`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `mrpworkcenter`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

ALTER TABLE `mrpworkorder`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `mrpworkorderemployee`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `onlinepayments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

ALTER TABLE `pointofsales`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

ALTER TABLE `poshistories`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `posprintcashier`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

ALTER TABLE `posprintorder`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

ALTER TABLE `postable`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

ALTER TABLE `postablegroup`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

ALTER TABLE `productassembledetail`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `productdisassembledetail`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `productpackage`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

ALTER TABLE `productsalesvariant`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchasedetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchaseexpensesdetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchaseextratax`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchaseorderdetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchaseorderexpensesdetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchaseorderextratax`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchaseorderpayments`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchaseorderpoint`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchaseorderrewarddetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchasepayments`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchasepoint`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchaserequisitiondetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `purchaserewarddetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `religions`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

ALTER TABLE `rentalreturndetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salariesrecord`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salaryperioddetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salarystructuredetail`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesdetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesexpensesdetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesextratax`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesmancommvarrecords`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesmanrecorddetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesmanrecords`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesorderdetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesorderexpensesdetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesorderextratax`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesorderpayments`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesorderpoint`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesorderrewarddetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salespayments`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salespoint`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `salesrewarddetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `schoollessonclass`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

ALTER TABLE `schoollessonteacher`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;

ALTER TABLE `schoolpaymentpackage`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

ALTER TABLE `schoolpaymentpackagedetail`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

ALTER TABLE `schoolscoringtype`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

ALTER TABLE `schoolscoringtyperange`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

ALTER TABLE `schoolstudentdorm`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

ALTER TABLE `schoolstudentpayment`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

ALTER TABLE `schoolstudentpaymentdetail`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

ALTER TABLE `schoolstudentpaymentschedule`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

ALTER TABLE `schoolstudentscore`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

ALTER TABLE `schoolstudentscoredetail`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

ALTER TABLE `schoolstudentsextrascore`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

ALTER TABLE `schoolstudentsextrascoredetail`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

ALTER TABLE `schoolstudentstatus`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

ALTER TABLE `schoolstupaymentscheduledetail`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

ALTER TABLE `servicedoercommvarrecords`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `servicedoerrecorddetail`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `servicedoerrecords`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `slidedata`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

ALTER TABLE `slideelements`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

ALTER TABLE `supplierbalance`
  MODIFY `transid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `suppliergiro`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `tableroles`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

ALTER TABLE `themecolors`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

ALTER TABLE `trackemployee`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `trexpenses`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `trproduct`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `trrevenues`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `units`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;

ALTER TABLE `vehicle`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

ALTER TABLE `vehiclebrand`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=32;

ALTER TABLE `vehicledocument`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `vehiclefuellog`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `vehiclemaintenancecategory`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

ALTER TABLE `vehiclemaintenancepart`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `vehiclemodel`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

ALTER TABLE `vehicleroute`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

ALTER TABLE `vehicletype`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;

ALTER TABLE `version`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

ALTER TABLE `virtualtrans`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

ALTER TABLE `workinghours`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `vw_salesdiscrules`  AS SELECT '0' AS `key_type`, concat('product.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`, concat('product.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` FROM `information_schema`.`columns` WHERE `information_schema`.`columns`.`TABLE_SCHEMA` = database() AND `information_schema`.`columns`.`TABLE_NAME` = 'product'union all select '0' AS `key_type`,concat('customer.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('customer.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'customer' union all select '0' AS `key_type`,concat('salesman.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('salesman.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'salesman' union all select '0' AS `key_type`,concat('unit.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('unit.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'units' union all select '0' AS `key_type`,concat('detail.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('detail.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'salesdetail' union all select '0' AS `key_type`,'salestotal' AS `value`,'salestotal' AS `label` union all select '1' AS `key_type`,concat('customer.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('customer.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'customer' union all select '1' AS `key_type`,concat('salesman.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('salesman.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'salesman' union all select '1' AS `key_type`,concat('sales.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('sales.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'sales' union all select '1' AS `key_type`,concat('detail.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('detail.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'salesdetail' union all select '1' AS `key_type`,'salesgross' AS `value`,'salesgross' AS `label` union all select '1' AS `key_type`,'brandsummary.[Product brand ID]' AS `value`,'brandsummary.[Product brand ID]' AS `label` union all select '1' AS `key_type`,'suppliersummary.[Supplier ID]' AS `value`,'suppliersummary.[Supplier ID]' AS `label` union all select '1' AS `key_type`,'factorysummary.[Factory ID]' AS `value`,'factorysummary.[Factory ID]' AS `label` union all select '1' AS `key_type`,'productgroupsummary.[Product Group ID]' AS `value`,'productgroupsummary.[Product Group ID]' AS `label`  ;

CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `vw_salespointrewardrules`  AS SELECT '0' AS `key_type`, concat('customer.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`, concat('customer.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` FROM `information_schema`.`columns` WHERE `information_schema`.`columns`.`TABLE_SCHEMA` = database() AND `information_schema`.`columns`.`TABLE_NAME` = 'customer'union all select '0' AS `key_type`,concat('salesman.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('salesman.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'salesman' union all select '0' AS `key_type`,concat('sales.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('sales.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'sales' union all select '0' AS `key_type`,'salestotal' AS `value`,'salestotal' AS `label` union all select '0' AS `key_type`,'brandsummary.[Product brand ID]' AS `value`,'brandsummary.[Product brand ID]' AS `label` union all select '0' AS `key_type`,'suppliersummary.[Supplier ID]' AS `value`,'suppliersummary.[Supplier ID]' AS `label` union all select '0' AS `key_type`,'factorysummary.[Factory ID]' AS `value`,'factorysummary.[Factory ID]' AS `label` union all select '0' AS `key_type`,'productgroupsummary.[Product Group ID]' AS `value`,'productgroupsummary.[Product Group ID]' AS `label` union all select '0' AS `key_type`,concat('detail.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('detail.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'salesdetail' union all select '1' AS `key_type`,concat('customer.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('customer.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'customer' union all select '1' AS `key_type`,concat('salesman.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('salesman.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'salesman' union all select '1' AS `key_type`,concat('sales.',`information_schema`.`columns`.`COLUMN_NAME`) AS `value`,concat('sales.',`information_schema`.`columns`.`COLUMN_NAME`) AS `label` from `information_schema`.`columns` where `information_schema`.`columns`.`TABLE_SCHEMA` = database() and `information_schema`.`columns`.`TABLE_NAME` = 'sales' union all select '1' AS `key_type`,'salestotal' AS `value`,'salestotal' AS `label` union all select '1' AS `key_type`,'brandsummary.[Product brand ID]' AS `value`,'brandsummary.[Product brand ID]' AS `label` union all select '1' AS `key_type`,'suppliersummary.[Supplier ID]' AS `value`,'suppliersummary.[Supplier ID]' AS `label` union all select '1' AS `key_type`,'factorysummary.[Factory ID]' AS `value`,'factorysummary.[Factory ID]' AS `label` union all select '1' AS `key_type`,'productgroupsummary.[Product Group ID]' AS `value`,'productgroupsummary.[Product Group ID]' AS `label`  ;


ALTER TABLE `attendance`
  ADD CONSTRAINT `FK_attendance_employee` FOREIGN KEY (`employeeid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `attendance_ibfk_kioskdevice` FOREIGN KEY (`kioskdeviceid`) REFERENCES `attendancekioskdevice` (`id`) ON UPDATE CASCADE;

ALTER TABLE `attendanceverifylog`
  ADD CONSTRAINT `attendanceverifylog_ibfk_1` FOREIGN KEY (`employeeid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `attendanceverifylog_ibfk_2` FOREIGN KEY (`attendanceid`) REFERENCES `attendance` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `attendanceverifylog_ibfk_3` FOREIGN KEY (`kioskdeviceid`) REFERENCES `attendancekioskdevice` (`id`) ON UPDATE CASCADE;

ALTER TABLE `authorityrequest`
  ADD CONSTRAINT `FK_authorityrequest_1` FOREIGN KEY (`userid`) REFERENCES `users` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_authorityrequest_2` FOREIGN KEY (`touserid`) REFERENCES `users` (`id`) ON UPDATE CASCADE;

ALTER TABLE `cogs`
  ADD CONSTRAINT `FK_cogs_division` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `cogs_ibfk_1` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE;

ALTER TABLE `customerbalance`
  ADD CONSTRAINT `FK_customerbalance_division` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `customerbalance_ibfk_1` FOREIGN KEY (`customerid`) REFERENCES `customer` (`id`) ON UPDATE CASCADE;

ALTER TABLE `customerdp`
  ADD CONSTRAINT `customerdp_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `customerdp_ibfk_2` FOREIGN KEY (`customerid`) REFERENCES `customer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `customerdp_ibfk_3` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `customerdp_ibfk_4` FOREIGN KEY (`downpaymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `customergiro`
  ADD CONSTRAINT `customergiro_ibfk_1` FOREIGN KEY (`customerid`) REFERENCES `customer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `customergiro_ibfk_2` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `customergiro_ibfk_3` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `customergroup`
  ADD CONSTRAINT `customergroup_ibfk_1` FOREIGN KEY (`receivableacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `customergroup_ibfk_3` FOREIGN KEY (`rewardacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `customergroup_ibfk_5` FOREIGN KEY (`salesdiscacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `customergroup_ibfk_6` FOREIGN KEY (`gainlossreceivableacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `customernote`
  ADD CONSTRAINT `customernote_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `customernote_ibfk_2` FOREIGN KEY (`customerid`) REFERENCES `customer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `customernote_ibfk_3` FOREIGN KEY (`customernoteid`) REFERENCES `customernotes` (`id`) ON UPDATE CASCADE;

ALTER TABLE `deliveryorder`
  ADD CONSTRAINT `deliveryorder_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `deliveryorder_ibfk_2` FOREIGN KEY (`salesmanid`) REFERENCES `salesman` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `deliveryorder_ibfk_3` FOREIGN KEY (`customerid`) REFERENCES `customer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `deliveryorder_ibfk_4` FOREIGN KEY (`shipment`) REFERENCES `shipments` (`id`) ON UPDATE CASCADE;

ALTER TABLE `deliveryorderdetail`
  ADD CONSTRAINT `deliveryorderdetail_ibfk_1` FOREIGN KEY (`salesid`) REFERENCES `deliveryorder` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `deliveryorderdetail_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `deliveryorderdetail_ibfk_3` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `deliveryorderdetail_ibfk_4` FOREIGN KEY (`salesidref`) REFERENCES `deliveryorder` (`salesid`) ON UPDATE CASCADE;

ALTER TABLE `deliveryorderrewarddetail`
  ADD CONSTRAINT `FK_deliveryorderrewarddetail_1` FOREIGN KEY (`salesid`) REFERENCES `deliveryorder` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_deliveryorderrewarddetail_2` FOREIGN KEY (`salesidref`) REFERENCES `deliveryorder` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_deliveryorderrewarddetail_3` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_deliveryorderrewarddetail_4` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE;

ALTER TABLE `departement`
  ADD CONSTRAINT `FK_departement_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE;

ALTER TABLE `depreciationrecords`
  ADD CONSTRAINT `depreciationrecords_ibfk_1` FOREIGN KEY (`fixedassetid`) REFERENCES `fixedasset` (`id`) ON UPDATE CASCADE;

ALTER TABLE `division`
  ADD CONSTRAINT `FK_division_1` FOREIGN KEY (`retainedearningacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_division_2` FOREIGN KEY (`exchangerateacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_division_3` FOREIGN KEY (`profitlossdiffcashacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `employeeface`
  ADD CONSTRAINT `employeeface_ibfk_1` FOREIGN KEY (`employeeid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE;

ALTER TABLE `employeefaceenrollment`
  ADD CONSTRAINT `employeefaceenrollment_ibfk_1` FOREIGN KEY (`employeeid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE;

ALTER TABLE `employeesalaries`
  ADD CONSTRAINT `employeesalaries_ibfk_1` FOREIGN KEY (`employeeid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `employeesalaries_ibfk_2` FOREIGN KEY (`salaryid`) REFERENCES `salaries` (`id`) ON UPDATE CASCADE;

ALTER TABLE `excratehistories`
  ADD CONSTRAINT `excratehistories_ibfk_1` FOREIGN KEY (`id`) REFERENCES `currencies` (`id`) ON UPDATE CASCADE;

ALTER TABLE `fixedasset`
  ADD CONSTRAINT `fixedasset_ibfk_1` FOREIGN KEY (`fagroup`) REFERENCES `fixedassetgroup` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fixedasset_ibfk_2` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fixedasset_ibfk_3` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fixedasset_ibfk_4` FOREIGN KEY (`accountid`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `fixedassetdepreciation`
  ADD CONSTRAINT `fixedassetdepreciation_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE;

ALTER TABLE `fixedassetdispose`
  ADD CONSTRAINT `fixedassetdispose_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fixedassetdispose_ibfk_2` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fixedassetdispose_ibfk_3` FOREIGN KEY (`accountid`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `fixedassetgroup`
  ADD CONSTRAINT `fixedassetgroup_ibfk_1` FOREIGN KEY (`fixedassetacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fixedassetgroup_ibfk_2` FOREIGN KEY (`depreciationacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fixedassetgroup_ibfk_3` FOREIGN KEY (`expenseacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fixedassetgroup_ibfk_4` FOREIGN KEY (`gainlostacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `goodsreceipt`
  ADD CONSTRAINT `goodsreceipt_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `goodsreceipt_ibfk_2` FOREIGN KEY (`purchaser`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `goodsreceipt_ibfk_3` FOREIGN KEY (`supplierid`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `goodsreceipt_ibfk_4` FOREIGN KEY (`shipment`) REFERENCES `shipments` (`id`) ON UPDATE CASCADE;

ALTER TABLE `goodsreceiptdetail`
  ADD CONSTRAINT `goodsreceiptdetail_ibfk_1` FOREIGN KEY (`purchaseid`) REFERENCES `goodsreceipt` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `goodsreceiptdetail_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `goodsreceiptdetail_ibfk_3` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `goodsreceiptdetail_ibfk_4` FOREIGN KEY (`purchaseidref`) REFERENCES `goodsreceipt` (`purchaseid`) ON UPDATE CASCADE;

ALTER TABLE `goodsreceiptrewarddetail`
  ADD CONSTRAINT `FK_goodsreceiptrewarddetail_1` FOREIGN KEY (`purchaseid`) REFERENCES `goodsreceipt` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_goodsreceiptrewarddetail_2` FOREIGN KEY (`purchaseidref`) REFERENCES `goodsreceipt` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_goodsreceiptrewarddetail_3` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_goodsreceiptrewarddetail_4` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE;

ALTER TABLE `inputpayablebal`
  ADD CONSTRAINT `inputpayablebal_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inputpayablebal_ibfk_2` FOREIGN KEY (`accountid`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `inputreceivablebal`
  ADD CONSTRAINT `inputreceivablebal_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inputreceivablebal_ibfk_2` FOREIGN KEY (`accountid`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `inventory`
  ADD CONSTRAINT `inventory_ibfk_1` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventory_ibfk_2` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventory_ibfk_3` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE;

ALTER TABLE `inventoryadjust`
  ADD CONSTRAINT `FK_inventoryadjust_account` FOREIGN KEY (`accountid`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_inventoryadjust_departement` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventoryadjust_division` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE;

ALTER TABLE `inventoryadjustdetail`
  ADD CONSTRAINT `inventoryadjustdetail_ibfk_1` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventoryadjustdetail_ibfk_2` FOREIGN KEY (`transid`) REFERENCES `inventoryadjust` (`id`) ON UPDATE CASCADE;

ALTER TABLE `inventoryin`
  ADD CONSTRAINT `inventoryin_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventoryin_ibfk_2` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventoryin_ibfk_3` FOREIGN KEY (`accountid`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `inventoryindetail`
  ADD CONSTRAINT `inventoryindetail_ibfk_1` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventoryindetail_ibfk_2` FOREIGN KEY (`transid`) REFERENCES `inventoryin` (`id`) ON UPDATE CASCADE;

ALTER TABLE `inventorymoving`
  ADD CONSTRAINT `inventorymoving_ibfk_1` FOREIGN KEY (`fromdivision`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventorymoving_ibfk_2` FOREIGN KEY (`fromdepartement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventorymoving_ibfk_3` FOREIGN KEY (`todivision`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventorymoving_ibfk_4` FOREIGN KEY (`todepartement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE;

ALTER TABLE `inventorymovingdetail`
  ADD CONSTRAINT `inventorymovingdetail_ibfk_1` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventorymovingdetail_ibfk_2` FOREIGN KEY (`transid`) REFERENCES `inventorymoving` (`id`) ON UPDATE CASCADE;

ALTER TABLE `inventoryout`
  ADD CONSTRAINT `inventoryout_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventoryout_ibfk_2` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventoryout_ibfk_3` FOREIGN KEY (`accountid`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `inventoryoutdetail`
  ADD CONSTRAINT `inventoryoutdetail_ibfk_1` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inventoryoutdetail_ibfk_2` FOREIGN KEY (`transid`) REFERENCES `inventoryout` (`id`) ON UPDATE CASCADE;

ALTER TABLE `journal`
  ADD CONSTRAINT `journal_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE;

ALTER TABLE `journalclose`
  ADD CONSTRAINT `journalclose_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `journalclose_ibfk_2` FOREIGN KEY (`accountid`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `journalexpense`
  ADD CONSTRAINT `journalexpense_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `journalexpense_ibfk_2` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `journalexpensedetail`
  ADD CONSTRAINT `journalexpensedetail_ibfk_1` FOREIGN KEY (`accountid`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `journalexpensedetail_ibfk_2` FOREIGN KEY (`jtid`) REFERENCES `journalexpense` (`jtid`) ON UPDATE CASCADE;

ALTER TABLE `journalrevenue`
  ADD CONSTRAINT `journalrevenue_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `journalrevenue_ibfk_2` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `journalrevenuedetail`
  ADD CONSTRAINT `journalrevenuedetail_ibfk_1` FOREIGN KEY (`accountid`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `journalrevenuedetail_ibfk_2` FOREIGN KEY (`jtid`) REFERENCES `journalrevenue` (`jtid`) ON UPDATE CASCADE;

ALTER TABLE `journaltrans`
  ADD CONSTRAINT `journaltrans_ibfk_1` FOREIGN KEY (`accountid`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `journaltrans_ibfk_2` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE;

ALTER TABLE `mrpbomcomponent`
  ADD CONSTRAINT `FK_mrpbomcomponent_product` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_mrpbomcomponent_product_2` FOREIGN KEY (`mrpproduct`) REFERENCES `product` (`id`) ON UPDATE CASCADE;

ALTER TABLE `mrpbomoperation`
  ADD CONSTRAINT `FK_mrpbomoperation_mrpoperation` FOREIGN KEY (`operationid`) REFERENCES `mrpoperation` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_mrpbomoperation_product` FOREIGN KEY (`mrpproduct`) REFERENCES `product` (`id`) ON UPDATE CASCADE;

ALTER TABLE `mrpoperation`
  ADD CONSTRAINT `FK_mrpoperation_mrpworkcenter` FOREIGN KEY (`workcenter`) REFERENCES `mrpworkcenter` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_mrpoperation_wageaccount` FOREIGN KEY (`wageaccount`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `mrporder`
  ADD CONSTRAINT `FK_mrporder_departement` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_mrporder_division` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_mrporder_product` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE;

ALTER TABLE `mrpordercomponent`
  ADD CONSTRAINT `FK_mrpordercomponent_mrporder` FOREIGN KEY (`mrporder`) REFERENCES `mrporder` (`transid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_mrpordercomponent_productid` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE;

ALTER TABLE `mrpworkcenter`
  ADD CONSTRAINT `FK_mrpworkcenter_productiondepartement` FOREIGN KEY (`productiondepartement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_mrpworkcenter_storedepartement` FOREIGN KEY (`storedepartement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE;

ALTER TABLE `mrpworkorder`
  ADD CONSTRAINT `FK_mrpworkorder_mrpoperation` FOREIGN KEY (`operationid`) REFERENCES `mrpoperation` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_mrpworkorder_mrporder` FOREIGN KEY (`mrporder`) REFERENCES `mrporder` (`transid`) ON UPDATE CASCADE;

ALTER TABLE `mrpworkorderemployee`
  ADD CONSTRAINT `FK_mrpworkorderemployee_employee` FOREIGN KEY (`employeeid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_mrpworkorderemployee_mrpworkorder` FOREIGN KEY (`workorderid`) REFERENCES `mrpworkorder` (`id`) ON UPDATE CASCADE;

ALTER TABLE `payableadjust`
  ADD CONSTRAINT `payableadjust_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `payableadjust_ibfk_2` FOREIGN KEY (`supplierid`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `payableadjust_ibfk_3` FOREIGN KEY (`expensestype`) REFERENCES `purchaseexpenses` (`id`) ON UPDATE CASCADE;

ALTER TABLE `payablepayment`
  ADD CONSTRAINT `payablepayment_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `payablepayment_ibfk_2` FOREIGN KEY (`supplierid`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `payablepayment_ibfk_3` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `paymenttype`
  ADD CONSTRAINT `paymenttype_ibfk_1` FOREIGN KEY (`paymentacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `paymenttype_ibfk_2` FOREIGN KEY (`cashdiscacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `paymenttype_ibfk_3` FOREIGN KEY (`expenseacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `pointofsales`
  ADD CONSTRAINT `FK_pointofsales_account` FOREIGN KEY (`sourcecash`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_pointofsales_customer` FOREIGN KEY (`customerdefault`) REFERENCES `customer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_pointofsales_departement` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_pointofsales_division` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_pointofsales_paymenttype` FOREIGN KEY (`paymentdefault`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_pointofsales_salesman` FOREIGN KEY (`salesmandefault`) REFERENCES `salesman` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_pointofsales_servicedoer` FOREIGN KEY (`servicedoerdefault`) REFERENCES `servicedoer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_pointofsales_shipments` FOREIGN KEY (`shipment`) REFERENCES `shipments` (`id`) ON UPDATE CASCADE;

ALTER TABLE `poshistories`
  ADD CONSTRAINT `FK_poshistories_posid` FOREIGN KEY (`posid`) REFERENCES `pointofsales` (`id`) ON UPDATE CASCADE;

ALTER TABLE `postable`
  ADD CONSTRAINT `FK_postable_customer` FOREIGN KEY (`customerid`) REFERENCES `customer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_postable_postablegroup` FOREIGN KEY (`tablegroup`) REFERENCES `postablegroup` (`id`) ON UPDATE CASCADE;

ALTER TABLE `product`
  ADD CONSTRAINT `product_ibfk_1` FOREIGN KEY (`author`) REFERENCES `authors` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `product_ibfk_10` FOREIGN KEY (`supplier`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `product_ibfk_11` FOREIGN KEY (`productgroup`) REFERENCES `productgroup` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `product_ibfk_12` FOREIGN KEY (`taxtype`) REFERENCES `taxes` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `product_ibfk_13` FOREIGN KEY (`cogsacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `product_ibfk_14` FOREIGN KEY (`inventoryacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `product_ibfk_3` FOREIGN KEY (`salesacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `product_ibfk_4` FOREIGN KEY (`salesdiscacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `product_ibfk_5` FOREIGN KEY (`salesreturnacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `product_ibfk_8` FOREIGN KEY (`brand`) REFERENCES `productbrand` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `product_ibfk_9` FOREIGN KEY (`factory`) REFERENCES `factories` (`id`) ON UPDATE CASCADE;

ALTER TABLE `productassemble`
  ADD CONSTRAINT `productassemble_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `productassemble_ibfk_2` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `productassemble_ibfk_3` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE;

ALTER TABLE `productassembledetail`
  ADD CONSTRAINT `productassembledetail_ibfk_1` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `productassembledetail_ibfk_2` FOREIGN KEY (`transid`) REFERENCES `productassemble` (`id`) ON UPDATE CASCADE;

ALTER TABLE `productdisassemble`
  ADD CONSTRAINT `productdisassemble_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `productdisassemble_ibfk_2` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `productdisassemble_ibfk_3` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE;

ALTER TABLE `productdisassembledetail`
  ADD CONSTRAINT `productdisassembledetail_ibfk_1` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `productdisassembledetail_ibfk_2` FOREIGN KEY (`transid`) REFERENCES `productdisassemble` (`id`) ON UPDATE CASCADE;

ALTER TABLE `productgroup`
  ADD CONSTRAINT `productgroup_ibfk_1` FOREIGN KEY (`cogsacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `productgroup_ibfk_2` FOREIGN KEY (`inventoryacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `productgroup_ibfk_4` FOREIGN KEY (`salesacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `productgroup_ibfk_5` FOREIGN KEY (`salesdiscacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `productgroup_ibfk_6` FOREIGN KEY (`salesreturnacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `productpackage`
  ADD CONSTRAINT `productpackage_ibfk_1` FOREIGN KEY (`packageid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `productpackage_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE;

ALTER TABLE `productsalesvariant`
  ADD CONSTRAINT `productsalesvariant_ibfk_1` FOREIGN KEY (`productgroup`) REFERENCES `productgroup` (`id`) ON UPDATE CASCADE;

ALTER TABLE `purchase`
  ADD CONSTRAINT `purchase_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchase_ibfk_2` FOREIGN KEY (`purchaser`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchase_ibfk_3` FOREIGN KEY (`supplierid`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchase_ibfk_4` FOREIGN KEY (`shipment`) REFERENCES `shipments` (`id`) ON UPDATE CASCADE;

ALTER TABLE `purchasedetail`
  ADD CONSTRAINT `purchasedetail_ibfk_1` FOREIGN KEY (`purchaseid`) REFERENCES `purchase` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchasedetail_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchasedetail_ibfk_3` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchasedetail_ibfk_4` FOREIGN KEY (`taxid`) REFERENCES `taxes` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchasedetail_ibfk_5` FOREIGN KEY (`purchaseidref`) REFERENCES `purchase` (`purchaseid`) ON UPDATE CASCADE;

ALTER TABLE `purchaseexpenses`
  ADD CONSTRAINT `purchaseexpenses_ibfk_1` FOREIGN KEY (`purchaseexpacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `purchaseexpensesdetail`
  ADD CONSTRAINT `purchaseexpensesdetail_ibfk_1` FOREIGN KEY (`purchaseidref`) REFERENCES `purchase` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseexpensesdetail_ibfk_2` FOREIGN KEY (`purchaseexpid`) REFERENCES `purchaseexpenses` (`id`) ON UPDATE CASCADE;

ALTER TABLE `purchaseextratax`
  ADD CONSTRAINT `purchaseextratax_ibfk_1` FOREIGN KEY (`purchaseid`) REFERENCES `purchase` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseextratax_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseextratax_ibfk_3` FOREIGN KEY (`taxid`) REFERENCES `taxes` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseextratax_ibfk_4` FOREIGN KEY (`purchaseidref`) REFERENCES `purchase` (`purchaseid`) ON UPDATE CASCADE;

ALTER TABLE `purchaseorder`
  ADD CONSTRAINT `purchaseorder_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseorder_ibfk_2` FOREIGN KEY (`purchaser`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseorder_ibfk_3` FOREIGN KEY (`supplierid`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseorder_ibfk_4` FOREIGN KEY (`shipment`) REFERENCES `shipments` (`id`) ON UPDATE CASCADE;

ALTER TABLE `purchaseorderdetail`
  ADD CONSTRAINT `purchaseorderdetail_ibfk_1` FOREIGN KEY (`purchaseid`) REFERENCES `purchaseorder` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseorderdetail_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseorderdetail_ibfk_3` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseorderdetail_ibfk_4` FOREIGN KEY (`taxid`) REFERENCES `taxes` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseorderdetail_ibfk_5` FOREIGN KEY (`purchaseidref`) REFERENCES `purchaseorder` (`purchaseid`) ON UPDATE CASCADE;

ALTER TABLE `purchaseorderexpensesdetail`
  ADD CONSTRAINT `purchaseorderexpensesdetail_ibfk_1` FOREIGN KEY (`purchaseidref`) REFERENCES `purchaseorder` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseorderexpensesdetail_ibfk_2` FOREIGN KEY (`purchaseexpid`) REFERENCES `purchaseexpenses` (`id`) ON UPDATE CASCADE;

ALTER TABLE `purchaseorderextratax`
  ADD CONSTRAINT `purchaseorderextratax_ibfk_1` FOREIGN KEY (`purchaseid`) REFERENCES `purchaseorder` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseorderextratax_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseorderextratax_ibfk_3` FOREIGN KEY (`taxid`) REFERENCES `taxes` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseorderextratax_ibfk_4` FOREIGN KEY (`purchaseidref`) REFERENCES `purchaseorder` (`purchaseid`) ON UPDATE CASCADE;

ALTER TABLE `purchaseorderpayments`
  ADD CONSTRAINT `purchaseorderpayments_ibfk_1` FOREIGN KEY (`purchaseidref`) REFERENCES `purchaseorder` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchaseorderpayments_ibfk_2` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `purchaseorderpoint`
  ADD CONSTRAINT `FK_purchaseorderpoint_1` FOREIGN KEY (`purchaseid`) REFERENCES `purchase` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_purchaseorderpoint_2` FOREIGN KEY (`purchaseidref`) REFERENCES `purchase` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_purchaseorderpoint_3` FOREIGN KEY (`supplier`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE;

ALTER TABLE `purchaseorderrewarddetail`
  ADD CONSTRAINT `FK_purchaseorderrewarddetail_1` FOREIGN KEY (`purchaseid`) REFERENCES `purchaseorder` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_purchaseorderrewarddetail_2` FOREIGN KEY (`purchaseidref`) REFERENCES `purchaseorder` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_purchaseorderrewarddetail_3` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_purchaseorderrewarddetail_4` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE;

ALTER TABLE `purchasepayments`
  ADD CONSTRAINT `purchasepayments_ibfk_1` FOREIGN KEY (`purchaseidref`) REFERENCES `purchase` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `purchasepayments_ibfk_2` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `purchasepoint`
  ADD CONSTRAINT `FK_purchasepoint_1` FOREIGN KEY (`purchaseid`) REFERENCES `purchase` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_purchasepoint_2` FOREIGN KEY (`purchaseidref`) REFERENCES `purchase` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_purchasepoint_3` FOREIGN KEY (`supplier`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE;

ALTER TABLE `purchaserewarddetail`
  ADD CONSTRAINT `FK_purchaserewarddetail_1` FOREIGN KEY (`purchaseid`) REFERENCES `purchase` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_purchaserewarddetail_2` FOREIGN KEY (`purchaseidref`) REFERENCES `purchase` (`purchaseid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_purchaserewarddetail_3` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_purchaserewarddetail_4` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE;

ALTER TABLE `receivableadjust`
  ADD CONSTRAINT `receivableadjust_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `receivableadjust_ibfk_2` FOREIGN KEY (`customerid`) REFERENCES `customer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `receivableadjust_ibfk_3` FOREIGN KEY (`expensestype`) REFERENCES `salesexpenses` (`id`) ON UPDATE CASCADE;

ALTER TABLE `receivablepayment`
  ADD CONSTRAINT `receivablepayment_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `receivablepayment_ibfk_2` FOREIGN KEY (`customerid`) REFERENCES `customer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `receivablepayment_ibfk_3` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `rentalreturn`
  ADD CONSTRAINT `rentalreturn_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `rentalreturn_ibfk_2` FOREIGN KEY (`customerid`) REFERENCES `customer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `rentalreturn_ibfk_3` FOREIGN KEY (`salesid`) REFERENCES `sales` (`salesid`) ON UPDATE CASCADE;

ALTER TABLE `rentalreturndetail`
  ADD CONSTRAINT `rentalreturndetail_ibfk_1` FOREIGN KEY (`rentalreturnid`) REFERENCES `rentalreturn` (`transid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `rentalreturndetail_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `rentalreturndetail_ibfk_3` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE;

ALTER TABLE `roles`
  ADD CONSTRAINT `currency_ibfk` FOREIGN KEY (`defaultcurrency`) REFERENCES `currencies` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
  ADD CONSTRAINT `customer_ibfk` FOREIGN KEY (`defaultcustomer`) REFERENCES `customer` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
  ADD CONSTRAINT `departement_ibfk` FOREIGN KEY (`defaultdepartement`) REFERENCES `departement` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
  ADD CONSTRAINT `division_ibfk` FOREIGN KEY (`defaultdivision`) REFERENCES `division` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
  ADD CONSTRAINT `employee_ibfk` FOREIGN KEY (`defaultemployee`) REFERENCES `employee` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
  ADD CONSTRAINT `payment_ibfk` FOREIGN KEY (`defaultpayment`) REFERENCES `paymenttype` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
  ADD CONSTRAINT `salesman_ibfk` FOREIGN KEY (`defaultsalesman`) REFERENCES `salesman` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
  ADD CONSTRAINT `servicedoer_ibfk` FOREIGN KEY (`defaultservicedoer`) REFERENCES `servicedoer` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
  ADD CONSTRAINT `shipment_ibfk` FOREIGN KEY (`defaultshipment`) REFERENCES `shipments` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
  ADD CONSTRAINT `supplier_ibfk` FOREIGN KEY (`defaultsupplier`) REFERENCES `supplier` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE;

ALTER TABLE `salaries`
  ADD CONSTRAINT `salaries_ibfk_1` FOREIGN KEY (`account`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salariesrecord`
  ADD CONSTRAINT `salariesrecord_ibfk_1` FOREIGN KEY (`employeeid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salariesrecord_ibfk_2` FOREIGN KEY (`salaryid`) REFERENCES `salaries` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salarypayments`
  ADD CONSTRAINT `salarypayments_ibfk_1` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salarypayments_ibfk_2` FOREIGN KEY (`employeeid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salarypayments_ibfk_3` FOREIGN KEY (`salaryid`) REFERENCES `salaries` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salarypayments_ibfk_4` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salaryperiod`
  ADD CONSTRAINT `FK_salaryperiod_account` FOREIGN KEY (`accountid`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salaryperiod_ibfk_2` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salaryperioddetail`
  ADD CONSTRAINT `salaryperioddetail_ibfk_1` FOREIGN KEY (`employeeid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salarystructuredetail`
  ADD CONSTRAINT `salarystructuredetail_ibfk_1` FOREIGN KEY (`salarystructure`) REFERENCES `salarystructure` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salarystructuredetail_ibfk_2` FOREIGN KEY (`salaryid`) REFERENCES `salaries` (`id`) ON UPDATE CASCADE;

ALTER TABLE `sales`
  ADD CONSTRAINT `sales_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `sales_ibfk_2` FOREIGN KEY (`salesmanid`) REFERENCES `salesman` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `sales_ibfk_3` FOREIGN KEY (`customerid`) REFERENCES `customer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `sales_ibfk_4` FOREIGN KEY (`shipment`) REFERENCES `shipments` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `sales_ibfk_5` FOREIGN KEY (`billto`) REFERENCES `customer` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesdetail`
  ADD CONSTRAINT `salesdetail_ibfk_1` FOREIGN KEY (`salesid`) REFERENCES `sales` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesdetail_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesdetail_ibfk_3` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesdetail_ibfk_4` FOREIGN KEY (`taxid`) REFERENCES `taxes` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesdetail_ibfk_5` FOREIGN KEY (`salesidref`) REFERENCES `sales` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesdetail_ibfk_6` FOREIGN KEY (`servicedoerid`) REFERENCES `servicedoer` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesexpenses`
  ADD CONSTRAINT `salesexpenses_ibfk_1` FOREIGN KEY (`salesexpacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesexpensesdetail`
  ADD CONSTRAINT `salesexpensesdetail_ibfk_1` FOREIGN KEY (`salesidref`) REFERENCES `sales` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesexpensesdetail_ibfk_2` FOREIGN KEY (`salesexpid`) REFERENCES `salesexpenses` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesextratax`
  ADD CONSTRAINT `salesextratax_ibfk_1` FOREIGN KEY (`salesid`) REFERENCES `sales` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesextratax_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesextratax_ibfk_3` FOREIGN KEY (`taxid`) REFERENCES `taxes` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesextratax_ibfk_4` FOREIGN KEY (`salesidref`) REFERENCES `sales` (`salesid`) ON UPDATE CASCADE;

ALTER TABLE `salesman`
  ADD CONSTRAINT `salesman_ibfk_1` FOREIGN KEY (`salesmangroup`) REFERENCES `salesmangroup` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesman_ibfk_2` FOREIGN KEY (`payablecommacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesman_ibfk_3` FOREIGN KEY (`expensecommacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesmancommperiod`
  ADD CONSTRAINT `salesmancommperiod_ibfk_1` FOREIGN KEY (`salaryid`) REFERENCES `salaries` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesmancommperiod_ibfk_2` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesmancommvarrecords`
  ADD CONSTRAINT `salesmancommvarrecords_ibfk_1` FOREIGN KEY (`periodid`) REFERENCES `salesmancommperiod` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesmandetail`
  ADD CONSTRAINT `salesmandetail_ibfk_1` FOREIGN KEY (`groupid`) REFERENCES `salesman` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesmandetail_ibfk_2` FOREIGN KEY (`salesmanid`) REFERENCES `salesman` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesmangroup`
  ADD CONSTRAINT `salesmangroup_ibfk_1` FOREIGN KEY (`payablecommacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesmangroup_ibfk_2` FOREIGN KEY (`expensecommacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesmanrecorddetail`
  ADD CONSTRAINT `salesmanrecorddetail_ibfk_1` FOREIGN KEY (`salesmanid`) REFERENCES `salesman` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesmanrecorddetail_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesmanrecorddetail_ibfk_3` FOREIGN KEY (`periodid`) REFERENCES `salesmancommperiod` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesmanrecords`
  ADD CONSTRAINT `salesmanrecords_ibfk_1` FOREIGN KEY (`salesmanid`) REFERENCES `salesman` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesmanrecords_ibfk_2` FOREIGN KEY (`periodid`) REFERENCES `salesmancommperiod` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesorder`
  ADD CONSTRAINT `salesorder_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorder_ibfk_2` FOREIGN KEY (`salesmanid`) REFERENCES `salesman` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorder_ibfk_3` FOREIGN KEY (`customerid`) REFERENCES `customer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorder_ibfk_4` FOREIGN KEY (`shipment`) REFERENCES `shipments` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesorderdetail`
  ADD CONSTRAINT `salesorderdetail_ibfk_1` FOREIGN KEY (`salesid`) REFERENCES `salesorder` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorderdetail_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorderdetail_ibfk_3` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorderdetail_ibfk_4` FOREIGN KEY (`taxid`) REFERENCES `taxes` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorderdetail_ibfk_5` FOREIGN KEY (`salesidref`) REFERENCES `salesorder` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorderdetail_ibfk_6` FOREIGN KEY (`servicedoerid`) REFERENCES `servicedoer` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesorderexpensesdetail`
  ADD CONSTRAINT `salesorderexpensesdetail_ibfk_1` FOREIGN KEY (`salesidref`) REFERENCES `salesorder` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorderexpensesdetail_ibfk_2` FOREIGN KEY (`salesexpid`) REFERENCES `salesexpenses` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesorderextratax`
  ADD CONSTRAINT `salesorderextratax_ibfk_1` FOREIGN KEY (`salesid`) REFERENCES `salesorder` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorderextratax_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorderextratax_ibfk_3` FOREIGN KEY (`taxid`) REFERENCES `taxes` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorderextratax_ibfk_4` FOREIGN KEY (`salesidref`) REFERENCES `salesorder` (`salesid`) ON UPDATE CASCADE;

ALTER TABLE `salesorderpayments`
  ADD CONSTRAINT `salesorderpayments_ibfk_1` FOREIGN KEY (`salesidref`) REFERENCES `salesorder` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesorderpayments_ibfk_2` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesorderpoint`
  ADD CONSTRAINT `FK_salesorderpoint_1` FOREIGN KEY (`salesid`) REFERENCES `salesorder` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_salesorderpoint_2` FOREIGN KEY (`salesidref`) REFERENCES `salesorder` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_salesorderpoint_3` FOREIGN KEY (`customer`) REFERENCES `customer` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesorderrewarddetail`
  ADD CONSTRAINT `FK_salesorderrewarddetail_1` FOREIGN KEY (`salesid`) REFERENCES `salesorder` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_salesorderrewarddetail_2` FOREIGN KEY (`salesidref`) REFERENCES `salesorder` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_salesorderrewarddetail_3` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_salesorderrewarddetail_4` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salespayments`
  ADD CONSTRAINT `salespayments_ibfk_1` FOREIGN KEY (`salesidref`) REFERENCES `sales` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salespayments_ibfk_2` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salespoint`
  ADD CONSTRAINT `FK_salespoint_1` FOREIGN KEY (`salesid`) REFERENCES `sales` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_salespoint_2` FOREIGN KEY (`salesidref`) REFERENCES `sales` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_salespoint_3` FOREIGN KEY (`customer`) REFERENCES `customer` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesproductrewardrules`
  ADD CONSTRAINT `salesproductrewardrules_ibfk_1` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `salesproductrewardrules_ibfk_2` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE;

ALTER TABLE `salesrewarddetail`
  ADD CONSTRAINT `FK_salesrewarddetail_1` FOREIGN KEY (`salesid`) REFERENCES `sales` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_salesrewarddetail_2` FOREIGN KEY (`salesidref`) REFERENCES `sales` (`salesid`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_salesrewarddetail_3` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_salesrewarddetail_4` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolclass`
  ADD CONSTRAINT `FK_schoolclass_schoollevel` FOREIGN KEY (`schoollevel`) REFERENCES `schoollevel` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolextrascore`
  ADD CONSTRAINT `FK_schoolextrascore_schoolextrascoregroup` FOREIGN KEY (`extrascoregroup`) REFERENCES `schoolextrascoregroup` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoollesson`
  ADD CONSTRAINT `FK_schoollesson_schoollessongroup` FOREIGN KEY (`lessongroup`) REFERENCES `schoollessongroup` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoollesson_schoolscoringtype` FOREIGN KEY (`scoringtype`) REFERENCES `schoolscoringtype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoollessonclass`
  ADD CONSTRAINT `FK_schoollessonclass_schoollesson` FOREIGN KEY (`schoollesson`) REFERENCES `schoollesson` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoollessonclass_schoolsubclass` FOREIGN KEY (`schoolsubclass`) REFERENCES `schoolsubclass` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoollessonclass_schoolteacher` FOREIGN KEY (`schoolteacher`) REFERENCES `schoolteacher` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoollessonteacher`
  ADD CONSTRAINT `FK_schoollessonteacher_schoollesson` FOREIGN KEY (`schoollesson`) REFERENCES `schoollesson` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoollessonteacher_schoolsubclass` FOREIGN KEY (`schoolsubclass`) REFERENCES `schoolsubclass` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoollessonteacher_schoolteacher` FOREIGN KEY (`schoolteacher`) REFERENCES `schoolteacher` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoollevel`
  ADD CONSTRAINT `FK_schoollevel_schoolteacher` FOREIGN KEY (`headmaster`) REFERENCES `schoolteacher` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolpayment`
  ADD CONSTRAINT `FK_schoolpayment_account` FOREIGN KEY (`unearnedrevenueacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolpayment_account_2` FOREIGN KEY (`paymentdiscacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolpayment_receivable` FOREIGN KEY (`receivableacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolpayment_revenue` FOREIGN KEY (`revenueacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolpayment_schoolpaymentgroup` FOREIGN KEY (`paymentgroup`) REFERENCES `schoolpaymentgroup` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolpaymentpackagedetail`
  ADD CONSTRAINT `FK_schoolpaymentpackagedetail_schoolpayment` FOREIGN KEY (`schoolpayment`) REFERENCES `schoolpayment` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolpaymentpackagedetail_schoolpaymentpackage` FOREIGN KEY (`schoolpaymentpackage`) REFERENCES `schoolpaymentpackage` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolscoringtyperange`
  ADD CONSTRAINT `FK_schoolscoringtyperange_schoolscoringtype` FOREIGN KEY (`schoolscoringtype`) REFERENCES `schoolscoringtype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolstudent`
  ADD CONSTRAINT `FK_schoolstudent_schoolclass` FOREIGN KEY (`schoolclass`) REFERENCES `schoolclass` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudent_schoolstudentdorm` FOREIGN KEY (`dorm`) REFERENCES `schoolstudentdorm` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudent_schoolstudentstatus` FOREIGN KEY (`status`) REFERENCES `schoolstudentstatus` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudent_schoolsubclass` FOREIGN KEY (`schoolsubclass`) REFERENCES `schoolsubclass` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolstudentdorm`
  ADD CONSTRAINT `FK_schoolstudentdorm_schoolteacher` FOREIGN KEY (`dormheadmaster`) REFERENCES `schoolteacher` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolstudentpayment`
  ADD CONSTRAINT `FK_schoolstudentpayment_division` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentpayment_paymenttype` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentpayment_schoolstudent` FOREIGN KEY (`schoolstudent`) REFERENCES `schoolstudent` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentpayment_schoolsubclass` FOREIGN KEY (`schoolsubclass`) REFERENCES `schoolsubclass` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolstudentpaymentdetail`
  ADD CONSTRAINT `FK_schoolstudentpaymentdetail_schoolpayment` FOREIGN KEY (`schoolpayment`) REFERENCES `schoolpayment` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentpaymentdetail_schoolstudent` FOREIGN KEY (`schoolstudent`) REFERENCES `schoolstudent` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentpaymentdetail_schoolstudentpayment` FOREIGN KEY (`parent`) REFERENCES `schoolstudentpayment` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentpaymentdetail_schoolsubclass` FOREIGN KEY (`schoolsubclass`) REFERENCES `schoolsubclass` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolstudentpaymentschedule`
  ADD CONSTRAINT `FK_schoolstudentpaymentschedule_division` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentpaymentschedule_schoolpaymentpackage` FOREIGN KEY (`schoolpaymentpackage`) REFERENCES `schoolpaymentpackage` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentpaymentschedule_schoolstudent` FOREIGN KEY (`schoolstudent`) REFERENCES `schoolstudent` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentpaymentschedule_schoolsubclass` FOREIGN KEY (`schoolsubclass`) REFERENCES `schoolsubclass` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolstudentscore`
  ADD CONSTRAINT `FK_schoolstudentscore_schoolexam` FOREIGN KEY (`schoolexam`) REFERENCES `schoolexam` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentscore_schoollesson` FOREIGN KEY (`schoollesson`) REFERENCES `schoollesson` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentscore_schoolperiod` FOREIGN KEY (`schoolperiod`) REFERENCES `schoolperiod` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentscore_schoolscoringtype` FOREIGN KEY (`scoringtype`) REFERENCES `schoolscoringtype` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentscore_schoolsubclass` FOREIGN KEY (`schoolsubclass`) REFERENCES `schoolsubclass` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentscore_schoolteacher` FOREIGN KEY (`schoolteacher`) REFERENCES `schoolteacher` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolstudentscoredetail`
  ADD CONSTRAINT `FK_schoolstudentscoredetail_schoolexam` FOREIGN KEY (`schoolexam`) REFERENCES `schoolexam` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentscoredetail_schoollesson` FOREIGN KEY (`schoollesson`) REFERENCES `schoollesson` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentscoredetail_schoolperiod` FOREIGN KEY (`schoolperiod`) REFERENCES `schoolperiod` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentscoredetail_schoolstudent` FOREIGN KEY (`schoolstudent`) REFERENCES `schoolstudent` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentscoredetail_schoolstudentscore` FOREIGN KEY (`schoolstudentscore`) REFERENCES `schoolstudentscore` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentscoredetail_schoolsubclass` FOREIGN KEY (`schoolsubclass`) REFERENCES `schoolsubclass` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentscoredetail_schoolteacher` FOREIGN KEY (`schoolteacher`) REFERENCES `schoolteacher` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentscoredetail_scoringtype` FOREIGN KEY (`scoringtype`) REFERENCES `schoolscoringtype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolstudentsextrascore`
  ADD CONSTRAINT `FK_schoolstudentsextrascore_schoolexam` FOREIGN KEY (`schoolexam`) REFERENCES `schoolexam` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascore_schoolextrascore` FOREIGN KEY (`schoolextrascore`) REFERENCES `schoolextrascore` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascore_schoolextrascoregroup` FOREIGN KEY (`schoolextrascoregroup`) REFERENCES `schoolextrascoregroup` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascore_schoolperiod` FOREIGN KEY (`schoolperiod`) REFERENCES `schoolperiod` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascore_schoolscoringtype` FOREIGN KEY (`scoringtype`) REFERENCES `schoolscoringtype` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascore_schoolsubclass` FOREIGN KEY (`schoolsubclass`) REFERENCES `schoolsubclass` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascore_schoolteacher` FOREIGN KEY (`schoolteacher`) REFERENCES `schoolteacher` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolstudentsextrascoredetail`
  ADD CONSTRAINT `FK_schoolstudentsextrascoredetail_schoolexam` FOREIGN KEY (`schoolexam`) REFERENCES `schoolexam` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascoredetail_schoolextrascore` FOREIGN KEY (`schoolextrascore`) REFERENCES `schoolextrascore` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascoredetail_schoolperiod` FOREIGN KEY (`schoolperiod`) REFERENCES `schoolperiod` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascoredetail_schoolstudent` FOREIGN KEY (`schoolstudent`) REFERENCES `schoolstudent` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascoredetail_schoolstudentsextrascore` FOREIGN KEY (`schoolstudentsextrascore`) REFERENCES `schoolstudentsextrascore` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascoredetail_schoolsubclass` FOREIGN KEY (`schoolsubclass`) REFERENCES `schoolsubclass` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascoredetail_schoolteacher` FOREIGN KEY (`schoolteacher`) REFERENCES `schoolteacher` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstudentsextrascoredetail_scoringtype` FOREIGN KEY (`scoringtype`) REFERENCES `schoolscoringtype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolstupaymentscheduledetail`
  ADD CONSTRAINT `FK_schoolstupaymentscheddetail_schoolpayment` FOREIGN KEY (`schoolpayment`) REFERENCES `schoolpayment` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstupaymentscheddetail_schoolstudent` FOREIGN KEY (`schoolstudent`) REFERENCES `schoolstudent` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolstupaymentscheddetail_schoolsubclass` FOREIGN KEY (`schoolsubclass`) REFERENCES `schoolsubclass` (`id`) ON UPDATE CASCADE;

ALTER TABLE `schoolsubclass`
  ADD CONSTRAINT `FK_schoolsubclass_schoolclass` FOREIGN KEY (`schoolclass`) REFERENCES `schoolclass` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_schoolsubclass_schoolteacher` FOREIGN KEY (`homeroomteacher`) REFERENCES `schoolteacher` (`id`) ON UPDATE CASCADE;

ALTER TABLE `servicedoer`
  ADD CONSTRAINT `servicedoer_ibfk_1` FOREIGN KEY (`servicedoergroup`) REFERENCES `servicedoergroup` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `servicedoer_ibfk_2` FOREIGN KEY (`payablecommacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `servicedoer_ibfk_3` FOREIGN KEY (`expensecommacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `servicedoercommperiod`
  ADD CONSTRAINT `servicedoercommperiod_ibfk_1` FOREIGN KEY (`salaryid`) REFERENCES `salaries` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `servicedoercommperiod_ibfk_2` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE;

ALTER TABLE `servicedoercommvarrecords`
  ADD CONSTRAINT `servicedoercommvarrecords_ibfk_1` FOREIGN KEY (`periodid`) REFERENCES `servicedoercommperiod` (`id`) ON UPDATE CASCADE;

ALTER TABLE `servicedoerdetail`
  ADD CONSTRAINT `servicedoerdetail_ibfk_1` FOREIGN KEY (`groupid`) REFERENCES `servicedoer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `servicedoerdetail_ibfk_2` FOREIGN KEY (`servicedoerid`) REFERENCES `servicedoer` (`id`) ON UPDATE CASCADE;

ALTER TABLE `servicedoergroup`
  ADD CONSTRAINT `servicedoergroup_ibfk_1` FOREIGN KEY (`payablecommacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `servicedoergroup_ibfk_2` FOREIGN KEY (`expensecommacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `servicedoerrecorddetail`
  ADD CONSTRAINT `servicedoerrecorddetail_ibfk_1` FOREIGN KEY (`servicedoerid`) REFERENCES `servicedoer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `servicedoerrecorddetail_ibfk_2` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `servicedoerrecorddetail_ibfk_3` FOREIGN KEY (`periodid`) REFERENCES `servicedoercommperiod` (`id`) ON UPDATE CASCADE;

ALTER TABLE `servicedoerrecords`
  ADD CONSTRAINT `servicedoerrecords_ibfk_1` FOREIGN KEY (`servicedoerid`) REFERENCES `servicedoer` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `servicedoerrecords_ibfk_2` FOREIGN KEY (`periodid`) REFERENCES `servicedoercommperiod` (`id`) ON UPDATE CASCADE;

ALTER TABLE `slidedata`
  ADD CONSTRAINT `FK_slidedata_slide` FOREIGN KEY (`slideid`) REFERENCES `customerdisplay` (`id`) ON UPDATE CASCADE;

ALTER TABLE `slideelements`
  ADD CONSTRAINT `FK_slideelements_slidedata` FOREIGN KEY (`slidedataid`) REFERENCES `slidedata` (`id`) ON UPDATE CASCADE;

ALTER TABLE `supplier`
  ADD CONSTRAINT `supplier_ibfk_1` FOREIGN KEY (`suppliergroup`) REFERENCES `suppliergroup` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `supplier_ibfk_2` FOREIGN KEY (`payableacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `supplier_ibfk_3` FOREIGN KEY (`rewardacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `supplier_ibfk_4` FOREIGN KEY (`purchasediscacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `supplier_ibfk_5` FOREIGN KEY (`gainlosspayableacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `supplier_ibfk_6` FOREIGN KEY (`accruedpayableacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `supplierbalance`
  ADD CONSTRAINT `FK_supplierbalance_division` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `supplierbalance_ibfk_1` FOREIGN KEY (`supplierid`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE;

ALTER TABLE `supplierdp`
  ADD CONSTRAINT `supplierdp_ibfk_1` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `supplierdp_ibfk_2` FOREIGN KEY (`supplierid`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `supplierdp_ibfk_3` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `supplierdp_ibfk_4` FOREIGN KEY (`downpaymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `suppliergiro`
  ADD CONSTRAINT `suppliergiro_ibfk_1` FOREIGN KEY (`supplierid`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `suppliergiro_ibfk_2` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `suppliergiro_ibfk_3` FOREIGN KEY (`paymenttype`) REFERENCES `paymenttype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `suppliergroup`
  ADD CONSTRAINT `suppliergroup_ibfk_1` FOREIGN KEY (`payableacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `suppliergroup_ibfk_3` FOREIGN KEY (`rewardacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `suppliergroup_ibfk_4` FOREIGN KEY (`purchasediscacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `suppliergroup_ibfk_5` FOREIGN KEY (`gainlosspayableacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `suppliergroup_ibfk_6` FOREIGN KEY (`accruedpayableacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `tableroles`
  ADD CONSTRAINT `FK_tableroles_roles` FOREIGN KEY (`roles`) REFERENCES `roles` (`id`) ON UPDATE CASCADE;

ALTER TABLE `taxes`
  ADD CONSTRAINT `taxes_ibfk_1` FOREIGN KEY (`taxoutacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `taxes_ibfk_2` FOREIGN KEY (`taxinacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `trackemployee`
  ADD CONSTRAINT `FK_trackemployee_attendance` FOREIGN KEY (`attendanceid`) REFERENCES `attendance` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_trackemployee_employee` FOREIGN KEY (`employeeid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE;

ALTER TABLE `units`
  ADD CONSTRAINT `productunit_ibfk_1` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE;

ALTER TABLE `vehicle`
  ADD CONSTRAINT `fk_vehicle_departement` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehicle_division` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehicle_driver` FOREIGN KEY (`defaultdriverid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehicle_fueltype` FOREIGN KEY (`fueltypeid`) REFERENCES `vehiclefueltype` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehicle_model` FOREIGN KEY (`modelid`) REFERENCES `vehiclemodel` (`id`) ON UPDATE CASCADE;

ALTER TABLE `vehicledocument`
  ADD CONSTRAINT `fk_vehicledocument_vehicle` FOREIGN KEY (`vehicleid`) REFERENCES `vehicle` (`id`) ON UPDATE CASCADE;

ALTER TABLE `vehiclefuellog`
  ADD CONSTRAINT `fk_vehiclefuellog_departement` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclefuellog_division` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclefuellog_driver` FOREIGN KEY (`driverid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclefuellog_fueltype` FOREIGN KEY (`fueltypeid`) REFERENCES `vehiclefueltype` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclefuellog_tripid` FOREIGN KEY (`tripid`) REFERENCES `vehicletrip` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclefuellog_vehicle` FOREIGN KEY (`vehicleid`) REFERENCES `vehicle` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclefuellog_vendor` FOREIGN KEY (`vendorid`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE;

ALTER TABLE `vehiclefueltype`
  ADD CONSTRAINT `FK_vehiclefueltype_expenseacc` FOREIGN KEY (`expenseacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_vehiclefueltype_product` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE;

ALTER TABLE `vehiclemaintenance`
  ADD CONSTRAINT `fk_vehiclemaintenance_category` FOREIGN KEY (`categoryid`) REFERENCES `vehiclemaintenancecategory` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclemaintenance_departement` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclemaintenance_division` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclemaintenance_requestedby` FOREIGN KEY (`requestedby`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclemaintenance_vehicle` FOREIGN KEY (`vehicleid`) REFERENCES `vehicle` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclemaintenance_vendor` FOREIGN KEY (`vendorid`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE;

ALTER TABLE `vehiclemaintenancecategory`
  ADD CONSTRAINT `FK_vehiclemaintenancecategory_account` FOREIGN KEY (`expenseacc`) REFERENCES `account` (`id`) ON UPDATE CASCADE;

ALTER TABLE `vehiclemaintenancepart`
  ADD CONSTRAINT `FK_vehiclemaintenancepart_vehiclemaintenance` FOREIGN KEY (`maintenanceid`) REFERENCES `vehiclemaintenance` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclemaintenancepart_product` FOREIGN KEY (`productid`) REFERENCES `product` (`id`) ON UPDATE CASCADE;

ALTER TABLE `vehiclemodel`
  ADD CONSTRAINT `fk_vehiclemodel_brand` FOREIGN KEY (`brandid`) REFERENCES `vehiclebrand` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclemodel_fueltype` FOREIGN KEY (`defaultfueltypeid`) REFERENCES `vehiclefueltype` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehiclemodel_type` FOREIGN KEY (`vehicletypeid`) REFERENCES `vehicletype` (`id`) ON UPDATE CASCADE;

ALTER TABLE `vehicletrip`
  ADD CONSTRAINT `fk_vehicletrip_departement` FOREIGN KEY (`departement`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehicletrip_division` FOREIGN KEY (`division`) REFERENCES `division` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehicletrip_driver` FOREIGN KEY (`driverid`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehicletrip_fueltypeid` FOREIGN KEY (`fueltypeid`) REFERENCES `vehiclefueltype` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehicletrip_route` FOREIGN KEY (`routeid`) REFERENCES `vehicleroute` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_vehicletrip_vehicle` FOREIGN KEY (`vehicleid`) REFERENCES `vehicle` (`id`) ON UPDATE CASCADE;

