ALTER TABLE Trn_Nomina ADD CantModifica INT DEFAULT(0) NOT NULL,NE_Estado INT DEFAULT(0) NOT NULL,NE_Prefijo VARCHAR(20)
,NE_Numero INT DEFAULT(0) NOT NULL,NE_FecEnvio DATETIME,NE_CUNE VARCHAR(500),NE_QR IMAGE
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsNomina]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paInsNomina]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryNomina_Cr]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paQryNomina_Cr]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryNomina_Cpn]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paQryNomina_Cpn]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryNomina]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paQryNomina]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsNomina_Sel]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paInsNomina_Sel]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paUpNomina]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paUpNomina]
GO

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paQryNomina_Cpn]  @pmIdPeriodo VARCHAR(8),@pmMes VARCHAR(6),@pmKeyRegistro VARCHAR(30)=Null,@pmIdEmpleado VARCHAR(16)=Null
,@pmIdNom VARCHAR(4)=Null,@pmIdDep VARCHAR(4)=Null,@pmEsRetiro BIT=Null,@pmNLiqRet INT=Null
 AS 
 SELECT  N.IdEmpleado AS IdEmpldo,Apellidos,Nombres,N.NContrato AS NumContrato,N.IdPeriodo AS IdPerdo,FecInicial,FecFinal,Cantidad,CantNoRem,VrDevengado,VrDeducido
,N.IdDep AS CodDep,Dependencia,N.IdInstala AS CodInst,Instlacion,N.IdCCosto AS CodCcto,CCosto,N.IdSubCos AS CodSubcen,SubCosto,N.IdNom AS CodNom,TipoNomina,Asistencia,NoDevenga
,TipoLiq,N.VrSalario AS VrSalBasico,N.pVehiculo AS PlacaVeh,TipCom,Comprobante,IdCiaCom,N.Observacion AS Observ,N.IdEstado AS Nom_IdEstdo,EN.Estado AS Nom_Estado,EsRetiro,NLiqRet
,N.CantModifica,N.NE_Estado,N.NE_Prefijo,N.NE_Numero,N.NE_FecEnvio,N.NE_CUNE,N.NE_QR,N.KeyRegistro AS KeyRegstro,TimeSys,N.FecUpdate AS FecUpd,N.IdUsuario AS IdUsuari,Usuario
--datos detalle de nomina
,Item,D.IdConcepto AS CodConcepto,Concepto,Detalle,CantDevg,CantDed,VrUnitario,VrTotDevg,VrTotDed,D.Unidad AS Undad,ClaseLiq,VrOrigen,D.Tarifa AS TarifaBase,DiasCalc,DiasNov,CodFondo,FD.Fondo AS Det_Fondo
,NPrestamo,NCuota,OrigCargue,VrBaseLiq,ClaseCon
--Datos empleado
,Codigo,IdLugarCed,Localidad,E.Direccion AS Dirccion,Telefono,TelMovil,e_mail,E.IdProf AS CodProf,Profesion,E.IdClase AS CodClaCta,ClaseCuenta,NumCuenta,E.IdBanco AS CodBanco,Banco,IdFonPen,FP.Fondo AS FondoPen
,IdFonEps,FS.Fondo AS FondoEps,IdFonArp,FR.Fondo AS FondoArp,IdCajaCom,CC.Fondo AS CajaComp,EsCondtor,FecNacmto,Licencia,CatLicencia,VigLicencia,E.IdLugar AS CodLugar,LugarLic,TallaCam,TallaPan,TallaZap,E.Inactivo AS Emp_Inactvo
--datos del contrato
,C.IdTipCon AS CodTipCon,TipoContrato,FecIngreso,FecRetiro,Indefinido,C.IdCargo AS CodCargo,Cargo,C.IdArea AS CodArea,Area,C.IdClase AS CodClaRie,ClaseRiesgo,CR.Tarifa AS TarifaRie,VrAuxTrans,SalMinimo,SalIntegral,FPnomina,ATFinMes,SegFinMes,DchDotacion,DchCafeteria
,C.IdEstado AS Con_IdEstdo,ECO.Estado AS Con_Estado,C.Inactivo AS Con_inactivo,C.IdJornada AS CodJnada,Jornada,TipoTrabj
,NumVeh,TipoAdmon,VehPropio,VrATransMes
 FROM Trn_Nomina AS N INNER JOIN Trn_NomDetalle AS D ON N.IdPeriodo=D.IdPeriodo AND N.KeyRegistro=D.KeyRegistro
 INNER JOIN Empleados AS E ON N.IdEmpleado=E.IdEmpleado INNER JOIN  Emp_Contrato AS C ON N.NContrato=C.NContrato
 INNER JOIN Dependencias AS DP ON N.IdDep=DP.IdDep  INNER JOIN Instalaciones AS I ON N.IdInstala=I.IdInstala
 INNER JOIN CentroCosto AS CO ON N.IdCCosto=CO.IdCCosto  INNER JOIN SubCentros AS SC ON N.IdSubCos=SC.IdSubCos
 INNER JOIN TiposNom AS TN ON N.IdNom=TN.IdNom INNER JOIN EstadoDoc AS EN ON N.IdEstado=EN.IdEstado 
 INNER JOIN adm_Usuarios AS U ON N.IdUsuario=U.IdUsuario
 INNER JOIN NomConceptos AS CN ON D.IdConcepto=CN.IdConcepto INNER JOIN Localidades AS L ON E.IdLugarCed=L.IdLocal
 INNER JOIN Profesiones AS P ON E.IdProf=P.IdProf   INNER JOIN ClaseCta AS CT ON E.IdClase=CT.IdClase
 INNER JOIN Bancos AS B ON E.IdBanco=B.IdBanco  INNER JOIN Fondos AS FP ON E.IdFonPen=FP.IdFondo
 INNER JOIN Fondos AS FS ON E.IdFonEps=FS.IdFondo  INNER JOIN Fondos AS FR ON E.IdFonArp=FR.IdFondo
 INNER JOIN Fondos AS CC ON E.IdCajaCom=CC.IdFondo INNER JOIN ExpLicencias AS EL ON E.IdLugar=EL.IdLugar
 INNER JOIN TiposCon AS TC ON C.IdTipCon=TC.IdTipCon
 INNER JOIN Cargos AS CG ON C.IdCargo=CG.IdCargo  INNER JOIN Areas AS AR ON C.IdArea=AR.IdArea
 INNER JOIN ClaseRie AS CR ON C.IdClase=CR.IdClase INNER JOIN Jornadas AS J ON C.IdJornada=J.IdJornada
 INNER JOIN EstadoDoc AS ECO ON C.IdEstado=ECO.IdEstado  LEFT JOIN Fondos AS FD ON D.CodFondo=FD.IdFondo
 LEFT JOIN NomVehiculos AS VH ON N.pVehiculo=VH.IdVehiculo
 WHERE  SUBSTRING(N.IdPeriodo,1,6)=@pmMes AND ClaseLiq IN ('NOMINA','NOVEDAD','LIQUDACION')
 AND N.IdPeriodo LIKE ISNULL(@pmIdPeriodo,'%')  AND N.KeyRegistro LIKE ISNULL(@pmKeyRegistro,'%') 
 AND N.IdNom like ISNULL(@pmIdNom,'%') AND  N.IdDep LIKE ISNULL(@pmIdDep,'%') AND N.IdEmpleado LIKE ISNULL(@pmIdEmpleado,'%')
 AND (NLiqRet>=ISNULL(@pmNLiqRet,-1)  AND NLiqRet<=ISNULL(@pmNLiqRet,2147483647))
 AND (EsRetiro=ISNULL(@pmEsRetiro,0) or EsRetiro=ISNULL(@pmEsRetiro,1))
 ORDER BY N.KeyRegistro,Item
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[paQryNomina_Cr]  @pmIdPeriodo VARCHAR(8),@pmKeyRegistro VARCHAR(30)=Null,@pmIdEmpleado VARCHAR(16)=Null,@pmIdNom VARCHAR(4)=Null,@pmIdDep VARCHAR(4)=Null
,@pmEsRetiro BIT=Null,@pmNLiqRet INT=Null
 AS 
 SELECT  N.IdEmpleado AS IdEmpldo,Apellidos,Nombres,N.NContrato AS NumContrato,N.IdPeriodo AS IdPerdo,FecInicial,FecFinal,Cantidad,CantNoRem,VrDevengado,VrDeducido
,N.IdDep AS CodDep,Dependencia,N.IdInstala AS CodInst,Instlacion,N.IdCCosto AS CodCcto,CCosto,N.IdSubCos AS CodSubcen,SubCosto,N.IdNom AS CodNom,TipoNomina,Asistencia,NoDevenga
,TipoLiq,N.VrSalario AS VrSalBasico,N.pVehiculo AS PlacaVeh,TipCom,Comprobante,IdCiaCom,N.Observacion AS Observ,N.IdEstado AS Nom_IdEstdo,EN.Estado AS Nom_Estado,EsRetiro,NLiqRet
,N.CantModifica,N.NE_Estado,N.NE_Prefijo,N.NE_Numero,N.NE_FecEnvio,N.NE_CUNE,N.NE_QR,N.KeyRegistro AS KeyRegstro,TimeSys,N.FecUpdate AS FecUpd,N.IdUsuario AS IdUsuari,Usuario
--datos detalle de nomina
,Item,D.IdConcepto AS CodConcepto,Concepto,Detalle,CantDevg,CantDed,VrUnitario,VrTotDevg,VrTotDed,D.Unidad AS Undad,ClaseLiq,VrOrigen,D.Tarifa AS TarifaBase,DiasCalc,DiasNov,CodFondo,FD.Fondo AS Det_Fondo
,NPrestamo,NCuota,OrigCargue,VrBaseLiq,ClaseCon
--Datos empleado
,Codigo,IdLugarCed,Localidad,E.Direccion AS Dirccion,Telefono,TelMovil,e_mail,E.IdProf AS CodProf,Profesion,E.IdClase AS CodClaCta,ClaseCuenta,NumCuenta,E.IdBanco AS CodBanco,Banco,IdFonPen,FP.Fondo AS FondoPen
,IdFonEps,FS.Fondo AS FondoEps,IdFonArp,FR.Fondo AS FondoArp,IdCajaCom,CC.Fondo AS CajaComp,EsCondtor,FecNacmto,Licencia,CatLicencia,VigLicencia,E.IdLugar AS CodLugar,LugarLic,TallaCam,TallaPan,TallaZap,E.Inactivo AS Emp_Inactvo
--datos del contrato
,C.IdTipCon AS CodTipCon,TipoContrato,FecIngreso,FecRetiro,Indefinido,C.IdCargo AS CodCargo,Cargo,C.IdArea AS CodArea,Area,C.IdClase AS CodClaRie,ClaseRiesgo,CR.Tarifa AS TarifaRie,VrAuxTrans,SalMinimo,SalIntegral,FPnomina,ATFinMes,SegFinMes,DchDotacion,DchCafeteria
,C.IdEstado AS Con_IdEstdo,ECO.Estado AS Con_Estado,C.Inactivo AS Con_inactivo,C.IdJornada AS CodJnada,Jornada,TipoTrabj
,NumVeh,TipoAdmon,VehPropio,VrATransMes
 FROM Trn_Nomina AS N INNER JOIN Trn_NomDetalle AS D ON N.IdPeriodo=D.IdPeriodo AND N.KeyRegistro=D.KeyRegistro
 INNER JOIN Empleados AS E ON N.IdEmpleado=E.IdEmpleado INNER JOIN  Emp_Contrato AS C ON N.NContrato=C.NContrato
 INNER JOIN Dependencias AS DP ON N.IdDep=DP.IdDep  INNER JOIN Instalaciones AS I ON N.IdInstala=I.IdInstala
 INNER JOIN CentroCosto AS CO ON N.IdCCosto=CO.IdCCosto  INNER JOIN SubCentros AS SC ON N.IdSubCos=SC.IdSubCos
 INNER JOIN TiposNom AS TN ON N.IdNom=TN.IdNom INNER JOIN EstadoDoc AS EN ON N.IdEstado=EN.IdEstado 
 INNER JOIN adm_Usuarios AS U ON N.IdUsuario=U.IdUsuario
 INNER JOIN NomConceptos AS CN ON D.IdConcepto=CN.IdConcepto INNER JOIN Localidades AS L ON E.IdLugarCed=L.IdLocal
 INNER JOIN Profesiones AS P ON E.IdProf=P.IdProf   INNER JOIN ClaseCta AS CT ON E.IdClase=CT.IdClase
 INNER JOIN Bancos AS B ON E.IdBanco=B.IdBanco  INNER JOIN Fondos AS FP ON E.IdFonPen=FP.IdFondo
 INNER JOIN Fondos AS FS ON E.IdFonEps=FS.IdFondo  INNER JOIN Fondos AS FR ON E.IdFonArp=FR.IdFondo
 INNER JOIN Fondos AS CC ON E.IdCajaCom=CC.IdFondo INNER JOIN ExpLicencias AS EL ON E.IdLugar=EL.IdLugar
 INNER JOIN TiposCon AS TC ON C.IdTipCon=TC.IdTipCon
 INNER JOIN Cargos AS CG ON C.IdCargo=CG.IdCargo  INNER JOIN Areas AS AR ON C.IdArea=AR.IdArea
 INNER JOIN ClaseRie AS CR ON C.IdClase=CR.IdClase INNER JOIN Jornadas AS J ON C.IdJornada=J.IdJornada
 INNER JOIN EstadoDoc AS ECO ON C.IdEstado=ECO.IdEstado  LEFT JOIN Fondos AS FD ON D.CodFondo=FD.IdFondo
 LEFT JOIN NomVehiculos AS VH ON N.pVehiculo=VH.IdVehiculo
 WHERE N.IdPeriodo LIKE ISNULL(@pmIdPeriodo,'%')  AND N.KeyRegistro LIKE ISNULL(@pmKeyRegistro,'%') AND N.IdNom like ISNULL(@pmIdNom,'%')
 AND  N.IdDep LIKE ISNULL(@pmIdDep,'%') AND N.IdEmpleado LIKE ISNULL(@pmIdEmpleado,'%')
 AND (NLiqRet>=ISNULL(@pmNLiqRet,-1)  AND NLiqRet<=ISNULL(@pmNLiqRet,2147483647))
 AND (EsRetiro=ISNULL(@pmEsRetiro,0) or EsRetiro=ISNULL(@pmEsRetiro,1))
 ORDER BY N.KeyRegistro,Item
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[paInsNomina_Sel]  @pmIdEmpleado  VARCHAR(16),@pmNewCedula VARCHAR(16)
 AS 
 INSERT INTO Trn_Nomina (IdPeriodo,KeyRegistro,IdEmpleado,FecInicial,FecFinal,Cantidad,VrDevengado,VrDeducido,NContrato,IdDep
,IdInstala,IdCCosto,IdSubCos,IdNom,VrSalario,VrATransMes,pVehiculo,TipCom,Comprobante,IdCiaCom,Observacion,IdEstado,EsRetiro,NLiqRet,TipoLiq,CantNoRem,TimeSys,IdUsuario
,CdTipoCot,SubTipo_Cot,Sal_Integral,TipoIdent,NotasAportante,CantModifica,NE_Estado,NE_Prefijo,NE_Numero,NE_FecEnvio,NE_CUNE,NE_QR)
 SELECT  IdPeriodo,@pmNewCedula +CAST(NContrato AS VARCHAR(10)) +CASE EsRetiro WHEN 1 THEN '_1' ELSE '_0'  END,@pmNewCedula,FecInicial,FecFinal,Cantidad,VrDevengado
,VrDeducido,NContrato,IdDep,IdInstala,IdCCosto,IdSubCos,IdNom,VrSalario,VrATransMes,pVehiculo,TipCom,Comprobante,IdCiaCom,Observacion,IdEstado,EsRetiro,NLiqRet,TipoLiq,CantNoRem
,TimeSys,IdUsuario,CdTipoCot,SubTipo_Cot,Sal_Integral,TipoIdent,NotasAportante,CantModifica,NE_Estado,NE_Prefijo,NE_Numero,NE_FecEnvio,NE_CUNE,NE_QR
 FROM Trn_Nomina 
 WHERE IdEmpleado=@pmIdEmpleado
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInsNomina] @pmIdPeriodo VARCHAR(8),@pmKeyRegistro VARCHAR(30),@pmIdEmpleado VARCHAR(16),@pmFecInicial SMALLDATETIME,@pmFecFinal SMALLDATETIME,@pmCantidad DECIMAL(10,4),@pmVrDevengado MONEY,@pmVrDeducido MONEY,@pmNContrato INT,@pmIdDep VARCHAR(4)
,@pmIdInstala VARCHAR(4),@pmIdCCosto VARCHAR(16),@pmIdSubCos VARCHAR(16),@pmIdNom VARCHAR(4),@pmVrSalario MONEY,@pmVrATransMes MONEY,@pmpVehiculo VARCHAR(10),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmEsRetiro BIT,@pmNLiqRet INT
,@pmTipoLiq CHAR(1),@pmCantNoRem DECIMAL(10,4),@pmCdTipoCot VARCHAR(4),@pmSubTipo_Cot VARCHAR(3),@pmSal_Integral BIT,@pmTipoIdent CHAR(1),@pmNotasAportante VARCHAR(250),@pmCantModifica INT,@pmNE_Estado INT,@pmNE_Prefijo VARCHAR(20),@pmNE_Numero INT,@pmNE_FecEnvio DATETIME
,@pmNE_CUNE VARCHAR(500),@pmTimeSys SMALLDATETIME,@pmIdUsuario VARCHAR(11),@pmFecUpdate SMALLDATETIME
 AS 
 INSERT INTO Trn_Nomina (IdPeriodo,KeyRegistro,IdEmpleado,FecInicial,FecFinal,Cantidad,VrDevengado,VrDeducido,NContrato,IdDep,IdInstala,IdCCosto,IdSubCos,IdNom,VrSalario,VrATransMes,pVehiculo,TipCom,Comprobante,IdCiaCom,Observacion,IdEstado,EsRetiro,NLiqRet,TipoLiq,CantNoRem,TimeSys,FecUpdate,IdUsuario
,CdTipoCot,SubTipo_Cot,Sal_Integral,TipoIdent,NotasAportante,CantModifica,NE_Estado,NE_Prefijo,NE_Numero,NE_FecEnvio,NE_CUNE,NE_QR)
 VALUES (@pmIdPeriodo,@pmKeyRegistro,@pmIdEmpleado,@pmFecInicial,@pmFecFinal,@pmCantidad,@pmVrDevengado,@pmVrDeducido,@pmNContrato,@pmIdDep,@pmIdInstala,@pmIdCCosto,@pmIdSubCos,@pmIdNom,@pmVrSalario,@pmVrATransMes,@pmpVehiculo,@pmTipCom,@pmComprobante,@pmIdCiaCom,@pmObservacion,@pmIdEstado
,@pmEsRetiro,@pmNLiqRet,@pmTipoLiq,@pmCantNoRem,@pmTimeSys,@pmFecUpdate,@pmIdUsuario,@pmCdTipoCot,@pmSubTipo_Cot,@pmSal_Integral,@pmTipoIdent,@pmNotasAportante,@pmCantModifica,@pmNE_Estado,@pmNE_Prefijo,@pmNE_Numero,@pmNE_FecEnvio,@pmNE_CUNE,Null)
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paUpNomina] @pmIdPeriodo VARCHAR(8),@pmKeyRegistro VARCHAR(30),@pmIdEmpleado VARCHAR(16),@pmFecInicial SMALLDATETIME,@pmFecFinal SMALLDATETIME,@pmCantidad DECIMAL(10,4),@pmVrDevengado MONEY,@pmVrDeducido MONEY,@pmNContrato INT,@pmIdDep VARCHAR(4)
,@pmIdInstala VARCHAR(4),@pmIdCCosto VARCHAR(16),@pmIdSubCos VARCHAR(16),@pmIdNom VARCHAR(4),@pmVrSalario MONEY,@pmVrATransMes MONEY,@pmpVehiculo VARCHAR(10),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4)
,@pmEsRetiro BIT,@pmNLiqRet INT,@pmTipoLiq CHAR(1),@pmCantNoRem DECIMAL(10,4),@pmCdTipoCot VARCHAR(4),@pmSubTipo_Cot VARCHAR(3),@pmSal_Integral BIT,@pmTipoIdent CHAR(1),@pmNotasAportante VARCHAR(250),@pmCantModifica INT,@pmNE_Estado INT,@pmNE_Prefijo VARCHAR(20)
,@pmNE_Numero INT,@pmNE_FecEnvio DATETIME,@pmNE_CUNE VARCHAR(500),@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_Nomina SET IdEmpleado=@pmIdEmpleado,FecInicial=@pmFecInicial,FecFinal=@pmFecFinal,Cantidad=@pmCantidad,VrDevengado=@pmVrDevengado,VrDeducido=@pmVrDeducido,NContrato=@pmNContrato,IdDep=@pmIdDep,IdInstala=@pmIdInstala,IdCCosto=@pmIdCCosto,IdSubCos=@pmIdSubCos,IdNom=@pmIdNom
,VrSalario=@pmVrSalario,VrATransMes=@pmVrATransMes,pVehiculo=@pmpVehiculo,TipCom=@pmTipCom,Comprobante=@pmComprobante,IdCiaCom=@pmIdCiaCom,Observacion=@pmObservacion,IdEstado=@pmIdEstado,EsRetiro=@pmEsRetiro,FecUpdate=@pmFecUpdate,NLiqRet=@pmNLiqRet,TipoLiq=@pmTipoLiq,CantNoRem=@pmCantNoRem
,CdTipoCot=@pmCdTipoCot,SubTipo_Cot=@pmSubTipo_Cot,Sal_Integral=@pmSal_Integral,TipoIdent=@pmTipoIdent,NotasAportante=@pmNotasAportante,CantModifica=@pmCantModifica,NE_Estado=@pmNE_Estado,NE_Prefijo=@pmNE_Prefijo,NE_Numero=@pmNE_Numero,NE_FecEnvio=@pmNE_FecEnvio,NE_CUNE=@pmNE_CUNE
 WHERE IdPeriodo=@pmIdPeriodo AND KeyRegistro=@pmKeyRegistro
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paQryNomina] @pmIdPeriodo VARCHAR(8),@pmKeyRegistro VARCHAR(30)
 AS 
 SELECT IdPeriodo,KeyRegistro,IdEmpleado,FecInicial,FecFinal,Cantidad,CantNoRem,VrDevengado,VrDeducido,NContrato,IdDep,IdInstala,IdCCosto,IdSubCos,IdNom
,VrSalario,VrATransMes,pVehiculo,TipCom,Comprobante,IdCiaCom,Observacion,IdEstado,EsRetiro,NLiqRet,TipoLiq,TimeSys,FecUpdate,IdUsuario
,CdTipoCot,SubTipo_Cot,Sal_Integral,TipoIdent,NotasAportante,CantModifica,NE_Estado,NE_Prefijo,NE_Numero,NE_FecEnvio,NE_CUNE,NE_QR
 FROM Trn_Nomina
 WHERE IdPeriodo=@pmIdPeriodo AND KeyRegistro LIKE ISNULL(@pmKeyRegistro,'%')
 ORDER BY KeyRegistro
GO
