-- MySQL dump 10.13  Distrib 8.0.36, for Linux (x86_64)
--
-- Host: localhost    Database: AppDTEApi
-- ------------------------------------------------------
-- Server version	8.0.46-0ubuntu0.24.04.3

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `CAF`
--

DROP TABLE IF EXISTS `CAF`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `CAF` (
  `idCAF` int NOT NULL AUTO_INCREMENT,
  `empresa_id` int DEFAULT NULL,
  `TipoDocumentoId` int DEFAULT NULL,
  `TipoCAF` int DEFAULT NULL,
  `Desde` int DEFAULT NULL,
  `Hasta` int DEFAULT NULL,
  `contenido_caf` blob,
  `sha256` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`idCAF`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `CAF`
--

LOCK TABLES `CAF` WRITE;
/*!40000 ALTER TABLE `CAF` DISABLE KEYS */;
/*!40000 ALTER TABLE `CAF` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `TipoDocumentos`
--

DROP TABLE IF EXISTS `TipoDocumentos`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `TipoDocumentos` (
  `TipoDocumentoId` int unsigned NOT NULL AUTO_INCREMENT,
  `TipoDocumentoDes` varchar(45) NOT NULL DEFAULT '',
  `DTE` int unsigned NOT NULL DEFAULT '1',
  `CodigoSii` int unsigned NOT NULL DEFAULT '0',
  `NOTACION` varchar(45) DEFAULT NULL,
  `StockInOut` int DEFAULT '0',
  PRIMARY KEY (`TipoDocumentoId`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `TipoDocumentos`
--

LOCK TABLES `TipoDocumentos` WRITE;
/*!40000 ALTER TABLE `TipoDocumentos` DISABLE KEYS */;
INSERT INTO `TipoDocumentos` VALUES (1,'FACTURA DE COMPRA ELECTRONICA',1,46,NULL,0),(2,'GUIA DESPACHO ELECTRONICA',1,52,NULL,1),(3,'FACTURA ELECTRONICA',1,33,NULL,1),(4,'NOTA DE CREDITO ELECTRONICA',1,61,NULL,0),(5,'FACTURA EXENTA ELECTRONICA',1,34,NULL,1),(6,'NOTA DEBITO ELECTRONICA',1,56,NULL,1),(7,'FACTURA DE COMPRA',1,45,NULL,1),(8,'FACTURA',1,30,NULL,1),(9,'NOTA DE CREDITO',1,60,NULL,1),(10,'BOLETA ELECTRONICA',1,39,NULL,1),(11,'ORDEN DE COMPRA',1,801,NULL,1),(12,'CARGA STOCK',0,0,'addSTOCK',0),(13,'SALIDA STOCK',0,0,'lowSTOCK',0),(14,'NOTA DE PEDIDO',1,802,NULL,1),(15,'REGISTRO MERMA',0,0,'MERMA',1);
/*!40000 ALTER TABLE `TipoDocumentos` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `empresa`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `empresa` (
  `empresa_id` int NOT NULL AUTO_INCREMENT,
  `empresa_rut` varchar(45) DEFAULT NULL,
  `empresa_raz` varchar(45) DEFAULT NULL,
  `estado_habilitado` int DEFAULT NULL,
  `limite_request` int DEFAULT '3600',
  `limite_dte` int DEFAULT '3600',
  `nro_resolucion_sii` int DEFAULT NULL,
  `fecha_resolucion_sii` varchar(45) DEFAULT NULL,
  `rut_receptor_caratula` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`empresa_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `empresa`
--

LOCK TABLES `empresa` WRITE;
/*!40000 ALTER TABLE `empresa` DISABLE KEYS */;
/*!40000 ALTER TABLE `empresa` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `estado_documento`
--

DROP TABLE IF EXISTS `estado_documento`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `estado_documento` (
  `id` int NOT NULL,
  `codigo` varchar(30) NOT NULL,
  `descripcion` varchar(255) NOT NULL,
  `activo` tinyint(1) NOT NULL DEFAULT '1',
  `orden` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `codigo` (`codigo`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `estado_documento`
--

LOCK TABLES `estado_documento` WRITE;
/*!40000 ALTER TABLE `estado_documento` DISABLE KEYS */;
/*!40000 ALTER TABLE `estado_documento` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `historial_dte`
--

DROP TABLE IF EXISTS `historial_dte`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `historial_dte` (
  `envio_id` int NOT NULL AUTO_INCREMENT,
  `hora_envio` time DEFAULT NULL,
  `fecha_envio` date DEFAULT NULL,
  `track_id` bigint unsigned NOT NULL,
  `empresa_id` int DEFAULT NULL,
  `usuario_id` int DEFAULT NULL,
  `periodo_id` int DEFAULT NULL,
  `envdteBase64` blob,
  `sha256` varchar(64) DEFAULT NULL,
  `FolioDTE` int DEFAULT NULL,
  `TipoDocumentoId` int DEFAULT NULL,
  `tiempo_envio` double DEFAULT NULL,
  PRIMARY KEY (`envio_id`)
) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `historial_dte`
--

LOCK TABLES `historial_dte` WRITE;
/*!40000 ALTER TABLE `historial_dte` DISABLE KEYS */;
/*!40000 ALTER TABLE `historial_dte` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `historial_endpoint`
--

DROP TABLE IF EXISTS `historial_endpoint`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `historial_endpoint` (
  `id` int NOT NULL AUTO_INCREMENT,
  `fecha_creacion` date DEFAULT NULL,
  `empresa_id` int DEFAULT NULL,
  `usuario_id` int DEFAULT NULL,
  `endpoint` varchar(45) DEFAULT NULL,
  `periodo_id` varchar(45) DEFAULT NULL,
  `hora_creacion` time DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=266 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `historial_endpoint`
--

LOCK TABLES `historial_endpoint` WRITE;
/*!40000 ALTER TABLE `historial_endpoint` DISABLE KEYS */;
INSERT INTO `historial_endpoint` VALUES (231,'2026-05-06',1,15,'/api/login','4','11:57:43','127.0.0.1'),(232,'2026-05-06',1,15,'/api/login','4','11:58:36','127.0.0.1'),(233,'2026-05-06',1,15,'/api/login','4','12:04:21','127.0.0.1'),(234,'2026-05-06',1,15,'/api/login','4','12:04:41','127.0.0.1'),(235,'2026-05-06',1,15,'/api/login','4','12:05:44','127.0.0.1'),(236,'2026-05-06',1,15,'/api/login','4','12:06:09','127.0.0.1'),(237,'2026-05-06',1,15,'/api/login','4','12:09:45','127.0.0.1'),(238,'2026-05-06',1,15,'/api/login','4','14:16:57','127.0.0.1'),(239,'2026-05-06',1,15,'/api/sendDTE','4','14:17:25','127.0.0.1'),(240,'2026-05-06',1,15,'/api/getDTE','4','14:26:10','127.0.0.1'),(241,'2026-05-07',1,15,'/api/login','4','21:34:46','127.0.0.1'),(242,'2026-05-08',1,15,'/api/login','4','12:34:34','127.0.0.1'),(243,'2026-05-08',1,15,'/api/login','4','12:35:17','127.0.0.1'),(244,'2026-05-08',1,15,'/api/getDTE','4','12:36:06','127.0.0.1'),(245,'2026-05-08',1,15,'/api/getDTE','4','12:36:31','127.0.0.1'),(246,'2026-05-08',1,15,'/api/getDTE','4','12:41:46','127.0.0.1'),(247,'2026-05-08',1,15,'/api/getDTE','4','12:42:44','127.0.0.1'),(248,'2026-05-08',1,15,'/api/getDTE','4','12:42:54','127.0.0.1'),(249,'2026-05-08',1,15,'/api/getDTE','4','12:43:10','127.0.0.1'),(250,'2026-05-08',1,15,'/api/getDTE','4','12:43:21','127.0.0.1'),(251,'2026-05-08',1,15,'/api/getDTE','4','12:44:11','127.0.0.1'),(252,'2026-05-08',1,15,'/api/getDTE','4','12:46:44','127.0.0.1'),(253,'2026-05-08',1,15,'/api/getDTE','4','12:47:45','127.0.0.1'),(254,'2026-05-08',1,15,'/api/getDTE','4','12:48:32','127.0.0.1'),(255,'2026-05-08',1,15,'/api/getDTE','4','12:50:25','127.0.0.1'),(256,'2026-05-08',1,15,'/api/getDTE','4','12:51:50','127.0.0.1'),(257,'2026-05-08',1,15,'/api/getDTE','4','12:52:40','127.0.0.1'),(258,'2026-05-08',1,15,'/api/getDTE','4','12:54:08','127.0.0.1'),(259,'2026-05-08',1,15,'/api/getDTE','4','12:56:02','127.0.0.1'),(260,'2026-05-08',1,15,'/api/getDTE','4','13:04:17','127.0.0.1'),(261,'2026-05-08',1,15,'/api/getDTE','4','13:09:06','127.0.0.1'),(262,'2026-05-08',1,15,'/api/getDTE','4','13:09:30','127.0.0.1'),(263,'2026-05-08',1,15,'/api/getDTE','4','13:10:34','127.0.0.1'),(264,'2026-05-08',1,15,'/api/getDTE','4','13:16:37','127.0.0.1'),(265,'2026-07-30',1,15,'/api/login','5','09:55:15','127.0.0.1');
/*!40000 ALTER TABLE `historial_endpoint` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `job_dte`
--

DROP TABLE IF EXISTS `job_dte`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `job_dte` (
  `job_id` int NOT NULL AUTO_INCREMENT,
  `empresa_id` int DEFAULT NULL,
  `usuario_id` varchar(45) DEFAULT NULL,
  `folio_dte` int DEFAULT NULL,
  `dte_json` text,
  `TipoDocumentoId` varchar(45) DEFAULT NULL,
  `hora_envio` time DEFAULT NULL,
  `fecha_envio` date DEFAULT NULL,
  `estado_proceso` int DEFAULT NULL,
  `track_id` bigint DEFAULT NULL,
  PRIMARY KEY (`job_id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `job_dte`
--

LOCK TABLES `job_dte` WRITE;
/*!40000 ALTER TABLE `job_dte` DISABLE KEYS */;
/*!40000 ALTER TABLE `job_dte` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `periodo`
--

DROP TABLE IF EXISTS `periodo`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `periodo` (
  `periodo_id` int NOT NULL AUTO_INCREMENT,
  `empresa_id` int DEFAULT NULL,
  `periodo` varchar(45) DEFAULT NULL,
  `cantidad_dte` int DEFAULT '0',
  `cantidad_request` int DEFAULT '0',
  PRIMARY KEY (`periodo_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `periodo`
--

LOCK TABLES `periodo` WRITE;
/*!40000 ALTER TABLE `periodo` DISABLE KEYS */;
/*!40000 ALTER TABLE `periodo` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `usuarios`
--

DROP TABLE IF EXISTS `usuarios`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `usuarios` (
  `usuario_id` int NOT NULL AUTO_INCREMENT,
  `username` varchar(45) DEFAULT NULL,
  `password` longtext,
  `fecha_creacion` datetime DEFAULT NULL,
  `jwt_secret_b64` longtext,
  `token_expires` longtext,
  `token_value` longtext,
  `empresa_id` int DEFAULT NULL,
  `certBase64` blob,
  `claveFirma` varchar(45) DEFAULT NULL,
  `usuario_rut` varchar(45) DEFAULT NULL,
  `usuario_nombres` varchar(45) DEFAULT NULL,
  `usuario_apellidos` varchar(45) DEFAULT NULL,
  `estado` int DEFAULT NULL,
  `token_dte` varchar(45) DEFAULT NULL,
  `token_boleta` varchar(45) DEFAULT NULL,
  `estado_habilitado` int DEFAULT NULL,
  `sha256` varchar(64) DEFAULT NULL,
  `upload_caf` int DEFAULT '0',
  `delete_caf` int DEFAULT '0',
  PRIMARY KEY (`usuario_id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `usuarios`
--

LOCK TABLES `usuarios` WRITE;
/*!40000 ALTER TABLE `usuarios` DISABLE KEYS */;
/*!40000 ALTER TABLE `usuarios` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2026-08-02 23:32:00
