ALTER TABLE Trn_RadicaVales ADD VrDescuento MONEY DEFAULT(0) NOT NULL
GO
ALTER TABLE Trn_DevVal ADD VrDescuento MONEY DEFAULT(0) NOT NULL
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsDevVal]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paInsDevVal]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsRadicaVales]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paInsRadicaVales]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryDevVal]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paQryDevVal]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryDevVal_Cr]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paQryDevVal_Cr]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryDevValLta]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paQryDevValLta]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryRadicaVales]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paQryRadicaVales]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryRadicaValesLta]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paQryRadicaValesLta]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryRadicaVales_Cr]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paQryRadicaVales_Cr]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paUpDevVal]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paUpDevVal]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paUpRadicaVales]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paUpRadicaVales]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsDevVal @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipDoc VARCHAR(3),@pmnRadica INT,@pmIdCiaDoc CHAR(2),@pmFecDoc SMALLDATETIME
,@pmIdTercero VARCHAR(16),@pmTotalPagos MONEY,@pmTotalCobros MONEY,@pmReferencia VARCHAR(50),@pmCxPagar BIT,@pmVrDescuento MONEY,@pmModdDev VARCHAR(10),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2)
,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmOrigenAdd VARCHAR(10),@pmTimeSys SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_DevVal (TipDev,Devolucion,IdCia,Fecha,IdConcepto,TipDoc,nRadica,IdCiaDoc,FecDoc,IdTercero,TotalPagos,TotalCobros,Referencia,CxPagar,VrDescuento,ModdDev,OrigenAdd,TipCom,Comprobante,IdCiaCom,Observacion,IdEstado,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDev,@pmDevolucion,@pmIdCia,@pmFecha,@pmIdConcepto,@pmTipDoc,@pmnRadica,@pmIdCiaDoc,@pmFecDoc,@pmIdTercero,@pmTotalPagos,@pmTotalCobros,@pmReferencia,@pmCxPagar,@pmVrDescuento,@pmModdDev,@pmOrigenAdd
,@pmTipCom,@pmComprobante,@pmIdCiaCom,@pmObservacion,@pmIdEstado,@pmTimeSys,@pmIdCiaCrea,@pmIdUsuario)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsRadicaVales @pmTipDoc VARCHAR(3),@pmnRadica INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmFechaVence SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmIdTercero VARCHAR(16)
,@pmTotalPagos MONEY,@pmTotalCobros MONEY,@pmReferencia VARCHAR(50),@pmCxPagar BIT,@pmVrDescuento MONEY,@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmAnulado BIT,@pmNumDev INT
,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmTimeSys SMALLDATETIME,@pmOrigenAdd VARCHAR(10),@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_RadicaVales (TipDoc,nRadica,IdCia,Fecha,FechaVence,IdConcepto,IdTercero,TotalPagos,TotalCobros,Referencia,CxPagar,VrDescuento,OrigenAdd,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,IdEstado,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDoc,@pmnRadica,@pmIdCia,@pmFecha,@pmFechaVence,@pmIdConcepto,@pmIdTercero,@pmTotalPagos,@pmTotalCobros,@pmReferencia,@pmCxPagar,@pmVrDescuento,@pmOrigenAdd,@pmTipCom,@pmComprobante,@pmIdCiaCom
,@pmAnulado,@pmNumDev,@pmFecDev,@pmObservacion,@pmIdEstado,@pmTimeSys,@pmIdCiaCrea,@pmIdUsuario)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paQryDevVal @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2)
 AS 
 SELECT TipDev,Devolucion,IdCia,Fecha,IdConcepto,TipDoc,nRadica,IdCiaDoc,FecDoc,IdTercero,TotalPagos,TotalCobros,Referencia,CxPagar,VrDescuento,ModdDev,OrigenAdd
,TipCom,Comprobante,IdCiaCom,Observacion,IdEstado,TimeSys,FecUpdate,IdCiaCrea,IdUsuario
 FROM Trn_DevVal
 WHERE TipDev=@pmTipDev AND Devolucion=@pmDevolucion AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paQryDevVal_Cr @pmTipDev VARCHAR(3),@pmDevolucionIni INT,@pmDevolucionFin INT,@pmIdCia CHAR(2)
 AS 
 SELECT TipDev,TipoDoc,Devolucion,D.IdCia AS CdCia,Compania,D.Fecha AS FechaDev,D.IdConcepto AS CdConcepto,Concepto,D.TipDoc AS TipRad,D.nRadica AS NumRadica,IdCiaDoc,FecDoc
,D.IdTercero AS NitTercero,T.RazonSocial AS NomTercero,TotalPagos,TotalCobros,D.Referencia AS DocReferencia,CxPagar,VrDescuento,ModdDev,OrigenAdd,TipCom,TipoCom,Comprobante,IdCiaCom
,D.Observacion AS Observ,D.IdEstado AS CdEstado,Estado,TimeSys,FecUpdate,IdCiaCrea,D.IdUsuario AS CdUsuario,Usuario,Leyenda
--detalles
,Item,TipoRango,IdRango,NumSerie,NumForma,V.Fecha AS FechaServ,HoraServ,IdCliente,CL.RazonSocial AS NomCliente,V.IdAgencia AS ValAgencia,Agencia,IdCuenta,NumMovil,CentCosto,Unidades,HoraRec,HoraEspera
,FactUnid,FactRutas,FactHoras,VrPago,VrCobro,PlacaVeh,CdConductor,NomConductor,CantPasaj,Usuarios,TipFac,NumFactura,IdCiaFac,FechaFac,V.Anulado AS ValAnulado,V.NumDev AS ValNumAnul,V.FecDev AS ValFechaDev
,V.Observacion AS ValObserv,FechaUp,CdUsuario
--datos del cliente
,CL.TipoId AS CliTipoId,CL.Dv AS CliDv,CL.Codigo AS CliCodigo,CL.NomCial AS CliNomCial,CL.Direccion AS CliDireccion,CL.IdLocal AS CliCdCiudad,L.Localidad AS NomCiudad,L.IdDep AS CdDep,Departamento
,CL.Telefono AS CliTelefono,CL.Fax AS CliFax,CL.e_mail AS CliEmail,CL.IdSector AS CdSector,SectorEco,CL.IdRegimen AS CdRegimen,Regimen,CL.TipEnte AS CliTipoEnte
 FROM Trn_DevVal AS D INNER JOIN Trn_Vales AS V ON D.TipDoc=V.TipDoc AND D.nRadica=V.nRadica AND D.IdCiaDoc=V.IdCia
 INNER JOIN  Terceros AS T ON D.IdTercero=T.IdTercero  INNER JOIN  Conceptos AS C ON D.IdConcepto=C.IdConcepto
 INNER JOIN Companias AS CN ON D.IdCia=CN.IdCia  INNER JOIN Sys_TiposDoc AS TD ON D.TipDev=TD.IdDoc
 INNER JOIN EstadoDoc AS ED ON D.IdEstado=ED.IdEstado  INNER JOIN adm_Usuarios AS U ON D.IdUsuario=U.IdUsuario
 INNER JOIN  Terceros AS CL ON V.IdCliente=CL.IdTercero
 INNER JOIN Localidades AS L ON CL.IdLocal=L.IdLocal  INNER JOIN Departamentos AS DP ON L.IdDep=DP.IdDep 
 INNER JOIN  RegimenDian AS RG ON CL.IdRegimen=RG.IdRegimen INNER JOIN SectoresEco AS SE ON CL.IdSector=SE.IdSector
 LEFT JOIN Agencias AS A ON V.IdAgencia=A.IdAgencia LEFT JOIN TiposCom AS TC ON D.TipCom=TC.IdCom
 WHERE TipDev=@pmTipDev AND Devolucion BETWEEN @pmDevolucionIni AND @pmDevolucionFin AND D.IdCia=@pmIdCia
 ORDER BY Devolucion
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paQryDevValLta @pmFechaIni SMALLDATETIME,@pmFechaFin SMALLDATETIME,@pmDevolucionIni INT=Null,@pmDevolucionFin INT=Null,@pmIdCia CHAR(2)=Null
,@pmIdConcepto VARCHAR(4)=Null,@pmIdTercero VARCHAR(16)=Null,@pmModdDev VARCHAR(10)=Null
 AS 
 SELECT Devolucion,D.IdCia AS CdCia,Compania,Fecha,D.IdConcepto AS CdConcepto,Concepto,TipDoc,nRadica,IdCiaDoc,FecDoc,D.IdTercero AS NitTercero,RazonSocial,TotalPagos,TotalCobros
,Referencia,CxPagar,VrDescuento,ModdDev,OrigenAdd,TipCom,Comprobante,IdCiaCom,D.Observacion AS Observ,D.IdEstado AS CdEstado,Estado,TimeSys,FecUpdate,IdCiaCrea,D.IdUsuario AS CdUsuario,Usuario,TipDev
 FROM Trn_DevVal AS D  INNER JOIN  Terceros AS T ON D.IdTercero=T.IdTercero  INNER JOIN  Conceptos AS C ON D.IdConcepto=C.IdConcepto
 INNER JOIN Companias AS CN ON D.IdCia=CN.IdCia  INNER JOIN EstadoDoc AS ED ON D.IdEstado=ED.IdEstado 
 INNER JOIN adm_Usuarios AS U ON D.IdUsuario=U.IdUsuario
 WHERE Fecha BETWEEN   @pmFechaIni AND @pmFechaFin AND D.IdCia LIKE ISNULL(@pmIdCia,'%%')
 AND Devolucion BETWEEN ISNULL(@pmDevolucionIni,0) AND ISNULL(@pmDevolucionFin,2147483647)
 AND D.IdConcepto  LIKE ISNULL(@pmIdConcepto,'%') AND D.IdTercero LIKE ISNULL(@pmIdTercero,'%')
 AND ModdDev LIKE ISNULL(@pmModdDev,'%')
 ORDER BY D.IdCia,Devolucion
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paQryRadicaVales @pmTipDoc VARCHAR(3),@pmnRadica INT,@pmIdCia CHAR(2)
 AS 
 SELECT TipDoc,nRadica,IdCia,Fecha,FechaVence,IdConcepto,IdTercero,TotalPagos,TotalCobros,Referencia,CxPagar,VrDescuento
,OrigenAdd,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,IdEstado,TimeSys,FecUpdate,IdCiaCrea,IdUsuario
 FROM Trn_RadicaVales
 WHERE TipDoc=@pmTipDoc AND nRadica=@pmnRadica AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paQryRadicaValesLta  @pmFechaIni SMALLDATETIME, @pmFechaFin SMALLDATETIME,@pmnRadicaIni INT=Null,@pmnRadicaFin INT=Null
,@pmIdCia CHAR(2)=Null,@pmIdTercero VARCHAR(16)=Null,@pmIdConcepto VARCHAR(4)=Null,@pmIdEstado VARCHAR(4)=Null,@pmAnulado BIT=Null
 AS 
 SELECT nRadica,IdCia,Fecha,FechaVence,R.IdConcepto AS CdConcepto ,Concepto,R.IdTercero AS NitTercero,RazonSocial,TotalPagos,TotalCobros,Referencia,CxPagar
,VrDescuento,OrigenAdd,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,R.Observacion AS Observ,R.IdEstado AS CdEstado,Estado,TimeSys,FecUpdate,IdCiaCrea
,R.IdUsuario AS IdUsuari,Usuario
 FROM Trn_RadicaVales AS R INNER JOIN Terceros AS T ON R.IdTercero=T.IdTercero
 INNER JOIN  Conceptos AS C ON R.IdConcepto=C.IdConcepto
 INNER JOIN EstadoDoc AS ED ON R.IdEstado=ED.IdEstado
 INNER JOIN adm_Usuarios AS U ON R.IdUsuario=U.IdUsuario
 WHERE  Fecha BETWEEN @pmFechaIni AND @pmFechaFin 
 AND nRadica BETWEEN ISNULL(@pmnRadicaIni,0) AND ISNULL(@pmnRadicaFin,2147483647)
 AND IdCia LIKE ISNULL(@pmIdCia,'%%')  AND R.IdTercero LIKE ISNULL(@pmIdTercero,'%')
 AND R.IdConcepto LIKE ISNULL(@pmIdConcepto,'%') AND R.IdEstado LIKE ISNULL(@pmIdEstado,'%')
AND (Anulado=ISNULL(@pmAnulado,0) or Anulado=ISNULL(@pmAnulado,1))
ORDER BY IdCia,nRadica
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paQryRadicaVales_Cr @pmTipDoc VARCHAR(3),@pmnRadicaIni INT,@pmnRadicaFin INT,@pmIdCia CHAR(2)
 AS 
 SELECT R.TipDoc AS CdTipDoc,TipoDoc,R.nRadica AS NumRadica,R.IdCia AS CdCia,Compania,R.Fecha AS FechaDoc,FechaVence,R.IdConcepto AS CdConcepto ,Concepto,R.IdTercero AS NitTercero
,T.RazonSocial AS NomTercero,TotalPagos,TotalCobros,R.Referencia AS DocReferncia,CxPagar,VrDescuento,OrigenAdd,TipCom,TipoCom,Comprobante,IdCiaCom,R.Anulado AS DocAnulado,R.NumDev AS DocNumDev,R.FecDev  AS DocFecDev
,R.Observacion AS Observ,R.IdEstado AS CdEstado,Estado,TimeSys,FecUpdate,IdCiaCrea,R.IdUsuario AS IdUsuari,Usuario,Leyenda
--detalles
,Item,TipoRango,IdRango,NumSerie,NumForma,V.Fecha AS FechaServ,HoraServ,IdCliente,CL.RazonSocial AS NomCliente,V.IdAgencia AS ValAgencia,Agencia,IdCuenta,NumMovil,CentCosto,Unidades,HoraRec,HoraEspera
,FactUnid,FactRutas,FactHoras,VrPago,VrCobro,PlacaVeh,CdConductor,NomConductor,CantPasaj,Usuarios,TipFac,NumFactura,IdCiaFac,FechaFac,V.Anulado AS ValAnulado,V.NumDev AS ValNumAnul,V.FecDev AS ValFechaDev
,V.Observacion AS ValObserv,FechaUp,CdUsuario
--datos del cliente
,CL.TipoId AS CliTipoId,CL.Dv AS CliDv,CL.Codigo AS CliCodigo,CL.NomCial AS CliNomCial,CL.Direccion AS CliDireccion,CL.IdLocal AS CliCdCiudad,L.Localidad AS NomCiudad,L.IdDep AS CdDep,Departamento
,CL.Telefono AS CliTelefono,CL.Fax AS CliFax,CL.e_mail AS CliEmail,CL.IdSector AS CdSector,SectorEco,CL.IdRegimen AS CdRegimen,Regimen,CL.TipEnte AS CliTipoEnte
 FROM Trn_RadicaVales AS R INNER JOIN Trn_Vales AS V ON R.TipDoc=V.TipDoc AND R.nRadica=V.nRadica AND R.IdCia=V.IdCia
 INNER JOIN  Terceros AS T ON R.IdTercero=T.IdTercero  INNER JOIN  Conceptos AS C ON R.IdConcepto=C.IdConcepto
 INNER JOIN Companias AS CN ON R.IdCia=CN.IdCia  INNER JOIN Sys_TiposDoc AS TD ON R.TipDoc=TD.IdDoc
 INNER JOIN EstadoDoc AS ED ON R.IdEstado=ED.IdEstado  INNER JOIN adm_Usuarios AS U ON R.IdUsuario=U.IdUsuario
 INNER JOIN  Terceros AS CL ON V.IdCliente=CL.IdTercero
 INNER JOIN Localidades AS L ON CL.IdLocal=L.IdLocal  INNER JOIN Departamentos AS D ON L.IdDep=D.IdDep 
 INNER JOIN  RegimenDian AS RG ON CL.IdRegimen=RG.IdRegimen INNER JOIN SectoresEco AS SE ON CL.IdSector=SE.IdSector
 LEFT JOIN Agencias AS A ON V.IdAgencia=A.IdAgencia LEFT JOIN TiposCom AS TC ON R.TipCom=TC.IdCom
  WHERE R.TipDoc=@pmTipDoc AND R.nRadica BETWEEN @pmnRadicaIni  AND @pmnRadicaFin AND R.IdCia=@pmIdCia
 ORDER BY R.nRadica
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paUpDevVal @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipDoc VARCHAR(3),@pmnRadica INT,@pmIdCiaDoc CHAR(2),@pmFecDoc SMALLDATETIME,@pmIdTercero VARCHAR(16)
,@pmTotalPagos MONEY,@pmTotalCobros MONEY,@pmReferencia VARCHAR(50),@pmCxPagar BIT,@pmVrDescuento MONEY,@pmModdDev VARCHAR(10),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmObservacion VARCHAR(250)
,@pmIdEstado VARCHAR(4),@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_DevVal SET Fecha=@pmFecha,IdConcepto=@pmIdConcepto,TipDoc=@pmTipDoc,nRadica=@pmnRadica,IdCiaDoc=@pmIdCiaDoc,FecDoc=@pmFecDoc,IdTercero=@pmIdTercero,TotalPagos=@pmTotalPagos,TotalCobros=@pmTotalCobros,Referencia=@pmReferencia
,CxPagar=@pmCxPagar,ModdDev=@pmModdDev,TipCom=@pmTipCom,Comprobante=@pmComprobante,IdCiaCom=@pmIdCiaCom,Observacion=@pmObservacion,VrDescuento=@pmVrDescuento,IdEstado=@pmIdEstado,FecUpdate=@pmFecUpdate 
 WHERE TipDev=@pmTipDev AND Devolucion=@pmDevolucion AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paUpRadicaVales @pmTipDoc VARCHAR(3),@pmnRadica INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmFechaVence SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmIdTercero VARCHAR(16),@pmTotalPagos MONEY,@pmTotalCobros MONEY
,@pmReferencia VARCHAR(50),@pmCxPagar BIT,@pmVrDescuento MONEY,@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_RadicaVales SET Fecha=@pmFecha,FechaVence=@pmFechaVence,IdConcepto=@pmIdConcepto,IdTercero=@pmIdTercero,TotalPagos=@pmTotalPagos,TotalCobros=@pmTotalCobros,Referencia=@pmReferencia,CxPagar=@pmCxPagar
,TipCom=@pmTipCom,Comprobante=@pmComprobante,IdCiaCom=@pmIdCiaCom,Anulado=@pmAnulado,NumDev=@pmNumDev,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado,FecUpdate=@pmFecUpdate,VrDescuento=@pmVrDescuento
 WHERE TipDoc=@pmTipDoc AND nRadica=@pmnRadica AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
INSERT INTO Sys_TiposDocCue (IdDoc,IdClase,ClaseCuenta,TipoMov)
 VALUES ('VAL',10,'DESCUENTOS','C')
INSERT INTO Sys_TiposDocCue (IdDoc,IdClase,ClaseCuenta,TipoMov)
 VALUES ('DRV',10,'DESCUENTOS','D')
GO
INSERT INTO Sys_Roles  (IdObj,IdRole,Funcion)
 VALUES ('FRMDVAL','DCT','Modificar Descuento')
GO
