--
-- Host: localhost    Database: facturaciondb
-- ------------------------------------------------------


--
-- Table structure for table `campoadicional`
--

CREATE TABLE `campoadicional` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
  `valor` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `Factura_id` int(11) DEFAULT NULL,
  `NotaCredito_id` int(11) DEFAULT NULL,
  `NotaDebito_id` int(11) DEFAULT NULL,
  `Retencion_id` int(11) DEFAULT NULL,
  `Guia_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_D7FF66CFBF127A8F` (`Factura_id`),
  KEY `IDX_D7FF66CF51CA559D` (`NotaCredito_id`),
  KEY `IDX_D7FF66CFBCB7242D` (`NotaDebito_id`),
  KEY `IDX_D7FF66CF6A1F1F62` (`Retencion_id`),
  KEY `IDX_D7FF66CFC9979183` (`Guia_id`),
  CONSTRAINT `FK_D7FF66CF51CA559D` FOREIGN KEY (`NotaCredito_id`) REFERENCES `notacredito` (`id`),
  CONSTRAINT `FK_D7FF66CF6A1F1F62` FOREIGN KEY (`Retencion_id`) REFERENCES `retencion` (`id`),
  CONSTRAINT `FK_D7FF66CFBCB7242D` FOREIGN KEY (`NotaDebito_id`) REFERENCES `notadebito` (`id`),
  CONSTRAINT `FK_D7FF66CFBF127A8F` FOREIGN KEY (`Factura_id`) REFERENCES `factura` (`id`),
  CONSTRAINT `FK_D7FF66CFC9979183` FOREIGN KEY (`Guia_id`) REFERENCES `guia` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `campoadicional`
--


--
-- Table structure for table `cliente`
--

CREATE TABLE `cliente` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `emisor_id` int(11) NOT NULL,
  `nombre` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `tipoIdentificacion` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
  `identificacion` varchar(25) COLLATE utf8_unicode_ci NOT NULL,
  `direccion` longtext COLLATE utf8_unicode_ci,
  `celular` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `correoElectronico` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_3BA1A2B96BDF87DF` (`emisor_id`),
  KEY `IDX_3BA1A2B93174800F` (`createdBy_id`),
  KEY `IDX_3BA1A2B965FF1AEC` (`updatedBy_id`),
  KEY `IDX_3BA1A2B963D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_3BA1A2B93174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_3BA1A2B963D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_3BA1A2B965FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_3BA1A2B96BDF87DF` FOREIGN KEY (`emisor_id`) REFERENCES `emisor` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `cliente`
--

INSERT INTO `cliente` VALUES (5,2,'James Pesantes','05','0930756887','Guasmo Sur Coop. Unión de Bananeros','0961614113','james.pesantes@hotmail.com','2019-03-22 04:18:18','2019-03-22 04:18:18',5,5,NULL),(6,2,'James Pesantes','04','0930756887001','Guasmo Sur Coop. Unión de Bananeros','','james.pesantes@hotmail.com','2019-03-31 22:02:36','2019-03-31 22:02:36',7,7,NULL),(7,2,'AIRON YOHAN MALDONADO RONDERO','05','0961277621','La 39 y ch','0980642760','amaldonado@saizetecnology.com','2019-05-13 22:57:44','2019-05-13 22:57:44',7,7,NULL),(8,2,'Ascencio Rivera Segundo Felipez','04','0905039780001','Barrio Virgen del Rosario, Comuna Jambelí sn carretero principal','0991141087','pescadosymariscos1955@hotmail.com','2019-06-20 21:46:34','2019-06-20 21:46:34',5,5,NULL),(9,2,'Michel Vidal Pinargote','05','0929509263','guamo sur','0991141087','michaelvidalp@hotmail.com','2019-06-20 21:48:32','2019-06-20 21:55:28',5,7,NULL);

--
-- Table structure for table `detalleadicional`
--

CREATE TABLE `detalleadicional` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
  `valor` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `facturaHasProducto_id` int(11) DEFAULT NULL,
  `notaCreditoHasProducto_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_87797196CE7FF8C7` (`facturaHasProducto_id`),
  KEY `IDX_8779719698D062E6` (`notaCreditoHasProducto_id`),
  CONSTRAINT `FK_8779719698D062E6` FOREIGN KEY (`notaCreditoHasProducto_id`) REFERENCES `notacreditohasproducto` (`id`),
  CONSTRAINT `FK_87797196CE7FF8C7` FOREIGN KEY (`facturaHasProducto_id`) REFERENCES `facturahasproducto` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `detalleadicional`
--


--
-- Table structure for table `emisor`
--

CREATE TABLE `emisor` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ruc` varchar(13) COLLATE utf8_unicode_ci NOT NULL,
  `ambiente` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  `tipoEmision` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  `razonSocial` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `nombreComercial` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL,
  `direccionMatriz` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `contribuyenteEspecial` varchar(13) COLLATE utf8_unicode_ci DEFAULT NULL,
  `obligadoContabilidad` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
  `dirLogo` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
  `dirFirma` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
  `dirDocAutorizados` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
  `passFirma` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `servidorCorreo` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
  `correoRemitente` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `passCorreo` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `puerto` int(11) NOT NULL,
  `SSLHabilitado` tinyint(1) DEFAULT NULL,
  `activo` tinyint(1) DEFAULT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_C30280783174800F` (`createdBy_id`),
  KEY `IDX_C302807865FF1AEC` (`updatedBy_id`),
  KEY `IDX_C302807863D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_C30280783174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_C302807863D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_C302807865FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `emisor`
--

INSERT INTO `emisor` VALUES (2,'0930756887001','2','1','JAMES ROGGER PESANTES PIGUAVE','SAIZE TECNOLOGY','GUASMO SUR COOP UNION DE BANANEROS BL 3 MZ 617 SL 8',NULL,'NO','C:\\FactelWebCliente\\demo/41546017_556046851517644_5632221169089249280_n.png','C:\\FactelWebCliente\\demo/james_rogger_pesantes_piguave.p12','C:\\FactelWebCliente\\demo','James1973','smtp.gmail.com','james.pesantes.piguave@gmail.com','197346825',465,1,1,'2018-11-21 14:33:14','2019-05-13 22:55:03',5,5,NULL);

--
-- Table structure for table `establecimiento`
--

CREATE TABLE `establecimiento` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `emisor_id` int(11) NOT NULL,
  `nombre` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
  `codigo` varchar(3) COLLATE utf8_unicode_ci NOT NULL,
  `urlweb` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `nombreComercial` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `direccion` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) DEFAULT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  `dirLogo` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_1C61EFE06BDF87DF` (`emisor_id`),
  KEY `IDX_1C61EFE03174800F` (`createdBy_id`),
  KEY `IDX_1C61EFE065FF1AEC` (`updatedBy_id`),
  KEY `IDX_1C61EFE063D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_1C61EFE03174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_1C61EFE063D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_1C61EFE065FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_1C61EFE06BDF87DF` FOREIGN KEY (`emisor_id`) REFERENCES `emisor` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `establecimiento`
--

INSERT INTO `establecimiento` VALUES (3,2,'MATRIZ','001',NULL,'SAIZE TECNOLOGY','GUASMO SUR COOP UNION DE BANANEROS BL 3 MZ 617 SL 8',1,'2018-11-21 14:34:22','2019-06-20 22:53:11',5,5,NULL,NULL);

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

CREATE TABLE `factura` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `cliente_id` int(11) NOT NULL,
  `emisor_id` int(11) NOT NULL,
  `establecimiento_id` int(11) NOT NULL,
  `claveAcceso` varchar(49) COLLATE utf8_unicode_ci NOT NULL,
  `numeroAutorizacion` varchar(49) COLLATE utf8_unicode_ci DEFAULT NULL,
  `fechaAutorizacion` datetime DEFAULT NULL,
  `estado` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `ambiente` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  `tipoEmision` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `secuencial` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
  `formaPago` varchar(4) COLLATE utf8_unicode_ci NOT NULL,
  `fechaEmision` date NOT NULL,
  `nombreArchivo` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
  `totalSinImpuestos` decimal(10,2) NOT NULL,
  `subtotal12` decimal(10,2) NOT NULL,
  `subtotal0` decimal(10,2) NOT NULL,
  `subtotalNoIVA` decimal(10,2) NOT NULL,
  `subtotalExentoIVA` decimal(10,2) NOT NULL,
  `valorICE` decimal(10,2) NOT NULL,
  `valorIRBPNR` decimal(10,2) NOT NULL,
  `iva12` decimal(10,2) NOT NULL,
  `totalDescuento` decimal(10,2) NOT NULL,
  `propina` decimal(10,2) NOT NULL,
  `valorTotal` decimal(10,2) NOT NULL,
  `firmado` tinyint(1) NOT NULL,
  `enviarSiAutorizado` tinyint(1) NOT NULL,
  `observacion` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `ptoEmision_id` int(11) NOT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_36569995DE734E51` (`cliente_id`),
  KEY `IDX_365699956BDF87DF` (`emisor_id`),
  KEY `IDX_3656999571B61351` (`establecimiento_id`),
  KEY `IDX_36569995E01B1B5E` (`ptoEmision_id`),
  KEY `IDX_365699953174800F` (`createdBy_id`),
  KEY `IDX_3656999565FF1AEC` (`updatedBy_id`),
  KEY `IDX_3656999563D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_365699953174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_3656999563D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_3656999565FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_365699956BDF87DF` FOREIGN KEY (`emisor_id`) REFERENCES `emisor` (`id`),
  CONSTRAINT `FK_3656999571B61351` FOREIGN KEY (`establecimiento_id`) REFERENCES `establecimiento` (`id`),
  CONSTRAINT `FK_36569995DE734E51` FOREIGN KEY (`cliente_id`) REFERENCES `cliente` (`id`),
  CONSTRAINT `FK_36569995E01B1B5E` FOREIGN KEY (`ptoEmision_id`) REFERENCES `ptoemision` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `factura`
--

INSERT INTO `factura` VALUES (14,5,2,3,'2103201901171331809300110010010000305001234567811','2103201901171331809300110010010000305001234567811','2019-03-21 10:22:41','AUTORIZADO','1','1','000030500','20','2019-03-21','FAC001-001-000030500',70.50,70.50,0.00,0.00,0.00,0.00,0.00,8.46,5.00,0.00,78.96,1,0,'Prueba 1 de factura sistema web','2019-03-22 04:21:50','2019-03-22 04:22:44',3,7,7,NULL),(15,5,2,3,'2203201901171331809300110010010000305011234567811','2203201901171331809300110010010000305011234567811','2019-03-22 08:53:37','AUTORIZADO','1','1','000030501','01','2019-03-22','FAC001-001-000030501',39.00,39.00,0.00,0.00,0.00,0.00,0.00,4.68,3.25,0.00,43.68,1,0,'pago en cheque','2019-03-23 02:53:19','2019-03-23 02:53:40',3,7,7,NULL),(16,5,2,3,'2203201901093075688700110010010000305021234567812',NULL,NULL,'ERROR','1','1','000030502','01','2019-03-22',NULL,10.15,10.15,0.00,0.00,0.00,0.00,0.00,1.22,0.00,0.00,11.37,0,0,'fdsafddfs','2019-03-23 03:02:22','2019-03-23 03:02:29',3,7,7,NULL),(17,5,2,3,'2203201901171331809300110010010000305031234567812',NULL,NULL,'ERROR','1','1','000030503','01','2019-03-22',NULL,5.56,5.56,0.00,0.00,0.00,0.00,0.00,0.67,0.00,0.00,6.23,0,0,'cualquoeijore','2019-03-23 03:15:06','2019-03-23 03:15:13',3,7,7,NULL),(18,6,2,3,'3103201901171331809300110010010000305041234567817',NULL,NULL,'ERROR','1','1','000030504','01','2019-03-31',NULL,5.56,5.56,0.00,0.00,0.00,0.00,0.00,0.67,0.00,0.00,6.23,0,0,'weferafes','2019-03-31 22:02:37','2019-03-31 22:02:45',3,7,7,NULL),(19,5,2,3,'0703201901171331809300110010010000305051234567819',NULL,NULL,'ERROR','1','1','000030505','01','2019-03-07',NULL,25.16,25.16,0.00,0.00,0.00,0.00,0.00,3.02,0.00,0.00,28.18,0,0,'fsdfasdfds','2019-03-31 22:59:41','2019-03-31 22:59:54',3,7,7,NULL),(20,5,2,3,'3103201901171331809300110010010000305061234567818',NULL,NULL,'ERROR','1','1','000030506','01','2019-03-31',NULL,10.15,10.15,0.00,0.00,0.00,0.00,0.00,1.22,0.00,0.00,11.37,0,0,'fsasfd','2019-03-31 23:09:16','2019-03-31 23:09:36',3,7,7,NULL),(21,5,2,3,'3103201901171331809300110010010000305071234567813',NULL,NULL,'ERROR','1','1','000030507','20','2019-03-31',NULL,10.15,10.15,0.00,0.00,0.00,0.00,0.00,1.22,0.00,0.00,11.37,0,0,'fsafdafds','2019-03-31 23:40:25','2019-03-31 23:40:33',3,7,7,NULL),(22,5,2,3,'0104201901171331809300110010010000305081234567814','0104201901171331809300110010010000305081234567814','2019-04-01 05:32:57','AUTORIZADO','1','1','000030508','01','2019-04-01','FAC001-001-000030508',5.56,5.56,0.00,0.00,0.00,0.00,0.00,0.67,0.00,0.00,6.23,1,0,'sdfasdfdf','2019-04-02 00:24:57','2019-04-02 00:32:58',3,7,7,NULL),(23,7,2,3,'1305201901093075688700110010010000305091234567814','1305201901093075688700110010010000305091234567814','2019-05-13 03:58:03','AUTORIZADO','1','1','000030509','20','2019-05-13','FAC001-001-000030509',25.16,25.16,0.00,0.00,0.00,0.00,0.00,3.02,0.00,0.00,28.18,1,0,'prueba','2019-05-13 22:57:44','2019-05-13 22:58:06',3,7,7,NULL),(24,9,2,3,'2006201901093075688700110010010000305101234567816','2006201901093075688700110010010000305101234567816','2019-06-20 02:55:49','AUTORIZADO','1','1','000030510','20','2019-06-20','FAC001-001-000030510',700.00,700.00,0.00,0.00,0.00,0.00,0.00,84.00,0.00,0.00,784.00,1,0,'Prueba saize Factura.','2019-06-20 21:55:28','2019-06-20 21:55:50',3,7,7,NULL),(25,7,2,3,'2006201901093075688700110010010000305111234567811','2006201901093075688700110010010000305111234567811','2019-06-20 02:57:43','AUTORIZADO','1','1','000030511','20','2019-06-20','FAC001-001-000030511',700.00,700.00,0.00,0.00,0.00,0.00,0.00,84.00,0.00,0.00,784.00,1,0,'prueba','2019-06-20 21:57:31','2019-06-20 21:57:44',3,7,7,NULL),(26,8,2,3,'2006201901093075688700129999990000305121234567810',NULL,'2019-06-20 03:11:56','NO AUTORIZADO','2','1','000030512','20','2019-06-20',NULL,650.00,650.00,0.00,0.00,0.00,0.00,0.00,78.00,0.00,0.00,728.00,1,1,'Desarrollo de página web, catálogo autoadministrable empresa Ecuafeed','2019-06-20 22:11:15','2019-06-20 22:11:57',3,7,7,NULL),(27,8,2,3,'2006201901093075688700120012000000000011234567811','2006201901093075688700120012000000000011234567811','2019-06-20 04:13:00','AUTORIZADO','2','1','000000001','20','2019-06-20','FAC001-200-000000001',650.00,650.00,0.00,0.00,0.00,0.00,0.00,78.00,0.00,0.00,728.00,1,1,'Desarrollo de página web, catálogo autoadministrable empresa Ecuafeed','2019-06-20 23:12:15','2019-06-20 23:13:28',3,7,7,NULL),(28,8,2,3,'2006201901093075688700120012000000000021234567815','2006201901093075688700120012000000000021234567815','2019-06-20 04:15:11','AUTORIZADO','2','1','000000002','20','2019-06-20','FAC001-200-000000002',50.00,50.00,0.00,0.00,0.00,0.00,0.00,6.00,0.00,0.00,56.00,1,0,'Dominio con extensión .ec      www.ecuafeed.ec','2019-06-20 23:14:57','2019-06-20 23:15:12',3,7,7,NULL);

--
-- Table structure for table `facturahasproducto`
--

CREATE TABLE `facturahasproducto` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `producto_id` int(11) NOT NULL,
  `factura_id` int(11) NOT NULL,
  `cantidad` decimal(10,2) NOT NULL,
  `nombre` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `codigoProducto` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `precioUnitario` decimal(10,2) NOT NULL,
  `descuento` decimal(10,2) NOT NULL,
  `valorTotal` decimal(10,2) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_1CFCFE017645698E` (`producto_id`),
  KEY `IDX_1CFCFE01F04F795F` (`factura_id`),
  CONSTRAINT `FK_1CFCFE017645698E` FOREIGN KEY (`producto_id`) REFERENCES `producto` (`id`),
  CONSTRAINT `FK_1CFCFE01F04F795F` FOREIGN KEY (`factura_id`) REFERENCES `factura` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `facturahasproducto`
--

INSERT INTO `facturahasproducto` VALUES (22,1,14,1.00,'SERVICIO DE CAMBIO DE ACEITE','001S',75.50,5.00,70.50),(23,4,15,1.00,'BOMBA DE GASOLINA','003P',42.25,3.25,39.00),(24,3,16,1.00,'FILTRO DE AIRE','002P',10.15,0.00,10.15),(25,2,17,1.00,'FILTRO DE GASOLINA','001P',5.56,0.00,5.56),(26,2,18,1.00,'FILTRO DE GASOLINA','001P',5.56,0.00,5.56),(27,1,19,1.00,'SERVICIO DE CAMBIO DE ACEITE','001S',25.16,0.00,25.16),(28,3,20,1.00,'FILTRO DE AIRE','002P',10.15,0.00,10.15),(29,3,21,1.00,'FILTRO DE AIRE','002P',10.15,0.00,10.15),(30,2,22,1.00,'FILTRO DE GASOLINA','001P',5.56,0.00,5.56),(31,1,23,1.00,'SERVICIO DE CAMBIO DE ACEITE','001S',25.16,0.00,25.16),(32,5,24,1.00,'Desarrollo de Página Web','001WEB',650.00,0.00,650.00),(33,6,24,1.00,'Hosting extensión .ec','002WEB',50.00,0.00,50.00),(34,5,25,1.00,'Desarrollo de Página Web','001WEB',650.00,0.00,650.00),(35,6,25,1.00,'Hosting extensión .ec','002WEB',50.00,0.00,50.00),(36,5,26,1.00,'Desarrollo de Página Web','001WEB',650.00,0.00,650.00),(37,5,27,1.00,'Desarrollo de Página Web','001WEB',650.00,0.00,650.00),(38,6,28,1.00,'Dominio extensión .ec','002WEB',50.00,0.00,50.00);

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

CREATE TABLE `guia` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `cliente_id` int(11) NOT NULL,
  `emisor_id` int(11) NOT NULL,
  `establecimiento_id` int(11) NOT NULL,
  `claveAcceso` varchar(49) COLLATE utf8_unicode_ci NOT NULL,
  `numeroAutorizacion` varchar(49) COLLATE utf8_unicode_ci DEFAULT NULL,
  `fechaAutorizacion` datetime DEFAULT NULL,
  `estado` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `ambiente` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  `tipoEmision` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `secuencial` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
  `nombreArchivo` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
  `dirPartida` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `razonSocialTransportista` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `rucTransportista` varchar(13) COLLATE utf8_unicode_ci NOT NULL,
  `fechaIniTransporte` date NOT NULL,
  `fechaFinTransporte` date NOT NULL,
  `placa` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
  `motivoTraslado` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `firmado` tinyint(1) NOT NULL,
  `enviarSiAutorizado` tinyint(1) NOT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `ptoEmision_id` int(11) NOT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_FB379403DE734E51` (`cliente_id`),
  KEY `IDX_FB3794036BDF87DF` (`emisor_id`),
  KEY `IDX_FB37940371B61351` (`establecimiento_id`),
  KEY `IDX_FB379403E01B1B5E` (`ptoEmision_id`),
  KEY `IDX_FB3794033174800F` (`createdBy_id`),
  KEY `IDX_FB37940365FF1AEC` (`updatedBy_id`),
  KEY `IDX_FB37940363D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_FB3794033174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_FB37940363D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_FB37940365FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_FB3794036BDF87DF` FOREIGN KEY (`emisor_id`) REFERENCES `emisor` (`id`),
  CONSTRAINT `FK_FB37940371B61351` FOREIGN KEY (`establecimiento_id`) REFERENCES `establecimiento` (`id`),
  CONSTRAINT `FK_FB379403DE734E51` FOREIGN KEY (`cliente_id`) REFERENCES `cliente` (`id`),
  CONSTRAINT `FK_FB379403E01B1B5E` FOREIGN KEY (`ptoEmision_id`) REFERENCES `ptoemision` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `guia`
--


--
-- Table structure for table `guiahasproducto`
--

CREATE TABLE `guiahasproducto` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `producto_id` int(11) NOT NULL,
  `guia_id` int(11) NOT NULL,
  `cantidad` decimal(10,2) NOT NULL,
  `nombre` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `codigoProducto` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_721B89A77645698E` (`producto_id`),
  KEY `IDX_721B89A762AA81F` (`guia_id`),
  CONSTRAINT `FK_721B89A762AA81F` FOREIGN KEY (`guia_id`) REFERENCES `guia` (`id`),
  CONSTRAINT `FK_721B89A77645698E` FOREIGN KEY (`producto_id`) REFERENCES `producto` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `guiahasproducto`
--


--
-- Table structure for table `impuesto`
--

CREATE TABLE `impuesto` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `codigo` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  `codigoPorcentaje` varchar(4) COLLATE utf8_unicode_ci NOT NULL,
  `tarifa` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
  `baseImponible` decimal(10,2) NOT NULL,
  `valor` decimal(10,2) NOT NULL,
  `facturaHasProducto_id` int(11) DEFAULT NULL,
  `notaCreditoHasProducto_id` int(11) DEFAULT NULL,
  `notaDebito_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_4F9058F7CE7FF8C7` (`facturaHasProducto_id`),
  KEY `IDX_4F9058F798D062E6` (`notaCreditoHasProducto_id`),
  KEY `IDX_4F9058F7FC96FD8` (`notaDebito_id`),
  CONSTRAINT `FK_4F9058F798D062E6` FOREIGN KEY (`notaCreditoHasProducto_id`) REFERENCES `notacreditohasproducto` (`id`),
  CONSTRAINT `FK_4F9058F7CE7FF8C7` FOREIGN KEY (`facturaHasProducto_id`) REFERENCES `facturahasproducto` (`id`),
  CONSTRAINT `FK_4F9058F7FC96FD8` FOREIGN KEY (`notaDebito_id`) REFERENCES `notadebito` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `impuesto`
--

INSERT INTO `impuesto` VALUES (23,'2','2','12.00',70.50,8.46,22,NULL,NULL),(26,'2','2','12.00',70.50,8.46,NULL,4,NULL),(27,'2','2','12.00',39.00,4.68,23,NULL,NULL),(28,'2','2','12.00',10.15,1.22,24,NULL,NULL),(29,'2','2','12.00',5.56,0.67,25,NULL,NULL),(30,'2','2','12.00',5.56,0.67,26,NULL,NULL),(31,'2','2','12.00',25.16,3.02,27,NULL,NULL),(32,'2','2','12.00',10.15,1.22,28,NULL,NULL),(33,'2','2','12.00',10.15,1.22,29,NULL,NULL),(34,'2','2','12.00',5.56,0.67,30,NULL,NULL),(35,'2','2','12.00',25.16,3.02,31,NULL,NULL),(36,'2','2','12.00',650.00,78.00,32,NULL,NULL),(37,'2','2','12.00',50.00,6.00,33,NULL,NULL),(38,'2','2','12.00',650.00,78.00,34,NULL,NULL),(39,'2','2','12.00',50.00,6.00,35,NULL,NULL),(40,'2','2','12.00',650.00,78.00,36,NULL,NULL),(41,'2','2','12.00',650.00,78.00,37,NULL,NULL),(42,'2','2','12.00',50.00,6.00,38,NULL,NULL);

--
-- Table structure for table `impuestocomprobanteretencion`
--

CREATE TABLE `impuestocomprobanteretencion` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `retencion_id` int(11) NOT NULL,
  `codigo` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  `codigoRetencion` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
  `baseImponible` decimal(10,2) NOT NULL,
  `porcentajeRetener` int(11) NOT NULL,
  `valorRetenido` decimal(10,2) NOT NULL,
  `codDocSustento` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
  `numDocSustento` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
  `fechaEmisionDocSustento` date NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_86AD65C722EC49A` (`retencion_id`),
  CONSTRAINT `FK_86AD65C722EC49A` FOREIGN KEY (`retencion_id`) REFERENCES `retencion` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `impuestocomprobanteretencion`
--


--
-- Table structure for table `impuestoice`
--

CREATE TABLE `impuestoice` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `codigoPorcentaje` varchar(4) COLLATE utf8_unicode_ci NOT NULL,
  `nombre` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_6F0EE7863174800F` (`createdBy_id`),
  KEY `IDX_6F0EE78665FF1AEC` (`updatedBy_id`),
  KEY `IDX_6F0EE78663D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_6F0EE7863174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_6F0EE78663D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_6F0EE78665FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `impuestoice`
--


--
-- Table structure for table `impuestoirbpnr`
--

CREATE TABLE `impuestoirbpnr` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `codigoPorcentaje` varchar(4) COLLATE utf8_unicode_ci NOT NULL,
  `nombre` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_AB0A0C0B3174800F` (`createdBy_id`),
  KEY `IDX_AB0A0C0B65FF1AEC` (`updatedBy_id`),
  KEY `IDX_AB0A0C0B63D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_AB0A0C0B3174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_AB0A0C0B63D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_AB0A0C0B65FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `impuestoirbpnr`
--


--
-- Table structure for table `impuestoiva`
--

CREATE TABLE `impuestoiva` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `codigoPorcentaje` varchar(4) COLLATE utf8_unicode_ci NOT NULL,
  `nombre` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `tarifa` decimal(10,2) NOT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_5FD6C58B3174800F` (`createdBy_id`),
  KEY `IDX_5FD6C58B65FF1AEC` (`updatedBy_id`),
  KEY `IDX_5FD6C58B63D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_5FD6C58B3174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_5FD6C58B63D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_5FD6C58B65FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `impuestoiva`
--

INSERT INTO `impuestoiva` VALUES (1,'2','IVA 12%',12.00,'2018-08-29 05:48:05','2018-08-29 05:48:05',NULL,NULL,NULL),(2,'0','IVA 0%',0.00,'2018-08-29 05:48:26','2018-08-29 05:48:26',NULL,NULL,NULL);

--
-- Table structure for table `mensaje`
--

CREATE TABLE `mensaje` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `identificador` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
  `mensaje` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `informacionAdicional` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tipo` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
  `Factura_id` int(11) DEFAULT NULL,
  `NotaCredito_id` int(11) DEFAULT NULL,
  `NotaDebito_id` int(11) DEFAULT NULL,
  `Retencion_id` int(11) DEFAULT NULL,
  `Guia_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_54DE249DBF127A8F` (`Factura_id`),
  KEY `IDX_54DE249D51CA559D` (`NotaCredito_id`),
  KEY `IDX_54DE249DBCB7242D` (`NotaDebito_id`),
  KEY `IDX_54DE249D6A1F1F62` (`Retencion_id`),
  KEY `IDX_54DE249DC9979183` (`Guia_id`),
  CONSTRAINT `FK_54DE249D51CA559D` FOREIGN KEY (`NotaCredito_id`) REFERENCES `notacredito` (`id`),
  CONSTRAINT `FK_54DE249D6A1F1F62` FOREIGN KEY (`Retencion_id`) REFERENCES `retencion` (`id`),
  CONSTRAINT `FK_54DE249DBCB7242D` FOREIGN KEY (`NotaDebito_id`) REFERENCES `notadebito` (`id`),
  CONSTRAINT `FK_54DE249DBF127A8F` FOREIGN KEY (`Factura_id`) REFERENCES `factura` (`id`),
  CONSTRAINT `FK_54DE249DC9979183` FOREIGN KEY (`Guia_id`) REFERENCES `guia` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `mensaje`
--

INSERT INTO `mensaje` VALUES (1,'1000','EL GESTOR DE CLAVES NO SE HA OBTENIDO CORRECTAMENTE',NULL,'EXCEPCION',16,NULL,NULL,NULL,NULL),(4,'1000','EL GESTOR DE CLAVES NO SE HA OBTENIDO CORRECTAMENTE',NULL,'EXCEPCION',17,NULL,NULL,NULL,NULL),(5,'1000','EL GESTOR DE CLAVES NO SE HA OBTENIDO CORRECTAMENTE',NULL,'EXCEPCION',18,NULL,NULL,NULL,NULL),(6,'1000','EL GESTOR DE CLAVES NO SE HA OBTENIDO CORRECTAMENTE',NULL,'EXCEPCION',19,NULL,NULL,NULL,NULL),(8,'1000','EL GESTOR DE CLAVES NO SE HA OBTENIDO CORRECTAMENTE',NULL,'EXCEPCION',20,NULL,NULL,NULL,NULL),(9,'1000','EL GESTOR DE CLAVES NO SE HA OBTENIDO CORRECTAMENTE',NULL,'EXCEPCION',21,NULL,NULL,NULL,NULL),(10,'56','ERROR ESTABLECIMIENTO CERRADO','El establecimiento 999 está cerrado','ERROR',26,NULL,NULL,NULL,NULL);

--
-- Table structure for table `motivo`
--

CREATE TABLE `motivo` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
  `valor` decimal(10,2) NOT NULL,
  `dotaDebito_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_1E553D50359609FE` (`dotaDebito_id`),
  CONSTRAINT `FK_1E553D50359609FE` FOREIGN KEY (`dotaDebito_id`) REFERENCES `notadebito` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `motivo`
--


--
-- Table structure for table `notacredito`
--

CREATE TABLE `notacredito` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `cliente_id` int(11) NOT NULL,
  `emisor_id` int(11) NOT NULL,
  `establecimiento_id` int(11) NOT NULL,
  `claveAcceso` varchar(49) COLLATE utf8_unicode_ci NOT NULL,
  `numeroAutorizacion` varchar(49) COLLATE utf8_unicode_ci DEFAULT NULL,
  `fechaAutorizacion` datetime DEFAULT NULL,
  `estado` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `ambiente` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  `tipoEmision` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `secuencial` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
  `fechaEmision` date NOT NULL,
  `tipoDocMod` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
  `fechaEmisionDocMod` date NOT NULL,
  `nroDocMod` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
  `motivo` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `nombreArchivo` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
  `totalSinImpuestos` decimal(10,2) NOT NULL,
  `subtotal12` decimal(10,2) NOT NULL,
  `subtotal0` decimal(10,2) NOT NULL,
  `subtotalNoIVA` decimal(10,2) NOT NULL,
  `subtotalExentoIVA` decimal(10,2) NOT NULL,
  `valorICE` decimal(10,2) NOT NULL,
  `valorIRBPNR` decimal(10,2) NOT NULL,
  `iva12` decimal(10,2) NOT NULL,
  `totalDescuento` decimal(10,2) NOT NULL,
  `valorTotal` decimal(10,2) NOT NULL,
  `firmado` tinyint(1) NOT NULL,
  `enviarSiAutorizado` tinyint(1) NOT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `ptoEmision_id` int(11) NOT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_799C85D7DE734E51` (`cliente_id`),
  KEY `IDX_799C85D76BDF87DF` (`emisor_id`),
  KEY `IDX_799C85D771B61351` (`establecimiento_id`),
  KEY `IDX_799C85D7E01B1B5E` (`ptoEmision_id`),
  KEY `IDX_799C85D73174800F` (`createdBy_id`),
  KEY `IDX_799C85D765FF1AEC` (`updatedBy_id`),
  KEY `IDX_799C85D763D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_799C85D73174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_799C85D763D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_799C85D765FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_799C85D76BDF87DF` FOREIGN KEY (`emisor_id`) REFERENCES `emisor` (`id`),
  CONSTRAINT `FK_799C85D771B61351` FOREIGN KEY (`establecimiento_id`) REFERENCES `establecimiento` (`id`),
  CONSTRAINT `FK_799C85D7DE734E51` FOREIGN KEY (`cliente_id`) REFERENCES `cliente` (`id`),
  CONSTRAINT `FK_799C85D7E01B1B5E` FOREIGN KEY (`ptoEmision_id`) REFERENCES `ptoemision` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `notacredito`
--

INSERT INTO `notacredito` VALUES (2,5,2,3,'2103201904171331809300110010010000305001234567810','2103201904171331809300110010010000305001234567810','2019-03-21 10:29:02','AUTORIZADO','1','1','000030500','2019-03-21','01','2019-03-21','001-001-000030500','mercaderia defectuosa','NC001-001-000030500',70.50,70.50,0.00,0.00,0.00,0.00,0.00,8.46,5.00,78.96,1,1,'2019-03-22 04:26:13','2019-03-22 04:29:07',3,7,7,NULL);

--
-- Table structure for table `notacreditohasproducto`
--

CREATE TABLE `notacreditohasproducto` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `producto_id` int(11) NOT NULL,
  `cantidad` decimal(10,2) NOT NULL,
  `nombre` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `codigoProducto` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `precioUnitario` decimal(10,2) NOT NULL,
  `descuento` decimal(10,2) NOT NULL,
  `valorTotal` decimal(10,2) NOT NULL,
  `notaCredito_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_721E66DE7645698E` (`producto_id`),
  KEY `IDX_721E66DE9CAE2D45` (`notaCredito_id`),
  CONSTRAINT `FK_721E66DE7645698E` FOREIGN KEY (`producto_id`) REFERENCES `producto` (`id`),
  CONSTRAINT `FK_721E66DE9CAE2D45` FOREIGN KEY (`notaCredito_id`) REFERENCES `notacredito` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `notacreditohasproducto`
--

INSERT INTO `notacreditohasproducto` VALUES (4,1,1.00,'SERVICIO DE CAMBIO DE ACEITE','001S',75.50,5.00,70.50,2);

--
-- Table structure for table `notadebito`
--

CREATE TABLE `notadebito` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `cliente_id` int(11) NOT NULL,
  `emisor_id` int(11) NOT NULL,
  `establecimiento_id` int(11) NOT NULL,
  `claveAcceso` varchar(49) COLLATE utf8_unicode_ci NOT NULL,
  `numeroAutorizacion` varchar(49) COLLATE utf8_unicode_ci DEFAULT NULL,
  `fechaAutorizacion` datetime DEFAULT NULL,
  `estado` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `ambiente` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  `tipoEmision` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `secuencial` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
  `fechaEmision` date NOT NULL,
  `tipoDocMod` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
  `fechaEmisionDocMod` date NOT NULL,
  `nroDocMod` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
  `nombreArchivo` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
  `totalSinImpuestos` decimal(10,2) NOT NULL,
  `subtotal12` decimal(10,2) NOT NULL,
  `subtotal0` decimal(10,2) NOT NULL,
  `subtotalNoIVA` decimal(10,2) NOT NULL,
  `subtotalExentoIVA` decimal(10,2) NOT NULL,
  `valorICE` decimal(10,2) NOT NULL,
  `iva12` decimal(10,2) NOT NULL,
  `valorTotal` decimal(10,2) NOT NULL,
  `firmado` tinyint(1) NOT NULL,
  `enviarSiAutorizado` tinyint(1) NOT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `ptoEmision_id` int(11) NOT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_60947670DE734E51` (`cliente_id`),
  KEY `IDX_609476706BDF87DF` (`emisor_id`),
  KEY `IDX_6094767071B61351` (`establecimiento_id`),
  KEY `IDX_60947670E01B1B5E` (`ptoEmision_id`),
  KEY `IDX_609476703174800F` (`createdBy_id`),
  KEY `IDX_6094767065FF1AEC` (`updatedBy_id`),
  KEY `IDX_6094767063D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_609476703174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_6094767063D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_6094767065FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_609476706BDF87DF` FOREIGN KEY (`emisor_id`) REFERENCES `emisor` (`id`),
  CONSTRAINT `FK_6094767071B61351` FOREIGN KEY (`establecimiento_id`) REFERENCES `establecimiento` (`id`),
  CONSTRAINT `FK_60947670DE734E51` FOREIGN KEY (`cliente_id`) REFERENCES `cliente` (`id`),
  CONSTRAINT `FK_60947670E01B1B5E` FOREIGN KEY (`ptoEmision_id`) REFERENCES `ptoemision` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `notadebito`
--


--
-- Table structure for table `producto`
--

CREATE TABLE `producto` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `emisor_id` int(11) NOT NULL,
  `impuesto_iva_id` int(11) NOT NULL,
  `impuesto_ice_id` int(11) DEFAULT NULL,
  `impuesto_irbpnr_id` int(11) DEFAULT NULL,
  `codigoPrincipal` varchar(25) COLLATE utf8_unicode_ci NOT NULL,
  `codigoAuxiliar` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL,
  `nombre` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
  `precioUnitario` decimal(10,2) NOT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_5ECD64436BDF87DF` (`emisor_id`),
  KEY `IDX_5ECD6443D0B25EB1` (`impuesto_iva_id`),
  KEY `IDX_5ECD6443F7D0D114` (`impuesto_ice_id`),
  KEY `IDX_5ECD64432780846A` (`impuesto_irbpnr_id`),
  KEY `IDX_5ECD64433174800F` (`createdBy_id`),
  KEY `IDX_5ECD644365FF1AEC` (`updatedBy_id`),
  KEY `IDX_5ECD644363D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_5ECD64432780846A` FOREIGN KEY (`impuesto_irbpnr_id`) REFERENCES `impuestoirbpnr` (`id`),
  CONSTRAINT `FK_5ECD64433174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_5ECD644363D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_5ECD644365FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_5ECD64436BDF87DF` FOREIGN KEY (`emisor_id`) REFERENCES `emisor` (`id`),
  CONSTRAINT `FK_5ECD6443D0B25EB1` FOREIGN KEY (`impuesto_iva_id`) REFERENCES `impuestoiva` (`id`),
  CONSTRAINT `FK_5ECD6443F7D0D114` FOREIGN KEY (`impuesto_ice_id`) REFERENCES `impuestoice` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `producto`
--

INSERT INTO `producto` VALUES (1,2,1,NULL,NULL,'001S','001S','SERVICIO DE CAMBIO DE ACEITE',25.16,'2018-11-23 20:59:31','2018-11-29 18:50:44',6,5,NULL),(2,2,1,NULL,NULL,'001P','001P','FILTRO DE GASOLINA',5.56,'2018-11-23 22:04:53','2018-11-29 18:49:57',5,5,NULL),(3,2,1,NULL,NULL,'002P','002P','FILTRO DE AIRE',10.15,'2018-11-23 22:05:33','2018-11-29 18:49:32',5,5,NULL),(4,2,1,NULL,NULL,'003P','003P','BOMBA DE GASOLINA',42.25,'2018-11-23 22:06:11','2018-11-29 18:50:15',5,5,NULL),(5,2,1,NULL,NULL,'001WEB','001WEB','Desarrollo de Página Web',650.00,'2019-06-20 21:51:11','2019-06-20 21:52:55',5,5,NULL),(6,2,1,NULL,NULL,'002WEB','002WEB','Hosting extensión .ec',50.00,'2019-06-20 21:52:30','2019-06-20 21:52:30',5,5,NULL);

--
-- Table structure for table `ptoemision`
--

CREATE TABLE `ptoemision` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `establecimiento_id` int(11) NOT NULL,
  `nombre` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
  `codigo` varchar(3) COLLATE utf8_unicode_ci NOT NULL,
  `secuencialFactura` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
  `secuencialNotaCredito` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
  `secuencialNotaDebito` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
  `secuencialGuiaRemision` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
  `secuencialRetencion` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
  `activo` tinyint(1) NOT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UNIQ_BE82597CA76ED395` (`user_id`),
  KEY `IDX_BE82597C71B61351` (`establecimiento_id`),
  KEY `IDX_BE82597C3174800F` (`createdBy_id`),
  KEY `IDX_BE82597C65FF1AEC` (`updatedBy_id`),
  KEY `IDX_BE82597C63D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_BE82597C3174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_BE82597C63D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_BE82597C65FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_BE82597C71B61351` FOREIGN KEY (`establecimiento_id`) REFERENCES `establecimiento` (`id`),
  CONSTRAINT `FK_BE82597CA76ED395` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `ptoemision`
--

INSERT INTO `ptoemision` VALUES (3,7,3,'PRINCIPAL','200','3','1','1','1','1',1,'2018-11-21 14:35:20','2019-06-20 23:14:57',5,7,NULL);

--
-- Table structure for table `retencion`
--

CREATE TABLE `retencion` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `cliente_id` int(11) NOT NULL,
  `emisor_id` int(11) NOT NULL,
  `establecimiento_id` int(11) NOT NULL,
  `claveAcceso` varchar(49) COLLATE utf8_unicode_ci NOT NULL,
  `numeroAutorizacion` varchar(49) COLLATE utf8_unicode_ci DEFAULT NULL,
  `fechaAutorizacion` datetime DEFAULT NULL,
  `estado` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `ambiente` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  `tipoEmision` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `secuencial` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
  `fechaEmision` date NOT NULL,
  `periodoFiscal` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
  `nombreArchivo` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
  `firmado` tinyint(1) NOT NULL,
  `enviarSiAutorizado` tinyint(1) NOT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `ptoEmision_id` int(11) NOT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_6240E309DE734E51` (`cliente_id`),
  KEY `IDX_6240E3096BDF87DF` (`emisor_id`),
  KEY `IDX_6240E30971B61351` (`establecimiento_id`),
  KEY `IDX_6240E309E01B1B5E` (`ptoEmision_id`),
  KEY `IDX_6240E3093174800F` (`createdBy_id`),
  KEY `IDX_6240E30965FF1AEC` (`updatedBy_id`),
  KEY `IDX_6240E30963D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_6240E3093174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_6240E30963D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_6240E30965FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_6240E3096BDF87DF` FOREIGN KEY (`emisor_id`) REFERENCES `emisor` (`id`),
  CONSTRAINT `FK_6240E30971B61351` FOREIGN KEY (`establecimiento_id`) REFERENCES `establecimiento` (`id`),
  CONSTRAINT `FK_6240E309DE734E51` FOREIGN KEY (`cliente_id`) REFERENCES `cliente` (`id`),
  CONSTRAINT `FK_6240E309E01B1B5E` FOREIGN KEY (`ptoEmision_id`) REFERENCES `ptoemision` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `retencion`
--


--
-- Table structure for table `role`
--

CREATE TABLE `role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  `createdBy_id` int(11) DEFAULT NULL,
  `updatedBy_id` int(11) DEFAULT NULL,
  `deletedBy_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_F75B25543174800F` (`createdBy_id`),
  KEY `IDX_F75B255465FF1AEC` (`updatedBy_id`),
  KEY `IDX_F75B255463D8C20E` (`deletedBy_id`),
  CONSTRAINT `FK_F75B25543174800F` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_F75B255463D8C20E` FOREIGN KEY (`deletedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `FK_F75B255465FF1AEC` FOREIGN KEY (`updatedBy_id`) REFERENCES `user` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `role`
--

INSERT INTO `role` VALUES (1,'ROLE_ADMIN','2018-08-29 05:28:37','2018-08-29 05:28:37',NULL,NULL,NULL),(2,'ROLE_EMISOR_ADMIN','2018-08-29 05:28:57','2018-08-29 05:28:57',NULL,NULL,NULL),(3,'ROLE_EMISOR','2018-08-29 05:29:25','2018-08-29 05:29:25',NULL,NULL,NULL);


