-- Table structure for models_users_approvals
-- ----------------------------
CREATE TABLE `models_users_approvals`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int UNSIGNED NOT NULL,
  `model_id` int UNSIGNED NOT NULL,
  `subject_id` int UNSIGNED NOT NULL,
  `state_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 `models_users_approvals_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `models_users_approvals_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `models_users_approvals_model_id_foreign`(`model_id` ASC) USING BTREE,
  INDEX `models_users_approvals_state_id_foreign`(`state_id` ASC) USING BTREE,
  INDEX `models_users_approvals_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `models_users_approvals_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `models_users_approvals_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `models_users_approvals_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `models_users_approvals_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `models_users_approvals_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `models_users_approvals_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `models_users_approvals_model_id_foreign` FOREIGN KEY (`model_id`) REFERENCES `models` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `models_users_approvals_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `models_users_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 models_users_approvals
-- ----------------------------

-- ----------------------------
-- Table structure for mrl_specifications
-- ----------------------------
CREATE TABLE `mrl_specifications`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `material_requisition_line_id` int UNSIGNED NOT NULL,
  `product_specification_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `product_specification_value_id` int UNSIGNED NULL DEFAULT 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 `mrl_specifications_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `mrl_specifications_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `mrl_specifications_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `mrl_specifications_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `mrl_specifications_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `mrl_specifications_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `mrl_specifications_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `mrl_specifications_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 mrl_specifications
-- ----------------------------

-- ----------------------------
-- Table structure for multi_currency_status
-- ----------------------------
CREATE TABLE `multi_currency_status`  (
  `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,
  `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 `multi_currency_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `multi_currency_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `multi_currency_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `multi_currency_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 multi_currency_status
-- ----------------------------
INSERT INTO `multi_currency_status` VALUES (1, 'عملة واحدة', 'One currency', '1', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `multi_currency_status` VALUES (2, 'متعدد العملات', 'Multiable currencies', '2', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);

-- ----------------------------
-- Table structure for multiable_product_offer_lines
-- ----------------------------
CREATE TABLE `multiable_product_offer_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `multiable_product_offer_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 `multiable_product_offer_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `multiable_product_offer_lines_multiable_product_offer_id_foreign`(`multiable_product_offer_id` ASC) USING BTREE,
  INDEX `multiable_product_offer_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `multiable_product_offer_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `multiable_product_offer_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `multiable_product_offer_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `multiable_product_offer_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `multiable_product_offer_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `multiable_product_offer_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `multiable_product_offer_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `multiable_product_offer_lines_multiable_product_offer_id_foreign` FOREIGN KEY (`multiable_product_offer_id`) REFERENCES `multiable_product_offers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `multiable_product_offer_lines_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 multiable_product_offer_lines
-- ----------------------------

-- ----------------------------
-- Table structure for multiable_product_offers
-- ----------------------------
CREATE TABLE `multiable_product_offers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  `if_sales_above_quantity` double NOT NULL,
  `price` double NOT NULL,
  `branch_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 `multiable_product_offers_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `multiable_product_offers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `multiable_product_offers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `multiable_product_offers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `multiable_product_offers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `multiable_product_offers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `multiable_product_offers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `multiable_product_offers_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `multiable_product_offers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `multiable_product_offers_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 multiable_product_offers
-- ----------------------------

-- ----------------------------
-- Table structure for note_voucher_components
-- ----------------------------
CREATE TABLE `note_voucher_components`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `note_voucher_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 `note_voucher_components_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `note_voucher_components_note_voucher_id_foreign`(`note_voucher_id` ASC) USING BTREE,
  INDEX `note_voucher_components_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `note_voucher_components_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `note_voucher_components_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `note_voucher_components_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `note_voucher_components_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_components_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_components_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_components_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_components_note_voucher_id_foreign` FOREIGN KEY (`note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_components_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 note_voucher_components
-- ----------------------------

-- ----------------------------
-- Table structure for note_voucher_line_serials
-- ----------------------------
CREATE TABLE `note_voucher_line_serials`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `note_voucher_line_id` int UNSIGNED NOT NULL,
  `sold_to_note_voucher_line_id` int UNSIGNED NULL DEFAULT NULL,
  `state_id` int UNSIGNED NOT NULL,
  `serial` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT 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 `note_voucher_line_serials_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `note_voucher_line_serials_note_voucher_line_id_foreign`(`note_voucher_line_id` ASC) USING BTREE,
  INDEX `note_voucher_line_serials_state_id_foreign`(`state_id` ASC) USING BTREE,
  INDEX `note_voucher_line_serials_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `note_voucher_line_serials_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `note_voucher_line_serials_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `note_voucher_line_serials_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `note_voucher_line_serials_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_line_serials_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_line_serials_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_line_serials_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_line_serials_note_voucher_line_id_foreign` FOREIGN KEY (`note_voucher_line_id`) REFERENCES `note_voucher_lines` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_line_serials_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_line_serials_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 note_voucher_line_serials
-- ----------------------------

-- ----------------------------
-- Table structure for note_voucher_line_specifications
-- ----------------------------
CREATE TABLE `note_voucher_line_specifications`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `note_voucher_line_id` int UNSIGNED NOT NULL,
  `product_specification_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `product_specification_value_id` int UNSIGNED NULL DEFAULT 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 `note_voucher_line_specifications_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `note_voucher_line_specifications_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `note_voucher_line_specifications_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `note_voucher_line_specifications_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `note_voucher_line_specifications_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_line_specifications_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_line_specifications_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_line_specifications_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 note_voucher_line_specifications
-- ----------------------------

-- ----------------------------
-- Table structure for note_voucher_lines
-- ----------------------------
CREATE TABLE `note_voucher_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `quantity` double NULL DEFAULT NULL,
  `quantity_t` double NULL DEFAULT NULL,
  `remain` double NULL DEFAULT NULL,
  `date` date NOT NULL,
  `note_voucher_id` int UNSIGNED NOT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_id` int UNSIGNED NULL DEFAULT NULL,
  `jouranl_id` int UNSIGNED NULL DEFAULT NULL,
  `warehouse_id` int UNSIGNED NULL DEFAULT NULL,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `cost_center_id` int UNSIGNED NULL DEFAULT NULL,
  `unit_id` int UNSIGNED NULL DEFAULT NULL,
  `note_voucher_type_id` int UNSIGNED NULL DEFAULT NULL,
  `posting_state_id` int UNSIGNED NOT NULL,
  `product_total_quantity_id` int UNSIGNED NULL DEFAULT NULL,
  `is_componentable` int UNSIGNED NULL DEFAULT NULL,
  `work_order_id` int UNSIGNED NULL DEFAULT NULL,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `sales_person_id` int UNSIGNED NULL DEFAULT NULL,
  `sales_person_percentage` double NULL DEFAULT NULL,
  `sales_person_amount` double NULL DEFAULT NULL,
  `in_date_unit_rate` double NULL DEFAULT NULL,
  `price` double NULL DEFAULT NULL,
  `price_t` double NULL DEFAULT NULL,
  `price_with_cost` double NULL DEFAULT NULL,
  `price_with_cost_t` double NULL DEFAULT NULL,
  `in_date_tax` double NULL DEFAULT NULL,
  `discount_percentage` double NULL DEFAULT NULL,
  `discount_after_discount` double NULL DEFAULT NULL,
  `discount_after_discount_value` double NULL DEFAULT NULL,
  `line_price` double NULL DEFAULT NULL,
  `line_price_with_discount` double NULL DEFAULT NULL,
  `line_price_with_tax` double NULL DEFAULT NULL,
  `line_discount_value` double NULL DEFAULT NULL,
  `line_tax_value` double NULL DEFAULT NULL,
  `discount_value` double NULL DEFAULT NULL,
  `expire_date` date NULL DEFAULT NULL,
  `is_it_bonus` int UNSIGNED NULL DEFAULT NULL,
  `tax_state_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,
  `branch_id` int UNSIGNED NOT NULL,
  `currency_id` int UNSIGNED NULL DEFAULT NULL,
  `in_date_currency_rate` double NULL DEFAULT NULL,
  `is_it_inventory_settlement` int NULL DEFAULT NULL,
  `one_unit_cost` double NULL DEFAULT NULL,
  `cost_in_date` double NULL DEFAULT NULL,
  `balance_in_date` double 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 `note_voucher_lines_tax_state_id_foreign`(`tax_state_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_note_voucher_id_foreign`(`note_voucher_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_warehouse_id_foreign`(`warehouse_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_cost_center_id_foreign`(`cost_center_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_is_it_bonus_foreign`(`is_it_bonus` ASC) USING BTREE,
  INDEX `note_voucher_lines_note_voucher_type_id_foreign`(`note_voucher_type_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_posting_state_id_foreign`(`posting_state_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_product_total_quantity_id_foreign`(`product_total_quantity_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_is_componentable_foreign`(`is_componentable` ASC) USING BTREE,
  INDEX `note_voucher_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `note_voucher_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `note_voucher_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `note_voucher_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_cost_center_id_foreign` FOREIGN KEY (`cost_center_id`) REFERENCES `cost_centers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_is_componentable_foreign` FOREIGN KEY (`is_componentable`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_is_it_bonus_foreign` FOREIGN KEY (`is_it_bonus`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_note_voucher_id_foreign` FOREIGN KEY (`note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_note_voucher_type_id_foreign` FOREIGN KEY (`note_voucher_type_id`) REFERENCES `note_voucher_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_posting_state_id_foreign` FOREIGN KEY (`posting_state_id`) REFERENCES `posting_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_product_total_quantity_id_foreign` FOREIGN KEY (`product_total_quantity_id`) REFERENCES `product_total_quantitys` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_tax_state_id_foreign` FOREIGN KEY (`tax_state_id`) REFERENCES `tax_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_lines_warehouse_id_foreign` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouses` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of note_voucher_lines
-- ----------------------------

-- ----------------------------
-- Table structure for note_voucher_out_types
-- ----------------------------
CREATE TABLE `note_voucher_out_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 `note_voucher_out_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `note_voucher_out_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `note_voucher_out_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `note_voucher_out_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `note_voucher_out_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_out_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_out_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_out_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 note_voucher_out_types
-- ----------------------------
INSERT INTO `note_voucher_out_types` VALUES (1, 'ليس سند حجز', '1', 'Not booking voucher', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:56', '2025-06-12 14:05:56', NULL);
INSERT INTO `note_voucher_out_types` VALUES (2, 'سند حجز', '1', 'Booking voucher', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:56', '2025-06-12 14:05:56', NULL);

-- ----------------------------
-- Table structure for note_voucher_types
-- ----------------------------
CREATE TABLE `note_voucher_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,
  `journal_id` int UNSIGNED NULL DEFAULT NULL,
  `in_out_type_id` int UNSIGNED NOT NULL,
  `numbering_type_id` int UNSIGNED NOT NULL,
  `note_voucher_out_type_id` int UNSIGNED NOT NULL,
  `dose_it_create_journal_entry` int UNSIGNED NOT NULL,
  `broker_account_for_journal_entry` int UNSIGNED NULL DEFAULT NULL,
  `support_cost_centers` int UNSIGNED NULL DEFAULT NULL,
  `next_number` int NULL DEFAULT NULL,
  `have_price` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `footer` 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 `note_voucher_types_have_price_foreign`(`have_price` ASC) USING BTREE,
  INDEX `note_voucher_types_journal_id_foreign`(`journal_id` ASC) USING BTREE,
  INDEX `note_voucher_types_in_out_type_id_foreign`(`in_out_type_id` ASC) USING BTREE,
  INDEX `note_voucher_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `note_voucher_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `note_voucher_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `note_voucher_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_types_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_types_have_price_foreign` FOREIGN KEY (`have_price`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_types_in_out_type_id_foreign` FOREIGN KEY (`in_out_type_id`) REFERENCES `in_out_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_voucher_types_journal_id_foreign` FOREIGN KEY (`journal_id`) REFERENCES `journals` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of note_voucher_types
-- ----------------------------
INSERT INTO `note_voucher_types` VALUES (1, 'سند ادخال', '1', 'Receipt note voucher', NULL, 1, 1, 1, 2, NULL, 2, NULL, 2, 1, '\r\n                <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://softya.com/demo/public/storage/logo.png\" />\r\n                    </div>\r\n                    <div class=\"col-5 center\">\r\n                        <div class=\"bold\" style=\"font-size:30px\">Company name</div>\r\n                    </div>\r\n                </div>\r\n            ', NULL, 1, NULL, NULL, NULL, NULL, NULL, '2025-06-12 14:05:50', '2025-06-12 14:05:50', NULL);
INSERT INTO `note_voucher_types` VALUES (2, 'سند اخراج', '2', 'Delivery note voucher', NULL, 2, 1, 1, 2, NULL, 2, NULL, 2, 1, '\r\n                <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://softya.com/demo/public/storage/logo.png\" />\r\n                    </div>\r\n                    <div class=\"col-5 center\">\r\n                        <div class=\"bold\" style=\"font-size:30px\">Company name</div>\r\n                    </div>\r\n                </div>\r\n            ', NULL, 1, NULL, NULL, NULL, NULL, NULL, '2025-06-12 14:05:50', '2025-06-12 14:05:50', NULL);
INSERT INTO `note_voucher_types` VALUES (3, 'سند نقل', '3', 'Transfer note voucher', NULL, 3, 1, 1, 2, NULL, 2, NULL, 2, 1, '\r\n                <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://softya.com/demo/public/storage/logo.png\" />\r\n                    </div>\r\n                    <div class=\"col-5 center\">\r\n                        <div class=\"bold\" style=\"font-size:30px\">Company name</div>\r\n                    </div>\r\n                </div>\r\n            ', NULL, 1, NULL, NULL, NULL, NULL, NULL, '2025-06-12 14:05:50', '2025-06-12 14:05:50', NULL);

-- ----------------------------
-- Table structure for note_vouchers
-- ----------------------------
CREATE TABLE `note_vouchers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `from_warehouse` int UNSIGNED NOT NULL,
  `to_warehouse` int UNSIGNED NOT NULL,
  `note_voucher_type_id` int UNSIGNED NOT NULL,
  `posting_state_id` int UNSIGNED NOT NULL,
  `foreign_order_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,
  `cost_center_id` int UNSIGNED NULL DEFAULT NULL,
  `approved_date` date NULL DEFAULT NULL,
  `approved_state_id` int UNSIGNED NULL DEFAULT NULL,
  `work_order_id` int UNSIGNED NULL DEFAULT NULL,
  `work_order_line_step_id` int UNSIGNED NULL DEFAULT NULL,
  `employee_id` int UNSIGNED NULL DEFAULT NULL,
  `account_id` int UNSIGNED NULL DEFAULT NULL,
  `set_as_final_stock` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `journal_entry_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 `note_vouchers_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `note_vouchers_cost_center_id_foreign`(`cost_center_id` ASC) USING BTREE,
  INDEX `note_vouchers_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `note_vouchers_from_warehouse_foreign`(`from_warehouse` ASC) USING BTREE,
  INDEX `note_vouchers_to_warehouse_foreign`(`to_warehouse` ASC) USING BTREE,
  INDEX `note_vouchers_note_voucher_type_id_foreign`(`note_voucher_type_id` ASC) USING BTREE,
  INDEX `note_vouchers_posting_state_id_foreign`(`posting_state_id` ASC) USING BTREE,
  INDEX `note_vouchers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `note_vouchers_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `note_vouchers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `note_vouchers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `note_vouchers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_vouchers_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_vouchers_cost_center_id_foreign` FOREIGN KEY (`cost_center_id`) REFERENCES `cost_centers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_vouchers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_vouchers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_vouchers_from_warehouse_foreign` FOREIGN KEY (`from_warehouse`) REFERENCES `warehouses` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_vouchers_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_vouchers_note_voucher_type_id_foreign` FOREIGN KEY (`note_voucher_type_id`) REFERENCES `note_voucher_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_vouchers_posting_state_id_foreign` FOREIGN KEY (`posting_state_id`) REFERENCES `posting_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_vouchers_to_warehouse_foreign` FOREIGN KEY (`to_warehouse`) REFERENCES `warehouses` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `note_vouchers_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 note_vouchers
-- ----------------------------

-- ----------------------------
-- Table structure for notification_columns
-- ----------------------------
CREATE TABLE `notification_columns`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `model_id` int UNSIGNED NOT NULL,
  `column_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci 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 `notification_columns_model_id_foreign`(`model_id` ASC) USING BTREE,
  INDEX `notification_columns_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `notification_columns_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `notification_columns_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `notification_columns_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `notification_columns_model_id_foreign` FOREIGN KEY (`model_id`) REFERENCES `models` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of notification_columns
-- ----------------------------
INSERT INTO `notification_columns` VALUES (1, 39, 'user_id', 1, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `notification_columns` VALUES (2, 39, 'from_date', 1, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `notification_columns` VALUES (3, 39, 'to_date', 1, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);

-- ----------------------------
-- Table structure for notification_sends
-- ----------------------------
CREATE TABLE `notification_sends`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `to` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `notification_column_id` int UNSIGNED NOT NULL,
  `notification_column_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci 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 `notification_sends_notification_column_id_foreign`(`notification_column_id` ASC) USING BTREE,
  INDEX `notification_sends_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `notification_sends_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `notification_sends_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `notification_sends_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `notification_sends_notification_column_id_foreign` FOREIGN KEY (`notification_column_id`) REFERENCES `notification_columns` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of notification_sends
-- ----------------------------

-- ----------------------------
-- Table structure for notification_types
-- ----------------------------
CREATE TABLE `notification_types`  (
  `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,
  `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 `notification_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `notification_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `notification_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `notification_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 notification_types
-- ----------------------------
INSERT INTO `notification_types` VALUES (1, 'عبر البريد الالكتروني', 'Email', '1', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `notification_types` VALUES (2, 'رسائل نصية', 'sms', '2', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);

-- ----------------------------
-- Table structure for notifications
-- ----------------------------
CREATE TABLE `notifications`  (
  `id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `notifiable_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `notifiable_id` bigint UNSIGNED NOT NULL,
  `data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `read_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `notifications_notifiable_type_notifiable_id_index`(`notifiable_type` ASC, `notifiable_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of notifications
-- ----------------------------

-- ----------------------------
-- Table structure for numbering_types
-- ----------------------------
CREATE TABLE `numbering_types`  (
  `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,
  `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 `numbering_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `numbering_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `numbering_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `numbering_types_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 numbering_types
-- ----------------------------
INSERT INTO `numbering_types` VALUES (1, 'تسلسلي', 'Auto increments', '1', 1, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `numbering_types` VALUES (2, 'شهري', 'monthly', '2', 1, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `numbering_types` VALUES (3, 'سنوي', 'yearly', '3', 1, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `numbering_types` VALUES (4, 'تسلسلي غير معدل', 'Auto increments not editable', '4', 1, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);

-- ----------------------------
-- Table structure for o_s_invoice_customer_status
-- ----------------------------
CREATE TABLE `o_s_invoice_customer_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 `o_s_invoice_customer_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `o_s_invoice_customer_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `o_s_invoice_customer_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `o_s_invoice_customer_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `o_s_invoice_customer_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `o_s_invoice_customer_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `o_s_invoice_customer_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `o_s_invoice_customer_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 o_s_invoice_customer_status
-- ----------------------------
INSERT INTO `o_s_invoice_customer_status` VALUES (1, 'تم الاستلام والرضى', '1', 'Delivered with satisfied', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);
INSERT INTO `o_s_invoice_customer_status` VALUES (2, 'شكوى', '2', 'Complain', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);

-- ----------------------------
-- Table structure for online_exam_answers
-- ----------------------------
CREATE TABLE `online_exam_answers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `online_exam_id` int UNSIGNED NOT NULL,
  `student_user_id` int UNSIGNED NOT NULL,
  `question_option_id` int UNSIGNED NULL DEFAULT NULL,
  `question_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 `online_exam_answers_online_exam_id_foreign`(`online_exam_id` ASC) USING BTREE,
  INDEX `online_exam_answers_student_user_id_foreign`(`student_user_id` ASC) USING BTREE,
  INDEX `online_exam_answers_question_option_id_foreign`(`question_option_id` ASC) USING BTREE,
  INDEX `online_exam_answers_question_id_foreign`(`question_id` ASC) USING BTREE,
  INDEX `online_exam_answers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_exam_answers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_exam_answers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_exam_answers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_exam_answers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_answers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_answers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_answers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_answers_online_exam_id_foreign` FOREIGN KEY (`online_exam_id`) REFERENCES `online_exams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_answers_question_id_foreign` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_answers_question_option_id_foreign` FOREIGN KEY (`question_option_id`) REFERENCES `question_options` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_answers_student_user_id_foreign` FOREIGN KEY (`student_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 online_exam_answers
-- ----------------------------

-- ----------------------------
-- Table structure for online_exam_attendances
-- ----------------------------
CREATE TABLE `online_exam_attendances`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `online_exam_id` int UNSIGNED NOT NULL,
  `student_user_id` int UNSIGNED NOT NULL,
  `date` 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 `online_exam_attendances_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_exam_attendances_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_exam_attendances_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_exam_attendances_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_exam_attendances_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_attendances_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_attendances_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_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 online_exam_attendances
-- ----------------------------

-- ----------------------------
-- Table structure for online_exam_questions
-- ----------------------------
CREATE TABLE `online_exam_questions`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `online_exam_id` int UNSIGNED NOT NULL,
  `question_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 `online_exam_questions_online_exam_id_foreign`(`online_exam_id` ASC) USING BTREE,
  INDEX `online_exam_questions_question_id_foreign`(`question_id` ASC) USING BTREE,
  INDEX `online_exam_questions_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_exam_questions_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_exam_questions_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_exam_questions_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_exam_questions_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_questions_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_questions_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_questions_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_questions_online_exam_id_foreign` FOREIGN KEY (`online_exam_id`) REFERENCES `online_exams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_questions_question_id_foreign` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of online_exam_questions
-- ----------------------------

-- ----------------------------
-- Table structure for online_exam_students
-- ----------------------------
CREATE TABLE `online_exam_students`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `online_exam_id` int UNSIGNED NOT NULL,
  `student_user_id` int UNSIGNED NOT NULL,
  `subject_id` int UNSIGNED NOT NULL,
  `exam_mark` int UNSIGNED NOT NULL,
  `student_mark` 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 `online_exam_students_online_exam_id_foreign`(`online_exam_id` ASC) USING BTREE,
  INDEX `online_exam_students_student_user_id_foreign`(`student_user_id` ASC) USING BTREE,
  INDEX `online_exam_students_subject_id_foreign`(`subject_id` ASC) USING BTREE,
  INDEX `online_exam_students_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_exam_students_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_exam_students_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_exam_students_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_exam_students_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_students_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_students_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_students_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_students_online_exam_id_foreign` FOREIGN KEY (`online_exam_id`) REFERENCES `online_exams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_students_student_user_id_foreign` FOREIGN KEY (`student_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exam_students_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 online_exam_students
-- ----------------------------

-- ----------------------------
-- Table structure for online_exams
-- ----------------------------
CREATE TABLE `online_exams`  (
  `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,
  `subject_id` int UNSIGNED NOT NULL,
  `start_datetime` datetime NOT NULL,
  `end_datetime` datetime NOT NULL,
  `exam_degree_of_success` double NULL DEFAULT NULL,
  `show_mark_after_finsh` int UNSIGNED NOT NULL,
  `durtion_till_end_from_start` 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 `online_exams_class_id_foreign`(`class_id` ASC) USING BTREE,
  INDEX `online_exams_subject_id_foreign`(`subject_id` ASC) USING BTREE,
  INDEX `online_exams_show_mark_after_finsh_foreign`(`show_mark_after_finsh` ASC) USING BTREE,
  INDEX `online_exams_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_exams_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_exams_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_exams_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_exams_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exams_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exams_class_id_foreign` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exams_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exams_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exams_show_mark_after_finsh_foreign` FOREIGN KEY (`show_mark_after_finsh`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_exams_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 online_exams
-- ----------------------------

-- ----------------------------
-- Table structure for online_pos_featured_products
-- ----------------------------
CREATE TABLE `online_pos_featured_products`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `from_date` date NULL DEFAULT NULL,
  `to_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 `online_pos_featured_products_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_pos_featured_products_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_pos_featured_products_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_pos_featured_products_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_pos_featured_products_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_featured_products_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_featured_products_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_featured_products_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 online_pos_featured_products
-- ----------------------------

-- ----------------------------
-- Table structure for online_pos_menu_categories
-- ----------------------------
CREATE TABLE `online_pos_menu_categories`  (
  `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,
  `online_pos_menu_category_id` int UNSIGNED NULL DEFAULT NULL,
  `main_child_zeros` int NULL DEFAULT NULL,
  `main_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 `online_pos_menu_categories_online_pos_menu_category_id_foreign`(`online_pos_menu_category_id` ASC) USING BTREE,
  INDEX `online_pos_menu_categories_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `online_pos_menu_categories_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_pos_menu_categories_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_pos_menu_categories_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_pos_menu_categories_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_pos_menu_categories_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_menu_categories_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_menu_categories_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_menu_categories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_menu_categories_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_menu_categories_online_pos_menu_category_id_foreign` FOREIGN KEY (`online_pos_menu_category_id`) REFERENCES `online_pos_menu_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 online_pos_menu_categories
-- ----------------------------

-- ----------------------------
-- Table structure for online_pos_menu_category_products
-- ----------------------------
CREATE TABLE `online_pos_menu_category_products`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `online_pos_menu_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 `online_pos_menu_category_products_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_pos_menu_category_products_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_pos_menu_category_products_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_pos_menu_category_products_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_pos_menu_category_products_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_menu_category_products_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_menu_category_products_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_menu_category_products_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 online_pos_menu_category_products
-- ----------------------------

-- ----------------------------
-- Table structure for online_pos_product_categories
-- ----------------------------
CREATE TABLE `online_pos_product_categories`  (
  `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,
  `fa_icon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `online_pos_product_category_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 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 `online_pos_product_categories_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_pos_product_categories_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_pos_product_categories_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_pos_product_categories_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_product_categories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_product_categories_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 online_pos_product_categories
-- ----------------------------

-- ----------------------------
-- Table structure for online_pos_product_category_ps
-- ----------------------------
CREATE TABLE `online_pos_product_category_ps`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `online_pos_product_category_id` int UNSIGNED NOT NULL,
  `product_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 `online_pos_product_category_ps_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_pos_product_category_ps_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_pos_product_category_ps_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_pos_product_category_ps_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_pos_product_category_ps_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_product_category_ps_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_product_category_ps_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_pos_product_category_ps_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 online_pos_product_category_ps
-- ----------------------------

-- ----------------------------
-- Table structure for online_store_invoice_lines
-- ----------------------------
CREATE TABLE `online_store_invoice_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `online_store_invoice_state_id` int UNSIGNED NOT NULL,
  `online_store_invoice_customer_state_id` int UNSIGNED NULL DEFAULT NULL,
  `pos_id` int UNSIGNED NULL DEFAULT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `pos_invoice_id` int UNSIGNED NULL DEFAULT NULL,
  `online_store_invoice_id` int UNSIGNED NOT NULL,
  `date` date NULL DEFAULT NULL,
  `price` double NULL DEFAULT NULL,
  `in_date_tax` double NULL DEFAULT NULL,
  `discount` double NULL DEFAULT NULL,
  `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 `online_store_invoice_lines_online_store_invoice_state_id_foreign`(`online_store_invoice_state_id` ASC) USING BTREE,
  INDEX `online_store_invoice_lines_online_store_invoice_id_foreign`(`online_store_invoice_id` ASC) USING BTREE,
  INDEX `online_store_invoice_lines_pos_id_foreign`(`pos_id` ASC) USING BTREE,
  INDEX `online_store_invoice_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `online_store_invoice_lines_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `online_store_invoice_lines_pos_invoice_id_foreign`(`pos_invoice_id` ASC) USING BTREE,
  INDEX `online_store_invoice_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_store_invoice_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_store_invoice_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_store_invoice_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_store_invoice_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoice_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoice_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoice_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoice_lines_online_store_invoice_id_foreign` FOREIGN KEY (`online_store_invoice_id`) REFERENCES `online_store_invoices` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoice_lines_online_store_invoice_state_id_foreign` FOREIGN KEY (`online_store_invoice_state_id`) REFERENCES `online_store_invoice_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoice_lines_pos_id_foreign` FOREIGN KEY (`pos_id`) REFERENCES `poss` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoice_lines_pos_invoice_id_foreign` FOREIGN KEY (`pos_invoice_id`) REFERENCES `pos_invoices` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoice_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoice_lines_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of online_store_invoice_lines
-- ----------------------------

-- ----------------------------
-- Table structure for online_store_invoice_status
-- ----------------------------
CREATE TABLE `online_store_invoice_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 `online_store_invoice_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_store_invoice_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_store_invoice_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_store_invoice_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_store_invoice_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoice_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoice_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoice_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 online_store_invoice_status
-- ----------------------------
INSERT INTO `online_store_invoice_status` VALUES (1, 'قيد الانشاء', '1', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);
INSERT INTO `online_store_invoice_status` VALUES (2, 'بانتضار الموافقة', '2', 'Pending to approve', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);
INSERT INTO `online_store_invoice_status` VALUES (3, 'يتم تحضير الطلب', '3', 'Preparing', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);
INSERT INTO `online_store_invoice_status` VALUES (4, 'الطلب مرفوض', '4', 'Rejected', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);
INSERT INTO `online_store_invoice_status` VALUES (5, 'تم الاستلام', '5', 'Delivered', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);
INSERT INTO `online_store_invoice_status` VALUES (6, 'تم الاستلام ويوجد شكوى', '6', 'Delivered with complane', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);
INSERT INTO `online_store_invoice_status` VALUES (7, 'مرتجع', '7', 'Returned', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);
INSERT INTO `online_store_invoice_status` VALUES (8, 'الغي من قبل الزبون قبل القبول', '8', 'Cancel by customer before preparing', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);

-- ----------------------------
-- Table structure for online_store_invoices
-- ----------------------------
CREATE TABLE `online_store_invoices`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `date` date NULL DEFAULT NULL,
  `delivery_datetime` datetime NULL DEFAULT NULL,
  `pos_id` int UNSIGNED NULL DEFAULT NULL,
  `pos_invoice_id` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `online_store_invoice_state_id` int UNSIGNED NOT NULL,
  `o_s_invoice_customer_state_id` int UNSIGNED NULL DEFAULT NULL,
  `amount` double NULL DEFAULT NULL,
  `tax` 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 `online_store_invoices_pos_id_foreign`(`pos_id` ASC) USING BTREE,
  INDEX `online_store_invoices_pos_invoice_id_foreign`(`pos_invoice_id` ASC) USING BTREE,
  INDEX `online_store_invoices_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `online_store_invoices_online_store_invoice_state_id_foreign`(`online_store_invoice_state_id` ASC) USING BTREE,
  INDEX `online_store_invoices_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_store_invoices_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_store_invoices_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_store_invoices_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_store_invoices_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoices_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoices_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoices_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoices_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoices_online_store_invoice_state_id_foreign` FOREIGN KEY (`online_store_invoice_state_id`) REFERENCES `online_store_invoice_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoices_pos_id_foreign` FOREIGN KEY (`pos_id`) REFERENCES `poss` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_invoices_pos_invoice_id_foreign` FOREIGN KEY (`pos_invoice_id`) REFERENCES `pos_invoices` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of online_store_invoices
-- ----------------------------

-- ----------------------------
-- Table structure for online_store_settings
-- ----------------------------
CREATE TABLE `online_store_settings`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `facebook_link` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `twitter_link` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `tiktok_link` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `instagram_link` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `contact_us_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `terms_conditions` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci 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,
  `customer_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `customer_permission_id` int UNSIGNED NULL DEFAULT NULL,
  `pos_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 `online_store_settings_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_store_settings_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_store_settings_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_store_settings_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_store_settings_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_settings_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_settings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_store_settings_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 online_store_settings
-- ----------------------------
INSERT INTO `online_store_settings` VALUES (1, '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);

-- ----------------------------
-- Table structure for online_supplier_percentages
-- ----------------------------
CREATE TABLE `online_supplier_percentages`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `online_supplier_id` int UNSIGNED NULL DEFAULT NULL,
  `pos_sales_category_id` int UNSIGNED NULL DEFAULT NULL,
  `percentage` double 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 `online_supplier_percentages_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_supplier_percentages_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_supplier_percentages_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_supplier_percentages_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_supplier_percentages_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_supplier_percentages_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_supplier_percentages_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_supplier_percentages_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 online_supplier_percentages
-- ----------------------------

-- ----------------------------
-- Table structure for online_suppliers
-- ----------------------------
CREATE TABLE `online_suppliers`  (
  `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 `online_suppliers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `online_suppliers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `online_suppliers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `online_suppliers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `online_suppliers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_suppliers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_suppliers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `online_suppliers_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 online_suppliers
-- ----------------------------
INSERT INTO `online_suppliers` VALUES (1, 'طلبات', '1', 'Talabat', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:56', '2025-06-12 14:05:56', NULL);

-- ----------------------------
-- Table structure for order_delivery_types
-- ----------------------------
CREATE TABLE `order_delivery_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 `order_delivery_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `order_delivery_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `order_delivery_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `order_delivery_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `order_delivery_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_delivery_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_delivery_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_delivery_types_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 order_delivery_types
-- ----------------------------
INSERT INTO `order_delivery_types` VALUES (1, 'استلام فوري', '1', 'Immediate receipt', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `order_delivery_types` VALUES (2, 'توصيل', '2', 'Delivery', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `order_delivery_types` VALUES (3, 'استلام بتاريخ', '3', 'Delivery', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `order_delivery_types` VALUES (4, 'تسخين وتقطيع', '4', 'Cutting and heating', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `order_delivery_types` VALUES (5, 'موقع كامل', '5', 'Full area', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);

-- ----------------------------
-- Table structure for order_drivers
-- ----------------------------
CREATE TABLE `order_drivers`  (
  `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,
  `mobile` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `cash_account_user_id` int UNSIGNED NULL DEFAULT NULL,
  `permission_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 `order_drivers_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `order_drivers_cash_account_user_id_foreign`(`cash_account_user_id` ASC) USING BTREE,
  INDEX `order_drivers_permission_id_foreign`(`permission_id` ASC) USING BTREE,
  INDEX `order_drivers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `order_drivers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `order_drivers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `order_drivers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `order_drivers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_drivers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_drivers_cash_account_user_id_foreign` FOREIGN KEY (`cash_account_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_drivers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_drivers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_drivers_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_drivers_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 order_drivers
-- ----------------------------

-- ----------------------------
-- Table structure for order_groups
-- ----------------------------
CREATE TABLE `order_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,
  `order_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 `order_groups_order_group_id_foreign`(`order_group_id` ASC) USING BTREE,
  INDEX `order_groups_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `order_groups_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `order_groups_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `order_groups_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `order_groups_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `order_groups_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_groups_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_groups_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_groups_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_groups_order_group_id_foreign` FOREIGN KEY (`order_group_id`) REFERENCES `order_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of order_groups
-- ----------------------------

-- ----------------------------
-- Table structure for order_journal_entries
-- ----------------------------
CREATE TABLE `order_journal_entries`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `is_it_main` int UNSIGNED NULL DEFAULT NULL,
  `is_it_insurance` int UNSIGNED NULL DEFAULT NULL,
  `order_id` int UNSIGNED NOT NULL,
  `journal_entry_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 `order_journal_entries_is_it_main_foreign`(`is_it_main` ASC) USING BTREE,
  INDEX `order_journal_entries_order_id_foreign`(`order_id` ASC) USING BTREE,
  INDEX `order_journal_entries_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `order_journal_entries_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `order_journal_entries_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `order_journal_entries_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `order_journal_entries_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `order_journal_entries_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_journal_entries_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_journal_entries_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_journal_entries_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_journal_entries_is_it_main_foreign` FOREIGN KEY (`is_it_main`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_journal_entries_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_journal_entries_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of order_journal_entries
-- ----------------------------

-- ----------------------------
-- Table structure for order_line_specifications
-- ----------------------------
CREATE TABLE `order_line_specifications`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `product_specification_id` int UNSIGNED NOT NULL,
  `order_line_id` int UNSIGNED NOT NULL,
  `product_specification_value_id` int UNSIGNED NULL DEFAULT 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 `order_line_specifications_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `order_line_specifications_product_specification_id_foreign`(`product_specification_id` ASC) USING BTREE,
  INDEX `order_line_specifications_order_line_id_foreign`(`order_line_id` ASC) USING BTREE,
  INDEX `order_line_specifications_product_specification_value_id_foreign`(`product_specification_value_id` ASC) USING BTREE,
  INDEX `order_line_specifications_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `order_line_specifications_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `order_line_specifications_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `order_line_specifications_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `order_line_specifications_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_specifications_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_specifications_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_specifications_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_specifications_order_line_id_foreign` FOREIGN KEY (`order_line_id`) REFERENCES `order_lines` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_specifications_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_specifications_product_specification_id_foreign` FOREIGN KEY (`product_specification_id`) REFERENCES `product_specifications` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_specifications_product_specification_value_id_foreign` FOREIGN KEY (`product_specification_value_id`) REFERENCES `product_specification_values` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of order_line_specifications
-- ----------------------------

-- ----------------------------
-- Table structure for order_line_status
-- ----------------------------
CREATE TABLE `order_line_status`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `order_id` int UNSIGNED NOT NULL,
  `order_line_id` int UNSIGNED NOT NULL,
  `order_stage_id` int UNSIGNED NOT NULL,
  `state_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 `order_line_status_order_id_foreign`(`order_id` ASC) USING BTREE,
  INDEX `order_line_status_order_line_id_foreign`(`order_line_id` ASC) USING BTREE,
  INDEX `order_line_status_order_stage_id_foreign`(`order_stage_id` ASC) USING BTREE,
  INDEX `order_line_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `order_line_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `order_line_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `order_line_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `order_line_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_status_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_status_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_status_order_line_id_foreign` FOREIGN KEY (`order_line_id`) REFERENCES `order_lines` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_line_status_order_stage_id_foreign` FOREIGN KEY (`order_stage_id`) REFERENCES `order_stages` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of order_line_status
-- ----------------------------

-- ----------------------------
-- Table structure for order_lines
-- ----------------------------
CREATE TABLE `order_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `order_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `date` date NOT NULL,
  `delivery_date` datetime NULL DEFAULT NULL,
  `price` double NULL DEFAULT NULL,
  `price_with_cost` double NULL DEFAULT NULL,
  `quantity` double NULL DEFAULT NULL,
  `discount_value` double NULL DEFAULT NULL,
  `discount_percentage` double NULL DEFAULT NULL,
  `in_date_tax` double NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `in_date_currency_rate` 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 `order_lines_order_id_foreign`(`order_id` ASC) USING BTREE,
  INDEX `order_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `order_lines_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `order_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `order_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `order_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `order_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `order_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_lines_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_lines_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of order_lines
-- ----------------------------

-- ----------------------------
-- Table structure for order_operators
-- ----------------------------
CREATE TABLE `order_operators`  (
  `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,
  `branch_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 `order_operators_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `order_operators_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `order_operators_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `order_operators_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `order_operators_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `order_operators_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_operators_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_operators_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_operators_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_operators_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 order_operators
-- ----------------------------

-- ----------------------------
-- Table structure for order_stage_status
-- ----------------------------
CREATE TABLE `order_stage_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 `order_stage_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `order_stage_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `order_stage_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `order_stage_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `order_stage_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_stage_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_stage_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_stage_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 order_stage_status
-- ----------------------------
INSERT INTO `order_stage_status` VALUES (1, 'قيد الانشاء', '1', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `order_stage_status` VALUES (2, 'تم', '2', 'Success', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);

-- ----------------------------
-- Table structure for order_stages
-- ----------------------------
CREATE TABLE `order_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,
  `is_it_final_stage` 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 `order_stages_is_it_final_stage_foreign`(`is_it_final_stage` ASC) USING BTREE,
  INDEX `order_stages_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `order_stages_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `order_stages_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `order_stages_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `order_stages_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_stages_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_stages_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_stages_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_stages_is_it_final_stage_foreign` FOREIGN KEY (`is_it_final_stage`) 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 order_stages
-- ----------------------------

-- ----------------------------
-- Table structure for order_status
-- ----------------------------
CREATE TABLE `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 `order_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `order_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `order_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `order_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `order_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `order_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 order_status
-- ----------------------------
INSERT INTO `order_status` VALUES (1, 'قيد الانتاج', '1', 'Pending production', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `order_status` VALUES (2, 'تم الانتهاء من الانتهاج', '2', 'Done production', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `order_status` VALUES (3, 'تم اخذ الطلب للعميل', '3', 'Gone to the customer', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `order_status` VALUES (4, 'اقفل الطلب بنجاح', '4', 'Success', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);
INSERT INTO `order_status` VALUES (5, 'الغي', '5', 'Canceled', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:06', '2025-06-12 14:06:06', NULL);

-- ----------------------------
-- Table structure for orders
-- ----------------------------
CREATE TABLE `orders`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `customer_user_id` int UNSIGNED NOT NULL,
  `tax_state_id` int UNSIGNED NOT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double NULL DEFAULT NULL,
  `order_group_id` int UNSIGNED NOT NULL,
  `order_delivery_type_id` int UNSIGNED NOT NULL,
  `order_state_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `order_operator_id` int UNSIGNED NOT NULL,
  `with_driver` double NULL DEFAULT NULL,
  `insurance` double NULL DEFAULT NULL,
  `can_take_the_insurance` int UNSIGNED NULL DEFAULT NULL,
  `can_return_this_amount_for_insurance` double UNSIGNED NULL DEFAULT NULL,
  `approve_from_admin_to_take_the_insurance` int UNSIGNED NULL DEFAULT NULL,
  `date` date NOT NULL,
  `token` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `delivery_date` datetime NULL DEFAULT NULL,
  `total_net_price` double NULL DEFAULT NULL,
  `total_taxs` double NULL DEFAULT NULL,
  `total_discounts` double NULL DEFAULT NULL,
  `price_without_discount_without_tax` double NULL DEFAULT NULL,
  `collected` double NULL DEFAULT NULL,
  `remain` double NULL DEFAULT NULL,
  `order_stage_id` int UNSIGNED NULL DEFAULT NULL,
  `delivery_area_id` int UNSIGNED NULL DEFAULT NULL,
  `user_addresse_id` int UNSIGNED NULL DEFAULT NULL,
  `order_driver_id` int UNSIGNED NULL DEFAULT NULL,
  `is_the_insurance_back` int UNSIGNED NULL DEFAULT NULL,
  `address` 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 `orders_customer_user_id_foreign`(`customer_user_id` ASC) USING BTREE,
  INDEX `orders_order_stage_id_foreign`(`order_stage_id` ASC) USING BTREE,
  INDEX `orders_tax_state_id_foreign`(`tax_state_id` ASC) USING BTREE,
  INDEX `orders_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `orders_order_group_id_foreign`(`order_group_id` ASC) USING BTREE,
  INDEX `orders_order_delivery_type_id_foreign`(`order_delivery_type_id` ASC) USING BTREE,
  INDEX `orders_order_state_id_foreign`(`order_state_id` ASC) USING BTREE,
  INDEX `orders_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `orders_order_operator_id_foreign`(`order_operator_id` ASC) USING BTREE,
  INDEX `orders_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `orders_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `orders_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `orders_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `orders_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_customer_user_id_foreign` FOREIGN KEY (`customer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_order_delivery_type_id_foreign` FOREIGN KEY (`order_delivery_type_id`) REFERENCES `order_delivery_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_order_group_id_foreign` FOREIGN KEY (`order_group_id`) REFERENCES `order_groups` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_order_operator_id_foreign` FOREIGN KEY (`order_operator_id`) REFERENCES `order_operators` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_order_stage_id_foreign` FOREIGN KEY (`order_stage_id`) REFERENCES `order_stages` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_order_state_id_foreign` FOREIGN KEY (`order_state_id`) REFERENCES `order_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `orders_tax_state_id_foreign` FOREIGN KEY (`tax_state_id`) REFERENCES `tax_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 orders
-- ----------------------------

-- ----------------------------
-- Table structure for partner_cost_centers
-- ----------------------------
CREATE TABLE `partner_cost_centers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `partner_user_id` int UNSIGNED NOT NULL,
  `cost_center_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` 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 `partner_cost_centers_partner_user_id_foreign`(`partner_user_id` ASC) USING BTREE,
  INDEX `partner_cost_centers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `partner_cost_centers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `partner_cost_centers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `partner_cost_centers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `partner_cost_centers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_cost_centers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_cost_centers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_cost_centers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_cost_centers_partner_user_id_foreign` FOREIGN KEY (`partner_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 partner_cost_centers
-- ----------------------------

-- ----------------------------
-- Table structure for partner_product_categories
-- ----------------------------
CREATE TABLE `partner_product_categories`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_category_id` int UNSIGNED NOT NULL,
  `customer_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `partner_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 `partner_product_categories_product_category_id_foreign`(`product_category_id` ASC) USING BTREE,
  INDEX `partner_product_categories_customer_main_account_id_foreign`(`customer_main_account_id` ASC) USING BTREE,
  INDEX `partner_product_categories_partner_user_id_foreign`(`partner_user_id` ASC) USING BTREE,
  INDEX `partner_product_categories_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `partner_product_categories_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `partner_product_categories_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `partner_product_categories_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `partner_product_categories_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_product_categories_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_product_categories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_product_categories_customer_main_account_id_foreign` FOREIGN KEY (`customer_main_account_id`) REFERENCES `customer_main_accounts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_product_categories_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_product_categories_partner_user_id_foreign` FOREIGN KEY (`partner_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_product_categories_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 partner_product_categories
-- ----------------------------

-- ----------------------------
-- Table structure for partner_relations
-- ----------------------------
CREATE TABLE `partner_relations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `partner_parent_user_id` int UNSIGNED NOT NULL,
  `partner_child_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 `partner_relations_partner_parent_user_id_foreign`(`partner_parent_user_id` ASC) USING BTREE,
  INDEX `partner_relations_partner_child_user_id_foreign`(`partner_child_user_id` ASC) USING BTREE,
  INDEX `partner_relations_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `partner_relations_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `partner_relations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `partner_relations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `partner_relations_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_relations_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_relations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_relations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_relations_partner_child_user_id_foreign` FOREIGN KEY (`partner_child_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `partner_relations_partner_parent_user_id_foreign` FOREIGN KEY (`partner_parent_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 partner_relations
-- ----------------------------

-- ----------------------------
-- Table structure for payment_methods
-- ----------------------------
CREATE TABLE `payment_methods`  (
  `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,
  `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 `payment_methods_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `payment_methods_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `payment_methods_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `payment_methods_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 payment_methods
-- ----------------------------
INSERT INTO `payment_methods` VALUES (1, 'نقدي', 'cash', '1', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);
INSERT INTO `payment_methods` VALUES (2, 'ذمم', 'check', '2', 1, NULL, NULL, '2025-06-12 14:05:49', '2025-06-12 14:05:49', NULL);

-- ----------------------------
-- Table structure for payment_terms
-- ----------------------------
CREATE TABLE `payment_terms`  (
  `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,
  `payment_terms_type_id` int UNSIGNED NOT NULL,
  `payment_terms_option_id` int UNSIGNED NULL DEFAULT NULL,
  `description_on_the_invoice` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `value` double NULL DEFAULT NULL,
  `number_of_days` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `percentage` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `days_of_the_month` 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,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `payment_terms_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `payment_terms_payment_terms_type_id_foreign`(`payment_terms_type_id` ASC) USING BTREE,
  INDEX `payment_terms_payment_terms_option_id_foreign`(`payment_terms_option_id` ASC) USING BTREE,
  INDEX `payment_terms_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `payment_terms_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `payment_terms_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `payment_terms_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `payment_terms_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `payment_terms_payment_terms_option_id_foreign` FOREIGN KEY (`payment_terms_option_id`) REFERENCES `payment_terms_options` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `payment_terms_payment_terms_type_id_foreign` FOREIGN KEY (`payment_terms_type_id`) REFERENCES `payment_terms_types` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of payment_terms
-- ----------------------------
INSERT INTO `payment_terms` VALUES (1, 'فاتورة فورية', 'Immediate Payment', '1', 1, 1, NULL, 0, '0', NULL, 0, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `payment_terms` VALUES (2, '15 يوم', '15 Days', '2', 1, 1, NULL, 0, '15', NULL, 0, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `payment_terms` VALUES (3, '30 يوم', '30 Days', '3', 1, 1, NULL, 0, '30', NULL, 0, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `payment_terms` VALUES (4, 'شهرين', 'Tow Month', '4', 1, 1, NULL, 0, '60', NULL, 0, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `payment_terms` VALUES (5, '90 يوم', '90 Days', '5', 1, 1, NULL, 0, '90', NULL, 0, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `payment_terms` VALUES (6, 'نهاية الشهر الحالي', 'End Of The Current Month', '6', 1, 3, NULL, 0, '31', NULL, 0, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `payment_terms` VALUES (7, 'نهاية الشهر المقبل', 'End Of The Following Month', '7', 1, 2, NULL, 0, '0', NULL, 31, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);

-- ----------------------------
-- Table structure for payment_terms_options
-- ----------------------------
CREATE TABLE `payment_terms_options`  (
  `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,
  `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 `payment_terms_options_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `payment_terms_options_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `payment_terms_options_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `payment_terms_options_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 payment_terms_options
-- ----------------------------
INSERT INTO `payment_terms_options` VALUES (1, 'يوم من تاريخ الفاتورة', 'Days after the invoice date', '1', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `payment_terms_options` VALUES (2, 'من الشهر التالي', 'Of the following month', '2', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `payment_terms_options` VALUES (3, 'من الشهر الحالي', 'Of the current month', '3', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);

-- ----------------------------
-- Table structure for payment_terms_types
-- ----------------------------
CREATE TABLE `payment_terms_types`  (
  `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,
  `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 `payment_terms_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `payment_terms_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `payment_terms_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `payment_terms_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 payment_terms_types
-- ----------------------------
INSERT INTO `payment_terms_types` VALUES (1, 'balance', 'Balance', '1', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `payment_terms_types` VALUES (2, 'نسبة', 'Percent', '2', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `payment_terms_types` VALUES (3, 'قيمة ثابتة', 'Fixed amount', '2', 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);

-- ----------------------------
-- Table structure for permission_curds
-- ----------------------------
CREATE TABLE `permission_curds`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `permission_id` int UNSIGNED NULL DEFAULT NULL,
  `model_id` int UNSIGNED NOT NULL,
  `create` int NULL DEFAULT NULL,
  `read` int NULL DEFAULT NULL,
  `update` int NULL DEFAULT NULL,
  `soft_delete` int NULL DEFAULT NULL,
  `restore` int NULL DEFAULT NULL,
  `force_delete` int 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 `permission_curds_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `permission_curds_permission_id_foreign`(`permission_id` ASC) USING BTREE,
  INDEX `permission_curds_model_id_foreign`(`model_id` ASC) USING BTREE,
  INDEX `permission_curds_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `permission_curds_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `permission_curds_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_curds_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_curds_model_id_foreign` FOREIGN KEY (`model_id`) REFERENCES `models` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_curds_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_curds_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 permission_curds
-- ----------------------------

-- ----------------------------
-- Table structure for permission_product_categories
-- ----------------------------
CREATE TABLE `permission_product_categories`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `permission_id` int UNSIGNED NOT NULL,
  `product_category_id` int UNSIGNED NOT NULL,
  `state_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 `permission_product_categories_permission_id_foreign`(`permission_id` ASC) USING BTREE,
  INDEX `permission_product_categories_product_category_id_foreign`(`product_category_id` ASC) USING BTREE,
  INDEX `permission_product_categories_state_id_foreign`(`state_id` ASC) USING BTREE,
  INDEX `permission_product_categories_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `permission_product_categories_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `permission_product_categories_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `permission_product_categories_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `permission_product_categories_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_product_categories_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_product_categories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_product_categories_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_product_categories_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_product_categories_product_category_id_foreign` FOREIGN KEY (`product_category_id`) REFERENCES `product_categories` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_product_categories_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 permission_product_categories
-- ----------------------------

-- ----------------------------
-- Table structure for permission_products
-- ----------------------------
CREATE TABLE `permission_products`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `permission_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `state_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 `permission_products_permission_id_foreign`(`permission_id` ASC) USING BTREE,
  INDEX `permission_products_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `permission_products_state_id_foreign`(`state_id` ASC) USING BTREE,
  INDEX `permission_products_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `permission_products_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `permission_products_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `permission_products_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `permission_products_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_products_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_products_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_products_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_products_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_products_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_products_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 permission_products
-- ----------------------------

-- ----------------------------
-- Table structure for permission_views
-- ----------------------------
CREATE TABLE `permission_views`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `permission_id` int UNSIGNED NULL DEFAULT NULL,
  `model_id` int UNSIGNED NOT NULL,
  `read` int 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 `permission_views_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `permission_views_permission_id_foreign`(`permission_id` ASC) USING BTREE,
  INDEX `permission_views_model_id_foreign`(`model_id` ASC) USING BTREE,
  INDEX `permission_views_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `permission_views_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `permission_views_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_views_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_views_model_id_foreign` FOREIGN KEY (`model_id`) REFERENCES `models` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_views_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permission_views_user_id_foreign` FOREIGN KEY (`user_id`) 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 permission_views
-- ----------------------------
INSERT INTO `permission_views` VALUES (1, 1, NULL, 1, 1, 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);
INSERT INTO `permission_views` VALUES (2, 1, NULL, 2, 1, 1, NULL, '2025-06-12 14:05:48', '2025-06-12 14:05:48', NULL);

-- ----------------------------
-- Table structure for permissions
-- ----------------------------
CREATE TABLE `permissions`  (
  `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,
  `approved_state_id` int UNSIGNED 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 = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of permissions
-- ----------------------------
INSERT INTO `permissions` VALUES (1, 'admin', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `permissions` VALUES (2, 'user', NULL, NULL, NULL, NULL, NULL, NULL, NULL);

-- ----------------------------
-- Table structure for permit_types
-- ----------------------------
CREATE TABLE `permit_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,
  `deducted_from_the_vacation_balance` int UNSIGNED NULL DEFAULT NULL,
  `number_of_days` double UNSIGNED NULL DEFAULT NULL,
  `limit` double UNSIGNED NULL DEFAULT NULL,
  `monthly_balance` double UNSIGNED NULL DEFAULT NULL,
  `monthly_balance_after_fife_years` double UNSIGNED NULL DEFAULT NULL,
  `is_unpaid` double UNSIGNED NULL DEFAULT NULL,
  `can_be_less_than_zero` 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 `permit_types_deducted_from_the_vacation_balance_foreign`(`deducted_from_the_vacation_balance` ASC) USING BTREE,
  INDEX `permit_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `permit_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `permit_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `permit_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `permit_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permit_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permit_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permit_types_deducted_from_the_vacation_balance_foreign` FOREIGN KEY (`deducted_from_the_vacation_balance`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `permit_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 permit_types
-- ----------------------------
INSERT INTO `permit_types` VALUES (1, 'سنوية', '1', 'Annual', 1, 12, NULL, NULL, NULL, 1, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);
INSERT INTO `permit_types` VALUES (2, 'مرضية', '2', 'Health', 1, 14, NULL, NULL, NULL, 1, NULL, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:52', '2025-06-12 14:05:52', NULL);

-- ----------------------------
-- Table structure for petty_cashs
-- ----------------------------
CREATE TABLE `petty_cashs`  (
  `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 `petty_cashs_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `petty_cashs_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `petty_cashs_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `petty_cashs_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `petty_cashs_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `petty_cashs_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `petty_cashs_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `petty_cashs_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 petty_cashs
-- ----------------------------
INSERT INTO `petty_cashs` VALUES (1, 'سلفة شهرية', '1', 'Monthly Petty cash', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:53', '2025-06-12 14:05:53', NULL);

-- ----------------------------
-- Table structure for pipeline_flows
-- ----------------------------
CREATE TABLE `pipeline_flows`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `pipeline_id` int UNSIGNED NOT NULL,
  `from_user_id` int UNSIGNED NULL DEFAULT NULL,
  `to_user_id` int UNSIGNED NULL DEFAULT NULL,
  `from_stage_id` int UNSIGNED NULL DEFAULT NULL,
  `to_stage_id` int UNSIGNED NULL DEFAULT NULL,
  `is_reverse` int UNSIGNED NULL DEFAULT NULL,
  `reschedule_date` date NULL DEFAULT NULL,
  `state_id` int UNSIGNED 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 `pipeline_flows_state_id_foreign`(`state_id` ASC) USING BTREE,
  INDEX `pipeline_flows_pipeline_id_foreign`(`pipeline_id` ASC) USING BTREE,
  INDEX `pipeline_flows_from_user_id_foreign`(`from_user_id` ASC) USING BTREE,
  INDEX `pipeline_flows_to_user_id_foreign`(`to_user_id` ASC) USING BTREE,
  INDEX `pipeline_flows_from_stage_id_foreign`(`from_stage_id` ASC) USING BTREE,
  INDEX `pipeline_flows_to_stage_id_foreign`(`to_stage_id` ASC) USING BTREE,
  INDEX `pipeline_flows_is_reverse_foreign`(`is_reverse` ASC) USING BTREE,
  INDEX `pipeline_flows_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pipeline_flows_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pipeline_flows_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pipeline_flows_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pipeline_flows_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_flows_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_flows_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_flows_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_flows_from_stage_id_foreign` FOREIGN KEY (`from_stage_id`) REFERENCES `stages` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_flows_from_user_id_foreign` FOREIGN KEY (`from_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_flows_is_reverse_foreign` FOREIGN KEY (`is_reverse`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_flows_pipeline_id_foreign` FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_flows_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_flows_to_stage_id_foreign` FOREIGN KEY (`to_stage_id`) REFERENCES `stages` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_flows_to_user_id_foreign` FOREIGN KEY (`to_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 pipeline_flows
-- ----------------------------

-- ----------------------------
-- Table structure for pipeline_lost_reasons
-- ----------------------------
CREATE TABLE `pipeline_lost_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 `pipeline_lost_reasons_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pipeline_lost_reasons_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pipeline_lost_reasons_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pipeline_lost_reasons_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pipeline_lost_reasons_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_lost_reasons_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_lost_reasons_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_lost_reasons_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 pipeline_lost_reasons
-- ----------------------------
INSERT INTO `pipeline_lost_reasons` VALUES (1, 'السعر مرتفع', '1', 'Price is high', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);
INSERT INTO `pipeline_lost_reasons` VALUES (2, 'لا يوجد سبب', '2', 'no reason', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);

-- ----------------------------
-- Table structure for pipeline_specifications
-- ----------------------------
CREATE TABLE `pipeline_specifications`  (
  `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,
  `product_specification_type_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 `pipeline_specifications_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pipeline_specifications_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pipeline_specifications_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pipeline_specifications_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pipeline_specifications_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_specifications_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_specifications_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_specifications_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 pipeline_specifications
-- ----------------------------

-- ----------------------------
-- Table structure for pipeline_status
-- ----------------------------
CREATE TABLE `pipeline_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 `pipeline_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pipeline_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pipeline_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pipeline_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pipeline_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_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 pipeline_status
-- ----------------------------
INSERT INTO `pipeline_status` VALUES (1, 'قيد الانشاء', '1', 'Pending', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:01', '2025-06-12 14:06:01', NULL);
INSERT INTO `pipeline_status` VALUES (2, 'تم بنجاح', '2', 'Successed', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:01', '2025-06-12 14:06:01', NULL);
INSERT INTO `pipeline_status` VALUES (3, 'فشلت', '3', 'Faild', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:01', '2025-06-12 14:06:01', NULL);
INSERT INTO `pipeline_status` VALUES (4, 'موقوف لوقت غير محدد', '4', 'Pending for sometimes', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:01', '2025-06-12 14:06:01', NULL);
INSERT INTO `pipeline_status` VALUES (5, 'تمت ولم ترحل الى المالية', '5', 'Done without invoice', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:01', '2025-06-12 14:06:01', NULL);

-- ----------------------------
-- Table structure for pipeline_types
-- ----------------------------
CREATE TABLE `pipeline_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,
  `product_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 `pipeline_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pipeline_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pipeline_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pipeline_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pipeline_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipeline_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 pipeline_types
-- ----------------------------
INSERT INTO `pipeline_types` VALUES (1, 'مبيعات شقق', '1', 'Appartment sales', 1, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);
INSERT INTO `pipeline_types` VALUES (2, 'مبيعات اراضي', '2', 'Lands sales', 1, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:06:02', '2025-06-12 14:06:02', NULL);

-- ----------------------------
-- Table structure for pipelines
-- ----------------------------
CREATE TABLE `pipelines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `expected_revenue` double NULL DEFAULT NULL,
  `in_date_unit_rate` double NULL DEFAULT NULL,
  `rate` int NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `customer_user_id` int UNSIGNED NOT NULL,
  `sales_person_id` int UNSIGNED NULL DEFAULT NULL,
  `sales_team_id` int UNSIGNED NULL DEFAULT NULL,
  `stage_id` int UNSIGNED NOT NULL,
  `coupon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `attachment_link` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `pipeline_state_id` int UNSIGNED NOT NULL,
  `price_offer_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `customer_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `pipeline_type_id` int UNSIGNED NOT NULL,
  `pipeline_lost_reason_id` int UNSIGNED NULL DEFAULT NULL,
  `order_driver_user_id` int UNSIGNED NULL DEFAULT NULL,
  `delivery_area_id` int UNSIGNED NULL DEFAULT NULL,
  `rank` int UNSIGNED NULL DEFAULT NULL,
  `date` date NULL DEFAULT NULL,
  `reschedule_date` date NULL DEFAULT NULL,
  `bg_color` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `checked` int 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 `pipelines_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `pipelines_customer_user_id_foreign`(`customer_user_id` ASC) USING BTREE,
  INDEX `pipelines_sales_person_id_foreign`(`sales_person_id` ASC) USING BTREE,
  INDEX `pipelines_sales_team_id_foreign`(`sales_team_id` ASC) USING BTREE,
  INDEX `pipelines_stage_id_foreign`(`stage_id` ASC) USING BTREE,
  INDEX `pipelines_customer_main_account_id_foreign`(`customer_main_account_id` ASC) USING BTREE,
  INDEX `pipelines_pipeline_state_id_foreign`(`pipeline_state_id` ASC) USING BTREE,
  INDEX `pipelines_price_offer_id_foreign`(`price_offer_id` ASC) USING BTREE,
  INDEX `pipelines_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `pipelines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pipelines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pipelines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pipelines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pipelines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipelines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipelines_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipelines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipelines_customer_main_account_id_foreign` FOREIGN KEY (`customer_main_account_id`) REFERENCES `customer_main_accounts` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipelines_customer_user_id_foreign` FOREIGN KEY (`customer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipelines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipelines_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipelines_pipeline_state_id_foreign` FOREIGN KEY (`pipeline_state_id`) REFERENCES `pipeline_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipelines_price_offer_id_foreign` FOREIGN KEY (`price_offer_id`) REFERENCES `price_offers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipelines_sales_person_id_foreign` FOREIGN KEY (`sales_person_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipelines_sales_team_id_foreign` FOREIGN KEY (`sales_team_id`) REFERENCES `sales_teams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pipelines_stage_id_foreign` FOREIGN KEY (`stage_id`) REFERENCES `stages` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of pipelines
-- ----------------------------

-- ----------------------------
-- Table structure for plate_types
-- ----------------------------
CREATE TABLE `plate_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 `plate_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `plate_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `plate_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `plate_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `plate_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `plate_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `plate_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `plate_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 plate_types
-- ----------------------------

-- ----------------------------
-- Table structure for po_custom_fields
-- ----------------------------
CREATE TABLE `po_custom_fields`  (
  `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,
  `purchase_order_type_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 `po_custom_fields_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `po_custom_fields_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `po_custom_fields_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `po_custom_fields_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `po_custom_fields_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `po_custom_fields_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `po_custom_fields_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `po_custom_fields_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 po_custom_fields
-- ----------------------------

-- ----------------------------
-- Table structure for po_custom_relations
-- ----------------------------
CREATE TABLE `po_custom_relations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `po_custom_field_id` int UNSIGNED NOT NULL,
  `purchase_order_line_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 `po_custom_relations_po_custom_field_id_foreign`(`po_custom_field_id` ASC) USING BTREE,
  INDEX `po_custom_relations_purchase_order_line_id_foreign`(`purchase_order_line_id` ASC) USING BTREE,
  INDEX `po_custom_relations_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `po_custom_relations_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `po_custom_relations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `po_custom_relations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `po_custom_relations_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `po_custom_relations_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `po_custom_relations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `po_custom_relations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `po_custom_relations_po_custom_field_id_foreign` FOREIGN KEY (`po_custom_field_id`) REFERENCES `po_custom_fields` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `po_custom_relations_purchase_order_line_id_foreign` FOREIGN KEY (`purchase_order_line_id`) REFERENCES `purchase_order_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 po_custom_relations
-- ----------------------------

-- ----------------------------
-- Table structure for pos_card_points
-- ----------------------------
CREATE TABLE `pos_card_points`  (
  `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,
  `phone` 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,
  `card_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NULL DEFAULT NULL,
  `points` double UNSIGNED NULL DEFAULT NULL,
  `amounts` double UNSIGNED NULL DEFAULT NULL,
  `total_amounts` 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 `pos_card_points_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_card_points_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_card_points_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_card_points_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_card_points_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_card_points_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_card_points_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_card_points_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 pos_card_points
-- ----------------------------

-- ----------------------------
-- Table structure for pos_closing_amounts
-- ----------------------------
CREATE TABLE `pos_closing_amounts`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `pos_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `collected_money_in_pos_value_id` int UNSIGNED NULL DEFAULT NULL,
  `count` int UNSIGNED NULL DEFAULT NULL,
  `amount` 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 `pos_closing_amounts_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_closing_amounts_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_closing_amounts_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_closing_amounts_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_closing_amounts_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_closing_amounts_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_closing_amounts_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_closing_amounts_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 pos_closing_amounts
-- ----------------------------

-- ----------------------------
-- Table structure for pos_closing_status
-- ----------------------------
CREATE TABLE `pos_closing_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 `pos_closing_status_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_closing_status_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_closing_status_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_closing_status_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_closing_status_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_closing_status_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_closing_status_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_closing_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 pos_closing_status
-- ----------------------------
INSERT INTO `pos_closing_status` VALUES (1, 'مفتوح', '1', 'Open', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `pos_closing_status` VALUES (2, 'مغلق', '2', 'Close', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for pos_draw_opens
-- ----------------------------
CREATE TABLE `pos_draw_opens`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int UNSIGNED NOT NULL,
  `pos_id` int 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 `pos_draw_opens_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_draw_opens_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_draw_opens_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_draw_opens_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_draw_opens_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_draw_opens_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_draw_opens_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_draw_opens_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 pos_draw_opens
-- ----------------------------

-- ----------------------------
-- Table structure for pos_invoice_credit_cards
-- ----------------------------
CREATE TABLE `pos_invoice_credit_cards`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `pos_invoice_id` int UNSIGNED NOT NULL,
  `credit_card_id` int UNSIGNED NOT NULL,
  `amount` 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,
  `pos_id` 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 `pos_invoice_credit_cards_pos_id_foreign`(`pos_id` ASC) USING BTREE,
  INDEX `pos_invoice_credit_cards_pos_invoice_id_foreign`(`pos_invoice_id` ASC) USING BTREE,
  INDEX `pos_invoice_credit_cards_credit_card_id_foreign`(`credit_card_id` ASC) USING BTREE,
  INDEX `pos_invoice_credit_cards_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_invoice_credit_cards_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_invoice_credit_cards_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_invoice_credit_cards_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_invoice_credit_cards_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_credit_cards_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_credit_cards_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_credit_cards_credit_card_id_foreign` FOREIGN KEY (`credit_card_id`) REFERENCES `credit_cards` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_credit_cards_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_credit_cards_pos_id_foreign` FOREIGN KEY (`pos_id`) REFERENCES `poss` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_credit_cards_pos_invoice_id_foreign` FOREIGN KEY (`pos_invoice_id`) REFERENCES `pos_invoices` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of pos_invoice_credit_cards
-- ----------------------------

-- ----------------------------
-- Table structure for pos_invoice_line_components
-- ----------------------------
CREATE TABLE `pos_invoice_line_components`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `pos_invoice_line_id` int UNSIGNED NOT NULL,
  `pos_product_component_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 `pos_invoice_line_components_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_invoice_line_components_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_invoice_line_components_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_invoice_line_components_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_invoice_line_components_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_line_components_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_line_components_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_line_components_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 pos_invoice_line_components
-- ----------------------------

-- ----------------------------
-- Table structure for pos_invoice_lines
-- ----------------------------
CREATE TABLE `pos_invoice_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `pos_id` int UNSIGNED NOT NULL,
  `pos_invoice_id` int UNSIGNED NOT NULL,
  `customer_user_id` int UNSIGNED NULL DEFAULT NULL,
  `posting_state_id` int UNSIGNED NOT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_id` int UNSIGNED NULL DEFAULT NULL,
  `note_voucher_id` int UNSIGNED NULL DEFAULT NULL,
  `warehouse_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `product_category_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `in_date_unit_rate` int UNSIGNED NOT NULL,
  `online_supplier_id` int UNSIGNED NULL DEFAULT NULL,
  `online_supplier_percentage` double UNSIGNED NULL DEFAULT NULL,
  `pos_sales_category_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_entry` int UNSIGNED NULL DEFAULT NULL,
  `printed` int NULL DEFAULT NULL,
  `line_price` double NULL DEFAULT NULL,
  `line_price_with_discount` double NULL DEFAULT NULL,
  `line_price_with_tax` double NULL DEFAULT NULL,
  `line_discount_value` double NULL DEFAULT NULL,
  `line_tax_value` double NULL DEFAULT NULL,
  `quantity` double NOT NULL,
  `quantity_t` double NULL DEFAULT NULL,
  `price` double NULL DEFAULT NULL,
  `price_t` double NULL DEFAULT NULL,
  `discount` double NULL DEFAULT NULL,
  `in_date_tax` double NULL DEFAULT NULL,
  `currency_id` int UNSIGNED NOT NULL,
  `in_date_currency_rate` double UNSIGNED NOT NULL,
  `default_currency` 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 `pos_invoice_lines_pos_id_foreign`(`pos_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_pos_invoice_id_foreign`(`pos_invoice_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_customer_user_id_foreign`(`customer_user_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_posting_state_id_foreign`(`posting_state_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_journal_id_foreign`(`journal_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_note_voucher_id_foreign`(`note_voucher_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_warehouse_id_foreign`(`warehouse_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_product_category_id_foreign`(`product_category_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_currency_id_foreign`(`currency_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_default_currency_foreign`(`default_currency` ASC) USING BTREE,
  INDEX `pos_invoice_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_invoice_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_invoice_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_invoice_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_invoice_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_currency_id_foreign` FOREIGN KEY (`currency_id`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_customer_user_id_foreign` FOREIGN KEY (`customer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_default_currency_foreign` FOREIGN KEY (`default_currency`) REFERENCES `currencies` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_journal_id_foreign` FOREIGN KEY (`journal_id`) REFERENCES `journals` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_note_voucher_id_foreign` FOREIGN KEY (`note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_pos_id_foreign` FOREIGN KEY (`pos_id`) REFERENCES `poss` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_pos_invoice_id_foreign` FOREIGN KEY (`pos_invoice_id`) REFERENCES `pos_invoices` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_posting_state_id_foreign` FOREIGN KEY (`posting_state_id`) REFERENCES `posting_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_product_category_id_foreign` FOREIGN KEY (`product_category_id`) REFERENCES `product_categories` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoice_lines_warehouse_id_foreign` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouses` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of pos_invoice_lines
-- ----------------------------

-- ----------------------------
-- Table structure for pos_invoices
-- ----------------------------
CREATE TABLE `pos_invoices`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `pos_id` int UNSIGNED NOT NULL,
  `customer_user_id` int UNSIGNED NULL DEFAULT NULL,
  `posting_state_id` int UNSIGNED NOT NULL,
  `journal_entry_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_id` int UNSIGNED NULL DEFAULT NULL,
  `transfered_to_main_server` int UNSIGNED NULL DEFAULT NULL,
  `note_voucher_id` int UNSIGNED NULL DEFAULT NULL,
  `online_supplier_id` int UNSIGNED NULL DEFAULT NULL,
  `online_supplier_percentage` double UNSIGNED NULL DEFAULT NULL,
  `warehouse_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `payment_method_id` int UNSIGNED NOT NULL,
  `credit_card_id` int UNSIGNED NULL DEFAULT NULL,
  `pos_lounge_invoice_id` int UNSIGNED NULL DEFAULT NULL,
  `journal_entry` int UNSIGNED NULL DEFAULT NULL,
  `printed` int NULL DEFAULT NULL,
  `amount_cash` double NULL DEFAULT NULL,
  `amount_visa` double NULL DEFAULT NULL,
  `customer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `customer_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `customer_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `transfer_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `amount` double NOT NULL,
  `amount_t` double NULL DEFAULT NULL,
  `tax` double NULL DEFAULT NULL,
  `tax_t` double NULL DEFAULT NULL,
  `discount` double NULL DEFAULT NULL,
  `discount_t` double NULL DEFAULT NULL,
  `collected_money` double NULL DEFAULT NULL,
  `pos_sales_category_id` int UNSIGNED NULL DEFAULT NULL,
  `transfer_to_server_state` int UNSIGNED NULL DEFAULT NULL,
  `local_pos_id` int UNSIGNED NULL DEFAULT NULL,
  `tax_state` int UNSIGNED NULL DEFAULT NULL,
  `return_from_invoice_id` int UNSIGNED NULL DEFAULT NULL,
  `qrcode` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `uuid` 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,
  `user_id` 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,
  `pos_card_point_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 `pos_invoices_pos_id_foreign`(`pos_id` ASC) USING BTREE,
  INDEX `pos_invoices_customer_user_id_foreign`(`customer_user_id` ASC) USING BTREE,
  INDEX `pos_invoices_posting_state_id_foreign`(`posting_state_id` ASC) USING BTREE,
  INDEX `pos_invoices_journal_entry_id_foreign`(`journal_entry_id` ASC) USING BTREE,
  INDEX `pos_invoices_journal_id_foreign`(`journal_id` ASC) USING BTREE,
  INDEX `pos_invoices_note_voucher_id_foreign`(`note_voucher_id` ASC) USING BTREE,
  INDEX `pos_invoices_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `pos_invoices_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_invoices_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_invoices_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_invoices_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `pos_invoices_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_invoices_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoices_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoices_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoices_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoices_customer_user_id_foreign` FOREIGN KEY (`customer_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoices_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoices_journal_entry_id_foreign` FOREIGN KEY (`journal_entry_id`) REFERENCES `journal_entries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoices_journal_id_foreign` FOREIGN KEY (`journal_id`) REFERENCES `journals` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoices_note_voucher_id_foreign` FOREIGN KEY (`note_voucher_id`) REFERENCES `note_vouchers` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoices_pos_id_foreign` FOREIGN KEY (`pos_id`) REFERENCES `poss` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_invoices_posting_state_id_foreign` FOREIGN KEY (`posting_state_id`) REFERENCES `posting_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_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 pos_invoices
-- ----------------------------

-- ----------------------------
-- Table structure for pos_lounge_invoice_lines
-- ----------------------------
CREATE TABLE `pos_lounge_invoice_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `pos_lounge_id` int UNSIGNED NOT NULL,
  `pos_lounge_invoice_id` int UNSIGNED NOT NULL,
  `pos_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `quantity` double UNSIGNED NOT NULL,
  `price` double UNSIGNED NULL DEFAULT NULL,
  `printed_to_check` int UNSIGNED NULL DEFAULT NULL,
  `tax_value` double UNSIGNED NULL DEFAULT NULL,
  `discount` double UNSIGNED NULL DEFAULT NULL,
  `components` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `printed` int UNSIGNED NULL DEFAULT NULL,
  `remain_print` 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 `pos_lounge_invoice_lines_pos_lounge_id_foreign`(`pos_lounge_id` ASC) USING BTREE,
  INDEX `pos_lounge_invoice_lines_pos_lounge_invoice_id_foreign`(`pos_lounge_invoice_id` ASC) USING BTREE,
  INDEX `pos_lounge_invoice_lines_pos_id_foreign`(`pos_id` ASC) USING BTREE,
  INDEX `pos_lounge_invoice_lines_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `pos_lounge_invoice_lines_unit_id_foreign`(`unit_id` ASC) USING BTREE,
  INDEX `pos_lounge_invoice_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_lounge_invoice_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_lounge_invoice_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_lounge_invoice_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_lounge_invoice_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoice_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoice_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoice_lines_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoice_lines_pos_id_foreign` FOREIGN KEY (`pos_id`) REFERENCES `poss` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoice_lines_pos_lounge_id_foreign` FOREIGN KEY (`pos_lounge_id`) REFERENCES `pos_lounges` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoice_lines_pos_lounge_invoice_id_foreign` FOREIGN KEY (`pos_lounge_invoice_id`) REFERENCES `pos_lounge_invoices` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoice_lines_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoice_lines_unit_id_foreign` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of pos_lounge_invoice_lines
-- ----------------------------

-- ----------------------------
-- Table structure for pos_lounge_invoices
-- ----------------------------
CREATE TABLE `pos_lounge_invoices`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `pos_lounge_id` int UNSIGNED NOT NULL,
  `pos_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `printed_to_check` 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 `pos_lounge_invoices_pos_lounge_id_foreign`(`pos_lounge_id` ASC) USING BTREE,
  INDEX `pos_lounge_invoices_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `pos_lounge_invoices_pos_id_foreign`(`pos_id` ASC) USING BTREE,
  INDEX `pos_lounge_invoices_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_lounge_invoices_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_lounge_invoices_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_lounge_invoices_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_lounge_invoices_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoices_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoices_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoices_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoices_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoices_pos_id_foreign` FOREIGN KEY (`pos_id`) REFERENCES `poss` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounge_invoices_pos_lounge_id_foreign` FOREIGN KEY (`pos_lounge_id`) REFERENCES `pos_lounges` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of pos_lounge_invoices
-- ----------------------------

-- ----------------------------
-- Table structure for pos_lounges
-- ----------------------------
CREATE TABLE `pos_lounges`  (
  `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,
  `casher_printer_ip` 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,
  `branch_id` int UNSIGNED NOT NULL,
  `pos_table_id` int UNSIGNED NOT NULL,
  `state` 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,
  `last_start` datetime 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 `pos_lounges_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `pos_lounges_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_lounges_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_lounges_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_lounges_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_lounges_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounges_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounges_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounges_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_lounges_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 pos_lounges
-- ----------------------------
INSERT INTO `pos_lounges` VALUES (1, 'طاولة 1', '1', NULL, 'Table 1', 1, 1, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);

-- ----------------------------
-- Table structure for pos_online_order_settings
-- ----------------------------
CREATE TABLE `pos_online_order_settings`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `create_journal_entry` int UNSIGNED NULL DEFAULT NULL,
  `driver_product_id` int UNSIGNED NULL DEFAULT NULL,
  `insurance_product_id` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `outstanding_and_unpaid_revenue` int UNSIGNED NULL DEFAULT NULL,
  `driver_account_user_id` int UNSIGNED NULL DEFAULT NULL,
  `insurance_account_user_id` int UNSIGNED NULL DEFAULT NULL,
  `send_sms_to_customer` int UNSIGNED NULL DEFAULT NULL,
  `customer_main_account_id` int UNSIGNED NULL DEFAULT NULL,
  `receipt_header` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `receipt_footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `print_order_as_final_stage` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `domain_for_sms` 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 `pos_online_order_settings_send_sms_to_customer_foreign`(`send_sms_to_customer` ASC) USING BTREE,
  INDEX `pos_online_order_settings_driver_account_user_id_foreign`(`driver_account_user_id` ASC) USING BTREE,
  INDEX `pos_online_order_settings_insurance_account_user_id_foreign`(`insurance_account_user_id` ASC) USING BTREE,
  INDEX `pos_online_order_settings_create_journal_entry_foreign`(`create_journal_entry` ASC) USING BTREE,
  INDEX `pos_online_order_settings_driver_product_id_foreign`(`driver_product_id` ASC) USING BTREE,
  INDEX `pos_online_order_settings_insurance_product_id_foreign`(`insurance_product_id` ASC) USING BTREE,
  INDEX `pos_online_order_settings_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `pos_online_order_settings_outstanding_and_unpaid_revenue_foreign`(`outstanding_and_unpaid_revenue` ASC) USING BTREE,
  INDEX `pos_online_order_settings_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_online_order_settings_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_online_order_settings_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_online_order_settings_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_online_order_settings_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_online_order_settings_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_online_order_settings_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_online_order_settings_create_journal_entry_foreign` FOREIGN KEY (`create_journal_entry`) REFERENCES `status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_online_order_settings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_online_order_settings_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_online_order_settings_driver_account_user_id_foreign` FOREIGN KEY (`driver_account_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_online_order_settings_driver_product_id_foreign` FOREIGN KEY (`driver_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_online_order_settings_insurance_account_user_id_foreign` FOREIGN KEY (`insurance_account_user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_online_order_settings_insurance_product_id_foreign` FOREIGN KEY (`insurance_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_online_order_settings_outstanding_and_unpaid_revenue_foreign` FOREIGN KEY (`outstanding_and_unpaid_revenue`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_online_order_settings_send_sms_to_customer_foreign` FOREIGN KEY (`send_sms_to_customer`) 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 pos_online_order_settings
-- ----------------------------

-- ----------------------------
-- Table structure for pos_payment_methods
-- ----------------------------
CREATE TABLE `pos_payment_methods`  (
  `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 `pos_payment_methods_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_payment_methods_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_payment_methods_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_payment_methods_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_payment_methods_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_payment_methods_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_payment_methods_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_payment_methods_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 pos_payment_methods
-- ----------------------------
INSERT INTO `pos_payment_methods` VALUES (1, 'كاش', '1', 'Cash', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);
INSERT INTO `pos_payment_methods` VALUES (2, 'فيزا', '2', 'Visa', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);
INSERT INTO `pos_payment_methods` VALUES (3, 'كاش + فيزا', '3', 'Visa', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);
INSERT INTO `pos_payment_methods` VALUES (4, 'نقاط', '4', 'Visa', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);

-- ----------------------------
-- Table structure for pos_posting_types
-- ----------------------------
CREATE TABLE `pos_posting_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 `pos_posting_types_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_posting_types_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_posting_types_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_posting_types_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_posting_types_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_posting_types_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_posting_types_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_posting_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 pos_posting_types
-- ----------------------------
INSERT INTO `pos_posting_types` VALUES (1, 'قيد وفاتورة مجمعة', '1', 'One note voucher and one journal entry', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);
INSERT INTO `pos_posting_types` VALUES (2, 'قيد وسند اخراج على كل فاتورة', '1', 'Note voucher and Journal entry for every invoice', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:51', '2025-06-12 14:05:51', NULL);

-- ----------------------------
-- Table structure for pos_printers
-- ----------------------------
CREATE TABLE `pos_printers`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `beeb` int UNSIGNED NOT NULL,
  `state` int UNSIGNED NULL DEFAULT NULL,
  `branch_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,
  `printing_state_id` int UNSIGNED 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 `pos_printers_state_foreign`(`state` ASC) USING BTREE,
  INDEX `pos_printers_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_printers_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_printers_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_printers_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_printers_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_printers_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_printers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_printers_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_printers_state_foreign` FOREIGN KEY (`state`) 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 pos_printers
-- ----------------------------

-- ----------------------------
-- Table structure for pos_product_categories
-- ----------------------------
CREATE TABLE `pos_product_categories`  (
  `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,
  `pos_product_category_id` int UNSIGNED NULL DEFAULT NULL,
  `is_it_components` int UNSIGNED NULL DEFAULT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `pos_id` int UNSIGNED NOT NULL,
  `is_it_for_all_poss` int UNSIGNED NOT 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 `pos_product_categories_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_product_categories_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_product_categories_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  INDEX `pos_product_categories_pos_product_category_id_foreign`(`pos_product_category_id` ASC) USING BTREE,
  CONSTRAINT `pos_product_categories_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_categories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_categories_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_categories_pos_product_category_id_foreign` FOREIGN KEY (`pos_product_category_id`) REFERENCES `pos_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 pos_product_categories
-- ----------------------------

-- ----------------------------
-- Table structure for pos_product_category_relations
-- ----------------------------
CREATE TABLE `pos_product_category_relations`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NULL DEFAULT NULL,
  `pos_product_category_id` int UNSIGNED NULL DEFAULT NULL,
  `user_id` int UNSIGNED NULL DEFAULT NULL,
  `rank` 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 `pos_product_category_relations_product_id_foreign`(`product_id` ASC) USING BTREE,
  INDEX `pos_product_category_relations_pos_product_category_id_foreign`(`pos_product_category_id` ASC) USING BTREE,
  INDEX `pos_product_category_relations_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_product_category_relations_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_product_category_relations_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_product_category_relations_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_product_category_relations_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_category_relations_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_category_relations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_category_relations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_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 `pos_product_category_relations_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 pos_product_category_relations
-- ----------------------------

-- ----------------------------
-- Table structure for pos_product_components
-- ----------------------------
CREATE TABLE `pos_product_components`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `product_id` int UNSIGNED NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `price` double NULL DEFAULT NULL,
  `state` 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,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `pos_product_components_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_product_components_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_product_components_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_product_components_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_product_components_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_components_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_components_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_components_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 pos_product_components
-- ----------------------------

-- ----------------------------
-- Table structure for pos_product_extras
-- ----------------------------
CREATE TABLE `pos_product_extras`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `first_product_id` int UNSIGNED NOT NULL,
  `second_product_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 `pos_product_extras_first_product_id_foreign`(`first_product_id` ASC) USING BTREE,
  INDEX `pos_product_extras_second_product_id_foreign`(`second_product_id` ASC) USING BTREE,
  INDEX `pos_product_extras_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_product_extras_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_product_extras_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_product_extras_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_product_extras_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_extras_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_extras_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_extras_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_extras_first_product_id_foreign` FOREIGN KEY (`first_product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_product_extras_second_product_id_foreign` FOREIGN KEY (`second_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 pos_product_extras
-- ----------------------------

-- ----------------------------
-- Table structure for pos_sales_categories
-- ----------------------------
CREATE TABLE `pos_sales_categories`  (
  `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 `pos_sales_categories_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_sales_categories_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_sales_categories_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_sales_categories_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_sales_categories_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_sales_categories_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_sales_categories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_sales_categories_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 pos_sales_categories
-- ----------------------------
INSERT INTO `pos_sales_categories` VALUES (1, 'مبيعات', '1', 'Sales', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);
INSERT INTO `pos_sales_categories` VALUES (2, 'طلبيات', '2', 'Requests', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);
INSERT INTO `pos_sales_categories` VALUES (3, 'جملة', '3', 'Whole sale', NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:59', '2025-06-12 14:05:59', NULL);

-- ----------------------------
-- Table structure for pos_settings
-- ----------------------------
CREATE TABLE `pos_settings`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `printing_state_id` int UNSIGNED NULL DEFAULT NULL,
  `transfer_token` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
  `transfer_link` 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 `pos_settings_printing_state_id_foreign`(`printing_state_id` ASC) USING BTREE,
  INDEX `pos_settings_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_settings_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_settings_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_settings_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_settings_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_settings_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_settings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_settings_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_settings_printing_state_id_foreign` FOREIGN KEY (`printing_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 pos_settings
-- ----------------------------

-- ----------------------------
-- Table structure for pos_tables
-- ----------------------------
CREATE TABLE `pos_tables`  (
  `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,
  `branch_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 `pos_tables_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `pos_tables_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_tables_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_tables_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_tables_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_tables_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_tables_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_tables_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_tables_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_tables_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 pos_tables
-- ----------------------------
INSERT INTO `pos_tables` VALUES (1, 'صالة 1', '1', 'Lounge 1', 1, NULL, 1, NULL, NULL, NULL, NULL, '2025-06-12 14:05:54', '2025-06-12 14:05:54', NULL);

-- ----------------------------
-- Table structure for pos_users
-- ----------------------------
CREATE TABLE `pos_users`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `pos_id` int UNSIGNED NOT NULL,
  `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 `pos_users_pos_id_foreign`(`pos_id` ASC) USING BTREE,
  INDEX `pos_users_user_id_foreign`(`user_id` ASC) USING BTREE,
  INDEX `pos_users_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_users_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_users_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_users_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_users_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_users_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_users_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_users_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_users_pos_id_foreign` FOREIGN KEY (`pos_id`) REFERENCES `poss` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_users_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 pos_users
-- ----------------------------

-- ----------------------------
-- Table structure for pos_waiting_invoice_lines
-- ----------------------------
CREATE TABLE `pos_waiting_invoice_lines`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `pos_id` int UNSIGNED NOT NULL,
  `pos_waiting_invoice_id` int UNSIGNED NOT NULL,
  `posting_state_id` int UNSIGNED NOT NULL,
  `product_id` int UNSIGNED NOT NULL,
  `unit_id` int UNSIGNED NOT NULL,
  `price` double UNSIGNED NULL DEFAULT NULL,
  `discount` double UNSIGNED NULL DEFAULT NULL,
  `quantity` double UNSIGNED NULL DEFAULT NULL,
  `printed` double UNSIGNED NULL DEFAULT NULL,
  `remain_print` double UNSIGNED NULL DEFAULT NULL,
  `components` 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 `pos_waiting_invoice_lines_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_waiting_invoice_lines_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_waiting_invoice_lines_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_waiting_invoice_lines_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_waiting_invoice_lines_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_waiting_invoice_lines_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_waiting_invoice_lines_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_waiting_invoice_lines_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 pos_waiting_invoice_lines
-- ----------------------------

-- ----------------------------
-- Table structure for pos_waiting_invoices
-- ----------------------------
CREATE TABLE `pos_waiting_invoices`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `pos_id` int UNSIGNED NOT NULL,
  `posting_state_id` int UNSIGNED NOT NULL,
  `branch_id` int UNSIGNED NOT NULL,
  `printed` int NULL DEFAULT NULL,
  `amount` double UNSIGNED NULL DEFAULT NULL,
  `customer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `customer_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `customer_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `arrival_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 `pos_waiting_invoices_pos_id_foreign`(`pos_id` ASC) USING BTREE,
  INDEX `pos_waiting_invoices_posting_state_id_foreign`(`posting_state_id` ASC) USING BTREE,
  INDEX `pos_waiting_invoices_branch_id_foreign`(`branch_id` ASC) USING BTREE,
  INDEX `pos_waiting_invoices_approved_by_foreign`(`approved_by` ASC) USING BTREE,
  INDEX `pos_waiting_invoices_approved_state_id_foreign`(`approved_state_id` ASC) USING BTREE,
  INDEX `pos_waiting_invoices_created_by_foreign`(`created_by` ASC) USING BTREE,
  INDEX `pos_waiting_invoices_deleted_by_foreign`(`deleted_by` ASC) USING BTREE,
  CONSTRAINT `pos_waiting_invoices_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_waiting_invoices_approved_state_id_foreign` FOREIGN KEY (`approved_state_id`) REFERENCES `approval_status` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_waiting_invoices_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_waiting_invoices_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_waiting_invoices_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_waiting_invoices_pos_id_foreign` FOREIGN KEY (`pos_id`) REFERENCES `poss` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `pos_waiting_invoices_posting_state_id_foreign` FOREIGN KEY (`posting_state_id`) REFERENCES `posting_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 pos_waiting_invoices
-- ----------------------------

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