Closed GoogleCodeExporter closed 8 years ago
No se despliegan hs, solo se tienen en cuenta funcionarios activos o dados de
baja entre la fecha dada
insert into consultasempleados values (0,"LISTADO ENVIAR A ESTUDIO CONTABLE -
MENSUALES","Genera el listado que sera enviado al estudio contable para la
liquidacion de los funcionarios MENSUALES","SELECT @rownum:=@rownum+1 AS
Nro,CONS.* from (SELECT @rownum:=0) r, (SELECT empPrim.NroEmpleado,
empPrim.Apellido, empPrim.Nombre, empPrim.NumeroDocumento,
empPrim.ServicioActual, empPrim.Turno,
empPrim.FechaIngreso,empPrim.FechaBaja,empPrim.ValorHora, /* ANTIGUEDAD */
(SELECT CAST(if(extract(YEAR FROM from_days(datediff(curdate(),
emp.FechaIngreso))) < 11, concat(extract(YEAR FROM
from_days(datediff(curdate(), emp.FechaIngreso))),'%'),'10%') AS CHAR) as
Antiguedad FROM empleados emp where emp.NroEmpleado=empPrim.NroEmpleado) as
ANTIGUEDAD, /* ARMADO */(SELECT CAST(if( emp.CapacitadoPortarArma=1 and
emp.EnServicioArmado=1,if(curdate()>='2012-01-01' ,'5%','2.5%'),'') AS CHAR)
from empleados emp where emp.Activo=1 and NroEmpleado=empPrim.NroEmpleado) as
ARMADO, /* NO LLEVA TICKETS ALIMENTACION
*/IF(empPrim.NoLlevaTicketsAlimentacion =1,'NO','') as 'Tickets
Alimentacion',/* EXTRAS DESCUENTOS */ (SELECT /*ADELANTO*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between 'FECHADESDE' and 'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='ADELANTO') as ADELANTO,(SELECT
/*ANDA*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel,extrasliquidacion el,
tipoextraliquidacion tel WHERE el.IdExtraLiquidacion = cel.IdExtraLiquidacion
and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha between'FECHADESDE' and
'FECHAHASTA' and el.idTipoExtraLiquidacion = tel.idTipoExtraLiquidacion and
tel.Nombre='ANDA') as ANDA, (SELECT /*RET. COOP.*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel,extrasliquidacion
el,tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between 'FECHADESDE' and'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='RET. COOP.') as 'RET. COOP.',(SELECT
/*MOVISTAR*/IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuot
a)),sum(el.CantHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between'FECHADESDE' and 'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='MOVISTAR')as MOVISTAR,(SELECT
/*RELIQ. HORAS*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el,tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between 'FECHADESDE' and'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='RELIQ. HORAS') as 'RELIQ.
HORAS',(SELECT
/*UNIFORME*/IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuot
a)),sum(el.CantHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between'FECHADESDE' and 'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='UNIFORME') as 'UNIFORME',(SELECT
/*CURSO*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el,tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between 'FECHADESDE' and'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='CURSO') as CURSO,(SELECT /*CARNET DE
SALUD*/IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),s
um(el.CantHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel,
extrasliquidacion el,tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between 'FECHADESDE' and'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='CARNET DE SALUD') as 'CARNET DE
SALUD',(SELECT /*DTO.
SINDICAL*/IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)
),sum(el.CantHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel,
extrasliquidacion el,tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado =empPrim.NroEmpleado and cel.Fecha
between'FECHADESDE' and 'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='DTO. SINDICAL') as 'DTO.
SINDICAL',(SELECT /*DESC.
ADM.*/IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),su
m(el.CantHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel,
extrasliquidacion el,tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between 'FECHADESDE' and'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='DESC. ADM.') as 'DESC. ADM.',(SELECT
/*BOLETOS*/IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota
)),sum(el.CantHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between'FECHADESDE' and 'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='BOLETOS') as BOLETOS, /*ABONOS*/
(SELECT /*HS A
SUMAR*/IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),s
um(el.CantHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel,
extrasliquidacion el,tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between 'FECHADESDE' and'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='HS A SUMAR') as 'HS A SUMAR',(SELECT
/*COMPLEMENTO*/IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorC
uota)),sum(el.CantHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion
cel,extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion
= cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between'FECHADESDE' and 'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='COMPLEMENTO') as
'COMPLEMENTO',(SELECT /*HS. LIC.
SIND.*/IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),s
um(el.CantHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel,
extrasliquidacion el,tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between 'FECHADESDE' and 'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='HS. LIC. SIND.') as 'HS. LIC.
SIND.',(SELECT
/*PAP*/IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),s
um(el.CantHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel,
extrasliquidacion el,tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between 'FECHADESDE' and 'FECHAHASTA' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre='PAP') as PAP, /*CUOTA SINDICAL*/
CAST(if(empPrim.EnSindicato=1,'1%','') as CHAR) as CUOTA_SINDICAL FROM
Empleados empPrim, TiposCargos cargo WHERE empPrim.IdCargo=cargo.IdCargo and
cargo.TipoFacturacion='MENSUAL' and (empPrim.Activo=1 OR empPrim.FechaBaja
between 'FECHADESDE' and 'FECHAHASTA') GROUP BY empPrim.NroEmpleado,
empPrim.Nombre, empPrim.Apellido) AS CONS ORDER BY Nro",1);
45 min.
Original comment by juanga...@gmail.com
on 27 Jun 2011 at 5:21
El insert con la consulta modificada segun lo ultimo del ticket 74
insert into consultasempleados values (0,"MENSUALES","MENSUALES","SELECT
@rownum:=@rownum+1 AS Nro,CONS.* from (SELECT @rownum:=0) r, (SELECT
empPrim.NroEmpleado as '#', empPrim.Apellido, empPrim.Nombre,
empPrim.NumeroDocumento as 'C.I', empPrim.ServicioActual, empPrim.Turno,
empPrim.FechaIngreso,empPrim.FechaBaja,empPrim.ValorHora, CAST((SELECT /*HS A
SUMAR*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(TIME_TO_SEC(el.CantHs_TipoExtraLlevaHs)))) FROM cuotasextrasliquidacion
cel, extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion
= cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'HS A SUMAR\') as CHAR) as \'HS A
SUMAR\',(SELECT /*HS. LIC. SIND.*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'HS. LIC. SIND.\') as \'HS. LIC.
SIND.\',(SELECT /*PAP*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'PAP\') as PAP,(SELECT
/*COMPLEMENTO*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'COMPLEMENTO\') as \'COMPLEMENTO\',
/* NO LLEVA TICKETS ALIMENTACION */IF(empPrim.NoLlevaTicketsAlimentacion
=1,\'NO\',\'\') as \'Tickets Alimentacion\',/* ANTIGUEDAD */ (SELECT
CAST(if(extract(YEAR FROM from_days(datediff(curdate(), emp.FechaIngreso))) <
11, concat(extract(YEAR FROM from_days(datediff(curdate(),
emp.FechaIngreso))),\'%\'),\'10%\') AS CHAR) as Antiguedad FROM empleados emp
where emp.NroEmpleado=empPrim.NroEmpleado) as ANTIGUEDAD, /* ARMADO */(SELECT
CAST(if( emp.CapacitadoPortarArma=1 and
emp.EnServicioArmado=1,if(curdate()>=\'2012-01-01\' ,\'5%\',\'2.5%\'),\'\') AS
CHAR) from empleados emp where emp.Activo=1 and
NroEmpleado=empPrim.NroEmpleado) as ARMADO,/* EXTRAS DESCUENTOS */ (SELECT
/*RETENCION JUDICIAL*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'RETENCION JUDICIAL\') as 'RETENCION
JUDICIAL', (SELECT /*ANDA*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'ANDA\') as ANDA, (SELECT /*RET.
COOP.*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'RET. COOP.\') as \'RET.
COOP.\',(SELECT /*ADELANTO*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'ADELANTO\') as ADELANTO, (SELECT
/*RELIQ. HORAS*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'RELIQ. HORAS\') as \'RELIQ.
HORAS\', (SELECT /*DESC. ADM.*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'DESC. ADM.\') as \'DESC.
ADM.\',(SELECT /*BOLETOS*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'BOLETOS\') as BOLETOS, (SELECT
/*MOVISTAR*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'MOVISTAR\')as MOVISTAR,(SELECT
/*UNIFORME*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'UNIFORME\') as \'UNIFORME\',(SELECT
/*CURSO*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'CURSO\') as CURSO,(SELECT /*CARNET
DE SALUD*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'CARNET DE SALUD\') as \'CARNET DE
SALUD\', /*CUOTA SINDICAL*/ CAST(if(empPrim.EnSindicato=1,\'1%\',\'\') as CHAR)
as CUOTA_SINDICAL, (SELECT /*DTO. SINDICAL*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),sum(el.C
antHs_TipoExtraLlevaHs)) FROM cuotasextrasliquidacion cel, extrasliquidacion
el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'DTO. SINDICAL\') as \'DTO.
SINDICAL\' FROM Empleados empPrim, TiposCargos cargo WHERE
empPrim.IdCargo=cargo.IdCargo and cargo.TipoFacturacion='MENSUAL' and
(empPrim.Activo=1 OR empPrim.FechaBaja between 'FECHADESDE' and 'FECHAHASTA')
GROUP BY empPrim.NroEmpleado, empPrim.Nombre, empPrim.Apellido) AS CONS ORDER
BY Nro",1);
15 min
Original comment by juanga...@gmail.com
on 29 Jun 2011 at 5:47
Cambia nuevamente por cambio en tipo de dato
insert into consultasempleados values (0,"MENSUALES","MENSUALES","SELECT
@rownum:=@rownum+1 AS Nro,CONS.* from (SELECT @rownum:=0) r, (SELECT
empPrim.NroEmpleado as '#', empPrim.Apellido, empPrim.Nombre,
empPrim.NumeroDocumento as 'C.I', empPrim.ServicioActual, empPrim.Turno,
empPrim.FechaIngreso,empPrim.FechaBaja,empPrim.ValorHora, CAST((SELECT /*HS A
SUMAR*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'HS A SUMAR\') as CHAR) as \'HS A
SUMAR\',CAST((SELECT /*HS. LIC. SIND.*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'HS. LIC. SIND.\') as CHAR) as \'HS.
LIC. SIND.\',CAST((SELECT /*PAP*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'PAP\') as CHAR) as PAP,CAST((SELECT
/*COMPLEMENTO*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'COMPLEMENTO\') as CHAR) as
\'COMPLEMENTO\', /* NO LLEVA TICKETS ALIMENTACION
*/IF(empPrim.NoLlevaTicketsAlimentacion =1,\'NO\',\'\') as \'Tickets
Alimentacion\',/* ANTIGUEDAD */ CAST((SELECT CAST(if(extract(YEAR FROM
from_days(datediff(curdate(), emp.FechaIngreso))) < 11, concat(extract(YEAR
FROM from_days(datediff(curdate(), emp.FechaIngreso))),\'%\'),\'10%\') AS CHAR)
as Antiguedad FROM empleados emp where emp.NroEmpleado=empPrim.NroEmpleado) AS
CHAR) as ANTIGUEDAD, /* ARMADO */CAST((SELECT CAST(if(
emp.CapacitadoPortarArma=1 and
emp.EnServicioArmado=1,if(curdate()>=\'2012-01-01\' ,\'5%\',\'2.5%\'),\'\') AS
CHAR) from empleados emp where emp.Activo=1 and
NroEmpleado=empPrim.NroEmpleado) AS CHAR) as ARMADO,/* EXTRAS DESCUENTOS */
CAST((SELECT /*RETENCION JUDICIAL*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'RETENCION JUDICIAL\') AS CHAR) as
'RETENCION JUDICIAL', CAST((SELECT /*ANDA*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'ANDA\') AS CHAR) as ANDA,
CAST((SELECT /*RET. COOP.*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'RET. COOP.\') as CHAR) as \'RET.
COOP.\',CAST((SELECT /*ADELANTO*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'ADELANTO\') AS CHAR) as ADELANTO,
CAST((SELECT /*RELIQ. HORAS*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'RELIQ. HORAS\') as CHAR) as
\'RELIQ. HORAS\', CAST((SELECT /*DESC. ADM.*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'DESC. ADM.\') as CHAR) as \'DESC.
ADM.\',CAST((SELECT /*BOLETOS*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'BOLETOS\') AS CHAR) as BOLETOS,
CAST((SELECT /*MOVISTAR*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'MOVISTAR\') AS CHAR) as
MOVISTAR,CAST((SELECT /*UNIFORME*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'UNIFORME\') as CHAR) as
\'UNIFORME\',CAST((SELECT /*CURSO*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'CURSO\') AS CHAR) as
CURSO,CAST((SELECT /*CARNET DE SALUD*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'CARNET DE SALUD\') as CHAR) as
\'CARNET DE SALUD\', /*CUOTA SINDICAL*/
CAST(if(empPrim.EnSindicato=1,\'1%\',\'\') AS CHAR) as CUOTA_SINDICAL,
CAST((SELECT /*DTO. SINDICAL*/
IF(tel.LlevaHs=0,sum(if(el.Signo=0,cel.ValorCuota*(-1),cel.ValorCuota)),SEC_TO_T
IME(SUM(el.CantHs_TipoExtraLlevaHsEnSegs))) FROM cuotasextrasliquidacion cel,
extrasliquidacion el, tipoextraliquidacion tel WHERE el.IdExtraLiquidacion =
cel.IdExtraLiquidacion and el.IdEmpleado = empPrim.NroEmpleado and cel.Fecha
between \'FECHADESDE\' and \'FECHAHASTA\' and el.idTipoExtraLiquidacion =
tel.idTipoExtraLiquidacion and tel.Nombre=\'DTO. SINDICAL\') as CHAR) as \'DTO.
SINDICAL\' FROM Empleados empPrim, TiposCargos cargo WHERE
empPrim.IdCargo=cargo.IdCargo and cargo.TipoFacturacion='MENSUAL' and
(empPrim.Activo=1 OR empPrim.FechaBaja between 'FECHADESDE' and 'FECHAHASTA')
GROUP BY empPrim.NroEmpleado, empPrim.Nombre, empPrim.Apellido) AS CONS ORDER
BY Nro",1);
Original comment by juanga...@gmail.com
on 29 Jun 2011 at 6:56
30 minutos adicionales por el cambio de tipo de CantHs_TipoExtraLlevaHsEnSeg en
extraliquidacion.
Original comment by juanga...@gmail.com
on 29 Jun 2011 at 7:20
Original issue reported on code.google.com by
juanga...@gmail.com
on 27 Jun 2011 at 4:31