-- GIC Database Backup
-- 2026-09-03 08:04:24


CREATE TABLE `accounts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `balance` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `initial_balance` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `is_primary` tinyint(1) NOT NULL DEFAULT '0',
  `enabled` tinyint(1) NOT NULL DEFAULT '1',
  `dash_order` int DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `accounts_company_id_foreign` (`company_id`),
  KEY `accounts_currency_id_foreign` (`currency_id`),
  KEY `accounts_created_by_foreign` (`created_by`),
  KEY `accounts_updated_by_foreign` (`updated_by`),
  CONSTRAINT `accounts_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `accounts_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `accounts_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `accounts_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `accounts` (`id`, `company_id`, `name`, `number`, `currency_id`, `balance`, `initial_balance`, `description`, `is_primary`, `enabled`, `dash_order`, `created_by`, `updated_by`, `deleted_at`, `created_at`, `updated_at`) VALUES
('3', '1', 'Cash', NULL, NULL, '0.0000', '0.0000', NULL, '1', '1', NULL, NULL, NULL, NULL, '2026-08-30 07:38:16', '2026-08-30 09:30:42'),
('4', '1', 'Bank', NULL, '2', '0.0000', '0.0000', NULL, '0', '1', NULL, NULL, '1', NULL, '2026-08-30 07:38:16', '2026-09-01 09:11:26');

CREATE TABLE `attendances` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `employee_id` bigint unsigned NOT NULL,
  `year` int unsigned NOT NULL,
  `month` int unsigned NOT NULL,
  `official_days` int unsigned NOT NULL DEFAULT '26',
  `present_days` int unsigned NOT NULL DEFAULT '0',
  `absent_days` int unsigned NOT NULL DEFAULT '0',
  `leave_days` int unsigned NOT NULL DEFAULT '0',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `attendances_employee_id_year_month_unique` (`employee_id`,`year`,`month`),
  KEY `attendances_created_by_foreign` (`created_by`),
  KEY `attendances_updated_by_foreign` (`updated_by`),
  KEY `attendances_company_id_year_month_index` (`company_id`,`year`,`month`),
  KEY `attendances_employee_id_year_month_index` (`employee_id`,`year`,`month`),
  CONSTRAINT `attendances_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `attendances_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `attendances_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  CONSTRAINT `attendances_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `attendances` (`id`, `company_id`, `employee_id`, `year`, `month`, `official_days`, `present_days`, `absent_days`, `leave_days`, `notes`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
('1', '1', '1', '2026', '9', '26', '26', '0', '0', NULL, '1', NULL, '2026-09-01 09:06:02', '2026-09-01 09:06:02');

CREATE TABLE `categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned DEFAULT NULL,
  `type` tinyint unsigned NOT NULL DEFAULT '0',
  `name_fa` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `sort_order` int NOT NULL DEFAULT '0',
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `categories_created_by_foreign` (`created_by`),
  KEY `categories_updated_by_foreign` (`updated_by`),
  KEY `categories_company_id_type_is_active_index` (`company_id`,`type`,`is_active`),
  CONSTRAINT `categories_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `categories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `categories_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `categories` (`id`, `company_id`, `type`, `name_fa`, `is_active`, `sort_order`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
('1', '1', '0', 'نمرات فعال', '1', '0', '2', NULL, '2026-08-29 10:54:16', '2026-08-29 10:54:16'),
('2', '1', '0', 'زمین سفید', '1', '1', '1', NULL, '2026-08-31 07:32:19', '2026-08-31 07:32:19'),
('3', '1', '3', 'خرچ روزانه', '1', '0', '1', NULL, '2026-09-01 06:26:47', '2026-09-01 06:26:47');

CREATE TABLE `cities` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `province_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name_pa` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name_en` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `cities_province_id_foreign` (`province_id`),
  KEY `cities_created_by_foreign` (`created_by`),
  KEY `cities_updated_by_foreign` (`updated_by`),
  CONSTRAINT `cities_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `cities_province_id_foreign` FOREIGN KEY (`province_id`) REFERENCES `states` (`id`) ON DELETE SET NULL,
  CONSTRAINT `cities_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `companies` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `name_fa` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `logo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date_format` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'm',
  `locale` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'fa',
  `enabled` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `companies` (`id`, `name`, `name_fa`, `email`, `phone`, `address`, `logo`, `date_format`, `locale`, `enabled`, `created_at`, `updated_at`) VALUES
('1', 'Green Industrial Co', 'شرکت صنایع سبز', NULL, NULL, NULL, NULL, 'm', 'fa', '1', '2026-08-26 10:13:33', '2026-08-26 10:13:33');

CREATE TABLE `contract_payments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `contract_id` bigint unsigned NOT NULL,
  `company_id` bigint unsigned NOT NULL,
  `amount` decimal(15,4) NOT NULL,
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `payment_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reference` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `receipt_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `contract_payments_account_id_foreign` (`account_id`),
  KEY `contract_payments_created_by_foreign` (`created_by`),
  KEY `contract_payments_updated_by_foreign` (`updated_by`),
  KEY `contract_payments_contract_id_index` (`contract_id`),
  KEY `contract_payments_company_id_index` (`company_id`),
  CONSTRAINT `contract_payments_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `contract_payments_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `contract_payments_contract_id_foreign` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`id`) ON DELETE CASCADE,
  CONSTRAINT `contract_payments_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `contract_payments_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `contracts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `company_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `number_jawaz` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `contract_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `category_id` bigint unsigned DEFAULT NULL,
  `phase_id` bigint unsigned DEFAULT NULL,
  `total` decimal(15,4) DEFAULT NULL,
  `paid` decimal(15,4) DEFAULT NULL,
  `retention_amount` decimal(15,4) DEFAULT NULL,
  `penalty_amount` decimal(15,4) DEFAULT NULL,
  `progress` smallint unsigned DEFAULT NULL COMMENT '0-100 percent',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `contracts_company_id_foreign` (`company_id`),
  KEY `contracts_currency_id_foreign` (`currency_id`),
  KEY `contracts_created_by_foreign` (`created_by`),
  KEY `contracts_updated_by_foreign` (`updated_by`),
  KEY `contracts_category_id_foreign` (`category_id`),
  KEY `contracts_phase_id_foreign` (`phase_id`),
  CONSTRAINT `contracts_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL,
  CONSTRAINT `contracts_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `contracts_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `contracts_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `contracts_phase_id_foreign` FOREIGN KEY (`phase_id`) REFERENCES `phases` (`id`) ON DELETE SET NULL,
  CONSTRAINT `contracts_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `currencies` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `symbol` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_primary` tinyint(1) NOT NULL DEFAULT '0',
  `rate` decimal(15,8) NOT NULL DEFAULT '1.00000000',
  `enabled` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `currencies_company_id_code_unique` (`company_id`,`code`),
  CONSTRAINT `currencies_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `currencies` (`id`, `company_id`, `name`, `code`, `symbol`, `is_primary`, `rate`, `enabled`, `created_at`, `updated_at`) VALUES
('1', '1', 'Afghani', 'AFN', '؋', '0', '1.00000000', '1', '2026-08-26 10:13:35', '2026-09-01 06:45:01'),
('2', '1', 'US Dollar', 'USD', '$', '1', '1.00000000', '1', '2026-08-26 10:13:35', '2026-09-01 06:45:01');

CREATE TABLE `customer_histories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned DEFAULT NULL,
  `land_id` bigint unsigned DEFAULT NULL,
  `customer_id` bigint unsigned DEFAULT NULL,
  `old_customer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `customer_histories_company_id_foreign` (`company_id`),
  KEY `customer_histories_customer_id_foreign` (`customer_id`),
  KEY `customer_histories_created_by_foreign` (`created_by`),
  KEY `customer_histories_updated_by_foreign` (`updated_by`),
  CONSTRAINT `customer_histories_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `customer_histories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `customer_histories_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `customer_histories_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `customer_histories` (`id`, `company_id`, `land_id`, `customer_id`, `old_customer`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
('1', '1', '3', '2', '1', '2', NULL, '2026-08-29 09:21:50', '2026-08-29 09:21:50'),
('2', '1', '10', '2', '3', '1', NULL, '2026-08-31 10:01:07', '2026-08-31 10:01:07');

CREATE TABLE `customers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `name_org` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `jawaz_org` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address_org` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `website` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `discount` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `gf_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `father_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tazkira` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `perment_province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `current_province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sector_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `perment_city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `current_city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `perment_valege` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `current_valege` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `prev_balance` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `customers_company_id_foreign` (`company_id`),
  KEY `customers_currency_id_foreign` (`currency_id`),
  KEY `customers_created_by_foreign` (`created_by`),
  KEY `customers_updated_by_foreign` (`updated_by`),
  CONSTRAINT `customers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `customers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `customers_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `customers_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `customers` (`id`, `company_id`, `name`, `name_org`, `jawaz_org`, `address_org`, `email`, `phone`, `address`, `website`, `discount`, `gf_name`, `father_name`, `tazkira`, `perment_province`, `current_province`, `sector_type`, `perment_city`, `current_city`, `perment_valege`, `current_valege`, `prev_balance`, `date`, `image`, `currency_id`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
('1', '1', 'Mohammad Rahimi', NULL, NULL, NULL, 'rahimi@example.com', '0700111222', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Kabul', NULL, NULL, NULL, NULL, NULL, '0.0000', NULL, NULL, NULL, NULL, NULL, '2026-08-26 10:13:36', '2026-08-26 10:13:36'),
('2', '1', 'Ahmad Walid', NULL, NULL, NULL, 'walid@example.com', '0799333444', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Kabul', NULL, NULL, NULL, NULL, NULL, '0.0000', NULL, NULL, NULL, NULL, NULL, '2026-08-26 10:13:36', '2026-08-26 10:13:36'),
('3', '1', 'لطیف حاتمی', NULL, '۱۲', 'دشت برچی', NULL, '2345678', 'دشت برچی', NULL, NULL, 'علی', 'سخی', '12334455', 'بامیان', 'کابل', NULL, 'شیبر', 'سیزدهم', 'شنبل', 'شفاخانه', '0.0000', '1405-06-09', NULL, '2', '1', '1', '2026-08-31 08:42:50', '2026-08-31 08:43:41');

CREATE TABLE `employees` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `father_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `grand_father_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tazkira` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `current_province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `position` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `qualification` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `salary` decimal(15,4) DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint unsigned NOT NULL DEFAULT '0',
  `join_date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `employees_company_id_foreign` (`company_id`),
  KEY `employees_currency_id_foreign` (`currency_id`),
  KEY `employees_created_by_foreign` (`created_by`),
  KEY `employees_updated_by_foreign` (`updated_by`),
  CONSTRAINT `employees_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `employees_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `employees_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `employees_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `employees` (`id`, `company_id`, `name`, `father_name`, `grand_father_name`, `tazkira`, `province`, `current_province`, `email`, `phone`, `address`, `position`, `qualification`, `salary`, `currency_id`, `type`, `status`, `join_date`, `image`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
('1', '1', 'hussain', 'abd hassan', 'sah', '23456', 'bamyan', 'kabul', 'hussainkhk408@gmail.com', '09987666788', 'barchi', 'manager', 'csc', '200.0000', '2', NULL, '0', '1405-06-10', NULL, '1', NULL, '2026-09-01 08:53:16', '2026-09-01 08:53:16');

CREATE TABLE `expenses` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `month` int unsigned NOT NULL,
  `year` int unsigned NOT NULL,
  `type_id` bigint unsigned DEFAULT NULL,
  `photo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `amount` decimal(15,4) DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `project_id` bigint unsigned DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `expenses_company_id_foreign` (`company_id`),
  KEY `expenses_currency_id_foreign` (`currency_id`),
  KEY `expenses_project_id_foreign` (`project_id`),
  KEY `expenses_account_id_foreign` (`account_id`),
  KEY `expenses_created_by_foreign` (`created_by`),
  KEY `expenses_updated_by_foreign` (`updated_by`),
  KEY `expenses_type_id_foreign` (`type_id`),
  CONSTRAINT `expenses_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `expenses_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `expenses_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `expenses_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `expenses_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE SET NULL,
  CONSTRAINT `expenses_type_id_foreign` FOREIGN KEY (`type_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL,
  CONSTRAINT `expenses_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `expenses` (`id`, `company_id`, `by`, `description`, `month`, `year`, `type_id`, `photo`, `amount`, `currency_id`, `project_id`, `account_id`, `date`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
('1', '1', 'super admin', NULL, '9', '2026', '3', NULL, '10.0000', '2', NULL, '4', '1405-06-10', '1', NULL, '2026-09-01 06:27:26', '2026-09-01 06:27:26');

CREATE TABLE `income` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `amount` decimal(15,4) DEFAULT NULL,
  `photo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `year` int unsigned NOT NULL,
  `month` int unsigned NOT NULL,
  `type_id` bigint unsigned DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `currency_rate` decimal(11,2) DEFAULT NULL,
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `machine_id` bigint unsigned DEFAULT NULL,
  `customer_id` bigint unsigned DEFAULT NULL,
  `serial_no` int unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `income_company_id_foreign` (`company_id`),
  KEY `income_account_id_foreign` (`account_id`),
  KEY `income_currency_id_foreign` (`currency_id`),
  KEY `income_machine_id_foreign` (`machine_id`),
  KEY `income_customer_id_foreign` (`customer_id`),
  KEY `income_created_by_foreign` (`created_by`),
  KEY `income_updated_by_foreign` (`updated_by`),
  KEY `income_type_id_foreign` (`type_id`),
  CONSTRAINT `income_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `income_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `income_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `income_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `income_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `income_machine_id_foreign` FOREIGN KEY (`machine_id`) REFERENCES `machines` (`id`) ON DELETE SET NULL,
  CONSTRAINT `income_type_id_foreign` FOREIGN KEY (`type_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL,
  CONSTRAINT `income_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `income` (`id`, `company_id`, `by`, `description`, `amount`, `photo`, `year`, `month`, `type_id`, `account_id`, `currency_id`, `currency_rate`, `date`, `machine_id`, `customer_id`, `serial_no`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
('3', '1', 'excavator', 'درآمد ماشین: excavator', '10880.0000', NULL, '1405', '6', NULL, '3', '2', '1.00', '1405-06-10', '1', NULL, NULL, '1', NULL, '2026-09-01 09:41:47', '2026-09-01 09:42:30');

CREATE TABLE `income_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `tax` decimal(5,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `income_types` (`id`, `name`, `tax`, `created_at`, `updated_at`) VALUES
('1', 'Land Sale', '0.00', '2026-08-26 10:13:36', '2026-08-26 10:13:36'),
('2', 'Utilities', '0.00', '2026-08-26 10:13:36', '2026-08-26 10:13:36'),
('3', 'Rent', '0.00', '2026-08-26 10:13:36', '2026-08-26 10:13:36'),
('4', 'Other', '0.00', '2026-08-26 10:13:36', '2026-08-26 10:13:36');

CREATE TABLE `invoice_customers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `invoice_id` bigint unsigned NOT NULL,
  `customer_id` bigint unsigned DEFAULT NULL,
  `percentage` decimal(5,2) NOT NULL DEFAULT '100.00',
  `amount` decimal(15,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `invoice_customers_invoice_id_foreign` (`invoice_id`),
  KEY `invoice_customers_customer_id_foreign` (`customer_id`),
  CONSTRAINT `invoice_customers_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoice_customers_invoice_id_foreign` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `invoice_customers` (`id`, `invoice_id`, `customer_id`, `percentage`, `amount`, `created_at`, `updated_at`) VALUES
('5', '5', '3', '100.00', '4000.00', '2026-08-31 08:45:56', '2026-08-31 08:45:56'),
('6', '6', '3', '100.00', '230.00', '2026-08-31 08:57:50', '2026-08-31 08:57:50'),
('7', '7', '2', '100.00', '230.00', '2026-08-31 10:01:07', '2026-08-31 10:01:07'),
('8', '8', '2', '100.00', '235.00', '2026-09-01 05:12:13', '2026-09-01 05:12:13');

CREATE TABLE `invoice_givebacks` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `invoice_id` bigint unsigned NOT NULL,
  `item_id` bigint unsigned DEFAULT NULL,
  `quantity` decimal(15,2) NOT NULL DEFAULT '0.00',
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `price` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `invoice_givebacks_company_id_foreign` (`company_id`),
  KEY `invoice_givebacks_invoice_id_foreign` (`invoice_id`),
  KEY `invoice_givebacks_created_by_foreign` (`created_by`),
  KEY `invoice_givebacks_updated_by_foreign` (`updated_by`),
  CONSTRAINT `invoice_givebacks_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoice_givebacks_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoice_givebacks_invoice_id_foreign` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoice_givebacks_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `invoice_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `invoice_id` bigint unsigned NOT NULL,
  `item_id` bigint unsigned DEFAULT NULL,
  `quantity` decimal(15,7) NOT NULL DEFAULT '1.0000000',
  `unit_id` bigint unsigned DEFAULT NULL,
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `price` decimal(20,4) DEFAULT NULL,
  `totals` decimal(20,4) DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `invoice_items_company_id_foreign` (`company_id`),
  KEY `invoice_items_invoice_id_foreign` (`invoice_id`),
  KEY `invoice_items_unit_id_foreign` (`unit_id`),
  KEY `invoice_items_created_by_foreign` (`created_by`),
  KEY `invoice_items_updated_by_foreign` (`updated_by`),
  CONSTRAINT `invoice_items_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoice_items_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoice_items_invoice_id_foreign` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoice_items_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoice_items_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `invoice_items` (`id`, `company_id`, `invoice_id`, `item_id`, `quantity`, `unit_id`, `date`, `price`, `totals`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
('5', '1', '5', '9', '2.0000000', NULL, '1405-06-09', '2000.0000', '4000.0000', '1', NULL, '2026-08-31 08:45:56', '2026-08-31 08:45:56'),
('6', '1', '6', '10', '0.1150000', NULL, '1405-06-09', '2000.0000', '230.0000', '1', NULL, '2026-08-31 08:57:50', '2026-08-31 08:57:50'),
('7', '1', '7', '10', '0.1150000', NULL, '1405-06-09', '2000.0000', '230.0000', '1', NULL, '2026-08-31 10:01:07', '2026-08-31 10:01:07'),
('8', '1', '8', '11', '0.1175000', '4', '1405-06-10', '2000.0000', '235.0000', '1', NULL, '2026-09-01 05:12:13', '2026-09-01 05:12:13');

CREATE TABLE `invoice_payments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `invoice_id` bigint unsigned NOT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `paid_at` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `paid_amount` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `commission_amount` decimal(15,4) DEFAULT NULL,
  `currency_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency_rate` decimal(15,8) DEFAULT NULL,
  `symbol` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `payment_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reference` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `installment_number` int unsigned DEFAULT NULL,
  `due_amount` decimal(15,4) DEFAULT NULL,
  `due_date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_percentage` decimal(5,2) DEFAULT NULL,
  `type` tinyint unsigned NOT NULL DEFAULT '1',
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `invoice_payments_company_id_foreign` (`company_id`),
  KEY `invoice_payments_invoice_id_foreign` (`invoice_id`),
  KEY `invoice_payments_account_id_foreign` (`account_id`),
  KEY `invoice_payments_created_by_foreign` (`created_by`),
  KEY `invoice_payments_updated_by_foreign` (`updated_by`),
  CONSTRAINT `invoice_payments_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoice_payments_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoice_payments_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoice_payments_invoice_id_foreign` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoice_payments_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `invoice_payments` (`id`, `company_id`, `invoice_id`, `account_id`, `paid_at`, `paid_amount`, `commission_amount`, `currency_code`, `currency_rate`, `symbol`, `description`, `payment_method`, `reference`, `installment_number`, `due_amount`, `due_date`, `company_percentage`, `type`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
('8', '1', '5', NULL, NULL, '0.0000', '2000.0000', 'USD', '70.00000000', NULL, NULL, NULL, NULL, '1', '2000.0000', '1405-06-10', '100.00', '2', '1', NULL, '2026-08-31 08:45:56', '2026-08-31 08:45:56'),
('9', '1', '5', NULL, NULL, '0.0000', '2000.0000', 'USD', '70.00000000', NULL, NULL, NULL, NULL, '2', '2000.0000', '1405-06-26', '100.00', '2', '1', NULL, '2026-08-31 08:45:56', '2026-08-31 08:45:56'),
('10', '1', '6', '4', '1405-06-09', '230.0000', '230.0000', NULL, '1.00000000', NULL, NULL, NULL, NULL, '1', '0.0000', '1405-06-09', '100.00', '1', '1', NULL, '2026-08-31 08:57:50', '2026-08-31 08:57:50'),
('11', '1', '7', '3', '1405-06-09', '230.0000', '6.9000', 'USD', '70.00000000', NULL, NULL, NULL, NULL, '1', '0.0000', '1405-06-09', '3.00', '1', '1', NULL, '2026-08-31 10:01:07', '2026-08-31 10:01:07'),
('12', '1', '8', '4', '1405-06-10', '235.0000', '235.0000', NULL, '1.00000000', NULL, NULL, NULL, NULL, '1', '0.0000', '1405-06-10', '100.00', '1', '1', NULL, '2026-09-01 05:12:13', '2026-09-01 05:12:13');

CREATE TABLE `invoices` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `customer_id` bigint unsigned DEFAULT NULL,
  `customer_from_id` bigint unsigned DEFAULT NULL,
  `invoice_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `category_id` bigint unsigned DEFAULT NULL,
  `invoice_status_code` tinyint unsigned NOT NULL DEFAULT '0',
  `invoiced_at` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `installment_count` int unsigned DEFAULT NULL,
  `amount` decimal(20,3) DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `discount` decimal(20,3) NOT NULL DEFAULT '0.000',
  `filename` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `east` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `west` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `north` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `south` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `latitude` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `street` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phase_id` bigint unsigned DEFAULT NULL,
  `block` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `girib_area_sold` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `metr_moraba_area_sold` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `price_letters` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sketch` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `length` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `length_girib_area_sold` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `length_metr_moraba_area_sold` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `length_price_letters` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `length_sketch` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` tinyint unsigned NOT NULL DEFAULT '1',
  `province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `city` varchar(122) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `city_id` bigint unsigned DEFAULT NULL,
  `nahia` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type_pay` tinyint unsigned DEFAULT NULL,
  `rate` decimal(15,4) DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `company_per` decimal(5,2) DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `invoices_company_id_foreign` (`company_id`),
  KEY `invoices_customer_id_foreign` (`customer_id`),
  KEY `invoices_customer_from_id_foreign` (`customer_from_id`),
  KEY `invoices_category_id_foreign` (`category_id`),
  KEY `invoices_currency_id_foreign` (`currency_id`),
  KEY `invoices_city_id_foreign` (`city_id`),
  KEY `invoices_created_by_foreign` (`created_by`),
  KEY `invoices_updated_by_foreign` (`updated_by`),
  CONSTRAINT `invoices_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoices_city_id_foreign` FOREIGN KEY (`city_id`) REFERENCES `cities` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoices_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoices_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoices_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoices_customer_from_id_foreign` FOREIGN KEY (`customer_from_id`) REFERENCES `customers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoices_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `invoices_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `invoices` (`id`, `company_id`, `customer_id`, `customer_from_id`, `invoice_number`, `category_id`, `invoice_status_code`, `invoiced_at`, `installment_count`, `amount`, `currency_id`, `discount`, `filename`, `east`, `west`, `north`, `south`, `latitude`, `street`, `phase_id`, `block`, `girib_area_sold`, `metr_moraba_area_sold`, `price_letters`, `sketch`, `length`, `length_girib_area_sold`, `length_metr_moraba_area_sold`, `length_price_letters`, `length_sketch`, `type`, `province`, `city`, `city_id`, `nahia`, `type_pay`, `rate`, `notes`, `company_per`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
('5', '1', '3', NULL, 'INV-1405-00001', NULL, '0', '1405-06-09', '2', '4000.000', '2', '0.000', NULL, 'صث', 'ثقفغ', 'قفغ', 'قفغع', NULL, 'a1', '8', 'a', '2.00', '4000.00', '4000.00', NULL, NULL, NULL, NULL, NULL, NULL, '1', 'کابل', NULL, NULL, '۱۳', '2', '70.0000', NULL, '100.00', '1', NULL, '2026-08-31 08:45:56', '2026-08-31 08:45:56'),
('6', '1', '3', NULL, 'INV-1405-00002', NULL, '1', '1405-06-09', '1', '230.000', NULL, '0.000', NULL, NULL, NULL, NULL, NULL, NULL, 's', '8', 'we', '0.12', '230.00', '230.00', NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, NULL, '1', '1.0000', NULL, '100.00', '1', NULL, '2026-08-31 08:57:50', '2026-08-31 08:57:50'),
('7', '1', '2', '3', 'INV-1405-00003', NULL, '1', '1405-06-09', '1', '230.000', '2', '0.000', NULL, NULL, NULL, NULL, NULL, NULL, 's', '8', 'we', '0.12', '230.00', '230.00', NULL, NULL, NULL, NULL, NULL, NULL, '3', NULL, NULL, NULL, NULL, '1', '70.0000', NULL, '3.00', '1', NULL, '2026-08-31 10:01:07', '2026-08-31 10:01:07'),
('8', '1', '2', NULL, 'INV-1405-00004', NULL, '1', '1405-06-10', '1', '235.000', NULL, '0.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '8', NULL, '0.1175', '235', '235', NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, NULL, '1', '1.0000', NULL, '100.00', '1', NULL, '2026-09-01 05:12:13', '2026-09-01 05:12:13');

CREATE TABLE `lands` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `category_id` bigint unsigned DEFAULT NULL,
  `phase_id` bigint unsigned NOT NULL,
  `area_jarib` decimal(10,2) DEFAULT NULL,
  `area_baswa` decimal(10,2) DEFAULT NULL,
  `area_sqm` bigint unsigned DEFAULT NULL,
  `area_unit_id` bigint unsigned DEFAULT NULL,
  `area_value` decimal(15,4) DEFAULT NULL,
  `area_sqm_m` decimal(15,4) DEFAULT NULL,
  `price_per_jarib_usd` decimal(20,4) DEFAULT NULL,
  `price_total_usd` decimal(20,4) DEFAULT NULL,
  `block` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `street` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `east` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `west` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `north` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `south` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `latitude` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `factory_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `owner_type` tinyint NOT NULL DEFAULT '1',
  `customer_id` bigint unsigned DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `lands_phase_id_foreign` (`phase_id`),
  KEY `lands_customer_id_foreign` (`customer_id`),
  KEY `lands_created_by_foreign` (`created_by`),
  KEY `lands_area_unit_id_foreign` (`area_unit_id`),
  KEY `lands_category_id_foreign` (`category_id`),
  CONSTRAINT `lands_area_unit_id_foreign` FOREIGN KEY (`area_unit_id`) REFERENCES `units` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lands_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lands_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lands_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lands_phase_id_foreign` FOREIGN KEY (`phase_id`) REFERENCES `phases` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `lands` (`id`, `name`, `category_id`, `phase_id`, `area_jarib`, `area_baswa`, `area_sqm`, `area_unit_id`, `area_value`, `area_sqm_m`, `price_per_jarib_usd`, `price_total_usd`, `block`, `street`, `east`, `west`, `north`, `south`, `latitude`, `factory_no`, `owner_type`, `customer_id`, `description`, `image`, `status`, `created_by`, `created_at`, `updated_at`) VALUES
('9', '420', '1', '8', '2.00', NULL, '4000', '5', '2.0000', '4000.0000', '2000.0000', '4000.0000', 'a', 'a1', NULL, NULL, NULL, NULL, NULL, '12', '2', '3', NULL, NULL, '1', '1', '2026-08-31 07:31:49', '2026-08-31 08:45:56'),
('10', '422', '2', '8', '0.12', NULL, '230', '4', '230.0000', '230.0000', '2000.0000', '230.0000', 'we', 's', NULL, NULL, NULL, NULL, NULL, 'sds', '2', '2', NULL, NULL, '1', '1', '2026-08-31 07:33:14', '2026-08-31 10:01:07'),
('11', '101', '1', '8', '0.12', NULL, '235', '4', '235.0000', '235.0000', '2000.0000', '235.0000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2', '2', NULL, NULL, '1', '1', '2026-09-01 05:10:57', '2026-09-01 05:12:13');

CREATE TABLE `machine_activities` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `machine_id` bigint unsigned NOT NULL,
  `customer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `driver` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `oil` int DEFAULT NULL,
  `hours` int unsigned DEFAULT NULL,
  `work_area` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `price` decimal(15,4) DEFAULT NULL,
  `oil_price` decimal(15,4) DEFAULT NULL,
  `fuel_liters` decimal(15,4) DEFAULT NULL,
  `fuel_price` decimal(15,4) DEFAULT NULL,
  `fuel_cost` decimal(15,4) DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `currency_rate` decimal(15,8) DEFAULT NULL,
  `status` tinyint unsigned NOT NULL DEFAULT '0',
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `income_id` bigint unsigned DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `machine_activities_company_id_foreign` (`company_id`),
  KEY `machine_activities_currency_id_foreign` (`currency_id`),
  KEY `machine_activities_income_id_foreign` (`income_id`),
  KEY `machine_activities_account_id_foreign` (`account_id`),
  KEY `machine_activities_created_by_foreign` (`created_by`),
  KEY `machine_activities_updated_by_foreign` (`updated_by`),
  KEY `machine_activities_machine_id_date_index` (`machine_id`,`date`),
  CONSTRAINT `machine_activities_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `machine_activities_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `machine_activities_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `machine_activities_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `machine_activities_income_id_foreign` FOREIGN KEY (`income_id`) REFERENCES `income` (`id`) ON DELETE SET NULL,
  CONSTRAINT `machine_activities_machine_id_foreign` FOREIGN KEY (`machine_id`) REFERENCES `machines` (`id`) ON DELETE CASCADE,
  CONSTRAINT `machine_activities_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `machine_activities` (`id`, `company_id`, `machine_id`, `customer`, `driver`, `oil`, `hours`, `work_area`, `description`, `price`, `oil_price`, `fuel_liters`, `fuel_price`, `fuel_cost`, `currency_id`, `currency_rate`, `status`, `date`, `income_id`, `account_id`, `created_by`, `updated_by`, `deleted_at`, `created_at`, `updated_at`) VALUES
('1', '1', '1', 'مهدی', 'علی', '1200', '24', 'کابل', NULL, '12000.0000', '2300.0000', NULL, NULL, NULL, '2', NULL, '0', '1405-06-10', NULL, '3', '1', NULL, '2026-09-01 09:40:55', '2026-09-01 09:19:01', '2026-09-01 09:40:55'),
('2', '1', '1', 'fakja', 'fadjfk;ak', NULL, '20', 'fa;kdf', NULL, '12000.0000', NULL, '20.0000', '56.0000', '1120.0000', '2', NULL, '0', '1405-06-10', '3', '3', '1', '1', NULL, '2026-09-01 09:41:47', '2026-09-01 09:42:30');

CREATE TABLE `machines` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `sku` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_id` bigint unsigned NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `price` decimal(11,2) DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `quantity` decimal(11,2) DEFAULT NULL,
  `status` tinyint unsigned NOT NULL DEFAULT '0',
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `machines_company_id_foreign` (`company_id`),
  KEY `machines_currency_id_foreign` (`currency_id`),
  KEY `machines_created_by_foreign` (`created_by`),
  KEY `machines_updated_by_foreign` (`updated_by`),
  CONSTRAINT `machines_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `machines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `machines_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `machines_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `machines` (`id`, `sku`, `company_id`, `name`, `description`, `price`, `currency_id`, `quantity`, `status`, `date`, `image`, `created_by`, `updated_by`, `deleted_at`, `created_at`, `updated_at`) VALUES
('1', '12', '1', 'excavator', NULL, '12000.00', '2', '1.00', '0', '1405-06-10', '5XWpJ1jEZYn1jU63ioxieBdjWYPMvGcn5CLbp78S.webp', '1', NULL, NULL, '2026-09-01 09:17:59', '2026-09-01 09:17:59');

CREATE TABLE `meeting` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned DEFAULT NULL,
  `subject` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `final_result` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `migrations` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=68 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
('1', '0001_01_01_000000_create_users_table', '1'),
('2', '0001_01_01_000001_create_cache_table', '1'),
('3', '0001_01_01_000002_create_jobs_table', '1'),
('4', '2026_08_16_073206_create_permission_tables', '1'),
('5', '2026_08_16_073500_create_states_table', '1'),
('6', '2026_08_16_073501_create_cities_table', '1'),
('7', '2026_08_16_073610_create_companies_table', '1'),
('8', '2026_08_16_073611_add_company_id_to_users_table', '1'),
('9', '2026_08_16_073612_create_currencies_table', '1'),
('10', '2026_08_16_073613_create_accounts_table', '1'),
('11', '2026_08_16_073614_create_categories_table', '1'),
('12', '2026_08_16_073615_create_units_table', '1'),
('13', '2026_08_16_073706_create_customers_table', '1'),
('14', '2026_08_16_073709_create_invoices_table', '1'),
('15', '2026_08_16_073710_create_invoice_items_table', '1'),
('16', '2026_08_16_073711_create_invoice_payments_table', '1'),
('17', '2026_08_16_073712_create_transactions_table', '1'),
('18', '2026_08_16_073850_create_projects_table', '1'),
('19', '2026_08_16_073851_create_machines_table', '1'),
('20', '2026_08_16_073904_create_income_types_table', '1'),
('21', '2026_08_16_073905_create_months_table', '1'),
('22', '2026_08_16_073906_create_income_table', '1'),
('23', '2026_08_16_073907_create_expenses_table', '1'),
('24', '2026_08_16_073908_create_employees_table', '1'),
('25', '2026_08_16_073909_create_salaries_table', '1'),
('26', '2026_08_16_073910_create_transfers_table', '1'),
('27', '2026_08_16_073911_create_contracts_table', '1'),
('28', '2026_08_16_073916_create_meetings_table', '1'),
('29', '2026_08_16_073917_create_shareholders_table', '1'),
('30', '2026_08_16_073918_create_tasks_table', '1'),
('31', '2026_08_16_073919_create_task_users_table', '1'),
('32', '2026_08_16_073920_create_invoice_givebacks_table', '1'),
('33', '2026_08_16_073921_create_customer_histories_table', '1'),
('34', '2026_08_17_063538_create_phases_table', '1'),
('35', '2026_08_17_100000_create_lands_table', '1'),
('36', '2026_08_17_100001_add_category_to_lands_table', '1'),
('37', '2026_08_17_110059_add_company_per_to_invoices_table', '1'),
('38', '2026_08_17_150000_add_boundaries_to_lands_table', '1'),
('39', '2026_08_17_160000_create_invoice_customers_table', '1'),
('40', '2026_08_20_112303_change_date_columns_to_string', '1'),
('41', '2026_08_23_063401_add_currency_to_transactions_table', '1'),
('42', '2026_08_23_102347_add_absent_days_to_salaries_table', '1'),
('43', '2026_08_23_114820_create_attendances_table', '1'),
('44', '2026_08_24_101541_change_income_type_id_foreign_key', '1'),
('45', '2026_08_25_100000_create_shareholder_items_table', '1'),
('46', '2026_08_25_110000_enhance_contracts_table', '1'),
('47', '2026_08_25_110001_create_contract_payments_table', '1'),
('48', '2026_08_25_120000_add_company_name_remove_contract_number', '1'),
('49', '2026_08_25_130000_add_income_id_and_account_id_to_shareholder_items', '1'),
('50', '2026_08_25_140000_repoint_expense_income_fk_to_categories', '1'),
('51', '2026_08_25_140001_add_contract_payment_id_to_transactions', '1'),
('52', '2026_08_25_150000_create_machine_activities_table', '1'),
('53', '2026_08_25_160000_fix_machine_activities_column_types', '1'),
('54', '2026_08_25_160001_revert_driver_to_string', '1'),
('55', '2026_08_26_100000_add_profile_fields_to_users_table', '1'),
('56', '2026_08_27_100000_make_measurement_units_dynamic', '2'),
('57', '2026_08_27_100100_make_land_area_dynamic', '2'),
('58', '2026_08_27_101000_drop_english_name_and_symbol_from_units', '3'),
('59', '2026_08_29_000001_widen_invoice_money_columns', '4'),
('60', '2026_08_29_000002_add_commission_amount_to_invoice_payments', '5'),
('61', '2026_08_29_000003_categories_single_name_and_lands_category_id', '6'),
('62', '2026_08_30_000000_create_backups_table', '7'),
('63', '2026_08_31_000001_rename_public_area_sqm_to_public_area_jerib_on_phases', '8'),
('64', '2026_09_01_000001_three_decimal_money_columns', '9'),
('65', '2026_09_01_000002_add_city_text_to_invoices_table', '10'),
('66', '2026_09_01_000001_add_fuel_columns_to_machine_activities', '11'),
('67', '2026_09_03_000001_add_checksum_to_backups_table', '12');

CREATE TABLE `model_has_permissions` (
  `permission_id` bigint unsigned NOT NULL,
  `model_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `model_id` bigint unsigned NOT NULL,
  PRIMARY KEY (`permission_id`,`model_id`,`model_type`),
  KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`),
  CONSTRAINT `model_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `model_has_roles` (
  `role_id` bigint unsigned NOT NULL,
  `model_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `model_id` bigint unsigned NOT NULL,
  PRIMARY KEY (`role_id`,`model_id`,`model_type`),
  KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`),
  CONSTRAINT `model_has_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `model_has_roles` (`role_id`, `model_type`, `model_id`) VALUES
('1', 'App\\Models\\User', '1'),
('2', 'App\\Models\\User', '2'),
('3', 'App\\Models\\User', '3'),
('4', 'App\\Models\\User', '4'),
('1', 'App\\Models\\User', '5'),
('1', 'App\\Models\\User', '6'),
('4', 'App\\Models\\User', '7');

CREATE TABLE `months` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `types` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `type_en` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `password_reset_tokens` (
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `permissions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `guard_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `permissions_name_guard_name_unique` (`name`,`guard_name`)
) ENGINE=InnoDB AUTO_INCREMENT=106 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `permissions` (`id`, `name`, `guard_name`, `created_at`, `updated_at`) VALUES
('1', 'users.view', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('2', 'users.create', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('3', 'users.edit', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('4', 'users.delete', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('5', 'users.toggle', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('6', 'users.reset-password', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('7', 'roles.view', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('8', 'roles.create', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('9', 'roles.edit', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('10', 'roles.delete', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('11', 'profile.view', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('12', 'profile.edit', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('13', 'profile.update-photo', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('14', 'profile.update-password', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('15', 'dashboard.view', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('16', 'phases.view', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('17', 'phases.create', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('18', 'phases.edit', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('19', 'phases.delete', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('20', 'lands.view', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('21', 'lands.create', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('22', 'lands.edit', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('23', 'lands.delete', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('24', 'customers.view', 'web', '2026-08-26 10:13:29', '2026-08-26 10:13:29'),
('25', 'customers.create', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('26', 'customers.edit', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('27', 'customers.delete', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('28', 'invoices.view', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('29', 'invoices.create', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('30', 'invoices.edit', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('31', 'invoices.delete', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('32', 'payments.view', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('33', 'payments.create', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('34', 'payments.edit', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('35', 'payments.delete', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('36', 'income.view', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('37', 'income.create', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('38', 'income.edit', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('39', 'income.delete', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('40', 'expenses.view', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('41', 'expenses.create', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('42', 'expenses.edit', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('43', 'expenses.delete', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('44', 'accounts.view', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('45', 'accounts.create', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('46', 'accounts.edit', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('47', 'accounts.delete', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('48', 'transfers.view', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('49', 'transfers.create', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('50', 'transfers.edit', 'web', '2026-08-26 10:13:30', '2026-08-26 10:13:30'),
('51', 'transfers.delete', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('52', 'employees.view', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('53', 'employees.create', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('54', 'employees.edit', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('55', 'employees.delete', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('56', 'salaries.view', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('57', 'salaries.create', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('58', 'salaries.edit', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('59', 'salaries.delete', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('60', 'attendance.view', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('61', 'attendance.create', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('62', 'attendance.edit', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('63', 'attendance.delete', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('64', 'projects.view', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('65', 'projects.create', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('66', 'projects.edit', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('67', 'projects.delete', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('68', 'machines.view', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('69', 'machines.create', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('70', 'machines.edit', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('71', 'machines.delete', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('72', 'meetings.view', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('73', 'meetings.create', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('74', 'meetings.edit', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('75', 'meetings.delete', 'web', '2026-08-26 10:13:31', '2026-08-26 10:13:31'),
('76', 'shareholders.view', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('77', 'shareholders.create', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('78', 'shareholders.edit', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('79', 'shareholders.delete', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('80', 'contracts.view', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('81', 'contracts.create', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('82', 'contracts.edit', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('83', 'contracts.delete', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('84', 'tasks.view', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('85', 'tasks.create', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('86', 'tasks.edit', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('87', 'tasks.delete', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('88', 'categories.view', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('89', 'categories.create', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('90', 'categories.edit', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('91', 'categories.delete', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('92', 'currencies.view', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('93', 'currencies.create', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('94', 'currencies.edit', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('95', 'currencies.delete', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('96', 'units.view', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('97', 'units.create', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('98', 'units.edit', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('99', 'units.delete', 'web', '2026-08-26 10:13:32', '2026-08-26 10:13:32'),
('100', 'reports.view', 'web', '2026-08-26 10:13:33', '2026-08-26 10:13:33'),
('101', 'backups.view', 'web', '2026-08-30 07:31:32', '2026-08-30 07:31:32'),
('102', 'backups.create', 'web', '2026-08-30 07:31:32', '2026-08-30 07:31:32'),
('103', 'backups.restore', 'web', '2026-08-30 07:31:32', '2026-08-30 07:31:32'),
('104', 'backups.delete', 'web', '2026-08-30 07:31:32', '2026-08-30 07:31:32'),
('105', '*', 'web', '2026-08-30 07:31:33', '2026-08-30 07:31:33');

CREATE TABLE `phases` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `area_sqm` bigint unsigned DEFAULT NULL,
  `score_count` int unsigned DEFAULT NULL,
  `jarib_count` decimal(15,2) DEFAULT NULL,
  `price_per_jarib_usd` decimal(15,2) DEFAULT NULL,
  `public_area_jerib` decimal(15,2) DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `phases` (`id`, `name`, `area_sqm`, `score_count`, `jarib_count`, `price_per_jarib_usd`, `public_area_jerib`, `description`, `image`, `created_at`, `updated_at`) VALUES
('8', 'فاز چهارم', '566000', '131', '46.12', NULL, '60.00', NULL, 'Uo66W2BDneiIvIS9ckKWNgIhjW3eGNEiVHnGK8wa.jpg', '2026-08-31 07:29:12', '2026-08-31 07:29:12');

CREATE TABLE `projects` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `budget` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `currency_id` bigint unsigned DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `manager` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `projects_company_id_foreign` (`company_id`),
  KEY `projects_currency_id_foreign` (`currency_id`),
  KEY `projects_created_by_foreign` (`created_by`),
  KEY `projects_updated_by_foreign` (`updated_by`),
  CONSTRAINT `projects_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `projects_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `projects_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `projects_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `role_has_permissions` (
  `permission_id` bigint unsigned NOT NULL,
  `role_id` bigint unsigned NOT NULL,
  PRIMARY KEY (`permission_id`,`role_id`),
  KEY `role_has_permissions_role_id_foreign` (`role_id`),
  CONSTRAINT `role_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `role_has_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `role_has_permissions` (`permission_id`, `role_id`) VALUES
('1', '1'),
('2', '1'),
('3', '1'),
('4', '1'),
('5', '1'),
('6', '1'),
('7', '1'),
('8', '1'),
('9', '1'),
('10', '1'),
('11', '1'),
('12', '1'),
('13', '1'),
('14', '1'),
('15', '1'),
('16', '1'),
('17', '1'),
('18', '1'),
('19', '1'),
('20', '1'),
('21', '1'),
('22', '1'),
('23', '1'),
('24', '1'),
('25', '1'),
('26', '1'),
('27', '1'),
('28', '1'),
('29', '1'),
('30', '1'),
('31', '1'),
('32', '1'),
('33', '1'),
('34', '1'),
('35', '1'),
('36', '1'),
('37', '1'),
('38', '1'),
('39', '1'),
('40', '1'),
('41', '1'),
('42', '1'),
('43', '1'),
('44', '1'),
('45', '1'),
('46', '1'),
('47', '1'),
('48', '1'),
('49', '1'),
('50', '1'),
('51', '1'),
('52', '1'),
('53', '1'),
('54', '1'),
('55', '1'),
('56', '1'),
('57', '1'),
('58', '1'),
('59', '1'),
('60', '1'),
('61', '1'),
('62', '1'),
('63', '1'),
('64', '1'),
('65', '1'),
('66', '1'),
('67', '1'),
('68', '1'),
('69', '1'),
('70', '1'),
('71', '1'),
('72', '1'),
('73', '1'),
('74', '1'),
('75', '1'),
('76', '1'),
('77', '1'),
('78', '1'),
('79', '1'),
('80', '1'),
('81', '1'),
('82', '1'),
('83', '1'),
('84', '1'),
('85', '1'),
('86', '1'),
('87', '1'),
('88', '1'),
('89', '1'),
('90', '1'),
('91', '1'),
('92', '1'),
('93', '1'),
('94', '1'),
('95', '1'),
('96', '1'),
('97', '1'),
('98', '1'),
('99', '1'),
('100', '1'),
('101', '1'),
('102', '1'),
('103', '1'),
('104', '1'),
('105', '1'),
('1', '2'),
('2', '2'),
('3', '2'),
('5', '2'),
('6', '2'),
('7', '2'),
('8', '2'),
('9', '2'),
('11', '2'),
('12', '2'),
('13', '2'),
('14', '2'),
('15', '2'),
('16', '2'),
('17', '2'),
('18', '2'),
('19', '2'),
('20', '2'),
('21', '2'),
('22', '2'),
('23', '2'),
('24', '2'),
('25', '2'),
('26', '2'),
('27', '2'),
('28', '2'),
('29', '2'),
('30', '2'),
('31', '2'),
('32', '2'),
('33', '2'),
('34', '2'),
('35', '2'),
('36', '2'),
('37', '2'),
('38', '2'),
('39', '2'),
('40', '2'),
('41', '2'),
('42', '2'),
('43', '2'),
('44', '2'),
('45', '2'),
('46', '2'),
('47', '2'),
('48', '2'),
('49', '2'),
('50', '2'),
('51', '2'),
('52', '2'),
('53', '2'),
('54', '2'),
('55', '2'),
('56', '2'),
('57', '2'),
('58', '2'),
('59', '2'),
('60', '2'),
('61', '2'),
('62', '2'),
('63', '2'),
('64', '2'),
('65', '2'),
('66', '2'),
('67', '2'),
('68', '2'),
('69', '2'),
('70', '2'),
('71', '2'),
('72', '2'),
('73', '2'),
('74', '2'),
('75', '2'),
('76', '2'),
('77', '2'),
('78', '2'),
('79', '2'),
('80', '2'),
('81', '2'),
('82', '2'),
('83', '2'),
('84', '2'),
('85', '2'),
('86', '2'),
('87', '2'),
('88', '2'),
('89', '2'),
('90', '2'),
('91', '2'),
('92', '2'),
('93', '2'),
('94', '2'),
('95', '2'),
('96', '2'),
('97', '2');
INSERT INTO `role_has_permissions` (`permission_id`, `role_id`) VALUES
('98', '2'),
('99', '2'),
('100', '2'),
('101', '2'),
('102', '2'),
('103', '2'),
('104', '2'),
('105', '2'),
('1', '3'),
('11', '3'),
('12', '3'),
('13', '3'),
('14', '3'),
('15', '3'),
('16', '3'),
('20', '3'),
('24', '3'),
('28', '3'),
('32', '3'),
('36', '3'),
('40', '3'),
('44', '3'),
('48', '3'),
('52', '3'),
('56', '3'),
('60', '3'),
('64', '3'),
('68', '3'),
('72', '3'),
('76', '3'),
('80', '3'),
('84', '3'),
('88', '3'),
('92', '3'),
('96', '3'),
('100', '3'),
('11', '4'),
('12', '4'),
('13', '4'),
('14', '4'),
('15', '4'),
('16', '4'),
('20', '4'),
('24', '4'),
('28', '4'),
('36', '4'),
('40', '4'),
('44', '4'),
('52', '4'),
('60', '4'),
('72', '4'),
('84', '4'),
('88', '4'),
('92', '4'),
('96', '4');

CREATE TABLE `roles` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `guard_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `roles_name_guard_name_unique` (`name`,`guard_name`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `roles` (`id`, `name`, `guard_name`, `created_at`, `updated_at`) VALUES
('1', 'super-admin', 'web', '2026-08-26 10:13:33', '2026-08-26 10:13:33'),
('2', 'admin', 'web', '2026-08-26 10:13:33', '2026-08-26 10:13:33'),
('3', 'manager', 'web', '2026-08-26 10:13:33', '2026-08-26 10:13:33'),
('4', 'employee', 'web', '2026-08-26 10:13:33', '2026-08-26 10:13:33');

CREATE TABLE `salaries` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `employee_id` bigint unsigned NOT NULL,
  `year` int unsigned NOT NULL,
  `month` int unsigned NOT NULL,
  `type` tinyint unsigned NOT NULL DEFAULT '1',
  `official_days` int unsigned DEFAULT NULL,
  `present_days` decimal(8,2) DEFAULT NULL,
  `absent_days` int unsigned NOT NULL DEFAULT '0',
  `amount_paid` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `bonus` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `tax` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `total` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `attendance` int unsigned DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `paid_date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `salaries_employee_id_year_month_unique` (`employee_id`,`year`,`month`),
  KEY `salaries_created_by_foreign` (`created_by`),
  KEY `salaries_updated_by_foreign` (`updated_by`),
  KEY `salaries_company_id_year_month_index` (`company_id`,`year`,`month`),
  KEY `salaries_employee_id_year_month_index` (`employee_id`,`year`,`month`),
  KEY `salaries_account_id_index` (`account_id`),
  KEY `salaries_paid_date_index` (`paid_date`),
  CONSTRAINT `salaries_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `salaries_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `salaries_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `salaries_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  CONSTRAINT `salaries_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `salaries` (`id`, `employee_id`, `year`, `month`, `type`, `official_days`, `present_days`, `absent_days`, `amount_paid`, `bonus`, `tax`, `total`, `attendance`, `account_id`, `paid_date`, `remark`, `company_id`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
('2', '1', '2026', '9', '1', '26', '26.00', '0', '200.0000', '0.0000', '0.0000', '200.0000', NULL, '4', '1405-06-10', NULL, '1', '1', NULL, '2026-09-01 09:05:06', '2026-09-01 09:05:06');

CREATE TABLE `shareholder_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `shareholder_id` bigint unsigned NOT NULL,
  `income_id` bigint unsigned DEFAULT NULL,
  `account_id` bigint unsigned DEFAULT NULL,
  `company_id` bigint unsigned NOT NULL,
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `price` decimal(15,4) DEFAULT NULL,
  `totals` decimal(11,1) DEFAULT NULL,
  `engine` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `shasi` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `car_price` decimal(15,2) DEFAULT NULL,
  `land_position` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `acre` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `land_price` decimal(15,2) DEFAULT NULL,
  `currency` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `symbol` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rate` decimal(15,8) DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `shareholder_items_company_id_foreign` (`company_id`),
  KEY `shareholder_items_created_by_foreign` (`created_by`),
  KEY `shareholder_items_updated_by_foreign` (`updated_by`),
  KEY `shareholder_items_shareholder_id_index` (`shareholder_id`),
  KEY `shareholder_items_income_id_foreign` (`income_id`),
  KEY `shareholder_items_account_id_foreign` (`account_id`),
  CONSTRAINT `shareholder_items_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `shareholder_items_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `shareholder_items_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `shareholder_items_income_id_foreign` FOREIGN KEY (`income_id`) REFERENCES `income` (`id`) ON DELETE SET NULL,
  CONSTRAINT `shareholder_items_shareholder_id_foreign` FOREIGN KEY (`shareholder_id`) REFERENCES `shareholders` (`id`) ON DELETE CASCADE,
  CONSTRAINT `shareholder_items_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `shareholders` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `price` decimal(11,1) DEFAULT NULL,
  `rate` decimal(11,2) DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `price_asset` decimal(15,4) DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `position` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `engine` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `shasi` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `car_price` decimal(11,1) DEFAULT NULL,
  `land_position` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `acre` decimal(11,1) DEFAULT NULL,
  `land_price` decimal(11,1) DEFAULT NULL,
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `shareholders_company_id_foreign` (`company_id`),
  KEY `shareholders_currency_id_foreign` (`currency_id`),
  KEY `shareholders_created_by_foreign` (`created_by`),
  KEY `shareholders_updated_by_foreign` (`updated_by`),
  CONSTRAINT `shareholders_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `shareholders_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `shareholders_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `shareholders_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `shareholders` (`id`, `company_id`, `name`, `last_name`, `price`, `rate`, `currency_id`, `price_asset`, `description`, `position`, `date`, `engine`, `shasi`, `car_price`, `land_position`, `acre`, `land_price`, `type`, `image`, `created_by`, `updated_by`, `deleted_at`, `created_at`, `updated_at`) VALUES
('1', '1', 'muslim', 'hassani', '2000000.0', '25.00', '2', NULL, NULL, 'manager', '1405-06-10', NULL, NULL, NULL, NULL, NULL, NULL, 'سرمایه‌گذار', 'x0B80XN0pVcaKu4vLuMAYA6qECHNZIZGT5YG350g.png', '1', '1', '2026-09-01 10:00:34', '2026-09-01 09:45:52', '2026-09-01 10:00:34');

CREATE TABLE `states` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `country_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name_en` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name_pa` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `latitude` double DEFAULT NULL,
  `longitude` double DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `states_created_by_foreign` (`created_by`),
  KEY `states_updated_by_foreign` (`updated_by`),
  CONSTRAINT `states_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `states_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `task_users` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `task_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `task_users_task_id_foreign` (`task_id`),
  KEY `task_users_user_id_foreign` (`user_id`),
  CONSTRAINT `task_users_task_id_foreign` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE,
  CONSTRAINT `task_users_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `tasks` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `priority` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `start_date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `end_date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `category_id` bigint unsigned DEFAULT NULL,
  `image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` tinyint unsigned NOT NULL DEFAULT '0',
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `tasks_company_id_foreign` (`company_id`),
  KEY `tasks_category_id_foreign` (`category_id`),
  KEY `tasks_created_by_foreign` (`created_by`),
  KEY `tasks_updated_by_foreign` (`updated_by`),
  CONSTRAINT `tasks_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL,
  CONSTRAINT `tasks_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `tasks_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `tasks_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


CREATE TABLE `transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `invoice_id` bigint unsigned DEFAULT NULL,
  `expense_id` bigint unsigned DEFAULT NULL,
  `income_id` bigint unsigned DEFAULT NULL,
  `salary_id` bigint unsigned DEFAULT NULL,
  `transfer_id` bigint unsigned DEFAULT NULL,
  `contract_payment_id` bigint unsigned DEFAULT NULL,
  `from_account_id` bigint unsigned DEFAULT NULL,
  `to_account_id` bigint unsigned DEFAULT NULL,
  `amount` decimal(15,4) NOT NULL,
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Income',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `currency_id` bigint unsigned DEFAULT NULL,
  `currency_rate` decimal(15,8) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `transactions_company_id_foreign` (`company_id`),
  KEY `transactions_invoice_id_foreign` (`invoice_id`),
  KEY `transactions_from_account_id_foreign` (`from_account_id`),
  KEY `transactions_to_account_id_foreign` (`to_account_id`),
  KEY `transactions_created_by_foreign` (`created_by`),
  KEY `transactions_updated_by_foreign` (`updated_by`),
  KEY `transactions_type_index` (`type`),
  KEY `transactions_currency_id_foreign` (`currency_id`),
  KEY `transactions_contract_payment_id_foreign` (`contract_payment_id`),
  CONSTRAINT `transactions_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `transactions_contract_payment_id_foreign` FOREIGN KEY (`contract_payment_id`) REFERENCES `contract_payments` (`id`) ON DELETE SET NULL,
  CONSTRAINT `transactions_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `transactions_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `transactions_from_account_id_foreign` FOREIGN KEY (`from_account_id`) REFERENCES `accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `transactions_invoice_id_foreign` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE SET NULL,
  CONSTRAINT `transactions_to_account_id_foreign` FOREIGN KEY (`to_account_id`) REFERENCES `accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `transactions_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `transactions` (`id`, `company_id`, `invoice_id`, `expense_id`, `income_id`, `salary_id`, `transfer_id`, `contract_payment_id`, `from_account_id`, `to_account_id`, `amount`, `date`, `type`, `description`, `created_by`, `updated_by`, `deleted_at`, `created_at`, `updated_at`, `currency_id`, `currency_rate`) VALUES
('1', '1', NULL, NULL, NULL, NULL, '1', NULL, '2', '1', '12.0000', '1405-06-05', 'Transfer', 'Transfer', '7', NULL, '2026-08-31 10:18:29', '2026-08-27 06:16:51', '2026-08-31 10:18:29', NULL, NULL),
('2', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', '1600.0000', '1405-06-07', 'Income', 'Cash sale INV-1405-00001', '2', NULL, '2026-08-31 08:44:05', '2026-08-29 09:21:50', '2026-08-31 08:44:05', NULL, '1.00000000'),
('3', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', '4080.0000', '1405-06-07', 'Income', 'Cash sale INV-1405-00002', '2', NULL, '2026-08-29 11:09:01', '2026-08-29 11:06:06', '2026-08-29 11:09:01', NULL, '1.00000000'),
('4', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2', '500.0000', '1405-06-07', 'Income', 'دریافت پول زمین - فاکتور INV-1405-00002', '2', NULL, '2026-08-31 08:44:16', '2026-08-29 11:57:30', '2026-08-31 08:44:16', NULL, '1.00000000'),
('6', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '4', '500.0000', '1405-06-09', 'Income', 'دریافت پول زمین - فاکتور INV-1405-00002', '1', NULL, '2026-08-31 08:44:16', '2026-08-31 04:59:52', '2026-08-31 08:44:16', NULL, '1.00000000'),
('7', '1', '6', NULL, NULL, NULL, NULL, NULL, NULL, '4', '230.0000', '1405-06-09', 'Income', 'Cash sale INV-1405-00002', '1', NULL, NULL, '2026-08-31 08:57:50', '2026-08-31 08:57:50', NULL, '1.00000000'),
('8', '1', '7', NULL, NULL, NULL, NULL, NULL, NULL, '3', '6.9000', '1405-06-09', 'Income', 'Cash sale INV-1405-00003', '1', NULL, NULL, '2026-08-31 10:01:07', '2026-08-31 10:01:07', '2', '70.00000000'),
('9', '1', '8', NULL, NULL, NULL, NULL, NULL, NULL, '4', '235.0000', '1405-06-10', 'Income', 'Cash sale INV-1405-00004', '1', NULL, NULL, '2026-09-01 05:12:13', '2026-09-01 05:12:13', NULL, '1.00000000'),
('10', '1', NULL, '1', NULL, NULL, NULL, NULL, '4', NULL, '10.0000', '1405-06-10', 'Expense', 'Expense', '1', NULL, NULL, '2026-09-01 06:27:26', '2026-09-01 06:27:26', '2', '70.00000000'),
('11', '1', NULL, NULL, NULL, '2', NULL, NULL, '4', NULL, '200.0000', '1405-06-10', 'Expense', 'Salary for employee #1 (2026-9)', '1', NULL, NULL, '2026-09-01 09:05:06', '2026-09-01 09:05:06', '2', '1.00000000'),
('12', '1', NULL, NULL, NULL, NULL, '2', NULL, '4', '3', '12.0000', '1405-06-10', 'Transfer', 'Transfer', '1', NULL, '2026-09-01 09:12:50', '2026-09-01 09:12:14', '2026-09-01 09:12:50', NULL, NULL),
('13', '1', NULL, NULL, '1', NULL, NULL, NULL, NULL, '4', '1200.0000', '1405-06-10', 'Income', 'Income', '1', NULL, '2026-09-01 09:15:19', '2026-09-01 09:14:38', '2026-09-01 09:15:19', '2', '1.00000000'),
('14', '1', NULL, NULL, '2', NULL, NULL, NULL, NULL, '3', '12000.0000', '1405-06-10', 'Income', 'درآمد ماشین: excavator', '1', NULL, '2026-09-01 09:40:55', '2026-09-01 09:19:01', '2026-09-01 09:40:55', '2', '1.00000000'),
('15', '1', NULL, NULL, '3', NULL, NULL, NULL, NULL, '3', '10880.0000', '1405-06-10', 'Income', 'درآمد ماشین: excavator', '1', NULL, NULL, '2026-09-01 09:41:47', '2026-09-01 09:42:30', '2', '1.00000000');

CREATE TABLE `transfers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `from_account_id` bigint unsigned DEFAULT NULL,
  `to_account_id` bigint unsigned DEFAULT NULL,
  `amount` decimal(15,4) NOT NULL,
  `date` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `transfers_company_id_foreign` (`company_id`),
  KEY `transfers_from_account_id_foreign` (`from_account_id`),
  KEY `transfers_to_account_id_foreign` (`to_account_id`),
  KEY `transfers_created_by_foreign` (`created_by`),
  KEY `transfers_updated_by_foreign` (`updated_by`),
  CONSTRAINT `transfers_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `transfers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `transfers_from_account_id_foreign` FOREIGN KEY (`from_account_id`) REFERENCES `accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `transfers_to_account_id_foreign` FOREIGN KEY (`to_account_id`) REFERENCES `accounts` (`id`) ON DELETE SET NULL,
  CONSTRAINT `transfers_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `transfers` (`id`, `company_id`, `from_account_id`, `to_account_id`, `amount`, `date`, `type`, `description`, `created_by`, `updated_by`, `deleted_at`, `created_at`, `updated_at`) VALUES
('1', '1', '2', '1', '12.0000', '1405-06-05', NULL, NULL, '7', NULL, '2026-08-31 10:18:29', '2026-08-27 06:16:51', '2026-08-31 10:18:29'),
('2', '1', '4', '3', '12.0000', '1405-06-10', 'انتقال جدید', NULL, '1', NULL, '2026-09-01 09:12:50', '2026-09-01 09:12:14', '2026-09-01 09:12:50');

CREATE TABLE `units` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned DEFAULT NULL,
  `name_fa` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ratio_to_m2` decimal(15,4) NOT NULL DEFAULT '1.0000',
  `is_default` tinyint(1) NOT NULL DEFAULT '0',
  `enabled` tinyint(1) NOT NULL DEFAULT '1',
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `units_company_id_foreign` (`company_id`),
  CONSTRAINT `units_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `units` (`id`, `company_id`, `name_fa`, `ratio_to_m2`, `is_default`, `enabled`, `created_by`, `created_at`, `updated_at`) VALUES
('4', '1', 'متر مربع', '1.0000', '1', '1', NULL, NULL, NULL),
('5', '1', 'جریب', '2000.0000', '0', '1', NULL, NULL, NULL),
('6', '1', 'ایکر', '4046.8564', '0', '1', NULL, NULL, NULL),
('7', '1', 'هکتار', '10000.0000', '0', '1', NULL, NULL, NULL),
('8', '1', 'بسوه', '100.0000', '0', '1', '2', '2026-08-27 09:49:48', '2026-08-27 09:49:48');

CREATE TABLE `users` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `full_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `position` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `locale` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'fa',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `profile_photo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `email_verified_at` timestamp NULL DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `remember_token` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_email_unique` (`email`),
  KEY `users_company_id_foreign` (`company_id`),
  CONSTRAINT `users_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `users` (`id`, `company_id`, `name`, `full_name`, `position`, `locale`, `is_active`, `profile_photo`, `email`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
('1', '1', 'superadmin', 'Super Admin', NULL, 'fa', '1', NULL, 'superadmin@gic.local', NULL, '$2y$12$K/x65/0brn0CI3trahfXwe2OeuLYP2kRhTTlu/HVTX7VLTkpP.ak.', NULL, '2026-08-26 10:13:34', '2026-08-26 10:13:34'),
('2', '1', 'admin', 'Admin User', 'admin', 'fa', '1', NULL, 'admin@gic.local', NULL, '$2y$12$6bzcMIxNsu54TNaVO8bmWuvPJyxDKDnBq5TZYUQeRCQCNtQXWCqwK', NULL, '2026-08-26 10:13:34', '2026-08-27 06:07:07'),
('3', '1', 'manager', 'Manager User', NULL, 'fa', '1', NULL, 'manager@gic.local', NULL, '$2y$12$shcSdS6p2B6E3/N6dJYK.uOjTb0.1DfAqmgbjtWx1Uc7tVdPhpbAW', NULL, '2026-08-26 10:13:35', '2026-08-26 10:13:35'),
('4', '1', 'employee', 'Employee User', NULL, 'fa', '1', NULL, 'employee@gic.local', NULL, '$2y$12$nsMqUbrlD7kC/zO2z6EfK.R2.SQP.EEqbuA0eEAQ/IsZcbSP8t/zO', NULL, '2026-08-26 10:13:35', '2026-08-27 06:57:22'),
('5', '1', 'hussain@gmail.com', NULL, 'dfgh', 'fa', '1', 'SxhuC69posWMhUlQsVDtz65mhHVHT78u5amRdbgU.webp', 'hussain@gmail.com', NULL, '$2y$12$ImauJ/e3c8/l/tHTVgNSD.xTwHk0KK21gN3uyEFFFRZJUavrER7s2', NULL, '2026-08-27 04:52:02', '2026-08-27 04:52:02'),
('6', '1', 'hussain', NULL, 'dfgh', 'fa', '1', 'x3md6KIPNzsBXSZPBw0zFInUAOIJYWqc8FRbxyjI.png', 'ali@gmail.com', NULL, '$2y$12$y5b.ADVBT1.lwmEHmArUVOH6BsFwRDSrqMaqwq3W2/FAVrYbasTsG', NULL, '2026-08-27 04:53:07', '2026-08-27 04:53:07'),
('7', '1', 'ali', 'ali', 'employee', 'fa', '1', 'YhZKl7UerGXucybkL6i4afLJiSgzLVef6I1PbbTc.png', 'ali123@gmail.com', NULL, '$2y$12$IUb8UEVO3dlrECKwVKXPPepvXNBMhON/2k79S6ZmnsDIS9IvpIkt6', NULL, '2026-08-27 05:47:51', '2026-08-27 05:47:51');

