ALTER TABLE LogPrestFactDet ADD TarifIvaInt DECIMAL(14,4) DEFAULT(0)
,VrIvaInt MONEY DEFAULT(0),TarifRetInt DECIMAL(14,4) DEFAULT(0),VrRetInt MONEY DEFAULT(0)
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryLogPrestFactFmt]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [dbo].[paQryLogPrestFactFmt]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsLogPrestFactDet]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [dbo].[paInsLogPrestFactDet]
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[paQryLogPrestFactFmt] @pmNumeroIni INT,@pmNumeroFin INT
 AS 
 SELECT L.Numero AS NumReg,L.Fecha AS FecProc,TipoProc,EstadoProc,Observacion,TimeSys,IdUsuario,Nombre
,Item,TipDoc,IdPrestamo,IdCia,ItemCuo,NumCuota,D.Fecha AS FecCausac,FecVence,VrTotal,TasaEfeMes,TasaEfeDia,IdCliente,IdAgencia,IdVend,Concepto,CodLinCred
,FecInicio,FecFinal,DiasLiquida,Estado,TipFac,Factura,IdCiaFac,FechaFac,Referencia,Comentario,NomCliente,TarifIvaInt,VrIvaInt,TarifRetInt,VrRetInt
 FROM LogPrestFact AS L LEFT JOIN LogPrestFactDet AS D ON L.Numero=D.Numero
 WHERE L.Numero BETWEEN @pmNumeroIni AND @pmNumeroFin
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInsLogPrestFactDet] @pmNumero INT,@pmItem INT,@pmTipDoc VARCHAR(3),@pmIdPrestamo INT,@pmIdCia CHAR(2),@pmItemCuo INT,@pmNumCuota INT,@pmFecha SMALLDATETIME,@pmFecVence SMALLDATETIME,@pmVrTotal MONEY
,@pmTasaEfeMes DECIMAL(16,8),@pmTasaEfeDia DECIMAL(16,8),@pmIdCliente VARCHAR(16),@pmIdAgencia VARCHAR(16),@pmIdVend VARCHAR(16),@pmConcepto VARCHAR(10),@pmCodLinCred VARCHAR(4),@pmFecInicio SMALLDATETIME
,@pmFecFinal SMALLDATETIME,@pmDiasLiquida DECIMAL(14,4),@pmEstado INT,@pmTipFac VARCHAR(3),@pmFactura INT,@pmIdCiaFac CHAR(2),@pmFechaFac SMALLDATETIME,@pmReferencia VARCHAR(50),@pmComentario VARCHAR(250),@pmNomCliente VARCHAR(150)
,@pmTarifIvaInt DECIMAL(14,4),@pmVrIvaInt MONEY,@pmTarifRetInt DECIMAL(14,4),@pmVrRetInt MONEY
 AS 
 INSERT INTO LogPrestFactDet (Numero,Item,TipDoc,IdPrestamo,IdCia,ItemCuo,NumCuota,Fecha,FecVence,VrTotal,TasaEfeMes,TasaEfeDia,IdCliente,IdAgencia,IdVend,Concepto,CodLinCred,FecInicio,FecFinal,DiasLiquida,Estado
,TipFac,Factura,IdCiaFac,FechaFac,Referencia,Comentario,NomCliente,TarifIvaInt,VrIvaInt,TarifRetInt,VrRetInt)
 VALUES (@pmNumero,@pmItem,@pmTipDoc,@pmIdPrestamo,@pmIdCia,@pmItemCuo,@pmNumCuota,@pmFecha,@pmFecVence,@pmVrTotal,@pmTasaEfeMes,@pmTasaEfeDia,@pmIdCliente,@pmIdAgencia,@pmIdVend,@pmConcepto,@pmCodLinCred
,@pmFecInicio,@pmFecFinal,@pmDiasLiquida,@pmEstado,@pmTipFac,@pmFactura,@pmIdCiaFac,@pmFechaFac,@pmReferencia,@pmComentario,@pmNomCliente,@pmTarifIvaInt,@pmVrIvaInt,@pmTarifRetInt,@pmVrRetInt)
GO
