-- Table structure for table `ventas2018`
--

CREATE TABLE `ventas2018` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `codvendedor` int NOT NULL DEFAULT '0',
  `REFERENCIA` varchar(20) DEFAULT NULL,
  `situacioncocina` varchar(50) DEFAULT NULL,
  `idfactura` bigint unsigned NOT NULL,
  `consecutivo` int NOT NULL,
  `INCREMENTO` int NOT NULL,
  `codarticulo` int NOT NULL,
  `codsituacion` int NOT NULL,
  `porcentajedescuento` double DEFAULT '0',
  `referenciafront` varchar(15) DEFAULT NULL,
  `impuesto` double DEFAULT '0',
  `idarticulo` bigint unsigned NOT NULL,
  `descripcion` varchar(120) DEFAULT NULL,
  `esmodificador` int DEFAULT '0',
  `nombrearticulo` varchar(100) DEFAULT NULL,
  `cantidad` double NOT NULL DEFAULT '0',
  `comentario` varchar(200) DEFAULT NULL,
  `observaciones` varchar(200) DEFAULT NULL,
  `valorunitario` double NOT NULL DEFAULT '0',
  `idmesa` int NOT NULL DEFAULT '1',
  `bruto` double NOT NULL DEFAULT '0',
  `baseunitario` double NOT NULL DEFAULT '0',
  `ivaunitario` double NOT NULL DEFAULT '0',
  `descuento` int NOT NULL DEFAULT '0',
  `valortotal` double NOT NULL DEFAULT '0',
  `cc` int DEFAULT '2',
  `documento` varchar(3) NOT NULL DEFAULT 'V',
  `origen` varchar(25) DEFAULT NULL,
  `fecha` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `fechacreacion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `HORAINI` datetime DEFAULT NULL,
  `HORAFIN` datetime DEFAULT NULL,
  `ultimaedicion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `idcliente` bigint unsigned NOT NULL DEFAULT '0',
  `idusuario` bigint unsigned NOT NULL DEFAULT '1',
  `idz` bigint unsigned NOT NULL DEFAULT '1',
  `abonado` int NOT NULL DEFAULT '0',
  `idfacturaqueabona` int NOT NULL DEFAULT '0',
  `costomedio` double DEFAULT '0',
  `porcentajeiva` double NOT NULL DEFAULT '0',
  `base` double NOT NULL DEFAULT '0',
  `iva` double NOT NULL DEFAULT '0',
  `esbolsillo` int NOT NULL DEFAULT '0',
  `idvendedor` bigint unsigned NOT NULL DEFAULT '1',
  `escortesia` int NOT NULL DEFAULT '0',
  `idcaja` bigint unsigned NOT NULL DEFAULT '1',
  `idnc` bigint unsigned NOT NULL DEFAULT '1',
  `nc` int DEFAULT '0',
  `idusuarionc` bigint unsigned NOT NULL DEFAULT '1',
  `mediodepago` varchar(25) NOT NULL DEFAULT 'EFECTIVO',
  `comision` int NOT NULL DEFAULT '0',
  `devolucionrevisada` int DEFAULT '0',
  `fechaabonado` datetime DEFAULT NULL,
  `fechamc` datetime DEFAULT NULL,
  `tienenc` int NOT NULL DEFAULT '0',
  `marcadoparanc` int NOT NULL DEFAULT '0',
  `servicio` int NOT NULL DEFAULT '0',
  `subido` int NOT NULL DEFAULT '0',
  `CODMODIF` int DEFAULT '0',
  `esmodif` int NOT NULL DEFAULT '0',
  `CODARTICULOABAJO` varchar(12) NOT NULL DEFAULT '',
  `PRECIOIVA` int NOT NULL DEFAULT '0',
  `NUMMODIF` int NOT NULL DEFAULT '0',
  `numservicio` int NOT NULL DEFAULT '0',
  `aliasespera` int NOT NULL DEFAULT '1',
  `impresiones` int NOT NULL DEFAULT '1',
  `IDMOTIVODTO` varchar(2) NOT NULL DEFAULT '-1',
  `DETALLEDENUMLINEA` varchar(2) NOT NULL DEFAULT '0',
  `FAMILIAAENA` varchar(2) NOT NULL DEFAULT '0',
  `DETALLEMODIF` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_NUMERO` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_N` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_SERIE` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_FO` varchar(2) NOT NULL DEFAULT '-1',
  `NORDERTIQUET` varchar(1) NOT NULL DEFAULT '0',
  `SORDERTIQUET` varchar(1) NOT NULL DEFAULT '',
  `REQ` int NOT NULL DEFAULT '0',
  `COSTEIVA` int NOT NULL DEFAULT '0',
  `DTO` int NOT NULL DEFAULT '0',
  `TIPO` varchar(2) NOT NULL DEFAULT 'V',
  `CODMACRO` int NOT NULL DEFAULT '0',
  `CODFORMATO` int NOT NULL DEFAULT '0',
  `NUMLINEA` int NOT NULL DEFAULT '1',
  `codigociudad` varchar(5) DEFAULT NULL,
  `email` varchar(5) DEFAULT NULL,
  `codigopostal` varchar(5) DEFAULT NULL,
  `codigodepartamento` varchar(5) DEFAULT NULL,
  `departamento` varchar(5) DEFAULT NULL,
  `ciudad` varchar(5) DEFAULT NULL,
  `cufe` varchar(5) DEFAULT NULL,
  `unidaddemedida` varchar(25) DEFAULT NULL,
  `esnota` int DEFAULT '0',
  `impreso` int DEFAULT '0',
  `domicilio` int DEFAULT '0',
  `domicilioexterno` int DEFAULT '0',
  `pv` varchar(25) DEFAULT 'texasburgers',
  `zonaventas` varchar(25) DEFAULT NULL,
  `seccionventas` varchar(25) DEFAULT NULL,
  `situacioncocina2` varchar(25) DEFAULT 'SELECCIONE',
  `integraconfamilia` int DEFAULT '1',
  `codmodifpapa` int DEFAULT '0',
  `TIPOIVA` int DEFAULT '1',
  `sesubearappi` int DEFAULT '0',
  `refventas` varchar(20) DEFAULT NULL,
  `placa` varchar(6) DEFAULT NULL,
  `iddomiciliario` int DEFAULT NULL,
  `horaaceptado` datetime DEFAULT NULL,
  `comandaaceptada` bit(1) DEFAULT b'0',
  `horaacancelada` datetime DEFAULT NULL,
  `comandacancelada` bit(1) DEFAULT b'0',
  `motivocancela` varchar(25) DEFAULT NULL,
  `paqueterecibido` bit(1) DEFAULT b'0',
  `hora_paqueterecibido` bit(1) DEFAULT b'0',
  `porcentajecomision` decimal(5,2) DEFAULT '0.00',
  `articulovence` date DEFAULT NULL,
  `deberecoger` datetime DEFAULT NULL,
  `imei` varchar(50) DEFAULT NULL,
  `factor` int DEFAULT '1',
  `puntosrevisados` bit(1) DEFAULT b'0',
  `idusuarioredime` int DEFAULT NULL,
  `usuarioredime` varchar(50) DEFAULT NULL,
  `fecharedime` datetime DEFAULT NULL,
  `costomenu` decimal(11,2) DEFAULT '0.00',
  `comensales` int DEFAULT '0',
  `impultraprocesados` int DEFAULT '0',
  `impazucaradas` int DEFAULT '0',
  `idmayornomina` int DEFAULT '0',
  `tipodescuento` varchar(15) DEFAULT NULL,
  `porcentajesobrecargoeventos` double DEFAULT '0',
  `sobrecargoeventos` double DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `idfactura` (`idfactura`),
  KEY `idarticulo` (`idarticulo`),
  KEY `idcc` (`cc`),
  KEY `idcliente` (`idcliente`),
  KEY `idusuario` (`idusuario`),
  KEY `idz` (`idz`),
  KEY `idvendedor` (`idvendedor`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `ventas2018`
--


--
-- Table structure for table `ventas2019`
--

CREATE TABLE `ventas2019` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `codvendedor` int NOT NULL DEFAULT '0',
  `REFERENCIA` varchar(20) DEFAULT NULL,
  `situacioncocina` varchar(50) DEFAULT NULL,
  `idfactura` bigint unsigned NOT NULL,
  `consecutivo` int NOT NULL,
  `INCREMENTO` int NOT NULL,
  `codarticulo` int NOT NULL,
  `codsituacion` int NOT NULL,
  `porcentajedescuento` double DEFAULT '0',
  `referenciafront` varchar(15) DEFAULT NULL,
  `impuesto` double DEFAULT '0',
  `idarticulo` bigint unsigned NOT NULL,
  `descripcion` varchar(120) DEFAULT NULL,
  `esmodificador` int DEFAULT '0',
  `nombrearticulo` varchar(100) DEFAULT NULL,
  `cantidad` double NOT NULL DEFAULT '0',
  `comentario` varchar(200) DEFAULT NULL,
  `observaciones` varchar(200) DEFAULT NULL,
  `valorunitario` double NOT NULL DEFAULT '0',
  `idmesa` int NOT NULL DEFAULT '1',
  `bruto` double NOT NULL DEFAULT '0',
  `baseunitario` double NOT NULL DEFAULT '0',
  `ivaunitario` double NOT NULL DEFAULT '0',
  `descuento` int NOT NULL DEFAULT '0',
  `valortotal` double NOT NULL DEFAULT '0',
  `cc` int DEFAULT '2',
  `documento` varchar(3) NOT NULL DEFAULT 'V',
  `origen` varchar(25) DEFAULT NULL,
  `fecha` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `fechacreacion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `HORAINI` datetime DEFAULT NULL,
  `HORAFIN` datetime DEFAULT NULL,
  `ultimaedicion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `idcliente` bigint unsigned NOT NULL DEFAULT '0',
  `idusuario` bigint unsigned NOT NULL DEFAULT '1',
  `idz` bigint unsigned NOT NULL DEFAULT '1',
  `abonado` int NOT NULL DEFAULT '0',
  `idfacturaqueabona` int NOT NULL DEFAULT '0',
  `costomedio` double DEFAULT '0',
  `porcentajeiva` double NOT NULL DEFAULT '0',
  `base` double NOT NULL DEFAULT '0',
  `iva` double NOT NULL DEFAULT '0',
  `esbolsillo` int NOT NULL DEFAULT '0',
  `idvendedor` bigint unsigned NOT NULL DEFAULT '1',
  `escortesia` int NOT NULL DEFAULT '0',
  `idcaja` bigint unsigned NOT NULL DEFAULT '1',
  `idnc` bigint unsigned NOT NULL DEFAULT '1',
  `nc` int DEFAULT '0',
  `idusuarionc` bigint unsigned NOT NULL DEFAULT '1',
  `mediodepago` varchar(25) NOT NULL DEFAULT 'EFECTIVO',
  `comision` int NOT NULL DEFAULT '0',
  `devolucionrevisada` int DEFAULT '0',
  `fechaabonado` datetime DEFAULT NULL,
  `fechamc` datetime DEFAULT NULL,
  `tienenc` int NOT NULL DEFAULT '0',
  `marcadoparanc` int NOT NULL DEFAULT '0',
  `servicio` int NOT NULL DEFAULT '0',
  `subido` int NOT NULL DEFAULT '0',
  `CODMODIF` int DEFAULT '0',
  `esmodif` int NOT NULL DEFAULT '0',
  `CODARTICULOABAJO` varchar(12) NOT NULL DEFAULT '',
  `PRECIOIVA` int NOT NULL DEFAULT '0',
  `NUMMODIF` int NOT NULL DEFAULT '0',
  `numservicio` int NOT NULL DEFAULT '0',
  `aliasespera` int NOT NULL DEFAULT '1',
  `impresiones` int NOT NULL DEFAULT '1',
  `IDMOTIVODTO` varchar(2) NOT NULL DEFAULT '-1',
  `DETALLEDENUMLINEA` varchar(2) NOT NULL DEFAULT '0',
  `FAMILIAAENA` varchar(2) NOT NULL DEFAULT '0',
  `DETALLEMODIF` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_NUMERO` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_N` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_SERIE` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_FO` varchar(2) NOT NULL DEFAULT '-1',
  `NORDERTIQUET` varchar(1) NOT NULL DEFAULT '0',
  `SORDERTIQUET` varchar(1) NOT NULL DEFAULT '',
  `REQ` int NOT NULL DEFAULT '0',
  `COSTEIVA` int NOT NULL DEFAULT '0',
  `DTO` int NOT NULL DEFAULT '0',
  `TIPO` varchar(2) NOT NULL DEFAULT 'V',
  `CODMACRO` int NOT NULL DEFAULT '0',
  `CODFORMATO` int NOT NULL DEFAULT '0',
  `NUMLINEA` int NOT NULL DEFAULT '1',
  `codigociudad` varchar(5) DEFAULT NULL,
  `email` varchar(5) DEFAULT NULL,
  `codigopostal` varchar(5) DEFAULT NULL,
  `codigodepartamento` varchar(5) DEFAULT NULL,
  `departamento` varchar(5) DEFAULT NULL,
  `ciudad` varchar(5) DEFAULT NULL,
  `cufe` varchar(5) DEFAULT NULL,
  `unidaddemedida` varchar(25) DEFAULT NULL,
  `esnota` int DEFAULT '0',
  `impreso` int DEFAULT '0',
  `domicilio` int DEFAULT '0',
  `domicilioexterno` int DEFAULT '0',
  `pv` varchar(25) DEFAULT 'texasburgers',
  `zonaventas` varchar(25) DEFAULT NULL,
  `seccionventas` varchar(25) DEFAULT NULL,
  `situacioncocina2` varchar(25) DEFAULT 'SELECCIONE',
  `integraconfamilia` int DEFAULT '1',
  `codmodifpapa` int DEFAULT '0',
  `TIPOIVA` int DEFAULT '1',
  `sesubearappi` int DEFAULT '0',
  `refventas` varchar(20) DEFAULT NULL,
  `placa` varchar(6) DEFAULT NULL,
  `iddomiciliario` int DEFAULT NULL,
  `horaaceptado` datetime DEFAULT NULL,
  `comandaaceptada` bit(1) DEFAULT b'0',
  `horaacancelada` datetime DEFAULT NULL,
  `comandacancelada` bit(1) DEFAULT b'0',
  `motivocancela` varchar(25) DEFAULT NULL,
  `paqueterecibido` bit(1) DEFAULT b'0',
  `hora_paqueterecibido` bit(1) DEFAULT b'0',
  `porcentajecomision` decimal(5,2) DEFAULT '0.00',
  `articulovence` date DEFAULT NULL,
  `deberecoger` datetime DEFAULT NULL,
  `imei` varchar(50) DEFAULT NULL,
  `factor` int DEFAULT '1',
  `puntosrevisados` bit(1) DEFAULT b'0',
  `idusuarioredime` int DEFAULT NULL,
  `usuarioredime` varchar(50) DEFAULT NULL,
  `fecharedime` datetime DEFAULT NULL,
  `costomenu` decimal(11,2) DEFAULT '0.00',
  `comensales` int DEFAULT '0',
  `impultraprocesados` int DEFAULT '0',
  `impazucaradas` int DEFAULT '0',
  `idmayornomina` int DEFAULT '0',
  `tipodescuento` varchar(15) DEFAULT NULL,
  `porcentajesobrecargoeventos` double DEFAULT '0',
  `sobrecargoeventos` double DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `idfactura` (`idfactura`),
  KEY `idarticulo` (`idarticulo`),
  KEY `idcc` (`cc`),
  KEY `idcliente` (`idcliente`),
  KEY `idusuario` (`idusuario`),
  KEY `idz` (`idz`),
  KEY `idvendedor` (`idvendedor`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `ventas2019`
--


--
-- Table structure for table `ventas2020`
--

CREATE TABLE `ventas2020` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `codvendedor` int NOT NULL DEFAULT '0',
  `REFERENCIA` varchar(20) DEFAULT NULL,
  `situacioncocina` varchar(50) DEFAULT NULL,
  `idfactura` bigint unsigned NOT NULL,
  `consecutivo` int NOT NULL,
  `INCREMENTO` int NOT NULL,
  `codarticulo` int NOT NULL,
  `codsituacion` int NOT NULL,
  `porcentajedescuento` double DEFAULT '0',
  `referenciafront` varchar(15) DEFAULT NULL,
  `impuesto` double DEFAULT '0',
  `idarticulo` bigint unsigned NOT NULL,
  `descripcion` varchar(120) DEFAULT NULL,
  `esmodificador` int DEFAULT '0',
  `nombrearticulo` varchar(100) DEFAULT NULL,
  `cantidad` double NOT NULL DEFAULT '0',
  `comentario` varchar(200) DEFAULT NULL,
  `observaciones` varchar(200) DEFAULT NULL,
  `valorunitario` double NOT NULL DEFAULT '0',
  `idmesa` int NOT NULL DEFAULT '1',
  `bruto` double NOT NULL DEFAULT '0',
  `baseunitario` double NOT NULL DEFAULT '0',
  `ivaunitario` double NOT NULL DEFAULT '0',
  `descuento` int NOT NULL DEFAULT '0',
  `valortotal` double NOT NULL DEFAULT '0',
  `cc` int DEFAULT '2',
  `documento` varchar(3) NOT NULL DEFAULT 'V',
  `origen` varchar(25) DEFAULT NULL,
  `fecha` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `fechacreacion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `HORAINI` datetime DEFAULT NULL,
  `HORAFIN` datetime DEFAULT NULL,
  `ultimaedicion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `idcliente` bigint unsigned NOT NULL DEFAULT '0',
  `idusuario` bigint unsigned NOT NULL DEFAULT '1',
  `idz` bigint unsigned NOT NULL DEFAULT '1',
  `abonado` int NOT NULL DEFAULT '0',
  `idfacturaqueabona` int NOT NULL DEFAULT '0',
  `costomedio` double DEFAULT '0',
  `porcentajeiva` double NOT NULL DEFAULT '0',
  `base` double NOT NULL DEFAULT '0',
  `iva` double NOT NULL DEFAULT '0',
  `esbolsillo` int NOT NULL DEFAULT '0',
  `idvendedor` bigint unsigned NOT NULL DEFAULT '1',
  `escortesia` int NOT NULL DEFAULT '0',
  `idcaja` bigint unsigned NOT NULL DEFAULT '1',
  `idnc` bigint unsigned NOT NULL DEFAULT '1',
  `nc` int DEFAULT '0',
  `idusuarionc` bigint unsigned NOT NULL DEFAULT '1',
  `mediodepago` varchar(25) NOT NULL DEFAULT 'EFECTIVO',
  `comision` int NOT NULL DEFAULT '0',
  `devolucionrevisada` int DEFAULT '0',
  `fechaabonado` datetime DEFAULT NULL,
  `fechamc` datetime DEFAULT NULL,
  `tienenc` int NOT NULL DEFAULT '0',
  `marcadoparanc` int NOT NULL DEFAULT '0',
  `servicio` int NOT NULL DEFAULT '0',
  `subido` int NOT NULL DEFAULT '0',
  `CODMODIF` int DEFAULT '0',
  `esmodif` int NOT NULL DEFAULT '0',
  `CODARTICULOABAJO` varchar(12) NOT NULL DEFAULT '',
  `PRECIOIVA` int NOT NULL DEFAULT '0',
  `NUMMODIF` int NOT NULL DEFAULT '0',
  `numservicio` int NOT NULL DEFAULT '0',
  `aliasespera` int NOT NULL DEFAULT '1',
  `impresiones` int NOT NULL DEFAULT '1',
  `IDMOTIVODTO` varchar(2) NOT NULL DEFAULT '-1',
  `DETALLEDENUMLINEA` varchar(2) NOT NULL DEFAULT '0',
  `FAMILIAAENA` varchar(2) NOT NULL DEFAULT '0',
  `DETALLEMODIF` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_NUMERO` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_N` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_SERIE` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_FO` varchar(2) NOT NULL DEFAULT '-1',
  `NORDERTIQUET` varchar(1) NOT NULL DEFAULT '0',
  `SORDERTIQUET` varchar(1) NOT NULL DEFAULT '',
  `REQ` int NOT NULL DEFAULT '0',
  `COSTEIVA` int NOT NULL DEFAULT '0',
  `DTO` int NOT NULL DEFAULT '0',
  `TIPO` varchar(2) NOT NULL DEFAULT 'V',
  `CODMACRO` int NOT NULL DEFAULT '0',
  `CODFORMATO` int NOT NULL DEFAULT '0',
  `NUMLINEA` int NOT NULL DEFAULT '1',
  `codigociudad` varchar(5) DEFAULT NULL,
  `email` varchar(5) DEFAULT NULL,
  `codigopostal` varchar(5) DEFAULT NULL,
  `codigodepartamento` varchar(5) DEFAULT NULL,
  `departamento` varchar(5) DEFAULT NULL,
  `ciudad` varchar(5) DEFAULT NULL,
  `cufe` varchar(5) DEFAULT NULL,
  `unidaddemedida` varchar(25) DEFAULT NULL,
  `esnota` int DEFAULT '0',
  `impreso` int DEFAULT '0',
  `domicilio` int DEFAULT '0',
  `domicilioexterno` int DEFAULT '0',
  `pv` varchar(25) DEFAULT 'texasburgers',
  `zonaventas` varchar(25) DEFAULT NULL,
  `seccionventas` varchar(25) DEFAULT NULL,
  `situacioncocina2` varchar(25) DEFAULT 'SELECCIONE',
  `integraconfamilia` int DEFAULT '1',
  `codmodifpapa` int DEFAULT '0',
  `TIPOIVA` int DEFAULT '1',
  `sesubearappi` int DEFAULT '0',
  `refventas` varchar(20) DEFAULT NULL,
  `placa` varchar(6) DEFAULT NULL,
  `iddomiciliario` int DEFAULT NULL,
  `horaaceptado` datetime DEFAULT NULL,
  `comandaaceptada` bit(1) DEFAULT b'0',
  `horaacancelada` datetime DEFAULT NULL,
  `comandacancelada` bit(1) DEFAULT b'0',
  `motivocancela` varchar(25) DEFAULT NULL,
  `paqueterecibido` bit(1) DEFAULT b'0',
  `hora_paqueterecibido` bit(1) DEFAULT b'0',
  `porcentajecomision` decimal(5,2) DEFAULT '0.00',
  `articulovence` date DEFAULT NULL,
  `deberecoger` datetime DEFAULT NULL,
  `imei` varchar(50) DEFAULT NULL,
  `factor` int DEFAULT '1',
  `puntosrevisados` bit(1) DEFAULT b'0',
  `idusuarioredime` int DEFAULT NULL,
  `usuarioredime` varchar(50) DEFAULT NULL,
  `fecharedime` datetime DEFAULT NULL,
  `costomenu` decimal(11,2) DEFAULT '0.00',
  `comensales` int DEFAULT '0',
  `impultraprocesados` int DEFAULT '0',
  `impazucaradas` int DEFAULT '0',
  `idmayornomina` int DEFAULT '0',
  `tipodescuento` varchar(15) DEFAULT NULL,
  `porcentajesobrecargoeventos` double DEFAULT '0',
  `sobrecargoeventos` double DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `idfactura` (`idfactura`),
  KEY `idarticulo` (`idarticulo`),
  KEY `idcc` (`cc`),
  KEY `idcliente` (`idcliente`),
  KEY `idusuario` (`idusuario`),
  KEY `idz` (`idz`),
  KEY `idvendedor` (`idvendedor`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `ventas2020`
--


--
-- Table structure for table `ventas2021`
--

CREATE TABLE `ventas2021` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `codvendedor` int NOT NULL DEFAULT '0',
  `REFERENCIA` varchar(20) DEFAULT NULL,
  `situacioncocina` varchar(50) DEFAULT NULL,
  `idfactura` bigint unsigned NOT NULL,
  `consecutivo` int NOT NULL,
  `INCREMENTO` int NOT NULL,
  `codarticulo` int NOT NULL,
  `codsituacion` int NOT NULL,
  `porcentajedescuento` double DEFAULT '0',
  `referenciafront` varchar(15) DEFAULT NULL,
  `impuesto` double DEFAULT '0',
  `idarticulo` bigint unsigned NOT NULL,
  `descripcion` varchar(120) DEFAULT NULL,
  `esmodificador` int DEFAULT '0',
  `nombrearticulo` varchar(100) DEFAULT NULL,
  `cantidad` double NOT NULL DEFAULT '0',
  `comentario` varchar(200) DEFAULT NULL,
  `observaciones` varchar(200) DEFAULT NULL,
  `valorunitario` double NOT NULL DEFAULT '0',
  `idmesa` int NOT NULL DEFAULT '1',
  `bruto` double NOT NULL DEFAULT '0',
  `baseunitario` double NOT NULL DEFAULT '0',
  `ivaunitario` double NOT NULL DEFAULT '0',
  `descuento` int NOT NULL DEFAULT '0',
  `valortotal` double NOT NULL DEFAULT '0',
  `cc` int DEFAULT '2',
  `documento` varchar(3) NOT NULL DEFAULT 'V',
  `origen` varchar(25) DEFAULT NULL,
  `fecha` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `fechacreacion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `HORAINI` datetime DEFAULT NULL,
  `HORAFIN` datetime DEFAULT NULL,
  `ultimaedicion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `idcliente` bigint unsigned NOT NULL DEFAULT '0',
  `idusuario` bigint unsigned NOT NULL DEFAULT '1',
  `idz` bigint unsigned NOT NULL DEFAULT '1',
  `abonado` int NOT NULL DEFAULT '0',
  `idfacturaqueabona` int NOT NULL DEFAULT '0',
  `costomedio` double DEFAULT '0',
  `porcentajeiva` double NOT NULL DEFAULT '0',
  `base` double NOT NULL DEFAULT '0',
  `iva` double NOT NULL DEFAULT '0',
  `esbolsillo` int NOT NULL DEFAULT '0',
  `idvendedor` bigint unsigned NOT NULL DEFAULT '1',
  `escortesia` int NOT NULL DEFAULT '0',
  `idcaja` bigint unsigned NOT NULL DEFAULT '1',
  `idnc` bigint unsigned NOT NULL DEFAULT '1',
  `nc` int DEFAULT '0',
  `idusuarionc` bigint unsigned NOT NULL DEFAULT '1',
  `mediodepago` varchar(25) NOT NULL DEFAULT 'EFECTIVO',
  `comision` int NOT NULL DEFAULT '0',
  `devolucionrevisada` int DEFAULT '0',
  `fechaabonado` datetime DEFAULT NULL,
  `fechamc` datetime DEFAULT NULL,
  `tienenc` int NOT NULL DEFAULT '0',
  `marcadoparanc` int NOT NULL DEFAULT '0',
  `servicio` int NOT NULL DEFAULT '0',
  `subido` int NOT NULL DEFAULT '0',
  `CODMODIF` int DEFAULT '0',
  `esmodif` int NOT NULL DEFAULT '0',
  `CODARTICULOABAJO` varchar(12) NOT NULL DEFAULT '',
  `PRECIOIVA` int NOT NULL DEFAULT '0',
  `NUMMODIF` int NOT NULL DEFAULT '0',
  `numservicio` int NOT NULL DEFAULT '0',
  `aliasespera` int NOT NULL DEFAULT '1',
  `impresiones` int NOT NULL DEFAULT '1',
  `IDMOTIVODTO` varchar(2) NOT NULL DEFAULT '-1',
  `DETALLEDENUMLINEA` varchar(2) NOT NULL DEFAULT '0',
  `FAMILIAAENA` varchar(2) NOT NULL DEFAULT '0',
  `DETALLEMODIF` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_NUMERO` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_N` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_SERIE` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_FO` varchar(2) NOT NULL DEFAULT '-1',
  `NORDERTIQUET` varchar(1) NOT NULL DEFAULT '0',
  `SORDERTIQUET` varchar(1) NOT NULL DEFAULT '',
  `REQ` int NOT NULL DEFAULT '0',
  `COSTEIVA` int NOT NULL DEFAULT '0',
  `DTO` int NOT NULL DEFAULT '0',
  `TIPO` varchar(2) NOT NULL DEFAULT 'V',
  `CODMACRO` int NOT NULL DEFAULT '0',
  `CODFORMATO` int NOT NULL DEFAULT '0',
  `NUMLINEA` int NOT NULL DEFAULT '1',
  `codigociudad` varchar(5) DEFAULT NULL,
  `email` varchar(5) DEFAULT NULL,
  `codigopostal` varchar(5) DEFAULT NULL,
  `codigodepartamento` varchar(5) DEFAULT NULL,
  `departamento` varchar(5) DEFAULT NULL,
  `ciudad` varchar(5) DEFAULT NULL,
  `cufe` varchar(5) DEFAULT NULL,
  `unidaddemedida` varchar(25) DEFAULT NULL,
  `esnota` int DEFAULT '0',
  `impreso` int DEFAULT '0',
  `domicilio` int DEFAULT '0',
  `domicilioexterno` int DEFAULT '0',
  `pv` varchar(25) DEFAULT 'texasburgers',
  `zonaventas` varchar(25) DEFAULT NULL,
  `seccionventas` varchar(25) DEFAULT NULL,
  `situacioncocina2` varchar(25) DEFAULT 'SELECCIONE',
  `integraconfamilia` int DEFAULT '1',
  `codmodifpapa` int DEFAULT '0',
  `TIPOIVA` int DEFAULT '1',
  `sesubearappi` int DEFAULT '0',
  `refventas` varchar(20) DEFAULT NULL,
  `placa` varchar(6) DEFAULT NULL,
  `iddomiciliario` int DEFAULT NULL,
  `horaaceptado` datetime DEFAULT NULL,
  `comandaaceptada` bit(1) DEFAULT b'0',
  `horaacancelada` datetime DEFAULT NULL,
  `comandacancelada` bit(1) DEFAULT b'0',
  `motivocancela` varchar(25) DEFAULT NULL,
  `paqueterecibido` bit(1) DEFAULT b'0',
  `hora_paqueterecibido` bit(1) DEFAULT b'0',
  `porcentajecomision` decimal(5,2) DEFAULT '0.00',
  `articulovence` date DEFAULT NULL,
  `deberecoger` datetime DEFAULT NULL,
  `imei` varchar(50) DEFAULT NULL,
  `factor` int DEFAULT '1',
  `puntosrevisados` bit(1) DEFAULT b'0',
  `idusuarioredime` int DEFAULT NULL,
  `usuarioredime` varchar(50) DEFAULT NULL,
  `fecharedime` datetime DEFAULT NULL,
  `costomenu` decimal(11,2) DEFAULT '0.00',
  `comensales` int DEFAULT '0',
  `impultraprocesados` int DEFAULT '0',
  `impazucaradas` int DEFAULT '0',
  `idmayornomina` int DEFAULT '0',
  `tipodescuento` varchar(15) DEFAULT NULL,
  `porcentajesobrecargoeventos` double DEFAULT '0',
  `sobrecargoeventos` double DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `idfactura` (`idfactura`),
  KEY `idarticulo` (`idarticulo`),
  KEY `idcc` (`cc`),
  KEY `idcliente` (`idcliente`),
  KEY `idusuario` (`idusuario`),
  KEY `idz` (`idz`),
  KEY `idvendedor` (`idvendedor`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `ventas2021`
--


--
-- Table structure for table `ventas2022`
--

CREATE TABLE `ventas2022` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `codvendedor` int NOT NULL DEFAULT '0',
  `REFERENCIA` varchar(20) DEFAULT NULL,
  `situacioncocina` varchar(50) DEFAULT NULL,
  `idfactura` bigint unsigned NOT NULL,
  `consecutivo` int NOT NULL,
  `INCREMENTO` int NOT NULL,
  `codarticulo` int NOT NULL,
  `codsituacion` int NOT NULL,
  `porcentajedescuento` double DEFAULT '0',
  `referenciafront` varchar(15) DEFAULT NULL,
  `impuesto` double DEFAULT '0',
  `idarticulo` bigint unsigned NOT NULL,
  `descripcion` varchar(120) DEFAULT NULL,
  `esmodificador` int DEFAULT '0',
  `nombrearticulo` varchar(100) DEFAULT NULL,
  `cantidad` double NOT NULL DEFAULT '0',
  `comentario` varchar(200) DEFAULT NULL,
  `observaciones` varchar(200) DEFAULT NULL,
  `valorunitario` double NOT NULL DEFAULT '0',
  `idmesa` int NOT NULL DEFAULT '1',
  `bruto` double NOT NULL DEFAULT '0',
  `baseunitario` double NOT NULL DEFAULT '0',
  `ivaunitario` double NOT NULL DEFAULT '0',
  `descuento` int NOT NULL DEFAULT '0',
  `valortotal` double NOT NULL DEFAULT '0',
  `cc` int DEFAULT '2',
  `documento` varchar(3) NOT NULL DEFAULT 'V',
  `origen` varchar(25) DEFAULT NULL,
  `fecha` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `fechacreacion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `HORAINI` datetime DEFAULT NULL,
  `HORAFIN` datetime DEFAULT NULL,
  `ultimaedicion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `idcliente` bigint unsigned NOT NULL DEFAULT '0',
  `idusuario` bigint unsigned NOT NULL DEFAULT '1',
  `idz` bigint unsigned NOT NULL DEFAULT '1',
  `abonado` int NOT NULL DEFAULT '0',
  `idfacturaqueabona` int NOT NULL DEFAULT '0',
  `costomedio` double DEFAULT '0',
  `porcentajeiva` double NOT NULL DEFAULT '0',
  `base` double NOT NULL DEFAULT '0',
  `iva` double NOT NULL DEFAULT '0',
  `esbolsillo` int NOT NULL DEFAULT '0',
  `idvendedor` bigint unsigned NOT NULL DEFAULT '1',
  `escortesia` int NOT NULL DEFAULT '0',
  `idcaja` bigint unsigned NOT NULL DEFAULT '1',
  `idnc` bigint unsigned NOT NULL DEFAULT '1',
  `nc` int DEFAULT '0',
  `idusuarionc` bigint unsigned NOT NULL DEFAULT '1',
  `mediodepago` varchar(25) NOT NULL DEFAULT 'EFECTIVO',
  `comision` int NOT NULL DEFAULT '0',
  `devolucionrevisada` int DEFAULT '0',
  `fechaabonado` datetime DEFAULT NULL,
  `fechamc` datetime DEFAULT NULL,
  `tienenc` int NOT NULL DEFAULT '0',
  `marcadoparanc` int NOT NULL DEFAULT '0',
  `servicio` int NOT NULL DEFAULT '0',
  `subido` int NOT NULL DEFAULT '0',
  `CODMODIF` int DEFAULT '0',
  `esmodif` int NOT NULL DEFAULT '0',
  `CODARTICULOABAJO` varchar(12) NOT NULL DEFAULT '',
  `PRECIOIVA` int NOT NULL DEFAULT '0',
  `NUMMODIF` int NOT NULL DEFAULT '0',
  `numservicio` int NOT NULL DEFAULT '0',
  `aliasespera` int NOT NULL DEFAULT '1',
  `impresiones` int NOT NULL DEFAULT '1',
  `IDMOTIVODTO` varchar(2) NOT NULL DEFAULT '-1',
  `DETALLEDENUMLINEA` varchar(2) NOT NULL DEFAULT '0',
  `FAMILIAAENA` varchar(2) NOT NULL DEFAULT '0',
  `DETALLEMODIF` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_NUMERO` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_N` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_SERIE` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_FO` varchar(2) NOT NULL DEFAULT '-1',
  `NORDERTIQUET` varchar(1) NOT NULL DEFAULT '0',
  `SORDERTIQUET` varchar(1) NOT NULL DEFAULT '',
  `REQ` int NOT NULL DEFAULT '0',
  `COSTEIVA` int NOT NULL DEFAULT '0',
  `DTO` int NOT NULL DEFAULT '0',
  `TIPO` varchar(2) NOT NULL DEFAULT 'V',
  `CODMACRO` int NOT NULL DEFAULT '0',
  `CODFORMATO` int NOT NULL DEFAULT '0',
  `NUMLINEA` int NOT NULL DEFAULT '1',
  `codigociudad` varchar(5) DEFAULT NULL,
  `email` varchar(5) DEFAULT NULL,
  `codigopostal` varchar(5) DEFAULT NULL,
  `codigodepartamento` varchar(5) DEFAULT NULL,
  `departamento` varchar(5) DEFAULT NULL,
  `ciudad` varchar(5) DEFAULT NULL,
  `cufe` varchar(5) DEFAULT NULL,
  `unidaddemedida` varchar(25) DEFAULT NULL,
  `esnota` int DEFAULT '0',
  `impreso` int DEFAULT '0',
  `domicilio` int DEFAULT '0',
  `domicilioexterno` int DEFAULT '0',
  `pv` varchar(25) DEFAULT 'texasburgers',
  `zonaventas` varchar(25) DEFAULT NULL,
  `seccionventas` varchar(25) DEFAULT NULL,
  `situacioncocina2` varchar(25) DEFAULT 'SELECCIONE',
  `integraconfamilia` int DEFAULT '1',
  `codmodifpapa` int DEFAULT '0',
  `TIPOIVA` int DEFAULT '1',
  `sesubearappi` int DEFAULT '0',
  `refventas` varchar(20) DEFAULT NULL,
  `placa` varchar(6) DEFAULT NULL,
  `iddomiciliario` int DEFAULT NULL,
  `horaaceptado` datetime DEFAULT NULL,
  `comandaaceptada` bit(1) DEFAULT b'0',
  `horaacancelada` datetime DEFAULT NULL,
  `comandacancelada` bit(1) DEFAULT b'0',
  `motivocancela` varchar(25) DEFAULT NULL,
  `paqueterecibido` bit(1) DEFAULT b'0',
  `hora_paqueterecibido` bit(1) DEFAULT b'0',
  `porcentajecomision` decimal(5,2) DEFAULT '0.00',
  `articulovence` date DEFAULT NULL,
  `deberecoger` datetime DEFAULT NULL,
  `imei` varchar(50) DEFAULT NULL,
  `factor` int DEFAULT '1',
  `puntosrevisados` bit(1) DEFAULT b'0',
  `idusuarioredime` int DEFAULT NULL,
  `usuarioredime` varchar(50) DEFAULT NULL,
  `fecharedime` datetime DEFAULT NULL,
  `costomenu` decimal(11,2) DEFAULT '0.00',
  `comensales` int DEFAULT '0',
  `impultraprocesados` int DEFAULT '0',
  `impazucaradas` int DEFAULT '0',
  `idmayornomina` int DEFAULT '0',
  `tipodescuento` varchar(15) DEFAULT NULL,
  `porcentajesobrecargoeventos` double DEFAULT '0',
  `sobrecargoeventos` double DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `idfactura` (`idfactura`),
  KEY `idarticulo` (`idarticulo`),
  KEY `idcc` (`cc`),
  KEY `idcliente` (`idcliente`),
  KEY `idusuario` (`idusuario`),
  KEY `idz` (`idz`),
  KEY `idvendedor` (`idvendedor`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `ventas2022`
--


--
-- Table structure for table `ventas2023`
--

CREATE TABLE `ventas2023` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `codvendedor` int NOT NULL DEFAULT '0',
  `REFERENCIA` varchar(20) DEFAULT NULL,
  `situacioncocina` varchar(50) DEFAULT NULL,
  `idfactura` bigint unsigned NOT NULL,
  `consecutivo` int NOT NULL,
  `INCREMENTO` int NOT NULL,
  `codarticulo` int NOT NULL,
  `codsituacion` int NOT NULL,
  `porcentajedescuento` double DEFAULT '0',
  `referenciafront` varchar(15) DEFAULT NULL,
  `impuesto` double DEFAULT '0',
  `idarticulo` bigint unsigned NOT NULL,
  `descripcion` varchar(120) DEFAULT NULL,
  `esmodificador` int DEFAULT '0',
  `nombrearticulo` varchar(100) DEFAULT NULL,
  `cantidad` double NOT NULL DEFAULT '0',
  `comentario` varchar(200) DEFAULT NULL,
  `observaciones` varchar(200) DEFAULT NULL,
  `valorunitario` double NOT NULL DEFAULT '0',
  `idmesa` int NOT NULL DEFAULT '1',
  `bruto` double NOT NULL DEFAULT '0',
  `baseunitario` double NOT NULL DEFAULT '0',
  `ivaunitario` double NOT NULL DEFAULT '0',
  `descuento` int NOT NULL DEFAULT '0',
  `valortotal` double NOT NULL DEFAULT '0',
  `cc` int DEFAULT '2',
  `documento` varchar(3) NOT NULL DEFAULT 'V',
  `origen` varchar(25) DEFAULT NULL,
  `fecha` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `fechacreacion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `HORAINI` datetime DEFAULT NULL,
  `HORAFIN` datetime DEFAULT NULL,
  `ultimaedicion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `idcliente` bigint unsigned NOT NULL DEFAULT '0',
  `idusuario` bigint unsigned NOT NULL DEFAULT '1',
  `idz` bigint unsigned NOT NULL DEFAULT '1',
  `abonado` int NOT NULL DEFAULT '0',
  `idfacturaqueabona` int NOT NULL DEFAULT '0',
  `costomedio` double DEFAULT '0',
  `porcentajeiva` double NOT NULL DEFAULT '0',
  `base` double NOT NULL DEFAULT '0',
  `iva` double NOT NULL DEFAULT '0',
  `esbolsillo` int NOT NULL DEFAULT '0',
  `idvendedor` bigint unsigned NOT NULL DEFAULT '1',
  `escortesia` int NOT NULL DEFAULT '0',
  `idcaja` bigint unsigned NOT NULL DEFAULT '1',
  `idnc` bigint unsigned NOT NULL DEFAULT '1',
  `nc` int DEFAULT '0',
  `idusuarionc` bigint unsigned NOT NULL DEFAULT '1',
  `mediodepago` varchar(25) NOT NULL DEFAULT 'EFECTIVO',
  `comision` int NOT NULL DEFAULT '0',
  `devolucionrevisada` int DEFAULT '0',
  `fechaabonado` datetime DEFAULT NULL,
  `fechamc` datetime DEFAULT NULL,
  `tienenc` int NOT NULL DEFAULT '0',
  `marcadoparanc` int NOT NULL DEFAULT '0',
  `servicio` int NOT NULL DEFAULT '0',
  `subido` int NOT NULL DEFAULT '0',
  `CODMODIF` int DEFAULT '0',
  `esmodif` int NOT NULL DEFAULT '0',
  `CODARTICULOABAJO` varchar(12) NOT NULL DEFAULT '',
  `PRECIOIVA` int NOT NULL DEFAULT '0',
  `NUMMODIF` int NOT NULL DEFAULT '0',
  `numservicio` int NOT NULL DEFAULT '0',
  `aliasespera` int NOT NULL DEFAULT '1',
  `impresiones` int NOT NULL DEFAULT '1',
  `IDMOTIVODTO` varchar(2) NOT NULL DEFAULT '-1',
  `DETALLEDENUMLINEA` varchar(2) NOT NULL DEFAULT '0',
  `FAMILIAAENA` varchar(2) NOT NULL DEFAULT '0',
  `DETALLEMODIF` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_NUMERO` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_N` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_SERIE` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_FO` varchar(2) NOT NULL DEFAULT '-1',
  `NORDERTIQUET` varchar(1) NOT NULL DEFAULT '0',
  `SORDERTIQUET` varchar(1) NOT NULL DEFAULT '',
  `REQ` int NOT NULL DEFAULT '0',
  `COSTEIVA` int NOT NULL DEFAULT '0',
  `DTO` int NOT NULL DEFAULT '0',
  `TIPO` varchar(2) NOT NULL DEFAULT 'V',
  `CODMACRO` int NOT NULL DEFAULT '0',
  `CODFORMATO` int NOT NULL DEFAULT '0',
  `NUMLINEA` int NOT NULL DEFAULT '1',
  `codigociudad` varchar(5) DEFAULT NULL,
  `email` varchar(5) DEFAULT NULL,
  `codigopostal` varchar(5) DEFAULT NULL,
  `codigodepartamento` varchar(5) DEFAULT NULL,
  `departamento` varchar(5) DEFAULT NULL,
  `ciudad` varchar(5) DEFAULT NULL,
  `cufe` varchar(5) DEFAULT NULL,
  `unidaddemedida` varchar(25) DEFAULT NULL,
  `esnota` int DEFAULT '0',
  `impreso` int DEFAULT '0',
  `domicilio` int DEFAULT '0',
  `domicilioexterno` int DEFAULT '0',
  `pv` varchar(25) DEFAULT 'texasburgers',
  `zonaventas` varchar(25) DEFAULT NULL,
  `seccionventas` varchar(25) DEFAULT NULL,
  `situacioncocina2` varchar(25) DEFAULT 'SELECCIONE',
  `integraconfamilia` int DEFAULT '1',
  `codmodifpapa` int DEFAULT '0',
  `TIPOIVA` int DEFAULT '1',
  `sesubearappi` int DEFAULT '0',
  `refventas` varchar(20) DEFAULT NULL,
  `placa` varchar(6) DEFAULT NULL,
  `iddomiciliario` int DEFAULT NULL,
  `horaaceptado` datetime DEFAULT NULL,
  `comandaaceptada` bit(1) DEFAULT b'0',
  `horaacancelada` datetime DEFAULT NULL,
  `comandacancelada` bit(1) DEFAULT b'0',
  `motivocancela` varchar(25) DEFAULT NULL,
  `paqueterecibido` bit(1) DEFAULT b'0',
  `hora_paqueterecibido` bit(1) DEFAULT b'0',
  `porcentajecomision` decimal(5,2) DEFAULT '0.00',
  `articulovence` date DEFAULT NULL,
  `deberecoger` datetime DEFAULT NULL,
  `imei` varchar(50) DEFAULT NULL,
  `factor` int DEFAULT '1',
  `puntosrevisados` bit(1) DEFAULT b'0',
  `idusuarioredime` int DEFAULT NULL,
  `usuarioredime` varchar(50) DEFAULT NULL,
  `fecharedime` datetime DEFAULT NULL,
  `costomenu` decimal(11,2) DEFAULT '0.00',
  `comensales` int DEFAULT '0',
  `impultraprocesados` int DEFAULT '0',
  `impazucaradas` int DEFAULT '0',
  `idmayornomina` int DEFAULT '0',
  `tipodescuento` varchar(15) DEFAULT NULL,
  `porcentajesobrecargoeventos` double DEFAULT '0',
  `sobrecargoeventos` double DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `idfactura` (`idfactura`),
  KEY `idarticulo` (`idarticulo`),
  KEY `idcc` (`cc`),
  KEY `idcliente` (`idcliente`),
  KEY `idusuario` (`idusuario`),
  KEY `idz` (`idz`),
  KEY `idvendedor` (`idvendedor`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `ventas2023`
--


--
-- Table structure for table `ventas3`
--

CREATE TABLE `ventas3` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `codvendedor` int NOT NULL DEFAULT '0',
  `REFERENCIA` varchar(20) DEFAULT NULL,
  `situacioncocina` varchar(50) DEFAULT NULL,
  `idfactura` bigint unsigned NOT NULL,
  `consecutivo` int NOT NULL,
  `INCREMENTO` int NOT NULL,
  `codarticulo` int NOT NULL,
  `codsituacion` int NOT NULL,
  `porcentajedescuento` double DEFAULT '0',
  `referenciafront` varchar(15) DEFAULT NULL,
  `impuesto` double DEFAULT '0',
  `idarticulo` bigint unsigned NOT NULL,
  `descripcion` varchar(120) DEFAULT NULL,
  `esmodificador` int DEFAULT '0',
  `nombrearticulo` varchar(100) DEFAULT NULL,
  `cantidad` double NOT NULL DEFAULT '0',
  `comentario` varchar(200) DEFAULT NULL,
  `observaciones` varchar(200) DEFAULT NULL,
  `valorunitario` double NOT NULL DEFAULT '0',
  `idmesa` int NOT NULL DEFAULT '1',
  `bruto` double NOT NULL DEFAULT '0',
  `baseunitario` double NOT NULL DEFAULT '0',
  `ivaunitario` double NOT NULL DEFAULT '0',
  `descuento` int NOT NULL DEFAULT '0',
  `valortotal` double NOT NULL DEFAULT '0',
  `cc` int DEFAULT '2',
  `documento` varchar(3) NOT NULL DEFAULT 'V',
  `origen` varchar(25) DEFAULT NULL,
  `fecha` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `fechacreacion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `HORAINI` datetime DEFAULT NULL,
  `HORAFIN` datetime DEFAULT NULL,
  `ultimaedicion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `idcliente` bigint unsigned NOT NULL DEFAULT '0',
  `idusuario` bigint unsigned NOT NULL DEFAULT '1',
  `idz` bigint unsigned NOT NULL DEFAULT '1',
  `abonado` int NOT NULL DEFAULT '0',
  `idfacturaqueabona` int NOT NULL DEFAULT '0',
  `costomedio` double DEFAULT '0',
  `porcentajeiva` double NOT NULL DEFAULT '0',
  `base` double NOT NULL DEFAULT '0',
  `iva` double NOT NULL DEFAULT '0',
  `esbolsillo` int NOT NULL DEFAULT '0',
  `idvendedor` bigint unsigned NOT NULL DEFAULT '1',
  `escortesia` int NOT NULL DEFAULT '0',
  `idcaja` bigint unsigned NOT NULL DEFAULT '1',
  `idnc` bigint unsigned NOT NULL DEFAULT '1',
  `nc` int DEFAULT '0',
  `idusuarionc` bigint unsigned NOT NULL DEFAULT '1',
  `mediodepago` varchar(25) NOT NULL DEFAULT 'EFECTIVO',
  `comision` int NOT NULL DEFAULT '0',
  `devolucionrevisada` int DEFAULT '0',
  `fechaabonado` datetime DEFAULT NULL,
  `fechamc` datetime DEFAULT NULL,
  `tienenc` int NOT NULL DEFAULT '0',
  `marcadoparanc` int NOT NULL DEFAULT '0',
  `servicio` int NOT NULL DEFAULT '0',
  `subido` int NOT NULL DEFAULT '0',
  `CODMODIF` int DEFAULT '0',
  `esmodif` int NOT NULL DEFAULT '0',
  `CODARTICULOABAJO` varchar(12) NOT NULL DEFAULT '',
  `PRECIOIVA` int NOT NULL DEFAULT '0',
  `NUMMODIF` int NOT NULL DEFAULT '0',
  `numservicio` int NOT NULL DEFAULT '0',
  `aliasespera` int NOT NULL DEFAULT '1',
  `impresiones` int NOT NULL DEFAULT '1',
  `IDMOTIVODTO` varchar(2) NOT NULL DEFAULT '-1',
  `DETALLEDENUMLINEA` varchar(2) NOT NULL DEFAULT '0',
  `FAMILIAAENA` varchar(2) NOT NULL DEFAULT '0',
  `DETALLEMODIF` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_NUMERO` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_N` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_SERIE` varchar(2) NOT NULL DEFAULT '0',
  `ABONODE_FO` varchar(2) NOT NULL DEFAULT '-1',
  `NORDERTIQUET` varchar(1) NOT NULL DEFAULT '0',
  `SORDERTIQUET` varchar(1) NOT NULL DEFAULT '',
  `REQ` int NOT NULL DEFAULT '0',
  `COSTEIVA` int NOT NULL DEFAULT '0',
  `DTO` int NOT NULL DEFAULT '0',
  `TIPO` varchar(2) NOT NULL DEFAULT 'V',
  `CODMACRO` int NOT NULL DEFAULT '0',
  `CODFORMATO` int NOT NULL DEFAULT '0',
  `NUMLINEA` int NOT NULL DEFAULT '1',
  `codigociudad` varchar(5) DEFAULT NULL,
  `email` varchar(5) DEFAULT NULL,
  `codigopostal` varchar(5) DEFAULT NULL,
  `codigodepartamento` varchar(5) DEFAULT NULL,
  `departamento` varchar(5) DEFAULT NULL,
  `ciudad` varchar(5) DEFAULT NULL,
  `cufe` varchar(5) DEFAULT NULL,
  `unidaddemedida` varchar(25) DEFAULT NULL,
  `esnota` int DEFAULT '0',
  `impreso` int DEFAULT '0',
  `domicilio` int DEFAULT '0',
  `domicilioexterno` int DEFAULT '0',
  `pv` varchar(25) DEFAULT 'texasburgers',
  `zonaventas` varchar(25) DEFAULT NULL,
  `seccionventas` varchar(25) DEFAULT NULL,
  `situacioncocina2` varchar(25) DEFAULT 'SELECCIONE',
  `integraconfamilia` int DEFAULT '1',
  `codmodifpapa` int DEFAULT '0',
  `TIPOIVA` int DEFAULT '1',
  `sesubearappi` int DEFAULT '0',
  `refventas` varchar(20) DEFAULT NULL,
  `placa` varchar(6) DEFAULT NULL,
  `iddomiciliario` int DEFAULT NULL,
  `horaaceptado` datetime DEFAULT NULL,
  `comandaaceptada` bit(1) DEFAULT b'0',
  `horaacancelada` datetime DEFAULT NULL,
  `comandacancelada` bit(1) DEFAULT b'0',
  `motivocancela` varchar(25) DEFAULT NULL,
  `paqueterecibido` bit(1) DEFAULT b'0',
  `hora_paqueterecibido` bit(1) DEFAULT b'0',
  `porcentajecomision` decimal(5,2) DEFAULT '0.00',
  `articulovence` date DEFAULT NULL,
  `deberecoger` datetime DEFAULT NULL,
  `imei` varchar(50) DEFAULT NULL,
  `factor` int DEFAULT '1',
  `puntosrevisados` bit(1) DEFAULT b'0',
  `idusuarioredime` int DEFAULT NULL,
  `usuarioredime` varchar(50) DEFAULT NULL,
  `fecharedime` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `idfactura` (`idfactura`),
  KEY `idarticulo` (`idarticulo`),
  KEY `idcc` (`cc`),
  KEY `idcliente` (`idcliente`),
  KEY `idusuario` (`idusuario`),
  KEY `idz` (`idz`),
  KEY `idvendedor` (`idvendedor`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `ventas3`
--


--
-- Table structure for table `ventasauxiliar`
--

CREATE TABLE `ventasauxiliar` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `idmesarelacionada` int DEFAULT '0',
  `estadoimpresion` int DEFAULT '0',
  `identificador` varchar(100) DEFAULT NULL,
  `enviadoalospv` smallint DEFAULT '0',
  `referenciafront` varchar(15) DEFAULT NULL,
  `descripcion` varchar(120) DEFAULT NULL,
  `pagarcontraentrega` int DEFAULT '0',
  `idmesa` int DEFAULT '1',
  `descuento` double NOT NULL DEFAULT '0',
  `codsituacion` int DEFAULT NULL,
  `idcliente` bigint unsigned NOT NULL DEFAULT '1',
  `idarticulo` bigint unsigned NOT NULL,
  `cc` int DEFAULT '2',
  `origen` varchar(15) DEFAULT 'MESAS',
  `comentario` varchar(200) DEFAULT NULL,
  `observaciones` varchar(200) DEFAULT NULL,
  `valorunitario` double DEFAULT '0',
  `cantidad` int DEFAULT '0',
  `valortotal` double DEFAULT '0',
  `fecha` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `fechacreacion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `fechaentregado` datetime DEFAULT NULL,
  `idusuario` bigint unsigned NOT NULL DEFAULT '1',
  `costomedio` double DEFAULT '0',
  `porcentajeiva` double NOT NULL DEFAULT '0',
  `idvendedor` bigint unsigned NOT NULL DEFAULT '1',
  `idcaja` bigint unsigned NOT NULL DEFAULT '1',
  `nota` varchar(25) NOT NULL DEFAULT '',
  `observacion` varchar(25) NOT NULL DEFAULT '',
  `despachado` int NOT NULL DEFAULT '0' COMMENT 'Significa que la cocina ya sirviÃ² el producto',
  `entregado` int NOT NULL DEFAULT '0' COMMENT 'Significa que la cocina ya sirviÃ² el producto',
  `enespera` int NOT NULL DEFAULT '0' COMMENT 'para que el mesero ya no pueda eliminar',
  `comision` int NOT NULL DEFAULT '0',
  `porcentajedescuento` double DEFAULT '0',
  `impuesto` double NOT NULL DEFAULT '0',
  `base` double NOT NULL DEFAULT '0',
  `servicio` double NOT NULL DEFAULT '0',
  `CODMODIF` int NOT NULL DEFAULT '0',
  `numlinea` int NOT NULL DEFAULT '0',
  `esmodif` int NOT NULL DEFAULT '0',
  `situacioncocina` varchar(50) DEFAULT NULL,
  `CODARTICULOABAJO` int NOT NULL DEFAULT '0',
  `COD_SATELITE` varchar(25) DEFAULT NULL,
  `unidaddemedida` varchar(25) DEFAULT NULL,
  `impreso` int DEFAULT '0',
  `domicilio` int DEFAULT '0',
  `domicilioexterno` int DEFAULT '0',
  `PrecuentaCallcenter` int DEFAULT '0',
  `pv` varchar(25) DEFAULT 'KALDI',
  `placa` varchar(8) DEFAULT NULL,
  `seccion` varchar(25) DEFAULT NULL,
  `bodega` varchar(25) DEFAULT NULL,
  `situacioncocina2` varchar(25) DEFAULT 'SELECCIONE',
  `refventas` varchar(20) DEFAULT NULL,
  `referencia` varchar(25) DEFAULT NULL,
  `enviaraproduccion` int DEFAULT '0',
  `baseunitario` decimal(11,2) DEFAULT '0.00',
  `impuestounitario` decimal(11,2) DEFAULT '0.00',
  `iddomiciliario` int DEFAULT NULL,
  `ultimocostev` double DEFAULT '0',
  `recibidovaux` double DEFAULT '0',
  `devueltavaux` double DEFAULT '0',
  `seccionventas` varchar(25) DEFAULT NULL,
  `porcentajecomision` decimal(5,2) DEFAULT '0.00',
  `articulovence` date DEFAULT NULL,
  `imei` varchar(50) DEFAULT NULL,
  `factor` int DEFAULT '1',
  `sefactura` bit(1) DEFAULT b'1',
  `costomenu` decimal(11,2) DEFAULT '0.00',
  `comensales` int DEFAULT '0',
  `comanda` varchar(10) DEFAULT '0',
  `impultraprocesados` int DEFAULT '0',
  `impazucaradas` int DEFAULT '0',
  `comocalculardescuento` varchar(10) DEFAULT 'porcentaje',
  `recibidoencallcenter` int DEFAULT '0',
  `tipodescuento` varchar(15) DEFAULT NULL,
  `porcentajesobrecargoeventos` double DEFAULT '0',
  `sobrecargoeventos` double DEFAULT '0',
  `sgroupname` int DEFAULT '0',
  `campovalor` varchar(25) DEFAULT 'valordeventa',
  `proximocosto` double DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `idarticulo` (`idarticulo`),
  KEY `idcc` (`cc`),
  KEY `idusuario` (`idusuario`),
  KEY `idvendedor` (`idvendedor`),
  KEY `idcliente` (`idcliente`),
  CONSTRAINT `ventasauxiliar_ibfk_3` FOREIGN KEY (`idusuario`) REFERENCES `clientes` (`id`),
  CONSTRAINT `ventasauxiliar_ibfk_4` FOREIGN KEY (`idvendedor`) REFERENCES `clientes` (`id`),
  CONSTRAINT `ventasauxiliar_ibfk_6` FOREIGN KEY (`idcliente`) REFERENCES `clientes` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=29756 DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `ventasauxiliar`
--


--
-- Table structure for table `ventasauxiliar2`
--

CREATE TABLE `ventasauxiliar2` (
  `idmesarelacionada` int DEFAULT '0',
  `estadoimpresion` int DEFAULT '0',
  `identificador` varchar(100) DEFAULT NULL,
  `referenciapayu` varchar(200) DEFAULT NULL,
  `referenciafront` varchar(15) DEFAULT NULL,
  `descripcion` varchar(120) DEFAULT NULL,
  `pagarcontraentrega` int DEFAULT '0',
  `idmesa` int DEFAULT '1',
  `descuento` double NOT NULL DEFAULT '0',
  `codsituacion` int DEFAULT NULL,
  `idcliente` bigint unsigned NOT NULL DEFAULT '1',
  `idarticulo` bigint unsigned NOT NULL,
  `cc` bigint unsigned NOT NULL DEFAULT '2',
  `origen` varchar(25) DEFAULT NULL,
  `comentario` varchar(200) DEFAULT NULL,
  `observaciones` varchar(200) DEFAULT NULL,
  `valorunitario` double NOT NULL DEFAULT '0',
  `cantidad` int DEFAULT '0',
  `valortotal` double NOT NULL DEFAULT '0',
  `fecha` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `fechacreacion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `fechaentregado` datetime DEFAULT NULL,
  `idusuario` bigint unsigned NOT NULL DEFAULT '1',
  `costomedio` double DEFAULT '0',
  `porcentajeiva` double NOT NULL DEFAULT '0',
  `idvendedor` bigint unsigned NOT NULL DEFAULT '1',
  `idcaja` bigint unsigned NOT NULL DEFAULT '1',
  `nota` varchar(25) NOT NULL DEFAULT '',
  `observacion` varchar(25) NOT NULL DEFAULT '',
  `despachado` int NOT NULL DEFAULT '0' COMMENT 'Significa que la cocina ya sirviÃ² el producto',
  `entregado` int NOT NULL DEFAULT '0' COMMENT 'Significa que la cocina ya sirviÃ² el producto',
  `enespera` int NOT NULL DEFAULT '0' COMMENT 'para que el mesero ya no pueda eliminar',
  `comision` int NOT NULL DEFAULT '0',
  `porcentajedescuento` double NOT NULL DEFAULT '0',
  `impuesto` double NOT NULL DEFAULT '0',
  `base` double NOT NULL DEFAULT '0',
  `servicio` double NOT NULL DEFAULT '0',
  `CODMODIF` int NOT NULL DEFAULT '0',
  `numlinea` int NOT NULL DEFAULT '0',
  `esmodif` int NOT NULL DEFAULT '0',
  `situacioncocina` varchar(50) DEFAULT NULL,
  `CODARTICULOABAJO` int NOT NULL DEFAULT '0',
  `COD_SATELITE` varchar(25) DEFAULT NULL,
  `unidaddemedida` varchar(25) DEFAULT NULL,
  `impreso` int DEFAULT '0',
  `domicilio` int DEFAULT '0',
  `domicilioexterno` int DEFAULT '0',
  `PrecuentaCallcenter` int DEFAULT '0',
  `pv` varchar(25) DEFAULT 'KALDI',
  `placa` varchar(8) DEFAULT NULL,
  `seccion` varchar(25) DEFAULT NULL,
  `bodega` varchar(25) DEFAULT NULL,
  `id` int DEFAULT '0',
  KEY `idarticulo` (`idarticulo`),
  KEY `idcc` (`cc`),
  KEY `idusuario` (`idusuario`),
  KEY `idvendedor` (`idvendedor`),
  KEY `idcliente` (`idcliente`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `ventasauxiliar2`
--


--
-- Table structure for table `ventasporhoras`
--

CREATE TABLE `ventasporhoras` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `fecha` date DEFAULT NULL,
  `dato0` double NOT NULL DEFAULT '0',
  `dato1` double NOT NULL DEFAULT '0',
  `dato2` double NOT NULL DEFAULT '0',
  `dato3` double NOT NULL DEFAULT '0',
  `dato4` double NOT NULL DEFAULT '0',
  `dato5` double NOT NULL DEFAULT '0',
  `dato6` double NOT NULL DEFAULT '0',
  `cc` int NOT NULL DEFAULT '0',
  `pv` varchar(25) DEFAULT 'KALDI',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `ventasporhoras`
--

INSERT INTO `ventasporhoras` (`id`, `fecha`, `dato0`, `dato1`, `dato2`, `dato3`, `dato4`, `dato5`, `dato6`, `cc`, `pv`) VALUES (1,'2022-12-29',0,89000,172500,1508000,154500,0,0,2,'KALDI');

--
-- Table structure for table `z`
--

CREATE TABLE `z` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `fecha` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `consecutivo` int NOT NULL DEFAULT '1',
  `descuento` double NOT NULL DEFAULT '0',
  `plataseparados` double NOT NULL DEFAULT '0',
  `domicilios` double NOT NULL DEFAULT '0',
  `ventaefectivo` double NOT NULL DEFAULT '0',
  `abonosseparados` double NOT NULL DEFAULT '0',
  `bruto` double NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT '0',
  `cantidaddearticulos` int NOT NULL DEFAULT '0',
  `idusuario` bigint unsigned NOT NULL DEFAULT '1',
  `devoluciones` double NOT NULL DEFAULT '0',
  `cc` bigint unsigned NOT NULL DEFAULT '1',
  `idcierre` int NOT NULL DEFAULT '0',
  `abonos` double NOT NULL DEFAULT '0',
  `bolsillos` double NOT NULL DEFAULT '0',
  `compras` double NOT NULL DEFAULT '0',
  `consumobolsillos` double NOT NULL DEFAULT '0',
  `ventaacredito` double NOT NULL DEFAULT '0',
  `pagofacturascredito` double NOT NULL DEFAULT '0',
  `otrosgastos` double NOT NULL DEFAULT '0',
  `gastossinafectarcaja` double NOT NULL DEFAULT '0',
  `idcaja` bigint unsigned NOT NULL,
  `otrosingresos` double NOT NULL DEFAULT '0',
  `cortesia` double NOT NULL DEFAULT '0',
  `cantidaddearticuloscortesia` double NOT NULL DEFAULT '0',
  `servicios` double DEFAULT '0',
  `fisico` int DEFAULT '0',
  `prestamoaempleados` double DEFAULT '0',
  `domicilio` int DEFAULT '0',
  `abonosprestamos` int DEFAULT '0',
  `base` int DEFAULT '0',
  `ifood` int DEFAULT '0',
  `rappi` int DEFAULT '0',
  `efectivo` int DEFAULT '0',
  `transferencias` int DEFAULT '0',
  `datafono` int DEFAULT '0',
  `observaciones` varchar(200) DEFAULT NULL,
  `domicilioexterno` int DEFAULT '0',
  `notasdebitoencompra` int DEFAULT '0',
  `pv` varchar(25) DEFAULT 'KALDI',
  `abonosordenservicio` double DEFAULT '0',
  `nequi` int DEFAULT '0',
  `notascreditoenventas` double DEFAULT '0',
  `otrosgastossinafectarcaja` double DEFAULT '0',
  `devolucionesdedinero` double DEFAULT '0',
  `sistecredito` int DEFAULT '0',
  `prestamosalaempresa` int DEFAULT '0',
  `abonosprestamosin` int DEFAULT '0',
  `nomina` int DEFAULT '0',
  `anticipos` int DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `idusuario` (`idusuario`),
  KEY `cc` (`cc`)
) ENGINE=InnoDB AUTO_INCREMENT=83 DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `z`
--

INSERT INTO `z` (`id`, `fecha`, `consecutivo`, `descuento`, `plataseparados`, `domicilios`, `ventaefectivo`, `abonosseparados`, `bruto`, `total`, `cantidaddearticulos`, `idusuario`, `devoluciones`, `cc`, `idcierre`, `abonos`, `bolsillos`, `compras`, `consumobolsillos`, `ventaacredito`, `pagofacturascredito`, `otrosgastos`, `gastossinafectarcaja`, `idcaja`, `otrosingresos`, `cortesia`, `cantidaddearticuloscortesia`, `servicios`, `fisico`, `prestamoaempleados`, `domicilio`, `abonosprestamos`, `base`, `ifood`, `rappi`, `efectivo`, `transferencias`, `datafono`, `observaciones`, `domicilioexterno`, `notasdebitoencompra`, `pv`, `abonosordenservicio`, `nequi`, `notascreditoenventas`, `otrosgastossinafectarcaja`, `devolucionesdedinero`, `sistecredito`, `prestamosalaempresa`, `abonosprestamosin`, `nomina`, `anticipos`) VALUES (1,'2020-12-24 19:28:24',1,0,0,0,4369900,0,3232315,4369900,1022,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,4369900,0,28000,0,0,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(2,'2025-09-06 21:00:16',4,0,0,0,2162101,0,2162101,2162101,549,5,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,2162101,0,0,0,220000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(3,'2025-09-07 20:25:25',5,0,0,0,2362300,0,2362300,2362300,569,5,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,2362300,0,0,0,235000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(4,'2025-09-08 21:03:11',6,0,0,0,905800,0,905800,905800,227,5,0,2,0,0,0,0,0,0,0,37000,0,1,0,0,0,0,868800,0,0,0,235000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(5,'2025-09-09 20:35:57',7,0,0,0,629800,0,629800,629800,169,5,0,2,0,0,0,0,0,0,0,45700,0,1,0,0,0,0,584100,0,0,0,235000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(6,'2025-09-10 20:51:29',8,0,0,0,653900,0,653900,653900,185,5,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,653900,0,0,0,235000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(7,'2025-09-11 20:24:36',9,0,0,0,1018500,0,1018500,1018500,283,5,0,2,0,0,0,0,0,0,0,36000,0,1,0,0,0,0,982500,0,0,0,235000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(8,'2025-09-12 20:58:21',10,0,0,0,1375800,0,1375800,1375800,391,5,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1375800,0,0,0,235000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(9,'2025-09-13 22:16:33',11,0,0,0,2019800,0,2019800,2019800,551,5,0,2,0,0,0,0,0,0,0,93000,0,1,0,0,0,0,1926800,0,0,0,235000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(10,'2025-09-14 21:31:18',12,0,0,0,2884300,0,2884300,2884300,799,5,0,2,0,0,0,0,0,0,0,12000,0,1,0,0,0,0,2872300,0,0,0,342000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(11,'2025-09-15 20:34:28',13,0,0,0,875800,0,875800,875800,259,5,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,875800,0,0,0,342500,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(12,'2025-09-16 20:06:14',14,0,0,0,729000,0,729000,729000,212,5,0,2,0,0,0,0,0,0,0,20000,0,1,0,0,0,0,709000,0,0,0,228800,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(13,'2025-09-17 20:10:23',15,0,0,0,695500,0,695500,695500,196,5,0,2,0,0,0,0,0,0,0,45250,0,1,0,0,0,0,650250,0,0,0,228800,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(14,'2025-09-18 20:13:22',16,0,0,0,646300,0,646300,646300,177,5,0,2,0,0,0,0,0,0,0,6000,0,1,0,0,0,0,640300,0,0,0,228400,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(15,'2025-09-19 21:01:29',17,0,0,0,1628000,0,1628000,1628000,484,5,0,2,0,0,0,0,0,0,0,117000,0,1,0,0,0,0,1511000,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(16,'2025-09-20 21:15:03',18,0,0,0,2664000,0,2664000,2664000,742,5,0,2,0,0,0,0,0,0,0,76400,0,1,0,0,0,0,2587600,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(17,'2025-09-21 20:07:50',19,0,0,0,2521800,0,2521800,2521800,723,5,0,2,0,0,0,0,0,0,0,52000,0,1,0,0,0,0,2469800,0,0,0,226000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(18,'2025-09-22 20:06:45',20,0,0,0,717000,0,717000,717000,212,5,0,2,0,0,0,0,0,0,0,27320,0,1,0,0,0,0,689680,0,0,0,225900,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(19,'2025-09-23 20:23:27',21,0,0,0,745300,0,745300,745300,214,5,0,2,0,0,0,0,0,0,0,46000,0,1,0,0,0,0,699300,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(20,'2025-09-24 20:47:17',22,0,0,0,527000,0,527000,527000,152,5,0,2,0,0,0,0,0,0,0,6000,0,1,0,0,0,0,521000,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(21,'2025-09-25 20:13:13',23,0,0,0,490000,0,490000,490000,145,5,0,2,0,0,0,0,0,0,0,3300,0,1,0,0,0,0,486700,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(22,'2025-09-26 21:45:10',24,0,0,0,1395000,0,1395000,1395000,398,5,0,2,0,0,0,0,0,0,0,110380,0,1,0,0,0,0,1284620,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(23,'2025-09-27 21:18:25',25,0,0,0,1827400,0,1827400,1827400,505,5,0,2,0,0,0,0,0,0,0,88000,0,1,0,0,0,0,1739400,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(24,'2025-09-28 20:45:10',26,0,0,0,2489000,0,2489000,2489000,688,5,0,2,0,0,0,0,0,0,0,463392,0,1,0,0,0,0,2025608,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(25,'2025-09-29 19:59:29',27,0,0,0,730500,0,730500,730500,207,5,0,2,0,0,0,0,0,0,0,42800,0,1,0,0,0,0,687700,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(26,'2025-09-30 20:16:56',28,0,0,0,688000,0,688000,688000,190,5,0,2,0,0,0,0,0,0,0,10000,0,1,0,0,0,0,678000,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(27,'2025-10-01 20:50:20',29,0,0,0,936800,0,936800,936800,270,5,0,2,0,0,0,0,0,0,0,33250,0,1,0,0,0,0,903550,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(28,'2025-10-02 20:00:59',30,0,0,0,795800,0,795800,795800,233,5,0,2,0,0,0,0,0,0,0,162580,0,1,0,0,0,0,633220,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(29,'2025-10-03 20:17:21',31,0,0,0,1068800,0,1068800,1068800,293,5,0,2,0,0,0,0,0,0,0,21788,0,1,0,0,0,0,1047012,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(30,'2025-10-04 20:51:52',32,0,0,0,1899000,0,1899000,1899000,515,5,0,2,0,0,0,0,0,0,0,6000,0,1,0,0,0,0,1893000,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(31,'2025-10-05 20:06:10',33,0,0,0,2003100,0,2003100,2003100,543,5,0,2,0,0,0,0,0,0,0,43400,0,1,0,0,0,0,1959700,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(32,'2025-10-06 20:29:14',34,0,0,0,773800,0,773800,773800,200,5,0,2,0,0,0,0,0,0,0,115681,0,1,0,0,0,0,658119,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(33,'2025-10-07 20:15:25',35,0,0,0,600800,0,600800,600800,165,5,0,2,0,0,0,0,0,0,0,87250,0,1,0,0,0,0,513550,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(34,'2025-10-08 20:12:13',36,0,0,0,606000,0,606000,606000,156,5,0,2,0,0,0,0,0,0,0,54000,0,1,0,0,0,0,552000,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(35,'2025-10-09 20:26:07',37,0,0,0,833000,0,833000,833000,234,5,0,2,0,0,0,0,0,0,0,99300,0,1,0,0,0,0,733700,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(36,'2025-10-10 20:52:35',38,0,0,0,1155600,0,1155600,1155600,301,5,0,2,0,0,0,0,0,0,0,65380,0,1,0,0,0,0,1090220,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(37,'2025-10-11 20:34:50',39,0,0,0,1672500,0,1672500,1672500,474,5,0,2,0,0,0,0,0,0,0,28413,0,1,0,0,0,0,1644087,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(38,'2025-10-12 20:44:17',40,0,0,0,1668400,0,1668400,1668400,434,5,0,2,0,0,0,0,0,0,0,95925,0,1,0,0,0,0,1572475,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(39,'2025-10-13 19:59:59',41,0,0,0,1228000,0,1228000,1228000,337,5,0,2,0,0,0,0,0,0,0,55000,0,1,0,0,0,0,1173000,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(40,'2025-10-14 19:50:00',42,0,0,0,541000,0,541000,541000,160,5,62600,2,0,0,0,0,0,0,0,102000,0,1,0,0,0,0,376400,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(41,'2025-10-15 19:55:41',43,0,0,0,423500,0,423500,423500,105,5,0,2,0,0,0,0,0,0,0,95900,0,1,0,0,0,0,327600,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(42,'2025-10-16 20:12:18',44,0,0,0,314500,0,314500,314500,92,5,0,2,0,0,0,0,0,0,0,73000,0,1,0,0,0,0,241500,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(43,'2025-10-17 21:09:46',45,0,0,0,602500,0,602500,602500,163,5,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,602500,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(44,'2025-10-18 20:56:35',46,0,0,0,2286400,0,2286400,2286400,651,5,0,2,0,0,0,0,0,0,0,220000,0,1,0,0,0,0,2066400,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(45,'2025-10-19 19:55:37',47,0,0,0,2190700,0,2190700,2190700,597,5,0,2,0,0,0,0,0,0,0,100500,0,1,0,0,0,0,2090200,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(46,'2025-10-20 20:25:40',48,0,0,0,541600,0,541600,541600,152,5,0,2,0,0,0,0,0,0,0,103880,0,1,0,0,0,0,437720,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(47,'2025-10-21 19:57:30',49,0,0,0,387000,0,387000,387000,104,5,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,387000,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(48,'2025-10-22 19:55:25',50,0,0,0,484500,0,484500,484500,142,5,0,2,0,0,0,0,0,0,0,55000,0,1,0,0,0,0,429500,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(49,'2025-10-23 20:08:24',51,0,0,0,374300,0,374300,374300,110,5,0,2,0,0,0,0,0,0,0,91500,0,1,0,0,0,0,282800,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(50,'2025-10-24 21:10:16',52,0,0,0,515300,0,515300,515300,143,5,0,2,0,0,0,0,0,0,0,55000,0,1,0,0,0,0,460300,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(51,'2025-10-25 21:06:37',53,0,0,0,2403300,0,2403300,2403300,699,5,0,2,0,0,0,0,0,0,0,110000,0,1,0,0,0,0,2293300,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(52,'2025-10-26 20:33:18',54,0,0,0,2369800,0,2369800,2369800,680,5,0,2,0,0,0,0,0,0,0,214390,0,1,0,0,0,0,2155410,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(53,'2025-10-27 19:52:44',55,0,0,0,452500,0,452500,452500,135,5,0,2,0,0,0,0,0,0,0,60000,0,1,0,0,0,0,392500,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(54,'2025-10-28 19:58:04',56,0,0,0,495000,0,495000,495000,138,5,0,2,0,0,0,0,0,0,0,55000,0,1,0,0,0,0,440000,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(55,'2025-10-29 19:59:55',57,0,0,0,569500,0,569500,569500,165,5,0,2,0,0,0,0,0,0,0,163000,0,1,0,0,0,0,406500,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(56,'2025-10-30 20:09:13',58,0,0,0,534500,0,534500,534500,146,5,0,2,0,0,0,0,0,0,0,55000,0,1,0,0,0,0,479500,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(57,'2025-10-31 21:49:20',59,0,0,0,2034500,0,2034500,2034500,532,5,0,2,0,0,0,0,0,0,0,85000,0,1,0,0,0,0,1949500,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(58,'2025-11-01 20:58:54',60,0,0,0,1891300,0,1891300,1891300,544,5,0,2,0,0,0,0,0,0,0,27000,0,1,0,0,0,0,1864300,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(59,'2025-11-02 20:50:18',61,0,0,0,2491600,0,2491600,2491600,697,5,0,2,0,0,0,0,0,0,0,54000,0,1,0,0,0,0,2437600,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(60,'2025-11-03 20:21:00',62,0,0,0,2187000,0,2187000,2187000,620,5,0,2,0,0,0,0,0,0,0,36000,0,1,0,0,0,0,2151000,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(61,'2025-11-04 19:58:49',63,0,0,0,560300,0,560300,560300,164,5,0,2,0,0,0,0,0,0,0,34600,0,1,0,0,0,0,525700,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(62,'2025-11-05 19:17:35',64,0,0,0,487500,0,487500,487500,143,5,0,2,0,0,0,0,0,0,0,23500,0,1,0,0,0,0,464000,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(63,'2025-11-06 19:45:06',65,0,0,0,286601,0,286601,286601,89,5,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,286601,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(64,'2025-11-07 21:00:48',66,0,0,0,831000,0,831000,831000,239,5,0,2,0,0,0,0,0,0,0,153440,0,1,0,0,0,0,677560,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(65,'2025-11-08 20:48:33',67,0,0,0,2398300,0,2398300,2398300,659,5,0,2,0,0,0,0,0,0,0,129990,0,1,0,0,0,0,2268310,0,0,0,228000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(66,'2025-11-09 19:57:06',68,0,0,0,1709300,0,1709300,1709300,469,5,0,2,0,0,0,0,0,0,0,37700,0,1,0,0,0,0,1671600,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(67,'2025-11-11 13:17:25',69,0,0,0,405000,0,405000,405000,113,5,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,405000,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(68,'2025-11-11 19:58:54',70,0,0,0,400500,0,400500,400500,117,5,0,2,0,0,0,0,0,0,0,59000,0,1,0,0,0,0,341500,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(69,'2025-11-12 20:20:51',71,0,0,0,431500,0,431500,431500,113,5,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,431500,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(70,'2025-11-13 19:55:22',72,0,0,0,386500,0,386500,386500,114,5,0,2,0,0,0,0,0,0,0,27800,0,1,0,0,0,0,358700,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(71,'2025-11-14 20:55:55',73,0,0,0,426100,0,426100,426100,124,5,0,2,0,0,0,0,0,0,0,127000,0,1,0,0,0,0,299100,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(72,'2025-11-15 21:12:29',74,0,0,0,1349800,0,1349800,1349800,364,5,0,2,0,0,0,0,0,0,0,62512,0,1,0,0,0,0,1287288,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(73,'2025-11-16 20:41:05',75,0,0,0,1828800,0,1828800,1828800,477,5,0,2,0,0,0,0,0,0,0,10000,0,1,0,0,0,0,1818800,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(74,'2025-11-17 20:18:51',76,0,0,0,1180400,0,1180400,1180400,323,5,0,2,0,0,0,0,0,0,0,34200,0,1,0,0,0,0,1146200,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(75,'2025-11-18 20:08:29',77,0,0,0,504000,0,504000,504000,142,5,0,2,0,0,0,0,0,0,0,26500,0,1,0,0,0,0,477500,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(76,'2025-11-19 19:57:28',78,0,0,0,631000,0,631000,631000,187,5,0,2,0,0,0,0,0,0,0,11813,0,1,0,0,0,0,619187,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(77,'2025-11-20 19:59:24',79,0,0,0,537000,0,537000,537000,150,5,0,2,0,0,0,0,0,0,0,36000,0,1,0,0,0,0,501000,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(78,'2025-11-21 21:42:00',80,0,0,0,854000,0,854000,854000,233,5,0,2,0,0,0,0,0,0,0,23690,0,1,0,0,0,0,830310,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(79,'2025-11-22 21:10:39',81,0,0,0,1582300,0,1582300,1582300,427,5,0,2,0,0,0,0,0,0,0,106000,0,1,0,0,0,0,1476300,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(80,'2025-11-25 20:04:11',82,0,0,0,2284600,0,2284600,2284600,630,5,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,2284600,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(81,'2025-11-26 20:08:33',83,0,0,0,479500,0,479500,479500,139,5,0,2,0,0,0,0,0,0,0,39280,0,1,0,0,0,0,440220,0,0,0,230000,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0),(82,'2025-11-27 20:09:46',84,0,0,0,593000,0,593000,593000,169,5,0,2,0,0,0,0,0,0,0,13000,0,1,0,0,0,0,580000,0,0,0,0,0,0,0,0,0,NULL,0,0,'KALDI',0,0,0,0,0,0,0,0,0,0);

--
-- Table structure for table `zonas`
--

CREATE TABLE `zonas` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `zona` varchar(25) DEFAULT NULL,
  `cc` bigint unsigned NOT NULL,
  `orden` int DEFAULT '0',
  `oculto` int DEFAULT '0',
  `COD_SATELITEZ` varchar(25) DEFAULT 'SELECCIONE',
  `pv` varchar(25) DEFAULT 'texasburgers',
  `idusuario` int DEFAULT '0',
  `eshotel` int DEFAULT '0',
  `activo` tinyint unsigned DEFAULT '1',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `cc` (`cc`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `zonas`
--

INSERT INTO `zonas` (`id`, `zona`, `cc`, `orden`, `oculto`, `COD_SATELITEZ`, `pv`, `idusuario`, `eshotel`, `activo`) VALUES (1,NULL,0,0,0,'SELECCIONE','texasburgers',0,0,1),(2,'SALON',2,5,0,'SELECCIONE','texasburgers',0,0,1);

--
-- Table structure for table `zonasclientes`
--

CREATE TABLE `zonasclientes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `codigozona` varchar(10) DEFAULT NULL,
  `nombrezona` varchar(25) DEFAULT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `zonasclientes`
--

INSERT INTO `zonasclientes` (`id`, `codigozona`, `nombrezona`) VALUES (1,NULL,'uno'),(2,NULL,''),(3,NULL,'');

--
-- Table structure for table `zonashabitaciones`
--

CREATE TABLE `zonashabitaciones` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `zona` varchar(25) DEFAULT NULL,
  `cc` bigint unsigned NOT NULL,
  `orden` int DEFAULT '0',
  `oculto` int DEFAULT '0',
  `COD_SATELITEZ` varchar(25) DEFAULT 'SELECCIONE',
  `pv` varchar(25) DEFAULT 'KALDI',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `cc` (`cc`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `zonashabitaciones`
--


--
-- Dumping routines for database 'capri2'
--
/*!50003 DROP FUNCTION IF EXISTS `biscaridfactura` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `biscaridfactura`(`consecutivoin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select id from facturas where consecutivo=consecutivoin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `biscarnombrecc` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `biscarnombrecc`(`ccin` INT(11)) RETURNS varchar(110) CHARSET utf8mb3
    SQL SECURITY INVOKER
BEGIN
DECLARE P VARCHAR(110);
SET P=(select centrodecostos from centrosdecostos where id=ccin);
RETURN ifnull(P,'DESCONOCIDO');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `bucarnombredeltercero` */;
DELIMITER ;;
CREATE DEFINER=`wwcont_texasburgers`@`%.%.%.%` FUNCTION `bucarnombredeltercero`(`idin` INT(11)) RETURNS varchar(110) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN DECLARE P varchar(110); SET P=(select if(tipodepersona=2,concat(ifnull(primernombre,''),' ',ifnull(segundonombre,''),' ',ifnull(primerapellido,''),' ',ifnull(segundoapellido,'')),concat(ifnull(razonsocial,''),' ',ifnull(nombrecomercial,''))) from clientes where id=idin); RETURN ifnull(P,'DESCONOCIDO'); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscadescripcionporrefcruzada` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`vps-385963.appitecintegraciones.com` FUNCTION `buscadescripcionporrefcruzada`(`refin` INT(11)) RETURNS varchar(50) CHARSET utf8mb3
    SQL SECURITY INVOKER
BEGIN declare a varchar(50); set a=(select descripcion from articulos where referenciacruzada=refin); return ifnull(a,'ERROR EN REFERENCIA CRUZADA'); end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarabonos` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`vps-385963.appitecintegraciones.com` FUNCTION `buscarabonos`(`idfacturain` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN DECLARE P INT(11); SET P=(select sum(valor) from abonos where idfactura=idfacturain and nc=0); RETURN ifnull(P,0); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarabonosencompras` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarabonosencompras`(`idfacturain` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN DECLARE P double; SET P=(select sum(valor) from abonoscompras where idmayorcompras=idfacturain); RETURN ifnull(P,0); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarabonosenseparados` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`vps-385963.appitecintegraciones.com` FUNCTION `buscarabonosenseparados`(`idfacturain` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN DECLARE P double; SET P=(select sum(valor) from abonosseparados where idmayorseparados=idfacturain and nc=0 and idgasto=0); RETURN ifnull(P,0); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarajustesproducto` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarajustesproducto`(`idin` INT(11), `fecha1` DATE, `fecha2` DATE) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select sum(cantidad) from ajustesdeinventario where idarticulo=idin and cast(fechacreacion as date) BETWEEN fecha1 and fecha2);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarbajasproducto` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarbajasproducto`(`idin` INT(11), `fecha1` DATE, `fecha2` DATE) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select sum(cantidad) from bajas where idarticulo=idin and cast(fecha as date)  BETWEEN fecha1 and fecha2);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarbarriotercero` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarbarriotercero`(`idin` INT(11)) RETURNS varchar(110) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN
DECLARE P varchar(110);
SET P=(select barrio from clientes where id=idin);
RETURN ifnull(P,'');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarcajaenfactura` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarcajaenfactura`(`consecutivoin` INT(11), `ccin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN DECLARE P INT(11); SET P=(select idcaja from facturas where consecutivo=consecutivoin and cc=ccin limit 1); RETURN ifnull(P,1); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarcantidaddeldia` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarcantidaddeldia`(`idarticuloin` INT(11), `fechain` DATE) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P DOUBLE;
SET P=(select AVG(cantidad) from inventarioinicial where idarticulo=idarticuloin and cast(fechacracion as date)=fechain);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarcantidadennotasdebito` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarcantidadennotasdebito`(`idarticuloin` INT(11), `idmayorin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(11);
set P=(select sum(cantidad) from lineasnotasdebito where idmayor=idmayorin and idarticulo=idarticuloin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarccdelarticulo` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarccdelarticulo`(`idin` INT(4)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(4);
SET P=(select cc from articulos where id=idin);
RETURN ifnull(P,-1);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarceduladeltercero` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarceduladeltercero`(`idin` INT(11)) RETURNS varchar(110) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN
DECLARE P varchar(20);
SET P=(select ifnull(cedula,'') from clientes where id=idin);
RETURN ifnull(P,'DESCONOCIDO');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarclientedelamesa` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarclientedelamesa`(`idmesain` INT(11)) RETURNS varchar(50) CHARSET latin1
BEGIN declare rs varchar(50); set rs=(select idcliente from ventasauxiliar where idmesa=idmesain limit 1); set rs=ifnull(rs,1); if rs>1 THEN set rs=bucarnombredeltercero(rs); ELSE set rs=''; end if; if rs='CLIENTES VARIOS' then set rs='';end if; return rs; end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarcodigoformapago` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarcodigoformapago`(`forma` VARCHAR(100)) RETURNS int
begin 
declare rs int(11);
set rs=(select orden from mediosdepago where mediodepago=forma);
return ifnull(rs,-1);
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarcodsituacion` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarcodsituacion`(`idarticuloin` INT(11)) RETURNS varchar(100) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN
declare rs varchar(150);
set rs=(select situacioncocina from articulos where id=idarticuloin);
return ifnull(rs,'Situacion indefinida');
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarcomprasporproductomesyano` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarcomprasporproductomesyano`(`idin` INT(11), `mesin` INT(2), `anoin` INT(4)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select sum(cantidad) from compras where idarticulo=idin and
       month(fecha)=mesin and year(fecha)=anoin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarcomprasproducto` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarcomprasproducto`(`idin` INT(11), `fecha1` DATE, `fecha2` DATE) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select sum(cantidad*factor) from compras where idarticulo=idin and cast(fecha as date)  BETWEEN fecha1 and fecha2);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarconsumosproducto` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarconsumosproducto`(`idin` INT(11), `fecha1` DATE, `fecha2` DATE) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(SELECT sum(movimientosdeinventario.cantidad)  from movimientosdeinventario where 
        idarticulo=idin and  cast(fechacreacion as date) between '' and '' 
         and (ventana='VENTAS' or ventana='CORTESIAS' OR ventana='DEVOLUCIONES'));
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarconteoproducto` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarconteoproducto`(`idin` INT(11), `fecha1` DATE) RETURNS varchar(11) CHARSET utf8mb3
    SQL SECURITY INVOKER
BEGIN
DECLARE P VARCHAR(11);
SET P=(select cantidad from inventarioinicial,mayoresinventarioinicial where idarticulo=idin and fecha=fecha1 and idmayor=mayoresinventarioinicial.id);
RETURN ifnull(P,'NA');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarcostomedio` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarcostomedio`(`idarticulo` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN DECLARE P double; SET P=(select costomedio from articulos where id=idarticulo); RETURN ifnull(P,0); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarcreditosdeldia` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarcreditosdeldia`(`ccin` INT(4), `fechain` DATE) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(
    select sum(facturas.total) from facturas 
       where cc=ccin and cast(fecha as date)=fechain and documento='C');
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarcuentacompras` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarcuentacompras`(`idin` INT(11)) RETURNS varchar(25) CHARSET latin1
    NO SQL
    SQL SECURITY INVOKER
BEGIN
declare a varchar(25);
set a=(select articulos.cuentacompras from articulos where id=idin);
return ifnull(a,'');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarcuentacosto` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarcuentacosto`(`idin` INT(11)) RETURNS varchar(25) CHARSET latin1
    NO SQL
    SQL SECURITY INVOKER
BEGIN
declare a varchar(25);
set a=(select articulos.cuentacosto from articulos where id=idin);
return ifnull(a,'');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarcuentaventa` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarcuentaventa`(`idin` INT(11)) RETURNS varchar(25) CHARSET latin1
    NO SQL
    SQL SECURITY INVOKER
BEGIN
declare a varchar(25);
set a=(select articulos.cuentaventa from articulos where id=idin);
return ifnull(a,'');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscardescripcion` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`localhost` FUNCTION `buscardescripcion`(`idin` INT(11)) RETURNS varchar(150) CHARSET utf8mb3
    SQL SECURITY INVOKER
BEGIN
DECLARE P varchar(150);
SET P=(select ifnull(descripcion,'') from articulos where id=idin );
RETURN ifnull(P,'');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscardescuendoespecial` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscardescuendoespecial`(`lineain` VARCHAR(50), `idgrupoin` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN declare r double; set r=(select porcentaje from descuentosporgrupo where linea=lineain and idgrupo=idgrupoin); return ifnull(r,0); end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscardescuentoporfecha` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscardescuentoporfecha`(`idarticuloin` INT(11), `horain` DATE) RETURNS int
    SQL SECURITY INVOKER
BEGIN
declare rs int(11);
set rs=(select porcentaje from porcentajesdescuentoarticulos,fechasdescuentos where fechasdescuentos.id=porcentajesdescuentoarticulos.idfecha and idarticulo=idarticuloin and fechasdescuentos.fecha=horain limit 1);
return ifnull(rs,0);
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscardiadelasemana` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscardiadelasemana`(`fechain` DATETIME) RETURNS varchar(25) CHARSET utf8mb3
    SQL SECURITY INVOKER
BEGIN
declare a varchar(25);declare b int(1);
set a='';

set b=(select DAYOFWEEK(fechain));
if b=2 then set a='Lunes'; 
elseif b=3 then set a='Martes' ;
elseif b=4 then set a='Miércoles'; 
elseif b=5 then set a='Jueves' ;
elseif b=6 then set a='Viernes';
elseif b=7 then set a='Sábado';
elseif b=1 then set a='Domingo'; 
end if;
return a;
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscardirecciontercero` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscardirecciontercero`(`idin` INT(11)) RETURNS varchar(110) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN
DECLARE P varchar(110);
SET P=(select direccion from clientes where id=idin);
RETURN ifnull(P,'');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarfactor` */;
DELIMITER ;;
CREATE DEFINER=`wwcont_texasburgers`@`%.%.%.%` FUNCTION `buscarfactor`(`idin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN declare rs int(5); set rs=(select factor from unidadesdemedida where id=idin); return ifnull(rs,1); end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarfechadefactura` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarfechadefactura`(`consecutivoin` INT(11)) RETURNS date
    SQL SECURITY INVOKER
BEGIN
DECLARE P DATE;
SET P=(select cast(fecha as date) from ventas where consecutivo=consecutivoin LIMIT 1);
RETURN ifnull(P,'');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarfisicoproducto` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarfisicoproducto`(`idin` INT(11), `fecha1` DATE) RETURNS varchar(11) CHARSET utf8mb3
    SQL SECURITY INVOKER
BEGIN
DECLARE P VARCHAR(11);
SET P=(select fisico from inventarioinicial,mayoresinventarioinicial where idarticulo=idin and fecha=fecha1 and idmayor=mayoresinventarioinicial.id);
RETURN ifnull(P,'NA');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscaridclientedelamesa` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscaridclientedelamesa`(`idmesain` INT(11), `id99` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN DECLARE rs int(1); set rs=(select idcliente from ventasauxiliar where idmesa=idmesain limit 1);
return ifnull(rs,id99); end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscaridmeseroactual` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscaridmeseroactual`(`idmesain` INT(11), `id99` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN DECLARE rs int(11); set rs=(select idvendedor  from ventasauxiliar where idmesa=idmesain limit 1); return ifnull(rs,id99); end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscaridporrefcruzada` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`vps-385963.appitecintegraciones.com` FUNCTION `buscaridporrefcruzada`(`refin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN declare a int(11); set a=(select id from articulos where referenciacruzada=refin); return ifnull(a,0); end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscaridseccion` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscaridseccion`(`seccionin` VARCHAR(50)) RETURNS int
    SQL SECURITY INVOKER
BEGIN DECLARE P int(11); SET P=(select ifnull(id,0) from secciones where seccion=seccionin); RETURN ifnull(P,0); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscaridunicodecliente` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscaridunicodecliente`(`nombrein` VARCHAR(100)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select id from clientes where primernombre=nombrein);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscaridunidad` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscaridunidad`(`unidadin` VARCHAR(50), `ccin` INT(1)) RETURNS int
    SQL SECURITY INVOKER
BEGIN DECLARE P int(11); SET P=(select ifnull(id,1) from unidadesdemedida where unidaddemedida=unidadin and cc=ccin); RETURN ifnull(P,1); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarimpresora` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarimpresora`(`situacionin` VARCHAR(100)) RETURNS varchar(105) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN
declare rs varchar(150);
set rs=(select nombreimpresora from situacionesdecocina where situacioncocina=situacionin);
return ifnull(rs,'Situacion indefinida');
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarinventariodeinsumos` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarinventariodeinsumos`(`idarticuloin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE q int(11);
SET q=(select tienecomposicion from articulos where id=idarticuloin);
if(q=0) THEN  
set q=(select cantidad from articulos where id=idarticuloin);
ELSE 
SET q=(select min(cantidad) from articulos where id in(select idinsumo from componentesarticulos where idarticulo=idarticuloin));
END IF;
RETURN ifnull(q,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarlineadelarticulo` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarlineadelarticulo`(`idarticuloin` INT(11)) RETURNS varchar(100) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN DECLARE rs varchar(100); 
set rs=(select linea  from articulos where id=idarticuloin ); return ifnull(rs,''); end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarmediodepago` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarmediodepago`(`idin` INT) RETURNS varchar(15) CHARSET latin1
    NO SQL
    SQL SECURITY INVOKER
BEGIN
declare a varchar(15);
declare b int(1);
set b=(select count(id) from registrosmediosdepago where idfactura=idin);
       if b>1 then 
       set a='VARIOS';
       ELSE
       set a=(select mediodepago from registrosmediosdepago where idfactura=idin);
       end if;
       return a;
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarnombrecc` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarnombrecc`(`ccin` INT(11)) RETURNS varchar(110) CHARSET utf8mb3
    SQL SECURITY INVOKER
BEGIN
DECLARE P VARCHAR(110);
SET P=(select centrodecostos from centrosdecostos where id=ccin);
RETURN ifnull(P,'DESCONOCIDO');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarnombreclientedelamesa` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarnombreclientedelamesa`(`idmesain` INT(11)) RETURNS varchar(100) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN
DECLARE rs varchar(100);
set rs=(select bucarnombredeltercero(idcliente) from ventasauxiliar where idmesa=idmesain limit 1);
return ifnull(rs,'');
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarnombredelamesa` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarnombredelamesa`(`idin` INT(5)) RETURNS varchar(50) CHARSET latin1
    NO SQL
BEGIN
declare a varchar(50);
set a=(select nombre from mesas where id=idin);
return ifnull(a,' '); 
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarnombredelamesadividida` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarnombredelamesadividida`(`idmesain` INT(11)) RETURNS varchar(25) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN
declare a varchar(25);
set a=(select mesas.nombre from mesas, ventasauxiliar where ventasauxiliar.idmesarelacionada=mesas.id and ventasauxiliar.idmesa=idmesain limit 1);
RETURN ifnull(a,'');
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarnombredelarticulo` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarnombredelarticulo`(`idin` INT(11)) RETURNS varchar(400) CHARSET utf8mb3
    SQL SECURITY INVOKER
BEGIN DECLARE P varchar(400); SET P=(select descripcion from articulos where id=idin); RETURN ifnull(P,''); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarnotassencompras` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarnotassencompras`(`idmayorin` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN DECLARE P int(11); SET P=(select sum(valortotal) from notasdebito where idmayorescompras=idmayorin); RETURN ifnull(P,0); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarnumlinea` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarnumlinea`(`identif` VARCHAR(50), `esmodifin` INT(1)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(2);
if  esmodifin=0 then 
SET P=(select 1+max(numlinea) from ventasauxiliar where idmesa=identif and esmodif=0);
else 
SET P=(select max(numlinea) from ventasauxiliar where idmesa=identif and esmodif=0);
end if;
RETURN ifnull(P,1);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarnumlineaporcliente` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarnumlineaporcliente`(`idclientein` VARCHAR(50), `esmodifin` INT(1)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(2);
if  esmodifin=0 then 
SET P=(select 1+max(numlinea) from ventasauxiliar where idcliente=idclientein);
else 
SET P=(select max(numlinea) from ventasauxiliar where idcliente=idclientein and esmodif=0);
end if;
RETURN ifnull(P,1);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarnumlineatomapedidos` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarnumlineatomapedidos`(`identif` VARCHAR(50), `esmodifin` INT(1)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(2);
if  esmodifin=0 then 
SET P=(select 1+max(numlinea) from ventasauxiliar where identificador=identif and esmodif=0);
else 
SET P=(select max(numlinea) from ventasauxiliar where identificador=identif and esmodif=0);
end if;
RETURN ifnull(P,1);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarordendia` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarordendia`(`a` VARCHAR(10)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
declare b int(1);
set b=0;


if a='Lunes' then set b=1; 
elseif  a='Martes'  then set b=2;
elseif  a='Miércoles' then set b=3;
elseif   a='Jueves'  then set b=4;
elseif  a='Viernes' then set b=5;
elseif  a='Sábado' then set b=6;
elseif   a='Domingo' then set b=7;
end if;
return b;
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarporcentaje` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarporcentaje`(`ccin` INT(11), `idarticuloin` INT(11), `idclientein` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
if ccin=9 then return 15; end if;
SET P=(select preciosespeciales.porcentaje from preciosespeciales,articulos where idcliente=idclientein and articulos.id=idarticuloin and articulos.linea=preciosespeciales.linea);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarporcentajeporgrupo` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarporcentajeporgrupo`(`ccin` INT(4), `idclientein` INT(11), `idarticuloin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN DECLARE P INT(11); SET P=(select descuentosporgrupo.porcentaje from descuentosporgrupo,articulos,clientes,gruposdepersonas where clientes.id=idclientein and articulos.id=idarticuloin and articulos.linea=descuentosporgrupo.linea and clientes.idgrupo=gruposdepersonas.id and descuentosporgrupo.idgrupo=gruposdepersonas.id); RETURN ifnull(P,0); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarpreciodeventa` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarpreciodeventa`(`idin` INT) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select preciodeventa from paraventas where id=idin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarprecioiva` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarprecioiva`(`numlineain` INT(11), `idfacturain` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN
declare rs double;
set rs=(select sum(valortotal) from ventas where idfactura=idfacturain and numlinea=numlineain );
return ifnull(rs,0);
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarpreciomaximo` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarpreciomaximo`(`idin` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN
DECLARE P DOUBLE;
SET P=(select MAX(valorgramo) from compras where idarticulo=idin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarpreciominimo` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarpreciominimo`(`idin` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN
DECLARE P DOUBLE;
    SET P=(select MIN(valorgramo) from compras where idarticulo=idin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarpreciopromedio` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarpreciopromedio`(`idin` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select AVG(valorgramo) from compras where idarticulo=idin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarrecibe` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarrecibe`(`idin` INT(11)) RETURNS varchar(200) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN
DECLARE P VARCHAR(200);
SET P=(select recibe from paraventas where id=idin);
RETURN ifnull(P,'');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarreferencia` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarreferencia`(`idarticuloin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN DECLARE P INT(11); SET P=(select referencia from articulos where id=idarticuloin ); RETURN ifnull(P,0); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarsaldodelafactura` */;
DELIMITER ;;
CREATE DEFINER=`pruebas`@`%` FUNCTION `buscarsaldodelafactura`(`idfacturain` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN DECLARE P INT(11); DECLARE aabonado INT(11); declare doc varchar(1); set doc=(select documento from facturas where id=idfacturain); if(doc='V') then RETURN 0; ELSE set aabonado=(select abonado from facturas where id=idfacturain); if aabonado>0 then set P= 0; else SET P=(select total  -retencion+servicio -buscarabonos(idfacturain) -valornc from facturas where id=idfacturain); end if; RETURN ifnull(P,0); END IF; END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarsaldodelamayor` */;
DELIMITER ;;
CREATE DEFINER=`pruebas`@`%` FUNCTION `buscarsaldodelamayor`(`idmayorin` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN DECLARE P double; declare notas int(11); DECLARE aabonado double; declare doc varchar(7); set notas=buscarnotassencompras(idmayorin); set doc=(select documento from mayorescompras where id=idmayorin); if(doc='CONTADO') then RETURN 0; ELSE SET P=(select base+iva-descuento - otrosdescuentos -buscarabonosencompras(idmayorin) - descuentocomercial from mayorescompras where id=idmayorin); SET P=P-notas; RETURN ifnull(P,0); END IF; END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarsaldodelamayorseparados` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`vps-385963.appitecintegraciones.com` FUNCTION `buscarsaldodelamayorseparados`(`idmayorin` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN DECLARE P double; DECLARE aabonado double; SET P=(select total -buscarabonosenseparados(idmayorin) from mayoresseparados where id=idmayorin); RETURN ifnull(P,0); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarsaldodelcliente` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`localhost` FUNCTION `buscarsaldodelcliente`(`idclientein` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN DECLARE P FLOAT(11); DECLARE Q FLOAT(11); DECLARE S FLOAT(11); SET P=(select sum(saldo) from facturas where idcliente=idclientein and documento='C' and abonado=0); set P=ifnull(P,0); set Q=(select sum(saldo) from mayoresseparados where idcliente=idclientein and abonado=0); set Q=ifnull(Q,0); set S=(select sum(saldo) from prestamos where idcliente=idclientein); set S=ifnull(S,0); RETURN ROUND(p+q+S,2); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarsaldodelprestamo` */;
DELIMITER ;;
CREATE DEFINER=`wwcont_texasburgers`@`%.%.%.%` FUNCTION `buscarsaldodelprestamo`(`idin` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN
    declare a double;
    set a=(select sum(valor) from abonosprestamos  where idprestamo=idin);
    set a=ifnull(a,0);
    return (select plazo*valorcuota+valorcuotainicial-a from prestamos where id=idin);
    end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarsaldodelprestamoin` */;
DELIMITER ;;
CREATE DEFINER=`wwcont_texasburgers`@`%.%.%.%` FUNCTION `buscarsaldodelprestamoin`(`idin` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN
     declare a double;
     set a=(select sum(valor) from abonosprestamosin  where idprestamo=idin);
     set a=ifnull(a,0);
     return (select valor-a from prestamosalaempresa where id=idin);
     end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarsaldodelproveedor` */;
DELIMITER ;;
CREATE DEFINER=`wwcont_texasburgers`@`%.%.%.%` FUNCTION `buscarsaldodelproveedor`(`idclientein` INT(11)) RETURNS int
    SQL SECURITY INVOKER
begin DECLARE P INT(11); DECLARE Q INT(11);  DECLARE prestamos INT(11); 
SET prestamos=(select sum(saldo) from prestamosalaempresa where idcliente=idclientein);
SET P=(select sum(valor-descuento) from mayorescompras where idproveedor=idclientein and documento='CREDITO');
SET Q=(select sum(abonoscompras.valor) from abonoscompras,mayorescompras where mayorescompras.idproveedor=idclientein and abonoscompras.idmayorcompras=mayorescompras.id);
set prestamos=ifnull(prestamos,0); set P=ifnull(P,0); 
set Q=ifnull(Q,0); 
RETURN P+prestamos-Q; END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarseccion` */;
DELIMITER ;;
CREATE DEFINER=`wwcont_texasburgers`@`%.%.%.%` FUNCTION `buscarseccion`(`idin` INT(11)) RETURNS varchar(25) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN
DECLARE a varchar(25);
set a=(select ifnull(secciones.seccion,'DESCONOCIDO') from articulos,secciones where articulos.id=idin and idseccion=secciones.id);
return ifnull(a,'DESCONOCIDO');
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscartelefonotercero` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscartelefonotercero`(`idin` INT(11)) RETURNS varchar(110) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN
DECLARE P varchar(110);
SET P=(select concat(ifnull(telefono,''),' ',ifnull(celular,'')) from clientes where id=idin);
RETURN ifnull(P,'');
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscartrasladosabodega` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscartrasladosabodega`(`idin` INT(11), `fecha1` DATE, `fecha2` DATE) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select sum(cantidad) from traslados where idarticulo=idin and cast(fechacreacion as date) BETWEEN fecha1 and fecha2 and origen<>'MESAS');
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscartrasladosproducto` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscartrasladosproducto`(`idin` INT(11), `fecha1` DATE, `fecha2` DATE) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select sum(cantidad) from traslados where idarticulo=idin and cast(fechacreacion as date) BETWEEN fecha1 and fecha2);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarultimaventa` */;
DELIMITER ;;
CREATE DEFINER=`wwcont_texasburgers`@`%.%.%.%` FUNCTION `buscarultimaventa`(`idin` INT(11)) RETURNS date
    SQL SECURITY INVOKER
BEGIN
        DECLARE P DATE;
        SET P=(select cast(fechacreacion as date) from ventas where idarticulo=idin order by id desc limit 1); 
        return ifnull(P,'');
        END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarultimoabonodecompras` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`localhost` FUNCTION `buscarultimoabonodecompras`(`idclientein` INT(11)) RETURNS varchar(25) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN
declare rs varchar(25);
set rs=(select max(abonoscompras.fechacreacion) from abonoscompras,mayorescompras where idmayorcompras=mayorescompras.id and mayorescompras.idproveedor=idclientein  );
return ifnull(rs,'SIN ABONOS');
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarunidaddemedida` */;
DELIMITER ;;
CREATE DEFINER=`restaura_kaldi`@`localhost` FUNCTION `buscarunidaddemedida`(`idin` INT(11)) RETURNS varchar(50) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN declare rs varchar(50); set rs=(select unidaddemedida from unidadesdemedida where id=idin); return ifnull(rs,'DESCONOCIDO'); end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarvalordelamesa` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarvalordelamesa`(`idmesain` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN DECLARE rs double; set rs=(select sum(valortotal) from ventasauxiliar where idmesa=idmesain); return ifnull(rs,0); end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarvalordelanotadebito` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarvalordelanotadebito`(`idndin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN DECLARE P int(11); SET P=(select valortotal from notasdebito where id=idndin); RETURN ifnull(P,0); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarventasdelusuario` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarventasdelusuario`(`idin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(11);
SET P=(select ifnull(sum(total),0) from facturas where idvendedor =idin and cast(fechacreacion as date)=cast(now()as date) and abonado=0 );
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarventasporproductoyvendedor` */;
DELIMITER ;;
CREATE DEFINER=`restaura_kaldi`@`localhost` FUNCTION `buscarventasporproductoyvendedor`(`idvendedorin` INT(11), `idarticuloin` INT(11), `mesin` INT(2)) RETURNS int
    SQL SECURITY INVOKER
begin
declare a int(11);
set a=(select sum(cantidad) from ventas where nc=0 and abonado=0 and idvendedor=idvendedorin and idarticulo=idarticuloin and year(fechacreacion)=year(now()) and month(fechacreacion)=mesin);
return ifnull(a,0);
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarventasproducto` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarventasproducto`(`idin` INT, `fecha1` DATE, `fecha2` DATE) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select sum(cantidad) from ventas where idarticulo=idin and fechacreacion BETWEEN fecha1 and fecha2);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarventasproductoanoymes` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `buscarventasproductoanoymes`(`idin` INT(11), `mesin` INT(2), `anoin` INT(4)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select sum(cantidad) from ventas where idarticulo=idin and month(fechacreacion)=mesin and year(fechacreacion)=anoin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `buscarzona` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`162.214.175.121` FUNCTION `buscarzona`(`idin` INT(11)) RETURNS varchar(25) CHARSET latin1
    SQL SECURITY INVOKER
BEGIN
DECLARE a varchar(25);
set a=(select ifnull(zona,'DESCONOCIDO') from zonas,mesas where zonas.id=mesas.idzona and mesas.id=idin);
return ifnull(a,'DESCONOCIDO');
end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `calcularcostodelafactura` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `calcularcostodelafactura`(`idfacturain` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN
DECLARE P DOUBLE;
SET P=(select sum(cantidad*costomedio)  from ventas where idfactura=idfacturain);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `calcularcostopomedio` */;
DELIMITER ;;
CREATE DEFINER=`wwcont_kaldi`@`%.%.%.%` FUNCTION `calcularcostopomedio`(`idin` INT(11)) RETURNS double
    SQL SECURITY INVOKER
begin
declare a double;
declare b double;
declare c double;
declare d double;
declare e double;
declare f double;
set d=(select valorgramo from compras where idarticulo=idin order by id desc limit 1);
set e=(select costomedio from articulos where id=idin);
set f=(select ultimocoste from articulos where id=idin);
set d=ifnull(d,0);
set a=(SELECT sum(cantidad*factor) from compras where  
idarticulo=idin and month(fecha)=month(now()) and year(fecha)=year(now()));
       set b=(SELECT sum(valortotal) from compras where  
idarticulo=idin and month(fecha)=month(now()) and year(fecha)=year(now()));
       set a=ifnull(a,1);
       set b=ifnull(b,0);
set c=  (b*1.0/a*1.0);
if c= 0 then set c=d; end if;
if c= 0 and e>0 then set c=e; end if;
if c= 0 and f>0 then set c=f; end if;
return c;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `calcularcostoseguningredientes` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `calcularcostoseguningredientes`(`idarticuloin` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN
DECLARE P double;
SET P=(select sum(articulos.costomedio*componentesarticulos.cantidad) 
from articulos,componentesarticulos where articulos.id=idinsumo and idarticulo=idarticuloin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `calcular_disponibilidad` */;
DELIMITER ;;
CREATE DEFINER=`pruebas`@`%` FUNCTION `calcular_disponibilidad`(idarticuloin INT) RETURNS double
BEGIN
    DECLARE vtienecomposicion INT;
    DECLARE compromiso INT;
    DECLARE cantidadactual DOUBLE;

    
    SELECT tienecomposicion INTO vtienecomposicion
    FROM articulos
    WHERE id = idarticuloin;

    
    SELECT IFNULL(SUM(factor * cantidad), 0) INTO compromiso
    FROM ventasauxiliar
    WHERE idarticulo = idarticuloin;

    
    IF vtienecomposicion < 1 THEN
        SELECT cantidad INTO cantidadactual
        FROM articulos
        WHERE id = idarticuloin;
    ELSE
        SELECT  MIN(a2.cantidad / c.cantidad) INTO cantidadactual FROM articulos a1 LEFT JOIN componentesarticulos c ON a1.id = c.idarticulo LEFT JOIN articulos a2 ON c.idinsumo = a2.id WHERE c.cantidad>0 and a1.id = idarticuloin;
    END IF;

    
   
        RETURN  cantidadactual- compromiso;
    
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `cantidaddecompras` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `cantidaddecompras`(`idin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(4);
SET P=(select count(id) from compras where idarticulo=idin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `comisionporclientes` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `comisionporclientes`(`idarticulo` INT(11), `idclientein` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(6);
DECLARE q varchar(50);
SET q=(select grupo from clientes  where id=idclientein);
if(q='ENTRENADORES') THEN  
SET P=(select comision from articulos where id=idarticulo);
ELSE 
SET P=(select (-valordistribuidor+valordeventa)/2 from articulos where id=idarticulo);
END IF;
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `comisionpreciopublico` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `comisionpreciopublico`(`idarticulo` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(6);
SET P=(select (-valordistribuidor+valordeventa)/2 from articulos where id=idarticulo);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `contararticulosenlamesa` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `contararticulosenlamesa`(`idarticuloin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(4);
SET P=(select sum(cantidad) from ventasauxiliar where idarticulo=idarticuloin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `contarlineasdelamesa` */;
DELIMITER ;;
CREATE DEFINER=`wwcont_texasburgers`@`%.%.%.%` FUNCTION `contarlineasdelamesa`(`idin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN DECLARE P int(11); declare notas int(11); set notas=(select count(id) from ventasauxiliar where idmesa=idin);RETURN ifnull(notas,0); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `contarlineasdemayorescompras` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `contarlineasdemayorescompras`(`idmayorin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN DECLARE P double; SET P=(select count(id) from compras where idmayor=idmayorin); RETURN ifnull(P,0); END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `contarlineasenventa` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`localhost` FUNCTION `contarlineasenventa`(`idin` INT(11)) RETURNS int
    NO SQL
    SQL SECURITY INVOKER
begin declare a int(3); set a=(select count(id) from ventas where idfactura=idin and abonado=0 and nc=0 and esmodif=0); return ifnull(a,0); end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `contarventasanuladas` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `contarventasanuladas`(`idarticuloin` INT(11), `idzin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(11);
set P=(select sum(cantidad) from ventas where idz=idzin and idarticulo=idarticuloin and abonado=1);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `contarventasbrutas` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `contarventasbrutas`(`idarticuloin` INT(11), `idzin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(11);
set P=(select sum(cantidad) from ventas where idz=idzin and idarticulo=idarticuloin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `desvestcompras` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `desvestcompras`(`idin` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN
DECLARE P double;
DECLARE q double;
SET q=(select buscarpreciopromedio(idin));
SET P=(select sum((valorgramo-q)*(valorgramo-q)) from compras where idarticulo=idin);
RETURN ifnull(SQRT(P),0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `esfestivo` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`vps-385963.appitecintegraciones.com` FUNCTION `esfestivo`(`fechain` DATE) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select id from festivos where fecha=fechain);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `espadre` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `espadre`(`idarticuloin` INT(11), `idinsumoin` INT(11), `idusuarioin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
declare idarticuloactual int(11);
delete from auxiliarbuscarpadre where idusuario=idusuarioin;
if idarticuloin=idinsumoin then 
return 1;
end if;
insert into auxiliarbuscarpadre(idusuario,a)
select idusuarioin,idarticulo  from componentesarticulos where idinsumo=idarticuloin;
while (select count(a) from auxiliarbuscarpadre where idusuario=idusuarioin)>0 do 
set idarticuloactual=(select a from auxiliarbuscarpadre where idusuario=idusuarioin limit 1);

if(idarticuloactual=idinsumoin)then return 1;end if;
insert into auxiliarbuscarpadre(idusuario,a)
select idusuarioin,idarticulo from componentesarticulos where idinsumo=idarticuloactual;
delete from auxiliarbuscarpadre  where a=idarticuloactual;
end while;
RETURN 0;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `facturatienemodificadores` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`162.214.175.121` FUNCTION `facturatienemodificadores`(`idin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
begin declare a int(3);declare b int(1); 
set b=0;
set a=(select count(id) from ventas where idfactura=idin and esmodif=1); 
if(a>0) then set b=1;end if;
return b; end ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `mirarsienventatienecomposicion` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `mirarsienventatienecomposicion`(`idarticuloin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
declare a int(2);
set a=(select count(componentesarticulos.id) from componentesarticulos,articulos where idarticulo=articulos.id and articulos.referencia=idarticuloin);
RETURN ifnull(a,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `mirarsitienecomposicion` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `mirarsitienecomposicion`(`idarticuloin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(1);
SET P=(select count(id) from componentesarticulos where idarticulo=idarticuloin);
IF p<1 THEN return '0';
else return 1;
END IF;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `sepuedeborrarfamiliademodificadores` */;
DELIMITER ;;
CREATE DEFINER=`controll_kaldi`@`vps-385963.appitecintegraciones.com` FUNCTION `sepuedeborrarfamiliademodificadores`(`idin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(2);
DECLARE Q INT(2);
SET P=(select count(id) from asignacionarticulosfamiliasmodificadores where idfamilia=idin);
SET Q=(select count(id) from modificadores where idfamilia=idin);
RETURN if(P+Q>0,0,1);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `sumarventasanuladas` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `sumarventasanuladas`(`idarticuloin` INT(11), `idzin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(11);
set P=(select sum(valortotal-cantidad*descuento) from ventas where idz=idzin and idarticulo=idarticuloin and abonado=1);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `sumarventasbrutas` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `sumarventasbrutas`(`idarticuloin` INT(11), `idzin` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P int(11);
set P=(select sum(valortotal-cantidad*descuento) from ventas where idz=idzin and idarticulo=idarticuloin);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `totalcompradeestecliente` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `totalcompradeestecliente`(`idclientein` INT(11)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select SUM(total) from facturas where idcliente=idclientein);
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `totalizarventaauxiliar` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `totalizarventaauxiliar`(`idmesain` INT(11)) RETURNS double
    SQL SECURITY INVOKER
BEGIN
DECLARE P DOUBLE;
SET P=(SELECT ifnull(SUM(valortotal),0)/10 FROM ventasauxiliar where idmesa=idmesain);
RETURN P;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `ventasentrehoras` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `ventasentrehoras`(`ccin` INT(3), `fecha1` DATE, `hora1` VARCHAR(9), `hora2` VARCHAR(9)) RETURNS int
    SQL SECURITY INVOKER
BEGIN
DECLARE P INT(11);
SET P=(select sum(valortotal) from ventas where cc=ccin and fecha between concat(fecha1,hora1) and concat(fecha1,hora2) ) ;
RETURN ifnull(P,0);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `cambiarcostoencascada` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `cambiarcostoencascada`(IN `idarticuloin` BIGINT(20), IN `ccin` BIGINT(20))
    SQL SECURITY INVOKER
BEGIN
declare idtablaactual int(11);
declare idarticuloactual int(11);
delete from auxiliarcambiodeprecios where cc=ccin;
insert into auxiliarcambiodeprecios(idarticulo,idinsumo,cantidad,cc)
select idarticulo,idinsumo,cantidad,ccin from componentesarticulos where idinsumo=idarticuloin;
while (select count(id) from auxiliarcambiodeprecios  where cc=ccin)>0 do 
set idtablaactual=(select id from auxiliarcambiodeprecios where cc=ccin limit 1);
set idarticuloactual=(select idarticulo from auxiliarcambiodeprecios where id=idtablaactual);
update articulos set subido=0,costomedio=calcularcostoseguningredientes(idarticuloactual) where id=idarticuloactual;
insert into auxiliarcambiodeprecios(idarticulo,idinsumo,cantidad,cc)
select idarticulo,idinsumo,cantidad,ccin from componentesarticulos where idinsumo=idarticuloactual;
delete from auxiliarcambiodeprecios  where id=idtablaactual;
end while;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `cotizarreceta` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `cotizarreceta`(IN `idusuarioin` INT(11), IN `tipodecotizacion` INT(1))
    SQL SECURITY INVOKER
BEGIN
declare idtablaactual int(11);
declare idcotizacionactual int(11);
declare cantidadactual double;
declare cantidadcotizacionactual double;
declare idarticuloactual int(11);
declare idarticuloparacotizar int(11);
if(select count(id) from auxiliarcotizarreceta)=0 THEN
truncate table auxiliarcotizarreceta;
else
delete from auxiliarcotizarreceta where idusuario=idusuarioin;
end if;
if(select count(id) from respuestacotizacionreceta)=0 THEN
truncate table respuestacotizacionreceta;
else
delete from respuestacotizacionreceta where idusuario=idusuarioin;
end if;




insert into respuestacotizacionreceta(idarticulo,idinsumo,cantidad,idusuario)
select 0,idarticulo,cantidad,idusuarioin from cotizaciondereceta where mirarsitienecomposicion(idarticulo)=0;









while(select count(id) from cotizaciondereceta where idusuario=idusuarioin and revisado=0)>0 DO
set idcotizacionactual=(select id from cotizaciondereceta  where idusuario=idusuarioin and revisado=0 limit 1);
set cantidadcotizacionactual=(select cantidad from cotizaciondereceta  where id=idcotizacionactual);
set idarticuloparacotizar=(select idarticulo from cotizaciondereceta  where id=idcotizacionactual);
insert into auxiliarcotizarreceta(idarticulo,idinsumo,cantidad,idusuario)
select idarticulo,idinsumo,cantidad*cantidadcotizacionactual,idusuarioin from componentesarticulos where idarticulo=idarticuloparacotizar;
while (select count(id) from auxiliarcotizarreceta  where idusuario=idusuarioin)>0 do 
set idtablaactual=(select id from auxiliarcotizarreceta  where idusuario=idusuarioin limit 1);
set idarticuloactual=(select idinsumo from auxiliarcotizarreceta where id=idtablaactual);
set cantidadactual=(select cantidad from auxiliarcotizarreceta where id=idtablaactual);
if(mirarsitienecomposicion(idarticuloactual)=0) THEN
insert into respuestacotizacionreceta(idarticulo,idinsumo,cantidad,idusuario)
values(0,idarticuloactual,cantidadactual,idusuarioin);
ELSE
insert into auxiliarcotizarreceta(idarticulo,idinsumo,cantidad,idusuario)
select idarticuloactual,idinsumo,cantidad*cantidadactual,idusuarioin from componentesarticulos where idarticulo=idarticuloactual;
end IF;
delete from auxiliarcotizarreceta  where id=idtablaactual;
end while;
update cotizaciondereceta set revisado=1 where id=idcotizacionactual;
end while;
if(tipodecotizacion=0) then 
select sum(respuestacotizacionreceta.cantidad) as cantidad,articulos.descripcion,articulos.costomedio as costo,unidaddemedida from respuestacotizacionreceta,articulos,unidadesdemedida where idinsumo=articulos.id and idunidaddemedida=unidadesdemedida.id GROUP by descripcion;
else 
select sum(respuestacotizacionreceta.cantidad) as cantidad,articulos.descripcion,articulos.ultimocoste as costo,unidaddemedida from respuestacotizacionreceta,articulos,unidadesdemedida where idinsumo=articulos.id and idunidaddemedida=unidadesdemedida.id GROUP by descripcion;
end if;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `detallarsurecetaagrupada` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `detallarsurecetaagrupada`(IN `idarticuloin` INT(11), IN `idusuarioin` INT(11))
    SQL SECURITY INVOKER
BEGIN
declare idtablaactual int(11);
declare cantidadactual double;
declare idarticuloactual int(11);
if(select count(id) from auxiliarcostoagrupado)=0 THEN
truncate table auxiliarcostoagrupado;
else
delete from auxiliarcostoagrupado where idusuario=idusuarioin;
end if;

if(select count(id) from respuestacostoagrupado)=0 THEN
truncate table respuestacostoagrupado;
else
delete from respuestacostoagrupado where idusuario=idusuarioin;
end if;



insert into auxiliarcostoagrupado(idarticulo,idinsumo,cantidad,idusuario)
select idarticulo,idinsumo,cantidad,idusuarioin from componentesarticulos where idarticulo=idarticuloin;
while (select count(id) from auxiliarcostoagrupado  where idusuario=idusuarioin)>0 do 
set idtablaactual=(select id from auxiliarcostoagrupado  where idusuario=idusuarioin limit 1);
set idarticuloactual=(select idinsumo from auxiliarcostoagrupado where id=idtablaactual);
set cantidadactual=(select cantidad from auxiliarcostoagrupado where id=idtablaactual);
if(mirarsitienecomposicion(idarticuloactual)=0) THEN
insert into respuestacostoagrupado(idarticulo,idinsumo,cantidad,idusuario)
values(0,idarticuloactual,cantidadactual,idusuarioin);
ELSE
insert into auxiliarcostoagrupado(idarticulo,idinsumo,cantidad,idusuario)
select idarticuloactual,idinsumo,cantidad*cantidadactual,idusuarioin from componentesarticulos where idarticulo=idarticuloactual;
end IF;
delete from auxiliarcostoagrupado  where id=idtablaactual;
end while;
select sum(respuestacostoagrupado.cantidad) as cantidad,articulos.descripcion,articulos.costomedio,unidaddemedida from respuestacostoagrupado,articulos,unidadesdemedida where idinsumo=articulos.id and idunidaddemedida=unidadesdemedida.id GROUP by descripcion;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `truncarventasauxiliar` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `truncarventasauxiliar`()
    SQL SECURITY INVOKER
BEGIN
declare n int(11);
set n =(select count(id) from ventasauxiliar);
if n=0 then 
truncate table ventasauxiliar;
end if;
END ;;
DELIMITER ;


