--
-- Host: localhost    Database: gold
-- ------------------------------------------------------


--
-- Table structure for table `Top 20`
--

CREATE TABLE `Top 20` (
  `nomb_clie` char(50) DEFAULT NULL,
  `sum(g.monto_total)` decimal(32,2) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `acceso`
--

CREATE TABLE `acceso` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `usuario_id` int(10) unsigned NOT NULL,
  `fecha_acceso` date NOT NULL,
  `programa` varchar(100) NOT NULL,
  `parametros` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `acceso_usua_idx` (`usuario_id`),
  CONSTRAINT `fk_acceso_usuario` FOREIGN KEY (`usuario_id`) REFERENCES `usuario` (`codi_usua`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `aliado_comercial`
--

CREATE TABLE `aliado_comercial` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `razon_social` varchar(80) NOT NULL,
  `nro_rif` varchar(20) NOT NULL,
  `direccion_fiscal` varchar(100) NOT NULL,
  `contacto` varchar(45) NOT NULL,
  `telefono` varchar(45) NOT NULL,
  `email` varchar(100) NOT NULL,
  `status_id` int(10) unsigned NOT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `ac_status_idx` (`status_id`),
  KEY `ac_sucursal_idx` (`sucursal_id`),
  CONSTRAINT `ac_status_fk` FOREIGN KEY (`status_id`) REFERENCES `status_type` (`codi_stat`),
  CONSTRAINT `aliado_comercial_sucursal_id_foreign` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--
-- Temporary table structure for view `api_estado`
--

/*!50001 DROP VIEW IF EXISTS `api_estado`*/;
/*!50001 CREATE VIEW `api_estado` AS SELECT 
 1 AS `id`,
 1 AS `nombre`*/;

--
-- Temporary table structure for view `api_sucursal`
--

/*!50001 DROP VIEW IF EXISTS `api_sucursal`*/;
/*!50001 CREATE VIEW `api_sucursal` AS SELECT 
 1 AS `codigo`,
 1 AS `nombre`,
 1 AS `email`,
 1 AS `area_metropolitana`,
 1 AS `zonas_no_cubiertas`,
 1 AS `frecuencia_de_cobertura`,
 1 AS `estado`*/;

--
-- Table structure for table `asistente`
--

CREATE TABLE `asistente` (
  `codi_asis` int(11) NOT NULL AUTO_INCREMENT,
  `nomb_asis` char(50) NOT NULL COMMENT 'Nombre',
  `apel_asis` char(50) NOT NULL COMMENT 'Apellido',
  `nume_cedu` char(15) DEFAULT NULL,
  `nume_tele` char(20) DEFAULT NULL,
  `text_obse` char(200) DEFAULT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `codi_disp` int(11) NOT NULL,
  `codi_stat` int(10) unsigned NOT NULL,
  PRIMARY KEY (`codi_asis`),
  KEY `asistente_FKIndex2` (`codi_disp`),
  KEY `asistente_FKIndex3` (`codi_stat`),
  KEY `asistente_sucursal_id_IDX` (`sucursal_id`) USING BTREE,
  CONSTRAINT `asistente_ibfk_2` FOREIGN KEY (`codi_disp`) REFERENCES `disponible_type` (`codi_disp`),
  CONSTRAINT `asistente_ibfk_3` FOREIGN KEY (`codi_stat`) REFERENCES `status_type` (`codi_stat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `audits`
--

CREATE TABLE `audits` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_type` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_id` bigint(20) unsigned DEFAULT NULL,
  `event` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `auditable_type` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `auditable_id` bigint(20) unsigned NOT NULL,
  `old_values` text COLLATE utf8mb4_unicode_ci,
  `new_values` text COLLATE utf8mb4_unicode_ci,
  `url` text COLLATE utf8mb4_unicode_ci,
  `ip_address` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` varchar(1023) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tags` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `audits_auditable_type_auditable_id_index` (`auditable_type`,`auditable_id`),
  KEY `audits_user_id_user_type_index` (`user_id`,`user_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `banco`
--

CREATE TABLE `banco` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(80) NOT NULL,
  `status_id` int(10) unsigned DEFAULT NULL,
  `abreviado` varchar(5) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_status` (`status_id`),
  CONSTRAINT `fk_banco_1` FOREIGN KEY (`status_id`) REFERENCES `status_type` (`codi_stat`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;

--
-- Table structure for table `caja`
--

CREATE TABLE `caja` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(50) NOT NULL,
  `counter_id` int(10) unsigned NOT NULL,
  `control_seniat` int(10) unsigned DEFAULT NULL,
  `tipo_id` int(10) unsigned DEFAULT NULL,
  `impresora_id` varchar(45) DEFAULT NULL,
  `serie` char(2) DEFAULT NULL,
  `conse_factura` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `caja_FKIndex1` (`counter_id`),
  KEY `caja_FKIndex2` (`tipo_id`),
  KEY `idx_countertipo` (`counter_id`,`tipo_id`),
  CONSTRAINT `caja_ibfk_1` FOREIGN KEY (`counter_id`) REFERENCES `counter` (`id`),
  CONSTRAINT `caja_ibfk_2` FOREIGN KEY (`tipo_id`) REFERENCES `tipo_caja_type` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `cajero`
--

CREATE TABLE `cajero` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `usuario_id` int(10) unsigned NOT NULL,
  `counter_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `cajero_FKIndex2` (`usuario_id`),
  KEY `cajero_FKIndex1` (`counter_id`),
  CONSTRAINT `cajero_ibfk_1` FOREIGN KEY (`counter_id`) REFERENCES `counter` (`id`),
  CONSTRAINT `cajero_ibfk_2` FOREIGN KEY (`usuario_id`) REFERENCES `usuario` (`codi_usua`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `cambio_tarifa`
--

CREATE TABLE `cambio_tarifa` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `tarifa_origen_id` int(10) unsigned NOT NULL COMMENT 'Cambiar::Indica la Tarifa Origen, la que se desea sustituir',
  `tarifa_destino_id` int(10) unsigned NOT NULL COMMENT 'Por::Indica la Tarifa Destino, la que se desea asignar',
  `excluir` varchar(250) DEFAULT NULL COMMENT 'Excepto a::Codigos Internos de los Clientes sobre los cuales no aplica este cambio',
  `ejecutar_el` date NOT NULL COMMENT 'Ejecutar El::Fecha en que entra en vigencia la nueva Tarifa',
  `registrado_el` date NOT NULL COMMENT 'Registrado El::Fecha en que el Usuario registro el cambio',
  `registrado_por` char(8) NOT NULL COMMENT 'Registrado Por::Login del Usuario que registro el cambio de la Tarifa',
  `ejecutado_el` date DEFAULT NULL COMMENT 'Ejecutado El::Fecha en que se realizo el cambio',
  `hora_ejecucion` time DEFAULT NULL COMMENT 'Hora de Ejecucion::Hora en que se realizo el cambio',
  `comentario` varchar(250) DEFAULT NULL COMMENT 'Comentario::asociado al cambio realizado',
  PRIMARY KEY (`id`),
  KEY `tari_orig_idx` (`tarifa_origen_id`) USING BTREE,
  KEY `tari_dest_idx` (`tarifa_destino_id`) USING BTREE,
  CONSTRAINT `camb_tari_dest_fk` FOREIGN KEY (`tarifa_destino_id`) REFERENCES `fac_tarifa` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `camb_tari_orig_fk` FOREIGN KEY (`tarifa_origen_id`) REFERENCES `fac_tarifa` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=latin1 COMMENT='Aqui se almacenan los cambios de Tarifa programados o ya rea';

--
-- Table structure for table `checkpoints`
--

CREATE TABLE `checkpoints` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `codigo` char(2) COLLATE utf8mb4_unicode_ci NOT NULL,
  `descripcion` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `descripcion_rastreo` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `terminal` int(10) unsigned NOT NULL,
  `visibilidad` int(10) unsigned NOT NULL,
  `tipo` enum('GESTION','INCIDENCIA','PROCESO') COLLATE utf8mb4_unicode_ci NOT NULL,
  `notificar` int(10) unsigned NOT NULL,
  `imagen` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `color` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `observacion` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `checkpoints_terminal_foreign` (`terminal`),
  KEY `checkpoints_visibilidad_foreign` (`visibilidad`),
  KEY `checkpoints_notificar_foreign` (`notificar`),
  CONSTRAINT `checkpoints_notificar_foreign` FOREIGN KEY (`notificar`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `checkpoints_terminal_foreign` FOREIGN KEY (`terminal`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `checkpoints_visibilidad_foreign` FOREIGN KEY (`visibilidad`) REFERENCES `sde_tipo_ckpt_type` (`tipo_ckpt`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `chofer`
--

CREATE TABLE `chofer` (
  `codi_chof` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `nomb_chof` char(50) NOT NULL,
  `apel_chof` char(50) NOT NULL,
  `nume_cedu` char(15) DEFAULT NULL,
  `tele_chof` char(20) DEFAULT NULL,
  `text_obse` char(200) DEFAULT NULL,
  `tipo_mens` int(10) unsigned NOT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `codi_disp` int(11) NOT NULL,
  `codi_stat` int(10) unsigned NOT NULL,
  `login` char(8) DEFAULT NULL COMMENT 'Login::',
  `password` varchar(50) DEFAULT NULL COMMENT 'Contraseña::',
  `acceso_mobile` date DEFAULT NULL COMMENT 'Último acceso Yamato::',
  PRIMARY KEY (`codi_chof`),
  UNIQUE KEY `login_idxu` (`login`) USING BTREE,
  KEY `chofer_FKIndex1` (`codi_stat`),
  KEY `chofer_FKIndex2` (`codi_disp`),
  KEY `idx_tipomens` (`tipo_mens`),
  KEY `chofer_sucursal_id_IDX` (`sucursal_id`) USING BTREE,
  CONSTRAINT `chofer_ibfk_1` FOREIGN KEY (`tipo_mens`) REFERENCES `mas_tipo_mens_type` (`tipo_mens`),
  CONSTRAINT `chofer_ibfk_3` FOREIGN KEY (`codi_disp`) REFERENCES `disponible_type` (`codi_disp`),
  CONSTRAINT `chofer_ibfk_4` FOREIGN KEY (`codi_stat`) REFERENCES `status_type` (`codi_stat`),
  CONSTRAINT `chofer_sucursal_id_foreign` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=161 DEFAULT CHARSET=latin1;

--
-- Table structure for table `ciclo_fact_type`
--

CREATE TABLE `ciclo_fact_type` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idex_desc` (`descripcion`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--
-- Table structure for table `cliente_pmn`
--

CREATE TABLE `cliente_pmn` (
  `cedula_rif` varchar(20) COLLATE latin1_spanish_ci NOT NULL,
  `nombre` varchar(100) COLLATE latin1_spanish_ci NOT NULL,
  `telefono_fijo` varchar(50) COLLATE latin1_spanish_ci NOT NULL,
  `telefono_movil` varchar(50) COLLATE latin1_spanish_ci NOT NULL,
  `direccion` varchar(200) COLLATE latin1_spanish_ci NOT NULL,
  `sucursal_id` char(20) COLLATE latin1_spanish_ci NOT NULL,
  `registrado_el` date NOT NULL,
  `registrado_por` int(10) unsigned NOT NULL,
  `email` varchar(50) COLLATE latin1_spanish_ci DEFAULT NULL,
  PRIMARY KEY (`cedula_rif`),
  KEY `cliente_pmn_usuario_idx` (`registrado_por`),
  KEY `cliente_pmn_sucursal_idx` (`sucursal_id`),
  CONSTRAINT `fk_cliente_pmn_usuario` FOREIGN KEY (`registrado_por`) REFERENCES `usuario` (`codi_usua`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;

--
-- Table structure for table `clientes_internacional`
--

CREATE TABLE `clientes_internacional` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `codigo` int(11) NOT NULL,
  `nombre` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `telefono_movil` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cedula_rif` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sexo` enum('M','F') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `telefono_fijo` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `direccion` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fecha_nacimiento` date DEFAULT NULL,
  `profesion_id` bigint(20) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `clientes_internacional_sucursal_id_foreign` (`sucursal_id`),
  KEY `clientes_internacional_profesion_id_foreign` (`profesion_id`),
  CONSTRAINT `clientes_internacional_profesion_id_foreign` FOREIGN KEY (`profesion_id`) REFERENCES `profesiones` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `clientes_internacional_sucursal_id_foreign` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `clientes_retail`
--

CREATE TABLE `clientes_retail` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `cedula_rif` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nombre` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `sexo` enum('M','F') COLLATE utf8mb4_unicode_ci NOT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `email` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `telefono_fijo` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `telefono_movil` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `direccion` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fecha_nacimiento` date DEFAULT NULL,
  `profesion_id` bigint(20) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `clientes_retail_cedula_rif_unique` (`cedula_rif`),
  KEY `clientes_retail_sucursal_id_foreign` (`sucursal_id`),
  KEY `clientes_retail_profesion_id_foreign` (`profesion_id`),
  CONSTRAINT `clientes_retail_profesion_id_foreign` FOREIGN KEY (`profesion_id`) REFERENCES `profesiones` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `clientes_retail_sucursal_id_foreign` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `cobranza`
--

CREATE TABLE `cobranza` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `factura_id` int(10) unsigned NOT NULL,
  `fecha` date NOT NULL,
  `forma_pago_id` int(10) unsigned NOT NULL,
  `documento` varchar(50) DEFAULT NULL,
  `banco_id` int(10) unsigned DEFAULT NULL,
  `monto_cancelado` float(10,2) NOT NULL DEFAULT '0.00',
  `turno_id` int(10) unsigned NOT NULL,
  `cajero_id` int(10) unsigned NOT NULL,
  `caja_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `cobranza_FKIndex1` (`forma_pago_id`),
  KEY `cobranza_FKIndex2` (`caja_id`),
  KEY `cobranza_FKIndex3` (`turno_id`),
  KEY `cobranza_FKIndex5` (`banco_id`),
  KEY `cobranza_FKIndex6` (`cajero_id`),
  KEY `cobranza_FKIndex7` (`factura_id`),
  KEY `idx_factforma` (`factura_id`,`forma_pago_id`),
  CONSTRAINT `cobranza_ibfk_1` FOREIGN KEY (`forma_pago_id`) REFERENCES `forma_pago` (`id`),
  CONSTRAINT `cobranza_ibfk_2` FOREIGN KEY (`caja_id`) REFERENCES `caja` (`id`),
  CONSTRAINT `cobranza_ibfk_3` FOREIGN KEY (`turno_id`) REFERENCES `turno` (`id`),
  CONSTRAINT `cobranza_ibfk_4` FOREIGN KEY (`banco_id`) REFERENCES `banco` (`id`),
  CONSTRAINT `cobranza_ibfk_5` FOREIGN KEY (`cajero_id`) REFERENCES `cajero` (`id`),
  CONSTRAINT `cobranza_ibfk_6` FOREIGN KEY (`factura_id`) REFERENCES `factura` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `concepto_rangos`
--

CREATE TABLE `concepto_rangos` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `concepto_id` bigint(20) unsigned NOT NULL,
  `rango_inicial` decimal(12,2) NOT NULL,
  `rango_final` decimal(12,2) NOT NULL,
  `valor` decimal(12,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `concepto_rangos_concepto_id_foreign` (`concepto_id`),
  CONSTRAINT `concepto_rangos_concepto_id_foreign` FOREIGN KEY (`concepto_id`) REFERENCES `conceptos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `conceptos`
--

CREATE TABLE `conceptos` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `nombre` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `orden` int(11) NOT NULL,
  `productos` json NOT NULL,
  `mostrar_como` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `activo` tinyint(1) NOT NULL,
  `fecha_inicial` date NOT NULL,
  `fecha_final` date DEFAULT NULL,
  `operacion` enum('SUMA','RESTA') COLLATE utf8mb4_unicode_ci NOT NULL,
  `aplica_como` enum('CANT','PORC') COLLATE utf8mb4_unicode_ci NOT NULL,
  `tipo` enum('CAMPO','CONCEPTO') COLLATE utf8mb4_unicode_ci NOT NULL,
  `actua_sobre` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
  `valor` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `base_imponible` tinyint(1) NOT NULL DEFAULT '0',
  `metodo` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `activo` (`nombre`),
  UNIQUE KEY `conceptos_nombre_unique` (`nombre`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `consumo_dia`
--

CREATE TABLE `consumo_dia` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `cliente_id` int(10) unsigned NOT NULL,
  `fecha` date NOT NULL,
  `cantidad_guias` int(11) NOT NULL,
  `cantidad_kilos` decimal(10,2) DEFAULT '0.00',
  `total_facturado` decimal(14,2) DEFAULT '0.00',
  `created_at` date DEFAULT NULL,
  `updated_at` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `consumo_dia_cliefech_idxu` (`cliente_id`,`fecha`),
  KEY `consumo_dia_cliente_idx` (`cliente_id`),
  CONSTRAINT `consumo_dia_cliente_fk` FOREIGN KEY (`cliente_id`) REFERENCES `master_cliente` (`codi_clie`)
) ENGINE=InnoDB AUTO_INCREMENT=128 DEFAULT CHARSET=latin1;

--
-- Table structure for table `consumo_mes`
--

CREATE TABLE `consumo_mes` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `cliente_id` int(10) unsigned NOT NULL,
  `anio` int(11) NOT NULL,
  `mes` int(11) NOT NULL,
  `cantidad_guias` int(11) NOT NULL,
  `cantidad_kilos` decimal(12,2) DEFAULT '0.00',
  `total_facturado` decimal(16,2) DEFAULT '0.00',
  `created_at` date DEFAULT NULL,
  `updated_at` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `consumo_mes_clieperi_idxu` (`cliente_id`,`anio`,`mes`),
  KEY `consumo_mes_cliente_idx` (`cliente_id`),
  KEY `cmes_anio_mes_idx` (`anio`,`mes`),
  CONSTRAINT `consumo_mes_cliente_fk` FOREIGN KEY (`cliente_id`) REFERENCES `master_cliente` (`codi_clie`)
) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=latin1;

--
-- Table structure for table `contenedor_ckpt`
--

CREATE TABLE `contenedor_ckpt` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `contenedor_id` bigint(20) unsigned NOT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `checkpoint_id` bigint(20) unsigned NOT NULL,
  `fecha` date NOT NULL,
  `hora` char(8) NOT NULL,
  `observacion` text,
  `usuario` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `contenedor_ckpt_FKIndex4` (`usuario`),
  KEY `contenedor_ckpt_sucursal_id_IDX` (`sucursal_id`) USING BTREE,
  KEY `contenedor_ckpt_checkpoint_id_IDX` (`checkpoint_id`) USING BTREE,
  KEY `contenedor_ckpt_FK_2` (`contenedor_id`),
  CONSTRAINT `contenedor_ckpt_FK` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contenedor_ckpt_FK_1` FOREIGN KEY (`checkpoint_id`) REFERENCES `checkpoints` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contenedor_ckpt_FK_2` FOREIGN KEY (`contenedor_id`) REFERENCES `sde_contenedor` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `contenedor_ckpt_ibfk_4` FOREIGN KEY (`usuario`) REFERENCES `usuario` (`codi_usua`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `counter`
--

CREATE TABLE `counter` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(50) NOT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `ruta_id` char(20) NOT NULL,
  `entrega_inmediata` int(10) unsigned DEFAULT NULL,
  `siglas` char(5) DEFAULT NULL,
  `limite_de_paquetes` int(11) DEFAULT NULL,
  `cantidad_de_paquetes` int(11) DEFAULT NULL,
  `ckpt_recepcion` char(2) DEFAULT NULL,
  `ckpt_confirmacion` char(2) DEFAULT NULL,
  `ckpt_almacen` char(2) DEFAULT NULL,
  `pais_id` int(10) unsigned DEFAULT NULL,
  `status_id` int(10) unsigned DEFAULT NULL,
  `direccion` varchar(250) DEFAULT NULL,
  `elegir_servicio` int(10) unsigned DEFAULT NULL,
  `es_ruta` int(10) unsigned DEFAULT NULL,
  `se_factura` int(10) unsigned DEFAULT NULL,
  `permite_pago` int(10) unsigned DEFAULT NULL,
  `email_jefe_almacen` varchar(150) DEFAULT NULL,
  `ckpt_antiguedad1` char(2) DEFAULT NULL,
  `ckpt_antiguedad2` char(2) DEFAULT NULL,
  `ckpt_antiguedad0` char(2) DEFAULT NULL,
  `aliado_comercial_id` int(11) DEFAULT NULL,
  `limite_kilos` decimal(6,2) DEFAULT NULL,
  `depende_de` int(10) unsigned DEFAULT NULL,
  `dom_origen` tinyint(1) unsigned DEFAULT NULL,
  `dom_destino` tinyint(1) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_siglas` (`siglas`),
  KEY `counter_FKIndex1` (`sucursal_id`),
  KEY `counter_FKIndex2` (`ruta_id`),
  KEY `idx_entrega` (`entrega_inmediata`),
  KEY `fk_ckptrece` (`ckpt_recepcion`),
  KEY `fk_ckptconf` (`ckpt_confirmacion`),
  KEY `fk_ckptalma` (`ckpt_almacen`),
  KEY `fk_pais` (`pais_id`),
  KEY `fk_status` (`status_id`),
  KEY `elegir_servicio` (`elegir_servicio`),
  KEY `fk_ruta` (`es_ruta`),
  KEY `fk_sefactura` (`se_factura`),
  KEY `fk_permitepago` (`permite_pago`),
  KEY `ckpt_antiguedad0` (`ckpt_antiguedad0`),
  KEY `counter_aliado_idx` (`aliado_comercial_id`),
  KEY `counter_sucursal_id_IDX` (`sucursal_id`) USING BTREE,
  CONSTRAINT `counter_aliado_fk` FOREIGN KEY (`aliado_comercial_id`) REFERENCES `aliado_comercial` (`id`),
  CONSTRAINT `counter_ibfk_2` FOREIGN KEY (`ruta_id`) REFERENCES `ruta` (`codi_ruta`),
  CONSTRAINT `counter_ibfk_3` FOREIGN KEY (`elegir_servicio`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `counter_sucursal_id_foreign` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_entrega` FOREIGN KEY (`entrega_inmediata`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `fk_permitepago` FOREIGN KEY (`permite_pago`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `fk_ruta` FOREIGN KEY (`es_ruta`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `fk_sefactura` FOREIGN KEY (`se_factura`) REFERENCES `sino_type` (`codi_sino`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `cuenta_bancaria`
--

CREATE TABLE `cuenta_bancaria` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `banco_id` int(10) unsigned NOT NULL,
  `codigo` char(10) NOT NULL,
  `numero` varchar(20) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `fk_cuenta_bancaria_codigo` (`codigo`),
  KEY `fk_cuenta_bancaria_banco1` (`banco_id`),
  CONSTRAINT `fk_cuenta_bancaria_banco1` FOREIGN KEY (`banco_id`) REFERENCES `banco` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 COMMENT='Cuentas bancarias para depositos y transferencias';

--
-- Table structure for table `descuentos`
--

CREATE TABLE `descuentos` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `cliente_id` int(10) unsigned NOT NULL,
  `anio` int(11) NOT NULL,
  `mes` int(11) NOT NULL,
  `descuento` decimal(12,2) NOT NULL,
  `factura` bigint(20) NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `dscto_cam_idxu` (`cliente_id`,`anio`,`mes`),
  KEY `dscto_cliente_idx` (`cliente_id`),
  CONSTRAINT `dscto_cliente_fk` FOREIGN KEY (`cliente_id`) REFERENCES `master_cliente` (`codi_clie`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Table structure for table `destinatario_frecuente`
--

CREATE TABLE `destinatario_frecuente` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `cliente_id` int(10) unsigned NOT NULL,
  `nombre` varchar(100) NOT NULL,
  `direccion` varchar(200) NOT NULL,
  `telefono` varchar(50) NOT NULL,
  `email` varchar(50) DEFAULT NULL,
  `cedula_rif` varchar(20) DEFAULT NULL,
  `persona_contacto` varchar(50) DEFAULT NULL,
  `codigo_postal` varchar(20) DEFAULT NULL,
  `destino_id` bigint(20) unsigned NOT NULL,
  `estado_id` int(11) DEFAULT NULL,
  `municipio_id` int(11) DEFAULT NULL,
  `parroquia_id` int(11) DEFAULT NULL,
  `securbar_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `destinatario_frecuente_FKIndex1` (`cliente_id`),
  KEY `idx_cliedest` (`cliente_id`,`destino_id`),
  KEY `idx_nomb` (`nombre`),
  KEY `destinatario_frecuente_destino_id_IDX` (`destino_id`) USING BTREE,
  CONSTRAINT `destinatario_frecuente_FK` FOREIGN KEY (`destino_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `destinatario_frecuente_ibfk_1` FOREIGN KEY (`cliente_id`) REFERENCES `master_cliente` (`codi_clie`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `detalle_error`
--

CREATE TABLE `detalle_error` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `proceso_id` int(11) NOT NULL COMMENT 'Identificador referencial al proceso a tratar.',
  `referencia` varchar(250) NOT NULL COMMENT 'Numero y/o identificador de referencia del proceso',
  `mensaje_error` text NOT NULL COMMENT 'Mensaje de error.',
  `comentario` varchar(250) DEFAULT NULL COMMENT 'Comentarios y/u observaciones referentes al detalle del proceso de error.',
  PRIMARY KEY (`id`),
  KEY `de_proceso_idx` (`proceso_id`)
) ENGINE=InnoDB AUTO_INCREMENT=136 DEFAULT CHARSET=latin1 COMMENT='Detalles de cada proceso de error generado en el sistema';

--
-- Table structure for table `disponible_type`
--

CREATE TABLE `disponible_type` (
  `codi_disp` int(11) NOT NULL,
  `desc_disp` char(20) NOT NULL,
  PRIMARY KEY (`codi_disp`),
  UNIQUE KEY `idxu_descdisp` (`desc_disp`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `divisa`
--

CREATE TABLE `divisa` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `siglas` char(3) NOT NULL,
  `descripcion` char(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Table structure for table `divisas`
--

CREATE TABLE `divisas` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `codigo` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nombre` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `divisas_codigo_unique` (`codigo`),
  UNIQUE KEY `divisas_nombre_unique` (`nombre`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `dsp_despacho`
--

CREATE TABLE `dsp_despacho` (
  `codi_desp` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `codi_clie` int(10) unsigned NOT NULL,
  `codi_orig` bigint(20) unsigned NOT NULL,
  `codi_dest` bigint(20) unsigned NOT NULL,
  `codi_oper` int(10) unsigned NOT NULL,
  `nomb_clie` varchar(50) NOT NULL,
  `dire_clie` varchar(200) NOT NULL,
  `tele_clie` varchar(50) NOT NULL,
  `fech_regi` datetime NOT NULL,
  `tipo_reco` int(10) unsigned NOT NULL,
  `checkpoint_id` bigint(20) unsigned NOT NULL,
  `fech_reco` date NOT NULL,
  `hora_list` char(5) DEFAULT NULL,
  `hora_desp` char(5) DEFAULT NULL,
  `hora_efec` char(5) DEFAULT NULL,
  `hora_cier` char(5) DEFAULT NULL,
  `nomb_pers` char(50) DEFAULT NULL,
  `text_obse` varchar(350) DEFAULT NULL,
  `fech_modi` date DEFAULT NULL,
  `codi_usua` int(10) unsigned NOT NULL,
  `usua_modi` int(10) unsigned DEFAULT NULL,
  `moti_noco` char(2) DEFAULT NULL,
  `peso_esti` decimal(10,2) NOT NULL COMMENT 'Peso Estimado',
  `cant_bult` int(11) NOT NULL DEFAULT '0',
  `dire_mail` varchar(50) NOT NULL COMMENT 'E-mail',
  `noti_noco` tinyint(1) NOT NULL COMMENT 'Notificar la No Completacion ',
  `hora_regi` char(5) DEFAULT NULL,
  `nomb_dest` char(50) DEFAULT NULL,
  `tele_dest` char(50) DEFAULT NULL,
  `dire_dest` char(250) DEFAULT NULL,
  `cont_envi` char(250) DEFAULT NULL,
  `fech_cier` date DEFAULT NULL,
  `pospuesta` tinyint(1) DEFAULT NULL,
  `usua_cier` int(10) unsigned DEFAULT NULL,
  `usua_desp` int(10) unsigned DEFAULT NULL,
  `fech_desp` date DEFAULT NULL,
  PRIMARY KEY (`codi_desp`),
  KEY `dsp_despacho_FKIndex1` (`codi_oper`),
  KEY `dsp_despacho_FKIndex3` (`codi_usua`),
  KEY `dsp_despacho_FKIndex4` (`usua_modi`),
  KEY `idx_motivo` (`moti_noco`),
  KEY `tipo_reco` (`tipo_reco`),
  KEY `codi_clie` (`codi_clie`),
  KEY `usua_cier` (`usua_cier`),
  KEY `usua_desp` (`usua_desp`),
  KEY `dsp_despacho_codi_orig_IDX` (`codi_orig`) USING BTREE,
  KEY `dsp_despacho_codi_dest_IDX` (`codi_dest`) USING BTREE,
  KEY `dsp_despacho_checkpoint_id_IDX` (`checkpoint_id`) USING BTREE,
  CONSTRAINT `dsp_despacho_FK` FOREIGN KEY (`codi_orig`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `dsp_despacho_FK_1` FOREIGN KEY (`codi_dest`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `dsp_despacho_FK_2` FOREIGN KEY (`checkpoint_id`) REFERENCES `checkpoints` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `dsp_despacho_ibfk_27` FOREIGN KEY (`codi_clie`) REFERENCES `master_cliente` (`codi_clie`),
  CONSTRAINT `dsp_despacho_ibfk_30` FOREIGN KEY (`codi_oper`) REFERENCES `sde_operacion` (`codi_oper`),
  CONSTRAINT `dsp_despacho_ibfk_31` FOREIGN KEY (`tipo_reco`) REFERENCES `dsp_tiporeco_type` (`tipo_reco`),
  CONSTRAINT `dsp_despacho_ibfk_33` FOREIGN KEY (`codi_usua`) REFERENCES `usuario` (`codi_usua`),
  CONSTRAINT `dsp_despacho_ibfk_34` FOREIGN KEY (`usua_modi`) REFERENCES `usuario` (`codi_usua`),
  CONSTRAINT `dsp_despacho_ibfk_35` FOREIGN KEY (`moti_noco`) REFERENCES `dsp_motivo_noco` (`moti_noco`),
  CONSTRAINT `dsp_despacho_ibfk_36` FOREIGN KEY (`usua_cier`) REFERENCES `usuario` (`codi_usua`),
  CONSTRAINT `dsp_despacho_ibfk_37` FOREIGN KEY (`usua_desp`) REFERENCES `usuario` (`codi_usua`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `dsp_motivo_noco`
--

CREATE TABLE `dsp_motivo_noco` (
  `moti_noco` char(2) NOT NULL,
  `desc_moti` varchar(50) NOT NULL,
  PRIMARY KEY (`moti_noco`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `dsp_tiporeco_type`
--

CREATE TABLE `dsp_tiporeco_type` (
  `tipo_reco` int(10) unsigned NOT NULL,
  `desc_tipo` varchar(30) NOT NULL,
  PRIMARY KEY (`tipo_reco`),
  UNIQUE KEY `dsp_tipopick_type_idxu_desctipo` (`desc_tipo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `empresa`
--

CREATE TABLE `empresa` (
  `id` int(11) NOT NULL,
  `nombre` varchar(100) NOT NULL,
  `direccion_fiscal` varchar(250) NOT NULL,
  `telefonos` varchar(100) NOT NULL,
  `email` varchar(100) NOT NULL,
  `persona_contacto` varchar(100) NOT NULL,
  `clave_secreta` varchar(100) NOT NULL,
  `fecha_registro` date NOT NULL,
  `vendedor_id` int(10) unsigned DEFAULT NULL,
  `pais_id` int(10) unsigned DEFAULT NULL,
  `status_id` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `vendedor_id` (`vendedor_id`),
  KEY `pais_id` (`pais_id`),
  KEY `status_id` (`status_id`),
  CONSTRAINT `empresa_ibfk_1` FOREIGN KEY (`vendedor_id`) REFERENCES `fac_vendedor` (`id`),
  CONSTRAINT `empresa_ibfk_2` FOREIGN KEY (`pais_id`) REFERENCES `pais` (`id`),
  CONSTRAINT `empresa_ibfk_3` FOREIGN KEY (`status_id`) REFERENCES `status_type` (`codi_stat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `empresa_courier`
--

CREATE TABLE `empresa_courier` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `nombre` varchar(50) NOT NULL,
  `cantidad_caracteres` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;

--
-- Table structure for table `estacion`
--

CREATE TABLE `estacion` (
  `codi_esta` char(20) NOT NULL,
  `codi_stat` int(10) unsigned NOT NULL,
  `desc_esta` char(50) NOT NULL,
  `nomb_cont` varchar(50) DEFAULT NULL,
  `text_obse` char(200) DEFAULT NULL,
  `dire_mail` varchar(300) NOT NULL,
  `nume_dias` varchar(20) NOT NULL COMMENT 'En cuantos dias llegamos a esta Zona del pais',
  `nume_tele` varchar(50) NOT NULL COMMENT 'Telefono de Contacto',
  `region_id` int(10) unsigned NOT NULL,
  `cuenta_cod` int(10) unsigned DEFAULT NULL,
  `cuenta_cnt` int(10) unsigned DEFAULT NULL,
  `cuenta_com` int(10) unsigned DEFAULT NULL,
  `pais_id` int(10) unsigned DEFAULT NULL,
  `porcentaje_venta` decimal(5,2) DEFAULT NULL COMMENT 'Porcentaje de Comision por Venta',
  `porcentaje_entrega` decimal(5,2) DEFAULT NULL COMMENT 'Porcentaje de Comisión por Entregas',
  `operacion_id` int(10) unsigned DEFAULT NULL,
  `dire_mail_principal` varchar(200) DEFAULT NULL,
  `zona_cod` int(10) unsigned DEFAULT NULL,
  `notificar_recolecta` int(10) unsigned DEFAULT NULL,
  `es_un_almacen` int(11) unsigned DEFAULT NULL,
  `oficina_fisica` int(10) unsigned DEFAULT NULL,
  `area_metropolitana` int(10) unsigned DEFAULT NULL,
  `sucursal_principal` int(10) unsigned DEFAULT NULL,
  `se_factura_en` int(10) unsigned DEFAULT NULL,
  `exenta_de_iva_id` int(10) unsigned DEFAULT NULL,
  `visible_en_registro_id` int(10) unsigned DEFAULT NULL,
  `estado_id` int(11) DEFAULT NULL,
  `zonas_nc` text,
  `frecuencia_de_cobertura` varchar(45) DEFAULT NULL,
  `palabra_relacionada` text COMMENT 'Palabra o nombre relacionado a una sucursal',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`codi_esta`),
  UNIQUE KEY `idx_nombre` (`desc_esta`),
  KEY `estacion_FKIndex1` (`codi_stat`),
  KEY `region_id` (`region_id`),
  KEY `pais_id` (`pais_id`),
  KEY `idx_operacion` (`operacion_id`),
  KEY `idx_zonacod` (`zona_cod`),
  KEY `idx_notificar` (`notificar_recolecta`),
  KEY `fk_zonacod` (`zona_cod`),
  KEY `fk_notificar` (`notificar_recolecta`),
  KEY `es_un_almacen` (`es_un_almacen`),
  KEY `fk_oficfisi` (`oficina_fisica`),
  KEY `area_metropolitana` (`area_metropolitana`),
  KEY `sucursal_principal` (`sucursal_principal`),
  KEY `fk_sefacturaen` (`se_factura_en`),
  KEY `fk_exenta` (`exenta_de_iva_id`),
  KEY `fk_visible` (`visible_en_registro_id`),
  KEY `esta_edox_idx` (`estado_id`),
  CONSTRAINT `esta_edox_fk` FOREIGN KEY (`estado_id`) REFERENCES `estado` (`id`),
  CONSTRAINT `estacion_ibfk_3` FOREIGN KEY (`codi_stat`) REFERENCES `status_type` (`codi_stat`),
  CONSTRAINT `estacion_ibfk_4` FOREIGN KEY (`region_id`) REFERENCES `region` (`id`),
  CONSTRAINT `estacion_ibfk_5` FOREIGN KEY (`pais_id`) REFERENCES `pais` (`id`),
  CONSTRAINT `estacion_ibfk_6` FOREIGN KEY (`es_un_almacen`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `estacion_ibfk_7` FOREIGN KEY (`area_metropolitana`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `estacion_ibfk_8` FOREIGN KEY (`sucursal_principal`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `fk_exenta` FOREIGN KEY (`exenta_de_iva_id`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `fk_notificar` FOREIGN KEY (`notificar_recolecta`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `fk_oficfisi` FOREIGN KEY (`oficina_fisica`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `fk_operacion` FOREIGN KEY (`operacion_id`) REFERENCES `sde_operacion` (`codi_oper`),
  CONSTRAINT `fk_sefacturaen` FOREIGN KEY (`se_factura_en`) REFERENCES `counter` (`id`),
  CONSTRAINT `fk_visible` FOREIGN KEY (`visible_en_registro_id`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `fk_zonacod` FOREIGN KEY (`zona_cod`) REFERENCES `sino_type` (`codi_sino`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `estadistica`
--

CREATE TABLE `estadistica` (
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `fecha` date NOT NULL,
  `medicion` char(20) NOT NULL,
  `cifra` float(8,2) NOT NULL,
  PRIMARY KEY (`sucursal_id`,`fecha`,`medicion`),
  KEY `idx_fecha` (`fecha`),
  KEY `estadistica_sucursal_id_IDX` (`sucursal_id`) USING BTREE,
  CONSTRAINT `estadistica_FK` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `estadistica_de_clientes`
--

CREATE TABLE `estadistica_de_clientes` (
  `cliente_id` int(10) unsigned NOT NULL,
  `fecha_primera_guia` date DEFAULT NULL,
  `fecha_ultima_guia` date DEFAULT NULL,
  `peso_total` decimal(10,2) DEFAULT NULL,
  `cantidad_guias` int(11) DEFAULT NULL,
  `venta_total` decimal(12,2) DEFAULT NULL,
  `dias_abandono` int(11) DEFAULT NULL,
  UNIQUE KEY `cliente_id` (`cliente_id`),
  CONSTRAINT `edc_cliente_foreign` FOREIGN KEY (`cliente_id`) REFERENCES `master_cliente` (`codi_clie`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `estadistica_de_guias`
--

CREATE TABLE `estadistica_de_guias` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `guia_id` bigint(20) unsigned NOT NULL,
  `fecha_guia` date NOT NULL,
  `fecha_pickup` date DEFAULT NULL,
  `dias_pickup` smallint(6) DEFAULT NULL,
  `fecha_traslado` date DEFAULT NULL,
  `dias_traslado` smallint(6) DEFAULT NULL,
  `acumulado_traslado` smallint(6) DEFAULT NULL,
  `fecha_arribo` date DEFAULT NULL,
  `dias_arribo` smallint(6) DEFAULT NULL,
  `acumulado_arribo` smallint(6) DEFAULT NULL,
  `fecha_ruta` date DEFAULT NULL,
  `dias_ruta` smallint(6) DEFAULT NULL,
  `acumulado_ruta` smallint(6) DEFAULT NULL,
  `fecha_entrega` date DEFAULT NULL,
  `dias_entrega` smallint(6) DEFAULT NULL,
  `acumulado_entrega` smallint(6) DEFAULT NULL,
  `acumulado_sin_entrega` smallint(6) DEFAULT NULL,
  `dias_sin_actualizar` smallint(6) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `estadistica_de_guias_FK` (`guia_id`),
  CONSTRAINT `estadistica_de_guias_FK` FOREIGN KEY (`guia_id`) REFERENCES `guias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `estadisticas`
--

CREATE TABLE `estadisticas` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `sucursal_id` char(20) NOT NULL,
  `fecha` date NOT NULL,
  `medicion` char(20) NOT NULL,
  `cifra` float(8,2) NOT NULL,
  `created_at` date DEFAULT NULL,
  `updated_at` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `sucu_fech_medi_idxu` (`sucursal_id`,`fecha`,`medicion`),
  KEY `estadisticas_sucursal` (`sucursal_id`),
  KEY `estadisticas_fecha_idx` (`fecha`),
  CONSTRAINT `estadisticas_sucursal_fk` FOREIGN KEY (`sucursal_id`) REFERENCES `estacion` (`codi_esta`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Table structure for table `estado`
--

CREATE TABLE `estado` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(45) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=184 DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_categoria_prod`
--

CREATE TABLE `fac_categoria_prod` (
  `codi_cate` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `desc_cate` varchar(200) NOT NULL,
  `fran_post` decimal(6,2) NOT NULL,
  PRIMARY KEY (`codi_cate`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_cortfact_type`
--

CREATE TABLE `fac_cortfact_type` (
  `tipo_cort` int(10) unsigned NOT NULL,
  `desc_cort` varchar(30) NOT NULL,
  PRIMARY KEY (`tipo_cort`),
  UNIQUE KEY `fac_cortfact_type_idxu_desccort` (`desc_cort`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_impuesto`
--

CREATE TABLE `fac_impuesto` (
  `sigl_impu` char(10) NOT NULL,
  `fech_vige` date NOT NULL,
  `mont_impu` double NOT NULL,
  PRIMARY KEY (`sigl_impu`,`fech_vige`),
  KEY `idx_sigl` (`sigl_impu`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_medida_type`
--

CREATE TABLE `fac_medida_type` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_desc` (`descripcion`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_producto`
--

CREATE TABLE `fac_producto` (
  `codi_prod` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `sigl_prod` char(10) NOT NULL,
  `desc_prod` varchar(50) NOT NULL,
  `tipo_prod` char(3) NOT NULL,
  `codi_cate` int(10) unsigned NOT NULL,
  `codi_stat` int(10) unsigned NOT NULL,
  `text_obse` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`codi_prod`),
  UNIQUE KEY `idxu_siglprod` (`sigl_prod`),
  KEY `producto_FKIndex1` (`codi_stat`),
  KEY `idx_tipoprod` (`tipo_prod`),
  KEY `idx_codicate` (`codi_cate`),
  CONSTRAINT `fac_producto_ibfk_1` FOREIGN KEY (`tipo_prod`) REFERENCES `fac_tipo_prod` (`tipo_prod`),
  CONSTRAINT `fac_producto_ibfk_2` FOREIGN KEY (`codi_cate`) REFERENCES `fac_categoria_prod` (`codi_cate`),
  CONSTRAINT `fac_producto_ibfk_3` FOREIGN KEY (`codi_stat`) REFERENCES `fac_statregi_type` (`codi_stat`)
) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_statregi_type`
--

CREATE TABLE `fac_statregi_type` (
  `codi_stat` int(10) unsigned NOT NULL,
  `desc_stat` char(15) NOT NULL,
  PRIMARY KEY (`codi_stat`),
  UNIQUE KEY `fact_stat_type_idxu_descstat` (`desc_stat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_tarifa`
--

CREATE TABLE `fac_tarifa` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(50) NOT NULL,
  `tipo_tarifa` int(10) unsigned NOT NULL,
  `peso_inicial` decimal(10,2) NOT NULL DEFAULT '0.00',
  `valor_incremento` decimal(10,2) NOT NULL DEFAULT '0.00',
  `medida_incremento` int(10) unsigned NOT NULL,
  `porcentaje_sobre_valor` decimal(5,2) NOT NULL DEFAULT '0.00',
  `volumen_para_dscto` int(10) unsigned NOT NULL DEFAULT '0',
  `dscto_por_volumen` decimal(5,2) NOT NULL DEFAULT '0.00',
  `peso_para_dscto` decimal(10,2) NOT NULL DEFAULT '0.00',
  `dscto_por_peso` decimal(5,2) NOT NULL DEFAULT '0.00',
  `monto_minimo` float(10,2) NOT NULL DEFAULT '0.00',
  `costo_parada_adicional` float(10,2) NOT NULL DEFAULT '0.00',
  `costo_ayudante` float(10,2) NOT NULL DEFAULT '0.00',
  `incremento_urbano` decimal(10,2) NOT NULL DEFAULT '0.00',
  `peso_inicial_urbano` decimal(10,2) NOT NULL,
  `tasa_iva` decimal(5,2) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_desctari` (`descripcion`),
  KEY `fac_tarifa_FKIndex1` (`tipo_tarifa`),
  CONSTRAINT `fac_tarifa_ibfk_1` FOREIGN KEY (`tipo_tarifa`) REFERENCES `fac_tipo_tarifa_type` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_tarifa_peso`
--

CREATE TABLE `fac_tarifa_peso` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `tarifa_id` int(10) unsigned NOT NULL,
  `codi_prod` int(10) unsigned NOT NULL,
  `origen` char(20) NOT NULL,
  `destino` char(20) NOT NULL,
  `peso_inicial` decimal(10,3) NOT NULL,
  `peso_final` decimal(10,3) NOT NULL,
  `monto_tarifa` decimal(10,2) NOT NULL,
  `franqueo_postal` decimal(10,2) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_pk` (`tarifa_id`,`codi_prod`,`origen`,`destino`,`peso_inicial`,`peso_final`),
  KEY `fac_bandas_FKIndex1` (`codi_prod`),
  KEY `fac_tarifa_peso_FKIndex2` (`destino`),
  KEY `fac_tarifa_peso_FKIndex3` (`origen`),
  KEY `fac_tarifa_peso_FKIndex4` (`tarifa_id`),
  KEY `idx_otro` (`tarifa_id`,`codi_prod`,`origen`,`destino`),
  CONSTRAINT `fac_tarifa_peso_ibfk_11` FOREIGN KEY (`tarifa_id`) REFERENCES `fac_tarifa` (`id`),
  CONSTRAINT `fac_tarifa_peso_ibfk_12` FOREIGN KEY (`codi_prod`) REFERENCES `fac_producto` (`codi_prod`),
  CONSTRAINT `fac_tarifa_peso_ibfk_13` FOREIGN KEY (`origen`) REFERENCES `estacion` (`codi_esta`),
  CONSTRAINT `fac_tarifa_peso_ibfk_14` FOREIGN KEY (`destino`) REFERENCES `estacion` (`codi_esta`)
) ENGINE=InnoDB AUTO_INCREMENT=25710 DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_tarifa_prod`
--

CREATE TABLE `fac_tarifa_prod` (
  `codi_tari` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `codi_clie` int(10) unsigned NOT NULL,
  `codi_prod` int(10) unsigned NOT NULL,
  `mont_base` double NOT NULL,
  `form_conc` varchar(100) NOT NULL,
  `tipo_oper` int(10) unsigned NOT NULL,
  `orde_impr` int(10) unsigned NOT NULL,
  `etiq_fact` varchar(100) NOT NULL,
  PRIMARY KEY (`codi_tari`,`codi_clie`,`codi_prod`),
  KEY `fac_tarifa_prod_idx_ordeimpr` (`orde_impr`),
  KEY `fac_tarifa_prod_FKIndex2` (`codi_prod`),
  KEY `fac_tarifa_prod_FKIndex3` (`codi_clie`),
  KEY `fac_tarifa_prod_FKIndex4` (`tipo_oper`),
  KEY `idx_clieprod` (`codi_clie`,`codi_prod`),
  CONSTRAINT `fac_tarifa_prod_ibfk_1` FOREIGN KEY (`codi_prod`) REFERENCES `fac_producto` (`codi_prod`),
  CONSTRAINT `fac_tarifa_prod_ibfk_2` FOREIGN KEY (`codi_clie`) REFERENCES `master_cliente` (`codi_clie`),
  CONSTRAINT `fac_tarifa_prod_ibfk_3` FOREIGN KEY (`tipo_oper`) REFERENCES `fac_tipooper_type` (`tipo_oper`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_tipo_prod`
--

CREATE TABLE `fac_tipo_prod` (
  `tipo_prod` char(3) NOT NULL,
  `desc_tpro` varchar(50) NOT NULL,
  `nomb_meto` varchar(50) NOT NULL,
  PRIMARY KEY (`tipo_prod`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_tipo_tarifa_type`
--

CREATE TABLE `fac_tipo_tarifa_type` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_desc` (`descripcion`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_tipooper_type`
--

CREATE TABLE `fac_tipooper_type` (
  `tipo_oper` int(10) unsigned NOT NULL,
  `desc_oper` varchar(30) NOT NULL,
  PRIMARY KEY (`tipo_oper`),
  UNIQUE KEY `fac_tipooper_type_idxu_descoper` (`desc_oper`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fac_vendedor`
--

CREATE TABLE `fac_vendedor` (
  `id` int(10) unsigned NOT NULL,
  `nombre` varchar(80) NOT NULL,
  `cedula` varchar(10) NOT NULL,
  `direccion_email` varchar(80) NOT NULL,
  `porcentaje_comision` decimal(5,2) NOT NULL,
  `status_id` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `status_id` (`status_id`),
  CONSTRAINT `fac_vendedor_ibfk_2` FOREIGN KEY (`status_id`) REFERENCES `status_type` (`codi_stat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `factura`
--

CREATE TABLE `factura` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `codi_clie` int(10) unsigned DEFAULT NULL,
  `cliente_id` int(11) DEFAULT NULL,
  `razon_social` varchar(100) DEFAULT NULL,
  `direccion` varchar(200) DEFAULT NULL,
  `telefono` varchar(45) DEFAULT NULL,
  `fecha` date NOT NULL,
  `serie` char(2) DEFAULT NULL,
  `control_seniat` int(10) unsigned DEFAULT NULL,
  `monto_base` double NOT NULL,
  `monto_franqueo` double DEFAULT NULL,
  `porcentaje_iva` double NOT NULL,
  `monto_iva` double NOT NULL,
  `monto_seguro` double NOT NULL DEFAULT '0',
  `monto_otros` double NOT NULL DEFAULT '0',
  `monto_aduana` double DEFAULT NULL,
  `monto_total` double DEFAULT NULL,
  `caja_id` int(10) unsigned NOT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `usuario_creacion` int(10) unsigned NOT NULL,
  `status_id` int(10) unsigned NOT NULL,
  `control_id` int(10) unsigned DEFAULT NULL,
  `usuario_anulacion` int(10) unsigned DEFAULT NULL,
  `motivo_anulacion` varchar(200) DEFAULT NULL,
  `fecha_anulacion` date DEFAULT NULL,
  `fecha_trans` date DEFAULT NULL,
  `hora_trans` char(5) DEFAULT NULL,
  `tipo_documento_id` char(1) NOT NULL,
  `cedula_rif` varchar(20) DEFAULT NULL,
  `numero` int(10) unsigned DEFAULT NULL,
  `numero_de_guias` int(11) DEFAULT NULL,
  `dscto_por_volumen` decimal(5,2) DEFAULT '0.00',
  `monto_dscto_volumen` decimal(10,2) DEFAULT '0.00',
  `peso_total` decimal(10,2) DEFAULT NULL,
  `dscto_por_peso` decimal(5,2) DEFAULT '0.00',
  `monto_dscto_peso` decimal(10,2) DEFAULT '0.00',
  `ticket_fiscal` int(11) DEFAULT NULL,
  `persona_autorizada` varchar(100) DEFAULT NULL,
  `impresa` int(10) unsigned DEFAULT NULL,
  `sistema_id` char(3) DEFAULT NULL,
  `direccion_entrega` varchar(250) DEFAULT NULL,
  `tipo_impresora` enum('L','F') DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_serifact` (`serie`,`numero`),
  KEY `fac_factura_FKIndex1` (`cliente_id`),
  KEY `idx_fechanul` (`fecha_anulacion`),
  KEY `factura_FKIndex3` (`usuario_creacion`),
  KEY `factura_FKIndex4` (`usuario_anulacion`),
  KEY `factura_FKIndex6` (`caja_id`),
  KEY `factura_FKIndex7` (`control_id`),
  KEY `factura_FKIndex9` (`status_id`),
  KEY `idx_cedularif` (`cedula_rif`),
  KEY `idx_numero` (`numero`),
  KEY `factura_FKIndex8` (`tipo_documento_id`),
  KEY `idx_impresa` (`impresa`),
  KEY `fk_sistema` (`sistema_id`),
  KEY `fk_mastercliente` (`codi_clie`),
  KEY `factura_sucursal_id_IDX` (`sucursal_id`) USING BTREE,
  CONSTRAINT `factura_FK` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `factura_ibfk_2` FOREIGN KEY (`status_id`) REFERENCES `status_fact_type` (`id`),
  CONSTRAINT `factura_ibfk_3` FOREIGN KEY (`usuario_creacion`) REFERENCES `usuario` (`codi_usua`),
  CONSTRAINT `factura_ibfk_4` FOREIGN KEY (`usuario_anulacion`) REFERENCES `usuario` (`codi_usua`),
  CONSTRAINT `factura_ibfk_6` FOREIGN KEY (`caja_id`) REFERENCES `caja` (`id`),
  CONSTRAINT `factura_ibfk_8` FOREIGN KEY (`tipo_documento_id`) REFERENCES `tipo_documento` (`id`),
  CONSTRAINT `fk_impresa` FOREIGN KEY (`impresa`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `fk_mastercliente` FOREIGN KEY (`codi_clie`) REFERENCES `master_cliente` (`codi_clie`),
  CONSTRAINT `fk_sistema` FOREIGN KEY (`sistema_id`) REFERENCES `sistema` (`codi_sist`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='InnoDB free: 13312 kB; (`cliente_id`) REFER `liberty/master_';

--
-- Table structure for table `factura_pmn`
--

CREATE TABLE `factura_pmn` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `cedula_rif` varchar(20) NOT NULL,
  `razon_social` varchar(100) NOT NULL,
  `direccion_fiscal` varchar(300) NOT NULL,
  `telefono` varchar(50) NOT NULL,
  `numero` varchar(20) DEFAULT NULL,
  `maquina_fiscal` varchar(20) DEFAULT NULL,
  `fecha_impresion` char(6) DEFAULT NULL,
  `hora_impresion` char(6) DEFAULT NULL,
  `monto_base` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_franqueo` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_iva` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_seguro` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_otros` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_total` decimal(13,2) NOT NULL DEFAULT '0.00',
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `receptoria_id` char(3) NOT NULL,
  `caja_id` int(10) unsigned NOT NULL,
  `creada_por` int(10) unsigned NOT NULL,
  `creada_el` date NOT NULL,
  `estatus` char(1) NOT NULL,
  `impresa_id` int(10) unsigned NOT NULL,
  `anulada_por` int(10) unsigned DEFAULT NULL,
  `anulada_el` date DEFAULT NULL,
  `motivo_anulacion` varchar(50) DEFAULT NULL,
  `porcentaje_rete_iva` decimal(5,2) DEFAULT '0.00',
  `monto_rete_iva` decimal(10,2) DEFAULT '0.00',
  `porcentaje_rete_islr` decimal(5,2) DEFAULT '0.00',
  `monto_rete_islr` decimal(10,2) DEFAULT '0.00',
  `monto_dscto` decimal(10,2) DEFAULT '0.00',
  `monto_cobrado` decimal(10,2) DEFAULT '0.00',
  `comprobante_retencion` varchar(20) DEFAULT NULL,
  `fecha_comprobante` date DEFAULT NULL,
  `comprobante_retencion_islr` varchar(45) DEFAULT NULL,
  `fecha_comprobante_islr` date DEFAULT NULL,
  `tiene_retencion` int(10) unsigned DEFAULT NULL,
  `forma_pago_id` int(10) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fpmn_cedu_idx` (`cedula_rif`),
  KEY `fpmn_rece_idx` (`receptoria_id`),
  KEY `fpmn_caja_idx` (`caja_id`),
  KEY `fpmn_crea_idx` (`creada_por`),
  KEY `fpmn_esta_idx` (`estatus`),
  KEY `fpmn_impr_idx` (`impresa_id`),
  KEY `fpmn_anul_idx` (`anulada_por`),
  KEY `fact_rete_idx` (`tiene_retencion`),
  KEY `fpmn_nume_idx` (`numero`),
  KEY `fpmn_fpag_idx` (`forma_pago_id`),
  KEY `factura_pmn_sucursal_id_IDX` (`sucursal_id`) USING BTREE,
  CONSTRAINT `factura_pmn_sucursal_id_foreign` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fpmn_anul_fk` FOREIGN KEY (`anulada_por`) REFERENCES `usuario` (`codi_usua`),
  CONSTRAINT `fpmn_caja_fk` FOREIGN KEY (`caja_id`) REFERENCES `caja` (`id`),
  CONSTRAINT `fpmn_crea_fk` FOREIGN KEY (`creada_por`) REFERENCES `usuario` (`codi_usua`),
  CONSTRAINT `fpmn_impr_fk` FOREIGN KEY (`impresa_id`) REFERENCES `sino_type` (`codi_sino`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `fecha_ultima_guia`
--

CREATE TABLE `fecha_ultima_guia` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `cliente_id` int(10) unsigned NOT NULL,
  `fecha_ultima_guia` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `cliente_id` (`cliente_id`),
  CONSTRAINT `fug_cliente_foreign` FOREIGN KEY (`cliente_id`) REFERENCES `master_cliente` (`codi_clie`)
) ENGINE=InnoDB AUTO_INCREMENT=3634 DEFAULT CHARSET=latin1;

--
-- Table structure for table `feriado`
--

CREATE TABLE `feriado` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fecha` date NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_fecha` (`fecha`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=latin1;

--
-- Table structure for table `forma_pago`
--

CREATE TABLE `forma_pago` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(50) NOT NULL,
  `status_id` int(10) unsigned NOT NULL,
  `requiere_documento` int(10) unsigned NOT NULL,
  `texto_documento` varchar(80) DEFAULT NULL,
  `requiere_cuenta` int(10) unsigned DEFAULT NULL,
  `abreviado` varchar(5) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `forma_pago_FKIndex1` (`status_id`),
  KEY `forma_pago_FKIndex2` (`requiere_documento`),
  KEY `fk_cuenta` (`requiere_cuenta`),
  CONSTRAINT `fk_cuenta` FOREIGN KEY (`requiere_cuenta`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `forma_pago_ibfk_1` FOREIGN KEY (`status_id`) REFERENCES `status_type` (`codi_stat`),
  CONSTRAINT `forma_pago_ibfk_2` FOREIGN KEY (`requiere_documento`) REFERENCES `sino_type` (`codi_sino`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;

--
-- Table structure for table `grupo`
--

CREATE TABLE `grupo` (
  `codi_grup` int(10) unsigned NOT NULL,
  `desc_grup` char(50) NOT NULL,
  `codi_stat` int(10) unsigned NOT NULL,
  `text_obse` char(200) DEFAULT NULL,
  PRIMARY KEY (`codi_grup`),
  KEY `grupo_FKIndex1` (`codi_stat`),
  CONSTRAINT `grupo_ibfk_1` FOREIGN KEY (`codi_stat`) REFERENCES `status_type` (`codi_stat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `guia`
--

CREATE TABLE `guia` (
  `nume_guia` char(20) NOT NULL,
  `codi_clie` int(10) unsigned NOT NULL,
  `cliente_id` int(11) DEFAULT NULL,
  `fech_guia` date NOT NULL,
  `esta_orig` char(20) NOT NULL,
  `esta_dest` char(20) NOT NULL,
  `peso_guia` double NOT NULL,
  `nomb_remi` char(100) NOT NULL,
  `dire_remi` char(200) NOT NULL,
  `tele_remi` char(50) NOT NULL,
  `nomb_dest` char(100) NOT NULL,
  `dire_dest` varchar(300) NOT NULL,
  `tele_dest` char(50) NOT NULL,
  `cant_piez` int(10) unsigned NOT NULL,
  `desc_cont` text NOT NULL,
  `codi_prod` int(10) unsigned NOT NULL,
  `tipo_guia` int(10) unsigned NOT NULL,
  `valor_declarado` decimal(10,2) NOT NULL,
  `porcentaje_iva` decimal(5,2) NOT NULL,
  `monto_iva` decimal(10,2) NOT NULL,
  `porcentaje_gas` decimal(5,2) DEFAULT NULL,
  `monto_gas` decimal(10,2) DEFAULT NULL,
  `asegurado` tinyint(1) DEFAULT NULL,
  `porcentaje_seguro` decimal(5,2) NOT NULL,
  `porcentaje_dscto` decimal(5,2) DEFAULT NULL,
  `monto_seguro` decimal(10,2) NOT NULL,
  `monto_base` decimal(12,2) NOT NULL,
  `monto_franqueo` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_dscto` decimal(12,2) DEFAULT NULL,
  `monto_otros` decimal(10,2) DEFAULT '0.00',
  `monto_total` decimal(12,2) NOT NULL,
  `considerar_dscto` tinyint(1) DEFAULT NULL,
  `entregado_a` varchar(50) DEFAULT NULL,
  `fecha_entrega` date DEFAULT NULL,
  `hora_entrega` char(5) DEFAULT NULL,
  `codi_ckpt` char(2) DEFAULT NULL,
  `esta_ckpt` varchar(20) DEFAULT NULL,
  `fech_ckpt` date DEFAULT NULL,
  `hora_ckpt` char(8) DEFAULT NULL,
  `obse_ckpt` varchar(100) DEFAULT NULL,
  `usua_ckpt` int(10) unsigned DEFAULT NULL,
  `fecha_pod` date DEFAULT NULL,
  `hora_pod` char(5) DEFAULT NULL,
  `usuario_pod` int(11) DEFAULT NULL,
  `cant_ayudantes` int(11) DEFAULT '0',
  `paradas_adicionales` int(11) DEFAULT '0',
  `courier_id` int(10) unsigned NOT NULL,
  `guia_externa` varchar(50) DEFAULT NULL,
  `flete_directo` tinyint(1) NOT NULL DEFAULT '0',
  `tiene_guia_retorno` tinyint(1) DEFAULT NULL,
  `guia_retorno` varchar(20) DEFAULT NULL,
  `observacion` varchar(200) DEFAULT NULL,
  `alto` float(10,2) DEFAULT '0.00',
  `ancho` float(10,2) DEFAULT '0.00',
  `largo` float(10,2) DEFAULT '0.00',
  `operacion_id` int(10) unsigned NOT NULL,
  `monto_base_int` decimal(10,2) DEFAULT '0.00',
  `porcentaje_sgro_int` float(5,2) DEFAULT '0.00',
  `monto_sgro_int` float(10,2) DEFAULT '0.00',
  `monto_total_int` float(10,2) DEFAULT '0.00',
  `total_int_local` decimal(10,2) DEFAULT '0.00',
  `peso_volumetrico` float(10,3) DEFAULT '0.000',
  `peso_libras` float(10,2) DEFAULT '0.00',
  `trans_fac` int(10) unsigned NOT NULL DEFAULT '0',
  `hoja_entrega` char(14) DEFAULT NULL,
  `usuario_creacion` varchar(20) DEFAULT NULL,
  `fecha_creacion` date DEFAULT NULL,
  `hora_creacion` char(5) DEFAULT NULL,
  `sistema_id` char(5) DEFAULT NULL,
  `recolecta_id` int(10) unsigned DEFAULT NULL,
  `tipo_documento_id` char(1) DEFAULT NULL,
  `cedula_rif` varchar(20) DEFAULT NULL,
  `cierre_caja` int(11) DEFAULT NULL,
  `caja_id` int(10) unsigned DEFAULT NULL,
  `anulada` int(10) unsigned NOT NULL DEFAULT '0',
  `producto_id` int(10) unsigned DEFAULT NULL,
  `tasa_dolar` decimal(10,2) DEFAULT NULL,
  `vol_maritimo_pies` decimal(10,3) DEFAULT '0.000',
  `vol_maritimo_mts` decimal(10,3) DEFAULT '0.000',
  `descripcion_gral` varchar(45) DEFAULT NULL,
  `ubicacion` char(20) DEFAULT NULL,
  `promocion_id` int(11) DEFAULT NULL,
  `excepcion_impuesto` int(10) unsigned DEFAULT NULL,
  `airport_import_fee` decimal(10,2) DEFAULT '0.00',
  `servicios_dga` decimal(10,2) DEFAULT '0.00',
  `proveedor_id` int(11) DEFAULT NULL,
  `vendedor_id` int(10) unsigned DEFAULT NULL,
  `estado_id` int(11) DEFAULT NULL,
  `municipio_id` int(11) DEFAULT NULL,
  `parroquia_id` int(11) DEFAULT NULL,
  `securbar_id` int(11) DEFAULT NULL,
  `receptoria_origen` char(3) DEFAULT NULL,
  `receptoria_destino` char(3) DEFAULT NULL,
  `factura_id` int(10) DEFAULT NULL,
  `cedula_destinatario` varchar(20) DEFAULT NULL,
  `tarifa_id` int(10) unsigned DEFAULT NULL,
  `en_efectivo` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`nume_guia`),
  KEY `guia_FKIndex1` (`esta_orig`),
  KEY `guia_FKIndex2` (`esta_dest`),
  KEY `sde_guia_FKIndex4` (`codi_clie`),
  KEY `guia_FKIndex4` (`tipo_guia`),
  KEY `codi_prod` (`codi_prod`),
  KEY `idx_codickpt` (`codi_ckpt`),
  KEY `idx_estackpt` (`esta_ckpt`),
  KEY `idx_usuackpt` (`usua_ckpt`),
  KEY `courier_id` (`courier_id`),
  KEY `flete_directo` (`flete_directo`,`tiene_guia_retorno`,`guia_retorno`),
  KEY `operacion_id` (`operacion_id`),
  KEY `idx_transfac` (`trans_fac`),
  KEY `hoja_entrega` (`hoja_entrega`),
  KEY `idx_fechusua` (`usuario_creacion`,`fecha_creacion`),
  KEY `idx_sistema` (`sistema_id`),
  KEY `recolecta_id` (`recolecta_id`),
  KEY `idx_tipodocu` (`tipo_documento_id`),
  KEY `idx_caja` (`caja_id`),
  KEY `producto_id` (`producto_id`),
  KEY `cliente_id` (`cliente_id`),
  KEY `idx_guiainte` (`guia_externa`),
  KEY `idx_promo` (`promocion_id`),
  KEY `idx_excepcion` (`excepcion_impuesto`),
  KEY `idx_fechapod` (`fecha_pod`),
  KEY `idx_fecha` (`fech_guia`),
  KEY `vendedor_id` (`vendedor_id`),
  KEY `guia_fact_idx` (`factura_id`),
  KEY `guia_cedufact_idx` (`cedula_rif`,`factura_id`),
  KEY `guia_tarifa_idx` (`tarifa_id`) USING BTREE,
  CONSTRAINT `guia_ibfk_126` FOREIGN KEY (`codi_clie`) REFERENCES `master_cliente` (`codi_clie`),
  CONSTRAINT `guia_ibfk_128` FOREIGN KEY (`esta_orig`) REFERENCES `estacion` (`codi_esta`),
  CONSTRAINT `guia_ibfk_129` FOREIGN KEY (`esta_dest`) REFERENCES `estacion` (`codi_esta`),
  CONSTRAINT `guia_ibfk_130` FOREIGN KEY (`codi_prod`) REFERENCES `fac_producto` (`codi_prod`),
  CONSTRAINT `guia_ibfk_131` FOREIGN KEY (`tipo_guia`) REFERENCES `tipo_guia_type` (`id`),
  CONSTRAINT `guia_ibfk_134` FOREIGN KEY (`trans_fac`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `guia_ibfk_136` FOREIGN KEY (`recolecta_id`) REFERENCES `dsp_despacho` (`codi_desp`),
  CONSTRAINT `guia_ibfk_139` FOREIGN KEY (`producto_id`) REFERENCES `fac_producto` (`codi_prod`),
  CONSTRAINT `guia_ibfk_140` FOREIGN KEY (`excepcion_impuesto`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `guia_ibfk_141` FOREIGN KEY (`vendedor_id`) REFERENCES `fac_vendedor` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `guia_ckpt`
--

CREATE TABLE `guia_ckpt` (
  `nume_guia` char(20) NOT NULL,
  `codi_esta` char(20) NOT NULL,
  `codi_ckpt` char(2) NOT NULL,
  `fech_ckpt` date NOT NULL,
  `hora_ckpt` char(8) NOT NULL,
  `text_obse` char(100) DEFAULT NULL,
  `codi_ruta` char(20) NOT NULL,
  `codi_usua` int(10) unsigned NOT NULL,
  PRIMARY KEY (`nume_guia`,`codi_esta`,`codi_ckpt`,`fech_ckpt`,`hora_ckpt`),
  KEY `guia_ckpt_FKIndex2` (`codi_esta`),
  KEY `guia_ckpt_FKIndex3` (`codi_ckpt`),
  KEY `guia_ckpt_FKIndex5` (`codi_ruta`),
  KEY `guia_ckpt_FKIndex6` (`codi_usua`),
  KEY `sde_guia_ckpt_FKIndex6` (`nume_guia`),
  KEY `idx_fecha` (`fech_ckpt`),
  CONSTRAINT `guia_ckpt_guia_fk` FOREIGN KEY (`nume_guia`) REFERENCES `guia` (`nume_guia`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `guia_ckpt_ibfk_12` FOREIGN KEY (`codi_esta`) REFERENCES `estacion` (`codi_esta`),
  CONSTRAINT `guia_ckpt_ibfk_13` FOREIGN KEY (`codi_ckpt`) REFERENCES `sde_checkpoint` (`codi_ckpt`),
  CONSTRAINT `guia_ckpt_ibfk_14` FOREIGN KEY (`codi_usua`) REFERENCES `usuario` (`codi_usua`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `tr_inse_ulti_cktp` AFTER INSERT ON `guia_ckpt` FOR EACH ROW call sp_inserta_ckpt(NEW.nume_guia,NEW.codi_esta,NEW.codi_ckpt,NEW.fech_ckpt,NEW.hora_ckpt,NEW.text_obse,NEW.codi_ruta,NEW.codi_usua) */;;
DELIMITER ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `tr_dele_ulti_cktp` AFTER DELETE ON `guia_ckpt` FOR EACH ROW call sp_borra_ckpt(OLD.nume_guia,OLD.codi_esta,OLD.codi_ckpt,OLD.fech_ckpt,OLD.hora_ckpt) */;;
DELIMITER ;

--
-- Table structure for table `guia_conceptos`
--

CREATE TABLE `guia_conceptos` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `guia_id` bigint(20) unsigned NOT NULL,
  `concepto_id` bigint(20) unsigned NOT NULL,
  `tipo` enum('CANT','PORC') COLLATE utf8mb4_unicode_ci NOT NULL,
  `valor` decimal(12,2) NOT NULL,
  `monto` decimal(14,2) NOT NULL,
  `explicacion` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `guia_conceptos_guia_id_foreign` (`guia_id`),
  KEY `guia_conceptos_concepto_id_foreign` (`concepto_id`),
  CONSTRAINT `guia_conceptos_concepto_id_foreign` FOREIGN KEY (`concepto_id`) REFERENCES `conceptos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `guia_conceptos_guia_id_foreign` FOREIGN KEY (`guia_id`) REFERENCES `guias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `guia_consecutivo`
--

CREATE TABLE `guia_consecutivo` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `nada` char(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1111108 DEFAULT CHARSET=latin1;

--
-- Table structure for table `guia_masiva_connect`
--

CREATE TABLE `guia_masiva_connect` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `codi_clie` int(10) unsigned NOT NULL,
  `fech_carg` date NOT NULL,
  `hora_carg` time NOT NULL,
  `guia_liberty` char(20) DEFAULT NULL,
  `guia_cliente` varchar(50) DEFAULT NULL,
  `destino` char(3) NOT NULL,
  `cant_piezas` int(10) NOT NULL,
  `asegurado` tinyint(1) NOT NULL,
  `empaque` varchar(5) NOT NULL,
  `modo_pago` char(3) NOT NULL,
  `desc_cont` varchar(200) NOT NULL,
  `valor_decl` decimal(12,2) DEFAULT NULL,
  `nomb_dest` varchar(100) NOT NULL,
  `dire_dest` varchar(300) NOT NULL,
  `tele_dest` varchar(50) NOT NULL,
  `cedu_dest` varchar(20) NOT NULL,
  `desti_frec` tinyint(1) unsigned DEFAULT NULL,
  `registrado_por` char(8) NOT NULL,
  `archivo_input` varchar(50) NOT NULL,
  `procesado_por` char(8) DEFAULT NULL,
  `fecha_proceso` date DEFAULT NULL,
  `hora_proceso` time DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=82 DEFAULT CHARSET=latin1;

--
-- Table structure for table `guia_modificada`
--

CREATE TABLE `guia_modificada` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `guia_id` bigint(20) unsigned NOT NULL,
  `fecha` date NOT NULL,
  `peso_original` double NOT NULL,
  `peso_nuevo` double NOT NULL,
  `usuario_id` int(10) unsigned NOT NULL,
  `sucursal_id` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `guia_modificada_FK` (`sucursal_id`),
  CONSTRAINT `guia_modificada_FK` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `guia_piezas`
--

CREATE TABLE `guia_piezas` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `guia_id` bigint(20) unsigned NOT NULL,
  `id_pieza` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `kilos` decimal(10,2) NOT NULL,
  `libras` decimal(10,2) NOT NULL,
  `largo` decimal(10,2) NOT NULL,
  `alto` decimal(10,2) NOT NULL,
  `ancho` decimal(10,2) NOT NULL,
  `volumen` decimal(10,2) NOT NULL,
  `descripcion` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pies_cub` decimal(10,3) DEFAULT NULL,
  `metros_cub` decimal(10,3) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `guia_piezas_guia_id_foreign` (`guia_id`),
  CONSTRAINT `guia_piezas_guia_id_foreign` FOREIGN KEY (`guia_id`) REFERENCES `guias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `guias`
--

CREATE TABLE `guias` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `numero` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tracking` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `cliente_retail_id` bigint(20) unsigned DEFAULT NULL,
  `cliente_corp_id` int(10) unsigned DEFAULT NULL,
  `cliente_int_id` bigint(20) unsigned DEFAULT NULL,
  `origen_id` bigint(20) unsigned NOT NULL,
  `destino_id` bigint(20) unsigned NOT NULL,
  `servicio` enum('REC','DOM') COLLATE utf8mb4_unicode_ci NOT NULL,
  `producto_id` bigint(20) unsigned NOT NULL,
  `forma_pago` enum('PPD','COD','CRD') COLLATE utf8mb4_unicode_ci NOT NULL,
  `nombre_remitente` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
  `direccion_remitente` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
  `telefono_remitente` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nombre_destinatario` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
  `direccion_destinatario` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
  `telefono_destinatario` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `contenido` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `piezas` int(11) NOT NULL DEFAULT '1',
  `valor_declarado` decimal(12,2) NOT NULL,
  `asegurado` tinyint(1) NOT NULL DEFAULT '1',
  `total` decimal(8,2) NOT NULL DEFAULT '0.00',
  `ubicacion` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vendedor_id` int(10) unsigned DEFAULT NULL,
  `tarifa_id` int(10) unsigned DEFAULT NULL,
  `receptoria_origen` int(10) unsigned DEFAULT NULL,
  `receptoria_destino` int(10) unsigned DEFAULT NULL,
  `kilos` decimal(10,2) DEFAULT '0.00',
  `libras` decimal(10,2) DEFAULT '0.00',
  `largo` decimal(10,2) DEFAULT '0.00',
  `ancho` decimal(10,2) DEFAULT '0.00',
  `alto` decimal(10,2) DEFAULT '0.00',
  `volumen` decimal(10,2) DEFAULT '0.00',
  `pies_cub` decimal(10,3) DEFAULT '0.000',
  `metros_cub` decimal(10,3) DEFAULT '0.000',
  `cedula_destinatario` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fecha_pod` date DEFAULT NULL,
  `hora_pod` time DEFAULT NULL,
  `usuario_pod` int(10) unsigned DEFAULT NULL,
  `entregado_a` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fecha_entrega` date DEFAULT NULL,
  `hora_entrega` time DEFAULT NULL,
  `factura_id` bigint(20) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `guias_numero_unique` (`numero`),
  UNIQUE KEY `guias_tracking_unique` (`tracking`),
  KEY `guias_cliente_retail_id_foreign` (`cliente_retail_id`),
  KEY `guias_cliente_corp_id_foreign` (`cliente_corp_id`),
  KEY `guias_cliente_int_id_foreign` (`cliente_int_id`),
  KEY `guias_origen_id_foreign` (`origen_id`),
  KEY `guias_destino_id_foreign` (`destino_id`),
  KEY `guias_producto_id_foreign` (`producto_id`),
  KEY `guias_vendedor_id_foreign` (`vendedor_id`),
  KEY `guias_tarifa_id_foreign` (`tarifa_id`),
  KEY `guias_receptoria_origen_foreign` (`receptoria_origen`),
  KEY `guias_receptoria_destino_foreign` (`receptoria_destino`),
  KEY `guias_usuario_pod_foreign` (`usuario_pod`),
  CONSTRAINT `guias_cliente_corp_id_foreign` FOREIGN KEY (`cliente_corp_id`) REFERENCES `master_cliente` (`codi_clie`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `guias_cliente_int_id_foreign` FOREIGN KEY (`cliente_int_id`) REFERENCES `clientes_internacional` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `guias_cliente_retail_id_foreign` FOREIGN KEY (`cliente_retail_id`) REFERENCES `clientes_retail` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `guias_destino_id_foreign` FOREIGN KEY (`destino_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `guias_origen_id_foreign` FOREIGN KEY (`origen_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `guias_producto_id_foreign` FOREIGN KEY (`producto_id`) REFERENCES `productos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `guias_receptoria_destino_foreign` FOREIGN KEY (`receptoria_destino`) REFERENCES `counter` (`id`),
  CONSTRAINT `guias_receptoria_origen_foreign` FOREIGN KEY (`receptoria_origen`) REFERENCES `counter` (`id`),
  CONSTRAINT `guias_tarifa_id_foreign` FOREIGN KEY (`tarifa_id`) REFERENCES `fac_tarifa` (`id`),
  CONSTRAINT `guias_usuario_pod_foreign` FOREIGN KEY (`usuario_pod`) REFERENCES `users` (`id`),
  CONSTRAINT `guias_vendedor_id_foreign` FOREIGN KEY (`vendedor_id`) REFERENCES `fac_vendedor` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `item_factura_pmn`
--

CREATE TABLE `item_factura_pmn` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `factura_id` int(10) NOT NULL,
  `guia_id` bigint(20) unsigned NOT NULL,
  `monto_base` decimal(10,2) NOT NULL DEFAULT '0.00',
  `porcentaje_dscto` decimal(5,2) NOT NULL DEFAULT '0.00',
  `monto_dscto` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_franqueo` decimal(10,2) NOT NULL DEFAULT '0.00',
  `porcentaje_iva` decimal(5,2) NOT NULL DEFAULT '0.00',
  `monto_iva` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_seguro` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_otros` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_total` decimal(12,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`id`),
  KEY `ifpmn_fact_idx` (`factura_id`),
  KEY `item_factura_pmn_guia_id_IDX` (`guia_id`) USING BTREE,
  CONSTRAINT `ifpmn_fact_fk` FOREIGN KEY (`factura_id`) REFERENCES `factura_pmn` (`id`),
  CONSTRAINT `item_factura_pmn_FK` FOREIGN KEY (`guia_id`) REFERENCES `guias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `item_nota_credito`
--

CREATE TABLE `item_nota_credito` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `nota_credito_id` int(10) NOT NULL,
  `guia_id` bigint(20) unsigned NOT NULL,
  `monto_base` decimal(10,2) NOT NULL DEFAULT '0.00',
  `porcentaje_dscto` decimal(5,2) NOT NULL DEFAULT '0.00',
  `monto_dscto` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_franqueo` decimal(10,2) NOT NULL DEFAULT '0.00',
  `porcentaje_iva` decimal(5,2) NOT NULL DEFAULT '0.00',
  `monto_iva` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_seguro` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_otros` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_total` decimal(12,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`id`),
  KEY `indc_ndcx_idx` (`nota_credito_id`),
  KEY `item_nota_credito_guia_id_IDX` (`guia_id`) USING BTREE,
  CONSTRAINT `indc_ndcx_fk` FOREIGN KEY (`nota_credito_id`) REFERENCES `nota_credito` (`id`),
  CONSTRAINT `item_nota_credito_FK` FOREIGN KEY (`guia_id`) REFERENCES `guias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `just_camp_type`
--

CREATE TABLE `just_camp_type` (
  `codi_just` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `desc_just` varchar(20) NOT NULL,
  PRIMARY KEY (`codi_just`),
  UNIQUE KEY `idxu_descjust` (`desc_just`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--
-- Table structure for table `log`
--

CREATE TABLE `log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fecha` date NOT NULL,
  `hora` time NOT NULL,
  `usuario` varchar(8) NOT NULL,
  `tabla` varchar(50) NOT NULL,
  `ref` varchar(20) NOT NULL,
  `nombre` varchar(300) NOT NULL,
  `descripcion` text NOT NULL,
  `sistema` varchar(15) DEFAULT NULL,
  `delicado` tinyint(1) DEFAULT NULL,
  `ip` varchar(25) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `log_fech_idx` (`fecha`),
  KEY `log_fech_usua_idx` (`fecha`,`usuario`),
  KEY `log_tabl_idx` (`tabla`),
  KEY `log_tabl_refe_idx` (`tabla`,`ref`),
  KEY `log_usua_idx` (`usuario`)
) ENGINE=InnoDB AUTO_INCREMENT=1452 DEFAULT CHARSET=latin1;

--
-- Table structure for table `log_api`
--

CREATE TABLE `log_api` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fecha` date NOT NULL,
  `hora` time NOT NULL,
  `tabla` varchar(100) NOT NULL,
  `referencia` varchar(50) DEFAULT NULL,
  `nombre` varchar(100) DEFAULT NULL,
  `accion` varchar(100) NOT NULL,
  `descripcion` text NOT NULL,
  `resultado_id` int(11) DEFAULT NULL,
  `tipo` char(1) NOT NULL,
  `token` varchar(25) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=339 DEFAULT CHARSET=latin1 COMMENT='Aqui se almacenan las transacciones realizadas a traves del API';

--
-- Table structure for table `mas_cate_ckpt_type`
--

CREATE TABLE `mas_cate_ckpt_type` (
  `codi_ccat` int(10) unsigned NOT NULL,
  `desc_cate` varchar(30) NOT NULL,
  PRIMARY KEY (`codi_ccat`),
  UNIQUE KEY `idxu_desccate` (`desc_cate`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `mas_inci_ckpt_type`
--

CREATE TABLE `mas_inci_ckpt_type` (
  `codi_inad` int(10) unsigned NOT NULL,
  `desc_inad` varchar(30) NOT NULL,
  PRIMARY KEY (`codi_inad`),
  UNIQUE KEY `idxu_descinad` (`desc_inad`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `mas_stat_cart_type`
--

CREATE TABLE `mas_stat_cart_type` (
  `stat_cart` int(10) unsigned NOT NULL,
  `desc_scar` varchar(30) NOT NULL,
  PRIMARY KEY (`stat_cart`),
  UNIQUE KEY `idxu_statcart` (`desc_scar`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `mas_tipo_mens_type`
--

CREATE TABLE `mas_tipo_mens_type` (
  `tipo_mens` int(10) unsigned NOT NULL,
  `desc_tmen` varchar(30) NOT NULL,
  PRIMARY KEY (`tipo_mens`),
  UNIQUE KEY `idxu_desctmen` (`desc_tmen`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `mas_tipo_ruta`
--

CREATE TABLE `mas_tipo_ruta` (
  `tipo_ruta` int(10) unsigned NOT NULL,
  `desc_trut` varchar(30) NOT NULL,
  PRIMARY KEY (`tipo_ruta`),
  UNIQUE KEY `idxu_desctrut` (`desc_trut`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `master_cliente`
--

CREATE TABLE `master_cliente` (
  `codi_clie` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `codi_depe` int(10) unsigned DEFAULT NULL,
  `nomb_clie` char(50) NOT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `dire_fisc` char(250) NOT NULL,
  `nume_drif` char(15) NOT NULL,
  `vendedor_id` int(10) unsigned NOT NULL,
  `tarifa_id` int(10) unsigned NOT NULL,
  `ciclo_id` int(10) unsigned NOT NULL,
  `nume_dnit` char(15) DEFAULT NULL,
  `pers_cona` char(50) NOT NULL,
  `tele_cona` char(50) NOT NULL,
  `pers_conb` char(50) DEFAULT NULL,
  `tele_conb` char(15) DEFAULT NULL,
  `dire_mail` char(50) DEFAULT NULL,
  `dire_reco` char(250) DEFAULT NULL,
  `hora_lune` char(5) DEFAULT NULL,
  `hora_mart` char(5) DEFAULT NULL,
  `hora_mier` char(5) DEFAULT NULL,
  `hora_juev` char(5) DEFAULT NULL,
  `hora_vier` char(5) DEFAULT NULL,
  `hora_saba` char(5) DEFAULT NULL,
  `codi_stat` int(10) unsigned NOT NULL,
  `codi_sino` int(10) unsigned NOT NULL,
  `text_obse` char(250) DEFAULT NULL,
  `nume_dfax` varchar(50) DEFAULT NULL,
  `codigo_interno` varchar(50) NOT NULL,
  `tipo_cliente` int(10) unsigned DEFAULT NULL,
  `ruta_recolecta` int(10) unsigned DEFAULT NULL,
  `ruta_entrega` int(10) unsigned DEFAULT NULL,
  `porcentaje_dsctoincr` decimal(5,2) DEFAULT '0.00',
  `hora_cierre` char(5) DEFAULT NULL,
  `status_credito_id` int(10) unsigned NOT NULL,
  `dscto_por_volumen` decimal(5,2) DEFAULT '0.00',
  `volumen_para_dscto` int(11) DEFAULT NULL,
  `dscto_por_peso` decimal(5,2) DEFAULT '0.00',
  `peso_para_dscto` decimal(10,2) DEFAULT NULL,
  `descuento_caduca_el` date DEFAULT NULL,
  `porcentaje_seguro` decimal(5,2) DEFAULT NULL,
  `dir_entrega_factura` varchar(250) DEFAULT NULL,
  `clave_servicios_web` varchar(45) DEFAULT NULL,
  `caducidad_de_guias` int(11) DEFAULT NULL,
  `mostrar_guia_externa` int(10) unsigned DEFAULT NULL,
  `carga_masiva` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `cm_guias_yamaguchi` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `guias_yamaguchi_por_carga` int(11) DEFAULT '0',
  `guias_yamaguchi_por_dia` int(11) DEFAULT '0',
  `pago_ppd` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `pago_crd` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `pago_cod` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `cm_destinatario_frecuente` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `clientes_por_carga` int(11) DEFAULT '0',
  `clientes_por_dia` int(11) DEFAULT '0',
  `usuario_api` varchar(8) DEFAULT NULL,
  `password_api` varchar(100) DEFAULT NULL,
  `maneja_api` tinyint(1) DEFAULT '0',
  `token_api` varchar(25) DEFAULT NULL,
  `guia_retorno` tinyint(1) DEFAULT '1',
  `proceso_api` int(10) unsigned DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `motivo_eliminacion_id` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`codi_clie`),
  UNIQUE KEY `codigo_interno` (`codigo_interno`),
  UNIQUE KEY `mastclie_procapix_idxu` (`proceso_api`),
  KEY `master_cliente_FKIndex2` (`codi_sino`),
  KEY `master_cliente_FKIndex3` (`codi_stat`),
  KEY `master_cliente_FKIndex4` (`tarifa_id`),
  KEY `codi_depe` (`codi_depe`),
  KEY `nomb_clie` (`nomb_clie`),
  KEY `tipo_cliente_type_id` (`tipo_cliente`),
  KEY `vendedor_id` (`vendedor_id`),
  KEY `ruta_recolecta` (`ruta_recolecta`),
  KEY `idx_rutaentr` (`ruta_entrega`),
  KEY `status_credito_id` (`status_credito_id`),
  KEY `ciclo_id` (`ciclo_id`),
  KEY `guia_externa_idx` (`mostrar_guia_externa`),
  KEY `clie_deleted_idx` (`deleted_at`),
  KEY `motielim_idx` (`motivo_eliminacion_id`),
  KEY `master_cliente_sucursal_id_foreign` (`sucursal_id`),
  CONSTRAINT `master_cliente_guia_externa_fk` FOREIGN KEY (`mostrar_guia_externa`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `master_cliente_ibfk_67` FOREIGN KEY (`vendedor_id`) REFERENCES `fac_vendedor` (`id`),
  CONSTRAINT `master_cliente_ibfk_68` FOREIGN KEY (`tarifa_id`) REFERENCES `fac_tarifa` (`id`),
  CONSTRAINT `master_cliente_ibfk_69` FOREIGN KEY (`ciclo_id`) REFERENCES `ciclo_fact_type` (`id`),
  CONSTRAINT `master_cliente_ibfk_70` FOREIGN KEY (`codi_stat`) REFERENCES `status_type` (`codi_stat`),
  CONSTRAINT `master_cliente_ibfk_71` FOREIGN KEY (`codi_sino`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `master_cliente_ibfk_72` FOREIGN KEY (`tipo_cliente`) REFERENCES `tipo_cliente_type` (`id`),
  CONSTRAINT `master_cliente_ibfk_73` FOREIGN KEY (`ruta_recolecta`) REFERENCES `sde_operacion` (`codi_oper`),
  CONSTRAINT `master_cliente_ibfk_74` FOREIGN KEY (`ruta_entrega`) REFERENCES `sde_operacion` (`codi_oper`),
  CONSTRAINT `master_cliente_ibfk_75` FOREIGN KEY (`status_credito_id`) REFERENCES `status_credito_type` (`id`),
  CONSTRAINT `master_cliente_sucursal_id_foreign` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `motielim_fk` FOREIGN KEY (`motivo_eliminacion_id`) REFERENCES `motivo_eliminacion` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1693 DEFAULT CHARSET=latin1;

--
-- Table structure for table `mensaje_yamaguchi`
--

CREATE TABLE `mensaje_yamaguchi` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tipo` char(15) NOT NULL,
  `texto` char(200) NOT NULL,
  `orden` int(11) NOT NULL,
  `fech_inic` date NOT NULL COMMENT 'Fecha Inicial::',
  `fech_fin` date DEFAULT NULL COMMENT 'Fecha Final::',
  `codigos` varchar(200) NOT NULL,
  `tiempo_indefinido` tinyint(1) DEFAULT NULL,
  `login` char(8) DEFAULT NULL,
  `icono` char(25) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `mens_yama_tipo_idx` (`tipo`),
  KEY `mens_yama_icon_idx` (`icono`),
  KEY `mens_yama_login_idx` (`login`)
) ENGINE=MyISAM AUTO_INCREMENT=73 DEFAULT CHARSET=latin1;

--
-- Table structure for table `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 AUTO_INCREMENT=78 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `motivo_eliminacion`
--

CREATE TABLE `motivo_eliminacion` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `description` varchar(100) NOT NULL,
  `created_at` datetime NOT NULL,
  `user_id` int(10) unsigned NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `motielim_user_idx` (`user_id`),
  CONSTRAINT `motielim_user_fk` FOREIGN KEY (`user_id`) REFERENCES `usuario` (`codi_usua`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `new_grupo`
--

CREATE TABLE `new_grupo` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(50) NOT NULL COMMENT 'Nombre::',
  `activo` tinyint(1) DEFAULT NULL COMMENT 'Activo ?::Indica si el Grupo esta activo o no',
  `sistema_id` char(3) NOT NULL COMMENT 'Sistema::al que pertenece el Grupo',
  `deleted_at` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `grup_acti_idx` (`activo`) USING BTREE,
  KEY `grup_sist_idx` (`sistema_id`) USING BTREE,
  CONSTRAINT `grup_sist_fk` FOREIGN KEY (`sistema_id`) REFERENCES `sistema` (`codi_sist`)
) ENGINE=InnoDB AUTO_INCREMENT=45 DEFAULT CHARSET=latin1;

--
-- Table structure for table `new_opcion`
--

CREATE TABLE `new_opcion` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `nombre` char(100) NOT NULL,
  `sistema_id` char(5) NOT NULL,
  `es_menu` tinyint(1) unsigned DEFAULT NULL COMMENT 'Es un Menu? ::Indica si el programa es o no un menu, caso contrario es un programa.',
  `activo` tinyint(1) NOT NULL,
  `programa` char(100) NOT NULL,
  `directorio` varchar(20) DEFAULT NULL COMMENT 'Ubicacion del Programa',
  `dependencia` int(10) unsigned DEFAULT NULL,
  `posicion` int(10) unsigned DEFAULT NULL,
  `imagen` char(50) DEFAULT NULL,
  `nivel` int(11) DEFAULT NULL,
  `uso_general` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `newo_depe_idx` (`dependencia`),
  KEY `newo_sist_idx` (`sistema_id`),
  CONSTRAINT `newo_depe_fk` FOREIGN KEY (`dependencia`) REFERENCES `new_opcion` (`id`),
  CONSTRAINT `newo_sist_fk` FOREIGN KEY (`sistema_id`) REFERENCES `sistema` (`codi_sist`)
) ENGINE=InnoDB AUTO_INCREMENT=226 DEFAULT CHARSET=latin1;

--
-- Table structure for table `nive_acce_type`
--

CREATE TABLE `nive_acce_type` (
  `nive_acce` int(10) unsigned NOT NULL,
  `desc_nive` char(50) NOT NULL,
  PRIMARY KEY (`nive_acce`),
  UNIQUE KEY `idxu_descnive` (`desc_nive`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `nota_credito`
--

CREATE TABLE `nota_credito` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `factura_id` int(10) NOT NULL,
  `cedula_rif` varchar(20) NOT NULL,
  `razon_social` varchar(50) NOT NULL,
  `direccion_fiscal` varchar(100) NOT NULL,
  `telefono` varchar(50) NOT NULL,
  `concepto` varchar(200) NOT NULL,
  `numero` decimal(10,0) DEFAULT NULL,
  `maquina_fiscal` varchar(20) DEFAULT NULL,
  `fecha_impresion` char(10) DEFAULT NULL,
  `hora_impresion` char(6) DEFAULT NULL,
  `monto_base` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_franqueo` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_iva` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_seguro` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_otros` decimal(10,2) NOT NULL DEFAULT '0.00',
  `monto_total` decimal(10,2) NOT NULL DEFAULT '0.00',
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `receptoria_id` int(10) unsigned NOT NULL,
  `caja_id` int(10) unsigned NOT NULL,
  `creada_por` int(10) unsigned NOT NULL,
  `creada_el` date NOT NULL,
  `estatus` char(1) NOT NULL,
  `impresa_id` int(10) unsigned NOT NULL,
  `monto_dscto` decimal(10,2) DEFAULT '0.00',
  PRIMARY KEY (`id`),
  UNIQUE KEY `nota_credito_factura_id_uindex` (`factura_id`),
  KEY `nota_rece_idx` (`receptoria_id`),
  KEY `nota_caja_idx` (`caja_id`),
  KEY `nota_crea_idx` (`creada_por`),
  KEY `nota_esta_idx` (`estatus`),
  KEY `nota_impr_idx` (`impresa_id`),
  KEY `nota_credito_sucursal_id_IDX` (`sucursal_id`) USING BTREE,
  CONSTRAINT `nota_caja_fk` FOREIGN KEY (`caja_id`) REFERENCES `caja` (`id`),
  CONSTRAINT `nota_crea_fk` FOREIGN KEY (`creada_por`) REFERENCES `usuario` (`codi_usua`),
  CONSTRAINT `nota_credito_FK` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `nota_fact_fk` FOREIGN KEY (`factura_id`) REFERENCES `factura_pmn` (`id`) ON DELETE CASCADE,
  CONSTRAINT `nota_impr_fk` FOREIGN KEY (`impresa_id`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `nota_rece_fk` FOREIGN KEY (`receptoria_id`) REFERENCES `counter` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `noti_consecutivo`
--

CREATE TABLE `noti_consecutivo` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `nada` char(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `notificacion`
--

CREATE TABLE `notificacion` (
  `id` int(11) NOT NULL,
  `guia_id` bigint(20) unsigned NOT NULL,
  `checkpoint_id` bigint(20) unsigned NOT NULL,
  `notificado` int(10) unsigned NOT NULL,
  `fecha` date DEFAULT NULL,
  `hora` char(5) DEFAULT NULL,
  `notificado_sms` tinyint(1) unsigned DEFAULT NULL,
  `tipo_sms` char(4) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_sino_type1` (`notificado`),
  KEY `notificacion_checkpoint_id_IDX` (`checkpoint_id`) USING BTREE,
  KEY `notificacion_guia_id_IDX` (`guia_id`) USING BTREE,
  CONSTRAINT `fk_sino_type1` FOREIGN KEY (`notificado`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `notificacion_FK` FOREIGN KEY (`checkpoint_id`) REFERENCES `checkpoints` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `notificacion_FK_1` FOREIGN KEY (`guia_id`) REFERENCES `guias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Aqui se almacenan las guias y los status que deben ser notif';

--
-- Table structure for table `opci_grup`
--

CREATE TABLE `opci_grup` (
  `codi_regi` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `codi_grup` int(10) unsigned NOT NULL,
  `codi_opci` int(10) unsigned NOT NULL,
  `nive_acce` int(10) unsigned NOT NULL,
  `fech_camb` datetime DEFAULT NULL,
  `usua_camb` char(8) DEFAULT NULL,
  PRIMARY KEY (`codi_regi`),
  UNIQUE KEY `opci_grup_idx_grupopci` (`codi_grup`,`codi_opci`),
  KEY `opci_grup_FKIndex1` (`nive_acce`),
  KEY `opci_grup_FKIndex2` (`codi_opci`),
  KEY `opci_grup_FKIndex3` (`codi_grup`),
  CONSTRAINT `opci_grup_ibfk_1` FOREIGN KEY (`nive_acce`) REFERENCES `nive_acce_type` (`nive_acce`),
  CONSTRAINT `opci_grup_ibfk_2` FOREIGN KEY (`codi_opci`) REFERENCES `opcion` (`codi_opci`),
  CONSTRAINT `opci_grup_ibfk_3` FOREIGN KEY (`codi_grup`) REFERENCES `grupo` (`codi_grup`)
) ENGINE=InnoDB AUTO_INCREMENT=4063 DEFAULT CHARSET=latin1;

--
-- Table structure for table `opcion`
--

CREATE TABLE `opcion` (
  `codi_opci` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `codi_sist` char(5) NOT NULL,
  `desc_opci` char(50) NOT NULL,
  `codi_tipo` int(10) unsigned NOT NULL,
  `nomb_prog` char(50) NOT NULL,
  `nume_depe` int(10) unsigned DEFAULT NULL,
  `imag_opci` char(50) DEFAULT NULL,
  `anch_imag` int(10) unsigned DEFAULT NULL,
  `alto_imag` int(10) unsigned DEFAULT NULL,
  `codi_stat` int(10) unsigned NOT NULL,
  `text_obse` char(200) DEFAULT NULL,
  `posi_opci` int(10) unsigned DEFAULT NULL,
  `path_opci` varchar(20) DEFAULT NULL COMMENT 'Ubicacion del Programa',
  `nombre_clase` varchar(100) DEFAULT NULL,
  `nivel` int(11) DEFAULT NULL,
  PRIMARY KEY (`codi_opci`),
  KEY `opcion_FKIndex1` (`codi_tipo`),
  KEY `opcion_FKIndex2` (`codi_stat`),
  KEY `idx_numedepe` (`nume_depe`),
  KEY `opcion_FKIndex3` (`codi_sist`),
  CONSTRAINT `opcion_ibfk_1` FOREIGN KEY (`codi_stat`) REFERENCES `status_type` (`codi_stat`),
  CONSTRAINT `opcion_ibfk_2` FOREIGN KEY (`codi_sist`) REFERENCES `sistema` (`codi_sist`),
  CONSTRAINT `opcion_ibfk_3` FOREIGN KEY (`codi_tipo`) REFERENCES `tipo_opci_type` (`codi_tipo`)
) ENGINE=InnoDB AUTO_INCREMENT=1106 DEFAULT CHARSET=latin1;

--
-- Table structure for table `operacion_destino_assn`
--

CREATE TABLE `operacion_destino_assn` (
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `codi_oper` int(10) unsigned NOT NULL,
  KEY `operacion_destino_assn_FKIndex1` (`codi_oper`),
  KEY `operacion_destino_assn_FK` (`sucursal_id`),
  CONSTRAINT `operacion_destino_assn_FK` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `operacion_destino_assn_ibfk_1` FOREIGN KEY (`codi_oper`) REFERENCES `sde_operacion` (`codi_oper`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `operacion_type`
--

CREATE TABLE `operacion_type` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_desc` (`descripcion`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `pago_factura_pmn`
--

CREATE TABLE `pago_factura_pmn` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `factura_id` int(10) NOT NULL,
  `forma_pago_id` int(10) unsigned NOT NULL,
  `numero_documento` varchar(20) DEFAULT NULL,
  `monto_pago` decimal(14,2) NOT NULL DEFAULT '0.00',
  `creado_el` date NOT NULL,
  `creado_por` int(10) unsigned NOT NULL,
  `banco_id` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pago_fact_idx` (`factura_id`),
  KEY `pago_form_idx` (`forma_pago_id`),
  KEY `pago_crea_fk` (`creado_por`),
  KEY `pago_banco_idx` (`banco_id`),
  CONSTRAINT `fk_pago_factura_pmn_1` FOREIGN KEY (`banco_id`) REFERENCES `banco` (`id`),
  CONSTRAINT `pago_crea_fk` FOREIGN KEY (`creado_por`) REFERENCES `usuario` (`codi_usua`),
  CONSTRAINT `pago_fact_fk` FOREIGN KEY (`factura_id`) REFERENCES `factura_pmn` (`id`),
  CONSTRAINT `pago_form_fk` FOREIGN KEY (`forma_pago_id`) REFERENCES `forma_pago` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `pais`
--

CREATE TABLE `pais` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `nombre` varchar(100) NOT NULL,
  `siglas` char(2) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_siglas` (`siglas`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 COMMENT='InnoDB free: 1942528 kB';

--
-- Table structure for table `parametro`
--

CREATE TABLE `parametro` (
  `indi_para` char(10) NOT NULL,
  `codi_para` char(10) NOT NULL,
  `desc_para` char(200) NOT NULL,
  `para_txt1` text NOT NULL,
  `para_txt2` char(200) DEFAULT NULL,
  `para_txt3` char(200) DEFAULT NULL,
  `para_txt4` char(200) DEFAULT NULL,
  `para_txt5` char(200) DEFAULT NULL,
  `para_val1` decimal(10,0) DEFAULT NULL,
  `para_val2` decimal(10,0) DEFAULT NULL,
  `para_val3` decimal(10,2) DEFAULT NULL,
  `para_val4` decimal(10,3) DEFAULT NULL,
  `para_val5` decimal(10,3) DEFAULT NULL,
  PRIMARY KEY (`indi_para`,`codi_para`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `password_resets`
--

CREATE TABLE `password_resets` (
  `email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  KEY `password_resets_email_index` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `permiso`
--

CREATE TABLE `permiso` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `grupo_id` int(11) NOT NULL COMMENT 'Grupo::',
  `opcion_id` int(10) unsigned NOT NULL COMMENT 'Opcion::',
  PRIMARY KEY (`id`),
  UNIQUE KEY `perm_opci_grup_idxu` (`grupo_id`,`opcion_id`),
  KEY `perm_grup_idx` (`grupo_id`) USING BTREE,
  KEY `perm_opci_idx` (`opcion_id`) USING BTREE,
  CONSTRAINT `perm_grup_fk` FOREIGN KEY (`grupo_id`) REFERENCES `new_grupo` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `perm_opci_fk` FOREIGN KEY (`opcion_id`) REFERENCES `new_opcion` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=482 DEFAULT CHARSET=latin1;

--
-- Table structure for table `pieza_checkpoints`
--

CREATE TABLE `pieza_checkpoints` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `pieza_id` bigint(20) unsigned NOT NULL,
  `checkpoint_id` bigint(20) unsigned NOT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `comentario` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pieza_checkpoints_pieza_id_foreign` (`pieza_id`),
  KEY `pieza_checkpoints_checkpoint_id_foreign` (`checkpoint_id`),
  KEY `pieza_checkpoints_sucursal_id_foreign` (`sucursal_id`),
  CONSTRAINT `pieza_checkpoints_checkpoint_id_foreign` FOREIGN KEY (`checkpoint_id`) REFERENCES `checkpoints` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `pieza_checkpoints_pieza_id_foreign` FOREIGN KEY (`pieza_id`) REFERENCES `guia_piezas` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `pieza_checkpoints_sucursal_id_foreign` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `pila_acceso`
--

CREATE TABLE `pila_acceso` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `login` char(20) NOT NULL COMMENT 'Login del Usuario que accede al programa',
  `fecha` date NOT NULL COMMENT 'Fecha de acceso al programa',
  `programa` varchar(100) NOT NULL COMMENT 'Nombre del programa accedido y sus parametros',
  `hora` time NOT NULL COMMENT 'Hora de Acceso al Programa',
  `parametros` varchar(250) DEFAULT NULL COMMENT 'Parametros del programa accedido',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `proceso`
--

CREATE TABLE `proceso` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `usuario` varchar(8) NOT NULL,
  `programa` varchar(100) NOT NULL,
  `fecha` date NOT NULL,
  `hora` char(8) NOT NULL,
  `accion` varchar(100) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `usuario` (`usuario`),
  KEY `fecha` (`fecha`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `proceso_error`
--

CREATE TABLE `proceso_error` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(300) NOT NULL COMMENT 'Nombre del proceso.',
  `usuario` char(8) NOT NULL COMMENT 'Usuario quien creó el proceso.',
  `fecha` date NOT NULL COMMENT 'Fecha en que ocurrió el proceso.',
  `hora_inicial` time NOT NULL COMMENT 'Hora inicial del proceso.',
  `hora_final` time DEFAULT NULL COMMENT 'Hora final del proceso.',
  `comentario` text COMMENT 'Comentarios y/u observaciones relacionados al proceso.',
  `notificar_admin` tinyint(1) NOT NULL COMMENT 'Confirmación de notificación al administrador del sistema',
  `notificar_usuario` tinyint(1) NOT NULL COMMENT 'Confirmacion de notificacion al usuario del sistema.',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Registros de procesos de error generados en el sistema';

--
-- Table structure for table `productos`
--

CREATE TABLE `productos` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `codigo` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nombre` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `se_vende` tinyint(1) NOT NULL,
  `observacion` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `productos_codigo_unique` (`codigo`),
  UNIQUE KEY `productos_nombre_unique` (`nombre`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `profesiones`
--

CREATE TABLE `profesiones` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `nombre` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `profesiones_nombre_unique` (`nombre`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `regi_trab_consecutivo`
--

CREATE TABLE `regi_trab_consecutivo` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `nada` char(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `region`
--

CREATE TABLE `region` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_nomb` (`descripcion`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;

--
-- Table structure for table `registro_trabajo`
--

CREATE TABLE `registro_trabajo` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `guia_id` bigint(20) unsigned NOT NULL,
  `comentario` varchar(250) NOT NULL,
  `usuario_id` int(10) unsigned NOT NULL,
  `fecha` date NOT NULL,
  `hora` char(8) NOT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `checkpoint_id` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_usuario1` (`usuario_id`),
  KEY `idx_fecha` (`fecha`),
  KEY `registro_trabajo_sucursal_id_IDX` (`sucursal_id`) USING BTREE,
  KEY `registro_trabajo_guia_id_IDX` (`guia_id`) USING BTREE,
  KEY `registro_trabajo_checkpoint_id_IDX` (`checkpoint_id`) USING BTREE,
  CONSTRAINT `fk_usuario1` FOREIGN KEY (`usuario_id`) REFERENCES `usuario` (`codi_usua`),
  CONSTRAINT `registro_trabajo_FK` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `registro_trabajo_FK_1` FOREIGN KEY (`guia_id`) REFERENCES `guias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `registro_trabajo_FK_2` FOREIGN KEY (`checkpoint_id`) REFERENCES `checkpoints` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Aqui se almacena cualquier informacion relativa a una guia. ';

--
-- Table structure for table `ruta`
--

CREATE TABLE `ruta` (
  `codi_ruta` char(20) NOT NULL,
  `desc_ruta` char(200) NOT NULL,
  `text_obse` char(200) DEFAULT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `tipo_ruta` int(10) unsigned NOT NULL DEFAULT '1',
  `codi_stat` int(10) unsigned NOT NULL,
  `porc_medi` double DEFAULT '50',
  `deleted_at` date DEFAULT NULL,
  PRIMARY KEY (`codi_ruta`),
  KEY `ruta_FKIndex1` (`codi_stat`),
  KEY `idx_tiporuta` (`tipo_ruta`),
  KEY `ruta_sucursal_id_IDX` (`sucursal_id`) USING BTREE,
  CONSTRAINT `ruta_FK` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `ruta_ibfk_2` FOREIGN KEY (`tipo_ruta`) REFERENCES `tipo_ruta_type` (`tipo_ruta`),
  CONSTRAINT `ruta_ibfk_3` FOREIGN KEY (`codi_stat`) REFERENCES `status_type` (`codi_stat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sde_checkpoint`
--

CREATE TABLE `sde_checkpoint` (
  `codi_ckpt` char(2) NOT NULL,
  `desc_ckpt` char(50) NOT NULL,
  `tipo_term` int(10) unsigned NOT NULL,
  `tipo_ckpt` int(10) unsigned NOT NULL,
  `text_obse` char(200) DEFAULT NULL,
  `codi_stat` int(10) unsigned NOT NULL,
  `codi_ccat` int(10) unsigned NOT NULL,
  `codi_inad` int(10) unsigned NOT NULL,
  `desc_devo` varchar(50) DEFAULT NULL,
  `notificar` int(10) unsigned NOT NULL DEFAULT '0',
  `pais_id` int(10) unsigned DEFAULT NULL,
  `comentario_ivr` varchar(300) DEFAULT NULL,
  `codigo_sodexo` int(11) DEFAULT NULL,
  `descripcion_sodexo` varchar(50) DEFAULT NULL,
  `notificacion_sms` tinyint(1) unsigned DEFAULT NULL,
  `imagen` varchar(50) DEFAULT NULL,
  `color` varchar(20) DEFAULT NULL,
  `delete_at` datetime DEFAULT NULL,
  PRIMARY KEY (`codi_ckpt`),
  KEY `checkpoint_FKIndex1` (`codi_stat`),
  KEY `checkpoint_FKIndex2` (`tipo_ckpt`),
  KEY `checkpoint_FKIndex3` (`tipo_term`),
  KEY `fk_pais` (`pais_id`),
  KEY `ckpt_dele_idx` (`delete_at`),
  KEY `ckpt_noti_idx` (`notificar`),
  KEY `ckpt_cate_idx` (`codi_ccat`),
  KEY `ckpt_inci_idx` (`codi_inad`),
  CONSTRAINT `ckpt_cate_fk` FOREIGN KEY (`codi_ccat`) REFERENCES `mas_cate_ckpt_type` (`codi_ccat`),
  CONSTRAINT `ckpt_inci_fk` FOREIGN KEY (`codi_inad`) REFERENCES `mas_inci_ckpt_type` (`codi_inad`),
  CONSTRAINT `ckpt_noti_fk` FOREIGN KEY (`notificar`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `sde_checkpoint_ibfk_1` FOREIGN KEY (`codi_stat`) REFERENCES `status_type` (`codi_stat`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `sde_checkpoint_ibfk_2` FOREIGN KEY (`tipo_ckpt`) REFERENCES `sde_tipo_ckpt_type` (`tipo_ckpt`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `sde_checkpoint_ibfk_3` FOREIGN KEY (`tipo_term`) REFERENCES `sde_terminal_ckpt_type` (`tipo_term`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `sde_checkpoint_ibfk_9` FOREIGN KEY (`pais_id`) REFERENCES `pais` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sde_cont_cont_assn`
--

CREATE TABLE `sde_cont_cont_assn` (
  `contenedor_id` bigint(20) unsigned NOT NULL,
  `valija_id` bigint(20) unsigned NOT NULL,
  KEY `sde_cont_cont_assn_FK` (`contenedor_id`),
  KEY `sde_cont_cont_assn_FK_1` (`valija_id`),
  CONSTRAINT `sde_cont_cont_assn_FK` FOREIGN KEY (`contenedor_id`) REFERENCES `sde_contenedor` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sde_cont_cont_assn_FK_1` FOREIGN KEY (`valija_id`) REFERENCES `sde_contenedor` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sde_contenedor`
--

CREATE TABLE `sde_contenedor` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `nume_cont` char(20) NOT NULL,
  `codi_oper` int(10) unsigned NOT NULL,
  `fecha` date NOT NULL,
  `stat_cont` char(1) DEFAULT NULL,
  `nombre_chofer` varchar(50) DEFAULT NULL,
  `cedula_chofer` varchar(50) DEFAULT NULL,
  `placa_vehiculo` varchar(10) DEFAULT NULL,
  `descipcion_vehiculo` varchar(50) DEFAULT NULL,
  `monto_flete` decimal(10,2) DEFAULT '0.00',
  `master` tinyint(4) DEFAULT NULL,
  `numero_valijas` int(11) DEFAULT NULL,
  `valijas` varchar(250) DEFAULT NULL,
  `pais_id` int(10) unsigned DEFAULT NULL COMMENT '	',
  `hora` char(5) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `contenedor_FKIndex1` (`codi_oper`),
  KEY `idx_statcont` (`stat_cont`),
  KEY `fecha` (`fecha`),
  KEY `idx_operfech` (`codi_oper`,`fecha`),
  KEY `idx_operstat` (`codi_oper`,`stat_cont`),
  CONSTRAINT `sde_contenedor_ibfk_1` FOREIGN KEY (`codi_oper`) REFERENCES `sde_operacion` (`codi_oper`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sde_contenedor_guia_assn`
--

CREATE TABLE `sde_contenedor_guia_assn` (
  `contenedor_id` bigint(20) unsigned NOT NULL,
  `guia_id` bigint(20) unsigned NOT NULL,
  KEY `sde_contenedor_guia_assn_guia_id_IDX` (`guia_id`) USING BTREE,
  KEY `sde_contenedor_guia_assn_FK_1` (`contenedor_id`),
  CONSTRAINT `sde_contenedor_guia_assn_FK` FOREIGN KEY (`guia_id`) REFERENCES `guias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sde_contenedor_guia_assn_FK_1` FOREIGN KEY (`contenedor_id`) REFERENCES `sde_contenedor` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sde_operacion`
--

CREATE TABLE `sde_operacion` (
  `codi_oper` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `codi_ruta` char(20) NOT NULL,
  `codi_chof` int(10) unsigned NOT NULL,
  `codi_vehi` int(10) unsigned NOT NULL,
  `sucusal_id` bigint(20) unsigned NOT NULL,
  `codi_tipo` int(10) unsigned NOT NULL,
  `expreso_nacional` int(10) unsigned DEFAULT NULL,
  `deleted_at` date DEFAULT NULL,
  PRIMARY KEY (`codi_oper`),
  KEY `operacion_FKIndex2` (`codi_chof`),
  KEY `operacion_FKIndex3` (`codi_vehi`),
  KEY `operacion_FKIndex4` (`codi_ruta`),
  KEY `operacion_FKIndex6` (`codi_tipo`),
  KEY `oper_expr_idx` (`expreso_nacional`),
  KEY `sdeo_tipo_sucu` (`codi_tipo`,`sucusal_id`),
  KEY `sde_operacion_sucusal_id_IDX` (`sucusal_id`) USING BTREE,
  CONSTRAINT `oper_expr_fk` FOREIGN KEY (`expreso_nacional`) REFERENCES `sino_type` (`codi_sino`),
  CONSTRAINT `sde_operacion_FK` FOREIGN KEY (`sucusal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `sde_operacion_ibfk_11` FOREIGN KEY (`codi_ruta`) REFERENCES `ruta` (`codi_ruta`),
  CONSTRAINT `sde_operacion_ibfk_12` FOREIGN KEY (`codi_chof`) REFERENCES `chofer` (`codi_chof`),
  CONSTRAINT `sde_operacion_ibfk_13` FOREIGN KEY (`codi_vehi`) REFERENCES `vehiculo` (`codi_vehi`),
  CONSTRAINT `sde_operacion_ibfk_16` FOREIGN KEY (`codi_tipo`) REFERENCES `sde_tipo_oper` (`codi_tipo`)
) ENGINE=InnoDB AUTO_INCREMENT=178 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sde_status_oper_type`
--

CREATE TABLE `sde_status_oper_type` (
  `codi_stat` int(10) unsigned NOT NULL,
  `desc_stat` char(50) NOT NULL,
  PRIMARY KEY (`codi_stat`),
  UNIQUE KEY `idxu_descstat` (`desc_stat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sde_terminal_ckpt_type`
--

CREATE TABLE `sde_terminal_ckpt_type` (
  `tipo_term` int(10) unsigned NOT NULL,
  `desc_tipo` char(20) NOT NULL,
  PRIMARY KEY (`tipo_term`),
  UNIQUE KEY `idxu_desctipo` (`desc_tipo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sde_tipo_ckpt_type`
--

CREATE TABLE `sde_tipo_ckpt_type` (
  `tipo_ckpt` int(10) unsigned NOT NULL,
  `desc_tipo` char(20) NOT NULL,
  PRIMARY KEY (`tipo_ckpt`),
  UNIQUE KEY `idxu_desctipo` (`desc_tipo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sde_tipo_oper`
--

CREATE TABLE `sde_tipo_oper` (
  `codi_tipo` int(10) unsigned NOT NULL,
  `desc_tipo` char(50) NOT NULL,
  `stan_hora` int(10) unsigned NOT NULL,
  PRIMARY KEY (`codi_tipo`),
  UNIQUE KEY `idxu_desctipo` (`desc_tipo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sino_type`
--

CREATE TABLE `sino_type` (
  `codi_sino` int(10) unsigned NOT NULL,
  `desc_sino` char(50) DEFAULT NULL,
  PRIMARY KEY (`codi_sino`),
  UNIQUE KEY `idx__sinotype01` (`desc_sino`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sistema`
--

CREATE TABLE `sistema` (
  `codi_sist` char(5) NOT NULL,
  `desc_sist` varchar(30) NOT NULL,
  `codi_stat` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`codi_sist`),
  KEY `codi_stat` (`codi_stat`),
  CONSTRAINT `sistema_ibfk_1` FOREIGN KEY (`codi_stat`) REFERENCES `status_type` (`codi_stat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `status_credito_type`
--

CREATE TABLE `status_credito_type` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(30) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_desc` (`descripcion`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `status_fact_type`
--

CREATE TABLE `status_fact_type` (
  `id` int(10) unsigned NOT NULL,
  `descripcion` varchar(20) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `fac_statfact_type_idxu_descstat` (`descripcion`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `status_type`
--

CREATE TABLE `status_type` (
  `codi_stat` int(10) unsigned NOT NULL,
  `desc_stat` char(20) NOT NULL,
  PRIMARY KEY (`codi_stat`),
  UNIQUE KEY `idxu_descstat` (`desc_stat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sucursales`
--

CREATE TABLE `sucursales` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `nombre` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
  `iata` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `telefono` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `estado_id` int(11) NOT NULL,
  `zona` int(11) NOT NULL,
  `es_export` tinyint(1) NOT NULL DEFAULT '0',
  `es_exenta` tinyint(1) DEFAULT '0',
  `es_principal` tinyint(1) DEFAULT '0',
  `es_area_metropolitana` tinyint(1) DEFAULT '0',
  `es_almacen` tinyint(1) DEFAULT '0',
  `es_tienda` tinyint(1) DEFAULT '1',
  `email_principal` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_almacen` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `zona_nc` text COLLATE utf8mb4_unicode_ci,
  `comision_venta` decimal(5,2) DEFAULT '0.00',
  `comision_entrega` decimal(5,2) DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `sucursales_nombre_unique` (`nombre`),
  UNIQUE KEY `sucursales_iata_unique` (`iata`),
  KEY `sucursales_estado_id_foreign` (`estado_id`),
  CONSTRAINT `sucursales_estado_id_foreign` FOREIGN KEY (`estado_id`) REFERENCES `estado` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `t1`
--

CREATE TABLE `t1` (
  `id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `t500`
--

CREATE TABLE `t500` (
  `id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tarifa_peso`
--

CREATE TABLE `tarifa_peso` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `tarifa_id` int(10) unsigned NOT NULL,
  `tipo_id` int(10) unsigned NOT NULL,
  `peso_inicial` decimal(10,3) NOT NULL,
  `peso_final` decimal(10,3) NOT NULL,
  `monto_tarifa` decimal(10,2) NOT NULL,
  `franqueo_postal` decimal(10,2) NOT NULL,
  `monto_base` decimal(10,4) NOT NULL,
  `porcentaje_fp` decimal(10,2) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_pk` (`tarifa_id`,`tipo_id`,`peso_inicial`,`peso_final`),
  KEY `idx_tarifa` (`tarifa_id`),
  KEY `idx_tipo` (`tipo_id`),
  KEY `idx_otro` (`tarifa_id`,`tipo_id`),
  CONSTRAINT `fk_tarifa` FOREIGN KEY (`tarifa_id`) REFERENCES `fac_tarifa` (`id`),
  CONSTRAINT `fk_tipo` FOREIGN KEY (`tipo_id`) REFERENCES `tipo_tarifa_type` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2210 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tasa_cambio`
--

CREATE TABLE `tasa_cambio` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `divisa_id` int(10) unsigned NOT NULL,
  `fecha_vigencia` date NOT NULL,
  `monto` decimal(10,2) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_divifech` (`divisa_id`,`fecha_vigencia`),
  KEY `tasa_cambio_FKIndex1` (`divisa_id`),
  CONSTRAINT `tasa_cambio_ibfk_1` FOREIGN KEY (`divisa_id`) REFERENCES `divisa` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tasas`
--

CREATE TABLE `tasas` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `divisa_id` bigint(20) unsigned NOT NULL,
  `fecha_hora` datetime NOT NULL,
  `tasa` decimal(12,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) unsigned DEFAULT NULL,
  `updated_by` bigint(20) unsigned DEFAULT NULL,
  `deleted_by` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `tasas_divisa_id_foreign` (`divisa_id`),
  CONSTRAINT `tasas_divisa_id_foreign` FOREIGN KEY (`divisa_id`) REFERENCES `divisas` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `tipo_aplica_type`
--

CREATE TABLE `tipo_aplica_type` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(45) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_desc` (`descripcion`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 COMMENT='Como aplica cierto impuesto o tasa, por valor o porcentaje';

--
-- Table structure for table `tipo_caja_type`
--

CREATE TABLE `tipo_caja_type` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_desc` (`descripcion`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tipo_cliente_type`
--

CREATE TABLE `tipo_cliente_type` (
  `id` int(10) unsigned NOT NULL,
  `descripcion` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_desc` (`descripcion`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tipo_documento`
--

CREATE TABLE `tipo_documento` (
  `id` char(1) NOT NULL,
  `descripcion` char(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tipo_documento_type`
--

CREATE TABLE `tipo_documento_type` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(30) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_desc` (`descripcion`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tipo_guia_type`
--

CREATE TABLE `tipo_guia_type` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_desc` (`descripcion`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--
-- Table structure for table `tipo_opci_type`
--

CREATE TABLE `tipo_opci_type` (
  `codi_tipo` int(10) unsigned NOT NULL,
  `desc_tipo` char(50) NOT NULL,
  PRIMARY KEY (`codi_tipo`),
  UNIQUE KEY `idxu_tipoopci` (`desc_tipo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tipo_ruta_type`
--

CREATE TABLE `tipo_ruta_type` (
  `tipo_ruta` int(10) unsigned NOT NULL,
  `desc_trut` varchar(30) NOT NULL,
  PRIMARY KEY (`tipo_ruta`),
  UNIQUE KEY `idxu_desctrut` (`desc_trut`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tipo_tarifa_type`
--

CREATE TABLE `tipo_tarifa_type` (
  `id` int(10) unsigned NOT NULL,
  `descripcion` char(3) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_descripcion` (`descripcion`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tipo_usua_type`
--

CREATE TABLE `tipo_usua_type` (
  `tipo_usua` int(10) unsigned NOT NULL,
  `desc_tipo` char(50) NOT NULL,
  PRIMARY KEY (`tipo_usua`),
  UNIQUE KEY `idxu_desctipo` (`desc_tipo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tipo_vehiculo`
--

CREATE TABLE `tipo_vehiculo` (
  `tipo_vehi` char(1) NOT NULL,
  `desc_tipo` char(50) NOT NULL,
  `capacidad_maxima` float(10,2) NOT NULL DEFAULT '0.00',
  `costo_km` float(10,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`tipo_vehi`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tracking_consecutivo`
--

CREATE TABLE `tracking_consecutivo` (
  `id` bigint(11) NOT NULL AUTO_INCREMENT,
  `nada` char(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7971 DEFAULT CHARSET=latin1 COMMENT='Esta tabla se utiliza para generar numeros consecutivos de t';

--
-- Table structure for table `turno`
--

CREATE TABLE `turno` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `usuario`
--

CREATE TABLE `usuario` (
  `codi_usua` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Codigo::',
  `nomb_usua` char(50) NOT NULL COMMENT 'Nombre::',
  `apel_usua` char(50) NOT NULL COMMENT 'Apellido::',
  `logi_usua` char(8) NOT NULL COMMENT 'Login::',
  `pass_usua` char(50) NOT NULL COMMENT 'Clave::',
  `codi_stat` int(10) unsigned NOT NULL COMMENT 'Estatus::',
  `sucursal_id` bigint(20) unsigned NOT NULL COMMENT 'Sucursal::',
  `tipo_usua` int(10) unsigned NOT NULL,
  `cant_inte` int(10) unsigned DEFAULT NULL,
  `mail_usua` char(50) DEFAULT NULL,
  `fech_acce` datetime DEFAULT NULL,
  `moti_bloq` char(200) DEFAULT NULL,
  `fech_clav` date DEFAULT NULL,
  `carg_usua` varchar(50) DEFAULT NULL,
  `supervisor` tinyint(1) DEFAULT '0',
  `grupo_id` int(11) DEFAULT NULL COMMENT 'Grupo::',
  `delete_at` datetime DEFAULT NULL,
  PRIMARY KEY (`codi_usua`),
  UNIQUE KEY `idxu_logiusua` (`logi_usua`),
  KEY `usuario_FKIndex1` (`codi_stat`),
  KEY `usuario_FKIndex2` (`sucursal_id`),
  KEY `usuario_FKIndex3` (`tipo_usua`),
  KEY `usua_grup_idx` (`grupo_id`) USING BTREE,
  KEY `usua_dele_idx` (`delete_at`),
  KEY `usuario_sucursal_id_IDX` (`sucursal_id`) USING BTREE,
  CONSTRAINT `usua_grup_fk` FOREIGN KEY (`grupo_id`) REFERENCES `new_grupo` (`id`),
  CONSTRAINT `usuario_ibfk_1` FOREIGN KEY (`codi_stat`) REFERENCES `status_type` (`codi_stat`),
  CONSTRAINT `usuario_ibfk_3` FOREIGN KEY (`tipo_usua`) REFERENCES `tipo_usua_type` (`tipo_usua`),
  CONSTRAINT `usuario_sucursal_id_foreign` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=811 DEFAULT CHARSET=latin1;

--
-- Table structure for table `usuario_connect`
--

CREATE TABLE `usuario_connect` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `cliente_id` int(10) unsigned NOT NULL,
  `nombre` varchar(80) NOT NULL,
  `direccion` varchar(500) NOT NULL,
  `email` varchar(80) NOT NULL,
  `telefono` varchar(50) NOT NULL,
  `logi_usua` varchar(20) NOT NULL,
  `clave_acceso` varchar(100) NOT NULL,
  `sucursal_id` bigint(20) unsigned NOT NULL,
  `status_id` int(10) unsigned NOT NULL,
  `fecha_registro` date NOT NULL,
  `codigo_postal` varchar(10) DEFAULT NULL,
  `fecha_acceso` datetime DEFAULT NULL,
  `cantidad_intentos` smallint(6) NOT NULL DEFAULT '0',
  `motivo_bloqueo` varchar(200) DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idxu_nick` (`logi_usua`),
  KEY `usuario_connect_FKIndex2` (`cliente_id`),
  KEY `status_id` (`status_id`),
  KEY `usua_conn_dele_idx` (`deleted_at`),
  KEY `usuario_connect_sucursal_id_IDX` (`sucursal_id`) USING BTREE,
  CONSTRAINT `usuario_connect_FK` FOREIGN KEY (`sucursal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `usuario_connect_ibfk_7` FOREIGN KEY (`cliente_id`) REFERENCES `master_cliente` (`codi_clie`),
  CONSTRAINT `usuario_connect_ibfk_9` FOREIGN KEY (`status_id`) REFERENCES `status_type` (`codi_stat`)
) ENGINE=InnoDB AUTO_INCREMENT=723 DEFAULT CHARSET=latin1;

--
-- Temporary table structure for view `v_facturado_en_tiendas`
--

/*!50001 DROP VIEW IF EXISTS `v_facturado_en_tiendas`*/;
/*!50001 CREATE VIEW `v_facturado_en_tiendas` AS SELECT 
 1 AS `fecha_factura`,
 1 AS `cantidad_facturas`,
 1 AS `total_facturado`*/;

--
-- Temporary table structure for view `v_fecha_ultima_guia`
--

/*!50001 DROP VIEW IF EXISTS `v_fecha_ultima_guia`*/;
/*!50001 CREATE VIEW `v_fecha_ultima_guia` AS SELECT 
 1 AS `codi_clie`,
 1 AS `ultima_fecha`*/;

--
-- Temporary table structure for view `v_rank_clientes_facturado`
--

/*!50001 DROP VIEW IF EXISTS `v_rank_clientes_facturado`*/;
/*!50001 CREATE VIEW `v_rank_clientes_facturado` AS SELECT 
 1 AS `id`,
 1 AS `razon_social`,
 1 AS `total_facturado`*/;

--
-- Temporary table structure for view `v_rank_clientes_kilos`
--

/*!50001 DROP VIEW IF EXISTS `v_rank_clientes_kilos`*/;
/*!50001 CREATE VIEW `v_rank_clientes_kilos` AS SELECT 
 1 AS `id`,
 1 AS `razon_social`,
 1 AS `cantidad_kilos`*/;

--
-- Temporary table structure for view `v_ranking`
--

/*!50001 DROP VIEW IF EXISTS `v_ranking`*/;
/*!50001 CREATE VIEW `v_ranking` AS SELECT 
 1 AS `rnk`,
 1 AS `id`,
 1 AS `razon_social`,
 1 AS `cantidad_guias`*/;

--
-- Temporary table structure for view `v_ranking_clientes`
--

/*!50001 DROP VIEW IF EXISTS `v_ranking_clientes`*/;
/*!50001 CREATE VIEW `v_ranking_clientes` AS SELECT 
 1 AS `id`,
 1 AS `razon_social`,
 1 AS `cantidad_guias`*/;

--
-- Temporary table structure for view `v_ranking_facturado`
--

/*!50001 DROP VIEW IF EXISTS `v_ranking_facturado`*/;
/*!50001 CREATE VIEW `v_ranking_facturado` AS SELECT 
 1 AS `rnk`,
 1 AS `id`,
 1 AS `razon_social`,
 1 AS `total_facturado`*/;

--
-- Temporary table structure for view `v_ranking_kilos`
--

/*!50001 DROP VIEW IF EXISTS `v_ranking_kilos`*/;
/*!50001 CREATE VIEW `v_ranking_kilos` AS SELECT 
 1 AS `rnk`,
 1 AS `id`,
 1 AS `razon_social`,
 1 AS `cantidad_kilos`*/;

--
-- Temporary table structure for view `v_resumen_consumo_mes`
--

/*!50001 DROP VIEW IF EXISTS `v_resumen_consumo_mes`*/;
/*!50001 CREATE VIEW `v_resumen_consumo_mes` AS SELECT 
 1 AS `anio`,
 1 AS `mes`,
 1 AS `cantidad_guias`*/;

--
-- Temporary table structure for view `v_resumen_consumo_mes_corp`
--

/*!50001 DROP VIEW IF EXISTS `v_resumen_consumo_mes_corp`*/;
/*!50001 CREATE VIEW `v_resumen_consumo_mes_corp` AS SELECT 
 1 AS `anio`,
 1 AS `mes`,
 1 AS `cantidad_guias`*/;

--
-- Temporary table structure for view `v_resumen_consumo_mes_expr`
--

/*!50001 DROP VIEW IF EXISTS `v_resumen_consumo_mes_expr`*/;
/*!50001 CREATE VIEW `v_resumen_consumo_mes_expr` AS SELECT 
 1 AS `anio`,
 1 AS `mes`,
 1 AS `cantidad_guias`*/;

--
-- Temporary table structure for view `v_sin_datos_fiscales`
--

/*!50001 DROP VIEW IF EXISTS `v_sin_datos_fiscales`*/;
/*!50001 CREATE VIEW `v_sin_datos_fiscales` AS SELECT 
 1 AS `id`,
 1 AS `guia_id`,
 1 AS `creada_el`,
 1 AS `logi_usua`,
 1 AS `esta_orig`,
 1 AS `receptoria_origen`,
 1 AS `esta_dest`,
 1 AS `receptoria_destino`,
 1 AS `cedula_rif`,
 1 AS `razon_social`,
 1 AS `monto_total`,
 1 AS `creada_por`*/;

--
-- Table structure for table `vehiculo`
--

CREATE TABLE `vehiculo` (
  `codi_vehi` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `desc_vehi` char(100) DEFAULT NULL,
  `nume_plac` char(10) DEFAULT NULL,
  `text_obse` char(200) DEFAULT NULL,
  `sucusal_id` bigint(20) unsigned NOT NULL,
  `tipo_vehi` char(1) NOT NULL,
  `codi_disp` int(11) NOT NULL,
  `codi_stat` int(10) unsigned NOT NULL,
  PRIMARY KEY (`codi_vehi`),
  KEY `vehiculo_FKIndex1` (`codi_stat`),
  KEY `vehiculo_FKIndex2` (`codi_disp`),
  KEY `vehiculo_FKIndex3` (`tipo_vehi`),
  KEY `idxu_placa` (`nume_plac`),
  KEY `vehiculo_sucusal_id_IDX` (`sucusal_id`) USING BTREE,
  CONSTRAINT `vehiculo_FK` FOREIGN KEY (`sucusal_id`) REFERENCES `sucursales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `vehiculo_ibfk_1` FOREIGN KEY (`codi_stat`) REFERENCES `status_type` (`codi_stat`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `vehiculo_ibfk_3` FOREIGN KEY (`tipo_vehi`) REFERENCES `tipo_vehiculo` (`tipo_vehi`),
  CONSTRAINT `vehiculo_ibfk_4` FOREIGN KEY (`codi_disp`) REFERENCES `disponible_type` (`codi_disp`)
) ENGINE=InnoDB AUTO_INCREMENT=96 DEFAULT CHARSET=latin1;

--
-- Table structure for table `vendedor_consecutivo`
--

CREATE TABLE `vendedor_consecutivo` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nada` char(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=latin1;

--
-- Final view structure for view `api_estado`
--

/*!50001 DROP VIEW IF EXISTS `api_estado`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `api_estado` AS select `estado`.`id` AS `id`,`estado`.`nombre` AS `nombre` from `estado` */;

--
-- Final view structure for view `api_sucursal`
--

/*!50001 DROP VIEW IF EXISTS `api_sucursal`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `api_sucursal` AS select `estacion`.`codi_esta` AS `codigo`,`estacion`.`desc_esta` AS `nombre`,`estacion`.`dire_mail` AS `email`,if((`estacion`.`area_metropolitana` = 1),'SI','NO') AS `area_metropolitana`,`estacion`.`zonas_nc` AS `zonas_no_cubiertas`,`estacion`.`frecuencia_de_cobertura` AS `frecuencia_de_cobertura`,replace(`estado`.`nombre`,'ESTADO ','') AS `estado` from (`estacion` join `estado` on((`estacion`.`estado_id` = `estado`.`id`))) where ((`estacion`.`codi_stat` = 1) and (`estacion`.`es_un_almacen` = 0) and (`estacion`.`codi_esta` <> 'SMG')) */;

--
-- Final view structure for view `v_facturado_en_tiendas`
--

/*!50001 DROP VIEW IF EXISTS `v_facturado_en_tiendas`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_facturado_en_tiendas` AS select `f`.`creada_el` AS `fecha_factura`,count(0) AS `cantidad_facturas`,sum(`f`.`monto_total`) AS `total_facturado` from ((`factura_pmn` `f` join `guia` `g` on((`f`.`id` = `g`.`factura_id`))) join `usuario` `u` on((`u`.`codi_usua` = `f`.`creada_por`))) where ((`f`.`estatus` <> 'A') and (`f`.`creada_el` >= (curdate() - interval 10 day)) and (`f`.`creada_el` <= curdate())) group by `f`.`creada_el` */;

--
-- Final view structure for view `v_fecha_ultima_guia`
--

/*!50001 DROP VIEW IF EXISTS `v_fecha_ultima_guia`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_fecha_ultima_guia` AS select `master_cliente`.`codi_clie` AS `codi_clie`,(select max(`guia`.`fech_guia`) from `guia` where (`guia`.`codi_clie` = `master_cliente`.`codi_clie`)) AS `ultima_fecha` from `master_cliente` */;

--
-- Final view structure for view `v_rank_clientes_facturado`
--

/*!50001 DROP VIEW IF EXISTS `v_rank_clientes_facturado`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_rank_clientes_facturado` AS select `master_cliente`.`codi_clie` AS `id`,`master_cliente`.`nomb_clie` AS `razon_social`,sum(`consumo_mes`.`total_facturado`) AS `total_facturado` from (`consumo_mes` join `master_cliente` on((`consumo_mes`.`cliente_id` = `master_cliente`.`codi_clie`))) where ((`consumo_mes`.`cliente_id` not in (2535,1382)) and (`consumo_mes`.`anio` >= year((curdate() - interval 365 day))) and (`consumo_mes`.`mes` >= month((curdate() - interval 365 day)))) group by `master_cliente`.`codi_clie`,`master_cliente`.`nomb_clie` order by `total_facturado` limit 100 */;

--
-- Final view structure for view `v_rank_clientes_kilos`
--

/*!50001 DROP VIEW IF EXISTS `v_rank_clientes_kilos`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_rank_clientes_kilos` AS select `master_cliente`.`codi_clie` AS `id`,`master_cliente`.`nomb_clie` AS `razon_social`,sum(`consumo_mes`.`cantidad_kilos`) AS `cantidad_kilos` from (`consumo_mes` join `master_cliente` on((`consumo_mes`.`cliente_id` = `master_cliente`.`codi_clie`))) where ((`consumo_mes`.`cliente_id` not in (2535,1382)) and (`consumo_mes`.`anio` >= year((curdate() - interval 365 day))) and (`consumo_mes`.`mes` >= month((curdate() - interval 365 day)))) group by `master_cliente`.`codi_clie`,`master_cliente`.`nomb_clie` order by `cantidad_kilos` limit 100 */;

--
-- Final view structure for view `v_ranking`
--

/*!50001 DROP VIEW IF EXISTS `v_ranking`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_ranking` AS select (select count(distinct `b`.`id`) from `v_ranking_clientes` `b` where (`b`.`cantidad_guias` >= `a`.`cantidad_guias`)) AS `rnk`,`a`.`id` AS `id`,`a`.`razon_social` AS `razon_social`,`a`.`cantidad_guias` AS `cantidad_guias` from `v_ranking_clientes` `a` */;

--
-- Final view structure for view `v_ranking_clientes`
--

/*!50001 DROP VIEW IF EXISTS `v_ranking_clientes`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_ranking_clientes` AS select `master_cliente`.`codi_clie` AS `id`,`master_cliente`.`nomb_clie` AS `razon_social`,sum(`consumo_mes`.`cantidad_guias`) AS `cantidad_guias` from (`consumo_mes` join `master_cliente` on((`consumo_mes`.`cliente_id` = `master_cliente`.`codi_clie`))) where ((`consumo_mes`.`cliente_id` not in (2535,1382)) and (`consumo_mes`.`anio` >= year((curdate() - interval 365 day))) and (`consumo_mes`.`mes` >= month((curdate() - interval 365 day)))) group by `master_cliente`.`codi_clie`,`master_cliente`.`nomb_clie` order by `cantidad_guias` limit 100 */;

--
-- Final view structure for view `v_ranking_facturado`
--

/*!50001 DROP VIEW IF EXISTS `v_ranking_facturado`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_ranking_facturado` AS select (select count(distinct `b`.`id`) from `v_rank_clientes_facturado` `b` where (`b`.`total_facturado` >= `a`.`total_facturado`)) AS `rnk`,`a`.`id` AS `id`,`a`.`razon_social` AS `razon_social`,`a`.`total_facturado` AS `total_facturado` from `v_rank_clientes_facturado` `a` */;

--
-- Final view structure for view `v_ranking_kilos`
--

/*!50001 DROP VIEW IF EXISTS `v_ranking_kilos`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_ranking_kilos` AS select (select count(distinct `b`.`id`) from `v_rank_clientes_kilos` `b` where (`b`.`cantidad_kilos` >= `a`.`cantidad_kilos`)) AS `rnk`,`a`.`id` AS `id`,`a`.`razon_social` AS `razon_social`,`a`.`cantidad_kilos` AS `cantidad_kilos` from `v_rank_clientes_kilos` `a` */;

--
-- Final view structure for view `v_resumen_consumo_mes`
--

/*!50001 DROP VIEW IF EXISTS `v_resumen_consumo_mes`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_resumen_consumo_mes` AS select `consumo_mes`.`anio` AS `anio`,`consumo_mes`.`mes` AS `mes`,sum(`consumo_mes`.`cantidad_guias`) AS `cantidad_guias` from `consumo_mes` group by `consumo_mes`.`anio`,`consumo_mes`.`mes` */;

--
-- Final view structure for view `v_resumen_consumo_mes_corp`
--

/*!50001 DROP VIEW IF EXISTS `v_resumen_consumo_mes_corp`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_resumen_consumo_mes_corp` AS select `consumo_mes`.`anio` AS `anio`,`consumo_mes`.`mes` AS `mes`,sum(`consumo_mes`.`cantidad_guias`) AS `cantidad_guias` from `consumo_mes` where (`consumo_mes`.`cliente_id` <> 1605) group by `consumo_mes`.`anio`,`consumo_mes`.`mes` */;

--
-- Final view structure for view `v_resumen_consumo_mes_expr`
--

/*!50001 DROP VIEW IF EXISTS `v_resumen_consumo_mes_expr`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_resumen_consumo_mes_expr` AS select `consumo_mes`.`anio` AS `anio`,`consumo_mes`.`mes` AS `mes`,sum(`consumo_mes`.`cantidad_guias`) AS `cantidad_guias` from `consumo_mes` where (`consumo_mes`.`cliente_id` = 1605) group by `consumo_mes`.`anio`,`consumo_mes`.`mes` */;

--
-- Final view structure for view `v_sin_datos_fiscales`
--

/*!50001 DROP VIEW IF EXISTS `v_sin_datos_fiscales`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_sin_datos_fiscales` AS select `f`.`id` AS `id`,`i`.`guia_id` AS `guia_id`,`f`.`creada_el` AS `creada_el`,`u`.`logi_usua` AS `logi_usua`,`g`.`esta_orig` AS `esta_orig`,`g`.`receptoria_origen` AS `receptoria_origen`,`g`.`esta_dest` AS `esta_dest`,`g`.`receptoria_destino` AS `receptoria_destino`,`f`.`cedula_rif` AS `cedula_rif`,`f`.`razon_social` AS `razon_social`,`f`.`monto_total` AS `monto_total`,`f`.`creada_por` AS `creada_por` from (((`factura_pmn` `f` join `item_factura_pmn` `i` on((`f`.`id` = `i`.`factura_id`))) join `guia` `g` on((`i`.`guia_id` = `g`.`nume_guia`))) join `usuario` `u` on((`f`.`creada_por` = `u`.`codi_usua`))) where (isnull(`f`.`fecha_impresion`) and isnull(`f`.`anulada_el`) and (`f`.`creada_el` >= (curdate() - interval 30 day)) and exists(select NULL from `pago_factura_pmn` `p` where (`p`.`factura_id` = `f`.`id`))) order by `f`.`creada_el` desc */;


