-- Table structure for add_exception_to_invoices
-- ----------------------------
CREATE TABLE `add_exception_to_invoices`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int UNSIGNED NOT NULL,
  `token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `add_exception_to_invoices_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `add_exception_to_invoices_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `add_exception_to_invoices_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `add_exception_to_invoices_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `add_exception_to_invoices_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `add_exception_to_invoices_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `add_exception_to_invoices_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `add_exception_to_invoices_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `add_exception_to_invoices_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `add_exception_to_invoices_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of add_exception_to_invoices
-- ----------------------------

-- ----------------------------
-- Table structure for allowance_on_salarys
-- ----------------------------
CREATE TABLE `allowance_on_salarys`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `allowance_on_salarys_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `allowance_on_salarys_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `allowance_on_salarys_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `allowance_on_salarys_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `allowance_on_salarys_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `allowance_on_salarys_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `allowance_on_salarys_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `allowance_on_salarys_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of allowance_on_salarys
-- ----------------------------
INSERT INTO `allowance_on_salarys` VALUES (1, 'بدل مواصلات', '1', 'Gaz Allowance', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);

-- ----------------------------
-- Table structure for application_gorups
-- ----------------------------
CREATE TABLE `application_gorups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of application_gorups
-- ----------------------------
INSERT INTO `application_gorups` VALUES (1, 'settings_applications', NULL, 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `application_gorups` VALUES (2, 'sales', NULL, 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `application_gorups` VALUES (3, 'finance', NULL, 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `application_gorups` VALUES (4, 'operations', NULL, 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `application_gorups` VALUES (5, 'manufacturing', NULL, 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `application_gorups` VALUES (6, 'hrm', NULL, 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `application_gorups` VALUES (7, 'marketing', NULL, 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `application_gorups` VALUES (8, 'others', NULL, 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);

-- ----------------------------
-- Table structure for application_status
-- ----------------------------
CREATE TABLE `application_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of application_status
-- ----------------------------
INSERT INTO `application_status` VALUES (1, 'active', NULL, 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `application_status` VALUES (2, 'disactive', NULL, 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `application_status` VALUES (3, 'suspended', NULL, 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);

-- ----------------------------
-- Table structure for applications
-- ----------------------------
CREATE TABLE `applications`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `application_gorup_id` int UNSIGNED NOT NULL,
  `application_state_id` int UNSIGNED NOT NULL,
  `price` double NULL DEFAULT NULL,
  `short_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `applications_application_gorup_id_foreign`(`application_gorup_id` ASC) USING BTREE,
  INDEX `applications_application_state_id_foreign`(`application_state_id` ASC) USING BTREE,
  CONSTRAINT `applications_application_gorup_id_foreign` FOREIGN KEY (`application_gorup_id`) REFERENCES `application_gorups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `applications_application_state_id_foreign` FOREIGN KEY (`application_state_id`) REFERENCES `application_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 38 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of applications
-- ----------------------------
INSERT INTO `applications` VALUES (1, 'settings', NULL, '1', 1, 1, NULL, 'general_settings_and_users_manegment', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (2, 'applications', NULL, '2', 1, 1, NULL, 'manege_applications_install_and_uninstall', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (3, 'sales', NULL, '3', 2, 2, NULL, 'from_quotations_to_invoices', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (4, 'pos', NULL, '4', 2, 2, NULL, 'pos_desc', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (5, 'rental', NULL, '5', 2, 1, NULL, 'manage_rental_contracts_deliveries_and_returns', 1, NULL, '2025-06-12 14:05:47', '2025-07-08 14:58:30', NULL);
INSERT INTO `applications` VALUES (6, 'accounting', NULL, '6', 3, 1, NULL, 'manage_financial_and_analytic_accounting', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (7, 'invoicing', NULL, '7', 3, 1, NULL, 'invoices_payments', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (8, 'expenses', NULL, '8', 3, 2, NULL, 'submit_validate_and_reinvoice_employee_expenses', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', '2025-06-12 14:05:47');
INSERT INTO `applications` VALUES (9, 'inventory', NULL, '9', 4, 2, NULL, 'manage_your_stock_and_logistics_activities', 1, NULL, '2025-06-12 14:05:47', '2025-08-04 15:00:40', NULL);
INSERT INTO `applications` VALUES (10, 'projects', NULL, '10', 4, 2, NULL, 'organize_and_schedule_your_projects', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', '2025-06-12 14:05:47');
INSERT INTO `applications` VALUES (11, 'purchases', NULL, '11', 4, 2, NULL, 'purchase_orders_tenders_and_agreements', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (12, 'receivables', NULL, '12', 4, 2, NULL, 'track_your_receivables_from_checks_and_cash', 1, NULL, '2025-06-12 14:05:47', '2025-08-04 15:00:34', NULL);
INSERT INTO `applications` VALUES (13, 'payable', NULL, '13', 4, 2, NULL, 'track_your_payable_from_checks_and_cash', 1, NULL, '2025-06-12 14:05:47', '2025-08-04 15:00:37', NULL);
INSERT INTO `applications` VALUES (14, 'documents', NULL, '14', 4, 2, NULL, 'document_management', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (15, 'manufacturing', NULL, '15', 5, 2, NULL, 'manufacturing_orders_and_boms', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (16, 'maintenances', NULL, '16', 5, 2, NULL, 'track_equipment_and_manage_maintenance_requests', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (17, 'employees', NULL, '17', 6, 2, NULL, 'centralize_employee_information', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (18, 'attendances', NULL, '18', 6, 2, NULL, 'track_employee_attendance', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (19, 'payrolls', NULL, '19', 6, 2, NULL, 'manage_your_employee_payroll_records', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (20, 'quality', NULL, '20', 5, 2, NULL, 'control_the_quality_of_your_products', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (21, 'email_marketing', NULL, '21', 7, 2, NULL, 'design_send_and_track_emails', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (22, 'sms_marketing', NULL, '22', 7, 2, NULL, 'design_send_and_track_sms', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (23, 'planning', NULL, '23', 8, 2, NULL, 'manage_your_employees_schedule', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', '2025-06-12 14:05:47');
INSERT INTO `applications` VALUES (24, 'approvals', NULL, '24', 6, 2, NULL, 'create_and_validate_approvals_requests', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', '2025-06-12 14:05:47');
INSERT INTO `applications` VALUES (25, 'crm', NULL, '25', 8, 2, NULL, 'track_leads_and_close_opportunities', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (26, 'pos_online_order', NULL, '25', 8, 2, NULL, 'get_android_and_ios_app_to_order_from_pos_model', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (27, 'educations', NULL, '8', 3, 2, NULL, 'Schools_and_online_educations', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (28, 'working_contracts', NULL, '28', 3, 2, NULL, 'doors_manufacturing', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (29, 'medical_clinics', NULL, '29', 3, 2, NULL, 'medical_clinics', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (30, 'garages', NULL, '30', 3, 2, NULL, 'garages', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (31, 'subscription', NULL, '31', 3, 2, NULL, 'subscription_desc', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (32, 'social_media_crm', NULL, '32', 3, 2, NULL, 'social_media_crm_desc', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (33, 'press', NULL, '33', 3, 2, NULL, 'press', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (34, 'car_auctions_application', NULL, '34', 3, 2, NULL, 'press', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (35, 'shipping_and_clearing_application', NULL, '35', 3, 2, NULL, 'press', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (36, 'auditing', NULL, '36', 3, 2, NULL, 'press', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `applications` VALUES (37, 'tasks', NULL, '37', 3, 2, NULL, 'task_desc', 1, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);

-- ----------------------------
-- Table structure for approval_status
-- ----------------------------
CREATE TABLE `approval_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `approval_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `approval_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `approval_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `approval_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of approval_status
-- ----------------------------
INSERT INTO `approval_status` VALUES (1, 'تم الموافقة عليه', NULL, 'Approved', NULL, NULL, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `approval_status` VALUES (2, 'تم الرفض', NULL, 'Rejected', NULL, NULL, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `approval_status` VALUES (3, 'قيد الانشاء', NULL, 'Pending', NULL, NULL, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);
INSERT INTO `approval_status` VALUES (4, 'تم الموافقة عليه وأغلق', NULL, 'Approved and closed', NULL, NULL, NULL, '2025-06-12 14:05:47', '2025-06-12 14:05:47', NULL);

-- ----------------------------
-- Table structure for approvals
-- ----------------------------
CREATE TABLE `approvals`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int UNSIGNED NOT NULL,
  `permission_id` int UNSIGNED NULL DEFAULT NULL,
  `model_id` int UNSIGNED NOT NULL,
  `curd_id` int UNSIGNED NOT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `approvals_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `approvals_permission_id_foreign`(`permission_id` ASC) USING BTREE,
  INDEX `approvals_model_id_foreign`(`model_id` ASC) USING BTREE,
  INDEX `approvals_curd_id_foreign`(`curd_id` ASC) USING BTREE,
  INDEX `approvals_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `approvals_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `approvals_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `approvals_curd_id_foreign` FOREIGN KEY (`curd_id`) REFERENCES `curds` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `approvals_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `approvals_model_id_foreign` FOREIGN KEY (`model_id`) REFERENCES `models` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `approvals_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `approvals_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of approvals
-- ----------------------------

-- ----------------------------
-- Table structure for areas
-- ----------------------------
CREATE TABLE `areas`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `areas_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `areas_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `areas_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `areas_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `areas_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `areas_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `areas_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `areas_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of areas
-- ----------------------------

-- ----------------------------
-- Table structure for asset_groups
-- ----------------------------
CREATE TABLE `asset_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `asset_group_id` int UNSIGNED NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `asset_groups_asset_group_id_foreign`(`asset_group_id` ASC) USING BTREE,
  INDEX `asset_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `asset_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `asset_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `asset_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_groups_asset_group_id_foreign` FOREIGN KEY (`asset_group_id`) REFERENCES `asset_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of asset_groups
-- ----------------------------
INSERT INTO `asset_groups` VALUES (1, 'متفرقة', 'Scattered', '1', NULL, 10, NULL, 1000, NULL, 1, NULL, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);

-- ----------------------------
-- Table structure for asset_journal_entries
-- ----------------------------
CREATE TABLE `asset_journal_entries`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `asset_id` int UNSIGNED NOT NULL,
  `journal_entry_id` int UNSIGNED NOT NULL,
  `journal_entry_line_id` int UNSIGNED NOT NULL,
  `asset_journal_entry_type_id` int UNSIGNED NULL DEFAULT NULL,
  `value` double UNSIGNED NOT NULL,
  `date` date NOT NULL,
  `from_date` date NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `asset_journal_entries_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `asset_journal_entries_journal_entry_line_id_foreign`(`journal_entry_line_id` ASC) USING BTREE,
  INDEX `asset_journal_entries_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `asset_journal_entries_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `asset_journal_entries_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `asset_journal_entries_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `asset_journal_entries_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_journal_entries_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_journal_entries_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_journal_entries_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_journal_entries_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_journal_entries_journal_entry_line_id_foreign` FOREIGN KEY (`journal_entry_line_id`) REFERENCES `journal_entry_lines` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of asset_journal_entries
-- ----------------------------

-- ----------------------------
-- Table structure for asset_maintenance_groups
-- ----------------------------
CREATE TABLE `asset_maintenance_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `main_child_zeros` int UNSIGNED NOT NULL,
  `main_child_counter` int UNSIGNED NULL DEFAULT NULL,
  `sub_child_zeros` int UNSIGNED NOT NULL,
  `sub_child_counter` int UNSIGNED NULL DEFAULT NULL,
  `next_number` int UNSIGNED NULL DEFAULT NULL,
  `asset_maintenance_group_id` int UNSIGNED NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `asset_maintenance_groups_asset_maintenance_group_id_foreign`(`asset_maintenance_group_id` ASC) USING BTREE,
  INDEX `asset_maintenance_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `asset_maintenance_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `asset_maintenance_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `asset_maintenance_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `asset_maintenance_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_groups_asset_maintenance_group_id_foreign` FOREIGN KEY (`asset_maintenance_group_id`) REFERENCES `asset_maintenance_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of asset_maintenance_groups
-- ----------------------------
INSERT INTO `asset_maintenance_groups` VALUES (1, 'طارئة', '1', 'Urgant', NULL, 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);

-- ----------------------------
-- Table structure for asset_maintenance_request_groups
-- ----------------------------
CREATE TABLE `asset_maintenance_request_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `main_child_zeros` int UNSIGNED NOT NULL,
  `main_child_counter` int UNSIGNED NULL DEFAULT NULL,
  `sub_child_zeros` int UNSIGNED NOT NULL,
  `sub_child_counter` int UNSIGNED NULL DEFAULT NULL,
  `asset_maintenance_request_group_id` int UNSIGNED NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `asset_maintenance_request_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `asset_maintenance_request_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `asset_maintenance_request_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `asset_maintenance_request_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `asset_maintenance_request_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_request_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_request_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_request_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of asset_maintenance_request_groups
-- ----------------------------
INSERT INTO `asset_maintenance_request_groups` VALUES (1, 'مستعجلة', '1', 'Urgant', NULL, 10, NULL, 1000, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);

-- ----------------------------
-- Table structure for asset_maintenance_request_status
-- ----------------------------
CREATE TABLE `asset_maintenance_request_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `asset_maintenance_request_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `asset_maintenance_request_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `asset_maintenance_request_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `asset_maintenance_request_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `asset_maintenance_request_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_request_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_request_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_request_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of asset_maintenance_request_status
-- ----------------------------
INSERT INTO `asset_maintenance_request_status` VALUES (1, 'بأنتضار الموافقة', '1', 'Pending approve', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `asset_maintenance_request_status` VALUES (2, 'تم ارسال فريق صيانة', '2', 'Employees send', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `asset_maintenance_request_status` VALUES (3, 'تمت الصيانة', '3', 'Successed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `asset_maintenance_request_status` VALUES (4, 'الغيت', '4', 'Canceled', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);

-- ----------------------------
-- Table structure for asset_maintenance_requests
-- ----------------------------
CREATE TABLE `asset_maintenance_requests`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `asset_maintenance_request_state_id` int UNSIGNED NULL DEFAULT NULL,
  `asset_maintenance_request_group_id` int UNSIGNED NULL DEFAULT NULL,
  `asset_maintenance_id` int UNSIGNED NULL DEFAULT NULL,
  `asset_id` int UNSIGNED NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `date` date NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `asset_maintenance_requests_asset_maintenance_id_foreign`(`asset_maintenance_id` ASC) USING BTREE,
  INDEX `asset_maintenance_requests_asset_id_foreign`(`asset_id` ASC) USING BTREE,
  INDEX `asset_maintenance_requests_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `asset_maintenance_requests_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `asset_maintenance_requests_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `asset_maintenance_requests_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `asset_maintenance_requests_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_requests_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_requests_asset_id_foreign` FOREIGN KEY (`asset_id`) REFERENCES `assets` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_requests_asset_maintenance_id_foreign` FOREIGN KEY (`asset_maintenance_id`) REFERENCES `asset_maintenances` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_requests_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_requests_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of asset_maintenance_requests
-- ----------------------------

-- ----------------------------
-- Table structure for asset_maintenance_status
-- ----------------------------
CREATE TABLE `asset_maintenance_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `asset_maintenance_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `asset_maintenance_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `asset_maintenance_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `asset_maintenance_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `asset_maintenance_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of asset_maintenance_status
-- ----------------------------
INSERT INTO `asset_maintenance_status` VALUES (1, 'قيد الصيانة', '1', 'Under maintenance', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `asset_maintenance_status` VALUES (2, 'تم بنجاح', '2', 'Successed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `asset_maintenance_status` VALUES (3, 'موقوف', '2', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);

-- ----------------------------
-- Table structure for asset_maintenance_types
-- ----------------------------
CREATE TABLE `asset_maintenance_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `create_schedules` int UNSIGNED NULL DEFAULT NULL,
  `invoice_maintenance_kind_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `asset_maintenance_types_create_schedules_foreign`(`create_schedules` ASC) USING BTREE,
  INDEX `asset_maintenance_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `asset_maintenance_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `asset_maintenance_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `asset_maintenance_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `asset_maintenance_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_types_create_schedules_foreign` FOREIGN KEY (`create_schedules`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenance_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of asset_maintenance_types
-- ----------------------------
INSERT INTO `asset_maintenance_types` VALUES (1, 'صيانة طارئة', '1', 'Uargent', 2, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);

-- ----------------------------
-- Table structure for asset_maintenances
-- ----------------------------
CREATE TABLE `asset_maintenances`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `start_date` datetime NULL DEFAULT NULL,
  `end_date` datetime NULL DEFAULT NULL,
  `asset_maintenance_group_id` int UNSIGNED NULL DEFAULT NULL,
  `asset_maintenance_type_id` int UNSIGNED NULL DEFAULT NULL,
  `asset_maintenance_state_id` int UNSIGNED NULL DEFAULT NULL,
  `asset_maintenance_request_id` int UNSIGNED NULL DEFAULT NULL,
  `employee_user_id` int UNSIGNED NULL DEFAULT NULL,
  `asset_id` int UNSIGNED NULL DEFAULT NULL,
  `spare_parts` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `asset_maintenances_asset_maintenance_group_id_foreign`(`asset_maintenance_group_id` ASC) USING BTREE,
  INDEX `asset_maintenances_asset_maintenance_type_id_foreign`(`asset_maintenance_type_id` ASC) USING BTREE,
  INDEX `asset_maintenances_asset_maintenance_state_id_foreign`(`asset_maintenance_state_id` ASC) USING BTREE,
  INDEX `asset_maintenances_employee_user_id_foreign`(`employee_user_id` ASC) USING BTREE,
  INDEX `asset_maintenances_asset_id_foreign`(`asset_id` ASC) USING BTREE,
  INDEX `asset_maintenances_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `asset_maintenances_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `asset_maintenances_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `asset_maintenances_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `asset_maintenances_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenances_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenances_asset_id_foreign` FOREIGN KEY (`asset_id`) REFERENCES `assets` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenances_asset_maintenance_group_id_foreign` FOREIGN KEY (`asset_maintenance_group_id`) REFERENCES `asset_maintenance_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenances_asset_maintenance_state_id_foreign` FOREIGN KEY (`asset_maintenance_state_id`) REFERENCES `asset_maintenance_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenances_asset_maintenance_type_id_foreign` FOREIGN KEY (`asset_maintenance_type_id`) REFERENCES `asset_maintenance_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenances_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenances_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_maintenances_employee_user_id_foreign` FOREIGN KEY (`employee_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of asset_maintenances
-- ----------------------------

-- ----------------------------
-- Table structure for asset_minimums
-- ----------------------------
CREATE TABLE `asset_minimums`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `asset_minimums_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `asset_minimums_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `asset_minimums_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `asset_minimums_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `asset_minimums_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_minimums_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_minimums_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_minimums_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of asset_minimums
-- ----------------------------
INSERT INTO `asset_minimums` VALUES (1, 'صفر', '1', 'Zero', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);
INSERT INTO `asset_minimums` VALUES (2, 'واحد', '2', 'One', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);

-- ----------------------------
-- Table structure for asset_status
-- ----------------------------
CREATE TABLE `asset_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `asset_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `asset_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `asset_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `asset_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `asset_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `asset_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of asset_status
-- ----------------------------
INSERT INTO `asset_status` VALUES (1, 'قيد الاستهلاك', '1', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);
INSERT INTO `asset_status` VALUES (2, 'تم استهلاكه', '2', 'Its been consumed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:55', '2025-06-12 14:05:55', NULL);

-- ----------------------------
-- Table structure for assets
-- ----------------------------
CREATE TABLE `assets`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `asset_account_id` int UNSIGNED NOT NULL,
  `asset_state_id` int UNSIGNED NOT NULL,
  `asset_group_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `accumulated_depreciation_account_id` int UNSIGNED NOT NULL,
  `expensed_depreciation_account_id` int UNSIGNED NOT NULL,
  `available_on_manufacturing` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NOT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double NOT NULL,
  `date_of_release` date NULL DEFAULT NULL,
  `purchase_date` date NOT NULL,
  `start_calculation_date` date NOT NULL,
  `quantity` double NOT NULL,
  `price` double NOT NULL,
  `remain` double NULL DEFAULT NULL,
  `tax_value` double NULL DEFAULT NULL,
  `stamps` double NULL DEFAULT NULL,
  `annual_consumption_ratio` double NULL DEFAULT NULL,
  `total_depreciation_hours` double NULL DEFAULT NULL,
  `accumolated` double NULL DEFAULT NULL,
  `asset_minimum_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `assets_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `assets_available_on_manufacturing_foreign`(`available_on_manufacturing` ASC) USING BTREE,
  INDEX `assets_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `assets_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `assets_asset_state_id_foreign`(`asset_state_id` ASC) USING BTREE,
  INDEX `assets_asset_group_id_foreign`(`asset_group_id` ASC) USING BTREE,
  INDEX `assets_asset_account_id_foreign`(`asset_account_id` ASC) USING BTREE,
  INDEX `assets_accumulated_depreciation_account_id_foreign`(`accumulated_depreciation_account_id` ASC) USING BTREE,
  INDEX `assets_expensed_depreciation_account_id_foreign`(`expensed_depreciation_account_id` ASC) USING BTREE,
  INDEX `assets_asset_minimum_id_foreign`(`asset_minimum_id` ASC) USING BTREE,
  INDEX `assets_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `assets_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `assets_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `assets_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `assets_accumulated_depreciation_account_id_foreign` FOREIGN KEY (`accumulated_depreciation_account_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_asset_account_id_foreign` FOREIGN KEY (`asset_account_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_asset_group_id_foreign` FOREIGN KEY (`asset_group_id`) REFERENCES `asset_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_asset_minimum_id_foreign` FOREIGN KEY (`asset_minimum_id`) REFERENCES `asset_minimums` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_asset_state_id_foreign` FOREIGN KEY (`asset_state_id`) REFERENCES `asset_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_available_on_manufacturing_foreign` FOREIGN KEY (`available_on_manufacturing`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_expensed_depreciation_account_id_foreign` FOREIGN KEY (`expensed_depreciation_account_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `assets_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of assets
-- ----------------------------

-- ----------------------------
-- Table structure for attendance_machines
-- ----------------------------
CREATE TABLE `attendance_machines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `attendance_machines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `attendance_machines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `attendance_machines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `attendance_machines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `attendance_machines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendance_machines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendance_machines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendance_machines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of attendance_machines
-- ----------------------------
INSERT INTO `attendance_machines` VALUES (1, 'ماكينة الدوام', '1', 'Attendnace Machine', '192.168.1.201', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);

-- ----------------------------
-- Table structure for attendance_notifications
-- ----------------------------
CREATE TABLE `attendance_notifications`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `notification_type_id` int UNSIGNED NOT NULL,
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `attendance_notifications_notification_type_id_foreign`(`notification_type_id` ASC) USING BTREE,
  INDEX `attendance_notifications_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `attendance_notifications_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `attendance_notifications_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `attendance_notifications_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `attendance_notifications_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendance_notifications_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendance_notifications_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendance_notifications_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendance_notifications_notification_type_id_foreign` FOREIGN KEY (`notification_type_id`) REFERENCES `notification_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of attendance_notifications
-- ----------------------------

-- ----------------------------
-- Table structure for attendance_types
-- ----------------------------
CREATE TABLE `attendance_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `attendance_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `attendance_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `attendance_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `attendance_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `attendance_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendance_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendance_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendance_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of attendance_types
-- ----------------------------
INSERT INTO `attendance_types` VALUES (1, 'دخول طبيعي', '1', 'Normal In', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `attendance_types` VALUES (2, 'خروج طبيعي', '2', 'Normal Out', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `attendance_types` VALUES (3, 'دخول اجازة سنوية', '3', 'Annual Vacation In', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `attendance_types` VALUES (4, 'خروج اجازة سنوية', '4', 'Annual Vacation Out', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `attendance_types` VALUES (5, 'دخول اجازة مرضية', '5', 'Health Vacation In', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `attendance_types` VALUES (6, 'خروج اجازة مرضية', '6', 'Health Vacation Out', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `attendance_types` VALUES (7, 'دخول مغادرة', '7', 'Leave In', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `attendance_types` VALUES (8, 'خروج مغادرة', '8', 'Leave Out', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `attendance_types` VALUES (9, 'دخول يدوي', '9', 'Manual In', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `attendance_types` VALUES (10, 'خروج يدوي', '10', 'Manual Out', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `attendance_types` VALUES (11, 'دخول عطلة', '11', 'Holiday In', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `attendance_types` VALUES (12, 'خروج عطلة', '12', 'Holiday Out', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);

-- ----------------------------
-- Table structure for attendances
-- ----------------------------
CREATE TABLE `attendances`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `employee_user_id` int UNSIGNED NOT NULL,
  `subscription_id` int UNSIGNED NULL DEFAULT NULL,
  `datetime` datetime NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `attendances_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `attendances_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `attendances_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `attendances_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `attendances_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendances_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendances_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `attendances_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of attendances
-- ----------------------------

-- ----------------------------
-- Table structure for audit_options
-- ----------------------------
CREATE TABLE `audit_options`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `is_it_text` int UNSIGNED NOT NULL,
  `is_it_checkbox` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `audit_options_is_it_text_foreign`(`is_it_text` ASC) USING BTREE,
  INDEX `audit_options_is_it_checkbox_foreign`(`is_it_checkbox` ASC) USING BTREE,
  INDEX `audit_options_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `audit_options_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `audit_options_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `audit_options_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `audit_options_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `audit_options_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `audit_options_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `audit_options_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `audit_options_is_it_checkbox_foreign` FOREIGN KEY (`is_it_checkbox`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `audit_options_is_it_text_foreign` FOREIGN KEY (`is_it_text`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of audit_options
-- ----------------------------

-- ----------------------------
-- Table structure for auditing_groups
-- ----------------------------
CREATE TABLE `auditing_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `auditing_group_id` int UNSIGNED NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `auditing_groups_auditing_group_id_foreign`(`auditing_group_id` ASC) USING BTREE,
  INDEX `auditing_groups_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `auditing_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `auditing_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `auditing_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `auditing_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `auditing_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `auditing_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `auditing_groups_auditing_group_id_foreign` FOREIGN KEY (`auditing_group_id`) REFERENCES `auditing_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `auditing_groups_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `auditing_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `auditing_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of auditing_groups
-- ----------------------------

-- ----------------------------
-- Table structure for auditing_settings
-- ----------------------------
CREATE TABLE `auditing_settings`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `first_serior_user_id` int UNSIGNED NULL DEFAULT NULL,
  `second_serior_user_id` int UNSIGNED NULL DEFAULT NULL,
  `third_serior_user_id` int UNSIGNED NULL DEFAULT NULL,
  `accounting_user_id` int UNSIGNED NULL DEFAULT NULL,
  `send_email_to_employee` int UNSIGNED NULL DEFAULT NULL,
  `financial_claim_title` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `email_for_financial_claim` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `new_balance_sheet_subject` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `new_balance_sheet_email` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `cc_email` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `final_balance_sheet_title` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `final_balance_sheet_email` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `email_header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `email_footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `auditing_settings_first_serior_user_id_foreign`(`first_serior_user_id` ASC) USING BTREE,
  INDEX `auditing_settings_second_serior_user_id_foreign`(`second_serior_user_id` ASC) USING BTREE,
  INDEX `auditing_settings_third_serior_user_id_foreign`(`third_serior_user_id` ASC) USING BTREE,
  INDEX `auditing_settings_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `auditing_settings_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `auditing_settings_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `auditing_settings_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `auditing_settings_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `auditing_settings_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `auditing_settings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `auditing_settings_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `auditing_settings_first_serior_user_id_foreign` FOREIGN KEY (`first_serior_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `auditing_settings_second_serior_user_id_foreign` FOREIGN KEY (`second_serior_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `auditing_settings_third_serior_user_id_foreign` FOREIGN KEY (`third_serior_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of auditing_settings
-- ----------------------------

-- ----------------------------
-- Table structure for available_accounting_months
-- ----------------------------
CREATE TABLE `available_accounting_months`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `month` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `state_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `available_accounting_months_state_id_foreign`(`state_id` ASC) USING BTREE,
  INDEX `available_accounting_months_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `available_accounting_months_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `available_accounting_months_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `available_accounting_months_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `available_accounting_months_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `available_accounting_months_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `available_accounting_months_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `available_accounting_months_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `available_accounting_months_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of available_accounting_months
-- ----------------------------

-- ----------------------------
-- Table structure for balance_sheet_audit_options
-- ----------------------------
CREATE TABLE `balance_sheet_audit_options`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `balance_sheet_audit_id` int UNSIGNED NOT NULL,
  `balance_sheet_id` int UNSIGNED NOT NULL,
  `audit_option_id` int UNSIGNED NOT NULL,
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `balance_sheet_audit_options_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `balance_sheet_audit_options_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `balance_sheet_audit_options_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `balance_sheet_audit_options_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `balance_sheet_audit_options_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_audit_options_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_audit_options_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_audit_options_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of balance_sheet_audit_options
-- ----------------------------

-- ----------------------------
-- Table structure for balance_sheet_audits
-- ----------------------------
CREATE TABLE `balance_sheet_audits`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `balance_sheet_id` int UNSIGNED NOT NULL,
  `auditer_user_id` int UNSIGNED NOT NULL,
  `turn` int NULL DEFAULT NULL,
  `rating` int NULL DEFAULT NULL,
  `start_datetime` datetime NULL DEFAULT NULL,
  `end_datetime` datetime NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `balance_sheet_audits_balance_sheet_id_foreign`(`balance_sheet_id` ASC) USING BTREE,
  INDEX `balance_sheet_audits_auditer_user_id_foreign`(`auditer_user_id` ASC) USING BTREE,
  INDEX `balance_sheet_audits_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `balance_sheet_audits_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `balance_sheet_audits_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `balance_sheet_audits_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `balance_sheet_audits_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_audits_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_audits_auditer_user_id_foreign` FOREIGN KEY (`auditer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_audits_balance_sheet_id_foreign` FOREIGN KEY (`balance_sheet_id`) REFERENCES `balance_sheets` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_audits_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_audits_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of balance_sheet_audits
-- ----------------------------

-- ----------------------------
-- Table structure for balance_sheet_files
-- ----------------------------
CREATE TABLE `balance_sheet_files`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `balance_sheet_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `balance_sheet_files_balance_sheet_id_foreign`(`balance_sheet_id` ASC) USING BTREE,
  INDEX `balance_sheet_files_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `balance_sheet_files_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `balance_sheet_files_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `balance_sheet_files_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `balance_sheet_files_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_files_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_files_balance_sheet_id_foreign` FOREIGN KEY (`balance_sheet_id`) REFERENCES `balance_sheets` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_files_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_files_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of balance_sheet_files
-- ----------------------------

-- ----------------------------
-- Table structure for balance_sheet_financial_claims
-- ----------------------------
CREATE TABLE `balance_sheet_financial_claims`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `balance_sheet_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `balance_sheet_financial_claims_balance_sheet_id_foreign`(`balance_sheet_id` ASC) USING BTREE,
  INDEX `balance_sheet_financial_claims_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `balance_sheet_financial_claims_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `balance_sheet_financial_claims_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `balance_sheet_financial_claims_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `balance_sheet_financial_claims_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_financial_claims_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_financial_claims_balance_sheet_id_foreign` FOREIGN KEY (`balance_sheet_id`) REFERENCES `balance_sheets` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_financial_claims_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_financial_claims_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of balance_sheet_financial_claims
-- ----------------------------

-- ----------------------------
-- Table structure for balance_sheet_rejects
-- ----------------------------
CREATE TABLE `balance_sheet_rejects`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `balance_sheet_rejects_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `balance_sheet_rejects_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `balance_sheet_rejects_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `balance_sheet_rejects_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `balance_sheet_rejects_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_rejects_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_rejects_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_rejects_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of balance_sheet_rejects
-- ----------------------------

-- ----------------------------
-- Table structure for balance_sheet_settings
-- ----------------------------
CREATE TABLE `balance_sheet_settings`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `main_account_id` int NULL DEFAULT NULL,
  `is_it_goods_at_the_beginning_of_the_period` int UNSIGNED NULL DEFAULT NULL,
  `is_it_goods_at_the_ending_of_the_period` int UNSIGNED NULL DEFAULT NULL,
  `is_it_title` int UNSIGNED NULL DEFAULT NULL,
  `is_it_account` int UNSIGNED NULL DEFAULT NULL,
  `is_it_profit_and_losses` int UNSIGNED NULL DEFAULT NULL,
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `formula` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `balance_sheet_settings_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `balance_sheet_settings_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `balance_sheet_settings_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `balance_sheet_settings_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `balance_sheet_settings_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_settings_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_settings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_settings_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 33 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of balance_sheet_settings
-- ----------------------------
INSERT INTO `balance_sheet_settings` VALUES (17, 'الموجودات', 1, NULL, NULL, 1, NULL, 1, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (18, 'الموجودات المتداولة', 1, NULL, NULL, 1, NULL, 1, NULL, 'الموجودات', NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (19, 'الصندوق', 1, NULL, NULL, NULL, NULL, NULL, NULL, 'الموجودات المتداولة', NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (20, 'النقدية في الصندوق', 1, NULL, NULL, NULL, NULL, NULL, NULL, 'الصندوق', NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (21, 'صندوق الشيكات', NULL, NULL, NULL, 1, NULL, NULL, NULL, 'الصندوق', NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (22, 'رصيد نهاية المدة', NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (23, 'الموجودات المتداولة', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (24, 'مجموع الموجودات المتداولة', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'رصيد نهاية المدة,+,الموجودات المتداولة', NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (25, 'مجموع الموجودات', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'مجموع الموجودات الثابتة,+,مجموع الموجودات المتداولة', NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (26, 'المطلوبات', NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (27, 'مجموع المطلوبات', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (28, 'حقوق الملكية', NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (29, 'الارباح والخسائر', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (30, 'حقوق الملكيه و راس المال', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (31, 'مجموع حقوق الملكية', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'الارباح والخسائر,+,حقوق الملكيه و راس المال', NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);
INSERT INTO `balance_sheet_settings` VALUES (32, 'مجموع المطلوبات وحقوق الملكية', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'مجموع حقوق الملكية,+, مجموع المطلوبات', NULL, 71, NULL, NULL, NULL, NULL, '2025-07-23 15:35:37', '2025-07-23 15:35:37', NULL);

-- ----------------------------
-- Table structure for balance_sheet_status
-- ----------------------------
CREATE TABLE `balance_sheet_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `is_it_uploaded` int UNSIGNED NOT NULL,
  `is_it_under_review` int UNSIGNED NOT NULL,
  `is_it_reassigned` int UNSIGNED NOT NULL,
  `is_it_reviewed` int UNSIGNED NOT NULL,
  `is_it_rejected` int UNSIGNED NOT NULL,
  `is_it_ready_to_deliver` int UNSIGNED NOT NULL,
  `is_it_delivered` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `balance_sheet_status_is_it_uploaded_foreign`(`is_it_uploaded` ASC) USING BTREE,
  INDEX `balance_sheet_status_is_it_under_review_foreign`(`is_it_under_review` ASC) USING BTREE,
  INDEX `balance_sheet_status_is_it_reviewed_foreign`(`is_it_reviewed` ASC) USING BTREE,
  INDEX `balance_sheet_status_is_it_rejected_foreign`(`is_it_rejected` ASC) USING BTREE,
  INDEX `balance_sheet_status_is_it_ready_to_deliver_foreign`(`is_it_ready_to_deliver` ASC) USING BTREE,
  INDEX `balance_sheet_status_is_it_delivered_foreign`(`is_it_delivered` ASC) USING BTREE,
  INDEX `balance_sheet_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `balance_sheet_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `balance_sheet_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `balance_sheet_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `balance_sheet_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_status_is_it_delivered_foreign` FOREIGN KEY (`is_it_delivered`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_status_is_it_ready_to_deliver_foreign` FOREIGN KEY (`is_it_ready_to_deliver`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_status_is_it_rejected_foreign` FOREIGN KEY (`is_it_rejected`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_status_is_it_reviewed_foreign` FOREIGN KEY (`is_it_reviewed`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_status_is_it_under_review_foreign` FOREIGN KEY (`is_it_under_review`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheet_status_is_it_uploaded_foreign` FOREIGN KEY (`is_it_uploaded`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of balance_sheet_status
-- ----------------------------
INSERT INTO `balance_sheet_status` VALUES (1, 'تم الرفع', '1', 'Uploaded', 1, 2, 2, 2, 2, 2, 2, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `balance_sheet_status` VALUES (2, 'تم الانتهاء من التدقيق الداخلي', '2', 'Under review', 2, 1, 2, 2, 2, 2, 2, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `balance_sheet_status` VALUES (3, 'تم التدقيق', '3', 'Reviewed', 2, 2, 2, 1, 2, 2, 2, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `balance_sheet_status` VALUES (4, 'اعادة تدقيق', '4', 'Reassign', 2, 2, 1, 2, 2, 2, 2, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `balance_sheet_status` VALUES (5, 'مرفوضة', '5', 'Rejected', 2, 2, 2, 2, 1, 2, 2, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `balance_sheet_status` VALUES (6, 'جاهزة للتسليم للعميل', '6', 'Ready to deliver', 2, 2, 2, 2, 2, 1, 2, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `balance_sheet_status` VALUES (7, 'تم التسليم للعميل', '7', 'Delivered', 2, 2, 2, 2, 2, 2, 1, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);

-- ----------------------------
-- Table structure for balance_sheets
-- ----------------------------
CREATE TABLE `balance_sheets`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `auditing_group_id` int UNSIGNED NOT NULL,
  `customer_user_id` int UNSIGNED NOT NULL,
  `auditer_user_id` int UNSIGNED NOT NULL,
  `balance_sheet_state_id` int UNSIGNED NOT NULL,
  `active_auditer_user_id` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `sent_email_with_financial_claim` int UNSIGNED NULL DEFAULT NULL,
  `uploaded_the_final_balance_sheet` int UNSIGNED NULL DEFAULT NULL,
  `send_final_balance_sheet` int UNSIGNED NULL DEFAULT NULL,
  `customer_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `price` double UNSIGNED NULL DEFAULT NULL,
  `cost` double UNSIGNED NULL DEFAULT NULL,
  `profit` double UNSIGNED NULL DEFAULT NULL,
  `time_till_done` double UNSIGNED NULL DEFAULT NULL,
  `actual_time_to_done` double UNSIGNED NULL DEFAULT NULL,
  `dose_it_upload_financial_claim` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `balance_sheets_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `balance_sheets_dose_it_upload_financial_claim_foreign`(`dose_it_upload_financial_claim` ASC) USING BTREE,
  INDEX `balance_sheets_active_auditer_user_id_foreign`(`active_auditer_user_id` ASC) USING BTREE,
  INDEX `balance_sheets_auditing_group_id_foreign`(`auditing_group_id` ASC) USING BTREE,
  INDEX `balance_sheets_customer_user_id_foreign`(`customer_user_id` ASC) USING BTREE,
  INDEX `balance_sheets_auditer_user_id_foreign`(`auditer_user_id` ASC) USING BTREE,
  INDEX `balance_sheets_balance_sheet_state_id_foreign`(`balance_sheet_state_id` ASC) USING BTREE,
  INDEX `balance_sheets_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `balance_sheets_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `balance_sheets_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `balance_sheets_active_auditer_user_id_foreign` FOREIGN KEY (`active_auditer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheets_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheets_auditer_user_id_foreign` FOREIGN KEY (`auditer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheets_auditing_group_id_foreign` FOREIGN KEY (`auditing_group_id`) REFERENCES `auditing_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheets_balance_sheet_state_id_foreign` FOREIGN KEY (`balance_sheet_state_id`) REFERENCES `balance_sheet_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheets_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheets_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheets_customer_user_id_foreign` FOREIGN KEY (`customer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheets_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `balance_sheets_dose_it_upload_financial_claim_foreign` FOREIGN KEY (`dose_it_upload_financial_claim`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of balance_sheets
-- ----------------------------

-- ----------------------------
-- Table structure for branches
-- ----------------------------
CREATE TABLE `branches`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `fax` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `tax_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number_after_comma` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `invoice_journal_note_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `e_invoice_data` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `reassignment_cost` date NULL DEFAULT NULL,
  `sales_tax_account_id` int UNSIGNED NULL DEFAULT NULL,
  `discount_allowed_account_id` int UNSIGNED NULL DEFAULT NULL,
  `discount_received_account_id` int UNSIGNED NULL DEFAULT NULL,
  `salary_expenses_account_id` int UNSIGNED NULL DEFAULT NULL,
  `salary_debit_account_id` int UNSIGNED NULL DEFAULT NULL,
  `external_purchases_account_id` int UNSIGNED NULL DEFAULT NULL,
  `payable_max_check_amount_per_day` int UNSIGNED NULL DEFAULT NULL,
  `customer_custom_fields_only` int UNSIGNED NULL DEFAULT NULL,
  `product_custom_fields_only` int UNSIGNED NULL DEFAULT NULL,
  `product_active_sales_fields` int UNSIGNED NULL DEFAULT NULL,
  `cost_of_goods_sold_account_id` int UNSIGNED NULL DEFAULT NULL,
  `goods_at_the_beginning_of_the_period_id` int UNSIGNED NULL DEFAULT NULL,
  `social_security_secretariats_account_id` int UNSIGNED NULL DEFAULT NULL,
  `company_contribution_to_social_security_account_id` int UNSIGNED NULL DEFAULT NULL,
  `collected_income_and_note_undeserved` int UNSIGNED NULL DEFAULT NULL,
  `can_do_sales_in_zero` int UNSIGNED NULL DEFAULT NULL,
  `is_products_has_expire_date` int UNSIGNED NULL DEFAULT NULL,
  `is_products_has_patch_number` int UNSIGNED NULL DEFAULT NULL,
  `is_products_has_serial_number` int UNSIGNED NULL DEFAULT NULL,
  `is_e_invoice` int UNSIGNED NULL DEFAULT NULL,
  `cost_calc_type` int UNSIGNED NULL DEFAULT NULL,
  `debits_account_id` int UNSIGNED NULL DEFAULT NULL,
  `credits_account_id` int UNSIGNED NULL DEFAULT NULL,
  `accounting_receipt_account_id` int UNSIGNED NULL DEFAULT NULL,
  `inventory_type_id` int UNSIGNED NULL DEFAULT NULL,
  `multi_currency_state_id` int UNSIGNED NULL DEFAULT NULL,
  `contract_close_state_id` int UNSIGNED NULL DEFAULT NULL,
  `stamp_user_id` int UNSIGNED NULL DEFAULT NULL,
  `expenses_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `income_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `purchase_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `employees_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `customers_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `vendors_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `broker_account_for_continuous_inventory_id` int UNSIGNED NULL DEFAULT NULL,
  `debit_aging_period` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `default_currency` int UNSIGNED NULL DEFAULT NULL,
  `tax_state_id` int UNSIGNED NULL DEFAULT NULL,
  `cost_center_id` int UNSIGNED NULL DEFAULT NULL,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `customer_id` int UNSIGNED NULL DEFAULT NULL,
  `balance_sheet_treeable` int UNSIGNED NULL DEFAULT NULL,
  `reports_header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `reports_footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `receipt_header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `receipt_footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `account_statement_footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `inventory_voucher_footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `last_css_file` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `chatgpt_token` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `branches_is_e_invoice_foreign`(`is_e_invoice` ASC) USING BTREE,
  INDEX `branches_customer_custom_fields_only_foreign`(`customer_custom_fields_only` ASC) USING BTREE,
  INDEX `branches_product_custom_fields_only_foreign`(`product_custom_fields_only` ASC) USING BTREE,
  INDEX `branches_can_do_sales_in_zero_foreign`(`can_do_sales_in_zero` ASC) USING BTREE,
  INDEX `branches_inventory_type_id_foreign`(`inventory_type_id` ASC) USING BTREE,
  INDEX `branches_multi_currency_state_id_foreign`(`multi_currency_state_id` ASC) USING BTREE,
  INDEX `branches_contract_close_state_id_foreign`(`contract_close_state_id` ASC) USING BTREE,
  INDEX `branches_employees_main_account_id_foreign`(`employees_main_account_id` ASC) USING BTREE,
  INDEX `branches_customers_main_account_id_foreign`(`customers_main_account_id` ASC) USING BTREE,
  INDEX `branches_vendors_main_account_id_foreign`(`vendors_main_account_id` ASC) USING BTREE,
  INDEX `branches_default_currency_foreign`(`default_currency` ASC) USING BTREE,
  INDEX `branches_tax_state_id_foreign`(`tax_state_id` ASC) USING BTREE,
  INDEX `branches_cost_center_id_foreign`(`cost_center_id` ASC) USING BTREE,
  INDEX `branches_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `branches_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `branches_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `branches_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_can_do_sales_in_zero_foreign` FOREIGN KEY (`can_do_sales_in_zero`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_contract_close_state_id_foreign` FOREIGN KEY (`contract_close_state_id`) REFERENCES `contract_close_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_cost_center_id_foreign` FOREIGN KEY (`cost_center_id`) REFERENCES `cost_centers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_customer_custom_fields_only_foreign` FOREIGN KEY (`customer_custom_fields_only`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_customers_main_account_id_foreign` FOREIGN KEY (`customers_main_account_id`) REFERENCES `main_accounts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_default_currency_foreign` FOREIGN KEY (`default_currency`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_employees_main_account_id_foreign` FOREIGN KEY (`employees_main_account_id`) REFERENCES `main_accounts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_inventory_type_id_foreign` FOREIGN KEY (`inventory_type_id`) REFERENCES `inventory_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_is_e_invoice_foreign` FOREIGN KEY (`is_e_invoice`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_multi_currency_state_id_foreign` FOREIGN KEY (`multi_currency_state_id`) REFERENCES `multi_currency_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_product_custom_fields_only_foreign` FOREIGN KEY (`product_custom_fields_only`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_tax_state_id_foreign` FOREIGN KEY (`tax_state_id`) REFERENCES `tax_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `branches_vendors_main_account_id_foreign` FOREIGN KEY (`vendors_main_account_id`) REFERENCES `main_accounts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of branches
-- ----------------------------
INSERT INTO `branches` VALUES (1, 'مجمع عيسى الطباخي وشركاه', '1', NULL, NULL, NULL, NULL, NULL, NULL, '3', 'رقم-رقم-رقم-رقم', '777=>street name=>اسم الحي=>اسم المدينة=>البلد=>الرمز البريدي=>الرقم الاضافي للعنوان=>معرف اخر', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2, 1, 1, NULL, NULL, NULL, NULL, 244, 1, 1, 1, 1, 2, 2, 241, 242, NULL, 1, 2, 2, NULL, 26, 21, 26, 114, 113, 211, NULL, NULL, 1, 2, 1, 2, NULL, 2, '<div class=\"row\">\r\n    <div class=\"col-5 center\">\r\n        <div class=\"bold\" style=\"font-size:30px\">مجمع عيسى الطباخي وشركاه</div>\r\n    </div>\r\n    <div class=\"col-2 center\">\r\n        <img width=\"180px\" height=\"100px\" src=\"https://eesa.cyberlapaccounts.com/main/public/storage/eesa.cyberlapaccounts.com/logo.png\" />\r\n    </div>\r\n    <div class=\"col-5 center\">\r\n        <div class=\"bold\" style=\"font-size:30px\">مجمع عيسى الطباخي وشركاه</div>\r\n    </div>\r\n</div>', NULL, '<div class=\"row\">\r\n    <div class=\"col-5 center\">\r\n        <div class=\"bold\" style=\"font-size:30px\">مجمع عيسى الطباخي وشركاه</div>\r\n    </div>\r\n    <div class=\"col-2 center\">\r\n        <img width=\"180px\" height=\"100px\" src=\"https://eesa.cyberlapaccounts.com/main/public/storage/eesa.cyberlapaccounts.com/logo.png\" />\r\n    </div>\r\n    <div class=\"col-5 center\">\r\n        <div class=\"bold\" style=\"font-size:30px\">مجمع عيسى الطباخي وشركاه</div>\r\n    </div>\r\n</div>', '<br />\r\n<br />\r\n<div class=\"end-footer\">\r\n    <div class=\"row\">\r\n        <div class=\"col-6\"><h3> المستلم:  عوني عيسى الطباخي</h3></div>\r\n        <div class=\"col-6\">\r\n            <h3> المحاسب :  \r\n            \r\n            </h3>\r\n            <img width=\'150\'  src=\'https://cyberlapaccounts.com/images/5458.png\' />\r\n        </div>\r\n    </div>\r\n    <br />\r\n    <div class=\"bg\" style=\"height: 40px; background-color:#1c85a7\"></div>\r\n</div>', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, '2025-06-12 14:05:49', '2025-07-16 11:38:22', NULL);

-- ----------------------------
-- Table structure for bus_groups
-- ----------------------------
CREATE TABLE `bus_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `main_child_zeros` double NULL DEFAULT 10,
  `main_child_counter` double NULL DEFAULT NULL,
  `sub_child_zeros` double NULL DEFAULT 1000,
  `sub_child_counter` double NULL DEFAULT NULL,
  `bus_group_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `bus_groups_bus_group_id_foreign`(`bus_group_id` ASC) USING BTREE,
  INDEX `bus_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `bus_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `bus_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `bus_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `bus_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `bus_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `bus_groups_bus_group_id_foreign` FOREIGN KEY (`bus_group_id`) REFERENCES `bus_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `bus_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `bus_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of bus_groups
-- ----------------------------
INSERT INTO `bus_groups` VALUES (1, 'باصات ملك', '1', NULL, 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);
INSERT INTO `bus_groups` VALUES (2, 'باصات اجار', '2', NULL, 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);

-- ----------------------------
-- Table structure for buses
-- ----------------------------
CREATE TABLE `buses`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `driver_user_id` int UNSIGNED NULL DEFAULT NULL,
  `rental_type_id` int UNSIGNED NULL DEFAULT NULL,
  `bus_group_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `buses_driver_user_id_foreign`(`driver_user_id` ASC) USING BTREE,
  INDEX `buses_bus_group_id_foreign`(`bus_group_id` ASC) USING BTREE,
  INDEX `buses_rental_type_id_foreign`(`rental_type_id` ASC) USING BTREE,
  INDEX `buses_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `buses_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `buses_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `buses_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `buses_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `buses_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `buses_bus_group_id_foreign` FOREIGN KEY (`bus_group_id`) REFERENCES `bus_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `buses_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `buses_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `buses_driver_user_id_foreign` FOREIGN KEY (`driver_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `buses_rental_type_id_foreign` FOREIGN KEY (`rental_type_id`) REFERENCES `rental_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of buses
-- ----------------------------

-- ----------------------------
-- Table structure for cache
-- ----------------------------
CREATE TABLE `cache`  (
  `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiration` int NOT NULL,
  PRIMARY KEY (`key`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of cache
-- ----------------------------

-- ----------------------------
-- Table structure for cache_locks
-- ----------------------------
CREATE TABLE `cache_locks`  (
  `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiration` int NOT NULL,
  PRIMARY KEY (`key`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of cache_locks
-- ----------------------------

-- ----------------------------
-- Table structure for car_auction_accounts
-- ----------------------------
CREATE TABLE `car_auction_accounts`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `account_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auction_accounts_account_id_foreign`(`account_id` ASC) USING BTREE,
  INDEX `car_auction_accounts_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auction_accounts_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auction_accounts_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auction_accounts_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auction_accounts_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_accounts_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_accounts_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_accounts_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_accounts_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auction_accounts
-- ----------------------------

-- ----------------------------
-- Table structure for car_auction_destinations
-- ----------------------------
CREATE TABLE `car_auction_destinations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auction_destinations_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auction_destinations_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auction_destinations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auction_destinations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auction_destinations_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_destinations_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_destinations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_destinations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auction_destinations
-- ----------------------------

-- ----------------------------
-- Table structure for car_auction_fines
-- ----------------------------
CREATE TABLE `car_auction_fines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `account_user_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auction_fines_account_user_id_foreign`(`account_user_id` ASC) USING BTREE,
  INDEX `car_auction_fines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auction_fines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auction_fines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auction_fines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auction_fines_account_user_id_foreign` FOREIGN KEY (`account_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_fines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_fines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_fines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_fines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auction_fines
-- ----------------------------

-- ----------------------------
-- Table structure for car_auction_groups
-- ----------------------------
CREATE TABLE `car_auction_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `car_auction_group_id` int UNSIGNED NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auction_groups_car_auction_group_id_foreign`(`car_auction_group_id` ASC) USING BTREE,
  INDEX `car_auction_groups_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `car_auction_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auction_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auction_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auction_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_groups_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_groups_car_auction_group_id_foreign` FOREIGN KEY (`car_auction_group_id`) REFERENCES `car_auction_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auction_groups
-- ----------------------------

-- ----------------------------
-- Table structure for car_auction_historys
-- ----------------------------
CREATE TABLE `car_auction_historys`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `car_auction_id` int UNSIGNED NOT NULL,
  `old_branch_id` int UNSIGNED NOT NULL,
  `new_branch_id` int UNSIGNED NOT NULL,
  `old_price` double UNSIGNED NULL DEFAULT NULL,
  `new_price` double UNSIGNED NULL DEFAULT NULL,
  `old_percentage` double UNSIGNED NULL DEFAULT NULL,
  `new_percentage` double UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auction_historys_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auction_historys_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auction_historys_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auction_historys_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auction_historys_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_historys_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_historys_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_historys_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auction_historys
-- ----------------------------

-- ----------------------------
-- Table structure for car_auction_refundable_insurances
-- ----------------------------
CREATE TABLE `car_auction_refundable_insurances`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `account_user_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auction_refundable_insurances_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auction_refundable_insurances_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auction_refundable_insurances_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auction_refundable_insurances_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auction_refundable_insurances_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_refundable_insurances_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_refundable_insurances_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_refundable_insurances_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auction_refundable_insurances
-- ----------------------------

-- ----------------------------
-- Table structure for car_auction_settings
-- ----------------------------
CREATE TABLE `car_auction_settings`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `broker_account_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `vehicle_shipping_cost_account_id` int UNSIGNED NULL DEFAULT NULL,
  `waiver_revenue_account_id` int UNSIGNED NULL DEFAULT NULL,
  `cost_of_cars_sold_account_id` int UNSIGNED NULL DEFAULT NULL,
  `revenue_from_the_sale_of_vehicles_account_id` int UNSIGNED NULL DEFAULT NULL,
  `brokerage_revenue_account_id` int UNSIGNED NULL DEFAULT NULL,
  `quality_inspection_expenses_account_id` int UNSIGNED NULL DEFAULT NULL,
  `quality_inspection_revenue_account_id` int UNSIGNED NULL DEFAULT NULL,
  `cost_to_put_it_in_inventory` double UNSIGNED NULL DEFAULT NULL,
  `revenue_download_account_id` int UNSIGNED NULL DEFAULT NULL,
  `header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auction_settings_broker_account_id_foreign`(`broker_account_id` ASC) USING BTREE,
  INDEX `car_auction_settings_waiver_revenue_account_id_foreign`(`waiver_revenue_account_id` ASC) USING BTREE,
  INDEX `car_auction_settings_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `car_auction_settings_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auction_settings_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auction_settings_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auction_settings_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auction_settings_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_settings_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_settings_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_settings_broker_account_id_foreign` FOREIGN KEY (`broker_account_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_settings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_settings_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_settings_waiver_revenue_account_id_foreign` FOREIGN KEY (`waiver_revenue_account_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auction_settings
-- ----------------------------

-- ----------------------------
-- Table structure for car_auction_stages
-- ----------------------------
CREATE TABLE `car_auction_stages`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `is_is_purchase` int UNSIGNED NULL DEFAULT NULL,
  `is_it_money_transfer` int UNSIGNED NULL DEFAULT NULL,
  `is_it_shipping` int UNSIGNED NULL DEFAULT NULL,
  `is_it_clearance` int UNSIGNED NULL DEFAULT NULL,
  `is_it_put_in_inventory` int UNSIGNED NULL DEFAULT NULL,
  `is_it_qc` int UNSIGNED NULL DEFAULT NULL,
  `is_it_selling` int UNSIGNED NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auction_stages_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auction_stages_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auction_stages_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auction_stages_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auction_stages_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_stages_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_stages_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_stages_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auction_stages
-- ----------------------------

-- ----------------------------
-- Table structure for car_auction_status
-- ----------------------------
CREATE TABLE `car_auction_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auction_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auction_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auction_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auction_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auction_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auction_status
-- ----------------------------
INSERT INTO `car_auction_status` VALUES (1, 'جديد', '1', 'New', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `car_auction_status` VALUES (2, 'في المحطة', '2', 'At terminal', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `car_auction_status` VALUES (3, 'محجوز', '3', 'Booked', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `car_auction_status` VALUES (4, 'في التحميل', '4', 'Loaded', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `car_auction_status` VALUES (5, 'تم شحنها', '5', 'Shipped', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `car_auction_status` VALUES (6, 'تم التوصيل', '6', 'Delivered', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `car_auction_status` VALUES (7, 'تم التسليم للعميل', '7', 'Relesed To Client', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `car_auction_status` VALUES (8, 'مباع', '8', 'Solid', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);

-- ----------------------------
-- Table structure for car_auction_types
-- ----------------------------
CREATE TABLE `car_auction_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auction_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auction_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auction_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auction_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auction_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auction_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auction_types
-- ----------------------------
INSERT INTO `car_auction_types` VALUES (1, 'شخصي للتجارة', '1', 'Personal for treading', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `car_auction_types` VALUES (2, 'لعميل + عمولة', '1', 'For customer with percentage', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);

-- ----------------------------
-- Table structure for car_auctions
-- ----------------------------
CREATE TABLE `car_auctions`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `car_auction_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `purchase_date` date NULL DEFAULT NULL,
  `pickup_date` date NULL DEFAULT NULL,
  `shipping_start_date` date NULL DEFAULT NULL,
  `arrival_date` date NULL DEFAULT NULL,
  `dispatch_date` date NULL DEFAULT NULL,
  `estimated_del_date` date NULL DEFAULT NULL,
  `actual_delivery_date` date NULL DEFAULT NULL,
  `carrier` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `qc_company_id` int UNSIGNED NULL DEFAULT NULL,
  `price` double NULL DEFAULT NULL,
  `car_auctions_type_id` int UNSIGNED NOT NULL,
  `car_auction_account_id` int UNSIGNED NOT NULL,
  `car_auction_destination_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `car_auction_state_id` int UNSIGNED NOT NULL,
  `car_auction_group_id` int UNSIGNED NOT NULL,
  `vendor_user_id` int UNSIGNED NULL DEFAULT NULL,
  `vehicle_sale_authorization` int UNSIGNED NULL DEFAULT NULL,
  `car_auction_stage_id` int UNSIGNED NULL DEFAULT NULL,
  `note_voucher_id` int UNSIGNED NULL DEFAULT NULL,
  `customer_user_id` int UNSIGNED NULL DEFAULT NULL,
  `auction_account_user_id` int UNSIGNED NOT NULL,
  `terminal_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `default_currency_id` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double UNSIGNED NOT NULL,
  `car_auction_percentage` double UNSIGNED NULL DEFAULT NULL,
  `days_till_receive_car` double UNSIGNED NULL DEFAULT NULL,
  `remain` double UNSIGNED NULL DEFAULT NULL,
  `min_selling_price` double UNSIGNED NULL DEFAULT NULL,
  `max_selling_price` double UNSIGNED NULL DEFAULT NULL,
  `selling_commission` double UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `user_note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auctions_car_auctions_type_id_foreign`(`car_auctions_type_id` ASC) USING BTREE,
  INDEX `car_auctions_car_auction_stage_id_foreign`(`car_auction_stage_id` ASC) USING BTREE,
  INDEX `car_auctions_car_auction_account_id_foreign`(`car_auction_account_id` ASC) USING BTREE,
  INDEX `car_auctions_car_auction_destination_id_foreign`(`car_auction_destination_id` ASC) USING BTREE,
  INDEX `car_auctions_note_voucher_id_foreign`(`note_voucher_id` ASC) USING BTREE,
  INDEX `car_auctions_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `car_auctions_car_auction_state_id_foreign`(`car_auction_state_id` ASC) USING BTREE,
  INDEX `car_auctions_car_auction_group_id_foreign`(`car_auction_group_id` ASC) USING BTREE,
  INDEX `car_auctions_vendor_user_id_foreign`(`vendor_user_id` ASC) USING BTREE,
  INDEX `car_auctions_vehicle_sale_authorization_foreign`(`vehicle_sale_authorization` ASC) USING BTREE,
  INDEX `car_auctions_customer_user_id_foreign`(`customer_user_id` ASC) USING BTREE,
  INDEX `car_auctions_auction_account_user_id_foreign`(`auction_account_user_id` ASC) USING BTREE,
  INDEX `car_auctions_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `car_auctions_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `car_auctions_default_currency_id_foreign`(`default_currency_id` ASC) USING BTREE,
  INDEX `car_auctions_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auctions_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auctions_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auctions_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auctions_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_auction_account_user_id_foreign` FOREIGN KEY (`auction_account_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_car_auction_account_id_foreign` FOREIGN KEY (`car_auction_account_id`) REFERENCES `car_auction_accounts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_car_auction_destination_id_foreign` FOREIGN KEY (`car_auction_destination_id`) REFERENCES `car_auction_destinations` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_car_auction_group_id_foreign` FOREIGN KEY (`car_auction_group_id`) REFERENCES `car_auction_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_car_auction_stage_id_foreign` FOREIGN KEY (`car_auction_stage_id`) REFERENCES `car_auction_stages` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_car_auction_state_id_foreign` FOREIGN KEY (`car_auction_state_id`) REFERENCES `car_auction_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_car_auctions_type_id_foreign` FOREIGN KEY (`car_auctions_type_id`) REFERENCES `car_auctions_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_customer_user_id_foreign` FOREIGN KEY (`customer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_default_currency_id_foreign` FOREIGN KEY (`default_currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_note_voucher_id_foreign` FOREIGN KEY (`note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_vehicle_sale_authorization_foreign` FOREIGN KEY (`vehicle_sale_authorization`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_vendor_user_id_foreign` FOREIGN KEY (`vendor_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auctions
-- ----------------------------

-- ----------------------------
-- Table structure for car_auctions_expenses_types
-- ----------------------------
CREATE TABLE `car_auctions_expenses_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `account_id` int UNSIGNED NULL DEFAULT NULL,
  `is_it_purchase` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `is_it_one_way_journal` int UNSIGNED NULL DEFAULT NULL,
  `is_it_one_way_journal_return` int UNSIGNED NULL DEFAULT NULL,
  `is_it_shipping_cost` int UNSIGNED NULL DEFAULT NULL,
  `is_it_clearance_cost` int UNSIGNED NULL DEFAULT NULL,
  `is_it_customs_insurance` int UNSIGNED NULL DEFAULT NULL,
  `is_it_clearance_expense` int UNSIGNED NULL DEFAULT NULL,
  `is_it_journal_entry` int UNSIGNED NULL DEFAULT NULL,
  `is_it_final` int UNSIGNED NULL DEFAULT NULL,
  `is_it_quality_inspection_expense` int UNSIGNED NULL DEFAULT NULL,
  `is_it_one_way_receipt` int UNSIGNED NULL DEFAULT NULL,
  `is_it_fines` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auctions_expenses_types_is_it_one_way_journal_foreign`(`is_it_one_way_journal` ASC) USING BTREE,
  INDEX `car_auctions_expenses_types_is_it_shipping_cost_foreign`(`is_it_shipping_cost` ASC) USING BTREE,
  INDEX `car_auctions_expenses_types_account_id_foreign`(`account_id` ASC) USING BTREE,
  INDEX `car_auctions_expenses_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auctions_expenses_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auctions_expenses_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auctions_expenses_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auctions_expenses_types_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_expenses_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_expenses_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_expenses_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_expenses_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_expenses_types_is_it_one_way_journal_foreign` FOREIGN KEY (`is_it_one_way_journal`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_expenses_types_is_it_shipping_cost_foreign` FOREIGN KEY (`is_it_shipping_cost`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auctions_expenses_types
-- ----------------------------

-- ----------------------------
-- Table structure for car_auctions_journal_entries
-- ----------------------------
CREATE TABLE `car_auctions_journal_entries`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `car_auctions_expenses_type_id` int UNSIGNED NOT NULL,
  `journal_entry_id` int UNSIGNED NOT NULL,
  `car_auction_id` int UNSIGNED NOT NULL,
  `car_auction_stage_id` int UNSIGNED NULL DEFAULT NULL,
  `is_main` int UNSIGNED NULL DEFAULT NULL,
  `is_final` int UNSIGNED NULL DEFAULT NULL,
  `is_it_qc` int UNSIGNED NULL DEFAULT NULL,
  `car_auction_refundable_insurance_id` int UNSIGNED NULL DEFAULT NULL,
  `car_auction_fine_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auctions_journal_entries_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `car_auctions_journal_entries_car_auction_id_foreign`(`car_auction_id` ASC) USING BTREE,
  INDEX `car_auctions_journal_entries_car_auction_stage_id_foreign`(`car_auction_stage_id` ASC) USING BTREE,
  INDEX `car_auctions_journal_entries_is_main_foreign`(`is_main` ASC) USING BTREE,
  INDEX `car_auctions_journal_entries_is_final_foreign`(`is_final` ASC) USING BTREE,
  INDEX `car_auctions_journal_entries_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auctions_journal_entries_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auctions_journal_entries_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auctions_journal_entries_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auctions_journal_entries_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_journal_entries_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_journal_entries_car_auction_id_foreign` FOREIGN KEY (`car_auction_id`) REFERENCES `car_auctions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_journal_entries_car_auction_stage_id_foreign` FOREIGN KEY (`car_auction_stage_id`) REFERENCES `car_auction_stages` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_journal_entries_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_journal_entries_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_journal_entries_is_final_foreign` FOREIGN KEY (`is_final`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_journal_entries_is_main_foreign` FOREIGN KEY (`is_main`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_journal_entries_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auctions_journal_entries
-- ----------------------------

-- ----------------------------
-- Table structure for car_auctions_types
-- ----------------------------
CREATE TABLE `car_auctions_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_auctions_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_auctions_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_auctions_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_auctions_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_auctions_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_auctions_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_auctions_types
-- ----------------------------
INSERT INTO `car_auctions_types` VALUES (1, 'للبيع', '1', 'Normal', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `car_auctions_types` VALUES (2, 'لزبون مع عمولة', '2', 'Customer with commission', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `car_auctions_types` VALUES (3, 'فحص جودة', '3', 'QC', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);

-- ----------------------------
-- Table structure for car_groups
-- ----------------------------
CREATE TABLE `car_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `car_group_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_groups_car_group_id_foreign`(`car_group_id` ASC) USING BTREE,
  INDEX `car_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_groups_car_group_id_foreign` FOREIGN KEY (`car_group_id`) REFERENCES `car_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_groups
-- ----------------------------
INSERT INTO `car_groups` VALUES (1, 'سيارات ركوب متوسط', '1', NULL, 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `car_groups` VALUES (2, 'سيارات هايبرد', '2', NULL, 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);

-- ----------------------------
-- Table structure for car_maintenances
-- ----------------------------
CREATE TABLE `car_maintenances`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `car_id` int UNSIGNED NOT NULL,
  `employee_user_id` int UNSIGNED NULL DEFAULT NULL,
  `car_receipt_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `date` date NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_maintenances_car_id_foreign`(`car_id` ASC) USING BTREE,
  INDEX `car_maintenances_employee_user_id_foreign`(`employee_user_id` ASC) USING BTREE,
  INDEX `car_maintenances_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `car_maintenances_car_receipt_id_foreign`(`car_receipt_id` ASC) USING BTREE,
  INDEX `car_maintenances_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_maintenances_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_maintenances_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_maintenances_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_maintenances_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_maintenances_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_maintenances_car_id_foreign` FOREIGN KEY (`car_id`) REFERENCES `cars` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_maintenances_car_receipt_id_foreign` FOREIGN KEY (`car_receipt_id`) REFERENCES `car_receipts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_maintenances_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_maintenances_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_maintenances_employee_user_id_foreign` FOREIGN KEY (`employee_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_maintenances_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_maintenances
-- ----------------------------

-- ----------------------------
-- Table structure for car_models
-- ----------------------------
CREATE TABLE `car_models`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_models_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_models_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_models_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_models_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_models_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_models_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_models_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_models_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_models
-- ----------------------------
INSERT INTO `car_models` VALUES (1, 'مرسيدس', '1', 'Mercedes', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `car_models` VALUES (2, 'هونداي', '2', 'Houndai', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);

-- ----------------------------
-- Table structure for car_receipt_groups
-- ----------------------------
CREATE TABLE `car_receipt_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_child_counter` int NULL DEFAULT NULL,
  `sub_child_zeros` int NULL DEFAULT NULL,
  `sub_child_counter` int NULL DEFAULT NULL,
  `car_receipt_group_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_receipt_groups_car_receipt_group_id_foreign`(`car_receipt_group_id` ASC) USING BTREE,
  INDEX `car_receipt_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_receipt_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_receipt_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_receipt_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_receipt_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_groups_car_receipt_group_id_foreign` FOREIGN KEY (`car_receipt_group_id`) REFERENCES `car_receipt_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_receipt_groups
-- ----------------------------
INSERT INTO `car_receipt_groups` VALUES (1, 'سيارات ركوب متوسط', '1', NULL, 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `car_receipt_groups` VALUES (2, 'سيارات هايبرد', '2', NULL, 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);

-- ----------------------------
-- Table structure for car_receipt_journal_entries
-- ----------------------------
CREATE TABLE `car_receipt_journal_entries`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `journal_entry_id` int UNSIGNED NOT NULL,
  `car_id` int UNSIGNED NOT NULL,
  `car_receipt_id` int UNSIGNED NOT NULL,
  `date` date NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_receipt_journal_entries_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `car_receipt_journal_entries_car_id_foreign`(`car_id` ASC) USING BTREE,
  INDEX `car_receipt_journal_entries_car_receipt_id_foreign`(`car_receipt_id` ASC) USING BTREE,
  INDEX `car_receipt_journal_entries_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_receipt_journal_entries_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_receipt_journal_entries_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_receipt_journal_entries_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_receipt_journal_entries_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_journal_entries_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_journal_entries_car_id_foreign` FOREIGN KEY (`car_id`) REFERENCES `cars` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_journal_entries_car_receipt_id_foreign` FOREIGN KEY (`car_receipt_id`) REFERENCES `car_receipts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_journal_entries_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_journal_entries_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_journal_entries_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_receipt_journal_entries
-- ----------------------------

-- ----------------------------
-- Table structure for car_receipt_note_vouchers
-- ----------------------------
CREATE TABLE `car_receipt_note_vouchers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `note_voucher_id` int UNSIGNED NOT NULL,
  `car_id` int UNSIGNED NOT NULL,
  `car_receipt_id` int UNSIGNED NOT NULL,
  `date` date NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_receipt_note_vouchers_note_voucher_id_foreign`(`note_voucher_id` ASC) USING BTREE,
  INDEX `car_receipt_note_vouchers_car_id_foreign`(`car_id` ASC) USING BTREE,
  INDEX `car_receipt_note_vouchers_car_receipt_id_foreign`(`car_receipt_id` ASC) USING BTREE,
  INDEX `car_receipt_note_vouchers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_receipt_note_vouchers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_receipt_note_vouchers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_receipt_note_vouchers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_receipt_note_vouchers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_note_vouchers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_note_vouchers_car_id_foreign` FOREIGN KEY (`car_id`) REFERENCES `cars` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_note_vouchers_car_receipt_id_foreign` FOREIGN KEY (`car_receipt_id`) REFERENCES `car_receipts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_note_vouchers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_note_vouchers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_note_vouchers_note_voucher_id_foreign` FOREIGN KEY (`note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_receipt_note_vouchers
-- ----------------------------

-- ----------------------------
-- Table structure for car_receipt_reserve_material_orders
-- ----------------------------
CREATE TABLE `car_receipt_reserve_material_orders`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `car_receipt_id` int UNSIGNED NOT NULL,
  `reserve_material_order_id` int UNSIGNED NOT NULL,
  `car_id` int UNSIGNED NOT NULL,
  `date` date NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_receipt_reserve_material_orders_car_receipt_id_foreign`(`car_receipt_id` ASC) USING BTREE,
  INDEX `car_receipt_reserve_material_orders_car_id_foreign`(`car_id` ASC) USING BTREE,
  INDEX `car_receipt_reserve_material_orders_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_receipt_reserve_material_orders_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_receipt_reserve_material_orders_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_receipt_reserve_material_orders_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_receipt_reserve_material_orders_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_reserve_material_orders_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_reserve_material_orders_car_id_foreign` FOREIGN KEY (`car_id`) REFERENCES `cars` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_reserve_material_orders_car_receipt_id_foreign` FOREIGN KEY (`car_receipt_id`) REFERENCES `car_receipts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_reserve_material_orders_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_reserve_material_orders_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_receipt_reserve_material_orders
-- ----------------------------

-- ----------------------------
-- Table structure for car_receipt_status
-- ----------------------------
CREATE TABLE `car_receipt_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_receipt_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_receipt_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_receipt_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_receipt_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_receipt_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipt_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_receipt_status
-- ----------------------------
INSERT INTO `car_receipt_status` VALUES (1, 'تم الاستلام', '1', 'Recevied', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `car_receipt_status` VALUES (2, 'تم بدئ الصيانة', '2', 'Construction started', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `car_receipt_status` VALUES (3, 'موقوف', '3', 'Suspended', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `car_receipt_status` VALUES (4, 'تمت الصيانة ولم يسلم', '4', 'Construction finshed but not delivered', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `car_receipt_status` VALUES (5, 'تمت الصيانة والتسليم', '5', 'Construction finshed and delivered', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);

-- ----------------------------
-- Table structure for car_receipts
-- ----------------------------
CREATE TABLE `car_receipts`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `received_date` datetime NOT NULL,
  `delivery_date` datetime NULL DEFAULT NULL,
  `received_car_meter` double NULL DEFAULT NULL,
  `delivered_car_meter` double NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `car_receipt_state_id` int UNSIGNED NULL DEFAULT NULL,
  `car_id` int UNSIGNED NOT NULL,
  `car_receipt_group_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_receipts_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `car_receipts_car_receipt_state_id_foreign`(`car_receipt_state_id` ASC) USING BTREE,
  INDEX `car_receipts_car_id_foreign`(`car_id` ASC) USING BTREE,
  INDEX `car_receipts_car_receipt_group_id_foreign`(`car_receipt_group_id` ASC) USING BTREE,
  INDEX `car_receipts_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_receipts_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_receipts_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_receipts_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_receipts_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipts_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipts_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipts_car_id_foreign` FOREIGN KEY (`car_id`) REFERENCES `cars` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipts_car_receipt_group_id_foreign` FOREIGN KEY (`car_receipt_group_id`) REFERENCES `car_receipt_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipts_car_receipt_state_id_foreign` FOREIGN KEY (`car_receipt_state_id`) REFERENCES `car_receipt_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipts_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_receipts_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_receipts
-- ----------------------------

-- ----------------------------
-- Table structure for car_status
-- ----------------------------
CREATE TABLE `car_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `car_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `car_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `car_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `car_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `car_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `car_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of car_status
-- ----------------------------
INSERT INTO `car_status` VALUES (1, 'جيدة', '1', 'good', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);
INSERT INTO `car_status` VALUES (2, 'تحتاج لصيانة كثيرة', '2', 'Need many maintanices', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:00', '2025-06-12 14:06:00', NULL);

-- ----------------------------
-- Table structure for cars
-- ----------------------------
CREATE TABLE `cars`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `car_group_id` int UNSIGNED NOT NULL,
  `car_model_id` int UNSIGNED NULL DEFAULT NULL,
  `customer_user_id` int UNSIGNED NOT NULL,
  `car_state_id` int UNSIGNED NULL DEFAULT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `date_of_manufacture` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `chassis_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `engine_size` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `color` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `plate_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `side_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `cars_car_group_id_foreign`(`car_group_id` ASC) USING BTREE,
  INDEX `cars_car_model_id_foreign`(`car_model_id` ASC) USING BTREE,
  INDEX `cars_customer_user_id_foreign`(`customer_user_id` ASC) USING BTREE,
  INDEX `cars_car_state_id_foreign`(`car_state_id` ASC) USING BTREE,
  INDEX `cars_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `cars_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `cars_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `cars_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `cars_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cars_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cars_car_group_id_foreign` FOREIGN KEY (`car_group_id`) REFERENCES `car_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cars_car_model_id_foreign` FOREIGN KEY (`car_model_id`) REFERENCES `car_models` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cars_car_state_id_foreign` FOREIGN KEY (`car_state_id`) REFERENCES `car_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cars_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cars_customer_user_id_foreign` FOREIGN KEY (`customer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cars_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of cars
-- ----------------------------

-- ----------------------------
-- Table structure for category_relations
-- ----------------------------
CREATE TABLE `category_relations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_category_id` int UNSIGNED NOT NULL,
  `pos_product_category_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `category_relations_product_category_id_foreign`(`product_category_id` ASC) USING BTREE,
  INDEX `category_relations_pos_product_category_id_foreign`(`pos_product_category_id` ASC) USING BTREE,
  INDEX `category_relations_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `category_relations_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `category_relations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `category_relations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `category_relations_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `category_relations_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `category_relations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `category_relations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `category_relations_pos_product_category_id_foreign` FOREIGN KEY (`pos_product_category_id`) REFERENCES `pos_product_categories` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `category_relations_product_category_id_foreign` FOREIGN KEY (`product_category_id`) REFERENCES `product_categories` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of category_relations
-- ----------------------------

-- ----------------------------
-- Table structure for ch_favorites
-- ----------------------------
CREATE TABLE `ch_favorites`  (
  `id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint NOT NULL,
  `favorite_id` bigint NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ch_favorites
-- ----------------------------

-- ----------------------------
-- Table structure for ch_messages
-- ----------------------------
CREATE TABLE `ch_messages`  (
  `id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `from_id` bigint NOT NULL,
  `to_id` bigint NOT NULL,
  `body` varchar(5000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `attachment` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `seen` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ch_messages
-- ----------------------------

-- ----------------------------
-- Table structure for changed_product_prices
-- ----------------------------
CREATE TABLE `changed_product_prices`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `smallest_unit_selling_price` double UNSIGNED NULL DEFAULT NULL,
  `offer_start_date` date NULL DEFAULT NULL,
  `offer_end_date` date NULL DEFAULT NULL,
  `smallest_unit_selling_price_above` double NULL DEFAULT NULL,
  `smallest_unit_selling_price_above_price` double NULL DEFAULT NULL,
  `pos_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `changed_product_prices_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `changed_product_prices_pos_id_foreign`(`pos_id` ASC) USING BTREE,
  INDEX `changed_product_prices_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `changed_product_prices_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `changed_product_prices_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `changed_product_prices_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `changed_product_prices_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `changed_product_prices_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `changed_product_prices_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `changed_product_prices_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `changed_product_prices_pos_id_foreign` FOREIGN KEY (`pos_id`) REFERENCES `poss` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `changed_product_prices_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of changed_product_prices
-- ----------------------------

-- ----------------------------
-- Table structure for check_books
-- ----------------------------
CREATE TABLE `check_books`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `bank_account_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `check_books_bank_account_id_foreign`(`bank_account_id` ASC) USING BTREE,
  INDEX `check_books_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `check_books_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `check_books_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `check_books_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `check_books_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_books_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_books_bank_account_id_foreign` FOREIGN KEY (`bank_account_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_books_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_books_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of check_books
-- ----------------------------
INSERT INTO `check_books` VALUES (1, 'دفتر شيكات', '1', 'Check book', NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for check_collect_types
-- ----------------------------
CREATE TABLE `check_collect_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `check_collect_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `check_collect_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `check_collect_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `check_collect_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `check_collect_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_collect_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_collect_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_collect_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of check_collect_types
-- ----------------------------
INSERT INTO `check_collect_types` VALUES (1, 'CO', '1', 'First beneficiary', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `check_collect_types` VALUES (2, 'مجير', '2', 'Check Check', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for check_collection_types
-- ----------------------------
CREATE TABLE `check_collection_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `check_collection_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `check_collection_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `check_collection_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `check_collection_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `check_collection_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_collection_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_collection_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_collection_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of check_collection_types
-- ----------------------------
INSERT INTO `check_collection_types` VALUES (1, 'في الحافظة', '1', 'In Portfolio', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);
INSERT INTO `check_collection_types` VALUES (2, 'شيك نقدي', '2', 'Cash check', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);

-- ----------------------------
-- Table structure for check_journal_entries
-- ----------------------------
CREATE TABLE `check_journal_entries`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `check_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_entry_line_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `check_journal_entries_check_id_foreign`(`check_id` ASC) USING BTREE,
  INDEX `check_journal_entries_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `check_journal_entries_journal_entry_line_id_foreign`(`journal_entry_line_id` ASC) USING BTREE,
  INDEX `check_journal_entries_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `check_journal_entries_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `check_journal_entries_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `check_journal_entries_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `check_journal_entries_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_journal_entries_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_journal_entries_check_id_foreign` FOREIGN KEY (`check_id`) REFERENCES `checks` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_journal_entries_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_journal_entries_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_journal_entries_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_journal_entries_journal_entry_line_id_foreign` FOREIGN KEY (`journal_entry_line_id`) REFERENCES `journal_entry_lines` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of check_journal_entries
-- ----------------------------

-- ----------------------------
-- Table structure for check_portfolios
-- ----------------------------
CREATE TABLE `check_portfolios`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `cheques_under_collection_user_id` int UNSIGNED NULL DEFAULT NULL,
  `cheques_for_payment_user_id` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `bank_user_id` int UNSIGNED NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `check_portfolios_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `check_portfolios_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `check_portfolios_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `check_portfolios_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `check_portfolios_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_portfolios_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_portfolios_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_portfolios_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of check_portfolios
-- ----------------------------
INSERT INTO `check_portfolios` VALUES (1, 'خزينة الشركة', '1', 'Internal Portfolio', 9, 29, 1, NULL, 4, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `check_portfolios` VALUES (2, 'خزينة البنك', '2', 'Bank Portfolio', 9, 29, 1, NULL, 3, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for check_reject_reasons
-- ----------------------------
CREATE TABLE `check_reject_reasons`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `check_reject_reasons_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `check_reject_reasons_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `check_reject_reasons_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `check_reject_reasons_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `check_reject_reasons_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_reject_reasons_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_reject_reasons_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_reject_reasons_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of check_reject_reasons
-- ----------------------------
INSERT INTO `check_reject_reasons` VALUES (1, 'لا يوجد رصيد كافي', '1', 'No enugh Balance', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `check_reject_reasons` VALUES (2, 'اختلاف توقيع', '2', 'Different Singture', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `check_reject_reasons` VALUES (3, 'الشيك ممزق', '3', 'Broken Check', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `check_reject_reasons` VALUES (4, 'اخرى', '3', 'Other', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for check_status
-- ----------------------------
CREATE TABLE `check_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `check_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `check_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `check_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `check_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `check_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of check_status
-- ----------------------------
INSERT INTO `check_status` VALUES (1, 'محصل', '1', 'Collected', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `check_status` VALUES (2, 'قيد التحصيل', '2', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `check_status` VALUES (3, 'رفض', '3', 'Rejected', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `check_status` VALUES (4, 'تم تجييره', '4', 'Rejected', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for check_types
-- ----------------------------
CREATE TABLE `check_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `check_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `check_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `check_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `check_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `check_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `check_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of check_types
-- ----------------------------
INSERT INTO `check_types` VALUES (1, 'شيك قيد التحصيل', '1', 'Pending Collect Check', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `check_types` VALUES (2, 'شيك اجل الدفع', '2', 'Payable Check', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for checks
-- ----------------------------
CREATE TABLE `checks`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` double NOT NULL,
  `collected_date` date NOT NULL,
  `due_date` date NOT NULL,
  `account_id` int UNSIGNED NOT NULL,
  `delegate_id` int UNSIGNED NULL DEFAULT NULL,
  `check_bank_account_id` int UNSIGNED NULL DEFAULT NULL,
  `delegate_commission_percentage` double NULL DEFAULT NULL,
  `delegate_commission_value` double NULL DEFAULT NULL,
  `delegate_auto_journal_entry_state_id` int UNSIGNED NULL DEFAULT NULL,
  `partner_id` int UNSIGNED NOT NULL,
  `journal_entry_id` int UNSIGNED NOT NULL,
  `journal_entry_line_id` int UNSIGNED NOT NULL,
  `check_state_id` int UNSIGNED NULL DEFAULT NULL,
  `check_type_id` int UNSIGNED NOT NULL,
  `check_collect_type_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `cost_center_id` int UNSIGNED NULL DEFAULT NULL,
  `check_portfolio_id` int UNSIGNED NULL DEFAULT NULL,
  `checked` int UNSIGNED NULL DEFAULT NULL,
  `changed_from_state_collected` int UNSIGNED NULL DEFAULT NULL,
  `changed_from_state_rejected` int UNSIGNED NULL DEFAULT NULL,
  `bank` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `branch` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double UNSIGNED NOT NULL,
  `tax_percentage` double UNSIGNED NULL DEFAULT NULL,
  `default_currency_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `checks_account_id_foreign`(`account_id` ASC) USING BTREE,
  INDEX `checks_delegate_id_foreign`(`delegate_id` ASC) USING BTREE,
  INDEX `checks_check_bank_account_id_foreign`(`check_bank_account_id` ASC) USING BTREE,
  INDEX `checks_delegate_auto_journal_entry_state_id_foreign`(`delegate_auto_journal_entry_state_id` ASC) USING BTREE,
  INDEX `checks_checked_foreign`(`checked` ASC) USING BTREE,
  INDEX `checks_partner_id_foreign`(`partner_id` ASC) USING BTREE,
  INDEX `checks_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `checks_journal_entry_line_id_foreign`(`journal_entry_line_id` ASC) USING BTREE,
  INDEX `checks_check_state_id_foreign`(`check_state_id` ASC) USING BTREE,
  INDEX `checks_check_type_id_foreign`(`check_type_id` ASC) USING BTREE,
  INDEX `checks_check_collect_type_id_foreign`(`check_collect_type_id` ASC) USING BTREE,
  INDEX `checks_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `checks_cost_center_id_foreign`(`cost_center_id` ASC) USING BTREE,
  INDEX `checks_check_portfolio_id_foreign`(`check_portfolio_id` ASC) USING BTREE,
  INDEX `checks_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `checks_default_currency_id_foreign`(`default_currency_id` ASC) USING BTREE,
  INDEX `checks_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `checks_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `checks_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `checks_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `checks_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_check_bank_account_id_foreign` FOREIGN KEY (`check_bank_account_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_check_collect_type_id_foreign` FOREIGN KEY (`check_collect_type_id`) REFERENCES `check_collect_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_check_portfolio_id_foreign` FOREIGN KEY (`check_portfolio_id`) REFERENCES `check_portfolios` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_check_state_id_foreign` FOREIGN KEY (`check_state_id`) REFERENCES `check_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_check_type_id_foreign` FOREIGN KEY (`check_type_id`) REFERENCES `check_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_checked_foreign` FOREIGN KEY (`checked`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_cost_center_id_foreign` FOREIGN KEY (`cost_center_id`) REFERENCES `cost_centers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_default_currency_id_foreign` FOREIGN KEY (`default_currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_delegate_auto_journal_entry_state_id_foreign` FOREIGN KEY (`delegate_auto_journal_entry_state_id`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_delegate_id_foreign` FOREIGN KEY (`delegate_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_journal_entry_line_id_foreign` FOREIGN KEY (`journal_entry_line_id`) REFERENCES `journal_entry_lines` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `checks_partner_id_foreign` FOREIGN KEY (`partner_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of checks
-- ----------------------------

-- ----------------------------
-- Table structure for cities
-- ----------------------------
CREATE TABLE `cities`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `country_id` int UNSIGNED NULL DEFAULT NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `cities_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `cities_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `cities_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `cities_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cities_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cities_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of cities
-- ----------------------------
INSERT INTO `cities` VALUES (1, 'city 1', '1', NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);

-- ----------------------------
-- Table structure for class_apis
-- ----------------------------
CREATE TABLE `class_apis`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `class_id` int UNSIGNED NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `iframe_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `class_apis_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `class_apis_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `class_apis_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `class_apis_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `class_apis_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_apis_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_apis_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_apis_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of class_apis
-- ----------------------------

-- ----------------------------
-- Table structure for class_bus_periods
-- ----------------------------
CREATE TABLE `class_bus_periods`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `from_datetime` datetime NOT NULL,
  `to_datetime` datetime NOT NULL,
  `driver_user_id` int UNSIGNED NOT NULL,
  `teacher_user_id` int UNSIGNED NULL DEFAULT NULL,
  `bus_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `class_bus_periods_driver_user_id_foreign`(`driver_user_id` ASC) USING BTREE,
  INDEX `class_bus_periods_teacher_user_id_foreign`(`teacher_user_id` ASC) USING BTREE,
  INDEX `class_bus_periods_bus_id_foreign`(`bus_id` ASC) USING BTREE,
  INDEX `class_bus_periods_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `class_bus_periods_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `class_bus_periods_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `class_bus_periods_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `class_bus_periods_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_bus_periods_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_bus_periods_bus_id_foreign` FOREIGN KEY (`bus_id`) REFERENCES `buses` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_bus_periods_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_bus_periods_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_bus_periods_driver_user_id_foreign` FOREIGN KEY (`driver_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_bus_periods_teacher_user_id_foreign` FOREIGN KEY (`teacher_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of class_bus_periods
-- ----------------------------

-- ----------------------------
-- Table structure for class_schedules
-- ----------------------------
CREATE TABLE `class_schedules`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `rank` int NULL DEFAULT NULL,
  `class_id` int UNSIGNED NOT NULL,
  `subject_id` int UNSIGNED NOT NULL,
  `day_id` int UNSIGNED NOT NULL,
  `teacher_user_id` int UNSIGNED NULL DEFAULT NULL,
  `start_time` time NULL DEFAULT NULL,
  `end_time` time NULL DEFAULT NULL,
  `start_url` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `class_schedules_class_id_foreign`(`class_id` ASC) USING BTREE,
  INDEX `class_schedules_subject_id_foreign`(`subject_id` ASC) USING BTREE,
  INDEX `class_schedules_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `class_schedules_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `class_schedules_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `class_schedules_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `class_schedules_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_schedules_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_schedules_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_schedules_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_schedules_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_schedules_subject_id_foreign` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of class_schedules
-- ----------------------------

-- ----------------------------
-- Table structure for class_teachers
-- ----------------------------
CREATE TABLE `class_teachers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `teacher_user_id` int UNSIGNED NOT NULL,
  `class_id` int UNSIGNED NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `class_teachers_teacher_user_id_foreign`(`teacher_user_id` ASC) USING BTREE,
  INDEX `class_teachers_class_id_foreign`(`class_id` ASC) USING BTREE,
  INDEX `class_teachers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `class_teachers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `class_teachers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `class_teachers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `class_teachers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_teachers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_teachers_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_teachers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_teachers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `class_teachers_teacher_user_id_foreign` FOREIGN KEY (`teacher_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of class_teachers
-- ----------------------------

-- ----------------------------
-- Table structure for classe_groups
-- ----------------------------
CREATE TABLE `classe_groups`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `main_child_zeros` double NULL DEFAULT 10,
  `main_child_counter` double NULL DEFAULT NULL,
  `sub_child_zeros` double NULL DEFAULT 1000,
  `sub_child_counter` double NULL DEFAULT NULL,
  `class_group_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `classe_groups_class_group_id_foreign`(`class_group_id` ASC) USING BTREE,
  INDEX `classe_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `classe_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `classe_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `classe_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `classe_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `classe_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `classe_groups_class_group_id_foreign` FOREIGN KEY (`class_group_id`) REFERENCES `classe_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `classe_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `classe_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of classe_groups
-- ----------------------------
INSERT INTO `classe_groups` VALUES (1, 'العواشر', '1', NULL, 10, NULL, 1000, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);

-- ----------------------------
-- Table structure for classes
-- ----------------------------
CREATE TABLE `classes`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `class_group_id` int UNSIGNED NOT NULL,
  `master_user_id` int UNSIGNED NOT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `classes_class_group_id_foreign`(`class_group_id` ASC) USING BTREE,
  INDEX `classes_master_user_id_foreign`(`master_user_id` ASC) USING BTREE,
  INDEX `classes_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `classes_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `classes_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `classes_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `classes_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `classes_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `classes_class_group_id_foreign` FOREIGN KEY (`class_group_id`) REFERENCES `classe_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `classes_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `classes_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `classes_master_user_id_foreign` FOREIGN KEY (`master_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of classes
-- ----------------------------

-- ----------------------------
-- Table structure for clearance_companies
-- ----------------------------
CREATE TABLE `clearance_companies`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `account_user_id` int UNSIGNED NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `clearance_companies_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `clearance_companies_account_user_id_foreign`(`account_user_id` ASC) USING BTREE,
  INDEX `clearance_companies_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `clearance_companies_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `clearance_companies_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `clearance_companies_account_user_id_foreign` FOREIGN KEY (`account_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `clearance_companies_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `clearance_companies_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `clearance_companies_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `clearance_companies_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of clearance_companies
-- ----------------------------

-- ----------------------------
-- Table structure for cliche_order_status
-- ----------------------------
CREATE TABLE `cliche_order_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `cliche_order_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `cliche_order_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `cliche_order_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `cliche_order_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `cliche_order_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_order_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_order_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_order_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of cliche_order_status
-- ----------------------------
INSERT INTO `cliche_order_status` VALUES (1, 'قيد الانشاء', '1', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `cliche_order_status` VALUES (2, 'موقوف', '2', 'Stoped', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `cliche_order_status` VALUES (3, 'تم', '3', 'Finshed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);
INSERT INTO `cliche_order_status` VALUES (4, 'تم التحويل الى فاتورة', '4', 'Finshed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:04', '2025-06-12 14:06:04', NULL);

-- ----------------------------
-- Table structure for cliche_order_types
-- ----------------------------
CREATE TABLE `cliche_order_types`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `foreign_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `next_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `cliche_order_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `cliche_order_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `cliche_order_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `cliche_order_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `cliche_order_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_order_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_order_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_order_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of cliche_order_types
-- ----------------------------

-- ----------------------------
-- Table structure for cliche_orders
-- ----------------------------
CREATE TABLE `cliche_orders`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `height` double NULL DEFAULT NULL,
  `width` double NULL DEFAULT NULL,
  `height_repeats` double NULL DEFAULT NULL,
  `width_repeats` double NULL DEFAULT NULL,
  `number_of_colors` double NULL DEFAULT NULL,
  `quantity` double NOT NULL,
  `price` double NULL DEFAULT NULL,
  `printing_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `user_id` int UNSIGNED NOT NULL,
  `note_voucher_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `cliche_printing_quality_id` int UNSIGNED NULL DEFAULT NULL,
  `cliche_thinkness_id` int UNSIGNED NULL DEFAULT NULL,
  `plate_type_id` int UNSIGNED NOT NULL,
  `shabak_type_id` int UNSIGNED NULL DEFAULT NULL,
  `cliche_order_type_id` int UNSIGNED NOT NULL,
  `cliche_order_state_id` int UNSIGNED NOT NULL,
  `asset_id` int UNSIGNED NULL DEFAULT NULL,
  `cylinder_measurement` double UNSIGNED NULL DEFAULT NULL,
  `cylinder_discount` double UNSIGNED NULL DEFAULT NULL,
  `checked` int UNSIGNED NULL DEFAULT NULL,
  `color1` int NULL DEFAULT NULL,
  `color1_width` double NULL DEFAULT NULL,
  `color1_height` double NULL DEFAULT NULL,
  `color1_quantity` double NULL DEFAULT NULL,
  `color2` int NULL DEFAULT NULL,
  `color2_width` double NULL DEFAULT NULL,
  `color2_height` double NULL DEFAULT NULL,
  `color2_quantity` double NULL DEFAULT NULL,
  `color3` int NULL DEFAULT NULL,
  `color3_width` double NULL DEFAULT NULL,
  `color3_height` double NULL DEFAULT NULL,
  `color3_quantity` double NULL DEFAULT NULL,
  `color4` int NULL DEFAULT NULL,
  `color4_width` double NULL DEFAULT NULL,
  `color4_height` double NULL DEFAULT NULL,
  `color4_quantity` double NULL DEFAULT NULL,
  `color5` int NULL DEFAULT NULL,
  `color5_width` double NULL DEFAULT NULL,
  `color5_height` double NULL DEFAULT NULL,
  `color5_quantity` double NULL DEFAULT NULL,
  `color6` int NULL DEFAULT NULL,
  `color6_width` double NULL DEFAULT NULL,
  `color6_height` double NULL DEFAULT NULL,
  `color6_quantity` double NULL DEFAULT NULL,
  `color7` int NULL DEFAULT NULL,
  `color7_width` double NULL DEFAULT NULL,
  `color7_height` double NULL DEFAULT NULL,
  `color7_quantity` double NULL DEFAULT NULL,
  `color8` int NULL DEFAULT NULL,
  `color8_width` double NULL DEFAULT NULL,
  `color8_height` double NULL DEFAULT NULL,
  `color8_quantity` double NULL DEFAULT NULL,
  `color9` int NULL DEFAULT NULL,
  `color9_width` double NULL DEFAULT NULL,
  `color9_height` double NULL DEFAULT NULL,
  `color9_quantity` double NULL DEFAULT NULL,
  `color10` int NULL DEFAULT NULL,
  `color10_width` double NULL DEFAULT NULL,
  `color10_height` double NULL DEFAULT NULL,
  `color10_quantity` double NULL DEFAULT NULL,
  `color11` int NULL DEFAULT NULL,
  `color11_width` double NULL DEFAULT NULL,
  `color11_height` double NULL DEFAULT NULL,
  `color11_quantity` double NULL DEFAULT NULL,
  `color12` int NULL DEFAULT NULL,
  `color12_width` double NULL DEFAULT NULL,
  `color12_height` double NULL DEFAULT NULL,
  `color12_quantity` double NULL DEFAULT NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `created_by` int UNSIGNED NULL DEFAULT NULL,
  `deleted_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_by` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `cliche_orders_asset_id_foreign`(`asset_id` ASC) USING BTREE,
  INDEX `cliche_orders_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `cliche_orders_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `cliche_orders_cliche_printing_quality_id_foreign`(`cliche_printing_quality_id` ASC) USING BTREE,
  INDEX `cliche_orders_cliche_thinkness_id_foreign`(`cliche_thinkness_id` ASC) USING BTREE,
  INDEX `cliche_orders_plate_type_id_foreign`(`plate_type_id` ASC) USING BTREE,
  INDEX `cliche_orders_shabak_type_id_foreign`(`shabak_type_id` ASC) USING BTREE,
  INDEX `cliche_orders_cliche_order_type_id_foreign`(`cliche_order_type_id` ASC) USING BTREE,
  INDEX `cliche_orders_cliche_order_state_id_foreign`(`cliche_order_state_id` ASC) USING BTREE,
  INDEX `cliche_orders_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `cliche_orders_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `cliche_orders_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `cliche_orders_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `cliche_orders_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_orders_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_orders_asset_id_foreign` FOREIGN KEY (`asset_id`) REFERENCES `assets` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_orders_cliche_order_state_id_foreign` FOREIGN KEY (`cliche_order_state_id`) REFERENCES `cliche_order_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_orders_cliche_order_type_id_foreign` FOREIGN KEY (`cliche_order_type_id`) REFERENCES `cliche_order_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_orders_cliche_printing_quality_id_foreign` FOREIGN KEY (`cliche_printing_quality_id`) REFERENCES `cliche_printing_qualitys` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_orders_cliche_thinkness_id_foreign` FOREIGN KEY (`cliche_thinkness_id`) REFERENCES `cliche_thinknesss` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_orders_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_orders_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_orders_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_orders_plate_type_id_foreign` FOREIGN KEY (`plate_type_id`) REFERENCES `plate_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_orders_shabak_type_id_foreign` FOREIGN KEY (`shabak_type_id`) REFERENCES `shabak_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `cliche_orders_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of cliche_orders
-- ----------------------------

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