if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInstm_Caja_Ant]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paInstm_Caja_Ant]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInstm_Caja_Dva]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paInstm_Caja_Dva]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInstm_Caja_Egr]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paInstm_Caja_Egr]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInstm_Caja_Rmt]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paInstm_Caja_Rmt]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsTraManifAnexo]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paInsTraManifAnexo]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryComprobantesTotCaj]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paQryComprobantesTotCaj]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryFinAbonosRca]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paQryFinAbonosRca]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryTraAnticiposTotCaj]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paQryTraAnticiposTotCaj]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryTraManifAnexo]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paQryTraManifAnexo]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryTraTrasladosRel]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paQryTraTrasladosRel]
GO


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[paQryFinAbonosRca] @pmFechaIni SMALLDATETIME,@pmFechaFin SMALLDATETIME,@pmIdCia CHAR(2)=NULL
,@pmIdCliente VARCHAR(16)=Null
AS 
SELECT RA.IdCliente AS NitClie,T.RazonSocial AS NomCliente,RA.IdAgencia AS CdAgencia,NomAgencia AS Agencia,RA.TipDoc AS TipPre,RA.IdPrestamo AS NumPrestamo
,IdCiaPre,CP.Compania AS NomCiaPre,ItemPre,NumCuota,C.Fecha AS FecEmision,FechaVence,Concepto,C.VrTotal AS VrCuota,VrAbonado
--datos del pago
,TipRec,Recibo,RA.IdCia AS CdCia,CI.Compania AS NomCiaAbono,RA.Item AS ItemPago,RA.Fecha AS FecRecibo,FecPago,TotalAbono,RA.Detalle AS DescPago,TipoAplica
,RA.IdVend AS CedVend,VN.RazonSocial AS Vendedor,Comision,DTF_EA,TasaNom,Spread_TA,TasaEfe,TipoCuota,C.TipoCausac AS TipCausac,NumCausacion,IdCiaCau,C.Detalle AS DescCuota
,CodLinCred,LinCredito,NumFactura,CLI.IdTipoTerc AS CdTipoTerc,TipoTercero,CLI.IdGrupo AS CdGrupo,GrupoClie
,VrPrestamo,P.VrCuota AS VrCuoPrest,NPlazos,Causacion,TipoCredito,P.TipoCausac AS Tipo_Causac,NumCredito,P.IdVend AS PreCedVend,VND.RazonSocial AS PreVendedor,P.Observacion AS Observ
FROM Trn_FinAbonos AS RA INNER JOIN Trn_FinCuotas AS C ON RA.TipDoc=C.TipDoc AND RA.IdPrestamo=C.IdPrestamo AND RA.IdCiaPre=C.IdCia AND RA.ItemPre=C.Item
INNER JOIN Companias AS CI ON RA.IdCia=CI.IdCia INNER JOIN Terceros AS T ON RA.IdCliente=T.IdTercero
INNER JOIN Terceros AS VN ON RA.IdVend=VN.IdTercero INNER JOIN Companias AS CP ON RA.IdCiaPre=CP.IdCia 
LEFT JOIN LineasCred AS L ON C.CodLinCred=L.IdLinea
LEFT JOIN TercCliePrestamo AS CLI ON RA.IdCliente=CLI.IdClie AND RA.IdAgencia=CLI.IdAgencia
LEFT JOIN TiposTerc AS TC ON CLI.IdTipoTerc=TC.IdTipoTerc LEFT JOIN GruposCli AS GC ON CLI.IdGrupo=GC.IdGrupo
LEFT JOIN Trn_FinPrestamo AS P ON RA.TipDoc=P.TipDoc AND RA.IdPrestamo=P.IdPrestamo AND RA.IdCiaPre=P.IdCia
LEFT JOIN Terceros AS VND ON P.IdVend=VND.IdTercero
WHERE RA.FecPago BETWEEN @pmFechaIni AND @pmFechaFin AND RA.IdCia LIKE ISNULL(@pmIdCia,'%%')
AND RA.IdCliente LIKE ISNULL(@pmIdCliente,'%')


GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE  [dbo].[paQryTraTrasladosRel] @pmFechaIni INT,@pmFechaFin INT,@pmIdCia CHAR(2)=Null,@pmIdVehiculo VARCHAR(10)=Null
,@pmIdConductor VARCHAR(16)=Null
AS 
 SELECT T.TipDoc AS CdTipDoc,TipoDoc,T.Traslado AS NumTraslado,T.IdCia AS CdCia,Compania,T.Fecha AS FecTraslado,T.FecDespacho AS FecDespTrasl,TipoTraslado,T.IdBodega AS CdBodega,BG.Bodega AS BodegaOrig,IdBodDtno,BD.Bodega AS BodegaDtno
,T.IdVehiculo AS PlacaVeh,NumVeh,V.IdTipoVeh AS CdTipoVeh,TipoVehiculo,T.IdConductor AS CedConductor,CDT.RazonSocial AS NomConductor,Manifiesto,CdCiaMuc,EstadoRec,FechaRec,CedRecibido,NomRecibido
,T.Observacion AS Observ,T.OrigenAdd,T.TimeSys,T.IdCiaCrea,T.IdUsuario AS CdUsuario,Usuario
,DR.Item AS DetItem,TipRem,Remesa,IdCiaRem,ItemRem,EdoRecibido,Comentarios,IdMercancia,DescripMcias,D.Cantidad AS Cant,PesoNeto,UndMed,dmsAlto,dmsAncho,dmsLargo,Volumen,UndVol
,Cases,Cajas,Palets,NitRemite,Remitente,DirOrigen,IdOrigen,LO.Localidad AS CiudadOrigen,LO.IdDep AS CodDepOrigen,DPO.Departamento AS DptoOrigen
,NitDestntario,Destinatario,DirDestino,IdDestino,LD.Localidad AS CiudadDestino,LD.IdDep AS CodDepDestino,DPD.Departamento AS DptoDestino
,TarifClie,D.VrDeclarado AS VlrDeclarado,D.VrSeguro AS VlrSeguro,TarifSeguro,UndTarifa,UndTarifPago,Remision,DocCliente,Referencia1,Referencia2,Referencia3,CdNovedad,Novedad
,R.FecDespacho AS FecDespRemesa,CL.TipoId AS CliTipoId,R.IdCliente AS NitCliente,CL.Dv AS CliDv,CL.RazonSocial AS NomCliente,R.IdAgencia AS CdAgencia,TipoAfiVehic,Modalidad,NumPedido,IdCiaPed,FechaPed,TipDcm,NumDocmto,IdCiaDcm,FechaDcm
,NumManif,IdCiaManif,EstCumplido,EstFactura,SerieGuia,NumGuia,R.CdBodega AS CodBodega,BR.Bodega AS BodActual
 FROM Trn_TraTraslados AS T INNER JOIN Companias AS CN ON T.IdCia=CN.IdCia INNER JOIN Terceros AS CDT ON T.IdConductor=CDT.IdTercero 
 INNER JOIN adm_Usuarios AS U ON T.IdUsuario=U.IdUsuario INNER JOIN Sys_TiposDoc AS TD ON T.TipDoc=TD.IdDoc
 INNER JOIN AlmBodegas AS BG ON T.IdBodega=BG.IdBodega INNER JOIN AlmBodegas AS BD ON T.IdBodDtno=BD.IdBodega
 INNER JOIN Trn_TraTrasladoRem AS DR ON T.TipDoc=DR.TipDoc AND T.Traslado=DR.Traslado AND T.IdCia=DR.IdCia
 INNER JOIN Trn_TraRemesa AS R ON DR.TipRem=R.TipDoc AND DR.Remesa=R.NumOrden AND DR.IdCiaRem=R.IdCia
 INNER JOIN Terceros AS CL ON R.IdCliente=CL.IdTercero  
 LEFT JOIN Trn_TraRemMcias AS D ON DR.TipRem=D.TipDoc AND DR.Remesa=D.NumOrden AND DR.IdCiaRem=D.IdCia AND DR.ItemRem=D.Item
 LEFT JOIN Localidades AS LO ON D.IdOrigen=LO.IdLocal LEFT JOIN Departamentos AS DPO ON LO.IdDep=DPO.IdDep
 LEFT JOIN Localidades AS LD ON D.IdDestino=LD.IdLocal LEFT JOIN Departamentos AS DPD ON LD.IdDep=DPD.IdDep
 LEFT JOIN NovedadTra AS NV ON DR.CdNovedad=NV.IdNovedad
 LEFT JOIN AlmBodegas AS BR ON R.CdBodega=BR.IdBodega 
 LEFT JOIN Vehiculos AS V ON T.IdVehiculo=V.IdVehiculo LEFT JOIN TiposVeh AS TV ON V.IdTipoVeh=TV.IdTipoVeh 
 WHERE  T.Fecha BETWEEN @pmFechaIni AND @pmFechaFin AND T.IdCia LIKE ISNULL(@pmIdCia,'%%')
 AND T.IdVehiculo LIKE ISNULL(@pmIdVehiculo,'%') AND T.IdConductor LIKE ISNULL(@pmIdConductor,'%')
 AND R.Anulado=0




GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paQryTraAnticiposTotCaj]  @pmFechaIni SMALLDATETIME,@pmFechaFin SMALLDATETIME,@pmIdCia CHAR(2)=Null
,@pmIdUsuario VARCHAR(11)=Null
AS
SELECT TipDoc,SUM(VrAnticipo) AS TotalAnt
FROM Trn_TraAnticipos 
WHERE Fecha BETWEEN @pmFechaIni AND @pmFechaFin AND TipoPago='EFECTIVO'
AND IdCia LIKE ISNULL(@pmIdCia,'%%') AND IdUsuario LIKE ISNULL(@pmIdUsuario,'%')
GROUP BY TipDoc
UNION ALL
SELECT D.TipDev,SUM(VrDevolucion)
FROM Trn_TraDevAnt AS D INNER JOIN Trn_TraAnticipos AS A ON D.TipDoc=A.TipDoc AND D.Anticipo=A.Anticipo AND D.IdCiaDoc=A.IdCia
WHERE D.Fecha BETWEEN @pmFechaIni AND @pmFechaFin AND A.TipoPago='EFECTIVO'
AND D.IdCia LIKE ISNULL(@pmIdCia,'%%') AND D.IdUsuario LIKE ISNULL(@pmIdUsuario,'%')
GROUP BY D.TipDev  

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInstm_Caja_Dva] @pmtmEst CHAR(2),@pmFechaIni SMALLDATETIME,@pmFechaFin SMALLDATETIME,@pmIdCia CHAR(2)=Null
,@pmIdCajero VARCHAR(11)=Null
 AS 
 INSERT INTO tm_Caja (tmEst,tmItem,TipDoc,Numero,IdCia,Fecha,IdConcepto,IdTercero,IdAgencia,VrSubTotal,VrDescuento,VrImpuesto,VrRetencion,VrOtros,VCargos,VrOtrosDctos,VrImpGlobal,VrSoldicom,VrNeto,VrEfectivo
,VrPagosOtr,VrCreditos,VrGastComb,VrGastOtros,Cantidad,CantPuntos,PuntosAcum,EnEfectivo,CdForma,NumForma,CdBanco,DetallePagos,CdCta,FecCheque,IdVend,TarifaCom,nClieCon,IdCajero,IdLocal,Referencia,Referencia2
,Modalidad,pVehiculo,TipRef,DocRef,IdCiaRef,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,TimeSys)
SELECT @pmtmEst,7,D.TipDev,D.Devolucion,D.IdCia,D.Fecha,D.IdConcepto,D.IdPoseedor,'0',VrDevolucion,0,0,0,0,0,0,0,0,VrDevolucion AS ValNeto,CASE A.TipoPago WHEN 'EFECTIVO' THEN VrDevolucion ELSE 0 END
,0,0,0,0,0,0,0,CASE A.TipoPago WHEN 'EFECTIVO' THEN 1 ELSE 0 END,CASE A.TipoPago WHEN 'EFECTIVO' THEN 'EFE' ELSE 'CHE' END,NumCheque,IdBanco,SUBSTRING(A.Beneficiario,1,150),D.CdCta,A.FecCheque,D.IdConductor,0,'0',D.IdUsuario,'0','ANTICIPOS',''
,A.Modalidad,D.IdVehiculo,A.TipMuc,A.Manifiesto,A.IdCiaMuc,D.TipCom,D.Comprobante,D.IdCiaCom,0,D.Anticipo,D.FecDoc,D.Observacion,D.TimeSys
 FROM Trn_TraDevAnt AS D INNER JOIN Trn_TraAnticipos AS A ON D.TipDoc=A.TipDoc AND D.Anticipo=A.Anticipo AND D.IdCiaDoc=A.IdCia
 LEFT JOIN CtasCorrientes AS CT ON D.CdCta=CT.IdCta
 WHERE D.Fecha BETWEEN @pmFechaIni AND @pmFechaFin AND A.TipoPago='EFECTIVO'
 AND D.IdCia LIKE ISNULL(@pmIdCia,'%%') AND D.IdUsuario LIKE ISNULL(@pmIdCajero,'%')
 
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInstm_Caja_Ant] @pmtmEst CHAR(2),@pmFechaIni SMALLDATETIME,@pmFechaFin SMALLDATETIME,@pmIdCia CHAR(2)=Null
,@pmIdCajero VARCHAR(11)=Null
 AS 
 INSERT INTO tm_Caja (tmEst,tmItem,TipDoc,Numero,IdCia,Fecha,IdConcepto,IdTercero,IdAgencia,VrSubTotal,VrDescuento,VrImpuesto,VrRetencion,VrOtros,VCargos,VrOtrosDctos,VrImpGlobal,VrSoldicom,VrNeto,VrEfectivo
,VrPagosOtr,VrCreditos,VrGastComb,VrGastOtros,Cantidad,CantPuntos,PuntosAcum,EnEfectivo,CdForma,NumForma,CdBanco,DetallePagos,CdCta,FecCheque,IdVend,TarifaCom,nClieCon,IdCajero,IdLocal,Referencia,Referencia2
,Modalidad,pVehiculo,TipRef,DocRef,IdCiaRef,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,TimeSys)
SELECT @pmtmEst,7,TipDoc,Anticipo,IdCia,Fecha,IdConcepto,IdPoseedor,'0',VrAnticipo,0,0,0,0,0,0,0,0,VrAnticipo AS ValNeto,CASE TipoPago WHEN 'EFECTIVO' THEN VrAnticipo ELSE 0 END
,0,0,0,0,0,0,0,CASE TipoPago WHEN 'EFECTIVO' THEN 1 ELSE 0 END,CASE TipoPago WHEN 'EFECTIVO' THEN 'EFE' ELSE 'CHE' END,NumCheque,IdBanco,SUBSTRING(Beneficiario,1,150),A.IdCta,FecCheque,IdConductor,0,'0',IdUsuario,'0','ANTICIPOS',''
,Modalidad,IdVehiculo,TipMuc,Manifiesto,IdCiaMuc,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,TimeSys
 FROM Trn_TraAnticipos AS A LEFT JOIN CtasCorrientes AS CT ON A.IdCta=CT.IdCta
 WHERE A.Fecha BETWEEN @pmFechaIni AND @pmFechaFin AND A.TipoPago='EFECTIVO'
 AND A.IdCia LIKE ISNULL(@pmIdCia,'%%') AND A.IdUsuario LIKE ISNULL(@pmIdCajero,'%')
 
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInstm_Caja_Rmt] @pmtmEst CHAR(2),@pmFechaIni SMALLDATETIME,@pmFechaFin SMALLDATETIME,@pmIdCia CHAR(2)=Null
,@pmIdUsuario VARCHAR(11)=Null
 AS 
 INSERT INTO tm_Caja (tmEst,tmItem,TipDoc,Numero,IdCia,Fecha,IdConcepto,IdTercero,IdAgencia,VrSubTotal,VrDescuento,VrImpuesto,VrRetencion,VrOtros,VCargos,VrOtrosDctos,VrImpGlobal,VrSoldicom,VrNeto,VrEfectivo
,VrPagosOtr,VrCreditos,VrGastComb,VrGastOtros,Cantidad,CantPuntos,PuntosAcum,EnEfectivo,CdForma,NumForma,CdBanco,DetallePagos,CdCta,FecCheque,IdVend,TarifaCom,nClieCon,IdCajero,IdLocal,Referencia,Referencia2
,Modalidad,pVehiculo,TipRef,DocRef,IdCiaRef,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,TimeSys)
SELECT @pmtmEst,8,TipDoc,Documento,IdCia,Fecha,'0',NitCliente,CdAgencia,VrPagado,VrCambio,0,0,0,0,0,0,0,VrPagado AS ValNeto,CASE EsCaja WHEN 1 THEN VrPagado ELSE 0 END
,0,0,0,0,0,0,0,EsCaja,IdForma,NumForma,IdBanco,Beneficiario,CdCta,FecForma,'0',0,'0',IdUsuario,CdLocal,Referncia1,Referncia2
,'REMESAS',Referncia2,TipRef,DocRef,IdCiaRef,'0',0,'00',0,0,Null,Detalle,Fecha
 FROM Trn_Pagos
 WHERE TipDoc IN ('RMT','ODP','DOP') AND Fecha BETWEEN @pmFechaIni AND @pmFechaFin 
 AND IdCia LIKE ISNULL(@pmIdCia,'%%') AND IdUsuario LIKE ISNULL(@pmIdUsuario,'%')
 
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[paInstm_Caja_Egr] @pmtmEst CHAR(2),@pmFechaIni SMALLDATETIME,@pmFechaFin SMALLDATETIME,@pmIdCia CHAR(2)=Null
,@pmIdCajero VARCHAR(11)=Null,@pmEnEfectivo BIT=Null
 AS 
 INSERT INTO tm_Caja (tmEst,tmItem,TipDoc,Numero,IdCia,Fecha,IdConcepto,IdTercero,IdAgencia,VrSubTotal,VrDescuento,VrImpuesto,VrRetencion,VrOtros,VCargos,VrOtrosDctos,VrImpGlobal,VrSoldicom,VrNeto,VrEfectivo
,VrPagosOtr,VrCreditos,VrGastComb,VrGastOtros,Cantidad,CantPuntos,PuntosAcum,EnEfectivo,CdForma,NumForma,CdBanco,DetallePagos,CdCta,FecCheque,IdVend,TarifaCom,nClieCon,IdCajero,IdLocal,Referencia,Referencia2
,Modalidad,pVehiculo,TipRef,DocRef,IdCiaRef,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,TimeSys)
SELECT @pmtmEst,6,TipCom,Comprobante,IdCia,Fecha,'0',IdTercero,'0',VrTotal,0,0,0,0,0,0,0,0,VrTotal AS ValNeto,CASE EnEfectivo WHEN 1 THEN VrTotal ELSE 0 END
,0,0,0,0,0,0,0,EnEfectivo,CASE EnEfectivo WHEN 1 THEN  'EFE' ELSE 'CHE' END,NumCheque,IdBanco,SUBSTRING(Beneficiario,1,150),C.IdCta,FecCheque,'0',0,'0',IdUsuario,'0','',''
,'EGRESO',pVehiculo,TipDoc,Documento,IdCiaDoc,CASE WHEN TipEgr IS NULL OR LEN(TipEgr)=0 THEN '0' ELSE TipEgr END ,NEgreso,'00',Anulado,NumDev,FecDev,Observacion,TimeSys
 FROM Trn_Comprobantes AS C LEFT JOIN CtasCorrientes AS CT ON C.IdCta=CT.IdCta
 WHERE  Fecha BETWEEN @pmFechaIni AND @pmFechaFin AND EsEgreso=1 AND Anticipo=0
 AND IdCia LIKE ISNULL(@pmIdCia,'%%') AND IdUsuario LIKE ISNULL(@pmIdCajero,'%')
 AND (EnEfectivo=ISNULL(@pmEnEfectivo,0) or EnEfectivo=ISNULL(@pmEnEfectivo,1))

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[paQryComprobantesTotCaj] @pmFechaIni SMALLDATETIME,@pmFechaFin SMALLDATETIME
,@pmIdCia CHAR(2)=Null,@pmIdUsuario VARCHAR(11)=Null
 AS 
 SELECT  TipCom,SUM(CASE EnEfectivo WHEN 1 THEN VrTotal ELSE 0 END)  AS  STOTCAJA
,SUM(CASE EnEfectivo WHEN 0 THEN  VrTotal ELSE 0 END)  AS  STOTOTROS
 FROM Trn_Comprobantes
 WHERE Fecha BETWEEN @pmFechaIni AND @pmFechaFin AND EsEgreso=1 AND Anticipo=0
 AND  IdCia LIKE ISNULL(@pmIdCia,'%%') AND  IdUsuario LIKE ISNULL(@pmIdUsuario,'%')
 GROUP BY TipCom

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[paInsTraManifAnexo] @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2),@pmkmsTotal DECIMAL(14,4),@pmVrFleteTon MONEY,@pmTipoRuta VARCHAR(10)
,@pmCdLocTrao VARCHAR(8),@pmCdLocTrad VARCHAR(8),@pmKmsTraOri DECIMAL(14,4),@pmKmsTraDes DECIMAL(14,4),@pmIdMneda VARCHAR(5),@pmVrTasa DECIMAL(14,4)
,@pmNomRemite VARCHAR(150),@pmNomDestino VARCHAR(150),@pmLugarFletes VARCHAR(100),@pmNumAnticipo INT,@pmNumCheque VARCHAR(20),@pmTipoMintrans VARCHAR(10)
,@pmMucMintrans INT,@pmContIntegral INT,@pmVolumenCarga DECIMAL(14,4),@pmNumPoliza VARCHAR(30),@pmCdBodDtno VARCHAR(4),@pmTipoTrslado INT
 AS 
 INSERT INTO Trn_TraManifAnexo (TipDoc,Manifiesto,IdCia,kmsTotal,VrFleteTon,TipoRuta,CdLocTrao,CdLocTrad,KmsTraOri,KmsTraDes,IdMneda,VrTasa,NomRemite,NomDestino
,LugarFletes,NumAnticipo,NumCheque,TipoMintrans,MucMintrans,ContIntegral,VolumenCarga,NumPoliza,CdBodDtno,TipoTrslado)
 VALUES (@pmTipDoc,@pmManifiesto,@pmIdCia,@pmkmsTotal,@pmVrFleteTon,@pmTipoRuta,@pmCdLocTrao,@pmCdLocTrad,@pmKmsTraOri,@pmKmsTraDes,@pmIdMneda,@pmVrTasa
,@pmNomRemite,@pmNomDestino,@pmLugarFletes,@pmNumAnticipo,@pmNumCheque,@pmTipoMintrans,@pmMucMintrans,@pmContIntegral,@pmVolumenCarga,@pmNumPoliza,@pmCdBodDtno,@pmTipoTrslado)


GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[paQryTraManifAnexo] @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2)
 AS 
 SELECT TipDoc,Manifiesto,IdCia,kmsTotal,VrFleteTon,TipoRuta,CdLocTrao,CdLocTrad,KmsTraOri,KmsTraDes,IdMneda,VrTasa
,NomRemite,NomDestino,LugarFletes,NumAnticipo,NumCheque,TipoMintrans,MucMintrans,ContIntegral,VolumenCarga,NumPoliza,CdBodDtno,TipoTrslado
 FROM Trn_TraManifAnexo
 WHERE TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto AND IdCia=@pmIdCia


