ALTER TABLE Conceptos ADD TipoConRev INT DEFAULT(0) NOT NULL
GO
ALTER TABLE TarifCuentas ADD CdCueOtr VARCHAR(16)
GO
ALTER TABLE Formaspago ADD CodValera VARCHAR(10) DEFAULT('VAL')
GO
INSERT INTO adm_Opciones (IdOpc,Opcion,TipoDato,Valor,NivUp,nModulo)
 VALUES ('MPL','MANTENER PRECIOS DE REMISION','BOOLEAN','0',5,'MAIN')
GO
INSERT INTO Sys_ObjetosApp (IdObj,IdGrupo,SubModulo,IndObj,Nombre,Formulario,Permisos,NivelMinimo,NomArchivo)
 VALUES ('FRMBCS','NOMPRO','GEN',28,'Archivo Plano-Banco Caja Social','FRMBCS','S',0,'')
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsConceptos]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paInsConceptos]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paUpConceptos]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paUpConceptos]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryConceptos]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paQryConceptos]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryConceptosLta]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paQryConceptosLta]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsFormaspago]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paInsFormaspago]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryFormaspago]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paQryFormaspago]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paUpFormaspago]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paUpFormaspago]
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paQryConceptosLta] @pmIdDoc VARCHAR(3)=Null,@pmIdCom VARCHAR(3)=Null,@pmPdterminado INT=Null
,@pmInactivo  BIT=Null
 AS 
 SELECT IdConcepto,Concepto,C.IdDoc AS CdTipo,TipoDoc,C.IdCom AS CdTcmp,TipoCom,Vcmto,Imptos,Retfte,RetIca,Observacion,Pdterminado
,TrfaSanc,RndTotal,DcmtoEquiv,TipoContab,CdComNiif,CdComFiscal,CodCiaTdo,TipoConRev
,C.FechaAdd AS Fec_Add,C.FechaUpdate AS Fec_Upd,C.IdUsuario AS IdUsuari,Usuario,C.Inactivo AS Inactiv
 FROM Conceptos AS C INNER JOIN Sys_TiposDoc AS T ON C.IdDoc=T.IdDoc
 INNER JOIN TiposCom AS TC ON C.IdCom=TC.IdCom
 INNER JOIN adm_Usuarios AS U ON C.IdUsuario=U.IdUsuario
 WHERE C.IdDoc LIKE ISNULL(@pmIdDoc,'%') AND C.IdCom LIKE ISNULL(@pmIdCom,'%')
 AND (Pdterminado>=ISNULL(@pmPdterminado,-1)  AND Pdterminado<=ISNULL(@pmPdterminado,2147483647))
 AND  (C.Inactivo=ISNULL(@pmInactivo,0) or C.Inactivo=ISNULL(@pmInactivo,1))
 ORDER BY C.IdDoc,Concepto
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paUpConceptos] @pmIdConcepto VARCHAR(4),@pmConcepto VARCHAR(100),@pmIdDoc VARCHAR(3),@pmIdCom VARCHAR(3),@pmVcmto BIT,@pmImptos BIT,@pmRetfte BIT
,@pmRetIca BIT,@pmObservacion VARCHAR(150),@pmPdterminado INT,@pmTrfaSanc DECIMAL(14,4),@pmRndTotal INT,@pmDcmtoEquiv BIT,@pmInactivo BIT
,@pmTipoContab VARCHAR(10),@pmCdComNiif VARCHAR(3),@pmCdComFiscal VARCHAR(3),@pmCodCiaTdo CHAR(2),@pmTipoConRev INT,@pmFechaUpdate SMALLDATETIME
 AS 
 UPDATE Conceptos SET Concepto=@pmConcepto,IdDoc=@pmIdDoc,IdCom=@pmIdCom,Vcmto=@pmVcmto,Imptos=@pmImptos,Retfte=@pmRetfte,RetIca=@pmRetIca,Observacion=@pmObservacion
,Pdterminado=@pmPdterminado,TrfaSanc=@pmTrfaSanc,RndTotal=@pmRndTotal,Inactivo=@pmInactivo,DcmtoEquiv=@pmDcmtoEquiv
,TipoContab=@pmTipoContab,CdComNiif=@pmCdComNiif,CdComFiscal=@pmCdComFiscal,CodCiaTdo=@pmCodCiaTdo,TipoConRev=@pmTipoConRev,FechaUpdate=@pmFechaUpdate
 WHERE IdConcepto=@pmIdConcepto
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paQryConceptos] @pmIdConcepto VARCHAR(4)
 AS 
 SELECT IdConcepto,Concepto,IdDoc,IdCom,Vcmto,Imptos,Retfte,RetIca,Observacion,Pdterminado
,TrfaSanc,RndTotal,Inactivo,DcmtoEquiv,TipoContab,CdComNiif,CdComFiscal,CodCiaTdo,TipoConRev
,FechaAdd,FechaUpdate,IdUsuario
 FROM Conceptos
 WHERE IdConcepto=@pmIdConcepto
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInsConceptos] @pmIdConcepto VARCHAR(4),@pmConcepto VARCHAR(100),@pmIdDoc VARCHAR(3),@pmIdCom VARCHAR(3),@pmVcmto BIT,@pmImptos BIT
,@pmRetfte BIT,@pmRetIca BIT,@pmObservacion VARCHAR(150),@pmPdterminado INT,@pmTrfaSanc DECIMAL(14,4),@pmRndTotal INT,@pmDcmtoEquiv BIT
,@pmInactivo BIT,@pmTipoContab VARCHAR(10),@pmCdComNiif VARCHAR(3),@pmCdComFiscal VARCHAR(3),@pmCodCiaTdo CHAR(2),@pmTipoConRev INT
,@pmFechaAdd SMALLDATETIME,@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Conceptos (IdConcepto,Concepto,IdDoc,IdCom,Vcmto,Imptos,Retfte,RetIca,Observacion,Pdterminado,TrfaSanc,RndTotal,DcmtoEquiv
,Inactivo,FechaAdd,IdUsuario,TipoContab,CdComNiif,CdComFiscal,CodCiaTdo,TipoConRev)
 VALUES (@pmIdConcepto,@pmConcepto,@pmIdDoc,@pmIdCom,@pmVcmto,@pmImptos,@pmRetfte,@pmRetIca,@pmObservacion,@pmPdterminado,@pmTrfaSanc
,@pmRndTotal,@pmDcmtoEquiv,@pmInactivo,@pmFechaAdd,@pmIdUsuario,@pmTipoContab,@pmCdComNiif,@pmCdComFiscal,@pmCodCiaTdo,@pmTipoConRev)
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInsFormaspago] @pmIdForma VARCHAR(4),@pmFormaPago VARCHAR(50),@pmConsecutivo INT,@pmCuadreCaja BIT,@pmRefDcmto BIT
,@pmRefNit BIT,@pmRefBco BIT,@pmRefFech BIT,@pmRefAtza BIT,@pmRefOtro BIT,@pmVldRangos BIT,@pmVleConsumo BIT,@pmCodIntegrity VARCHAR(20),@pmCodValera VARCHAR(10),@pmInactivo BIT
 AS 
 INSERT INTO Formaspago (IdForma,FormaPago,Consecutivo,CuadreCaja,RefDcmto,RefNit,RefBco,RefFech,RefAtza,RefOtro,VldRangos,VleConsumo,CodIntegrity,CodValera,Inactivo)
 VALUES (@pmIdForma,@pmFormaPago,@pmConsecutivo,@pmCuadreCaja,@pmRefDcmto,@pmRefNit,@pmRefBco,@pmRefFech,@pmRefAtza
,@pmRefOtro,@pmVldRangos,@pmVleConsumo,@pmCodIntegrity,@pmCodValera,@pmInactivo)
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paUpFormaspago] @pmIdForma VARCHAR(4),@pmFormaPago VARCHAR(50),@pmConsecutivo INT,@pmCuadreCaja BIT
,@pmRefDcmto BIT,@pmRefNit BIT,@pmRefBco BIT,@pmRefFech BIT,@pmRefAtza BIT,@pmRefOtro BIT,@pmVldRangos BIT,@pmVleConsumo BIT
,@pmCodIntegrity VARCHAR(20),@pmCodValera VARCHAR(10),@pmInactivo BIT
 AS 
 UPDATE Formaspago SET FormaPago=@pmFormaPago,Consecutivo=@pmConsecutivo,CuadreCaja=@pmCuadreCaja,RefDcmto=@pmRefDcmto,RefNit=@pmRefNit
,RefBco=@pmRefBco,RefFech=@pmRefFech,RefAtza=@pmRefAtza,RefOtro=@pmRefOtro,VldRangos=@pmVldRangos,VleConsumo=@pmVleConsumo
,CodIntegrity=@pmCodIntegrity,CodValera=@pmCodValera,Inactivo=@pmInactivo
 WHERE IdForma=@pmIdForma
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paQryFormaspago] @pmIdForma VARCHAR(4)
 AS 
 IF @pmIdForma IS NULL
  SELECT IdForma,FormaPago,Consecutivo,CuadreCaja,RefDcmto,RefNit,RefBco,RefFech,RefAtza,RefOtro,VldRangos,VleConsumo,CodIntegrity,CodValera
  FROM Formaspago
  WHERE Inactivo=0
  ORDER BY Consecutivo
 ELSE
  SELECT IdForma,FormaPago,Consecutivo,CuadreCaja,RefDcmto,RefNit,RefBco,RefFech,RefAtza,RefOtro,VldRangos,VleConsumo,CodIntegrity,CodValera,Inactivo
  FROM Formaspago
  WHERE IdForma=@pmIdForma
GO
