-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `cbox_practice`
--

-- --------------------------------------------------------

--
-- Stand-in structure for view `vercomprobantes`
-- (See below for the actual view)
--
CREATE TABLE `vercomprobantes` (
`id_comp` int(11)
,`nro_talonario` int(11)
,`id_talonario` int(11)
,`txt_nro_talonario` varchar(100)
,`tipo_comp` varchar(50)
,`id_tipo_comp` int(11)
,`tipo_comp_afip` int(11)
,`nro_comp` int(11)
,`txt_nro_comp` varchar(100)
,`cae` varchar(50)
,`importe_total` double
,`importe_neto` double
,`neto_21` double
,`neto_105` double
,`importe_exento` double
,`importe_iva` double
,`importe_alicuota` double
,`codfactura` int(11)
,`fecha_operacion` date
,`hora_operacion` time
,`id_vendedor` int(11)
,`vendedor` varchar(150)
,`cuenta` int(11)
,`cliente` varchar(300)
,`cuit` varchar(11)
,`dias_transcurridos` int(7)
,`fecha_comp` datetime
,`fecha_vto` varchar(20)
);

-- --------------------------------------------------------

--
-- Structure for view `vercomprobantes`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`cbox`@`localhost` SQL SECURITY DEFINER VIEW `vercomprobantes`  AS  select `cmp`.`id_comp` AS `id_comp`,`vtipcomp`.`nro_talonario` AS `nro_talonario`,`vtipcomp`.`id_talonario` AS `id_talonario`,`agregar_caracter`(4,cast(`vtipcomp`.`nro_talonario` as char(50) charset latin1),'0',1) AS `txt_nro_talonario`,`vtipcomp`.`tipo_comp` AS `tipo_comp`,`vtipcomp`.`id_tipo_comp` AS `id_tipo_comp`,`vtipcomp`.`tipo_comp_afip` AS `tipo_comp_afip`,`cmp`.`nro_comp` AS `nro_comp`,`agregar_caracter`(8,cast(`cmp`.`nro_comp` as char(50) charset latin1),'0',1) AS `txt_nro_comp`,`cmp`.`cae` AS `cae`,`cmp`.`importe_total` AS `importe_total`,`cmp`.`importe_neto` AS `importe_neto`,`cmp`.`neto_21` AS `neto_21`,`cmp`.`neto_105` AS `neto_105`,`cmp`.`importe_exento` AS `importe_exento`,`cmp`.`importe_iva` AS `importe_iva`,`cmp`.`importe_alicuota` AS `importe_alicuota`,`fac`.`codfactura` AS `codfactura`,`fac`.`fecha_operacion` AS `fecha_operacion`,`fac`.`hora_operacion` AS `hora_operacion`,`vend`.`id` AS `id_vendedor`,`vend`.`nombre` AS `vendedor`,`cli`.`cuenta` AS `cuenta`,`cli`.`apenom` AS `cliente`,`cli`.`cuilt` AS `cuit`,(to_days(now()) - to_days(`fac`.`fecha_operacion`)) AS `dias_transcurridos`,`cmp`.`fecha_comp` AS `fecha_comp`,`cmp`.`fecha_vto` AS `fecha_vto` from ((((`comprobantes` `cmp` join `vertalonarios_tipocomp` `vtipcomp` on((`cmp`.`id_talonario` = `vtipcomp`.`id_talonario`))) join `facturas` `fac` on((`cmp`.`id_fk_factura` = `fac`.`codfactura`))) left join `user` `vend` on((`fac`.`id_vendedor` = `vend`.`id`))) left join `cliente` `cli` on((`fac`.`id_cliente` = `cli`.`cuenta`))) ;
COMMIT;

