# ************************************************************
# Sequel Pro SQL dump
# Versión 4541
#
# http://www.sequelpro.com/
# https://github.com/sequelpro/sequelpro
#
# Host: 127.0.0.1 (MySQL 5.7.26)
# Base de datos: financiera
# Tiempo de Generación: 2020-04-22 18:38:31 +0000
# ************************************************************




# Volcado de tabla administradores
# ------------------------------------------------------------


CREATE TABLE `administradores` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(11) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `administrador_usuario` (`user_id`),
  CONSTRAINT `administrador_usuario` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla agencias
# ------------------------------------------------------------


CREATE TABLE `agencias` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `nombre` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `clave` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `direccion` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `seccion_id` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla clientes
# ------------------------------------------------------------


CREATE TABLE `clientes` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `codigo_cliente` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rfc` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `curp` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sexo` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `estado_civil` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `n_dependientes` int(10) DEFAULT NULL,
  `identificacion_frente` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `identificacion_detras` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tipo_identificacion` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `no_identificacion` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lugar_nacimiento` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `nacionalidad` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `nombre_conyuge` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fecha_nacimiento_conyuge` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tipo_empleo` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tipo_empleo_otro` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `negocio_propio` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `antiguedad_anios` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `antiguedad_meses` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ocupacion` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ocupacion_otro` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `periodicidad_ingresos` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `periodicidad_ingresos_otro` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ingresos_comprobados_s` double DEFAULT NULL,
  `ingresos_comprobados_f` double DEFAULT NULL,
  `ingresos_no_comprobados_s` double DEFAULT NULL,
  `ingresos_no_comprobados_f` double DEFAULT NULL,
  `total_ingresos_s` double DEFAULT NULL,
  `total_ingresos_f` double DEFAULT NULL,
  `renta_casa_s` double DEFAULT NULL,
  `renta_casa_f` double DEFAULT NULL,
  `alimentos_s` double DEFAULT NULL,
  `alimentos_f` double DEFAULT NULL,
  `gastos_regulares_s` double DEFAULT NULL,
  `gastos_regulares_f` double DEFAULT NULL,
  `otro_gastos_regulares_s` double DEFAULT NULL,
  `otro_gastos_regulares_f` double DEFAULT NULL,
  `pago_creditos_s` double DEFAULT NULL,
  `pago_creditos_f` double DEFAULT NULL,
  `total_gastos_s` double DEFAULT NULL,
  `total_gastos_f` double DEFAULT NULL,
  `efectivo_mensual_disponible` double DEFAULT NULL,
  `tarifa_semanal_maxima` double DEFAULT NULL,
  `tarifa_propuesta_semanal` double DEFAULT NULL,
  `check_luz` tinyint(4) DEFAULT NULL,
  `check_agua_potable` tinyint(4) DEFAULT NULL,
  `check_auto_propio` tinyint(4) DEFAULT NULL,
  `check_telefono_fijo` tinyint(4) DEFAULT NULL,
  `check_telefono_movil` tinyint(4) DEFAULT NULL,
  `check_refrigerador` tinyint(4) DEFAULT NULL,
  `check_estufa` tinyint(4) DEFAULT NULL,
  `check_internet` tinyint(4) DEFAULT NULL,
  `check_gas` tinyint(4) DEFAULT NULL,
  `check_tv_paga` tinyint(4) DEFAULT NULL,
  `check_alumbrado_publico` tinyint(4) DEFAULT NULL,
  `domicilio_id` int(10) unsigned DEFAULT NULL,
  `cobranza_id` int(10) unsigned DEFAULT NULL,
  `laboral_id` int(10) unsigned DEFAULT NULL,
  `prestamo_empresas_otras` enum('Si','No') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `madre_soltera` enum('Si','No') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `auto_propio` enum('Si','No') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `personas_viviendo` int(10) DEFAULT NULL,
  `territorio_id` int(10) unsigned DEFAULT NULL,
  `estado_cuenta` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `comprobante_domicilio` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `clientes_usuarios` (`user_id`),
  KEY `cliente_domicilio` (`domicilio_id`),
  KEY `cliente_cobranza` (`cobranza_id`),
  KEY `cliente_laboral` (`laboral_id`),
  CONSTRAINT `cliente_cobranza` FOREIGN KEY (`cobranza_id`) REFERENCES `domicilios` (`id`) ON DELETE CASCADE,
  CONSTRAINT `cliente_domicilio` FOREIGN KEY (`domicilio_id`) REFERENCES `domicilios` (`id`) ON DELETE CASCADE,
  CONSTRAINT `cliente_laboral` FOREIGN KEY (`laboral_id`) REFERENCES `domicilios` (`id`) ON DELETE CASCADE,
  CONSTRAINT `clientes_usuarios` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla cobranzas
# ------------------------------------------------------------


CREATE TABLE `cobranzas` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `no_semana` int(11) DEFAULT NULL,
  `fecha_pago` date DEFAULT NULL,
  `tarifa_semanal` float DEFAULT NULL,
  `atrasos` float DEFAULT NULL,
  `cargo_moratorio` float DEFAULT NULL,
  `pago_esperado` float DEFAULT NULL,
  `pago_recibido` float DEFAULT NULL,
  `balance_final` float DEFAULT NULL,
  `balance_final_esperado` float DEFAULT NULL,
  `estatus` enum('Realizado','No Realizado','Espera','Incompleto','Saldo a favor') DEFAULT NULL,
  `prestamo_id` int(11) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `cobranza_prestamo` (`prestamo_id`),
  CONSTRAINT `cobranza_prestamo` FOREIGN KEY (`prestamo_id`) REFERENCES `prestamos` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;



# Volcado de tabla colonias
# ------------------------------------------------------------


CREATE TABLE `colonias` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `nombre` varchar(50) DEFAULT NULL,
  `asentamiento` varchar(50) DEFAULT NULL,
  `codigo_postal` int(11) DEFAULT NULL,
  `territorio_id` int(11) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `colonia_territorio` (`territorio_id`),
  CONSTRAINT `colonia_territorio` FOREIGN KEY (`territorio_id`) REFERENCES `territorios` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



# Volcado de tabla comisiones
# ------------------------------------------------------------


CREATE TABLE `comisiones` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `promotor_id` int(11) DEFAULT NULL,
  `firma` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `inicio_semana` datetime DEFAULT NULL,
  `fin_semana` datetime DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `total_comision` double DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla configuraciones
# ------------------------------------------------------------


CREATE TABLE `configuraciones` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `fecha_falsa` timestamp NULL DEFAULT NULL,
  `num_max_semanas` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `reprecentante` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `app_mode` enum('PROD','DEBUG') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ultima_ejecucion` timestamp NULL DEFAULT NULL,
  `monto_maximo_por_domcicilio` double DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `configuraciones` (`id`, `fecha_falsa`, `num_max_semanas`, `created_at`, `updated_at`, `deleted_at`, `reprecentante`, `app_mode`, `ultima_ejecucion`, `monto_maximo_por_domcicilio`)
VALUES
	(1,'2020-03-20 00:00:00',20,'2019-10-24 21:15:07','2020-04-22 07:09:32',NULL,'Juan Camanei Juarez','DEBUG','2020-03-20 00:00:00',NULL);



# Volcado de tabla credit_cards
# ------------------------------------------------------------


CREATE TABLE `credit_cards` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `cliente_id` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `banco` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ultimo_digitos` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `creditCar_cliente` (`cliente_id`),
  CONSTRAINT `creditCar_cliente` FOREIGN KEY (`cliente_id`) REFERENCES `clientes` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla domicilios
# ------------------------------------------------------------


CREATE TABLE `domicilios` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `calle` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `num_int` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `num_ext` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `colonia` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tipo_asentamiento` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `codigo_postal` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ciudad` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `estado` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `municipio` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pais` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tiempo_viviendo` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tipo_domicilio` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vive_con` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_id` int(11) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `type` enum('Empresa','Cobranza','Vivienda') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `telefono` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `telefono_casa` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tipo_usuario` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tiempo_viviendo_anios` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tiempo_viviendo_meses` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `otra_colonia` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lat` double DEFAULT NULL,
  `lng` double DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `domicilio_usuario` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla errores_administrativos
# ------------------------------------------------------------


CREATE TABLE `errores_administrativos` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `tipo_error` varchar(100) DEFAULT NULL,
  `concepto` varchar(100) DEFAULT NULL,
  `fecha` date DEFAULT NULL,
  `promotor_id` int(11) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



# Volcado de tabla gerentes_sucursales
# ------------------------------------------------------------


CREATE TABLE `gerentes_sucursales` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `codigo_gerente_sucursal` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `agencia_id` int(11) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `gerenteSucursal_usuarios` (`user_id`),
  KEY `gerente_sucursales_sucursales` (`agencia_id`),
  CONSTRAINT `gerenteSucursal_usuarios` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  CONSTRAINT `gerente_sucursales_sucursales` FOREIGN KEY (`agencia_id`) REFERENCES `agencias` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla gerentes_supervisores
# ------------------------------------------------------------


CREATE TABLE `gerentes_supervisores` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `codigo_gerente_supervisor` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `gerente_sucursal_id` int(11) unsigned DEFAULT NULL,
  `grupo_secciones_id` int(11) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `gerenteSupervisor_usuarios` (`user_id`),
  KEY `gerenteScucursal_gerenteSupervisor` (`gerente_sucursal_id`),
  KEY `gerente_supervisores_grupo_secciones` (`grupo_secciones_id`),
  CONSTRAINT `gerenteScucursal_gerenteSupervisor` FOREIGN KEY (`gerente_sucursal_id`) REFERENCES `gerentes_sucursales` (`id`) ON DELETE CASCADE,
  CONSTRAINT `gerenteSupervisor_usuarios` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  CONSTRAINT `gerente_supervisores_grupo_secciones` FOREIGN KEY (`grupo_secciones_id`) REFERENCES `grupo_secciones` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla grupo_secciones
# ------------------------------------------------------------


CREATE TABLE `grupo_secciones` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `nombre` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `clave` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `direccion` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `agencia_id` int(11) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla migrations
# ------------------------------------------------------------


CREATE TABLE `migrations` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migrations` (`id`, `migration`, `batch`)
VALUES
	(1,'2014_10_12_000000_create_users_table',1),
	(2,'2014_10_12_100000_create_password_resets_table',1),
	(3,'2019_04_13_180116_create_permisos_table',1),
	(4,'2019_04_13_182835_create_permisos_asignados_table',1);



# Volcado de tabla pagos
# ------------------------------------------------------------


CREATE TABLE `pagos` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `cantidad` float DEFAULT NULL,
  `fecha` date DEFAULT NULL,
  `prestamo_id` int(11) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `cobranza_id` int(11) unsigned DEFAULT NULL,
  `cliente_id` int(11) unsigned DEFAULT NULL,
  `tipo_cobro` enum('Refinanciado','Puro') DEFAULT NULL,
  `recibio_id` int(10) DEFAULT NULL,
  `comentario` varchar(255) DEFAULT NULL,
  `tipo_pago_radio` enum('Transferencia','Efectivo') DEFAULT NULL,
  `num_trasferencia` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pago_prestamo` (`prestamo_id`),
  KEY `pagos_cobranza` (`cobranza_id`),
  CONSTRAINT `pago_prestamo` FOREIGN KEY (`prestamo_id`) REFERENCES `prestamos` (`id`) ON DELETE CASCADE,
  CONSTRAINT `pagos_cobranza` FOREIGN KEY (`cobranza_id`) REFERENCES `cobranzas` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;



# Volcado de tabla permisos
# ------------------------------------------------------------


CREATE TABLE `permisos` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `nombre` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla permisos_asignados
# ------------------------------------------------------------


CREATE TABLE `permisos_asignados` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `permiso_id` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `permisos_asignados_user_id_foreign` (`user_id`),
  KEY `permisos_asignados_permiso_id_foreign` (`permiso_id`),
  CONSTRAINT `permisos_asignados_permiso_id_foreign` FOREIGN KEY (`permiso_id`) REFERENCES `permisos` (`id`),
  CONSTRAINT `permisos_asignados_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla prestamos
# ------------------------------------------------------------


CREATE TABLE `prestamos` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `cliente_id` int(10) unsigned NOT NULL,
  `promotor_id` int(10) unsigned DEFAULT NULL,
  `inicio_prestamo` date DEFAULT NULL,
  `fin_prestamo` date DEFAULT NULL,
  `estatus` enum('Inactivo','Normal','Mora','Completado') COLLATE utf8mb4_unicode_ci DEFAULT 'Inactivo',
  `calificacion` float DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `solicitud_id` int(11) unsigned DEFAULT NULL,
  `fecha_finalizado` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `prestamo_promotor` (`promotor_id`),
  KEY `prestamo_cliente` (`cliente_id`),
  KEY `prestamo_solicitud` (`solicitud_id`),
  CONSTRAINT `prestamo_cliente` FOREIGN KEY (`cliente_id`) REFERENCES `clientes` (`id`) ON DELETE CASCADE,
  CONSTRAINT `prestamo_promotor` FOREIGN KEY (`promotor_id`) REFERENCES `promotores` (`id`) ON DELETE CASCADE,
  CONSTRAINT `prestamo_solicitud` FOREIGN KEY (`solicitud_id`) REFERENCES `solicitudes` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla promotores
# ------------------------------------------------------------


CREATE TABLE `promotores` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `codigo_promotor` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `supervisor_id` int(10) unsigned DEFAULT NULL,
  `territorio_id` int(11) unsigned DEFAULT NULL,
  `score` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `promotores_usuarios` (`user_id`),
  KEY `promotor_territorio` (`territorio_id`),
  KEY `promotor_supervisor` (`supervisor_id`),
  CONSTRAINT `promotor_supervisor` FOREIGN KEY (`supervisor_id`) REFERENCES `supervisores` (`id`) ON DELETE CASCADE,
  CONSTRAINT `promotor_territorio` FOREIGN KEY (`territorio_id`) REFERENCES `territorios` (`id`) ON DELETE CASCADE,
  CONSTRAINT `promotores_usuarios` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla referencias
# ------------------------------------------------------------


CREATE TABLE `referencias` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `cliente_id` int(11) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `nombre` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `a_paterno` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `a_materno` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `parentesco` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `numero_referencia` int(11) DEFAULT NULL,
  `telefono_celular` varchar(14) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `telefono_casa` varchar(14) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `domicilio_id` int(11) unsigned DEFAULT NULL,
  `contactada` bit(1) DEFAULT NULL,
  `parentesco_otro` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `referencia_cliente` (`cliente_id`),
  KEY `referencia_domicilio` (`domicilio_id`),
  CONSTRAINT `referencia_cliente` FOREIGN KEY (`cliente_id`) REFERENCES `clientes` (`id`) ON DELETE CASCADE,
  CONSTRAINT `referencia_domicilio` FOREIGN KEY (`domicilio_id`) REFERENCES `domicilios` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla referencias_validacion
# ------------------------------------------------------------


CREATE TABLE `referencias_validacion` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `parentesco` blob,
  `telefono_solicitante` blob,
  `referencia_interesada` blob,
  `sueldo` blob,
  `auto` blob,
  `refrigerador` blob,
  `gas` blob,
  `periodo_pago` blob,
  `direccion` blob,
  `actividad` blob,
  `trabajo` blob,
  `recomienda` blob,
  `referencia_id` int(11) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `referencia_validacion_referencia` (`referencia_id`),
  CONSTRAINT `referencia_validacion_referencia` FOREIGN KEY (`referencia_id`) REFERENCES `referencias` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



# Volcado de tabla rompimiento_politicas
# ------------------------------------------------------------


CREATE TABLE `rompimiento_politicas` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `tipo_error` varchar(100) DEFAULT NULL,
  `concepto` varchar(100) DEFAULT NULL,
  `fecha` date DEFAULT NULL,
  `promotor_id` int(11) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



# Volcado de tabla secciones
# ------------------------------------------------------------


CREATE TABLE `secciones` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `nombre` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `clave` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `direccion` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `grupo_secciones_id` int(11) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `secciones_grupo_seccion` (`grupo_secciones_id`),
  CONSTRAINT `secciones_grupo_seccion` FOREIGN KEY (`grupo_secciones_id`) REFERENCES `grupo_secciones` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla solicitudes
# ------------------------------------------------------------


CREATE TABLE `solicitudes` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `promotor_id` int(10) unsigned DEFAULT NULL,
  `cliente_id` int(10) unsigned DEFAULT NULL,
  `comprobante_domicilio` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `estado_cuenta` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rfc` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `homoclave` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `credito_carro` enum('Si','No') COLLATE utf8mb4_unicode_ci DEFAULT 'No',
  `status` enum('Aprobada','Rechazada','Proceso','Paso 2','Paso 3','Paso 4','Paso 5','Supervisión','Validación','Preaprobado') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cantidad_solicitada` float DEFAULT NULL,
  `cantidad_aprobada` float DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `domicilio_id` int(11) unsigned DEFAULT NULL,
  `comision_apertura` float DEFAULT NULL,
  `total_financiar` float DEFAULT NULL,
  `plazo_credito` int(11) DEFAULT NULL,
  `tasa_interes_anual` float DEFAULT NULL,
  `costo_anual_total` float DEFAULT NULL,
  `cargo_servicio` float DEFAULT NULL,
  `primer_pago` float DEFAULT NULL,
  `pago_semanal` float DEFAULT NULL,
  `prestamo_empresas_otras` enum('Si','No') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `madre_soltera` enum('Si','No') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `auto_propio` enum('Si','No') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `firma` blob,
  `tipo_prestamo` enum('Renovación','Paralelo','Refinanciamiento','Normal') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `primer_viernes` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `solicitud_domicilio` (`domicilio_id`),
  KEY `solicitud_cliente` (`cliente_id`),
  CONSTRAINT `solicitud_cliente` FOREIGN KEY (`cliente_id`) REFERENCES `clientes` (`id`) ON DELETE CASCADE,
  CONSTRAINT `solicitud_domicilio` FOREIGN KEY (`domicilio_id`) REFERENCES `domicilios` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla supervisores
# ------------------------------------------------------------


CREATE TABLE `supervisores` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL,
  `supervisor_id` int(10) unsigned DEFAULT NULL,
  `codigo_supervisor` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `gerente_supervisor_id` int(10) unsigned DEFAULT NULL,
  `seccion_id` int(11) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `supervisores_usuarios` (`user_id`),
  KEY `supervisor_gerente_supervisor` (`gerente_supervisor_id`),
  KEY `supervisores_secciones` (`seccion_id`),
  CONSTRAINT `supervisor_gerente_supervisor` FOREIGN KEY (`gerente_supervisor_id`) REFERENCES `gerentes_supervisores` (`id`) ON DELETE CASCADE,
  CONSTRAINT `supervisores_secciones` FOREIGN KEY (`seccion_id`) REFERENCES `secciones` (`id`) ON DELETE CASCADE,
  CONSTRAINT `supervisores_usuarios` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla territorios
# ------------------------------------------------------------


CREATE TABLE `territorios` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `nombre` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `clave` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `direccion` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `seccion_id` int(11) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `territorio_seccion` (`seccion_id`),
  CONSTRAINT `territorio_seccion` FOREIGN KEY (`seccion_id`) REFERENCES `secciones` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


# Volcado de tabla validadores
# ------------------------------------------------------------


CREATE TABLE `validadores` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(11) unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `codigo_validador` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `administrador_usuario` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



# Volcado de tabla visitas
# ------------------------------------------------------------


CREATE TABLE `visitas` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `fecha` date DEFAULT NULL,
  `hora` time DEFAULT NULL,
  `cliente_id` int(11) unsigned DEFAULT NULL,
  `promotor_id` int(11) unsigned DEFAULT NULL,
  `comentario` varchar(300) DEFAULT NULL,
  `lat` double DEFAULT NULL,
  `long` double DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `validacion` tinyint(4) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `visita_cliente` (`cliente_id`),
  KEY `visita_promotor` (`promotor_id`),
  CONSTRAINT `visita_cliente` FOREIGN KEY (`cliente_id`) REFERENCES `clientes` (`id`) ON DELETE CASCADE,
  CONSTRAINT `visita_promotor` FOREIGN KEY (`promotor_id`) REFERENCES `promotores` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;




