
CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `_cob` AS select `cobroz`.`cob_tot` AS `T`,`cobroz`.`cob_fec` AS `F`,`cobroz`.`cob_id_contrato` AS `C`,substr(`cobroz`.`cob_id_tdp`,1,1) AS `M`,`cobroz`.`cob_md` AS `MD`,`cobroz`.`cob_id_empresa` AS `ID_EMP`,`empresas`.`emp_nomc` AS `EC`,`cobroz`.`cob_id_usuario` AS `USU_KOD`,`almacenes`.`alm_obs` AS `ALM_NC` from ((`cobroz` join `empresas` on(`cobroz`.`cob_id_empresa` = `empresas`.`id_emp`)) join `almacenes` on(`cobroz`.`cob_id_alm` = `almacenes`.`id_almacen`)) where `cobroz`.`id_cobro` > 0 and `cobroz`.`cob_anu` = 'NO';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `_cot` AS select `cotizaciones`.`tot_real` AS `T`,`cotizaciones`.`fec` AS `F`,substr(`cotizaciones`.`modalidad`,1,1) AS `M`,`cotizaciones`.`id_tip_pag` AS `TP`,`cotizaciones`.`acu` AS `A`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`empresas`.`emp_nomc` AS `EC`,`cotizaciones`.`id_usuario` AS `USU_KOD`,`cotizaciones`.`anu` AS `ANU`,`almacenes`.`alm_obs` AS `ALM_NC` from ((`cotizaciones` join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) where `cotizaciones`.`id_cotizacion` > 0 and `cotizaciones`.`cot_pri` = '1' and `cotizaciones`.`anu` = 'N';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `_dev` AS select `devoluciones`.`dev_total` AS `TOT`,`devoluciones`.`dev_anu` AS `ANU`,`devoluciones`.`dev_dinero` AS `DIN`,`devoluciones`.`dev_fec` AS `FEC`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`empresas`.`emp_nomc` AS `EC`,`devoluciones`.`dev_id_usuario` AS `USU_KOD`,`almacenes`.`alm_obs` AS `ALM_NC` from ((`devoluciones` join `almacenes` on(`devoluciones`.`dev_id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) where `devoluciones`.`dev_anu` = 'N';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `_egr` AS select `almacenes`.`alm_id_empresa` AS `ID_EMP`,`egresos`.`fec` AS `FEC`,`egresos`.`tot` AS `TOT`,`empresas`.`emp_nomc` AS `EC`,`egresos`.`eg_mod` AS `MODA`,`egresos`.`eg_tot_dol` AS `TOT_DOL`,`egresos`.`eg_tc` AS `TC`,`egresos`.`eg_id_usu` AS `USU_KOD`,`egresos`.`anu` AS `ANU`,`almacenes`.`alm_obs` AS `ALM_NC` from ((`egresos` join `almacenes` on(`egresos`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) where `egresos`.`anu` = 'N';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `_kon` AS select `contratos`.`con_adelanto` AS `A`,`contratos`.`con_fecha` AS `F`,substr(`contratos`.`tip_tip_adelanto`,1,1) AS `M`,`contratos`.`con_id_empresa` AS `ID_EMP`,`empresas`.`emp_nomc` AS `EC`,`contratos`.`con_id_usario` AS `USU_KOD`,`almacenes`.`alm_obs` AS `ALM_NC` from ((`contratos` join `empresas` on(`contratos`.`con_id_empresa` = `empresas`.`id_emp`)) join `almacenes` on(`contratos`.`con_id_alm` = `almacenes`.`id_almacen`)) where `contratos`.`id_contrato` > 0;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `_koni` AS select `contratos_ingresos`.`ci_total` AS `T`,`contratos_ingresos`.`ci_fec` AS `F`,substr(`contratos_ingresos`.`ci_tipo`,1,1) AS `M`,`contratos`.`con_id_empresa` AS `ID_EMP`,`empresas`.`emp_nomc` AS `EC`,`contratos_ingresos`.`ci_id_usuario` AS `USU_KOD`,`contratos_ingresos`.`ci_anu` AS `ANU`,`almacenes`.`alm_obs` AS `ALM_NC` from (((`contratos_ingresos` join `contratos` on(`contratos_ingresos`.`ci_id_contrato` = `contratos`.`id_contrato`)) join `empresas` on(`contratos`.`con_id_empresa` = `empresas`.`id_emp`)) join `almacenes` on(`contratos_ingresos`.`ci_id_alm` = `almacenes`.`id_almacen`)) where `contratos_ingresos`.`id_con_ing` > 0 and `contratos_ingresos`.`ci_anu` = 'N';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `_ven` AS select `ventas`.`tot` AS `T`,`ventas`.`fec` AS `F`,`ventas`.`id_tip_pag` AS `TP`,substr(`ventas`.`ven_modalidad`,1,1) AS `M`,`ventas`.`acuenta` AS `A`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`empresas`.`emp_nomc` AS `EC`,`ventas`.`id_usuario` AS `USU_KOD`,`ventas`.`anu` AS `ANU`,`almacenes`.`alm_obs` AS `ALM_NC` from ((`ventas` join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) where `ventas`.`id_venta` > 0 and `ventas`.`ven_prin` = 1 and `ventas`.`anu` = 'N';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `app_sp` AS select `stocks_presentaciones`.`sp_id_producto` AS `IDP`,`almacenes`.`alm_nombre` AS `ALM`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES`,`stocks_presentaciones`.`sp_cantidad` AS `CAN`,`stocks_presentaciones`.`sp_presentacion` AS `PIE` from ((`stocks_presentaciones` join `almacenes` on(`stocks_presentaciones`.`sp_id_almacen` = `almacenes`.`id_almacen`)) join `productos` on(`stocks_presentaciones`.`sp_id_producto` = `productos`.`id_producto`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `bis_ginterna_det` AS select `ginterna`.`id_gi` AS `GI_ID`,`ginterna`.`gi_anu` AS `GI_ANU`,`ginterna`.`gi_id_cotizacion` AS `COT_ID`,`ginterna_det`.`id_producto` AS `PRO_ID`,`ginterna_det`.`ca` AS `CA`,`ginterna_det`.`can_uni` AS `PIE`,`ginterna_det`.`ca_control` AS `CA_CONTROL` from (`ginterna` join `ginterna_det` on(`ginterna`.`id_gi` = `ginterna_det`.`id_gi`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `par_productos` AS select `lineas`.`lin_nombre` AS `LI`,`productos`.`id_producto` AS `ID`,`productos`.`pro_codigo` AS `CO`,`productos`.`pro_des` AS `DE`,`productos`.`pro_pv_min` AS `PMI`,`productos`.`pro_pv_max` AS `PMA`,`productos`.`pro_uso` AS `ELI`,`productos`.`pro_rojo` AS `ROJ`,`productos`.`pro_ama` AS `AMA` from (`productos` join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `pri_cot_det` AS select `cotizaciones_det`.`id_cotizacion` AS `ID`,`cotizaciones_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `COD`,`cotizaciones_det`.`id_producto` AS `ID_PRO`,`lineas`.`lin_nombre` AS `LIN`,`marcas`.`mar_nombre` AS `MAR`,`productos`.`pro_des` AS `DES`,`cotizaciones_det`.`ca` AS `CAN`,`cotizaciones_det`.`pr` AS `PRE`,`cotizaciones_det`.`im` AS `IMP`,`cotizaciones_det`.`can_uni` AS `PIE` from (((`cotizaciones_det` join `productos` on(`cotizaciones_det`.`id_producto` = `productos`.`id_producto`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `pri_gia_det` AS select `guias_det`.`id_guia` AS `ID`,`guias_det`.`cx` AS `CX`,`guias_det`.`id_producto` AS `ID_PRO`,`productos`.`pro_codigo` AS `COD`,`lineas`.`lin_nombre` AS `LIN`,`marcas`.`mar_nombre` AS `MAR`,`productos`.`pro_des` AS `DES`,`guias_det`.`ca` AS `CAN`,`guias_det`.`can_uni` AS `PIE`,0 AS `IMP`,0 AS `PRE` from (((`guias_det` join `productos` on(`guias_det`.`id_producto` = `productos`.`id_producto`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `pri_ven_det` AS select `ventas_det`.`id_venta` AS `ID`,`ventas_det`.`cx` AS `CX`,`ventas_det`.`id_producto` AS `ID_PRO`,`productos`.`pro_codigo` AS `COD`,`lineas`.`lin_nombre` AS `LIN`,`marcas`.`mar_nombre` AS `MAR`,`productos`.`pro_des` AS `DES`,`ventas_det`.`ca` AS `CAN`,`ventas_det`.`pr` AS `PRE`,`ventas_det`.`im` AS `IMP`,`ventas_det`.`can_uni` AS `PIE` from (((`ventas_det` join `productos` on(`ventas_det`.`id_producto` = `productos`.`id_producto`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `v_anios` AS select year(`ventas`.`fec`) AS `ANIO` from `ventas` group by year(`ventas`.`fec`) order by year(`ventas`.`fec`);

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `v_stocks` AS select `productos`.`id_producto` AS `ID`,`productos`.`pro_codigo` AS `COD`,`lineas`.`lin_nombre` AS `LINEA`,`productos`.`pro_des` AS `DESCRIPCION`,`marcas`.`mar_nombre` AS `MARCA`,`productos`.`pro_pc_sol` AS `PC_SOL`,`productos`.`pro_pv_min` AS `PV_MIN`,`productos`.`pro_pv_max` AS `PV_MAX`,`stocks`.`stock` AS `STOCK`,`almacenes`.`alm_nombre` AS `ALM` from ((((`productos` join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `stocks` on(`productos`.`id_producto` = `stocks`.`id_producto`)) join `almacenes` on(`stocks`.`id_almacen` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vaju_control` AS select `ajustes`.`anu` AS `ANU`,`ajustes`.`acc` AS `ACC`,`ajustes_det`.`id_producto` AS `IDP`,`ajustes_det`.`ca` AS `CA`,`ajustes_det`.`can_uni` AS `PIE`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`ajustes`.`fec` AS `FEC`,`ajustes`.`id_alm` AS `ID_ALM` from ((`ajustes` join `ajustes_det` on(`ajustes`.`id_ajuste` = `ajustes_det`.`id_ajuste`)) join `almacenes` on(`ajustes`.`id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vajup_control` AS select `ajustes_presentacion`.`anu` AS `ANU`,`ajustes_presentacion`.`acc` AS `ACC`,`ajustes_presentacion_det`.`id_producto` AS `IDP`,`ajustes_presentacion_det`.`cajas` AS `CAJ`,`ajustes_presentacion_det`.`piezas` AS `PIE_O`,`ajustes_presentacion_det`.`piezas_ajuste` AS `PIE_Q`,`ajustes_presentacion_det`.`piezas` - `ajustes_presentacion_det`.`piezas_ajuste` AS `PIE_R`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`ajustes_presentacion`.`fec` AS `FEC`,`ajustes_presentacion`.`id_alm` AS `ID_ALM` from ((`ajustes_presentacion` join `ajustes_presentacion_det` on(`ajustes_presentacion`.`id_ajuste` = `ajustes_presentacion_det`.`id_ajuste`)) join `almacenes` on(`ajustes_presentacion`.`id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vajustes` AS select `ajustes`.`id_ajuste` AS `ID`,`ajustes`.`fec` AS `FEC`,`almacenes`.`alm_obs` AS `ALM`,`ajustes`.`num` AS `NUM`,`ajustes`.`acc` AS `ACC`,`ajustes`.`obs` AS `OBS`,`ajustes`.`anu` AS `ANU`,`empresas`.`emp_nomc` AS `EMPC` from ((`ajustes` join `almacenes` on(`ajustes`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vajustes_det` AS select `ajustes`.`id_ajuste` AS `ID`,`ajustes`.`fec` AS `FEC`,`almacenes`.`alm_obs` AS `ALM`,`ajustes`.`num` AS `NUM`,`ajustes`.`acc` AS `ACC`,`ajustes`.`obs` AS `OBS`,`ajustes`.`anu` AS `ANU`,`ajustes_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES`,`ajustes_det`.`ca` AS `KA`,`marcas`.`mar_nombre` AS `MAR`,`lineas`.`lin_nombre` AS `LINEA`,`ajustes_det`.`can_uni` AS `PIEZAS`,`empresas`.`emp_nomc` AS `EMPC` from ((((((`ajustes` join `almacenes` on(`ajustes`.`id_alm` = `almacenes`.`id_almacen`)) join `ajustes_det` on(`ajustes`.`id_ajuste` = `ajustes_det`.`id_ajuste`)) join `productos` on(`ajustes_det`.`id_producto` = `productos`.`id_producto`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vajustex` AS select `ajustex`.`id_ajuste` AS `ID`,`ajustex`.`fecha` AS `FEC`,`almacenes`.`alm_nombre` AS `ALM`,`productos`.`pro_codigo` AS `COD`,`lineas`.`lin_nombre` AS `LIN`,`productos`.`pro_des` AS `DES`,`marcas`.`mar_nombre` AS `MAR`,`ajustex`.`accion` AS `ACC`,`ajustex`.`cant` AS `CANT` from ((((`ajustex` join `almacenes` on(`ajustex`.`id_almacen` = `almacenes`.`id_almacen`)) join `productos` on(`ajustex`.`id_producto` = `productos`.`id_producto`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vajux_control` AS select `ajustex`.`accion` AS `ACC`,`ajustex`.`id_producto` AS `IDP`,`ajustex`.`cant` AS `CA`,`ajustex`.`piezas` AS `PIE`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`ajustex`.`fecha` AS `FEC`,`productos`.`pro_codigo` AS `COD`,`ajustex`.`id_almacen` AS `ID_ALM` from ((`ajustex` join `almacenes` on(`ajustex`.`id_almacen` = `almacenes`.`id_almacen`)) join `productos` on(`ajustex`.`id_producto` = `productos`.`id_producto`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcaja` AS select `caja_chica`.`id_caja` AS `ID`,`caja_chica`.`fecha` AS `FEC`,`almacenes`.`alm_nombre` AS `ALM`,`almacenes`.`alm_obs` AS `ALMC`,`caja_chica`.`total` AS `TOT`,`caja_chica`.`obs` AS `OBS`,`empresas`.`emp_nomc` AS `EMPC` from ((`caja_chica` join `almacenes` on(`caja_chica`.`id_almacen` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vclientes` AS select `clientes`.`id_cliente` AS `ID`,`clientes`.`cli_nombre` AS `NOMBRE`,`clientes`.`cli_contacto` AS `CONTACTO`,`clientes`.`cli_dir` AS `DIRECCION`,`distritos`.`dis_nombre` AS `DISTRITO`,`clientes`.`cli_dni` AS `DNI`,`clientes`.`cli_ruc` AS `RUC`,`clientes`.`cli_tel` AS `TEL`,`clientes`.`cli_cel` AS `CEL`,`clientes`.`cli_fax` AS `FAX`,`clientes`.`cli_email` AS `EMAIL`,`clientes_tipos`.`clit_nombre` AS `TIPO`,`sunat_catalogos`.`des` AS `SUN_DOC_TIP`,`sunat_catalogos`.`cod` AS `SUN_DOC_COD`,`sunat_catalogos`.`sunat_cod` AS `SUNAT_COD`,`clientes`.`cli_ubi_pai` AS `UBI_PAI`,`clientes`.`cli_ubi_dep` AS `UBI_DEP`,`clientes`.`cli_ubi_pro` AS `UBI_PRO`,`clientes`.`cli_ubi_dis` AS `UBI_DIS`,`clientes`.`cli_ubi_cod` AS `UBI_COD`,`clientes`.`cli_rnd` AS `CLI_RND` from (((`clientes` join `clientes_tipos` on(`clientes`.`cli_id_clit` = `clientes_tipos`.`id_clit`)) join `distritos` on(`clientes`.`cli_id_distrito` = `distritos`.`id_distrito`)) join `sunat_catalogos` on(`clientes`.`cli_id_tip_doc` = `sunat_catalogos`.`id`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vclientes_suc` AS select `clientes_suc`.`id_suc` AS `ID`,`clientes`.`cli_nombre` AS `CLI`,`clientes_suc`.`suc_nom` AS `NOM`,`clientes_suc`.`suc_dir` AS `DIR` from (`clientes_suc` join `clientes` on(`clientes`.`id_cliente` = `clientes_suc`.`suc_id_cliente`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcobros` AS select `cobros`.`id_cobro` AS `ID`,`cobros`.`num` AS `NUM`,`cobros`.`fec` AS `FEC`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`cobros`.`pendiente` AS `PEN`,`cobros`.`total` AS `TOT`,`cobros`.`mon` AS `MON`,`cobros`.`anu` AS `ANU`,`cobros`.`gi` AS `GI`,`fpagos`.`nombre` AS `FPAGO`,`cobros`.`numf` AS `NUMF`,`cobros`.`fecven` AS `FECVEN`,`comprobantes`.`com_nombre` AS `COM`,`cobros`.`serr` AS `SERR`,`cobros`.`numr` AS `NUMR`,`cobros`.`pag` AS `PAG`,`cobros`.`fecpag` AS `FECPAG`,`cobros`.`gi2` AS `GI2`,`cobros`.`id_cliente` AS `ID_CLI`,`almacenes`.`alm_nombre` AS `ALM`,`cobros`.`id_alm` AS `ID_ALM` from ((((`cobros` join `clientes` on(`cobros`.`id_cliente` = `clientes`.`id_cliente`)) join `fpagos` on(`cobros`.`id_fpago` = `fpagos`.`id_fpago`)) join `comprobantes` on(`cobros`.`id_comprobante` = `comprobantes`.`id_comprobante`)) join `almacenes` on(`cobros`.`id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcobrox_dia` AS select `vis_cobrox`.`ID` AS `ID`,`vis_cobrox`.`FEC` AS `FEC`,concat(substr(`vis_cobrox`.`COM`,1,1),if(octet_length(`vis_cobrox`.`CSER`) > 0,concat(`vis_cobrox`.`CSER`,'-',`vis_cobrox`.`CNUM`),`vis_cobrox`.`CNUM`)) AS `GUIA`,`vis_cobrox`.`TOTAL` AS `TOTAL`,`vis_cobrox`.`SALDO` AS `SALDO`,`vis_cobrox`.`CLI` AS `CLI`,`vis_cobrox`.`GI` AS `GI`,`vis_cobrox`.`TOT_VEN` AS `IMPORTE`,`vis_cobrox`.`DEV_ID` AS `DEV_ID`,`devoluciones`.`dev_nro` AS `DEV_NRO`,`devoluciones`.`dev_fec` AS `DEV_FEC`,`comprobantes`.`com_nombre` AS `DEV_COM`,`devoluciones`.`dev_ser` AS `DEV_CON_SER`,`devoluciones`.`dev_num` AS `DEV_COM_NUM`,`devoluciones`.`dev_tipo` AS `DEV_TIPO`,`vis_cobrox`.`ANU` AS `ANU`,`vis_cobrox`.`ISER` AS `ISER`,`vis_cobrox`.`INUM` AS `INUM`,`vis_cobrox`.`COM` AS `COM`,`vis_cobrox`.`NUM` AS `NUM`,`vis_cobrox`.`EMPC` AS `EMPC`,`vis_cobrox`.`ID_USU` AS `KOD_USU` from ((`vis_cobrox` join `devoluciones` on(`vis_cobrox`.`DEV_ID` = `devoluciones`.`id_devolucion`)) join `comprobantes` on(`devoluciones`.`dev_id_comprobante` = `comprobantes`.`id_comprobante`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcobrox_dia_xx` AS select `vis_cobrox`.`ID` AS `ID`,`vis_cobrox`.`FEC` AS `FEC`,concat(substr(`vis_cobrox`.`COM`,1,1),if(octet_length(`vis_cobrox`.`CSER`) > 0,concat(`vis_cobrox`.`CSER`,'-',`vis_cobrox`.`CNUM`),`vis_cobrox`.`CNUM`)) AS `GUIA`,`vis_cobrox`.`TOTAL` AS `TOTAL`,`vis_cobrox`.`SALDO` AS `SALDO`,`vis_cobrox`.`CLI` AS `CLI`,`vis_cobrox`.`GI` AS `GI`,`vis_cobrox`.`TOT_VEN` AS `IMPORTE`,`vis_cobrox`.`DEV_ID` AS `DEV_ID`,`devoluciones`.`dev_nro` AS `DEV_NRO`,`devoluciones`.`dev_fec` AS `DEV_FEC`,`comprobantes`.`com_nombre` AS `DEV_COM`,`devoluciones`.`dev_ser` AS `DEV_CON_SER`,`devoluciones`.`dev_num` AS `DEV_COM_NUM`,`devoluciones`.`dev_tipo` AS `DEV_TIPO`,`vis_cobrox`.`ANU` AS `ANU`,`vis_cobrox`.`ISER` AS `ISER`,`vis_cobrox`.`INUM` AS `INUM`,`vis_cobrox`.`COM` AS `COM`,`vis_cobrox`.`NUM` AS `NUM`,`vis_cobrox`.`EMPC` AS `EMPC`,`vis_cobrox`.`ID_USU` AS `KOD_USU`,`vis_cobrox`.`ALM_NC` AS `ALM_NC` from ((`vis_cobrox` join `devoluciones` on(`vis_cobrox`.`DEV_ID` = `devoluciones`.`id_devolucion`)) join `comprobantes` on(`devoluciones`.`dev_id_comprobante` = `comprobantes`.`id_comprobante`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcobroz` AS select `cobroz`.`id_cobro` AS `ID`,`cobroz`.`cob_num` AS `NUM`,`comprobantes`.`com_nombre` AS `COM`,`cobroz`.`cob_cser` AS `CSER`,`cobroz`.`cob_cnum` AS `CNUM`,`cobroz`.`cob_fec` AS `FEC`,`cobroz`.`cob_gi` AS `GI`,`cobroz`.`cob_tot` AS `TOT`,`cobroz`.`cob_sal` AS `SAL`,`cobroz`.`cob_aut` AS `AUT`,`cobroz`.`cob_anu` AS `ANU`,`cobroz`.`cob_icser` AS `ICSER`,`cobroz`.`cob_icnum` AS `ICNUM`,`cobroz`.`cob_obs` AS `OBS`,`cobroz`.`cob_ven_tot` AS `VEN_TOT`,`cobroz`.`cob_ven_sal` AS `VEN_SAL`,`cobroz`.`cob_ven_acu` AS `VEN_ACU`,`usuarios`.`nom` AS `USU`,`clientes`.`cli_nombre` AS `CLI`,`cobroz`.`cob_id_tdp` AS `TDP`,`cobroz`.`cob_id_contrato` AS `ID_KON`,`cobroz`.`cob_id_empresa` AS `ID_EMP`,`empresas`.`emp_nomc` AS `EMPC`,`cobroz`.`cob_id_usuario` AS `KOD_USU`,`cobroz`.`cob_req_ver` AS `REG_VER`,`bancos`.`ban_nombre` AS `CTA_BAN`,`cuentas`.`cta_nro` AS `CTA_NRO`,`cuentas`.`cta_mnd` AS `CTA_MND`,`cobroz`.`cob_ope_nro` AS `OPE_NRO`,`cobroz`.`cob_ope_fec` AS `OPE_FEC`,date_format(`cobroz`.`cob_ope_fec`,'%d-%m-%y') AS `OPE_FEC_`,`cobroz`.`cob_id_cta` AS `ID_CTA`,`almacenes`.`alm_obs` AS `ALM_NC` from (((((((`cobroz` join `comprobantes` on(`cobroz`.`cob_id_com` = `comprobantes`.`id_comprobante`)) join `usuarios` on(`cobroz`.`cob_id_usuario` = `usuarios`.`id_usuario`)) join `clientes` on(`cobroz`.`cob_id_cliente` = `clientes`.`id_cliente`)) join `empresas` on(`cobroz`.`cob_id_empresa` = `empresas`.`id_emp`)) join `cuentas` on(`cobroz`.`cob_id_cta` = `cuentas`.`id_cta`)) join `bancos` on(`cuentas`.`cta_id_ban` = `bancos`.`id_banco`)) join `almacenes` on(`cobroz`.`cob_id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcobroz_dia` AS select `vcobroz`.`ID` AS `ID`,`vcobroz`.`FEC` AS `FEC`,concat(substr(`vcobroz`.`COM`,1,1),if(octet_length(`vcobroz`.`CSER`) > 0,concat(`vcobroz`.`CSER`,'-',`vcobroz`.`CNUM`),`vcobroz`.`CNUM`)) AS `GUIA`,`vcobroz`.`VEN_TOT` AS `IMPORTE`,if(`vcobroz`.`TDP` = 'EFECTIVO',`vcobroz`.`TOT`,0) AS `EFE`,if(`vcobroz`.`TDP` = 'DEPOSITO',`vcobroz`.`TOT`,0) AS `BAN`,`vcobroz`.`SAL` AS `SAL`,`vcobroz`.`CLI` AS `CLI`,`vcobroz`.`GI` AS `GI`,`vcobroz`.`TDP` AS `TDP`,`vcobroz`.`TOT` AS `TOT`,`vcobroz`.`ID_KON` AS `ID_KON`,`vcobroz`.`ANU` AS `ANU`,`vcobroz`.`COM` AS `COM`,`vcobroz`.`ICSER` AS `ICSER`,`vcobroz`.`ICNUM` AS `ICNUM`,`vcobroz`.`NUM` AS `NUM`,`vcobroz`.`EMPC` AS `EMPC`,`vcobroz`.`KOD_USU` AS `KOD_USU` from `vcobroz`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcobroz_dia_xx` AS select `vcobroz`.`ID` AS `ID`,`vcobroz`.`FEC` AS `FEC`,concat(substr(`vcobroz`.`COM`,1,1),if(octet_length(`vcobroz`.`CSER`) > 0,concat(`vcobroz`.`CSER`,'-',`vcobroz`.`CNUM`),`vcobroz`.`CNUM`)) AS `GUIA`,`vcobroz`.`VEN_TOT` AS `IMPORTE`,if(`vcobroz`.`TDP` = 'EFECTIVO',`vcobroz`.`TOT`,0) AS `EFE`,if(`vcobroz`.`TDP` = 'DEPOSITO',`vcobroz`.`TOT`,0) AS `BAN`,`vcobroz`.`SAL` AS `SAL`,`vcobroz`.`CLI` AS `CLI`,`vcobroz`.`GI` AS `GI`,`vcobroz`.`TDP` AS `TDP`,`vcobroz`.`TOT` AS `TOT`,`vcobroz`.`ID_KON` AS `ID_KON`,`vcobroz`.`ANU` AS `ANU`,`vcobroz`.`COM` AS `COM`,`vcobroz`.`ICSER` AS `ICSER`,`vcobroz`.`ICNUM` AS `ICNUM`,`vcobroz`.`NUM` AS `NUM`,`vcobroz`.`EMPC` AS `EMPC`,`vcobroz`.`KOD_USU` AS `KOD_USU`,`vcobroz`.`ALM_NC` AS `ALM_NC` from `vcobroz`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcom_control` AS select `compras`.`anulado` AS `ANU`,`compras`.`et` AS `ET`,`compras_det`.`id_producto` AS `IDP`,`compras_det`.`ca` AS `CA`,`compras_det`.`can_uni` AS `PIE`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`compras`.`fecha` AS `FEC` from ((`compras` join `compras_det` on(`compras`.`id_compra` = `compras_det`.`id_compra`)) join `almacenes` on(`compras`.`id_almacen` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcompras` AS select `compras`.`id_compra` AS `ID`,`almacenes`.`alm_nombre` AS `ALM`,`compras`.`fecha` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`compras`.`numero` AS `NUM`,`compras`.`moneda` AS `MON`,`compras`.`t_cambio` AS `TIC`,`proveedores`.`pro_nombre` AS `PROV`,`compras`.`id_tip_pag` AS `TDP`,`compras`.`inc_igv` AS `INI`,`compras`.`sub_total` AS `SUT`,`compras`.`igv` AS `IGV`,`compras`.`total` AS `TOT`,`compras`.`anulado` AS `ANU`,`proveedores`.`pro_ruc` AS `RUC`,`proveedores`.`pro_dni` AS `DNI`,`compras`.`id_proveedor` AS `ID_PROV`,`compras`.`gi` AS `GI`,`compras`.`et` AS `ET`,`empresas`.`emp_nomc` AS `EMPC`,`almacenes`.`alm_obs` AS `ALMC`,`compras`.`ser` AS `SER`,`compras`.`dam` AS `DAM`,`compras`.`ser_` AS `SER_`,`compras`.`dam_` AS `DAM_`,`compras`.`num_` AS `NUM_`,`compras`.`id_almacen` AS `ID_ALM`,`almacenes`.`alm_id_empresa` AS `ID_EMP` from ((((`compras` join `almacenes` on(`compras`.`id_almacen` = `almacenes`.`id_almacen`)) join `comprobantes` on(`compras`.`id_comprobante` = `comprobantes`.`id_comprobante`)) join `proveedores` on(`compras`.`id_proveedor` = `proveedores`.`id_proveedor`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcompras_det` AS select `compras`.`id_compra` AS `ID`,`almacenes`.`alm_nombre` AS `ALM`,`compras`.`fecha` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`compras`.`numero` AS `NUM`,`compras`.`moneda` AS `MON`,`compras`.`t_cambio` AS `TIC`,`proveedores`.`pro_nombre` AS `PROV`,`compras`.`id_tip_pag` AS `TDP`,`compras`.`inc_igv` AS `INI`,`compras`.`sub_total` AS `SUT`,`compras`.`igv` AS `IGV`,`compras`.`total` AS `TOT`,`compras`.`anulado` AS `ANU`,`proveedores`.`pro_ruc` AS `RUC`,`proveedores`.`pro_dni` AS `DNI`,`compras`.`id_proveedor` AS `ID_PROV`,`compras`.`gi` AS `GI`,`compras_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `COD`,`marcas`.`mar_nombre` AS `MAR`,`productos`.`pro_des` AS `DES`,`compras_det`.`ca` AS `KA`,`compras_det`.`pr` AS `PR`,`compras_det`.`im` AS `IMP`,`compras`.`et` AS `ET`,`lineas`.`lin_nombre` AS `LINEA`,`compras_det`.`can_uni` AS `PIEZAS`,`empresas`.`emp_nomc` AS `EMPC`,`almacenes`.`alm_obs` AS `ALMC`,`compras`.`ser` AS `SER`,`compras`.`dam` AS `DAM` from ((((((((`compras` join `almacenes` on(`compras`.`id_almacen` = `almacenes`.`id_almacen`)) join `comprobantes` on(`compras`.`id_comprobante` = `comprobantes`.`id_comprobante`)) join `proveedores` on(`compras`.`id_proveedor` = `proveedores`.`id_proveedor`)) join `compras_det` on(`compras`.`id_compra` = `compras_det`.`id_compra`)) join `productos` on(`compras_det`.`id_producto` = `productos`.`id_producto`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`)) join `lineas` on(`lineas`.`id_linea` = `productos`.`pro_id_linea`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcompras_det_` AS select `compras`.`id_compra` AS `ID`,`compras`.`fecha` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`compras`.`numero` AS `NUM`,`compras`.`moneda` AS `MON`,`compras`.`anulado` AS `ANU`,`compras`.`gi` AS `GI`,`compras_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES`,`compras_det`.`ca` AS `KA`,`compras_det`.`pr` AS `PR`,`compras_det`.`im` AS `IMP`,`lineas`.`lin_nombre` AS `LINEA`,`compras_det`.`can_uni` AS `PIEZAS`,`compras`.`ser` AS `SER`,`compras`.`dam` AS `DAM`,`compras`.`ser_` AS `SER_`,`compras`.`num_` AS `NUM_`,`compras`.`dam_` AS `DAM_`,`compras_det`.`id_producto` AS `ID_PRO` from ((((`compras` join `comprobantes` on(`compras`.`id_comprobante` = `comprobantes`.`id_comprobante`)) join `compras_det` on(`compras`.`id_compra` = `compras_det`.`id_compra`)) join `productos` on(`compras_det`.`id_producto` = `productos`.`id_producto`)) join `lineas` on(`lineas`.`id_linea` = `productos`.`pro_id_linea`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcot_control` AS select `cotizaciones_det`.`id_producto` AS `IDP`,`cotizaciones_det`.`ca` AS `CA`,`cotizaciones_det`.`can_uni` AS `PIE`,`cotizaciones_det`.`ca_control` AS `CA_CONTROL`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones_det`.`dej` AS `DEJ`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`cotizaciones`.`fec` AS `FEC`,`cotizaciones`.`cot_pri` AS `PRI`,`cotizaciones`.`id_cotizacion` AS `ID_COT` from ((`cotizaciones` join `cotizaciones_det` on(`cotizaciones`.`id_cotizacion` = `cotizaciones_det`.`id_cotizacion`)) join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcot_edc` AS select `cotizaciones`.`id_cotizacion` AS `ID`,`almacenes`.`alm_nombre` AS `ALM`,`cotizaciones`.`fec` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`cotizaciones`.`ser` AS `SER`,`cotizaciones`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`cotizaciones`.`tcam` AS `TCAM`,`cotizaciones`.`inc_igv` AS `IIG`,`cotizaciones`.`tot` AS `TOT`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM`,`cotizaciones`.`id_usuario` AS `IDU`,`cotizaciones`.`mon` AS `MON`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones`.`gi` AS `GI`,`cotizaciones`.`nped` AS `NPED`,`cotizaciones`.`contacto` AS `CONT`,`cotizaciones`.`id_cliente` AS `IDCLI`,`clientes`.`cli_email` AS `EMA`,`clientes`.`cli_dir` AS `DIR`,`personal`.`per_nombre` AS `VEN`,`tipos_pagos`.`tipp_nombre` AS `TDP`,`cotizaciones`.`acu` AS `ACU`,`monedas`.`mon_nombre` AS `MND`,`cotizaciones`.`vue` AS `VUE`,`cotizaciones`.`sal` AS `SAL`,`cotizaciones`.`modalidad` AS `MODAL`,`cotizaciones`.`cot_pri` AS `PRI_`,`cotizaciones`.`cot_des` AS `DES_`,concat(`cotizaciones`.`ser`,'-',`cotizaciones`.`num`) AS `SER_NUM`,`cotizaciones`.`tot_real` AS `TOT_REAL`,`cotizaciones`.`tot_des` AS `TOT_DES`,`cotizaciones`.`tot_cob` AS `TOT_COB`,`cotizaciones`.`tot_real` - `cotizaciones`.`tot_cob` AS `SALDO`,`empresas`.`emp_nomc` AS `EMPC` from (((((((`cotizaciones` join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `comprobantes` on(`cotizaciones`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`cotizaciones`.`id_cliente` = `clientes`.`id_cliente`)) join `personal` on(`cotizaciones`.`id_vendedor` = `personal`.`id_personal`)) join `tipos_pagos` on(`cotizaciones`.`id_tip_pag` = `tipos_pagos`.`id_tip_pag`)) join `monedas` on(`cotizaciones`.`id_moneda` = `monedas`.`id_moneda`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcot_sal_pen` AS select `cotizaciones`.`id_cotizacion` AS `ID`,`cotizaciones`.`fec` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`cotizaciones`.`ser` AS `SER`,`cotizaciones`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`cotizaciones`.`tcam` AS `TCAM`,`cotizaciones`.`inc_igv` AS `IIG`,`cotizaciones`.`tot` AS `TOT`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM`,`cotizaciones`.`id_usuario` AS `IDU`,`cotizaciones`.`mon` AS `MON`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones`.`gi` AS `GI`,`cotizaciones`.`nped` AS `NPED`,`cotizaciones`.`contacto` AS `CONT`,`cotizaciones`.`id_cliente` AS `IDCLI`,`cotizaciones_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `COD`,`cotizaciones_det`.`des` AS `DES`,`cotizaciones_det`.`ca` AS `KA`,`cotizaciones_det`.`pr` AS `PR`,`cotizaciones_det`.`im` AS `IMP`,`cotizaciones_det`.`dt` AS `DT`,`marcas`.`mar_nombre` AS `MAR`,`cotizaciones_det`.`can_uni` AS `UNI`,`lineas`.`lin_nombre` AS `LINEA`,`cotizaciones_det`.`ca_control` AS `CA_CONTROL`,`cotizaciones_det`.`ve_control` AS `VE_CONTROL`,`cotizaciones_det`.`dej` AS `DEJA`,`cotizaciones`.`cot_pri` AS `PRI_`,`cotizaciones`.`cot_des` AS `DES_`,`empresas`.`emp_nomc` AS `EMPC` from ((((((((`cotizaciones` join `comprobantes` on(`cotizaciones`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`cotizaciones`.`id_cliente` = `clientes`.`id_cliente`)) join `cotizaciones_det` on(`cotizaciones`.`id_cotizacion` = `cotizaciones_det`.`id_cotizacion`)) join `productos` on(`cotizaciones_det`.`id_producto` = `productos`.`id_producto`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcotizaciones` AS select `cotizaciones`.`id_cotizacion` AS `ID`,`almacenes`.`alm_obs` AS `ALM`,`cotizaciones`.`fec` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`cotizaciones`.`ser` AS `SER`,`cotizaciones`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`cotizaciones`.`tcam` AS `TCAM`,`cotizaciones`.`inc_igv` AS `IIG`,`cotizaciones`.`tot` AS `TOT`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM`,`cotizaciones`.`id_usuario` AS `IDU`,`cotizaciones`.`mon` AS `MON`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones`.`gi` AS `GI`,`cotizaciones`.`nped` AS `NPED`,`cotizaciones`.`contacto` AS `CONT`,`cotizaciones`.`id_cliente` AS `IDCLI`,`clientes`.`cli_email` AS `EMA`,`clientes`.`cli_dir` AS `DIR`,`personal`.`per_nombre` AS `VEN`,`tipos_pagos`.`tipp_nombre` AS `TDP`,`cotizaciones`.`acu` AS `ACU`,`monedas`.`mon_nombre` AS `MND`,`cotizaciones`.`vue` AS `VUE`,`cotizaciones`.`sal` AS `SAL`,`cotizaciones`.`modalidad` AS `MODAL`,`cotizaciones`.`cot_pri` AS `PRI_`,`cotizaciones`.`cot_des` AS `DES_`,concat(`cotizaciones`.`ser`,'-',`cotizaciones`.`num`) AS `SER_NUM`,`cotizaciones`.`tot_real` AS `TOT_REAL`,`cotizaciones`.`tot_des` AS `TOT_DES`,`cotizaciones`.`tot_cob` AS `TOT_COB`,`cotizaciones`.`tot_real` - `cotizaciones`.`tot_cob` AS `SALDO`,`empresas`.`emp_nomc` AS `EMPC`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`compras`.`ser` AS `COM_SER`,`compras`.`numero` AS `COM_NUM`,`compras_doc`.`com_nombre` AS `COM_DOC`,`com_empresas`.`emp_nomc` AS `COM_EMP`,`clientes`.`cli_dni` AS `DNI`,`personal`.`per_cel` AS `PER_CEL`,`clientes`.`cli_tel` AS `CLI_TEL`,`clientes`.`cli_cel` AS `CLI_CEL` from (((((((((((`cotizaciones` join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `comprobantes` on(`cotizaciones`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`cotizaciones`.`id_cliente` = `clientes`.`id_cliente`)) join `personal` on(`cotizaciones`.`id_vendedor` = `personal`.`id_personal`)) join `tipos_pagos` on(`cotizaciones`.`id_tip_pag` = `tipos_pagos`.`id_tip_pag`)) join `monedas` on(`cotizaciones`.`id_moneda` = `monedas`.`id_moneda`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `compras` on(`cotizaciones`.`id_compra` = `compras`.`id_compra`)) join `comprobantes` `compras_doc` on(`compras`.`id_comprobante` = `compras_doc`.`id_comprobante`)) join `almacenes` `com_almacenes` on(`compras`.`id_almacen` = `com_almacenes`.`id_almacen`)) join `empresas` `com_empresas` on(`com_almacenes`.`alm_id_empresa` = `com_empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcotizaciones_app` AS select `cotizaciones`.`id_cotizacion` AS `ID`,`cotizaciones`.`fec` AS `FEC`,`cotizaciones`.`ser` AS `SER`,`cotizaciones`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`cotizaciones`.`tcam` AS `TCAM`,`cotizaciones`.`inc_igv` AS `IIG`,`cotizaciones`.`tot` AS `TOT`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM`,`cotizaciones`.`id_usuario` AS `IDU`,`cotizaciones`.`mon` AS `MON`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones`.`gi` AS `GI`,`cotizaciones`.`nped` AS `NPED`,`cotizaciones`.`contacto` AS `CONT`,`cotizaciones`.`id_cliente` AS `IDCLI`,`personal`.`per_nombre` AS `VEN`,`cotizaciones`.`acu` AS `ACU`,`cotizaciones`.`vue` AS `VUE`,`cotizaciones`.`sal` AS `SAL`,`cotizaciones`.`modalidad` AS `MODAL`,`cotizaciones`.`cot_pri` AS `PRI_`,`cotizaciones`.`cot_des` AS `DES_`,concat(`cotizaciones`.`ser`,'-',`cotizaciones`.`num`) AS `SER_NUM`,`cotizaciones`.`tot_real` AS `TOT_REAL`,`cotizaciones`.`tot_des` AS `TOT_DES`,`cotizaciones`.`tot_cob` AS `TOT_COB`,`cotizaciones`.`tot_real` - `cotizaciones`.`tot_cob` AS `SALDO`,`clientes`.`cli_dni` AS `DNI`,`cotizaciones`.`bit_precio` AS `BIT_PRE`,`cotizaciones`.`bit_stock` AS `BIT_STO`,`cotizaciones`.`bit_estado` AS `BIT_EST` from ((`cotizaciones` join `clientes` on(`cotizaciones`.`id_cliente` = `clientes`.`id_cliente`)) join `personal` on(`cotizaciones`.`id_vendedor` = `personal`.`id_personal`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcotizaciones_det` AS select `cotizaciones`.`id_cotizacion` AS `ID`,`almacenes`.`alm_obs` AS `ALM`,`cotizaciones`.`fec` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`cotizaciones`.`ser` AS `SER`,`cotizaciones`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`cotizaciones`.`tcam` AS `TCAM`,`cotizaciones`.`inc_igv` AS `IIG`,`cotizaciones`.`tot` AS `TOT`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM`,`cotizaciones`.`id_usuario` AS `IDU`,`cotizaciones`.`mon` AS `MON`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones`.`gi` AS `GI`,`cotizaciones`.`nped` AS `NPED`,`cotizaciones`.`contacto` AS `CONT`,`cotizaciones`.`id_cliente` AS `IDCLI`,`cotizaciones_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `COD`,`cotizaciones_det`.`des` AS `DES`,`cotizaciones_det`.`ca` AS `KA`,`cotizaciones_det`.`pr` AS `PR`,`cotizaciones_det`.`im` AS `IMP`,`cotizaciones_det`.`dt` AS `DT`,`marcas`.`mar_nombre` AS `MAR`,`cotizaciones_det`.`can_uni` AS `UNI`,`lineas`.`lin_nombre` AS `LINEA`,`cotizaciones_det`.`ca_control` AS `CA_CONTROL`,`cotizaciones_det`.`ve_control` AS `VE_CONTROL`,`cotizaciones_det`.`dej` AS `DEJA`,`empresas`.`emp_nomc` AS `EMPC` from ((((((((`cotizaciones` join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `comprobantes` on(`cotizaciones`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`cotizaciones`.`id_cliente` = `clientes`.`id_cliente`)) join `cotizaciones_det` on(`cotizaciones`.`id_cotizacion` = `cotizaciones_det`.`id_cotizacion`)) join `productos` on(`cotizaciones_det`.`id_producto` = `productos`.`id_producto`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcotizaciones_det2` AS select `cotizaciones_det`.`id_cotizacion` AS `ID`,`cotizaciones_det`.`cx` AS `CX`,`cotizaciones_det`.`id_producto` AS `IDP`,`cotizaciones_det`.`ca` AS `CA`,`cotizaciones_det`.`pr` AS `PR`,`cotizaciones_det`.`im` AS `IMP`,`cotizaciones_det`.`can_uni` AS `PIE`,`cotizaciones_det`.`ca_control` AS `CA_CONTROL`,`cotizaciones_det`.`ve_control` AS `VE_CONTROL`,`cotizaciones_det`.`dev` AS `DEV`,`cotizaciones_det`.`dej` AS `DEJ`,`cotizaciones_det`.`ca` - `cotizaciones_det`.`ca_control` AS `T_SAL` from `cotizaciones_det`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vcotizaciones_det_permisos` AS select `cotizaciones`.`id_cotizacion` AS `ID`,`almacenes`.`alm_obs` AS `ALM`,`cotizaciones`.`fec` AS `FEC`,date_format(`cotizaciones`.`fec`,'%d-%m-%y') AS `FEC_`,`cotizaciones`.`ser` AS `SER`,`cotizaciones`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM`,`cotizaciones`.`id_usuario` AS `IDU`,`cotizaciones`.`mon` AS `MON`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones`.`gi` AS `GI`,`cotizaciones`.`nped` AS `NPED`,`cotizaciones`.`contacto` AS `CONT`,`cotizaciones_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `COD`,`cotizaciones_det`.`des` AS `DES`,`cotizaciones_det`.`ca` AS `KA`,`cotizaciones_det`.`pr` AS `PR`,`cotizaciones_det`.`im` AS `IMP`,`cotizaciones_det`.`dt` AS `DT`,`cotizaciones_det`.`can_uni` AS `UNI`,`cotizaciones_det`.`ca_control` AS `CA_CONTROL`,`cotizaciones_det`.`ve_control` AS `VE_CONTROL`,`cotizaciones_det`.`dej` AS `DEJA`,`personal`.`per_nombre` AS `VENDEDOR`,`cotizaciones_det`.`bit_stock` AS `BIT_STOCK`,`cotizaciones_det`.`bit_stock_usu` AS `BIT_STOCK_USU`,`cotizaciones_det`.`bit_stock_dis` AS `BIT_STOCK_DIS`,`cotizaciones_det`.`bit_stock_ex` AS `BIT_STOCK_EX`,`cotizaciones_det`.`bit_precio` AS `BIT_PRECIO`,`cotizaciones_det`.`bit_precio_usu` AS `BIT_PRECIO_USU`,`cotizaciones_det`.`bit_precio_ex` AS `BIT_PRECIO_EX`,`cotizaciones_det`.`bit_precio_min` AS `BIT_PRECIO_MIN`,`usu_stock`.`nom` AS `USU_STOCK`,`usu_precio`.`nom` AS `USU_PRECIO` from (((((((`cotizaciones` join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `clientes` on(`cotizaciones`.`id_cliente` = `clientes`.`id_cliente`)) join `cotizaciones_det` on(`cotizaciones`.`id_cotizacion` = `cotizaciones_det`.`id_cotizacion`)) join `productos` on(`cotizaciones_det`.`id_producto` = `productos`.`id_producto`)) join `personal` on(`cotizaciones`.`id_vendedor` = `personal`.`id_personal`)) join `usuarios` `usu_stock` on(`cotizaciones_det`.`bit_stock_usu` = `usu_stock`.`id_usuario`)) join `usuarios` `usu_precio` on(`cotizaciones_det`.`bit_precio_usu` = `usu_precio`.`id_usuario`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vdev_control` AS select `devoluciones`.`dev_anu` AS `ANU`,`devoluciones_det`.`dd_id_producto` AS `IDP`,`devoluciones_det`.`dd_cant` AS `CA`,`devoluciones_det`.`dd_pie` AS `PIE`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`devoluciones`.`dev_fec` AS `FEC`,`devoluciones`.`dev_tipo` AS `TIP` from ((`devoluciones` join `devoluciones_det` on(`devoluciones`.`id_devolucion` = `devoluciones_det`.`dd_id_devolucion`)) join `almacenes` on(`devoluciones`.`dev_id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vdevoluciones` AS select `devoluciones`.`id_devolucion` AS `ID`,`almacenes`.`alm_nombre` AS `ALM`,`devoluciones`.`dev_nro` AS `NRO`,`devoluciones`.`dev_fec` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`devoluciones`.`dev_ser` AS `SER`,`devoluciones`.`dev_num` AS `NUM`,`devoluciones`.`dev_anu` AS `ANU`,`devoluciones`.`dev_nro_` AS `NRO_`,`devoluciones`.`dev_total` AS `TOT`,`clientes`.`cli_nombre` AS `CLI`,`devoluciones`.`dev_tipo` AS `TIP`,`devoluciones`.`dev_usado` AS `USADO`,`devoluciones`.`dev_dinero` AS `DINERO`,`devoluciones`.`dev_recibo` AS `RECIBO`,`empresas`.`emp_nomc` AS `EMPC`,`almacenes`.`alm_obs` AS `ALMC`,`usuarios`.`nom` AS `USU` from (((((`devoluciones` join `comprobantes` on(`devoluciones`.`dev_id_comprobante` = `comprobantes`.`id_comprobante`)) join `almacenes` on(`devoluciones`.`dev_id_alm` = `almacenes`.`id_almacen`)) join `clientes` on(`devoluciones`.`dev_id_cliente` = `clientes`.`id_cliente`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `usuarios` on(`devoluciones`.`dev_id_usuario` = `usuarios`.`id_usuario`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vdevoluciones_full` AS select `devoluciones`.`id_devolucion` AS `ID`,`devoluciones`.`dev_id_alm` AS `ID_ALM`,`devoluciones`.`dev_nro` AS `NRO`,`devoluciones`.`dev_fec` AS `FEC`,`devoluciones`.`dev_id_comprobante` AS `ID_COM`,`devoluciones`.`dev_ser` AS `SER`,`devoluciones`.`dev_num` AS `NUM`,`devoluciones`.`dev_anu` AS `ANU`,`devoluciones`.`dev_id_usuario` AS `IDU`,`devoluciones`.`dev_gi` AS `GI`,`devoluciones`.`dev_total` AS `TOT`,`devoluciones`.`dev_id_cliente` AS `ID_CLI`,`devoluciones`.`dev_id_ref` AS `ID_REF`,`devoluciones`.`dev_tipo` AS `TIP`,`devoluciones_det`.`dd_id_producto` AS `IDP`,`devoluciones_det`.`dd_cant` AS `CAN`,`devoluciones_det`.`dd_pie` AS `PIE`,`devoluciones_det`.`dd_pre` AS `PRE`,`devoluciones_det`.`dd_imp` AS `IMP` from (`devoluciones` join `devoluciones_det` on(`devoluciones`.`id_devolucion` = `devoluciones_det`.`dd_id_devolucion`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vegresos` AS select `egresos`.`id_egreso` AS `ID`,`egresos`.`fec` AS `FEC`,`almacenes`.`alm_obs` AS `ALM`,`egresos_tipos`.`nombre` AS `TDE`,`egresos`.`tot` AS `TOT`,`egresos`.`obs` AS `OBS`,`egresos`.`nro` AS `NRO`,`empresas`.`emp_nomc` AS `EMPC`,`usuarios`.`nom` AS `USU`,`egresos`.`anu` AS `ANU`,`egresos`.`anu_fec` AS `ANU_FEC`,date_format(`egresos`.`anu_fec`,'%d-%m-%y') AS `ANU_FEC_`,`egresos`.`anu_hor` AS `ANU_HOR`,`egresos`.`anu_tim` AS `ANU_TIM`,`egresos`.`anu_usu` AS `ANU_USU` from ((((`egresos` join `egresos_tipos` on(`egresos`.`id_et` = `egresos_tipos`.`id_et`)) join `almacenes` on(`egresos`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `usuarios` on(`egresos`.`eg_id_usu` = `usuarios`.`id_usuario`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vgiainterna_full` AS select `ginterna`.`id_gi` AS `ID`,`ginterna`.`gi_id_cotizacion` AS `ID_COT`,`ginterna`.`gi_anu` AS `ANU`,`ginterna_det`.`id_producto` AS `IDP`,`ginterna_det`.`ca` AS `CAN`,`ginterna_det`.`can_uni` AS `PIE` from (`ginterna` join `ginterna_det` on(`ginterna`.`id_gi` = `ginterna_det`.`id_gi`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vgin_control` AS select `ginterna`.`gi_anu` AS `ANU`,`ginterna_det`.`id_producto` AS `IDP`,`ginterna_det`.`ca` AS `CA`,`ginterna_det`.`can_uni` AS `PIE`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`ginterna`.`gi_fec` AS `FEC` from ((`ginterna` join `ginterna_det` on(`ginterna`.`id_gi` = `ginterna_det`.`id_gi`)) join `almacenes` on(`ginterna`.`gi_id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vginterna` AS select `ginterna`.`id_gi` AS `ID`,`almacenes`.`alm_obs` AS `ALM`,`ginterna`.`gi_inum` AS `INUM`,`ginterna`.`gi_num` AS `NUM`,`ginterna`.`gi_fec` AS `FEC`,`ginterna`.`gi_id_cliente` AS `ID_CLIENTE`,`ginterna`.`gi_destinatario` AS `DES`,`ginterna`.`gi_id_cotizacion` AS `ID_COT`,`ginterna`.`gi_cot_ser` AS `COT_SER`,`ginterna`.`gi_cot_num` AS `COT_NUM`,`ginterna`.`gi_anu` AS `ANU`,`ginterna`.`gi_id_usuario` AS `IDU`,`clientes`.`cli_nombre` AS `CLI`,`ginterna`.`gi_serie` AS `SER`,`ginterna`.`gi_iserie` AS `ISER`,`empresas`.`emp_nomc` AS `EMPC`,`cot_alm`.`alm_obs` AS `C_ALM`,`cot_emp`.`emp_nomc` AS `C_EMP`,`ginterna`.`gi_car` AS `CAR` from ((((((`ginterna` join `almacenes` on(`ginterna`.`gi_id_alm` = `almacenes`.`id_almacen`)) join `cotizaciones` on(`ginterna`.`gi_id_cotizacion` = `cotizaciones`.`id_cotizacion`)) join `clientes` on(`cotizaciones`.`id_cliente` = `clientes`.`id_cliente`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `almacenes` `cot_alm` on(`cotizaciones`.`id_alm` = `cot_alm`.`id_almacen`)) join `empresas` `cot_emp` on(`cot_alm`.`alm_id_empresa` = `cot_emp`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vginterna_det` AS select `ginterna`.`id_gi` AS `ID`,`almacenes`.`alm_obs` AS `ALM`,`ginterna`.`gi_num` AS `NUM`,`ginterna`.`gi_fec` AS `FEC`,`ginterna`.`gi_destinatario` AS `DEST`,`ginterna`.`gi_cot_ser` AS `COT_SER`,`ginterna`.`gi_cot_num` AS `COT_NUM`,`ginterna`.`gi_anu` AS `ANU`,`ginterna_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `PRO_COD`,`productos`.`pro_des` AS `PRO_DES`,`ginterna_det`.`ca` AS `CA`,`ginterna_det`.`can_uni` AS `PIEZAS`,`ginterna`.`gi_inum` AS `INUM`,`ginterna`.`gi_serie` AS `SER`,`ginterna`.`gi_iserie` AS `ISER`,`empresas`.`emp_nomc` AS `EMPC` from ((((`ginterna` join `almacenes` on(`ginterna`.`gi_id_alm` = `almacenes`.`id_almacen`)) join `ginterna_det` on(`ginterna`.`id_gi` = `ginterna_det`.`id_gi`)) join `productos` on(`ginterna_det`.`id_producto` = `productos`.`id_producto`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vguia_control` AS select `guias`.`anu` AS `ANU`,`guias_det`.`id_producto` AS `IDP`,`guias_det`.`ca` AS `CA`,`guias_det`.`can_uni` AS `PIE`,`guias`.`guia_desc` AS `ALTER_STOCK`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`guias`.`fe` AS `FEC`,`guias`.`id_almacen` AS `ID_ALM` from ((`guias` join `guias_det` on(`guias`.`id_guia` = `guias_det`.`id_guia`)) join `almacenes` on(`guias`.`id_almacen` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vguias` AS select `guias`.`id_guia` AS `ID`,`almacenes`.`alm_obs` AS `ALM`,`guias`.`tipo` AS `TIP`,`guias`.`ser` AS `SER`,`guias`.`num` AS `NUM`,`guias`.`fe` AS `FEC`,`guias`.`fit` AS `FIT`,`guias`.`dir_par` AS `DIR_PAR`,`guias`.`costo` AS `COSTO`,`guias`.`t_mar` AS `TMAR`,`guias`.`t_placa` AS `TPLA`,`guias`.`t_const` AS `TCON`,`guias`.`t_nlic` AS `TLIC`,`guias`.`des_rs` AS `DES_RS`,`guias`.`des_dir` AS `DES_DIR`,`guias`.`des_ruc` AS `DES_RUC`,`guias`.`et_rs` AS `ET_RS`,`guias`.`et_ruc` AS `ET_RU`,`comprobantes`.`com_nombre` AS `COMR`,`guias`.`serr` AS `SERR`,`guias`.`numr` AS `NUMR`,cast(`guias`.`serr` as unsigned) AS `SERR_`,cast(`guias`.`numr` as unsigned) AS `NUMR_`,`guias`.`idr` AS `IDR`,`guias`.`oc_nro` AS `OC_NRO`,`guias`.`anu` AS `ANU`,`guias`.`iser` AS `ISER`,`guias`.`inum` AS `INUM`,`guias`.`gi` AS `GI`,`alm_sal`.`alm_obs` AS `ALM_SAL`,`guias`.`des_dni` AS `DES_DNI`,`empresas`.`emp_nomc` AS `EMPC`,`s_emp`.`emp_nomc` AS `S_EMPC`,`r_emp`.`emp_nomc` AS `R_EMPC`,`tipos_de_guias`.`com_nombre` AS `TIP_GIA`,`gdr_motivos`.`mot_des` AS `MOTIVO`,`lista_paises`.`pai_nom` AS `PAIS`,`guias`.`xx_ubi_dep` AS `UBI_DEP`,`guias`.`xx_ubi_pro` AS `UBI_PRO`,`guias`.`xx_ubi_dis` AS `UBI_DIS`,`guias`.`xx_ubi_cod` AS `UBI_COD`,`guias`.`xx_peso` AS `PESO`,`guias`.`xx_ce_gen` AS `CE_GEN`,`guias`.`xx_ce_hash` AS `CE_HASH`,`guias`.`xx_ce_fec` AS `CE_FEC`,`guias`.`xx_ce_hor` AS `CE_HOR`,`guias`.`xx_ce_tim` AS `CE_TIM`,`guias`.`xx_ce_usu` AS `CE_USU`,`guias`.`xx_tip_tra` AS `TIP_TRA`,`sunat_catalogos`.`des` AS `CHO_TDI`,`guias`.`xx_tdi_nro` AS `TDI_NRO`,`guias`.`xx_cho_nom` AS `CHO_NOM`,`guias`.`xx_cho_ape` AS `CHO_APE`,`empresas`.`emp_fe_ruc` AS `EMP_RUC`,`guias`.`xx_link` AS `LINK` from ((((((((((`guias` join `almacenes` on(`guias`.`id_almacen` = `almacenes`.`id_almacen`)) join `comprobantes` on(`guias`.`id_comr` = `comprobantes`.`id_comprobante`)) join `almacenes` `alm_sal` on(`guias`.`guia_id_alm` = `alm_sal`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `empresas` `s_emp` on(`alm_sal`.`alm_id_empresa` = `s_emp`.`id_emp`)) join `empresas` `r_emp` on(`guias`.`id_emp_r` = `r_emp`.`id_emp`)) join `comprobantes` `tipos_de_guias` on(`guias`.`xx_id_tip_gia` = `tipos_de_guias`.`id_comprobante`)) join `gdr_motivos` on(`guias`.`xx_id_mot` = `gdr_motivos`.`id_mot`)) join `lista_paises` on(`guias`.`xx_id_pais` = `lista_paises`.`id_pais`)) join `sunat_catalogos` on(`guias`.`xx_id_tdi` = `sunat_catalogos`.`id`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vguias24` AS select `guias`.`id_guia` AS `ID`,`almacenes`.`alm_obs` AS `ALM`,`guias`.`tipo` AS `TIP`,`guias`.`ser` AS `SER`,`guias`.`num` AS `NUM`,date_format(`guias`.`fe`,'%d-%m-%Y') AS `FEC_`,`guias`.`fe` AS `FEC`,`guias`.`fit` AS `FIT`,date_format(`guias`.`fit`,'%d-%m-%Y') AS `FIT_`,`guias`.`dir_par` AS `DIR_PAR`,`guias`.`costo` AS `COSTO`,`guias`.`t_mar` AS `TMAR`,`guias`.`t_placa` AS `TPLA`,`guias`.`t_const` AS `TCON`,`guias`.`t_nlic` AS `TLIC`,`guias`.`des_rs` AS `DES_RS`,`guias`.`des_dir` AS `DES_DIR`,`guias`.`des_ruc` AS `DES_RUC`,`guias`.`et_rs` AS `ET_RS`,`guias`.`et_ruc` AS `ET_RU`,`comprobantes`.`com_nombre` AS `COMR`,`guias`.`serr` AS `SERR`,`guias`.`numr` AS `NUMR`,cast(`guias`.`serr` as unsigned) AS `SERR_`,cast(`guias`.`numr` as unsigned) AS `NUMR_`,`guias`.`idr` AS `IDR`,`guias`.`oc_nro` AS `OC_NRO`,`guias`.`anu` AS `ANU`,`guias`.`iser` AS `ISER`,`guias`.`inum` AS `INUM`,`guias`.`gi` AS `GI`,`alm_sal`.`alm_obs` AS `ALM_SAL`,`guias`.`des_dni` AS `DES_DNI`,`empresas`.`emp_nomc` AS `EMPC`,`s_emp`.`emp_nomc` AS `S_EMPC`,`r_emp`.`emp_nomc` AS `R_EMPC`,`tipos_de_guias`.`com_nombre` AS `TIP_GIA`,`gdr_motivos`.`mot_des` AS `MOTIVO`,`lista_paises`.`pai_nom` AS `PAIS`,`guias`.`xx_ubi_dep` AS `UBI_DEP`,`guias`.`xx_ubi_pro` AS `UBI_PRO`,`guias`.`xx_ubi_dis` AS `UBI_DIS`,`guias`.`xx_ubi_cod` AS `UBI_COD`,`guias`.`xx_peso` AS `PESO`,`guias`.`xx_ce_gen` AS `CE_GEN`,`guias`.`xx_ce_hash` AS `CE_HASH`,`guias`.`xx_ce_fec` AS `CE_FEC`,`guias`.`xx_ce_hor` AS `CE_HOR`,`guias`.`xx_ce_tim` AS `CE_TIM`,`guias`.`xx_ce_usu` AS `CE_USU`,`guias`.`xx_tip_tra` AS `TIP_TRA`,`sunat_catalogos`.`des` AS `CHO_TDI`,`guias`.`xx_tdi_nro` AS `TDI_NRO`,`guias`.`xx_cho_nom` AS `CHO_NOM`,`guias`.`xx_cho_ape` AS `CHO_APE`,`empresas`.`emp_fe_ruc` AS `EMP_RUC`,`guias`.`xx_link` AS `LINK`,`empresas`.`emp_noml` AS `EMPRESA_NL`,`guias`.`tra_pro` AS `TRA_PRO` from ((((((((((`guias` join `almacenes` on(`guias`.`id_almacen` = `almacenes`.`id_almacen`)) join `comprobantes` on(`guias`.`id_comr` = `comprobantes`.`id_comprobante`)) join `almacenes` `alm_sal` on(`guias`.`guia_id_alm` = `alm_sal`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `empresas` `s_emp` on(`alm_sal`.`alm_id_empresa` = `s_emp`.`id_emp`)) join `empresas` `r_emp` on(`guias`.`id_emp_r` = `r_emp`.`id_emp`)) join `comprobantes` `tipos_de_guias` on(`guias`.`xx_id_tip_gia` = `tipos_de_guias`.`id_comprobante`)) join `gdr_motivos` on(`guias`.`xx_id_mot` = `gdr_motivos`.`id_mot`)) join `lista_paises` on(`guias`.`xx_id_pais` = `lista_paises`.`id_pais`)) join `sunat_catalogos` on(`guias`.`xx_id_tdi` = `sunat_catalogos`.`id`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vguias_d` AS select `guias_det`.`id_guia` AS `ID`,`guias_det`.`cx` AS `CX`,`guias_det`.`cod` AS `CO`,`guias_det`.`des` AS `DE`,`unidades`.`uni_nombre` AS `UN`,`guias_det`.`ca` AS `CA` from ((`guias_det` join `productos` on(`guias_det`.`id_producto` = `productos`.`id_producto`)) join `unidades` on(`productos`.`pro_id_unidad` = `unidades`.`id_unidad`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vguias_det` AS select `guias`.`id_guia` AS `ID`,`almacenes`.`alm_obs` AS `ALM`,`guias`.`tipo` AS `TIP`,`guias`.`ser` AS `SER`,`guias`.`num` AS `NUM`,`guias`.`fe` AS `FEC`,`guias`.`fit` AS `FIT`,`guias`.`dir_par` AS `DIR_PAR`,`guias`.`costo` AS `COSTO`,`guias`.`t_mar` AS `TMAR`,`guias`.`t_placa` AS `TPLA`,`guias`.`t_const` AS `TCON`,`guias`.`t_nlic` AS `TLIC`,`guias`.`des_rs` AS `DES_RS`,`guias`.`des_dir` AS `DES_DIR`,`guias`.`des_ruc` AS `DES_RUC`,`guias`.`et_rs` AS `ET_RS`,`guias`.`et_ruc` AS `ET_RU`,`comprobantes`.`com_nombre` AS `COMR`,`guias`.`serr` AS `SERR`,`guias`.`numr` AS `NUMR`,`guias`.`idr` AS `IDR`,`guias`.`oc_nro` AS `OC_NRO`,`guias`.`anu` AS `ANU`,`guias`.`iser` AS `ISER`,`guias`.`inum` AS `INUM`,`guias`.`gi` AS `GI`,`guias_det`.`cx` AS `CX`,`guias_det`.`ca` AS `KA`,`marcas`.`mar_nombre` AS `MAR`,`lineas`.`lin_nombre` AS `LIN`,`guias_det`.`can_uni` AS `PIEZAS`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES`,`empresas`.`emp_nomc` AS `EMPC` from (((((((`guias` join `almacenes` on(`guias`.`id_almacen` = `almacenes`.`id_almacen`)) join `comprobantes` on(`guias`.`id_comr` = `comprobantes`.`id_comprobante`)) join `guias_det` on(`guias`.`id_guia` = `guias_det`.`id_guia`)) join `productos` on(`guias_det`.`id_producto` = `productos`.`id_producto`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`)) join `lineas` on(`lineas`.`id_linea` = `productos`.`pro_id_linea`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vguias_fe` AS select `guias`.`id_guia` AS `ID`,`empresas`.`emp_fe_ruc` AS `EMP_RUC`,`empresas`.`emp_fe_nom_com` AS `EMP_RAZ_SOC`,`empresas`.`emp_fe_ubi` AS `EMP_DIR_UBI`,`empresas`.`emp_fe_dep` AS `EMP_DIR_DEP`,`empresas`.`emp_fe_prv` AS `EMP_DIR_PRO`,`empresas`.`emp_fe_dis` AS `EMP_DIR_DIS`,`empresas`.`emp_fe_dir` AS `EMP_DIR`,`empresas`.`emp_fe_ema` AS `EMP_EMA`,`gdr_motivos`.`mot_des` AS `MOT_DES`,`gdr_motivos`.`mot_cod` AS `MOT_COD`,`empresas`.`emp_nomc` AS `EMP_NC`,`guias`.`ser` AS `SER`,`guias`.`num` AS `NUM`,`guias`.`xx_ce_hash` AS `CE_HASH`,`guias`.`fe` AS `FEC_EMI`,`guias`.`xx_ce_gen` AS `GEN`,`guias`.`xx_id_tip_gia` AS `ID_TIP_GIA` from (((`guias` join `almacenes` on(`guias`.`id_almacen` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `gdr_motivos` on(`guias`.`xx_id_mot` = `gdr_motivos`.`id_mot`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vguias_fe_clientes` AS select `clientes`.`id_cliente` AS `ID_CLI`,`clientes`.`cli_ubi_pai` AS `DIR_PAI`,`clientes`.`cli_ubi_dep` AS `DIR_DEP`,`clientes`.`cli_ubi_pro` AS `DIR_PRO`,`clientes`.`cli_ubi_dis` AS `DIR_DIS`,`clientes`.`cli_ubi_cod` AS `DIR_UBI`,`clientes`.`cli_ruc` AS `RUC`,`clientes`.`cli_dni` AS `DNI`,`clientes`.`cli_dir` AS `DIR`,`clientes`.`cli_nombre` AS `CLI_NOM`,`clientes`.`cli_email` AS `CLI_EMA` from `clientes`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vingresos` AS select `ingresos`.`id_ingreso` AS `ID`,`ingresos`.`fec` AS `FEC`,date_format(`ingresos`.`fec`,'%d-%m-%y') AS `FEC_`,`ingresos`.`tot` AS `TOT`,`ingresos`.`obs` AS `OBS`,`ingresos_tipos`.`nombre` AS `TDI`,`almacenes`.`alm_obs` AS `ALM`,`empresas`.`emp_nomc` AS `EMPC`,`ingresos`.`usu` AS `USU_KOD`,`usuarios`.`nom` AS `USU_NOM`,`ingresos`.`anu` AS `ANU` from ((((`ingresos` join `ingresos_tipos` on(`ingresos`.`id_it` = `ingresos_tipos`.`id_it`)) join `almacenes` on(`ingresos`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `usuarios` on(`ingresos`.`usu` = `usuarios`.`id_usuario`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_ajustes_presentacion` AS select `ajustes_presentacion`.`id_ajuste` AS `ID`,`ajustes_presentacion`.`fec` AS `FEC`,`almacenes`.`alm_obs` AS `ALM`,`ajustes_presentacion`.`num` AS `NUM`,`ajustes_presentacion`.`acc` AS `ACC`,`ajustes_presentacion`.`obs` AS `OBS`,`ajustes_presentacion`.`anu` AS `ANU`,`ajustes_presentacion`.`id_usuario` AS `ID_USU`,`ajustes_presentacion`.`gi` AS `GI`,`empresas`.`emp_nomc` AS `EMPC` from ((`ajustes_presentacion` join `almacenes` on(`almacenes`.`id_almacen` = `ajustes_presentacion`.`id_alm`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_ajustes_presentacion_det` AS select `ajustes_presentacion_det`.`id_ajuste` AS `ID`,`ajustes_presentacion_det`.`item` AS `ITEM`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES`,`lineas`.`lin_nombre` AS `LIN`,`ajustes_presentacion_det`.`cajas` AS `CAJAS`,`ajustes_presentacion_det`.`piezas` AS `PIEZAS`,`ajustes_presentacion_det`.`piezas_ajuste` AS `PIEZAS_AJUSTE`,`vis_ajustes_presentacion`.`ALM` AS `ALM`,`vis_ajustes_presentacion`.`NUM` AS `NUM`,`vis_ajustes_presentacion`.`ACC` AS `ACC`,`vis_ajustes_presentacion`.`FEC` AS `FEC`,`vis_ajustes_presentacion`.`ANU` AS `ANU`,`vis_ajustes_presentacion`.`EMPC` AS `EMPC` from (((`ajustes_presentacion_det` join `productos` on(`productos`.`id_producto` = `ajustes_presentacion_det`.`id_producto`)) join `lineas` on(`lineas`.`id_linea` = `productos`.`pro_id_linea`)) join `vis_ajustes_presentacion` on(`vis_ajustes_presentacion`.`ID` = `ajustes_presentacion_det`.`id_ajuste`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_almacenes` AS select `almacenes`.`id_almacen` AS `IDA`,`almacenes`.`alm_nombre` AS `ANL`,`almacenes`.`alm_obs` AS `ANC`,`almacenes`.`alm_dir` AS `ADIR`,`almacenes`.`alm_id_empresa` AS `IDE`,`empresas`.`emp_noml` AS `ENL`,`empresas`.`emp_nomc` AS `ENC`,`empresas`.`emp_dir` AS `EDIR`,`almacenes`.`alm_fun` AS `FUN`,`almacenes`.`alm_tel` AS `TEL` from (`almacenes` join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_bi_clientes_2022` AS select `cotizaciones`.`id_cliente` AS `CLI_ID`,round(sum(`cotizaciones`.`tot_real`),2) AS `TOTAL` from `cotizaciones` where `cotizaciones`.`anu` = 'N' and year(`cotizaciones`.`fec`) >= 2022 group by `cotizaciones`.`id_cliente`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_bi_clientes_filtrados` AS select `vclientes`.`NOMBRE` AS `NOMBRE`,`vclientes`.`CONTACTO` AS `CONTACTO`,`vclientes`.`DIRECCION` AS `DIRECCION`,`vclientes`.`DISTRITO` AS `DISTRITO`,`vclientes`.`DNI` AS `DNI`,`vclientes`.`RUC` AS `RUC`,`vclientes`.`TEL` AS `TEL`,`vclientes`.`CEL` AS `CEL`,`vclientes`.`FAX` AS `FAX`,`vclientes`.`EMAIL` AS `EMAIL`,`vclientes`.`TIPO` AS `TIPO`,`vclientes`.`SUN_DOC_TIP` AS `SUN_DOC_TIP`,`vclientes`.`SUN_DOC_COD` AS `SUN_DOC_COD`,`vclientes`.`SUNAT_COD` AS `SUNAT_COD`,`vclientes`.`UBI_PAI` AS `UBI_PAI`,`vclientes`.`UBI_DEP` AS `UBI_DEP`,`vclientes`.`UBI_PRO` AS `UBI_PRO`,`vclientes`.`UBI_DIS` AS `UBI_DIS`,`vclientes`.`UBI_COD` AS `UBI_COD`,`vis_bi_clientes_2022`.`TOTAL` AS `TOTAL` from (`vis_bi_clientes_2022` join `vclientes` on(`vis_bi_clientes_2022`.`CLI_ID` = `vclientes`.`ID`)) order by `vis_bi_clientes_2022`.`TOTAL` desc;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_bitacora` AS select `bitacora`.`id_bit` AS `ID`,`bitacora`.`bit_id_usu` AS `USU_ID`,`bitacora`.`bit_fec` AS `FEC`,date_format(`bitacora`.`bit_fec`,'%d-%m-%y') AS `FEC_`,`bitacora`.`bit_hor` AS `HOR`,`bitacora`.`bit_ip` AS `IP`,`bitacora`.`bit_mnu` AS `MNU`,`bitacora`.`bit_mod` AS `MOD_PHP`,`bitacora`.`bit_acc` AS `ACC`,`bitacora`.`bit_mod_id` AS `MOD_ID`,`bitacora`.`bit_sql_cab` AS `SQL_CAB`,`bitacora`.`bit_sql_det` AS `SQL_DET`,`bitacora`.`bit_usu` AS `USU`,`bitacora`.`bit_ses_id` AS `SES_ID`,`bitacora`.`bit_php` AS `PHP` from `bitacora`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cobrox` AS select `cobrox`.`id_cx` AS `ID`,`cobrox`.`cx_num` AS `NUM`,`cobrox`.`cx_fec` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`cobrox`.`cx_cser` AS `CSER`,`cobrox`.`cx_cnum` AS `CNUM`,`cobrox`.`cx_tot_ven` AS `TOT_VEN`,`cobrox`.`cx_tot_acu` AS `TOT_ACU`,`cobrox`.`cx_tipo` AS `TIPO`,`cobrox`.`cx_id_dev` AS `DEV_ID`,`devoluciones`.`dev_nro` AS `DEV_NRO`,`cobrox`.`cx_dev_tot` AS `DEV_TOT`,`cobrox`.`cx_dev_sal` AS `DEV_SAL`,`cobrox`.`cx_total` AS `TOTAL`,`cobrox`.`cx_saldo` AS `SALDO`,`cobrox`.`cx_obs` AS `OBS`,`cobrox`.`cx_anu` AS `ANU`,`clientes`.`cli_nombre` AS `CLI`,`cobrox`.`cx_id_usuario` AS `ID_USU`,`cobrox`.`cx_gi` AS `GI`,`cobrox`.`cx_num_` AS `NUM_`,`cobrox`.`cx_iser` AS `ISER`,`cobrox`.`cx_inum` AS `INUM`,`cobrox`.`cx_fec_dev` AS `FEC_DEV`,`cobrox`.`cx_doc_ven` AS `DOC_VEN`,`cobrox`.`cx_doc_nro` AS `DOC_NRO`,`cobrox`.`cx_doc_fec` AS `DOC_FEC`,`empresas`.`emp_nomc` AS `EMPC`,`usuarios`.`nom` AS `USU`,`almacenes`.`alm_obs` AS `ALM_NC` from ((((((`cobrox` join `comprobantes` on(`cobrox`.`cx_id_com` = `comprobantes`.`id_comprobante`)) join `devoluciones` on(`cobrox`.`cx_id_dev` = `devoluciones`.`id_devolucion`)) join `clientes` on(`cobrox`.`cx_id_cliente` = `clientes`.`id_cliente`)) join `empresas` on(`cobrox`.`cx_id_empresa` = `empresas`.`id_emp`)) join `usuarios` on(`cobrox`.`cx_id_usuario` = `usuarios`.`id_usuario`)) join `almacenes` on(`cobrox`.`cx_id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cobroz_ventas` AS select `cobroz_ventas`.`id_cv` AS `id_cv`,`cobroz_ventas`.`cv_sys_fec` AS `cv_sys_fec`,`cobroz_ventas`.`cv_sys_hor` AS `cv_sys_hor`,`cobroz_ventas`.`cv_sys_tim` AS `cv_sys_tim`,`cobroz_ventas`.`cv_id_cob` AS `cv_id_cob`,`cobroz_ventas`.`cv_id_ven` AS `cv_id_ven`,`cobroz_ventas`.`cv_id_usu` AS `cv_id_usu`,`cobroz_ventas`.`cv_modo` AS `cv_modo`,`cobroz_ventas`.`cv_com` AS `cv_com`,`cobroz_ventas`.`cv_ser` AS `cv_ser`,`cobroz_ventas`.`cv_num` AS `cv_num` from `cobroz_ventas`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_compras_et` AS select `compras_det`.`id_producto` AS `IDP`,`compras_det`.`can_uni` AS `PIE`,`compras`.`et` AS `ET`,`compras`.`fec_lle` AS `FEC`,`compras_det`.`ca` AS `CAN`,`compras`.`ser` AS `SER`,`compras`.`numero` AS `NUM` from (`compras` join `compras_det` on(`compras`.`id_compra` = `compras_det`.`id_compra`)) where `compras`.`anulado` = 'N' and `compras`.`et` = 'SI';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_contratos` AS select `contratos`.`id_contrato` AS `ID`,`contratos`.`con_fecha` AS `FEC`,`contratos`.`con_numero` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`contratos`.`con_total` AS `TOT`,`contratos`.`con_adelanto` AS `ADE`,`contratos`.`con_acuenta` AS `ACU`,`contratos`.`con_saldo` AS `SAL`,`contratos`.`con_id_usario` AS `ID_USU`,`contratos`.`con_gi` AS `GI`,`contratos`.`con_usado` AS `USA`,`contratos`.`tip_tip_adelanto` AS `TIP_A`,`empresas`.`emp_nomc` AS `EMPC`,`contratos`.`con_id_empresa` AS `ID_EMP`,`usuarios`.`nom` AS `USU`,`almacenes`.`alm_obs` AS `ALM_NC` from ((((`contratos` join `clientes` on(`contratos`.`con_id_cliente` = `clientes`.`id_cliente`)) join `empresas` on(`contratos`.`con_id_empresa` = `empresas`.`id_emp`)) join `usuarios` on(`contratos`.`con_id_usario` = `usuarios`.`id_usuario`)) join `almacenes` on(`contratos`.`con_id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_contratos_ingresos` AS select `contratos_ingresos`.`id_con_ing` AS `ID`,`contratos`.`con_numero` AS `CON_NRO`,`contratos`.`con_total` AS `CON_TOT`,`contratos_ingresos`.`ci_fec` AS `FEC`,`contratos_ingresos`.`ci_numero` AS `NUM`,`contratos_ingresos`.`ci_total` AS `TOT`,`contratos_ingresos`.`ci_tipo` AS `TIP`,`contratos_ingresos`.`ci_acu` AS `ACU`,`contratos_ingresos`.`ci_saldo` AS `SAL`,`clientes`.`cli_nombre` AS `CLI`,`empresas`.`emp_nomc` AS `EMPC`,`usuarios`.`nom` AS `USU`,`almacenes`.`alm_obs` AS `ALM_NC` from (((((`contratos_ingresos` join `contratos` on(`contratos_ingresos`.`ci_id_contrato` = `contratos`.`id_contrato`)) join `clientes` on(`contratos`.`con_id_cliente` = `clientes`.`id_cliente`)) join `empresas` on(`contratos`.`con_id_empresa` = `empresas`.`id_emp`)) join `usuarios` on(`contratos_ingresos`.`ci_id_usuario` = `usuarios`.`id_usuario`)) join `almacenes` on(`contratos_ingresos`.`ci_id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cot_cobroz` AS select `cobroz`.`id_cobro` AS `ID`,`cobroz`.`cob_num` AS `COD`,date_format(`cobroz`.`cob_fec`,'%d-%m-%y') AS `FEC_`,`cobroz`.`cob_id_com` AS `ID_COM`,`cobroz`.`cob_cser` AS `COT_SER`,`cobroz`.`cob_cnum` AS `COT_NUM`,`cobroz`.`cob_icser` AS `COT_ISER`,`cobroz`.`cob_icnum` AS `COT_INUM`,`cobroz`.`cob_anu` AS `ANU`,`cobroz`.`cob_tot` AS `TOT`,`cobroz`.`cob_id_tdp` AS `TDP`,`bancos`.`ban_nombre` AS `CTA_BAN`,`cuentas`.`cta_nro` AS `CTA_NRO`,`cobroz`.`cob_ope_nro` AS `OPE_NRO`,date_format(`cobroz`.`cob_ope_fec`,'%d-%m-%y') AS `OPE_FEC_` from ((`cobroz` join `cuentas` on(`cobroz`.`cob_id_cta` = `cuentas`.`id_cta`)) join `bancos` on(`cuentas`.`cta_id_ban` = `bancos`.`id_banco`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cot_devoluciones` AS select `devoluciones`.`id_devolucion` AS `ID`,`devoluciones`.`dev_nro` AS `NRO`,`devoluciones`.`dev_fec` AS `FEC`,date_format(`devoluciones`.`dev_fec`,'%d-%m-%y') AS `FEC_`,`devoluciones`.`dev_id_comprobante` AS `ID_COM`,`devoluciones`.`dev_ser` AS `COT_SER`,`devoluciones`.`dev_num` AS `COT_NUM`,`devoluciones`.`dev_anu` AS `ANU`,`devoluciones`.`dev_ser_` AS `COT_ISER`,`devoluciones`.`dev_num_` AS `COT_INUM`,`devoluciones`.`dev_total` AS `TOT`,`devoluciones`.`dev_tipo` AS `TIP`,`devoluciones`.`dev_dinero` AS `DEV_DINERO`,`devoluciones`.`dev_recibo` AS `RECIBO` from `devoluciones`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cot_edc` AS select `cotizaciones`.`id_cotizacion` AS `ID`,`almacenes`.`alm_nombre` AS `ALM`,`cotizaciones`.`fec` AS `FEC`,`cotizaciones`.`ser` AS `SER`,`cotizaciones`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`cotizaciones`.`tcam` AS `TCAM`,`cotizaciones`.`inc_igv` AS `IIG`,`cotizaciones`.`tot` AS `TOT`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM`,`cotizaciones`.`id_usuario` AS `IDU`,`cotizaciones`.`mon` AS `MON`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones`.`gi` AS `GI`,`cotizaciones`.`nped` AS `NPED`,`cotizaciones`.`contacto` AS `CONT`,`cotizaciones`.`id_cliente` AS `IDCLI`,`personal`.`per_nombre` AS `VEN`,`cotizaciones`.`acu` AS `ACU`,`monedas`.`mon_nombre` AS `MND`,`cotizaciones`.`vue` AS `VUE`,`cotizaciones`.`sal` AS `SAL`,`cotizaciones`.`modalidad` AS `MODAL`,`cotizaciones`.`cot_pri` AS `PRI_`,`cotizaciones`.`cot_des` AS `DES_`,concat(`cotizaciones`.`ser`,'-',`cotizaciones`.`num`) AS `SER_NUM`,`cotizaciones`.`tot_real` AS `TOT_REAL`,`cotizaciones`.`tot_des` AS `TOT_DES`,`cotizaciones`.`tot_cob` AS `TOT_COB`,`cotizaciones`.`tot_real` - `cotizaciones`.`tot_cob` AS `SALDO`,`empresas`.`emp_nomc` AS `EMPC`,`clientes`.`cli_dni` AS `DNI`,`clientes`.`cli_ruc` AS `RUC` from (((((`cotizaciones` join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `clientes` on(`cotizaciones`.`id_cliente` = `clientes`.`id_cliente`)) join `personal` on(`cotizaciones`.`id_vendedor` = `personal`.`id_personal`)) join `monedas` on(`cotizaciones`.`id_moneda` = `monedas`.`id_moneda`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cot_edc_fec_ven` AS select `cotizaciones`.`id_cotizacion` AS `ID`,`almacenes`.`alm_nombre` AS `ALM`,`cotizaciones`.`fec` AS `FEC`,`cotizaciones`.`ser` AS `SER`,`cotizaciones`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`cotizaciones`.`tcam` AS `TCAM`,`cotizaciones`.`inc_igv` AS `IIG`,`cotizaciones`.`tot` AS `TOT`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM`,`cotizaciones`.`id_usuario` AS `IDU`,`cotizaciones`.`mon` AS `MON`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones`.`gi` AS `GI`,`cotizaciones`.`nped` AS `NPED`,`cotizaciones`.`contacto` AS `CONT`,`cotizaciones`.`id_cliente` AS `IDCLI`,`personal`.`per_nombre` AS `VEN`,`cotizaciones`.`acu` AS `ACU`,`monedas`.`mon_nombre` AS `MND`,`cotizaciones`.`vue` AS `VUE`,`cotizaciones`.`sal` AS `SAL`,`cotizaciones`.`modalidad` AS `MODAL`,`cotizaciones`.`cot_pri` AS `PRI_`,`cotizaciones`.`cot_des` AS `DES_`,concat(`cotizaciones`.`ser`,'-',`cotizaciones`.`num`) AS `SER_NUM`,`cotizaciones`.`tot_real` AS `TOT_REAL`,`cotizaciones`.`tot_des` AS `TOT_DES`,`cotizaciones`.`tot_cob` AS `TOT_COB`,`cotizaciones`.`tot_real` - `cotizaciones`.`tot_cob` AS `SALDO`,`empresas`.`emp_nomc` AS `EMPC`,`clientes`.`cli_dni` AS `DNI`,`clientes`.`cli_ruc` AS `RUC`,`cotizaciones`.`fv_id` AS `FV_ID`,`cotizaciones`.`fv_cob` AS `FV_COB`,date_format(`cotizaciones`.`fv_cob`,'%d-%m-%y') AS `FV_COB_`,`cotizaciones`.`fv_sal` AS `FV_SAL`,date_format(`cotizaciones`.`fv_sal`,'%d-%m-y') AS `FV_SAL_`,`cotizaciones`.`fv_can_pen` AS `CAN_PEN` from (((((`cotizaciones` join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `clientes` on(`cotizaciones`.`id_cliente` = `clientes`.`id_cliente`)) join `personal` on(`cotizaciones`.`id_vendedor` = `personal`.`id_personal`)) join `monedas` on(`cotizaciones`.`id_moneda` = `monedas`.`id_moneda`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cot_notas` AS select `fe_ventaz`.`id_ven` AS `ID`,`empresas`.`emp_nomc` AS `EMP_NC`,`comprobantes`.`com_nombre` AS `COM`,`fe_ventaz`.`fv_ser` AS `COM_SER`,`fe_ventaz`.`fv_num` AS `COM_NUM`,`com_ventas`.`com_nombre` AS `REF_COM`,`fe_ventaz`.`fv_r_ser` AS `REF_SER`,`fe_ventaz`.`fv_r_num` AS `REF_NUM`,`fe_ventaz`.`fv_r_id_ven` AS `REF_VEN_ID`,`fe_ventaz`.`fv_anu` AS `ANU`,`fe_ventaz`.`fv_st` AS `ST`,`fe_ventaz`.`fv_igv` AS `IGV`,`fe_ventaz`.`fv_tot` AS `TOT`,`fe_ventaz`.`fv_fec` AS `FEC`,date_format(`fe_ventaz`.`fv_fec`,'%d-%m-%y') AS `FEC_`,`fe_ventaz`.`fv_cli` AS `CLI` from (((`fe_ventaz` join `comprobantes` on(`fe_ventaz`.`fv_id_com` = `comprobantes`.`id_comprobante`)) join `comprobantes` `com_ventas` on(`fe_ventaz`.`fv_r_id_com` = `com_ventas`.`id_comprobante`)) join `empresas` on(`fe_ventaz`.`fv_id_emp` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cot_ven_cob` AS select `ventas`.`id_venta` AS `ID`,`empresas`.`emp_nomc` AS `EMP_NC`,`almacenes`.`alm_obs` AS `ALM_NC`,`comprobantes`.`com_nombre` AS `COM`,`ventas`.`ser` AS `SER`,`ventas`.`num` AS `NUM`,`ventas`.`fec` AS `FEC`,date_format(`ventas`.`fec`,'%d-%m-%y') AS `FEC_`,`clientes`.`cli_nombre` AS `CLI`,`ventas`.`st` AS `ST`,`ventas`.`igv` AS `IGV`,`ventas`.`tot` AS `TOT`,`ventas`.`anu` AS `ANU`,`REF_COM`.`com_nombre` AS `REF_COM`,`ventas`.`ven_id_ven` AS `REF_KOD`,`ventas`.`ven_fe_ge` AS `FE_GE`,`ventas`.`ven_cob_pag` AS `PAGADO`,`ventas`.`ven_cob_kod` AS `COB_KOD`,`ventas`.`ven_cob_modo` AS `MODO` from (((((`ventas` join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) join `comprobantes` `REF_COM` on(`ventas`.`ven_id_com` = `REF_COM`.`id_comprobante`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cot_ven_relacionadas` AS select `ventas`.`id_venta` AS `ID`,`comprobantes`.`com_nombre` AS `COM`,`ventas`.`ser` AS `SER`,`ventas`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`ventas`.`fec` AS `FEC`,date_format(`ventas`.`fec`,'%d-%m-%y') AS `FEC_`,`ventas`.`tot` AS `TOT`,`ventas`.`anu` AS `ANU`,`ventas`.`iser` AS `ISER`,`ventas`.`inum` AS `INUM`,`ventas`.`ven_id_com` AS `REF_ID_COM`,`ventas`.`ven_id_ven` AS `REF_ID`,`ventas`.`gi` AS `GI`,`ventas`.`ven_cob_pag` AS `PAGADO`,`empresas`.`emp_nomc` AS `EMP_NC` from ((((`ventas` join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cotizaciones` AS select `cotizaciones`.`id_cotizacion` AS `ID`,`almacenes`.`alm_id_empresa` AS `EMP_ID`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM` from (`cotizaciones` join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cotizaciones_det` AS select `cotizaciones_det`.`id_cotizacion` AS `COT_ID`,`cotizaciones_det`.`cx` AS `CX`,`cotizaciones_det`.`ca` AS `CAN`,`cotizaciones_det`.`can_uni` AS `CAN_UNI`,`cotizaciones_det`.`pr` AS `PRE`,`cotizaciones_det`.`im` AS `IMP`,`productos`.`pro_des` AS `DES`,`productos`.`pro_codigo` AS `COD` from (`cotizaciones_det` join `productos` on(`cotizaciones_det`.`id_producto` = `productos`.`id_producto`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cuentas` AS select `cuentas`.`id_cta` AS `ID`,`cuentas`.`cta_sys_fec` AS `SYS_FEC`,date_format(`cuentas`.`cta_sys_fec`,'%d-%m-%y') AS `SYS_FEC_`,`bancos`.`ban_nombre` AS `BAN`,`cuentas`.`cta_tipo` AS `TIP`,`cuentas`.`cta_nro` AS `NRO`,`cuentas`.`cta_mnd` AS `MND`,`cuentas`.`cta_cci` AS `CCI`,`cuentas`.`cta_tit` AS `TIT`,`cuentas`.`cta_hab` AS `HAB`,`cuentas`.`cta_obs` AS `OBS`,`usuarios`.`nom` AS `USU` from ((`cuentas` join `bancos` on(`cuentas`.`cta_id_ban` = `bancos`.`id_banco`)) join `usuarios` on(`cuentas`.`cta_id_usu` = `usuarios`.`id_usuario`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_cuentas_emp` AS select `cuentas`.`id_cta` AS `ID_CTA`,`cuentas_emp`.`id_emp` AS `EMP_ID`,`bancos`.`ban_nombre` AS `BAN`,`cuentas`.`cta_tipo` AS `TIP`,`cuentas`.`cta_nro` AS `NRO`,`cuentas`.`cta_mnd` AS `MND`,`cuentas`.`cta_cci` AS `CCI`,`cuentas`.`cta_hab` AS `HAB`,`empresas`.`emp_nomc` AS `EMP`,concat(trim(`empresas`.`emp_nomc`),' * ',trim(`bancos`.`ban_nombre`),' ',trim(`cuentas`.`cta_nro`),' ',`cuentas`.`cta_mnd`) AS `MI_CUENTA` from (((`cuentas_emp` join `cuentas` on(`cuentas_emp`.`id_cta` = `cuentas`.`id_cta`)) join `bancos` on(`cuentas`.`cta_id_ban` = `bancos`.`id_banco`)) join `empresas` on(`cuentas_emp`.`id_emp` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_depurador_cot` AS select `empresas`.`emp_nomc` AS `EMP`,`almacenes`.`alm_obs` AS `ALM`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM`,`cotizaciones`.`anu` AS `ANU` from ((`cotizaciones` join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_devoluciones_det` AS select `devoluciones_det`.`dd_id_devolucion` AS `ID`,`devoluciones_det`.`dd_cx` AS `ITEM`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES`,`lineas`.`lin_nombre` AS `LIN`,`devoluciones_det`.`dd_cant` AS `CAN`,`devoluciones_det`.`dd_pie` AS `PIE`,`devoluciones_det`.`dd_pre` AS `PRE`,`devoluciones_det`.`dd_imp` AS `IMP` from ((`devoluciones_det` join `productos` on(`productos`.`id_producto` = `devoluciones_det`.`dd_id_producto`)) join `lineas` on(`lineas`.`id_linea` = `productos`.`pro_id_linea`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_edc22` AS select `edc22`.`cx` AS `CX`,`edc22`.`usu` AS `USU`,`edc22`.`hw` AS `HW`,`edc22`.`php` AS `PHP`,`edc22`.`php_id` AS `PHP_ID`,`edc22`.`fec` AS `FEC`,date_format(`edc22`.`fec`,'%d-%m-%y') AS `FEC_`,`edc22`.`gi` AS `GI`,`edc22`.`doc_tip` AS `DOC_TIP`,`edc22`.`doc_num` AS `DOC_NUM`,`edc22`.`doc_tdp` AS `DOC_TDP`,`edc22`.`doc_obs` AS `DOC_OBS`,`edc22`.`tot` AS `TOT`,`edc22`.`deb` AS `DEB`,`edc22`.`hab` AS `HAB`,`edc22`.`sal` AS `SAL` from `edc22`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_fe_ventaz` AS select `fe_ventaz`.`id_ven` AS `ID`,`empresas`.`emp_nomc` AS `EMP_NC`,`almacenes`.`alm_obs` AS `ALM_NC`,`comprobantes`.`com_nombre` AS `COM`,`fe_ventaz`.`fv_ser` AS `SER`,`fe_ventaz`.`fv_num` AS `NUM`,`fe_ventaz`.`fv_ser_` AS `SER_`,`fe_ventaz`.`fv_num_` AS `NUM_`,`fe_ventaz`.`fv_fec` AS `FEC`,date_format(`fe_ventaz`.`fv_fec`,'%d-%m-%y') AS `FEC_`,date_format(`fe_ventaz`.`fv_fec`,'%d/%m/%Y') AS `NC_FEC`,`com_m`.`com_nombre` AS `COM_M`,`fe_ventaz`.`fv_r_ser` AS `SER_M`,`fe_ventaz`.`fv_r_ser_` AS `SER_M_`,`fe_ventaz`.`fv_r_num` AS `NUM_M`,`fe_ventaz`.`fv_r_num_` AS `NUM_M_`,`fe_ventaz`.`fv_r_id_ven` AS `ID_VEN_M`,`fe_ventaz`.`fv_ndi` AS `NDI`,`fe_ventaz`.`fv_cli` AS `CLI`,`fe_ventaz`.`fv_dir` AS `DIR`,`fe_ventaz`.`fv_ema` AS `EMA`,`fe_ventaz`.`fv_anu` AS `ANU`,`fe_ventaz`.`fv_gen` AS `GEN`,`fe_ventaz`.`fv_id_usu` AS `ID_USU`,`fe_ventaz`.`fv_st` AS `ST`,`fe_ventaz`.`fv_igv` AS `IGV`,`fe_ventaz`.`fv_tot` AS `TOT`,`fe_catalogos`.`cod` AS `CAT_COD`,`fe_catalogos`.`cod` AS `CAT_TIP`,`fe_catalogos`.`des` AS `CAT_DES`,`fe_catalogos`.`tab` AS `TAB_X`,`empresas`.`emp_fe_nom_com` AS `EMP_FE_NOM`,`empresas`.`emp_fe_ruc` AS `EMP_FE_RUC`,`empresas`.`emp_fe_dep` AS `EMP_FE_DEP`,`empresas`.`emp_fe_prv` AS `EMP_FE_PRV`,`empresas`.`emp_fe_dis` AS `EMP_FE_DIS`,`empresas`.`emp_fe_ubi` AS `EMP_FE_UBI`,`empresas`.`emp_fe_dir` AS `EMP_FE_DIR`,`empresas`.`emp_fe_ema` AS `EMP_FE_EMA`,`clientes`.`cli_nombre` AS `CLI_NOM`,`clientes`.`cli_dir` AS `CLI_DIR`,`clientes`.`cli_dni` AS `CLI_DNI`,`clientes`.`cli_ruc` AS `CLI_RUC`,`clientes`.`cli_email` AS `CLI_EMAIL`,`clientes`.`cli_ubi_pai` AS `CLI_PAI`,`clientes`.`cli_ubi_dep` AS `CLI_DEP`,`clientes`.`cli_ubi_pro` AS `CLI_PRV`,`clientes`.`cli_ubi_dis` AS `CLI_DIS`,`clientes`.`cli_ubi_cod` AS `CLI_UBI`,`fe_ventaz`.`fv_id_cli` AS `ID_CLI`,`fe_ventaz`.`fv_hash` AS `FE_HASH`,`fe_ventaz`.`dat_ubi_pai` AS `NDC_UBI_PAI`,`fe_ventaz`.`dat_ubi_dep` AS `NDC_UBI_DEP`,`fe_ventaz`.`dat_ubi_pro` AS `NDC_UBI_PRO`,`fe_ventaz`.`dat_ubi_dis` AS `NDC_UBI_DIS`,`fe_ventaz`.`dat_ubi_cod` AS `NDC_UBI_COD` from ((((((`fe_ventaz` join `almacenes` on(`fe_ventaz`.`fv_id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `comprobantes` on(`fe_ventaz`.`fv_id_com` = `comprobantes`.`id_comprobante`)) join `comprobantes` `com_m` on(`fe_ventaz`.`fv_r_id_com` = `com_m`.`id_comprobante`)) join `fe_catalogos` on(`fe_ventaz`.`fe_id_tip` = `fe_catalogos`.`id`)) join `clientes` on(`fe_ventaz`.`fv_id_cli` = `clientes`.`id_cliente`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_fe_ventaz_ex` AS select `fe_ventaz`.`id_ven` AS `ID`,`fe_ventaz`.`fv_fec` AS `FEC`,`fe_ventaz`.`fv_anu` AS `ANU`,`fe_ventaz`.`fv_gen` AS `GEN`,`fe_ventaz`.`fv_tot` AS `TOT`,`fe_ventaz`.`fv_id_emp` AS `EMP_ID`,`fe_ventaz`.`fv_id_com` AS `COM_ID` from `fe_ventaz`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_fechas_plazos` AS select `fechas_plazos`.`id_fp` AS `ID`,`fechas_plazos`.`fp_sys_fec` AS `SYS_FEC`,`fechas_plazos`.`fp_sys_hor` AS `SYS_HOR`,`fechas_plazos`.`fp_sys_tim` AS `SYS_TIM`,`fechas_plazos`.`fp_fer` AS `FER`,date_format(`fechas_plazos`.`fp_fer`,'%d-%m-%y') AS `FER_`,`fechas_plazos`.`fp_fin` AS `FIN`,date_format(`fechas_plazos`.`fp_fin`,'%d-%m-%y') AS `FIN_`,`fechas_plazos`.`fp_cob` AS `COB`,`fechas_plazos`.`fp_sal` AS `SAL`,`fechas_plazos`.`fp_obs` AS `OBS`,`fechas_plazos`.`fp_usu` AS `USU` from `fechas_plazos`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_fes_empresas` AS select `almacenes`.`id_almacen` AS `ID_ALM`,`empresas`.`emp_noml` AS `EMP_NL`,`empresas`.`emp_nomc` AS `EMP_NC`,`empresas`.`emp_fe_ruc` AS `EMP_RUC` from (`almacenes` join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_fes_ndc` AS select `fe_ventaz`.`id_ven` AS `ID`,`fe_ventaz`.`fv_id_emp` AS `ID_EMP`,`fe_ventaz`.`fv_id_com` AS `ID_COM`,`fe_ventaz`.`fv_ser` AS `NDC_SER`,`fe_ventaz`.`fv_num` AS `NDC_NUM`,`fe_ventaz`.`fv_ser_` AS `NDC_SER_`,`fe_ventaz`.`fv_num_` AS `NDC_NUM_`,`fe_ventaz`.`fv_fec` AS `NDC_FEC`,date_format(`fe_ventaz`.`fv_fec`,'%d-%m-%Y') AS `NDC_FEC_`,`fe_ventaz`.`fv_id_cli` AS `NDC_CLI_ID`,`fe_ventaz`.`fv_cli` AS `NDC_CLI_NOM`,`fe_ventaz`.`fv_ndi` AS `NDC_CLI_NDI`,`fe_ventaz`.`fv_dir` AS `NDC_CLI_DIR`,`clientes`.`cli_nombre` AS `CLI_NOM`,`sunat_catalogos`.`des` AS `CLI_TDI`,`sunat_catalogos`.`sunat_cod` AS `CLI_TDI_SUNAT_COD`,`clientes`.`cli_dni` AS `CLI_DNI`,`clientes`.`cli_ruc` AS `CLI_RUC`,`comprobantes`.`com_nombre` AS `REF_COM`,`fe_ventaz`.`fv_r_id_com` AS `REF_COM_ID`,`fe_ventaz`.`fv_r_ser` AS `REF_SER`,`fe_ventaz`.`fv_r_ser_` AS `REF_SER_`,`fe_ventaz`.`fv_r_num` AS `REF_NUM`,`fe_ventaz`.`fv_r_num_` AS `REF_NUM_`,`fe_ventaz`.`fv_st` AS `SUB`,`fe_ventaz`.`fv_igv` AS `IGV`,`fe_ventaz`.`fv_tot` AS `TOT`,`fe_catalogos`.`des` AS `MOT_DES`,`fe_catalogos`.`cod` AS `MOT_COD`,`fe_ventaz`.`respuesta_sunat_zip` AS `R_SUN_ZIP`,`empresas`.`emp_noml` AS `EMP_NOM`,`empresas`.`emp_fe_nom_com` AS `EMP_NOM_COM`,`empresas`.`emp_fe_ruc` AS `EMP_RUC`,`empresas`.`emp_fe_dep` AS `EMP_DIR_DEP`,`empresas`.`emp_fe_prv` AS `EMP_DIR_PRO`,`empresas`.`emp_fe_dis` AS `EMP_DIR_DIS`,`empresas`.`emp_fe_dir` AS `EMP_DIR`,`fe_ventaz`.`dat_ubi_pai` AS `NDC_UBI_API`,`fe_ventaz`.`dat_ubi_dep` AS `NDC_UBI_DEP`,`fe_ventaz`.`dat_ubi_pro` AS `NDC_UBI_PRO`,`fe_ventaz`.`dat_ubi_dis` AS `NDC_UBI_DIS`,`fe_ventaz`.`dat_ubi_cod` AS `NDC_UBI_COD` from (((((`fe_ventaz` join `clientes` on(`fe_ventaz`.`fv_id_cli` = `clientes`.`id_cliente`)) join `sunat_catalogos` on(`clientes`.`cli_id_tip_doc` = `sunat_catalogos`.`id`)) join `comprobantes` on(`fe_ventaz`.`fv_r_id_com` = `comprobantes`.`id_comprobante`)) join `fe_catalogos` on(`fe_ventaz`.`fe_id_tip` = `fe_catalogos`.`id`)) join `empresas` on(`fe_ventaz`.`fv_id_emp` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_fes_ventas` AS select `ventas`.`id_venta` AS `ID`,`ventas`.`respuesta_sunat_zip` AS `R_SUN_ZIP`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`ventas`.`id_com` AS `ID_COM`,`ventas`.`anu` AS `ANU`,`ventas`.`id_cliente` AS `ID_CLI`,`ventas`.`st` AS `SUB`,`ventas`.`igv` AS `IGV`,`ventas`.`tot` AS `TOT`,`ventas`.`fec` AS `FEC`,date_format(`ventas`.`fec`,'%d-%m-%Y') AS `FEC_`,`comprobantes`.`com_nombre` AS `COM`,`ventas`.`ser` AS `SER`,`ventas`.`num` AS `NUM`,`ventas`.`iser` AS `ISER`,`ventas`.`inum` AS `INUM`,`clientes`.`cli_nombre` AS `CLI_NOM`,`clientes`.`cli_dir` AS `CLI_DIR`,`sunat_catalogos`.`des` AS `CLI_TDI`,`clientes`.`cli_dni` AS `CLI_DNI`,`clientes`.`cli_ruc` AS `CLI_RUC`,`empresas`.`emp_noml` AS `EMP_NOM`,`empresas`.`emp_fe_nom_com` AS `EMP_NOM_COM`,`empresas`.`emp_fe_dep` AS `EMP_DIR_DEP`,`empresas`.`emp_fe_prv` AS `EMP_DIR_PRO`,`empresas`.`emp_fe_dis` AS `EMP_DIR_DIS`,`empresas`.`emp_fe_ruc` AS `EMP_RUC`,`empresas`.`emp_fe_dir` AS `EMP_DIR` from (((((`ventas` join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) join `sunat_catalogos` on(`clientes`.`cli_id_tip_doc` = `sunat_catalogos`.`id`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_fes_ventas_det` AS select `ventas_det`.`id_venta` AS `ID_VEN`,`ventas_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES`,`ventas_det`.`ca` AS `CAN`,`ventas_det`.`pr` AS `PRE`,`ventas_det`.`im` AS `IMP`,`ventas_det`.`can_uni` AS `PIE` from (`ventas_det` join `productos` on(`ventas_det`.`id_producto` = `productos`.`id_producto`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_ginterna` AS select `ginterna`.`id_gi` AS `ID`,`almacenes`.`alm_id_empresa` AS `EMP_ID`,`ginterna`.`gi_inum` AS `INUM`,`ginterna`.`gi_fec` AS `FEC`,`ginterna`.`gi_iserie` AS `ISER` from (`ginterna` join `almacenes` on(`ginterna`.`gi_id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_guias_aux` AS select `guias`.`id_guia` AS `ID`,`almacenes`.`alm_id_empresa` AS `EMP_KOD`,`guias`.`id_comr` AS `VEN_COM_KOD`,`guias`.`i_serr` AS `VEN_ISER`,`guias`.`i_numr` AS `VEN_INUM`,`guias`.`anu` AS `ANU` from (`guias` join `almacenes` on(`guias`.`id_almacen` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_notas_rpt` AS select `fe_ventaz`.`id_ven` AS `ID`,`empresas`.`emp_nomc` AS `EMP`,`comprobantes`.`com_nombre` AS `COM`,`fe_ventaz`.`fv_ser` AS `SER`,`fe_ventaz`.`fv_num` AS `NUM`,`fe_ventaz`.`fv_fec` AS `FEC`,date_format(`fe_ventaz`.`fv_fec`,'%d-%m-%y') AS `FEC_`,`fe_ventaz`.`fv_ndi` AS `CLI_NDI`,`fe_ventaz`.`fv_cli` AS `CLI_NOM`,`fe_ventaz`.`fv_st` AS `SUB_TOT`,`fe_ventaz`.`fv_igv` AS `IGV`,`fe_ventaz`.`fv_tot` AS `TOT`,`fe_ventaz`.`fv_anu` AS `ANU`,`fe_ventaz`.`fv_gen` AS `GEN`,`komprobantes`.`com_nombre` AS `REF_COM`,`fe_ventaz`.`fv_r_ser` AS `REF_SER`,`fe_ventaz`.`fv_r_num` AS `REF_NUM` from (((`fe_ventaz` join `empresas` on(`fe_ventaz`.`fv_id_emp` = `empresas`.`id_emp`)) join `comprobantes` on(`fe_ventaz`.`fv_id_com` = `comprobantes`.`id_comprobante`)) join `comprobantes` `komprobantes` on(`fe_ventaz`.`fv_r_id_com` = `komprobantes`.`id_comprobante`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_parse_cotizaciones` AS select `cotizaciones`.`id_cotizacion` AS `id_cotizacion`,`cotizaciones`.`fec` AS `fec`,`cotizaciones_det`.`id_producto` AS `id_producto`,`cotizaciones_det`.`ca` AS `ca`,`cotizaciones_det`.`cod` AS `cod`,`cotizaciones_det`.`des` AS `des`,`cotizaciones_det`.`ca_control` AS `ca_control`,`cotizaciones_det`.`can_uni` AS `can_uni`,`cotizaciones`.`cot_pri` AS `cot_pri` from (`cotizaciones` join `cotizaciones_det` on(`cotizaciones`.`id_cotizacion` = `cotizaciones_det`.`id_cotizacion`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_parse_guias` AS select `guias`.`idr` AS `ID_COT`,`guias_det`.`id_producto` AS `ID_PRO`,`guias_det`.`ca` AS `CAN`,`guias_det`.`can_uni` AS `PIE`,`guias`.`anu` AS `ANU`,`guias`.`id_guia` AS `ID_GUIA` from (`guias_det` join `guias` on(`guias_det`.`id_guia` = `guias`.`id_guia`)) where `guias`.`id_comr` = -3;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_parse_guias_internas` AS select `ginterna`.`gi_id_cotizacion` AS `ID_COT`,`ginterna_det`.`id_producto` AS `ID_PRO`,`ginterna_det`.`ca` AS `CAN`,`ginterna_det`.`can_uni` AS `PIE`,`ginterna`.`gi_anu` AS `ANU` from (`ginterna_det` join `ginterna` on(`ginterna_det`.`id_gi` = `ginterna`.`id_gi`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_prod_pre` AS select `stocks_presentaciones`.`sp_id_producto` AS `ID_PRO`,`productos`.`pro_codigo` AS `COD`,`stocks_presentaciones`.`sp_presentacion` AS `PIE` from (`stocks_presentaciones` join `productos` on(`stocks_presentaciones`.`sp_id_producto` = `productos`.`id_producto`)) group by `stocks_presentaciones`.`sp_id_producto`,`productos`.`pro_codigo`,`stocks_presentaciones`.`sp_presentacion`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_sp` AS select `stocks_presentaciones`.`sp_id_producto` AS `ID_PRO`,`stocks_presentaciones`.`sp_presentacion` AS `PIE`,sum(`stocks_presentaciones`.`sp_cantidad`) AS `STOCK`,`stocks_presentaciones`.`sp_provicional` AS `PROVICIONAL`,`almacenes`.`alm_id_empresa` AS `ID_EMP` from (`stocks_presentaciones` join `almacenes` on(`stocks_presentaciones`.`sp_id_almacen` = `almacenes`.`id_almacen`)) group by `stocks_presentaciones`.`sp_id_producto`,`stocks_presentaciones`.`sp_presentacion`,`stocks_presentaciones`.`sp_provicional`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_stock_pre_par` AS select `productos`.`pro_codigo` AS `COD`,`stocks_pre_par`.`id_pre` AS `PIE`,`stocks_pre_par`.`sto_o` AS `STO_O`,`stocks_pre_par`.`sto_c` AS `STO_C`,`stocks_pre_par`.`sto_d` AS `STO_D`,`stocks_pre_par`.`prov` AS `PRV`,`almacenes`.`alm_obs` AS `alm_obs`,`empresas`.`emp_nomc` AS `emp_nomc` from (((`stocks_pre_par` join `productos` on(`stocks_pre_par`.`id_pro` = `productos`.`id_producto`)) join `almacenes` on(`stocks_pre_par`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_stock_presentaciones` AS select `productos`.`id_producto` AS `ID`,`productos`.`pro_codigo` AS `COD`,`lineas`.`lin_nombre` AS `LINEA`,`productos`.`pro_des` AS `DESCRIPCION`,`marcas`.`mar_nombre` AS `MARCA`,`productos`.`pro_pc_sol` AS `PC_SOL`,`productos`.`pro_pv_min` AS `PV_MIN`,`productos`.`pro_pv_max` AS `PV_MAX`,`almacenes`.`alm_nombre` AS `ALM`,`stocks_presentaciones`.`sp_cantidad` AS `C_CAJA`,`stocks_presentaciones`.`sp_presentacion` AS `C_UNI`,if(`productos`.`pro_uso` = 'S','SI','NO') AS `USO`,`stocks_presentaciones`.`sp_provicional` AS `PROVICIONAL`,`empresas`.`emp_nomc` AS `EMPC`,`almacenes`.`alm_obs` AS `ALMC` from (((((`productos` join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `almacenes`) join `stocks_presentaciones` on(`stocks_presentaciones`.`sp_id_producto` = `productos`.`id_producto` and `almacenes`.`id_almacen` = `stocks_presentaciones`.`sp_id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_stock_presentacionez` AS select `productos`.`id_producto` AS `ID`,`productos`.`pro_codigo` AS `COD`,`lineas`.`lin_nombre` AS `LINEA`,`productos`.`pro_des` AS `DESCRIPCION`,`marcas`.`mar_nombre` AS `MARCA`,`productos`.`pro_pc_sol` AS `PC_SOL`,`productos`.`pro_pv_min` AS `PV_MIN`,`productos`.`pro_pv_max` AS `PV_MAX`,`almacenes`.`alm_nombre` AS `ALM`,`stocks_presentaciones`.`sp_cantidad` AS `C_CAJA`,`stocks_presentaciones`.`sp_presentacion` AS `C_UNI`,if(`productos`.`pro_uso` = 'S','SI','NO') AS `USO`,`stocks_presentaciones`.`sp_provicional` AS `PROVICIONAL`,`empresas`.`emp_nomc` AS `EMPC`,`almacenes`.`alm_obs` AS `ALMC`,`stocks_presentaciones`.`sp_id_almacen` AS `ALM_ID` from (((((`productos` join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `almacenes`) join `stocks_presentaciones` on(`stocks_presentaciones`.`sp_id_producto` = `productos`.`id_producto` and `almacenes`.`id_almacen` = `stocks_presentaciones`.`sp_id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_transferencias` AS select `transferencias`.`id_trans` AS `ID`,`transferencias`.`fec` AS `FEC`,`transferencias`.`id_alm_o` AS `ID_ALM_O`,`almacenes`.`alm_id_empresa` AS `EMP_ID` from (`transferencias` join `almacenes` on(`transferencias`.`id_alm_o` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_transformaciones` AS select `transformaciones`.`id_transformacion` AS `ID`,`transformaciones`.`fecha` AS `FEC`,`almacenes`.`alm_obs` AS `ALM`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES_PRO`,`transformaciones`.`cant` AS `CAN`,`transformaciones`.`de_caja` AS `D_CAJA`,`transformaciones`.`de_uxc` AS `D_U_X_CAJA`,`transformaciones`.`a_caja` AS `A_CAJA`,`transformaciones`.`a_uxc` AS `A_U_X_CAJA`,`transformaciones`.`gi` AS `GI`,`empresas`.`emp_nomc` AS `EMPC` from (((`transformaciones` join `almacenes` on(`almacenes`.`id_almacen` = `transformaciones`.`id_almacen`)) join `productos` on(`productos`.`id_producto` = `transformaciones`.`id_producto`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_usuarios_cargos` AS select `usuarios`.`id_usuario` AS `ID`,`usuarios`.`nom` AS `USU`,`cargos`.`car_nombre` AS `CAR`,`usuarios`.`hab` AS `HAB` from ((`usuarios` join `personal` on(`usuarios`.`id_vendedor` = `personal`.`id_personal`)) join `cargos` on(`personal`.`per_id_cargo` = `cargos`.`id_cargo`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_ventas` AS select `ventas`.`id_venta` AS `ID`,`ventas`.`id_com` AS `COM_ID`,`ventas`.`iser` AS `ISER`,`ventas`.`inum` AS `INUM`,`almacenes`.`alm_id_empresa` AS `EMP_ID` from (`ventas` join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_ventas_control` AS select `ventas_control`.`id_vc` AS `ID`,`empresas`.`emp_nomc` AS `EMP`,`ventas_control`.`vc_mes` AS `MES_`,`ventas_control`.`vc_ani` AS `ANI_`,`meses`.`mes` AS `MES`,`ventas_control`.`vc_tot` AS `TOT`,`ventas_control`.`vc_obs` AS `OBS`,`ventas_control`.`vc_cal` AS `CAL`,`ventas_control`.`vc_bol` AS `BOL`,`ventas_control`.`vc_fac` AS `FAC`,`ventas_control`.`vc_otr` AS `OTR`,`ventas_control`.`vc_fec` AS `FEC`,date_format(`ventas_control`.`vc_fec`,'%d-%m-%y') AS `FEC_`,`empresas`.`id_emp` AS `EMP_`,`ventas_control`.`vc_dif` AS `DIF`,`ventas_control`.`vc_ndc` AS `NDC`,`ventas_control`.`vc_cal_m_ndc` AS `CAL_M_NDC`,`ventas_control`.`vc_p_dia` AS `P_DIA`,`ventas_control`.`vc_p_tot` AS `P_TOT`,`ventas_control`.`vc_p_dif` AS `P_DIF` from ((`ventas_control` join `empresas` on(`ventas_control`.`vc_id_emp` = `empresas`.`id_emp`)) join `meses` on(`ventas_control`.`vc_mes` = `meses`.`id_mes`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_ventas_control_ex` AS select `almacenes`.`alm_id_empresa` AS `EMP_ID`,`ventas`.`id_com` AS `COM_ID`,`ventas`.`fec` AS `FEC`,`ventas`.`tot` AS `TOT`,`ventas`.`anu` AS `ANU` from (`ventas` join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_ventas_cuotas_t` AS select `ventas_cuotas_t`.`cx` AS `CX`,`ventas_cuotas_t`.`hw` AS `HW`,`ventas_cuotas_t`.`tot` AS `TOT`,`ventas_cuotas_t`.`fec` AS `FEC`,date_format(`ventas_cuotas_t`.`fec`,'%d-%m-%y') AS `FEC_` from `ventas_cuotas_t`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_ventas_det_productos` AS select `ventas_det`.`id_producto` AS `PRO_ID`,`ventas_det`.`pr` AS `PRE` from (`productos` join `ventas_det` on(`ventas_det`.`id_producto` = `productos`.`id_producto`)) group by `ventas_det`.`id_producto`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_ventas_lotes` AS select `ventas_lotes`.`id_vl` AS `ID`,`ventas_lotes`.`vl_nro` AS `NRO`,`ventas_lotes`.`vl_sys_fec` AS `SYS_FEC`,date_format(`ventas_lotes`.`vl_sys_fec`,'%d-%m-%y') AS `SYS_FEC_`,`ventas_lotes`.`vl_sys_hor` AS `HOR`,`ventas_lotes`.`vl_sys_tim` AS `TIM`,`ventas_lotes`.`vl_emp_id` AS `EMP_COD`,`ventas_lotes`.`vl_tie_id` AS `TIE_COD`,`empresas`.`emp_nomc` AS `EMP_NC`,`almacenes`.`alm_obs` AS `TIE_NC`,`ventas_lotes`.`vl_com` AS `COM`,`ventas_lotes`.`vl_ser` AS `SER`,`ventas_lotes`.`vl_iser` AS `ISER`,`ventas_lotes`.`vl_fec` AS `FEC`,date_format(`ventas_lotes`.`vl_fec`,'%d-%m-%y') AS `FEC_`,`ventas_lotes`.`vl_tot_a_gen` AS `TOT_A_GEN`,`ventas_lotes`.`vl_min` AS `WIN`,`ventas_lotes`.`vl_max` AS `WAX`,`ventas_lotes`.`vl_tip_cli` AS `TIP_CLI`,`ventas_lotes`.`vl_ruc_dni` AS `RUC_DNI`,`ventas_lotes`.`vl_tig` AS `TIG`,`ventas_lotes`.`vl_run` AS `RUN`,`ventas_lotes`.`vl_run_ini` AS `RUN_INI`,`ventas_lotes`.`vl_run_fin` AS `RUN_FIN`,`ventas_lotes`.`vl_run_dif` AS `RUN_DIF` from ((`ventas_lotes` join `almacenes` on(`ventas_lotes`.`vl_tie_id` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vis_ventas_lotes_cab_det` AS select `ventas_lotes`.`id_vl` AS `ID`,`ventas_lotes`.`vl_nro` AS `NRO`,`ventas_lotes`.`vl_sys_fec` AS `SYS_FEC`,date_format(`ventas_lotes`.`vl_sys_fec`,'%d-%m-%y') AS `SYS_FEC_`,`ventas_lotes`.`vl_sys_hor` AS `HOR`,`ventas_lotes`.`vl_sys_tim` AS `TIM`,`ventas_lotes`.`vl_emp_id` AS `EMP_COD`,`ventas_lotes`.`vl_tie_id` AS `TIE_COD`,`empresas`.`emp_nomc` AS `EMP_NC`,`almacenes`.`alm_obs` AS `TIE_NC`,`ventas_lotes`.`vl_com` AS `COM`,`ventas_lotes`.`vl_ser` AS `SER`,`ventas_lotes`.`vl_iser` AS `ISER`,`ventas_lotes`.`vl_fec` AS `FEC`,date_format(`ventas_lotes`.`vl_fec`,'%d-%m-%y') AS `FEC_`,`ventas_lotes`.`vl_tot_a_gen` AS `TOT_A_GEN`,`ventas_lotes`.`vl_min` AS `WIN`,`ventas_lotes`.`vl_max` AS `WAX`,`ventas_lotes`.`vl_tip_cli` AS `TIP_CLI`,`ventas_lotes`.`vl_ruc_dni` AS `RUC_DNI`,`ventas_lotes`.`vl_tig` AS `TIG`,`ventas_lotes`.`vl_run` AS `RUN`,`ventas_lotes`.`vl_run_ini` AS `RUN_INI`,`ventas_lotes`.`vl_run_fin` AS `RUN_FIN`,`ventas_lotes`.`vl_run_dif` AS `RUN_DIF` from ((`ventas_lotes` join `almacenes` on(`ventas_lotes`.`vl_tie_id` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vix23_cotizaciones_det` AS select `cotizaciones`.`id_cotizacion` AS `COT_KOD`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones_det`.`id_producto` AS `PRO_KOD`,`cotizaciones_det`.`ca` AS `CAN`,`cotizaciones_det`.`can_uni` AS `PIE`,`cotizaciones_det`.`ca_control` AS `CA_CONTROL`,`cotizaciones_det`.`ve_control` AS `VE_CONTROL`,`cotizaciones`.`fec` AS `COT_FEC`,`cotizaciones_det`.`cod` AS `PRO_COD`,`cotizaciones_det`.`des` AS `PRO_DES`,`cotizaciones_det`.`dev` AS `DEVO`,`cotizaciones_det`.`dej` AS `DEJA` from (`cotizaciones_det` join `cotizaciones` on(`cotizaciones_det`.`id_cotizacion` = `cotizaciones`.`id_cotizacion`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vix23_devoluciones` AS select `devoluciones`.`id_devolucion` AS `DEV_ID`,`devoluciones`.`dev_tipo` AS `TIPO`,`devoluciones`.`dev_id_comprobante` AS `REF_COM_KOD`,`devoluciones`.`dev_id_ref` AS `REF_KOD`,`devoluciones`.`dev_anu` AS `ANU`,`devoluciones`.`dev_fec` AS `FEC`,`devoluciones_det`.`dd_cx` AS `CX`,`devoluciones_det`.`dd_id_producto` AS `PRO_KOD`,`devoluciones_det`.`dd_cant` AS `CAN`,`devoluciones_det`.`dd_pie` AS `PIE` from (`devoluciones` join `devoluciones_det` on(`devoluciones`.`id_devolucion` = `devoluciones_det`.`dd_id_devolucion`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vix23_ginterna_det` AS select `ginterna`.`id_gi` AS `ID`,`ginterna`.`gi_id_cotizacion` AS `COT_KOD`,`ginterna_det`.`id_producto` AS `PRO_KOD`,`ginterna_det`.`ca` AS `CAN`,`ginterna_det`.`can_uni` AS `PIE`,`ginterna_det`.`ca_control` AS `CA_CONTROL`,`ginterna`.`gi_anu` AS `ANU` from (`ginterna` join `ginterna_det` on(`ginterna`.`id_gi` = `ginterna_det`.`id_gi`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vix23_guias` AS select `guias`.`id_guia` AS `ID`,`guias`.`id_almacen` AS `ALM_KOD`,`almacenes`.`alm_id_empresa` AS `EMP_KOD`,`guias`.`iser` AS `ISER`,`guias`.`inum` AS `INUM`,`guias`.`xx_id_tip_gia` AS `TIP_GIA`,`guias`.`anu` AS `ANU`,`guias`.`id_comr` AS `REF_COM_KOD`,`guias`.`idr` AS `REF_KOD` from (`guias` join `almacenes` on(`guias`.`id_almacen` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vix23_guias_cot` AS select `ginterna`.`id_gi` AS `ID`,`empresas`.`emp_nomc` AS `COT_EMP_NC`,`cotizaciones`.`ser` AS `COT_SER`,`cotizaciones`.`num` AS `COT_NUM` from (((`ginterna` join `cotizaciones` on(`ginterna`.`gi_id_cotizacion` = `cotizaciones`.`id_cotizacion`)) join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vix23_guias_det` AS select `guias`.`id_guia` AS `ID`,`guias`.`anu` AS `ANU`,`guias_det`.`id_producto` AS `PRO_KOD`,`guias_det`.`can_uni` AS `PIE`,`guias_det`.`ca` AS `CAN`,`guias`.`id_comr` AS `COM_REF_KOD`,`guias`.`idr` AS `REF_KOD` from (`guias` join `guias_det` on(`guias`.`id_guia` = `guias_det`.`id_guia`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vix23_ventas` AS select `ventas`.`id_venta` AS `ID`,`ventas`.`anu` AS `ANU`,`ventas_det`.`id_producto` AS `PRO_KOD`,`ventas_det`.`ca` AS `CAN`,`ventas_det`.`can_uni` AS `PIE`,`ventas`.`ven_id_com` AS `COM_REF_KOD`,`ventas`.`ven_id_ven` AS `REF_KOD` from (`ventas` join `ventas_det` on(`ventas`.`id_venta` = `ventas_det`.`id_venta`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vix23_ventas_kill` AS select `ventas_kill`.`vk_ref_cod` AS `REF_KOD`,`ventas_kill_det`.`kd_id_pro` AS `PRO_KOD`,`ventas_kill_det`.`kd_pie` AS `PIE`,`ventas_kill`.`vk_anu` AS `ANU`,`ventas_kill_det`.`kd_can` AS `CAN` from (`ventas_kill` join `ventas_kill_det` on(`ventas_kill`.`id_vk` = `ventas_kill_det`.`kd_id_vk`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vix_cotizaciones` AS select `cotizaciones`.`id_cotizacion` AS `ID_COT`,`empresas`.`emp_nomc` AS `EMP`,`almacenes`.`alm_obs` AS `ALM`,`cotizaciones`.`ser` AS `SER`,`cotizaciones`.`num` AS `NUM`,`cotizaciones`.`iser` AS `SER_`,`cotizaciones`.`inum` AS `NUM_`,`empresas`.`id_emp` AS `ID_EMP`,`almacenes`.`id_almacen` AS `ID_ALM` from ((`cotizaciones` join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vix_stock_pie` AS select `almacenes`.`alm_obs` AS `ALM`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES`,`stocks_presentaciones`.`sp_presentacion` AS `PIE`,`stocks_presentaciones`.`sp_cantidad` AS `CAN`,`stocks_presentaciones`.`sp_provicional` AS `PROVI`,`stocks_presentaciones`.`sp_id_producto` AS `ID_PRO`,`stocks_presentaciones`.`sp_id_almacen` AS `ID_ALM`,`lineas`.`lin_nombre` AS `LIN` from (((`stocks_presentaciones` join `productos` on(`stocks_presentaciones`.`sp_id_producto` = `productos`.`id_producto`)) join `almacenes` on(`stocks_presentaciones`.`sp_id_almacen` = `almacenes`.`id_almacen`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `viz_con_ing` AS select `contratos_ingresos`.`id_con_ing` AS `ID`,`contratos_ingresos`.`ci_fec` AS `FEC`,`contratos`.`con_numero` AS `CON_NUM`,`contratos_ingresos`.`ci_numero` AS `NUM`,`contratos_ingresos`.`ci_total` AS `TOT`,`contratos_ingresos`.`ci_tipo` AS `TIP`,`contratos_ingresos`.`ci_gi` AS `GI`,`contratos_ingresos`.`ci_saldo` AS `SAL`,`contratos`.`con_total` AS `CON_TOT`,`clientes`.`cli_nombre` AS `CLI`,`contratos_ingresos`.`ci_id_contrato` AS `ID_KON`,`empresas`.`emp_nomc` AS `EMPC`,`contratos_ingresos`.`ci_id_usuario` AS `KOD_USU` from (((`contratos_ingresos` join `contratos` on(`contratos_ingresos`.`ci_id_contrato` = `contratos`.`id_contrato`)) join `clientes` on(`contratos`.`con_id_cliente` = `clientes`.`id_cliente`)) join `empresas` on(`contratos`.`con_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `viz_con_ing_dia` AS select `viz_con_ing`.`ID` AS `ID`,`viz_con_ing`.`FEC` AS `FEC`,concat('CON-',`viz_con_ing`.`CON_NUM`) AS `GUIA`,`viz_con_ing`.`CON_TOT` AS `IMPORTE`,if(`viz_con_ing`.`TIP` = 'EFECTIVO',`viz_con_ing`.`TOT`,0) AS `EFE`,if(`viz_con_ing`.`TIP` = 'DEPOSITO',`viz_con_ing`.`TOT`,0) AS `BAN`,`viz_con_ing`.`SAL` AS `SAL`,`viz_con_ing`.`CLI` AS `CLI`,`viz_con_ing`.`GI` AS `GI`,`viz_con_ing`.`TIP` AS `TIP`,`viz_con_ing`.`TOT` AS `TOT`,`viz_con_ing`.`ID_KON` AS `ID_KON`,'N' AS `ANU`,`viz_con_ing`.`NUM` AS `NUM`,`viz_con_ing`.`EMPC` AS `EMPC`,`viz_con_ing`.`KOD_USU` AS `KOD_USU` from `viz_con_ing`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `viz_con_ing_dia_xx` AS select `viz_con_ing_xx`.`ID` AS `ID`,`viz_con_ing_xx`.`FEC` AS `FEC`,concat('CON-',`viz_con_ing_xx`.`CON_NUM`) AS `GUIA`,`viz_con_ing_xx`.`CON_TOT` AS `IMPORTE`,if(`viz_con_ing_xx`.`TIP` = 'EFECTIVO',`viz_con_ing_xx`.`TOT`,0) AS `EFE`,if(`viz_con_ing_xx`.`TIP` = 'DEPOSITO',`viz_con_ing_xx`.`TOT`,0) AS `BAN`,`viz_con_ing_xx`.`SAL` AS `SAL`,`viz_con_ing_xx`.`CLI` AS `CLI`,`viz_con_ing_xx`.`GI` AS `GI`,`viz_con_ing_xx`.`TIP` AS `TIP`,`viz_con_ing_xx`.`TOT` AS `TOT`,`viz_con_ing_xx`.`ID_KON` AS `ID_KON`,'N' AS `ANU`,`viz_con_ing_xx`.`NUM` AS `NUM`,`viz_con_ing_xx`.`EMPC` AS `EMPC`,`viz_con_ing_xx`.`KOD_USU` AS `KOD_USU`,`viz_con_ing_xx`.`ALM_NC` AS `ALM_NC` from `viz_con_ing_xx`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `viz_con_ing_xx` AS select `contratos_ingresos`.`id_con_ing` AS `ID`,`contratos_ingresos`.`ci_fec` AS `FEC`,`contratos`.`con_numero` AS `CON_NUM`,`contratos_ingresos`.`ci_numero` AS `NUM`,`contratos_ingresos`.`ci_total` AS `TOT`,`contratos_ingresos`.`ci_tipo` AS `TIP`,`contratos_ingresos`.`ci_gi` AS `GI`,`contratos_ingresos`.`ci_saldo` AS `SAL`,`contratos`.`con_total` AS `CON_TOT`,`clientes`.`cli_nombre` AS `CLI`,`contratos_ingresos`.`ci_id_contrato` AS `ID_KON`,`empresas`.`emp_nomc` AS `EMPC`,`contratos_ingresos`.`ci_id_usuario` AS `KOD_USU`,`almacenes`.`alm_obs` AS `ALM_NC` from ((((`contratos_ingresos` join `contratos` on(`contratos_ingresos`.`ci_id_contrato` = `contratos`.`id_contrato`)) join `clientes` on(`contratos`.`con_id_cliente` = `clientes`.`id_cliente`)) join `empresas` on(`contratos`.`con_id_empresa` = `empresas`.`id_emp`)) join `almacenes` on(`contratos_ingresos`.`ci_id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `viz_contratos_efe_dep` AS select `contratos`.`id_contrato` AS `ID`,`contratos`.`con_fecha` AS `FEC`,concat('CON-',`contratos`.`con_numero`) AS `GUIA`,`contratos`.`con_total` AS `IMPORTE`,if(`contratos`.`tip_tip_adelanto` = 'EFECTIVO',`contratos`.`con_adelanto`,0) AS `EFE`,if(`contratos`.`tip_tip_adelanto` = 'DEPOSITO',`contratos`.`con_adelanto`,0) AS `BAN`,`contratos`.`con_total` - `contratos`.`con_adelanto` AS `SAL`,`clientes`.`cli_nombre` AS `CLI`,`contratos`.`con_gi` AS `GI`,'N' AS `ANU`,`contratos`.`con_adelanto` AS `TOT`,`empresas`.`emp_nomc` AS `EMPC`,`contratos`.`con_id_usario` AS `KOD_USU` from ((`contratos` join `clientes` on(`contratos`.`con_id_cliente` = `clientes`.`id_cliente`)) join `empresas` on(`contratos`.`con_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `viz_contratos_efe_dep_xx` AS select `contratos`.`id_contrato` AS `ID`,`contratos`.`con_fecha` AS `FEC`,concat('CON-',`contratos`.`con_numero`) AS `GUIA`,`contratos`.`con_total` AS `IMPORTE`,if(`contratos`.`tip_tip_adelanto` = 'EFECTIVO',`contratos`.`con_adelanto`,0) AS `EFE`,if(`contratos`.`tip_tip_adelanto` = 'DEPOSITO',`contratos`.`con_adelanto`,0) AS `BAN`,`contratos`.`con_total` - `contratos`.`con_adelanto` AS `SAL`,`clientes`.`cli_nombre` AS `CLI`,`contratos`.`con_gi` AS `GI`,'N' AS `ANU`,`contratos`.`con_adelanto` AS `TOT`,`empresas`.`emp_nomc` AS `EMPC`,`contratos`.`con_id_usario` AS `KOD_USU`,`almacenes`.`alm_obs` AS `ALM_NC` from (((`contratos` join `clientes` on(`contratos`.`con_id_cliente` = `clientes`.`id_cliente`)) join `empresas` on(`contratos`.`con_id_empresa` = `empresas`.`id_emp`)) join `almacenes` on(`contratos`.`con_id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `viz_cotizacion_efe_dep` AS select `cotizaciones`.`id_cotizacion` AS `ID`,`cotizaciones`.`fec` AS `FEC`,concat('P',if(octet_length(`cotizaciones`.`ser`) > 0,concat(`cotizaciones`.`ser`,'-',`cotizaciones`.`num`),`cotizaciones`.`num`)) AS `GUIA`,`cotizaciones`.`tot_real` AS `IMPORTE`,if(`cotizaciones`.`modalidad` = 'EFECTIVO',`cotizaciones`.`acu` - `cotizaciones`.`vue`,0) AS `EFE`,if(`cotizaciones`.`modalidad` = 'DEPOSITO',`cotizaciones`.`acu` - `cotizaciones`.`vue`,0) AS `BAN`,`cotizaciones`.`tot_real` - (`cotizaciones`.`acu` - `cotizaciones`.`vue`) AS `SAL`,`clientes`.`cli_nombre` AS `CLI`,`cotizaciones`.`gi` AS `GI`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM`,`cotizaciones`.`acu` - `cotizaciones`.`vue` AS `TOT`,`empresas`.`emp_nomc` AS `EMPC`,`cotizaciones`.`id_usuario` AS `KOD_USU` from (((`cotizaciones` join `clientes` on(`cotizaciones`.`id_cliente` = `clientes`.`id_cliente`)) join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) where `cotizaciones`.`id_cotizacion` > 0 and `cotizaciones`.`cot_pri` = '1';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `viz_cotizacion_efe_dep_xx` AS select `cotizaciones`.`id_cotizacion` AS `ID`,`cotizaciones`.`fec` AS `FEC`,concat('P',if(octet_length(`cotizaciones`.`ser`) > 0,concat(`cotizaciones`.`ser`,'-',`cotizaciones`.`num`),`cotizaciones`.`num`)) AS `GUIA`,`cotizaciones`.`tot_real` AS `IMPORTE`,if(`cotizaciones`.`modalidad` = 'EFECTIVO',`cotizaciones`.`acu` - `cotizaciones`.`vue`,0) AS `EFE`,if(`cotizaciones`.`modalidad` = 'DEPOSITO',`cotizaciones`.`acu` - `cotizaciones`.`vue`,0) AS `BAN`,`cotizaciones`.`tot_real` - (`cotizaciones`.`acu` - `cotizaciones`.`vue`) AS `SAL`,`clientes`.`cli_nombre` AS `CLI`,`cotizaciones`.`gi` AS `GI`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM`,`cotizaciones`.`acu` - `cotizaciones`.`vue` AS `TOT`,`empresas`.`emp_nomc` AS `EMPC`,`cotizaciones`.`id_usuario` AS `KOD_USU`,`almacenes`.`alm_obs` AS `ALM_NC` from (((`cotizaciones` join `clientes` on(`cotizaciones`.`id_cliente` = `clientes`.`id_cliente`)) join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) where `cotizaciones`.`id_cotizacion` > 0 and `cotizaciones`.`cot_pri` = '1';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `viz_ventas_efe_dep` AS select `ventas`.`id_venta` AS `ID`,`ventas`.`fec` AS `FEC`,concat(substr(`comprobantes`.`com_nombre`,1,1),`ventas`.`ser`,'-',`ventas`.`num`) AS `GUIA`,`ventas`.`tot` AS `IMPORTE`,if(`ventas`.`ven_modalidad` = 'EFECTIVO',`ventas`.`acuenta`,0) AS `EFE`,if(`ventas`.`ven_modalidad` = 'DEPOSITO',`ventas`.`acuenta`,0) AS `BAN`,`ventas`.`tot` - `ventas`.`acuenta` AS `SAL`,`clientes`.`cli_nombre` AS `CLI`,`ventas`.`gi` AS `GI`,`ventas`.`anu` AS `ANU`,`ventas`.`iser` AS `ISER`,`ventas`.`inum` AS `INUM`,`ventas`.`vuelto` AS `VUE`,`ventas`.`acuenta` AS `TOT`,`empresas`.`emp_nomc` AS `EMPC`,`ventas`.`id_usuario` AS `KOD_USU` from ((((`ventas` join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) where `ventas`.`ven_prin` = 1;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `viz_ventas_efe_dep_xx` AS select `ventas`.`id_venta` AS `ID`,`ventas`.`fec` AS `FEC`,concat(substr(`comprobantes`.`com_nombre`,1,1),`ventas`.`ser`,'-',`ventas`.`num`) AS `GUIA`,`ventas`.`tot` AS `IMPORTE`,if(`ventas`.`ven_modalidad` = 'EFECTIVO',`ventas`.`acuenta`,0) AS `EFE`,if(`ventas`.`ven_modalidad` = 'DEPOSITO',`ventas`.`acuenta`,0) AS `BAN`,`ventas`.`tot` - `ventas`.`acuenta` AS `SAL`,`clientes`.`cli_nombre` AS `CLI`,`ventas`.`gi` AS `GI`,`ventas`.`anu` AS `ANU`,`ventas`.`iser` AS `ISER`,`ventas`.`inum` AS `INUM`,`ventas`.`vuelto` AS `VUE`,`ventas`.`acuenta` AS `TOT`,`empresas`.`emp_nomc` AS `EMPC`,`ventas`.`id_usuario` AS `KOD_USU`,`almacenes`.`alm_obs` AS `ALM_NC` from ((((`ventas` join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) where `ventas`.`ven_prin` = 1;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vkar_aju` AS select `ajustes`.`fec` AS `FEC`,`ajustes`.`id_alm` AS `ID_ALM`,`almacenes`.`alm_nombre` AS `ALM`,`ajustes`.`num` AS `NUM`,`ajustes`.`acc` AS `ACC`,`ajustes`.`gi` AS `GI`,`ajustes_det`.`id_producto` AS `ID_PRO`,`ajustes_det`.`ca` AS `CA`,`ajustes_det`.`can_uni` AS `UNI` from ((`ajustes` join `ajustes_det` on(`ajustes`.`id_ajuste` = `ajustes_det`.`id_ajuste`)) join `almacenes` on(`ajustes`.`id_alm` = `almacenes`.`id_almacen`)) where `ajustes`.`anu` = 'N';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vkar_ajup` AS select `ajustes_presentacion`.`id_ajuste` AS `ID`,'AJUSTEP' AS `COM`,`ajustes_presentacion`.`fec` AS `FEC`,`almacenes`.`alm_nombre` AS `ALM`,`ajustes_presentacion`.`num` AS `NUM`,`ajustes_presentacion`.`acc` AS `ACC`,`ajustes_presentacion`.`gi` AS `GI`,`ajustes_presentacion_det`.`id_producto` AS `ID_PRO`,`ajustes_presentacion_det`.`cajas` AS `CA`,`ajustes_presentacion_det`.`piezas` AS `PIE`,`ajustes_presentacion_det`.`piezas_ajuste` AS `PIE_AJ`,`almacenes`.`id_almacen` AS `ID_ALM`,`ajustes_presentacion_det`.`piezas` - `ajustes_presentacion_det`.`piezas_ajuste` AS `PIE_N` from ((`ajustes_presentacion` join `almacenes` on(`ajustes_presentacion`.`id_alm` = `almacenes`.`id_almacen`)) join `ajustes_presentacion_det` on(`ajustes_presentacion`.`id_ajuste` = `ajustes_presentacion_det`.`id_ajuste`)) where `ajustes_presentacion`.`anu` = 'N';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vkar_com` AS select `compras`.`fecha` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`compras`.`numero` AS `NUM`,`proveedores`.`pro_nombre` AS `PROV`,`compras_det`.`id_producto` AS `ID_PRO`,`compras_det`.`ca` AS `CA`,`compras`.`gi` AS `GI`,`compras`.`id_almacen` AS `ID_ALM`,`compras_det`.`can_uni` AS `UNI`,`compras`.`et` AS `ET` from (((`compras` join `compras_det` on(`compras`.`id_compra` = `compras_det`.`id_compra`)) join `comprobantes` on(`compras`.`id_comprobante` = `comprobantes`.`id_comprobante`)) join `proveedores` on(`proveedores`.`id_proveedor` = `compras`.`id_proveedor`)) where `compras`.`anulado` = 'N';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vkar_devoluciones` AS select `devoluciones`.`id_devolucion` AS `ID`,`almacenes`.`alm_nombre` AS `ALM`,'DEV' AS `COM`,`devoluciones`.`dev_nro` AS `NRO`,`devoluciones`.`dev_fec` AS `FEC`,`comprobantes`.`com_nombre` AS `REF_COM`,`devoluciones`.`dev_ser` AS `REF_SER`,`devoluciones`.`dev_num` AS `REF_NUM`,`devoluciones`.`dev_gi` AS `GI`,`devoluciones`.`dev_id_alm` AS `ID_ALM`,`devoluciones_det`.`dd_id_producto` AS `ID_PRO`,`devoluciones_det`.`dd_cant` AS `CA`,`devoluciones_det`.`dd_pie` AS `PIE` from (((`devoluciones` join `almacenes` on(`devoluciones`.`dev_id_alm` = `almacenes`.`id_almacen`)) join `comprobantes` on(`devoluciones`.`dev_id_comprobante` = `comprobantes`.`id_comprobante`)) join `devoluciones_det` on(`devoluciones`.`id_devolucion` = `devoluciones_det`.`dd_id_devolucion`)) where `devoluciones`.`dev_anu` = 'N' and `devoluciones`.`dev_tipo` = 'D';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vkar_gui` AS select `guias`.`id_almacen` AS `ID_ALM`,`guias`.`fe` AS `FEC`,'GUIA' AS `COM`,`guias`.`ser` AS `SER`,`guias`.`num` AS `NUM`,`guias`.`des_rs` AS `CLI`,`guias_det`.`id_producto` AS `ID_PRO`,`guias_det`.`ca` AS `CA`,`guias`.`gi` AS `GI`,`guias_det`.`can_uni` AS `UNI` from (`guias` join `guias_det` on(`guias`.`id_guia` = `guias_det`.`id_guia`)) where `guias`.`anu` = 'N' and `guias`.`guia_desc` = 1;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vkar_gui_int` AS select `ginterna`.`id_gi` AS `ID`,`almacenes`.`alm_nombre` AS `ALM`,'GUIA.INT.' AS `COM`,`ginterna`.`gi_num` AS `NUM`,`ginterna`.`gi_fec` AS `FEC`,`ginterna`.`gi_destinatario` AS `CLI`,`ginterna`.`gi_cot_ser` AS `COT_SER`,`ginterna`.`gi_cot_num` AS `COT_NUM`,`ginterna`.`gi_gi` AS `GI`,`ginterna_det`.`id_producto` AS `ID_PRO`,`ginterna_det`.`ca` AS `CA`,`ginterna_det`.`cod` AS `COD`,`ginterna_det`.`des` AS `DES`,`ginterna_det`.`can_uni` AS `PIE`,`ginterna_det`.`ca_control` AS `CA_CONTROL`,`ginterna`.`gi_id_alm` AS `ID_ALM` from ((`ginterna` join `ginterna_det` on(`ginterna`.`id_gi` = `ginterna_det`.`id_gi`)) join `almacenes` on(`ginterna`.`gi_id_alm` = `almacenes`.`id_almacen`)) where `ginterna`.`gi_anu` = 'N';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vkar_tra` AS select `transferencias`.`fec` AS `FEC`,`origen`.`alm_nombre` AS `ORI`,`transferencias`.`num` AS `NUM`,`transferencias`.`gi` AS `GI`,`transferencias_det`.`id_producto` AS `ID_PRO`,`transferencias_det`.`cant` AS `CA`,`destino`.`alm_nombre` AS `DES`,`transferencias`.`id_alm_o` AS `ID_ALM_O`,`transferencias`.`id_alm_d` AS `ID_ALM_D`,`transferencias`.`val` AS `VAL`,`transferencias_det`.`can_uni` AS `UNI`,`transferencias`.`tser` AS `TSER`,`transferencias`.`tnum` AS `TNUM`,`transferencias`.`id_trans` AS `ID_TRA` from (((`transferencias` join `almacenes` `origen` on(`origen`.`id_almacen` = `transferencias`.`id_alm_o`)) join `transferencias_det` on(`transferencias`.`id_trans` = `transferencias_det`.`id_trans`)) join `almacenes` `destino` on(`transferencias`.`id_alm_d` = `destino`.`id_almacen`)) where `transferencias`.`anu` = 'N';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vkar_transformaciones` AS select `transformaciones`.`id_transformacion` AS `ID`,'TRANSFORMACION' AS `COM`,`transformaciones`.`id_transformacion` AS `NUM`,'' AS `PROV`,`transformaciones`.`fecha` AS `FEC`,`transformaciones`.`id_almacen` AS `ID_ALM`,`transformaciones`.`id_producto` AS `ID_PRO`,`transformaciones`.`cant` AS `CANT`,`transformaciones`.`de_caja` AS `SA_KA`,`transformaciones`.`de_uxc` AS `SA_PIE`,`transformaciones`.`de_caja` AS `GE_KA`,`transformaciones`.`de_uxc` - `transformaciones`.`cant` AS `GE_PIE`,`transformaciones`.`a_caja` AS `RE_KA`,`transformaciones`.`a_uxc` AS `RE_PIE`,`transformaciones`.`a_caja` AS `SU_KA`,`transformaciones`.`a_uxc` + `transformaciones`.`cant` AS `SU_PIE`,`transformaciones`.`gi` AS `GI` from `transformaciones`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vkar_ven` AS select `ventas`.`id_alm` AS `ID_ALM`,`ventas`.`fec` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`ventas`.`ser` AS `SER`,`ventas`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`ventas`.`gi` AS `GI`,`ventas_det`.`id_producto` AS `ID_PRO`,`ventas_det`.`ca` AS `CA`,`ventas_det`.`can_uni` AS `UNI` from (((`ventas` join `ventas_det` on(`ventas`.`id_venta` = `ventas_det`.`id_venta`)) join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) where `ventas`.`anu` = 'N' and `ventas`.`ven_desc` = 1;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vmenus` AS select `menus`.`id` AS `ID`,`menu`.`nombre` AS `MN`,`menu`.`col` AS `MC`,`menu`.`ord` AS `MO`,`menu`.`nl` AS `ML`,`menus`.`sm` AS `SN`,`menus`.`url` AS `SU`,`menus`.`orden` AS `SO`,`menus`.`nl` AS `SL` from (`menu` join `menus` on(`menu`.`id_menu` = `menus`.`id_menu`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vpagos` AS select `pagos`.`id_pago` AS `ID`,`pagos`.`num` AS `NUM`,`pagos`.`fec` AS `FEC`,`proveedores`.`pro_nombre` AS `PROV`,`proveedores`.`pro_ruc` AS `RUC`,`pagos`.`pendiente` AS `PEN`,`pagos`.`total` AS `TOT`,`pagos`.`mon` AS `MON`,`pagos`.`anu` AS `ANU`,`pagos`.`gi` AS `GI`,`fpagos`.`nombre` AS `FPAGO`,`pagos`.`numf` AS `NUMF`,`pagos`.`fecven` AS `FECVEN`,`comprobantes`.`com_nombre` AS `COM`,`pagos`.`serr` AS `SERR`,`pagos`.`numr` AS `NUMR`,`pagos`.`pag` AS `PAG`,`pagos`.`fecpag` AS `FECPAG`,`pagos`.`gi2` AS `GI2`,`pagos`.`id_proveedor` AS `ID_PROV`,`almacenes`.`alm_nombre` AS `ALM`,`pagos`.`id_alm` AS `ID_ALM` from ((((`pagos` join `proveedores` on(`pagos`.`id_proveedor` = `proveedores`.`id_proveedor`)) join `fpagos` on(`pagos`.`id_fpago` = `fpagos`.`id_fpago`)) join `comprobantes` on(`pagos`.`id_comprobante` = `comprobantes`.`id_comprobante`)) join `almacenes` on(`pagos`.`id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vparche` AS select `ventas`.`ven_id_ven` AS `ID_COT`,`ventas_det`.`id_producto` AS `ID_PRO`,`ventas_det`.`ca` AS `KA`,`ventas_det`.`can_uni` AS `PIE` from (`ventas` join `ventas_det` on(`ventas`.`id_venta` = `ventas_det`.`id_venta`)) where `ventas`.`ven_id_com` = -3 and `ventas`.`anu` = 'N' and `ventas`.`ven_prin` = 0 order by `ventas`.`ven_id_ven`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vpersonal` AS select `personal`.`id_personal` AS `ID`,`personal`.`per_nombre` AS `NOMBRE`,`personal`.`per_direccion` AS `DIRECCION`,`distritos`.`dis_nombre` AS `DISTRITO`,`personal`.`per_fecnac` AS `FEC_NAC`,`personal`.`per_dni` AS `DNI`,`personal`.`per_tel` AS `TEL`,`personal`.`per_cel` AS `CEL`,`personal`.`per_fecing` AS `FEC_ING`,`personal`.`per_email` AS `EMAIL`,`cargos`.`car_nombre` AS `CARGO` from ((`personal` join `distritos` on(`personal`.`per_id_distrito` = `distritos`.`id_distrito`)) join `cargos` on(`personal`.`per_id_cargo` = `cargos`.`id_cargo`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vproductos` AS select `productos`.`id_producto` AS `ID`,`productos`.`pro_codigo` AS `COD`,`lineas`.`lin_nombre` AS `LINEA`,`productos`.`pro_des` AS `DESCRIPCION`,`marcas`.`mar_nombre` AS `MARCA`,`unidades`.`uni_nombre` AS `UNIDAD`,`productos`.`pro_pc_sol` AS `PC_SOL`,`productos`.`pro_pv_min` AS `PV_MIN`,`productos`.`pro_pv_max` AS `PV_MAX`,`proveedores`.`pro_nombre` AS `PROVEEDOR`,if(`productos`.`pro_uso` = 'S','SI','NO') AS `USO`,`productos`.`pro_rojo` AS `ROJ`,`productos`.`pro_ama` AS `AMA` from ((((`productos` join `unidades` on(`productos`.`pro_id_unidad` = `unidades`.`id_unidad`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `proveedores` on(`productos`.`pro_id_proveedor` = `proveedores`.`id_proveedor`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vproveedores` AS select `proveedores`.`id_proveedor` AS `ID`,`proveedores`.`pro_nombre` AS `NOMBRE`,`proveedores`.`pro_contacto` AS `CONTACTO`,`proveedores`.`pro_dir` AS `DIRECCION`,`distritos`.`dis_nombre` AS `DISTRITO`,`proveedores`.`pro_dni` AS `DNI`,`proveedores`.`pro_ruc` AS `RUC`,`proveedores`.`pro_tel` AS `TEL`,`proveedores`.`pro_cel` AS `CEL`,`proveedores`.`pro_fax` AS `FAX`,`proveedores`.`pro_email` AS `EMAIL` from (`proveedores` join `distritos` on(`proveedores`.`pro_id_distrito` = `distritos`.`id_distrito`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vstocks` AS select `stocks`.`id_almacen` AS `ID_ALM`,`stocks`.`id_producto` AS `ID_PRO`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES`,`productos`.`pro_pv_min` AS `PV_MIN`,`productos`.`pro_pv_max` AS `PV_MAX`,`marcas`.`mar_nombre` AS `MAR`,`stocks`.`stock` AS `STOCK`,`productos`.`pro_pc_sol` AS `PC_SOL`,`almacenes`.`alm_nombre` AS `ALM` from (((`stocks` join `productos` on(`stocks`.`id_producto` = `productos`.`id_producto`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`)) join `almacenes` on(`almacenes`.`id_almacen` = `stocks`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vtransferencias` AS select `transferencias`.`id_trans` AS `ID`,`transferencias`.`fec` AS `FEC`,`origen`.`alm_obs` AS `ORI`,`transferencias`.`num` AS `NUM`,`destino`.`alm_obs` AS `DES`,`transferencias`.`anu` AS `ANU`,`transferencias`.`id_usuario` AS `IDU`,`transferencias`.`tser` AS `TSER`,`transferencias`.`tnum` AS `TNUM`,`transferencias`.`val` AS `VAL`,`e_ori`.`emp_nomc` AS `O_EMPC`,`e_des`.`emp_nomc` AS `D_EMPC`,`transferencias`.`r_com` AS `R_COM`,`transferencias`.`r_ser` AS `R_SER`,`transferencias`.`r_num` AS `R_NUM`,`transferencias`.`carreta` AS `CARR`,`transferencias`.`tser_` AS `TSER_`,`transferencias`.`tnum_` AS `TNUM_` from ((((`transferencias` join `almacenes` `origen` on(`transferencias`.`id_alm_o` = `origen`.`id_almacen`)) join `almacenes` `destino` on(`transferencias`.`id_alm_d` = `destino`.`id_almacen`)) join `empresas` `e_ori` on(`origen`.`alm_id_empresa` = `e_ori`.`id_emp`)) join `empresas` `e_des` on(`destino`.`alm_id_empresa` = `e_des`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vtransferencias_det` AS select `transferencias`.`id_trans` AS `ID`,`transferencias`.`fec` AS `FEC`,`origen`.`alm_obs` AS `ALM_O`,`transferencias`.`num` AS `NUM`,`transferencias`.`anu` AS `ANU`,`transferencias`.`id_usuario` AS `ID_U`,`destino`.`alm_obs` AS `ALM_D`,`transferencias_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES`,`marcas`.`mar_nombre` AS `MAR`,`transferencias_det`.`cant` AS `KA`,`lineas`.`lin_nombre` AS `LINEA`,`origen`.`alm_obs` AS `ALM_O_C`,`destino`.`alm_obs` AS `ALM_D_C`,`transferencias_det`.`can_uni` AS `CAN_UNI`,`transferencias`.`tser` AS `TSER`,`transferencias`.`tnum` AS `TNUM`,`o_emp`.`emp_nomc` AS `O_EMPC`,`d_emp`.`emp_nomc` AS `D_EMPC` from ((((((((`transferencias` join `almacenes` `origen` on(`transferencias`.`id_alm_o` = `origen`.`id_almacen`)) join `almacenes` `destino` on(`transferencias`.`id_alm_d` = `destino`.`id_almacen`)) join `transferencias_det` on(`transferencias_det`.`id_trans` = `transferencias`.`id_trans`)) join `productos` on(`transferencias_det`.`id_producto` = `productos`.`id_producto`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`)) join `lineas` on(`lineas`.`id_linea` = `productos`.`pro_id_linea`)) join `empresas` `o_emp` on(`origen`.`alm_id_empresa` = `o_emp`.`id_emp`)) join `empresas` `d_emp` on(`destino`.`alm_id_empresa` = `d_emp`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vusu_mem` AS select `usuarios_menus`.`id_usuario` AS `IDU`,`menu`.`id_menu` AS `IDM`,`menu`.`col` AS `COL`,sum(`usuarios_menus`.`valor`) AS `VA`,`menu`.`nombre` AS `ME` from (((`usuarios_menus` join `usuarios` on(`usuarios_menus`.`id_usuario` = `usuarios`.`id_usuario`)) join `menus` on(`usuarios_menus`.`id_sm` = `menus`.`id`)) join `menu` on(`menus`.`id_menu` = `menu`.`id_menu`)) where '' = '' group by `usuarios_menus`.`id_usuario`,`menu`.`id_menu`,`menu`.`col` order by `menu`.`col`,`menu`.`ord`,`menus`.`orden`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vusu_men` AS select `usuarios_menus`.`id_usuario` AS `IDU`,`menu`.`id_menu` AS `IDM`,`menus`.`id` AS `IDS`,`usuarios`.`nom` AS `USU`,`menu`.`nombre` AS `ME`,`menus`.`sm` AS `SM`,`usuarios_menus`.`valor` AS `VA`,`menu`.`col` AS `COL`,`menu`.`ord` AS `MO`,`menus`.`orden` AS `SO`,`menu`.`nl` AS `ML`,`menus`.`nl` AS `SL`,`menus`.`url` AS `UR` from (((`usuarios_menus` join `usuarios` on(`usuarios_menus`.`id_usuario` = `usuarios`.`id_usuario`)) join `menus` on(`usuarios_menus`.`id_sm` = `menus`.`id`)) join `menu` on(`menus`.`id_menu` = `menu`.`id_menu`)) where '' = '' order by `menu`.`col`,`menu`.`ord`,`menus`.`orden`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vven_control` AS select `ventas`.`anu` AS `ANU`,`ventas_det`.`id_producto` AS `IDP`,`ventas_det`.`ca` AS `CA`,`ventas_det`.`can_uni` AS `PIE`,`ventas_det`.`ca_control` AS `CA_CONTROL`,`ventas`.`ven_id_com` AS `VEN_ID_COM`,`ventas_det`.`dej` AS `DEJ`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`ventas`.`id_venta` AS `ID_VEN`,`ventas`.`ven_prin` AS `PRI`,`ventas`.`ven_desc` AS `ALTER_STOCK`,`ventas`.`fec` AS `FEC`,`ventas`.`id_alm` AS `ID_ALM` from ((`ventas` join `ventas_det` on(`ventas`.`id_venta` = `ventas_det`.`id_venta`)) join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vven_edc` AS select `ventas`.`id_venta` AS `ID`,`almacenes`.`alm_nombre` AS `ALM`,`ventas`.`fec` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`ventas`.`ser` AS `SER`,`ventas`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`ventas`.`tcam` AS `TCAM`,`ventas`.`inc_igv` AS `IIG`,`ventas`.`tot` AS `TOT`,`ventas`.`iser` AS `ISER`,`ventas`.`inum` AS `INUM`,`ventas`.`id_usuario` AS `IDU`,`ventas`.`mon` AS `MON`,`ventas`.`anu` AS `ANU`,`ventas`.`gi` AS `GI`,'' AS `NPED`,'' AS `CONT`,`clientes`.`id_cliente` AS `IDCLI`,`clientes`.`cli_email` AS `EMA`,`clientes`.`cli_dir` AS `DIR`,'' AS `VEN`,`tipos_pagos`.`tipp_nombre` AS `TDP`,`ventas`.`acuenta` AS `ACU`,`monedas`.`mon_nombre` AS `MND`,`ventas`.`vuelto` AS `VUE`,`ventas`.`tot` - `ventas`.`acuenta` AS `SAL`,`ventas`.`ven_modalidad` AS `MODAL`,`ventas`.`ven_prin` AS `PRI_`,`ventas`.`ven_desc` AS `DES_`,concat(`ventas`.`ser`,'-',`ventas`.`num`) AS `SER_NUM`,`ventas`.`tot` AS `TOT_REAL`,0 AS `TOT_DES`,`ventas`.`ven_cob` AS `TOT_COB`,`ventas`.`tot` - `ventas`.`ven_cob` AS `SALDO`,`empresas`.`emp_nomc` AS `EMPC` from ((((((`ventas` join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) join `tipos_pagos` on(`ventas`.`id_tip_pag` = `tipos_pagos`.`id_tip_pag`)) join `monedas` on(`ventas`.`mon` = `monedas`.`id_moneda`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vven_sal_pen` AS select `ventas`.`id_venta` AS `ID`,`ventas`.`fec` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`ventas`.`ser` AS `SER`,`ventas`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`ventas`.`tcam` AS `TCAM`,`ventas`.`inc_igv` AS `IIG`,`ventas`.`tot` AS `TOT`,`ventas`.`iser` AS `ISER`,`ventas`.`inum` AS `INUM`,`ventas`.`id_usuario` AS `IDU`,`ventas`.`mon` AS `MON`,`ventas`.`anu` AS `ANU`,`ventas`.`gi` AS `GI`,'' AS `NPED`,'' AS `CONT`,`clientes`.`id_cliente` AS `IDCLI`,`ventas_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES`,`ventas_det`.`ca` AS `KA`,`ventas_det`.`pr` AS `PR`,`ventas_det`.`im` AS `IMP`,0 AS `DT`,`marcas`.`mar_nombre` AS `MAR`,`ventas_det`.`can_uni` AS `UNI`,`lineas`.`lin_nombre` AS `LINEA`,`ventas_det`.`ca_control` AS `CA_CONTROL`,0 AS `VE_CONTROL`,`ventas_det`.`dej` AS `DEJA`,`ventas`.`ven_prin` AS `PRI_`,`ventas`.`ven_desc` AS `DES_`,`empresas`.`emp_nomc` AS `EMPC` from ((((((((`ventas` join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) join `ventas_det` on(`ventas`.`id_venta` = `ventas_det`.`id_venta`)) join `productos` on(`ventas_det`.`id_producto` = `productos`.`id_producto`)) join `marcas` on(`productos`.`pro_id_marca` = `marcas`.`id_marca`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vventas` AS select `ventas`.`id_venta` AS `ID`,`almacenes`.`alm_obs` AS `ALM`,`ventas`.`fec` AS `FEC`,date_format(`ventas`.`fec`,'%d-%m-%y') AS `FEC_`,`comprobantes`.`com_nombre` AS `COM`,`ventas`.`ser` AS `SER`,`ventas`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`ventas`.`id_tip_pag` AS `TDP`,`ventas`.`tcam` AS `TCAM`,`ventas`.`inc_igv` AS `INI`,`ventas`.`st` AS `ST`,`ventas`.`igv` AS `IGV`,`ventas`.`tot` AS `TOT`,`ventas`.`mon` AS `MON`,`ventas`.`anu` AS `ANU`,`ventas`.`iser` AS `ISER`,`ventas`.`inum` AS `INUM`,`ventas`.`id_usuario` AS `IDU`,`ventas`.`gi` AS `GI`,`ventas`.`id_cliente` AS `ID_CLI`,`clientes`.`cli_dir` AS `DIR`,`ventas`.`id_tarjeta` AS `ID_TAR`,`tarjetas`.`tar_nombre` AS `TAR`,`tarjetas`.`tar_abre` AS `TAR_ABR`,`ventas`.`id_banco` AS `ID_BAN`,`bancos`.`ban_nombre` AS `BAN`,`ventas`.`adelanto` AS `ADE`,`ventas`.`acuenta` AS `ACU`,`ventas`.`pagar_con` AS `P_CON`,`ventas`.`vuelto` AS `VUE`,`ventas`.`ven_id_com` AS `VEN_ID_COM`,`ventas`.`ven_id_ven` AS `VEN_ID_VEN`,`comprobantes_b`.`com_nombre` AS `VEN_COM_REF`,`usuarios`.`nom` AS `USU`,`tipos_pagos`.`tipp_nombre` AS `TDP_`,`distritos`.`dis_nombre` AS `DIS`,month(`ventas`.`fec`) AS `IMES`,year(`ventas`.`fec`) AS `ANIO`,`meses`.`mes` AS `MES_`,`ventas`.`ven_p_des` AS `P_DES`,`ventas`.`ven_modalidad` AS `MODAL`,`ventas`.`ven_prin` AS `PRI_`,`ventas`.`ven_desc` AS `DES_`,`ventas`.`id_com` AS `COM_`,`clientes`.`cli_dni` AS `DNI`,`empresas`.`emp_nomc` AS `EMPC`,`ventas`.`ven_r_ser` AS `COT_SER`,`ventas`.`ven_r_num` AS `COT_NUM`,`ventas`.`ven_fe_ge` AS `GEN`,`ventas`.`ven_fe_nd` AS `ND`,`ventas`.`ven_cob_pag` AS `COB_PAG`,`ventas`.`ven_cob_fec` AS `COB_FEC`,date_format(`ventas`.`ven_cob_fec`,'%d-%m-%y') AS `COB_FEC_`,`ventas`.`ven_cob_hor` AS `COB_HOR`,`ventas`.`ven_cob_tim` AS `COB_TIM`,`ventas`.`ven_cob_usu` AS `COB_USU`,`ventas`.`ven_cob_kod` AS `COB_KOD`,`ventas`.`ven_cob_modo` AS `COB_MOD`,`ventas`.`ven_cob_moda` AS `COB_MODA`,`ventas`.`ven_cob_obs` AS `COB_OBS` from (((((((((((`ventas` join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) join `tarjetas` on(`ventas`.`id_tarjeta` = `tarjetas`.`id_tarjeta`)) join `bancos` on(`ventas`.`id_banco` = `bancos`.`id_banco`)) join `comprobantes` `comprobantes_b` on(`ventas`.`ven_id_com` = `comprobantes_b`.`id_comprobante`)) join `usuarios` on(`ventas`.`id_usuario` = `usuarios`.`id_usuario`)) join `tipos_pagos` on(`ventas`.`id_tip_pag` = `tipos_pagos`.`id_tip_pag`)) join `distritos` on(`clientes`.`cli_id_distrito` = `distritos`.`id_distrito`)) join `meses` on(month(`ventas`.`fec`) = `meses`.`id_mes`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vventas_ctas` AS select `ventas`.`id_venta` AS `ID`,`almacenes`.`alm_obs` AS `ALM`,`ventas`.`fec` AS `FEC`,date_format(`ventas`.`fec`,'%d-%m-%y') AS `FEC_`,`comprobantes`.`com_nombre` AS `COM`,`ventas`.`ser` AS `SER`,`ventas`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`ventas`.`id_tip_pag` AS `TDP`,`ventas`.`tcam` AS `TCAM`,`ventas`.`inc_igv` AS `INI`,`ventas`.`st` AS `ST`,`ventas`.`igv` AS `IGV`,`ventas`.`tot` AS `TOT`,`ventas`.`mon` AS `MON`,`ventas`.`anu` AS `ANU`,`ventas`.`iser` AS `ISER`,`ventas`.`inum` AS `INUM`,`ventas`.`id_usuario` AS `IDU`,`ventas`.`gi` AS `GI`,`ventas`.`id_cliente` AS `ID_CLI`,`clientes`.`cli_dir` AS `DIR`,`ventas`.`id_tarjeta` AS `ID_TAR`,`ventas`.`id_banco` AS `ID_BAN`,`ventas`.`adelanto` AS `ADE`,`ventas`.`acuenta` AS `ACU`,`ventas`.`pagar_con` AS `P_CON`,`ventas`.`vuelto` AS `VUE`,`ventas`.`ven_id_com` AS `VEN_ID_COM`,`ventas`.`ven_id_ven` AS `VEN_ID_VEN`,`comprobantes_b`.`com_nombre` AS `VEN_COM_REF`,`usuarios`.`nom` AS `USU`,month(`ventas`.`fec`) AS `IMES`,year(`ventas`.`fec`) AS `ANIO`,`ventas`.`ven_p_des` AS `P_DES`,`ventas`.`ven_modalidad` AS `MODAL`,`ventas`.`ven_prin` AS `PRI_`,`ventas`.`ven_desc` AS `DES_`,`ventas`.`id_com` AS `COM_`,`clientes`.`cli_dni` AS `DNI`,`empresas`.`emp_nomc` AS `EMPC`,`ventas`.`ven_r_ser` AS `COT_SER`,`ventas`.`ven_r_num` AS `COT_NUM`,`ventas`.`ven_fe_ge` AS `GEN`,`ventas`.`ven_fe_nd` AS `ND`,`ventas`.`ven_cob_pag` AS `COB_PAG`,`ventas`.`ven_cob_fec` AS `COB_FEC`,date_format(`ventas`.`ven_cob_fec`,'%d-%m-%y') AS `COB_FEC_`,`ventas`.`ven_cob_hor` AS `COB_HOR`,`ventas`.`ven_cob_tim` AS `COB_TIM`,`ventas`.`ven_cob_usu` AS `COB_USU`,`ventas`.`ven_cob_kod` AS `COB_KOD`,`ventas`.`ven_cob_modo` AS `COB_MOD`,`ventas`.`ven_cob_moda` AS `COB_MODA`,`ventas`.`ven_cob_obs` AS `COB_OBS`,`ventas`.`ven_cob_cta_id` AS `CTA_ID`,`cta_bancos`.`ban_nombre` AS `CTA_BAN`,`cuentas`.`cta_tipo` AS `CTA_TIP`,`cuentas`.`cta_nro` AS `CTA_NRO`,`cuentas`.`cta_mnd` AS `CTA_MND`,`ventas`.`ven_cob_cta_ope_nro` AS `CTA_OPE_NRO`,`ventas`.`ven_cob_cta_ope_fec` AS `CTA_OPE_FEC`,date_format(`ventas`.`ven_cob_cta_ope_fec`,'%d-%m-%y') AS `CTA_OPE_FEC_` from ((((((((`ventas` join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) join `comprobantes` `comprobantes_b` on(`ventas`.`ven_id_com` = `comprobantes_b`.`id_comprobante`)) join `usuarios` on(`ventas`.`id_usuario` = `usuarios`.`id_usuario`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `cuentas` on(`ventas`.`ven_cob_cta_id` = `cuentas`.`id_cta`)) join `bancos` `cta_bancos` on(`cuentas`.`cta_id_ban` = `cta_bancos`.`id_banco`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vventas_d` AS select `ventas_det`.`id_venta` AS `ID`,`ventas_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `CO`,`ventas_det`.`des` AS `DE`,`ventas_det`.`ca` AS `CA`,`ventas_det`.`pr` AS `PR`,`ventas_det`.`im` AS `IM`,`ventas_det`.`can_uni` AS `UNI` from (`ventas_det` join `productos` on(`ventas_det`.`id_producto` = `productos`.`id_producto`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vventas_det` AS select `ventas`.`id_venta` AS `ID`,`ventas`.`fec` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`ventas`.`ser` AS `SER`,`ventas`.`num` AS `NUM`,`ventas_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `COD`,`ventas_det`.`des` AS `DES`,`ventas_det`.`ca` AS `CA`,`ventas_det`.`pr` AS `PR`,`ventas_det`.`im` AS `IM`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`almacenes`.`alm_obs` AS `ALM`,`marcas`.`mar_nombre` AS `MAR`,`ventas`.`anu` AS `ANU`,`lineas`.`lin_nombre` AS `LIN`,`empresas`.`emp_nomc` AS `EMPC`,`ventas`.`ven_r_ser` AS `COT_SER`,`ventas`.`ven_r_num` AS `COT_NUM`,`comprobante_ref`.`com_nombre` AS `COM_REF`,`ventas`.`ven_id_ven` AS `VEN_ID_VEN` from (((((((((`ventas` join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `ventas_det` on(`ventas_det`.`id_venta` = `ventas`.`id_venta`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `productos` on(`ventas_det`.`id_producto` = `productos`.`id_producto`)) join `marcas` on(`marcas`.`id_marca` = `productos`.`pro_id_marca`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `comprobantes` `comprobante_ref` on(`ventas`.`ven_id_com` = `comprobante_ref`.`id_comprobante`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vventas_det2` AS select `ventas_det`.`id_venta` AS `ID`,`ventas_det`.`cx` AS `CX`,`ventas_det`.`id_producto` AS `IDP`,`ventas_det`.`ca` AS `CA`,`ventas_det`.`pr` AS `PR`,`ventas_det`.`im` AS `IMP`,`ventas_det`.`can_uni` AS `PIE`,`ventas_det`.`ca_control` AS `CA_CONTROL`,`ventas_det`.`dev` AS `DEV`,`ventas_det`.`dej` AS `DEJ`,`ventas_det`.`ca` - `ventas_det`.`ca_control` AS `T_SAL` from `ventas_det`;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vventas_fe` AS select `ventas`.`id_venta` AS `ID`,`almacenes`.`alm_obs` AS `ALM`,`ventas`.`fec` AS `FEC`,date_format(`ventas`.`fec`,'%d/%m/%Y') AS `FEC_FE`,`comprobantes`.`com_nombre` AS `COM`,`ventas`.`ser` AS `SER`,`ventas`.`num` AS `NUM`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`ventas`.`id_tip_pag` AS `TDP`,`ventas`.`tcam` AS `TCAM`,`ventas`.`inc_igv` AS `INI`,`ventas`.`st` AS `ST`,`ventas`.`igv` AS `IGV`,`ventas`.`tot` AS `TOT`,`ventas`.`mon` AS `MON`,`ventas`.`anu` AS `ANU`,`ventas`.`iser` AS `ISER`,`ventas`.`inum` AS `INUM`,`ventas`.`id_usuario` AS `IDU`,`ventas`.`gi` AS `GI`,`ventas`.`id_cliente` AS `ID_CLI`,`clientes`.`cli_dir` AS `DIR`,`ventas`.`id_tarjeta` AS `ID_TAR`,`tarjetas`.`tar_nombre` AS `TAR`,`tarjetas`.`tar_abre` AS `TAR_ABR`,`ventas`.`id_banco` AS `ID_BAN`,`bancos`.`ban_nombre` AS `BAN`,`ventas`.`adelanto` AS `ADE`,`ventas`.`acuenta` AS `ACU`,`ventas`.`pagar_con` AS `P_CON`,`ventas`.`vuelto` AS `VUE`,`ventas`.`ven_id_com` AS `VEN_ID_COM`,`ventas`.`ven_id_ven` AS `VEN_ID_VEN`,`comprobantes_b`.`com_nombre` AS `VEN_COM_REF`,`usuarios`.`nom` AS `USU`,`tipos_pagos`.`tipp_nombre` AS `TDP_`,`distritos`.`dis_nombre` AS `DIS`,month(`ventas`.`fec`) AS `IMES`,year(`ventas`.`fec`) AS `ANIO`,`meses`.`mes` AS `MES_`,`ventas`.`ven_p_des` AS `P_DES`,`ventas`.`ven_modalidad` AS `MODAL`,`ventas`.`ven_prin` AS `PRI_`,`ventas`.`ven_desc` AS `DES_`,`ventas`.`id_com` AS `COM_`,`clientes`.`cli_dni` AS `DNI`,`empresas`.`emp_nomc` AS `EMPC`,`ventas`.`ven_r_ser` AS `COT_SER`,`ventas`.`ven_r_num` AS `COT_NUM`,`clientes`.`cli_email` AS `EMAIL`,`ventas`.`ven_gia` AS `GIA`,`ventas`.`fec_ven` AS `FVCTO`,`empresas`.`emp_fe_ele` AS `EMP_FE_HAB`,`empresas`.`emp_fe_nom_com` AS `EMP_FE_NOM`,`empresas`.`emp_fe_ruc` AS `EMP_FE_RUC`,`empresas`.`emp_fe_dep` AS `EMP_FE_DEP`,`empresas`.`emp_fe_prv` AS `EMP_FE_PRV`,`empresas`.`emp_fe_dis` AS `EMP_FE_DIS`,`empresas`.`emp_fe_ubi` AS `EMP_FE_UBI`,`empresas`.`emp_fe_dir` AS `EMP_FE_DIR`,`empresas`.`emp_fe_ema` AS `EMP_FE_EMA`,`ventas`.`ven_fe_ge` AS `VEN_FE_GEN`,`ventas`.`ven_ubi_pai` AS `UBI_PAI`,`ventas`.`ven_ubi_dep` AS `UBI_DEP`,`ventas`.`ven_ubi_pro` AS `UBI_PRO`,`ventas`.`ven_ubi_dis` AS `UBI_DIS`,`ventas`.`ven_ubi_cod` AS `UBI_COD`,`ventas`.`ven_hash` AS `FE_HASH`,`ventas`.`ven_cli_dir` AS `VEN_CLIENTE_DIR` from (((((((((((`ventas` join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) join `tarjetas` on(`ventas`.`id_tarjeta` = `tarjetas`.`id_tarjeta`)) join `bancos` on(`ventas`.`id_banco` = `bancos`.`id_banco`)) join `comprobantes` `comprobantes_b` on(`ventas`.`ven_id_com` = `comprobantes_b`.`id_comprobante`)) join `usuarios` on(`ventas`.`id_usuario` = `usuarios`.`id_usuario`)) join `tipos_pagos` on(`ventas`.`id_tip_pag` = `tipos_pagos`.`id_tip_pag`)) join `distritos` on(`clientes`.`cli_id_distrito` = `distritos`.`id_distrito`)) join `meses` on(month(`ventas`.`fec`) = `meses`.`id_mes`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `vventas_uti` AS select `ventas`.`id_venta` AS `ID`,`almacenes`.`alm_nombre` AS `ALM`,`ventas`.`fec` AS `FEC`,`comprobantes`.`com_nombre` AS `COM`,`ventas`.`ser` AS `SER`,`ventas`.`num` AS `NUM`,`ventas`.`anu` AS `ANU`,`ventas`.`iser` AS `ISER`,`ventas`.`inum` AS `INUM`,`ventas_det`.`cx` AS `CX`,`productos`.`pro_codigo` AS `COD`,`productos`.`pro_des` AS `DES`,`ventas_det`.`ca` AS `CA`,`ventas_det`.`prc` AS `PRC`,`ventas_det`.`pr` AS `PRV`,(`ventas_det`.`pr` - `ventas_det`.`prc`) * `ventas_det`.`ca` AS `UTI` from ((((`ventas` join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`)) join `ventas_det` on(`ventas`.`id_venta` = `ventas_det`.`id_venta`)) join `productos` on(`ventas_det`.`id_producto` = `productos`.`id_producto`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `xxx_vcot_control` AS select `cotizaciones_det`.`id_producto` AS `IDP`,`cotizaciones_det`.`ca` AS `CA`,`cotizaciones_det`.`can_uni` AS `PIE`,`cotizaciones_det`.`ca_control` AS `CA_CONTROL`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones_det`.`dej` AS `DEJ`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`cotizaciones`.`fec` AS `FEC`,`cotizaciones`.`cot_pri` AS `PRI`,`cotizaciones`.`id_cotizacion` AS `ID_COT` from ((`cotizaciones` join `cotizaciones_det` on(`cotizaciones`.`id_cotizacion` = `cotizaciones_det`.`id_cotizacion`)) join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `z_vis_cotizaciones` AS select `cotizaciones`.`id_cotizacion` AS `ID`,`cotizaciones`.`iser` AS `ISER`,`cotizaciones`.`inum` AS `INUM`,`almacenes`.`id_almacen` AS `ID_ALM`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`almacenes`.`alm_obs` AS `ALM_NC` from (`cotizaciones` join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `z_vis_devoluciones` AS select `devoluciones`.`id_devolucion` AS `ID`,`devoluciones`.`dev_id_alm` AS `ID_ALM`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`devoluciones`.`dev_nro_` AS `NRO_`,`devoluciones`.`dev_tipo` AS `TIP` from (`devoluciones` join `almacenes` on(`devoluciones`.`dev_id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `z_vis_emp_alm` AS select `empresas`.`id_emp` AS `ID_EMP`,`almacenes`.`id_almacen` AS `ID_ALM`,`empresas`.`emp_nomc` AS `EMP_NC`,`empresas`.`emp_noml` AS `EMP_NL`,`almacenes`.`alm_obs` AS `ALM_NC`,`almacenes`.`alm_nombre` AS `ALM_NL` from (`almacenes` join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) where `empresas`.`id_emp` > 0 and `almacenes`.`id_almacen` > 0;

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `z_vis_ginterna` AS select `ginterna`.`id_gi` AS `ID`,`ginterna`.`gi_inum` AS `INUM`,`ginterna`.`gi_id_alm` AS `ID_ALM`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`ginterna`.`gi_iserie` AS `ISER` from (`ginterna` join `almacenes` on(`ginterna`.`gi_id_alm` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `z_vis_guias` AS select `guias`.`id_guia` AS `ID`,`guias`.`iser` AS `ISER`,`guias`.`inum` AS `INUM`,`almacenes`.`alm_id_empresa` AS `ID_EMP` from (`guias` join `almacenes` on(`guias`.`id_almacen` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `z_vis_ingresos` AS select `almacenes`.`alm_id_empresa` AS `ID_EMP`,`ingresos`.`id_ingreso` AS `ID`,`ingresos`.`fec` AS `FEC`,`ingresos`.`id_alm` AS `ID_ALM`,`ingresos`.`tot` AS `TOT`,`empresas`.`emp_nomc` AS `EC`,`usuarios`.`nom` AS `USU_NOM`,`ingresos`.`usu` AS `USU_KOD`,`ingresos`.`anu` AS `ANU`,`almacenes`.`alm_obs` AS `ALM_NC` from (((`ingresos` join `almacenes` on(`ingresos`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `usuarios` on(`ingresos`.`usu` = `usuarios`.`id_usuario`)) where `ingresos`.`anu` = 'N';

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `z_vis_rpt_cot` AS select `cotizaciones`.`id_cotizacion` AS `ID`,concat(`empresas`.`emp_nomc`,' / ',`almacenes`.`alm_obs`) AS `E_A`,`empresas`.`emp_nomc` AS `EMPC`,`almacenes`.`alm_obs` AS `ALMC`,'PROFORMA' AS `COM`,concat(`cotizaciones`.`ser`,'-',`cotizaciones`.`num`) AS `S_N`,`cotizaciones`.`ser` AS `SER`,`cotizaciones`.`num` AS `NUM`,`cotizaciones`.`fec` AS `FEC`,date_format(`cotizaciones`.`fec`,'%d-%m-%y') AS `FEC_`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`clientes`.`cli_dni` AS `DNI`,`distritos`.`dis_nombre` AS `DEP`,`cotizaciones`.`tot_real` AS `TOT_REAL`,`cotizaciones`.`tot_cob` AS `TOT_COB`,`cotizaciones`.`tot_real` - `cotizaciones`.`tot_cob` AS `SALDO`,`personal`.`per_nombre` AS `VEN`,`cotizaciones`.`anu` AS `ANU`,`cotizaciones`.`cot_pri` AS `PRI_` from (((((`cotizaciones` join `almacenes` on(`cotizaciones`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `clientes` on(`cotizaciones`.`id_cliente` = `clientes`.`id_cliente`)) join `distritos` on(`clientes`.`cli_id_distrito` = `distritos`.`id_distrito`)) join `personal` on(`cotizaciones`.`id_vendedor` = `personal`.`id_personal`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `z_vis_transferencias` AS select `transferencias`.`id_trans` AS `ID`,`transferencias`.`fec` AS `FEC`,`transferencias`.`tser_` AS `TSER_`,`transferencias`.`tnum_` AS `TNUM_`,`transferencias`.`id_alm_o` AS `ID_ALM_O`,`almacenes`.`alm_id_empresa` AS `ID_EMP_O` from (`transferencias` join `almacenes` on(`transferencias`.`id_alm_o` = `almacenes`.`id_almacen`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `z_vis_ventas` AS select `ventas`.`id_venta` AS `ID`,`almacenes`.`id_almacen` AS `ID_ALM`,`almacenes`.`alm_id_empresa` AS `ID_EMP`,`ventas`.`iser` AS `ISER`,`ventas`.`inum` AS `INUM`,`ventas`.`id_com` AS `ID_COM`,`comprobantes`.`com_nombre` AS `COM`,`almacenes`.`alm_obs` AS `ALM_NC` from ((`ventas` join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `z_viz_cot_pro` AS select 'PROFORMA' AS `COM`,`cotizaciones`.`fec` AS `FEC`,`cotizaciones_det`.`id_producto` AS `ID_PRO`,`productos`.`pro_codigo` AS `COD`,`lineas`.`lin_nombre` AS `LIN`,`productos`.`pro_des` AS `DES`,`cotizaciones_det`.`ca` * `cotizaciones_det`.`can_uni` AS `TOT_PIE`,`cotizaciones`.`cot_pri` AS `PRI_`,`cotizaciones_det`.`im` AS `IMP`,`cotizaciones`.`anu` AS `ANU` from (((`cotizaciones_det` join `productos` on(`cotizaciones_det`.`id_producto` = `productos`.`id_producto`)) join `cotizaciones` on(`cotizaciones_det`.`id_cotizacion` = `cotizaciones`.`id_cotizacion`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `z_viz_rpt_ven` AS select `ventas`.`id_venta` AS `ID`,concat(`empresas`.`emp_nomc`,' / ',`almacenes`.`alm_obs`) AS `E_A`,`empresas`.`emp_nomc` AS `EMPC`,`almacenes`.`alm_obs` AS `ALMC`,`comprobantes`.`com_nombre` AS `COM`,concat(`ventas`.`ser`,' / ',`ventas`.`num`) AS `S_N`,`ventas`.`ser` AS `SER`,`ventas`.`num` AS `NUM`,`ventas`.`fec` AS `FEC`,date_format(`ventas`.`fec`,'%d-%m-%y') AS `FEC_`,`clientes`.`cli_nombre` AS `CLI`,`clientes`.`cli_ruc` AS `RUC`,`clientes`.`cli_dni` AS `DNI`,`distritos`.`dis_nombre` AS `DEP`,`ventas`.`tot` AS `TOT_REAL`,`ventas`.`acuenta` AS `TOT_COB`,`ventas`.`tot` - `ventas`.`acuenta` AS `SALDO`,'-' AS `VEN`,`ventas`.`anu` AS `ANU`,`ventas`.`ven_prin` AS `PRI_` from (((((`ventas` join `almacenes` on(`ventas`.`id_alm` = `almacenes`.`id_almacen`)) join `empresas` on(`almacenes`.`alm_id_empresa` = `empresas`.`id_emp`)) join `clientes` on(`ventas`.`id_cliente` = `clientes`.`id_cliente`)) join `distritos` on(`clientes`.`cli_id_distrito` = `distritos`.`id_distrito`)) join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`));

CREATE ALGORITHM=UNDEFINED DEFINER=`k9zy30omkwy5`@`localhost` SQL SECURITY DEFINER VIEW `z_viz_ven_pro` AS select `comprobantes`.`com_nombre` AS `COM`,`ventas`.`fec` AS `FEC`,`ventas_det`.`id_producto` AS `ID_PRO`,`productos`.`pro_codigo` AS `COD`,`lineas`.`lin_nombre` AS `LIN`,`productos`.`pro_des` AS `DES`,`ventas_det`.`ca` * `ventas_det`.`can_uni` AS `TOT_PIE`,`ventas`.`ven_prin` AS `PRI_`,`ventas_det`.`im` AS `IMP`,`ventas`.`anu` AS `ANU` from ((((`ventas_det` join `ventas` on(`ventas_det`.`id_venta` = `ventas`.`id_venta`)) join `productos` on(`ventas_det`.`id_producto` = `productos`.`id_producto`)) join `lineas` on(`productos`.`pro_id_linea` = `lineas`.`id_linea`)) join `comprobantes` on(`ventas`.`id_com` = `comprobantes`.`id_comprobante`));
