ALTER TABLE LogRemesasDet ADD CantViajes INT DEFAULT(0)
GO
ALTER TABLE LogIntMoraDet ADD BaseIvaMora MONEY DEFAULT(0) NOT NULL,PorcBaseIva DECIMAL(14,4) DEFAULT(0) NOT NULL
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsLogRemesasDet]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paInsLogRemesasDet]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsLogIntMoraDet]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paInsLogIntMoraDet]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryLogIntMoraDet]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paQryLogIntMoraDet]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInsLogRemesasDet] @pmClaveReg VARCHAR(10),@pmItem INT,@pmIdMercancia VARCHAR(16),@pmDescripcion VARCHAR(250),@pmCantidad DECIMAL(14,4),@pmPesoNeto DECIMAL(14,4),@pmVolumen DECIMAL(14,4),@pmUndMed VARCHAR(10),@pmTarifaClie MONEY,@pmTarifaPago MONEY,@pmVrDeclarado MONEY,@pmVrSeguro MONEY,@pmIdCliente VARCHAR(16),@pmNitRemite VARCHAR(16),@pmRemitente VARCHAR(250)
,@pmDirOrigen VARCHAR(250),@pmNitDestntario VARCHAR(16),@pmDestinatario VARCHAR(250),@pmDirDestino VARCHAR(250),@pmIdOrigen VARCHAR(10),@pmIdDestino VARCHAR(10),@pmReferencia1 VARCHAR(50),@pmReferencia2 VARCHAR(50),@pmReferencia3 VARCHAR(50),@pmDocCliente VARCHAR(30),@pmSedeRem VARCHAR(10),@pmSedeDest VARCHAR(10),@pmCodServicio VARCHAR(10),@pmTelDestin VARCHAR(50)
,@pmNumGuia VARCHAR(20),@pmCodUsuario VARCHAR(20),@pmEstadoReg INT,@pmRemesa INT,@pmIdCia CHAR(2),@pmObservacion VARCHAR(2000),@pmUndTarifa VARCHAR(10),@pmUndTarifPago VARCHAR(10),@pmTipoTarifa VARCHAR(10),@pmTipoMintrans VARCHAR(10),@pmTipoRemesa VARCHAR(10),@pmTipoRuta CHAR(1),@pmFechaRem SMALLDATETIME,@pmFechaEntrega SMALLDATETIME,@pmPlacaVeh VARCHAR(10),@pmNumRemolque VARCHAR(10)
,@pmIdConductor VARCHAR(16),@pmCodRuta VARCHAR(4),@pmIdAgencia VARCHAR(16),@pmNumRemision DECIMAL(18,2),@pmTarifaSeguro DECIMAL(14,4),@pmPesoContVacio DECIMAL(14,4),@pmPactoCargue BIT,@pmHorasPactoCargue INT,@pmMinPactoCargue INT,@pmHoraCitaCargue SMALLDATETIME,@pmHoraLlegaCargue SMALLDATETIME,@pmHoraEntraCargue SMALLDATETIME,@pmHoraSaleCargue SMALLDATETIME
,@pmPactoDescargue BIT,@pmHorasPactoDescargue INT,@pmMinPactoDescargue INT,@pmHoraCitaDescargue SMALLDATETIME,@pmHoraLlegaDescargue SMALLDATETIME,@pmHoraEntraDescargue SMALLDATETIME,@pmHoraSaleDescargue SMALLDATETIME,@pmTomadorPoliza CHAR(1),@pmPolizaSeguro VARCHAR(50),@pmNitCiaPoliza VARCHAR(16),@pmNomCiaPoliza VARCHAR(150),@pmFecVencePol SMALLDATETIME,@pmCantViajes INT
 AS 
 INSERT INTO LogRemesasDet (ClaveReg,Item,IdMercancia,Descripcion,Cantidad,PesoNeto,Volumen,UndMed,TarifaClie,TarifaPago,VrDeclarado,VrSeguro,IdCliente,NitRemite,Remitente,DirOrigen,NitDestntario,Destinatario,DirDestino,IdOrigen,IdDestino,Referencia1,Referencia2,Referencia3,DocCliente,SedeRem,SedeDest,CodServicio,TelDestin,NumGuia,CodUsuario,EstadoReg,Remesa,IdCia,Observacion,UndTarifa
,UndTarifPago,TipoTarifa,TipoMintrans,TipoRemesa,TipoRuta,FechaRem,FechaEntrega,PlacaVeh,NumRemolque,IdConductor,CodRuta,IdAgencia,NumRemision,TarifaSeguro,PesoContVacio,PactoCargue,HorasPactoCargue,MinPactoCargue,HoraCitaCargue,HoraLlegaCargue,HoraEntraCargue,HoraSaleCargue,PactoDescargue,HorasPactoDescargue,MinPactoDescargue,HoraCitaDescargue,HoraLlegaDescargue,HoraEntraDescargue,HoraSaleDescargue
,TomadorPoliza,PolizaSeguro,NitCiaPoliza,NomCiaPoliza,FecVencePol,CantViajes)
 VALUES (@pmClaveReg,@pmItem,@pmIdMercancia,@pmDescripcion,@pmCantidad,@pmPesoNeto,@pmVolumen,@pmUndMed,@pmTarifaClie,@pmTarifaPago,@pmVrDeclarado,@pmVrSeguro,@pmIdCliente,@pmNitRemite,@pmRemitente,@pmDirOrigen,@pmNitDestntario,@pmDestinatario,@pmDirDestino,@pmIdOrigen,@pmIdDestino,@pmReferencia1,@pmReferencia2,@pmReferencia3,@pmDocCliente,@pmSedeRem,@pmSedeDest,@pmCodServicio
,@pmTelDestin,@pmNumGuia,@pmCodUsuario,@pmEstadoReg,@pmRemesa,@pmIdCia,@pmObservacion,@pmUndTarifa,@pmUndTarifPago,@pmTipoTarifa,@pmTipoMintrans,@pmTipoRemesa,@pmTipoRuta,@pmFechaRem,@pmFechaEntrega,@pmPlacaVeh,@pmNumRemolque,@pmIdConductor,@pmCodRuta,@pmIdAgencia,@pmNumRemision,@pmTarifaSeguro,@pmPesoContVacio,@pmPactoCargue,@pmHorasPactoCargue,@pmMinPactoCargue,@pmHoraCitaCargue,@pmHoraLlegaCargue
,@pmHoraEntraCargue,@pmHoraSaleCargue,@pmPactoDescargue,@pmHorasPactoDescargue,@pmMinPactoDescargue,@pmHoraCitaDescargue,@pmHoraLlegaDescargue,@pmHoraEntraDescargue,@pmHoraSaleDescargue,@pmTomadorPoliza,@pmPolizaSeguro,@pmNitCiaPoliza,@pmNomCiaPoliza,@pmFecVencePol,@pmCantViajes)
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInsLogIntMoraDet] @pmNumero INT,@pmItem INT,@pmTipDoc VARCHAR(3),@pmFactura INT,@pmIdCiaFac CHAR(2),@pmItemFac INT,@pmFechaVence SMALLDATETIME,@pmVrFactura MONEY
,@pmVrAbonado MONEY,@pmIdCliente VARCHAR(16),@pmIdAgencia VARCHAR(16),@pmIdVend VARCHAR(16),@pmFecUltLiq SMALLDATETIME,@pmFecIniLiq SMALLDATETIME,@pmFecFinLiq SMALLDATETIME
,@pmDiasLiquida INT,@pmDiasGracia INT,@pmVrBaseLiq MONEY,@pmTasaIntMora DECIMAL(14,4),@pmVrLiquida MONEY,@pmTarifIva DECIMAL(14,4),@pmVrIvaInt MONEY,@pmNumNota INT
,@pmIdCiaNot CHAR(2),@pmComprobante INT,@pmNomCiaFact VARCHAR(50),@pmNomCliente VARCHAR(150),@pmNomVend VARCHAR(150),@pmNomAgencia VARCHAR(50),@pmBaseIvaMora MONEY,@pmPorcBaseIva DECIMAL(14,4)
 AS 
 INSERT INTO LogIntMoraDet (Numero,Item,TipDoc,Factura,IdCiaFac,ItemFac,FechaVence,VrFactura,VrAbonado,IdCliente,IdAgencia,IdVend,FecUltLiq,FecIniLiq,FecFinLiq,DiasLiquida,DiasGracia,VrBaseLiq,TasaIntMora
,VrLiquida,TarifIva,VrIvaInt,NumNota,IdCiaNot,Comprobante,NomCiaFact,NomCliente,NomVend,NomAgencia,BaseIvaMora,PorcBaseIva)
 VALUES (@pmNumero,@pmItem,@pmTipDoc,@pmFactura,@pmIdCiaFac,@pmItemFac,@pmFechaVence,@pmVrFactura,@pmVrAbonado,@pmIdCliente,@pmIdAgencia,@pmIdVend,@pmFecUltLiq
,@pmFecIniLiq,@pmFecFinLiq,@pmDiasLiquida,@pmDiasGracia,@pmVrBaseLiq,@pmTasaIntMora,@pmVrLiquida,@pmTarifIva,@pmVrIvaInt,@pmNumNota,@pmIdCiaNot,@pmComprobante,@pmNomCiaFact,@pmNomCliente,@pmNomVend,@pmNomAgencia,@pmBaseIvaMora,@pmPorcBaseIva)
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[paQryLogIntMoraDet] @pmNumero INT
 AS 
 SELECT Numero,Item,TipDoc,Factura,IdCiaFac,ItemFac,FechaVence,VrFactura,VrAbonado,IdCliente,IdAgencia
,IdVend,FecUltLiq,FecIniLiq,FecFinLiq,DiasLiquida,DiasGracia,VrBaseLiq,TasaIntMora,VrLiquida,TarifIva
,PorcBaseIva,BaseIvaMora,VrIvaInt,NumNota,IdCiaNot,Comprobante,NomCiaFact,NomCliente,NomVend,NomAgencia
 FROM LogIntMoraDet
 WHERE Numero=@pmNumero
 ORDER BY Item
GO
