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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsTraLiquidaDed]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paInsTraLiquidaDed]
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].[paInsTraManifiesto]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[paInsTraManifiesto]
GO

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelNovedadRep @pmIdNov VARCHAR(4)
 AS 
 DELETE FROM NovedadRep
 WHERE IdNov=@pmIdNov

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTarifAnticipos @pmNumero INT
 AS 
 DELETE FROM TarifAnticipos
 WHERE Numero=@pmNumero
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paDelTarifasFletes  @pmNumero INT
 AS 
 DELETE FROM TarifasFletes  WHERE  Numero=@pmNumero

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paDeltm_TraDetalle @pmtmNumero VARCHAR(5),@pmtmItem INT
 AS 
 DELETE FROM tm_TraDetalle
 WHERE tmNumero=@pmtmNumero
 AND (tmItem>=ISNULL(@pmtmItem,-1)  AND tmItem<=ISNULL(@pmtmItem,2147483647))
 
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraAnticipos @pmTipDoc VARCHAR(3),@pmAnticipo INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraAnticipos
 WHERE TipDoc=@pmTipDoc AND Anticipo=@pmAnticipo 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 paDelTraAntAbonos @pmTipDoc VARCHAR(3),@pmDocumento INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraAntAbonos
 WHERE TipDoc=@pmTipDoc AND Documento=@pmDocumento AND IdCia=@pmIdCia 

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paDelTraCauDetalle @pmTipDoc VARCHAR(3),@pmCausacion INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraCauDetalle
 WHERE TipDoc=@pmTipDoc AND Causacion=@pmCausacion AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraCausacion @pmTipDoc VARCHAR(3),@pmCausacion INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraCausacion
 WHERE TipDoc=@pmTipDoc AND Causacion=@pmCausacion AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraConcCausac @pmIdConcepto VARCHAR(4)
 AS 
 DELETE FROM TraConcCausac
 WHERE IdConcepto=@pmIdConcepto

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paDelTraConceptos @pmTipDoc VARCHAR(3),@pmDocumento INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraConceptos
 WHERE TipDoc=@pmTipDoc AND Documento=@pmDocumento AND IdCia=@pmIdCia

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraCumplido @pmTipDoc VARCHAR(3),@pmCumplido INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraCumplido
 WHERE TipDoc=@pmTipDoc AND Cumplido=@pmCumplido 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 paDelTraCumRemesas @pmTipDoc VARCHAR(3),@pmCumplido INT,@pmIdCia CHAR(2) 
 AS 
 DELETE FROM Trn_TraCumRemesas
 WHERE TipDoc=@pmTipDoc AND Cumplido=@pmCumplido AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraDespachos @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraDespachos
 WHERE TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paDelTraDespProgram @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraDespProgram
 WHERE TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto AND IdCia=@pmIdCia


GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraDevAnt @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraDevAnt
 WHERE TipDev=@pmTipDev AND Devolucion=@pmDevolucion AND IdCia=@pmIdCia

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraDevCau @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraDevCau
 WHERE TipDev=@pmTipDev AND Devolucion=@pmDevolucion AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraDevLeg @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraDevLeg
 WHERE TipDev=@pmTipDev AND Devolucion=@pmDevolucion AND IdCia=@pmIdCia

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraDevLiq @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraDevLiq
 WHERE TipDev=@pmTipDev AND Devolucion=@pmDevolucion AND IdCia=@pmIdCia

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraDevOdp @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraDevOdp
 WHERE TipDev=@pmTipDev AND Devolucion=@pmDevolucion AND IdCia=@pmIdCia

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paDelTraFacRemesas @pmTipDoc VARCHAR(3),@pmFactura INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraFacRemesas
 WHERE TipDoc=@pmTipDoc AND Factura=@pmFactura AND IdCia=@pmIdCia


GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraFijos @pmNumero INT
 AS 
 DELETE FROM TraFijos  WHERE Numero=@pmNumero

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paDelTraLiquida @pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraLiquida
 WHERE TipDoc=@pmTipDoc AND Liquidacion=@pmLiquidacion AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraLiqViajes @pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraLiqViajes
 WHERE TipDoc=@pmTipDoc AND Liquidacion=@pmLiquidacion 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 paDelTraManifAnexo @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraManifAnexo
 WHERE TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto AND IdCia=@pmIdCia

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraManifiesto @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2)
 AS 
 BEGIN
  DECLARE @TrnNombre VARCHAR(20)
  SET @TrnNombre = 'TrnManifiesto'
   BEGIN TRANSACTION @TrnNombre
   DELETE FROM  Trn_TraManifAnexo  WHERE  TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto AND IdCia=@pmIdCia 
   DELETE FROM Trn_TraManifiesto  WHERE TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto AND IdCia=@pmIdCia 
  COMMIT TRANSACTION  @TrnNombre
 END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paDelTraManifRem @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraManifRem
 WHERE TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraOrdenManif @pmTipDoc VARCHAR(3),@pmOrdPago INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraOrdenManif
 WHERE TipDoc=@pmTipDoc AND OrdPago=@pmOrdPago AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraOrdenPago @pmTipDoc VARCHAR(3),@pmOrdPago INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraOrdenPago
 WHERE TipDoc=@pmTipDoc AND OrdPago=@pmOrdPago 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 paDelTraOrdenRemesas @pmTipDoc VARCHAR(3),@pmOrdPago INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraOrdenRemesas
 WHERE TipDoc=@pmTipDoc AND OrdPago=@pmOrdPago 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 paDelTraPedAnexo @pmTipDoc VARCHAR(3),@pmPedido INT,@pmIdCia CHAR(2)
 AS 
  DELETE FROM Trn_TraPedAnexo WHERE TipDoc=@pmTipDoc AND Pedido=@pmPedido 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 paDelTraPedido @pmTipDoc VARCHAR(3),@pmPedido INT,@pmIdCia CHAR(2)
 AS 
 BEGIN
  DECLARE @TrnNombre VARCHAR(20)
  SET @TrnNombre = 'TrnPedido'
   BEGIN TRANSACTION @TrnNombre
   DELETE FROM Trn_TraPedAnexo WHERE TipDoc=@pmTipDoc AND Pedido=@pmPedido AND IdCia=@pmIdCia
   DELETE FROM Trn_TraPedido WHERE TipDoc=@pmTipDoc AND Pedido=@pmPedido AND IdCia=@pmIdCia
  COMMIT TRANSACTION  @TrnNombre
 END


GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paDelTraPedMcias @pmTipDoc VARCHAR(3),@pmPedido INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraPedMcias
 WHERE TipDoc=@pmTipDoc AND Pedido=@pmPedido 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 paDelTraPresItems @pmNumPsto INT,@pmItem INT
 AS 
 DELETE FROM Trn_TraPresItems
 WHERE NumPsto=@pmNumPsto 
 AND (Item>=ISNULL(@pmItem,-1)  AND Item<=ISNULL(@pmItem,2147483647))
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraPresAnt @pmNumPsto INT
 AS 
 BEGIN
  DECLARE @TrnNombre VARCHAR(20)
  SET @TrnNombre = 'TrnPresAnt'
  BEGIN TRANSACTION @TrnNombre
   DELETE FROM Trn_TraPresItems  WHERE NumPsto=@pmNumPsto    
   DELETE FROM Trn_TraPresAnt  WHERE NumPsto=@pmNumPsto
  COMMIT TRANSACTION  @TrnNombre
 END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraRemAnexo @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraRemAnexo
 WHERE TipDoc=@pmTipDoc AND NumOrden=@pmNumOrden AND IdCia=@pmIdCia

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paDelTraRemCntdor @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraRemCntdor
 WHERE TipDoc=@pmTipDoc AND NumOrden=@pmNumOrden 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 paDelTraRemMcias @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2)
 AS 
 DELETE FROM Trn_TraRemMcias
 WHERE TipDoc=@pmTipDoc AND NumOrden=@pmNumOrden AND IdCia=@pmIdCia

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paDelTraRemesa @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2)
 AS 
 BEGIN
  DECLARE @TrnNombre VARCHAR(20)
  SET @TrnNombre = 'TrnRemesa'
   BEGIN TRANSACTION @TrnNombre
   DELETE FROM Trn_TraRemAnexo  WHERE TipDoc=@pmTipDoc AND NumOrden=@pmNumOrden AND IdCia=@pmIdCia
   DELETE FROM Trn_TraRemesa  WHERE TipDoc=@pmTipDoc AND NumOrden=@pmNumOrden AND IdCia=@pmIdCia
  COMMIT TRANSACTION  @TrnNombre
 END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsNovedadRep @pmIdNov VARCHAR(4),@pmNovedad VARCHAR(50),@pmInactivo BIT
 AS 
 INSERT INTO NovedadRep (IdNov,Novedad,Inactivo)
 VALUES (@pmIdNov,@pmNovedad,@pmInactivo)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTarifAnticipos @pmNumero INT,@pmCuotaMax DECIMAL(14,4),@pmTipoCuota VARCHAR(10),@pmTipoAplica VARCHAR(10)
,@pmCdOrigen VARCHAR(8),@pmCdDestino VARCHAR(8),@pmNitCliente VARCHAR(16),@pmCdTipoVeh VARCHAR(4),@pmTipoAfilVeh VARCHAR(10)
,@pmInactivo BIT,@pmCdRuta VARCHAR(4),@pmFechaCrea SMALLDATETIME,@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO TarifAnticipos (Numero,CuotaMax,TipoCuota,TipoAplica,CdOrigen,CdDestino,CdRuta,NitCliente,CdTipoVeh,TipoAfilVeh,Inactivo,FechaCrea,IdUsuario)
 VALUES (@pmNumero,@pmCuotaMax,@pmTipoCuota,@pmTipoAplica,@pmCdOrigen,@pmCdDestino,@pmCdRuta,@pmNitCliente,@pmCdTipoVeh,@pmTipoAfilVeh,@pmInactivo,@pmFechaCrea,@pmIdUsuario)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsTarifasFletes @pmIdOrigen VARCHAR(8),@pmIdDestino VARCHAR(8),@pmNumero INT,@pmTipoTarifa VARCHAR(10),@pmTarifClie MONEY,@pmTarifPago MONEY
,@pmTarifTabla MONEY,@pmIdMneda VARCHAR(5),@pmUndMed VARCHAR(10),@pmNitCliente VARCHAR(16),@pmCdNat VARCHAR(4),@pmCdTipoVeh VARCHAR(4)
,@pmCdRango VARCHAR(4),@pmUndTarifClie VARCHAR(10),@pmUndTarifPago VARCHAR(10),@pmInactivo BIT,@pmCdRuta VARCHAR(4),@pmFechaCrea SMALLDATETIME,@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO TarifasFletes (Numero,IdOrigen,IdDestino,CdRuta,TipoTarifa,TarifClie,TarifPago,TarifTabla,IdMneda,UndMed,NitCliente,CdNat,CdTipoVeh,CdRango,UndTarifClie,UndTarifPago,Inactivo,FechaCrea,IdUsuario)
 VALUES (@pmNumero,@pmIdOrigen,@pmIdDestino,@pmCdRuta,@pmTipoTarifa,@pmTarifClie,@pmTarifPago,@pmTarifTabla,@pmIdMneda,@pmUndMed,@pmNitCliente
,@pmCdNat,@pmCdTipoVeh,@pmCdRango,@pmUndTarifClie,@pmUndTarifPago,@pmInactivo,@pmFechaCrea,@pmIdUsuario)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInstm_TraAnt @pmtmNumero VARCHAR(5),@pmtmItem INT,@pmtmTipAnt VARCHAR(3),@pmtmAnticipo INT,@pmtmIdCia CHAR(2)
,@pmtmValor MONEY,@pmtmVrAnticipo MONEY,@pmtmTotalAbonos MONEY,@pmtmDetalle VARCHAR(100),@pmtmCdCueAnt VARCHAR(16)
 AS 
 INSERT INTO tm_TraAnt (tmNumero,tmItem,tmTipAnt,tmAnticipo,tmIdCia,tmValor,tmVrAnticipo,tmTotalAbonos,tmDetalle,tmCdCueAnt)
 VALUES (@pmtmNumero,@pmtmItem,@pmtmTipAnt,@pmtmAnticipo,@pmtmIdCia,@pmtmValor,@pmtmVrAnticipo,@pmtmTotalAbonos,@pmtmDetalle,@pmtmCdCueAnt)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE  paInstm_TraAnt_Sel @pmTipDoc VARCHAR(3),@pmDocumento INT,@pmIdCia CHAR(2),@pmtmNumero VARCHAR(5)
 AS 
 INSERT INTO tm_TraAnt (tmNumero,tmItem,tmTipAnt,tmAnticipo,tmIdCia,tmValor,tmVrAnticipo,tmTotalAbonos,tmDetalle,tmCdCueAnt)
 SELECT @pmtmNumero,Item,TipAnt,A.Anticipo,IdCiaAnt,A.VrAbono,AN.VrAnticipo,AN.VrAbonado,Detalle,CdCuentaAnt
 FROM Trn_TraAntAbonos AS A INNER JOIN Trn_TraAnticipos AS AN ON A.TipAnt=AN.TipDoc AND A.Anticipo=AN.Anticipo AND A.IdCiaAnt=AN.IdCia
 WHERE  A.TipDoc=@pmTipDoc AND A.Documento=@pmDocumento AND A.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 paInstm_TraConc @pmtmNumero VARCHAR(5),@pmtmItem INT,@pmtmDescripcion VARCHAR(250),@pmtmTarifa DECIMAL(14,4),@pmtmTipoConc VARCHAR(10),@pmtmRubro VARCHAR(20)
,@pmtmCantidad DECIMAL(14,4),@pmtmVrUnitario MONEY,@pmtmTarifIva DECIMAL(14,4),@pmtmIdConcepto VARCHAR(4),@pmtmCdCuenta VARCHAR(16),@pmtmNitTercero VARCHAR(16),@pmtmVrBase MONEY
,@pmtmTipoTarif CHAR(1),@pmtmRefConc VARCHAR(50),@pmtmFijos BIT
 AS 
 INSERT INTO tm_TraConc (tmNumero,tmItem,tmDescripcion,tmTarifa,tmTipoConc,tmRubro,tmCantidad,tmVrUnitario,tmTarifIva,tmIdConcepto,tmCdCuenta,tmNitTercero,tmVrBase,tmTipoTarif,tmRefConc,tmFijos)
 VALUES (@pmtmNumero,@pmtmItem,@pmtmDescripcion,@pmtmTarifa,@pmtmTipoConc,@pmtmRubro,@pmtmCantidad,@pmtmVrUnitario,@pmtmTarifIva,@pmtmIdConcepto,@pmtmCdCuenta
,@pmtmNitTercero,@pmtmVrBase,@pmtmTipoTarif,@pmtmRefConc,@pmtmFijos)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInstm_TraConc_Sel @pmTipDoc VARCHAR(3),@pmDocumento INT,@pmIdCia CHAR(2),@pmtmNumero VARCHAR(5)
 AS 
 INSERT INTO tm_TraConc (tmNumero,tmItem,tmDescripcion,tmTarifa,tmTipoConc,tmRubro,tmCantidad,tmVrUnitario,tmTarifIva,tmIdConcepto,tmCdCuenta,tmNitTercero,tmVrBase,tmTipoTarif,tmRefConc,tmFijos)
 SELECT @pmtmNumero,Item,Descripcion,Tarifa,TipoConc,RubroConcep, Cantidad, VrUnitario, TarifIva, IdConcepto, CdCuenta, NitTercero,VrBase,TipoTarif,RefConc,Fijos
 FROM   Trn_TraConceptos
 WHERE TipDoc=@pmTipDoc  AND Documento=@pmDocumento AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInstm_TraDetalle @pmtmNumero VARCHAR(5),@pmtmItem INT,@pmtmIdMercancia VARCHAR(16),@pmtmDescripMcias VARCHAR(250),@pmtmCantidad DECIMAL(14,4),@pmtmPesoNeto DECIMAL(14,4),@pmtmUndMed VARCHAR(10),@pmtmdmsAlto DECIMAL(14,4),@pmtmdmsAncho DECIMAL(14,4),@pmtmdmsLargo DECIMAL(14,4),@pmtmVolumen DECIMAL(14,4),@pmtmUndVol VARCHAR(10),@pmtmIdUnd VARCHAR(4),@pmtmIdEmp VARCHAR(4),@pmtmIdNat VARCHAR(4),@pmtmIdMnjo VARCHAR(4),@pmtmIdTmcia VARCHAR(4)
,@pmtmCdRango VARCHAR(4),@pmtmCases INT,@pmtmCajas INT,@pmtmPalets INT,@pmtmRemision DECIMAL(18,2),@pmtmNumOrden INT,@pmtmNitRemite VARCHAR(16),@pmtmRemitente VARCHAR(250),@pmtmDirOrigen VARCHAR(250),@pmtmIdOrigen VARCHAR(8),@pmtmNitDestntario VARCHAR(16),@pmtmDestinatario VARCHAR(250),@pmtmDirDestino VARCHAR(250),@pmtmIdDestino VARCHAR(8),@pmtmCdAgencia VARCHAR(16),@pmtmTipoVehic VARCHAR(10),@pmtmTarifClie MONEY,@pmtmTarifPago MONEY,@pmtmTarifTabla MONEY,@pmtmVrDeclarado MONEY,@pmtmVrSeguro MONEY
,@pmtmTarifSeguro DECIMAL(14,4),@pmtmDocCliente VARCHAR(30),@pmtmReferencia1 VARCHAR(50),@pmtmReferencia2 VARCHAR(50),@pmtmReferencia3 VARCHAR(50),@pmtmContenedor1 VARCHAR(50),@pmtmContenedor2 VARCHAR(50),@pmtmUndTarifa VARCHAR(10),@pmtmTipRem VARCHAR(3),@pmtmRemesa INT,@pmtmIdCiaRem CHAR(2),@pmtmItemRem INT,@pmtmNumMintrans DECIMAL(14,2),@pmtmPesoCont DECIMAL(14,4),@pmtmUndTarPago VARCHAR(10)
 AS 
 INSERT INTO tm_TraDetalle (tmNumero,tmItem,tmIdMercancia,tmDescripMcias,tmCantidad,tmPesoNeto,tmUndMed,tmdmsAlto,tmdmsAncho,tmdmsLargo,tmVolumen,tmUndVol,tmIdUnd,tmIdEmp,tmIdNat,tmIdMnjo,tmIdTmcia,tmCdRango,tmCases,tmCajas,tmPalets,tmRemision,tmNumOrden,tmNitRemite,tmRemitente,tmDirOrigen,tmIdOrigen,tmNitDestntario,tmDestinatario,tmDirDestino,tmIdDestino,tmCdAgencia,tmTipoVehic,tmTarifClie,tmTarifPago,tmTarifTabla,tmVrDeclarado,tmVrSeguro,tmTarifSeguro,tmDocCliente,tmReferencia1,tmReferencia2,tmReferencia3
,tmContenedor1,tmContenedor2,tmUndTarifa,tmTipRem,tmRemesa,tmIdCiaRem,tmItemRem,tmNumMintrans,tmPesoCont,tmUndTarPago)
 VALUES (@pmtmNumero,@pmtmItem,@pmtmIdMercancia,@pmtmDescripMcias,@pmtmCantidad,@pmtmPesoNeto,@pmtmUndMed,@pmtmdmsAlto,@pmtmdmsAncho,@pmtmdmsLargo,@pmtmVolumen,@pmtmUndVol,@pmtmIdUnd,@pmtmIdEmp,@pmtmIdNat,@pmtmIdMnjo,@pmtmIdTmcia,@pmtmCdRango,@pmtmCases,@pmtmCajas,@pmtmPalets,@pmtmRemision,@pmtmNumOrden,@pmtmNitRemite,@pmtmRemitente,@pmtmDirOrigen,@pmtmIdOrigen,@pmtmNitDestntario,@pmtmDestinatario,@pmtmDirDestino,@pmtmIdDestino,@pmtmCdAgencia,@pmtmTipoVehic
,@pmtmTarifClie,@pmtmTarifPago,@pmtmTarifTabla,@pmtmVrDeclarado,@pmtmVrSeguro,@pmtmTarifSeguro,@pmtmDocCliente,@pmtmReferencia1,@pmtmReferencia2,@pmtmReferencia3,@pmtmContenedor1,@pmtmContenedor2,@pmtmUndTarifa,@pmtmTipRem,@pmtmRemesa,@pmtmIdCiaRem,@pmtmItemRem,@pmtmNumMintrans,@pmtmPesoCont,@pmtmUndTarPago)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInstm_TraDetalle_Muc @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2),@pmtmNumero VARCHAR(5)
 AS 
 INSERT INTO tm_TraDetalle (tmNumero,tmItem,tmIdMercancia,tmDescripMcias,tmCantidad,tmPesoNeto,tmUndMed,tmdmsAlto,tmdmsAncho,tmdmsLargo,tmVolumen,tmUndVol,tmIdUnd,tmIdEmp,tmIdNat
,tmIdMnjo,tmIdTmcia,tmCdRango,tmCases,tmCajas,tmPalets,tmRemision,tmNumOrden,tmNitRemite,tmRemitente,tmDirOrigen,tmIdOrigen,tmNitDestntario,tmDestinatario,tmDirDestino,tmIdDestino
,tmCdAgencia,tmTipoVehic,tmTarifClie,tmTarifPago,tmTarifTabla,tmVrDeclarado,tmVrSeguro,tmTarifSeguro,tmDocCliente,tmReferencia1,tmReferencia2,tmReferencia3,tmContenedor1,tmContenedor2,tmUndTarifa
,tmTipRem,tmRemesa,tmIdCiaRem,tmItemRem,tmNumMintrans,tmPesoCont,tmUndTarPago)
SELECT @pmtmNumero,RM.Item,IdMercancia,DescripMcias,Cantidad,PesoNeto,UndMed,dmsAlto,dmsAncho,dmsLargo,Volumen,UndVol,IdUnd,IdEmp,IdNat
,IdMnjo,IdTmcia,CdRango,Cases,Cajas,Palets,Remision,Factura,NitRemite,Remitente,DirOrigen,IdOrigen,NitDestntario,Destinatario,DirDestino,IdDestino
,CdAgencia,'TERCEROS',TarifClie,RM.TarifPago,RM.TarifTabla,VrDeclarado,VrSeguro,TarifSeguro,DocCliente,Referencia1,Referencia2,Referencia3,Contenedor1,Contenedor2,UndTarifa
,TipRem,Remesa,IdCiaRem,ItemRem,RemMintrans,PesoCont,UndTarifPago
 FROM Trn_TraManifRem AS RM INNER JOIN  Trn_TraRemMcias  AS D ON  RM.TipRem=D.TipDoc AND RM.Remesa=D.NumOrden AND RM.IdCiaRem=D.IdCia   AND RM.ItemRem=D.Item
 WHERE RM.TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto AND RM.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 paInstm_TraDetalle_Odp @pmTipDoc VARCHAR(3),@pmOrdPago INT,@pmIdCia CHAR(2)
,@pmtmNumero VARCHAR(5)
 AS 
 INSERT INTO tm_TraDetalle (tmNumero,tmItem,tmIdMercancia,tmDescripMcias,tmCantidad,tmPesoNeto,tmUndMed,tmdmsAlto,tmdmsAncho,tmdmsLargo,tmVolumen,tmUndVol,tmIdUnd,tmIdEmp,tmIdNat,tmIdMnjo,tmIdTmcia,tmCdRango,tmCases,tmCajas,tmPalets
,tmRemision,tmNumOrden,tmNitRemite,tmRemitente,tmDirOrigen,tmIdOrigen,tmNitDestntario,tmDestinatario,tmDirDestino,tmIdDestino,tmCdAgencia,tmTipoVehic,tmTarifClie,tmTarifPago,tmTarifTabla,tmVrDeclarado,tmVrSeguro,tmTarifSeguro,tmDocCliente,tmReferencia1,tmReferencia2,tmReferencia3
,tmContenedor1,tmContenedor2,tmUndTarifa,tmTipRem,tmRemesa,tmIdCiaRem,tmItemRem,tmNumMintrans,tmPesoCont,tmUndTarPago)
 SELECT @pmtmNumero,R.Item,IdMercancia,Detalle,R.Cantidad,R.PesoNeto,R.UndMed,dmsAlto,dmsAncho,dmsLargo,R.Volumen,R.UndVol,IdUnd,IdEmp,IdNat,IdMnjo,IdTmcia,CdRango,R.Cases,R.Cajas,R.Palets,Remision,Cumplido
,NitRemite,Remitente,DirOrigen,IdOrigen,NitDestntario,Destinatario,DirDestino,IdDestino,CdAgencia,'TERCEROS',TarifClie,R.TarifPago,R.TarifTabla,VrDeclarado,VrSeguro,TarifSeguro,DocCliente,Referencia1,Referencia2,Referencia3
,Contenedor1,Contenedor2,D.UndTarifa,TipRem,Remesa,IdCiaRem,ItemRem,0,PesoCont,R.UndTarifa
 FROM Trn_TraOrdenRemesas AS R INNER JOIN Trn_TraRemMcias AS D ON R.TipRem=D.TipDoc AND  R.Remesa=D.NumOrden AND R.IdCiaRem=D.IdCia AND R.ItemRem=D.Item
 WHERE R.TipDoc=@pmTipDoc AND R.OrdPago=@pmOrdPago  AND R.IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInstm_TraDetalle_Rem @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2),@pmtmNumero VARCHAR(5)
 AS 
 INSERT INTO tm_TraDetalle (tmNumero,tmItem,tmIdMercancia,tmDescripMcias,tmCantidad,tmPesoNeto,tmUndMed,tmdmsAlto,tmdmsAncho,tmdmsLargo,tmVolumen,tmUndVol,tmIdUnd,tmIdEmp,tmIdNat
,tmIdMnjo,tmIdTmcia,tmCdRango,tmCases,tmCajas,tmPalets,tmRemision,tmNumOrden,tmNitRemite,tmRemitente,tmDirOrigen,tmIdOrigen,tmNitDestntario,tmDestinatario,tmDirDestino,tmIdDestino
,tmCdAgencia,tmTipoVehic,tmTarifClie,tmTarifPago,tmTarifTabla,tmVrDeclarado,tmVrSeguro,tmTarifSeguro,tmDocCliente,tmReferencia1,tmReferencia2,tmReferencia3,tmContenedor1,tmContenedor2,tmUndTarifa
,tmTipRem,tmRemesa,tmIdCiaRem,tmItemRem,tmNumMintrans,tmPesoCont,tmUndTarPago)
SELECT @pmtmNumero,Item,IdMercancia,DescripMcias,Cantidad,PesoNeto,UndMed,dmsAlto,dmsAncho,dmsLargo,Volumen,UndVol,IdUnd,IdEmp,IdNat
,IdMnjo,IdTmcia,CdRango,Cases,Cajas,Palets,Remision,Factura,NitRemite,Remitente,DirOrigen,IdOrigen,NitDestntario,Destinatario,DirDestino,IdDestino
,CdAgencia,'TERCEROS',TarifClie,TarifPago,TarifTabla,VrDeclarado,VrSeguro,TarifSeguro,DocCliente,Referencia1,Referencia2,Referencia3,Contenedor1,Contenedor2
,UndTarifa,TipFac,Factura,IdCiaFac,0,0,PesoCont,UndTarifPago
 FROM Trn_TraRemMcias
 WHERE TipDoc=@pmTipDoc AND NumOrden=@pmNumOrden AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInstm_TraDetalle_Sel @pmTipDoc VARCHAR(3),@pmPedido INT,@pmIdCia CHAR(2),@pmtmNumero VARCHAR(5)
 AS 
 INSERT INTO tm_TraDetalle (tmNumero,tmItem,tmIdMercancia,tmDescripMcias,tmCantidad,tmPesoNeto,tmUndMed,tmdmsAlto,tmdmsAncho,tmdmsLargo,tmVolumen,tmUndVol,tmIdUnd,tmIdEmp,tmIdNat
,tmIdMnjo,tmIdTmcia,tmCdRango,tmCases,tmCajas,tmPalets,tmRemision,tmNumOrden,tmNitRemite,tmRemitente,tmDirOrigen,tmIdOrigen,tmNitDestntario,tmDestinatario,tmDirDestino,tmIdDestino
,tmCdAgencia,tmTipoVehic,tmTarifClie,tmTarifPago,tmTarifTabla,tmVrDeclarado,tmVrSeguro,tmTarifSeguro,tmDocCliente,tmReferencia1,tmReferencia2,tmReferencia3,tmContenedor1,tmContenedor2,tmUndTarifa
,tmTipRem,tmRemesa,tmIdCiaRem,tmItemRem,tmNumMintrans,tmPesoCont,tmUndTarPago)
SELECT @pmtmNumero,Item,IdMercancia,DescripMcias,Cantidad,PesoNeto,UndMed,dmsAlto,dmsAncho,dmsLargo,Volumen,UndVol,IdUnd,IdEmp,IdNat
,IdMnjo,IdTmcia,CdRango,Cases,Cajas,Palets,0,0,NitRemite,Remitente,DirOrigen,IdOrigen,NitDestntario,Destinatario,DirDestino,IdDestino
,'0','TERCEROS',TarifClie,TarifPago,TarifTabla,VrDeclarado,VrSeguro,TarifSeguro,'0',Referencia1,Referencia2,'',Contenedor1,Contenedor2,UndTarifa
,TipDoc,Pedido,IdCia,Item,0,0,UndTarifPago
 FROM Trn_TraPedMcias
 WHERE TipDoc=@pmTipDoc AND Pedido=@pmPedido AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInstm_TraDetConc @pmtmNumero VARCHAR(5),@pmtmItem INT,@pmtmIdConcepto VARCHAR(4),@pmtmDescripcion VARCHAR(250),@pmtmTipoConc VARCHAR(10),@pmtmVrDebito MONEY,@pmtmVrCredito MONEY,@pmtmCdCuenta VARCHAR(16)
,@pmtmNitTercero VARCHAR(16),@pmtmCdCCosto VARCHAR(16),@pmtmCdSubCos VARCHAR(16),@pmtmpVehiculo VARCHAR(10),@pmtmTipoAfiVehic VARCHAR(10),@pmtmVrBase MONEY,@pmtmTarifBase DECIMAL(14,4),@pmtmReferencia VARCHAR(50)
,@pmtmTipDocRef VARCHAR(3),@pmtmDocRef INT,@pmtmTipFac VARCHAR(3),@pmtmFactura VARCHAR(15),@pmtmIdCiaFac CHAR(2),@pmtmItemFac INT,@pmtmFecVence SMALLDATETIME,@pmtmCodAgncia VARCHAR(16),@pmtmCantComb DECIMAL(14,4)
 AS 
 INSERT INTO tm_TraDetConc (tmNumero,tmItem,tmIdConcepto,tmDescripcion,tmTipoConc,tmVrDebito,tmVrCredito,tmCdCuenta,tmNitTercero,tmCdCCosto,tmCdSubCos,tmpVehiculo,tmTipoAfiVehic,tmVrBase,tmTarifBase,tmReferencia,tmTipDocRef
,tmDocRef,tmTipFac,tmFactura,tmIdCiaFac,tmItemFac,tmFecVence,tmCodAgncia,tmCantComb)
 VALUES (@pmtmNumero,@pmtmItem,@pmtmIdConcepto,@pmtmDescripcion,@pmtmTipoConc,@pmtmVrDebito,@pmtmVrCredito,@pmtmCdCuenta,@pmtmNitTercero,@pmtmCdCCosto,@pmtmCdSubCos,@pmtmpVehiculo,@pmtmTipoAfiVehic
,@pmtmVrBase,@pmtmTarifBase,@pmtmReferencia,@pmtmTipDocRef,@pmtmDocRef,@pmtmTipFac,@pmtmFactura,@pmtmIdCiaFac,@pmtmItemFac,@pmtmFecVence,@pmtmCodAgncia,@pmtmCantComb)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInstm_TraDetConc_Dev  @pmTipDoc VARCHAR(3),@pmCausacion INT,@pmIdCia CHAR(2),@pmtmNumero VARCHAR(5)
 AS 
 INSERT INTO tm_TraDetConc (tmNumero,tmItem,tmIdConcepto,tmDescripcion,tmTipoConc,tmVrDebito,tmVrCredito,tmCdCuenta,tmNitTercero,tmCdCCosto,tmCdSubCos,tmpVehiculo
,tmTipoAfiVehic,tmVrBase,tmTarifBase,tmReferencia,tmTipDocRef,tmDocRef,tmTipFac,tmFactura,tmIdCiaFac,tmItemFac,tmFecVence,tmCodAgncia,tmCantComb)
 SELECT @pmtmNumero,Item,IdConcepto,Descripcion,TipoConc,VrCredito,VrDebito,CdCuenta,NitTercero,CdCCosto,CdSubCos,pVehiculo
,TipoAfiVehic,VrBase,TarifBase,Referencia,TipDocRef,DocRef,TipFac,Factura,IdCiaFac,ItemFac,FecVence,'0',0
 FROM Trn_TraCauDetalle
 WHERE TipDoc=@pmTipDoc AND Causacion=@pmCausacion 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 paInstm_TraDetConc_Dlg  @pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2),@pmtmNumero VARCHAR(5)
 AS 
 INSERT INTO tm_TraDetConc (tmNumero,tmItem,tmIdConcepto,tmDescripcion,tmTipoConc,tmVrDebito,tmVrCredito,tmCdCuenta,tmNitTercero,tmCdCCosto,tmCdSubCos,tmpVehiculo
,tmTipoAfiVehic,tmVrBase,tmTarifBase,tmReferencia,tmTipDocRef,tmDocRef,tmTipFac,tmFactura,tmIdCiaFac,tmItemFac,tmFecVence,tmCodAgncia,tmCantComb)
 SELECT @pmtmNumero,Item,IdConcepto,DescConcepto,RubroConc,VrCredito,VrDebito,IdCuenta,IdTercero,CdCCosto,CdSubCos,pVehiculo
,'TERCEROS',VrBase,TarifBase,RefConcep,TipDoc,Liquidacion,TipFac,Factura,IdCiaFac,ItemFac,FecVence,CodAgncia,CantComb
 FROM Trn_TraLiqDetalle
 WHERE TipDoc=@pmTipDoc AND Liquidacion=@pmLiquidacion 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 paInstm_TraDetConc_Leg  @pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2),@pmtmNumero VARCHAR(5)
 AS 
 INSERT INTO tm_TraDetConc (tmNumero,tmItem,tmIdConcepto,tmDescripcion,tmTipoConc,tmVrDebito,tmVrCredito,tmCdCuenta,tmNitTercero,tmCdCCosto,tmCdSubCos,tmpVehiculo
,tmTipoAfiVehic,tmVrBase,tmTarifBase,tmReferencia,tmTipDocRef,tmDocRef,tmTipFac,tmFactura,tmIdCiaFac,tmItemFac,tmFecVence,tmCodAgncia,tmCantComb)
 SELECT @pmtmNumero,Item,IdConcepto,DescConcepto,RubroConc,VrDebito,VrCredito,IdCuenta,IdTercero,CdCCosto,CdSubCos,pVehiculo
,'TERCEROS',VrBase,TarifBase,RefConcep,TipDoc,Liquidacion,TipFac,Factura,IdCiaFac,ItemFac,FecVence,CodAgncia,CantComb
 FROM Trn_TraLiqDetalle
 WHERE TipDoc=@pmTipDoc AND Liquidacion=@pmLiquidacion 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 paInstm_TraDetConc_Sel  @pmTipDoc VARCHAR(3),@pmCausacion INT,@pmIdCia CHAR(2),@pmtmNumero VARCHAR(5)
 AS 
 INSERT INTO tm_TraDetConc (tmNumero,tmItem,tmIdConcepto,tmDescripcion,tmTipoConc,tmVrDebito,tmVrCredito,tmCdCuenta,tmNitTercero,tmCdCCosto,tmCdSubCos,tmpVehiculo
,tmTipoAfiVehic,tmVrBase,tmTarifBase,tmReferencia,tmTipDocRef,tmDocRef,tmTipFac,tmFactura,tmIdCiaFac,tmItemFac,tmFecVence,tmCodAgncia,tmCantComb)
 SELECT @pmtmNumero,Item,IdConcepto,Descripcion,TipoConc,VrDebito,VrCredito,CdCuenta,NitTercero,CdCCosto,CdSubCos,pVehiculo
,TipoAfiVehic,VrBase,TarifBase,Referencia,TipDocRef,DocRef,TipFac,Factura,IdCiaFac,ItemFac,FecVence,'0',0
 FROM Trn_TraCauDetalle
 WHERE TipDoc=@pmTipDoc AND Causacion=@pmCausacion AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInstm_TraLiqCausac @pmtmNumero VARCHAR(5),@pmtmItem INT,@pmtmTipCau VARCHAR(3),@pmtmCausacion INT,@pmtmIdCiaCau CHAR(2),@pmtmItemCau INT,@pmtmFecha SMALLDATETIME,@pmtmIdConcepto VARCHAR(4),@pmtmDescripcion VARCHAR(250)
,@pmtmVrAbono MONEY,@pmtmNit VARCHAR(16),@pmtmVehiculo VARCHAR(10),@pmtmTipOdp VARCHAR(3),@pmtmOrdenPago INT,@pmtmIdCiaOdp CHAR(2),@pmtmTipMuc VARCHAR(3),@pmtmManifiesto INT,@pmtmIdCiaMuc CHAR(2),@pmtmItemFact INT,@pmtmVrSaldo MONEY
,@pmtmEsVence BIT,@pmtmCdCuenta VARCHAR(16),@pmtmCuePagar VARCHAR(16),@pmtmFactura VARCHAR(20),@pmtmConcValor MONEY,@pmtmConcAbono MONEY,@pmtmCdCCosto VARCHAR(16),@pmtmCdSubCos VARCHAR(16)
 AS 
 INSERT INTO tm_TraLiqCausac (tmNumero,tmItem,tmTipCau,tmCausacion,tmIdCiaCau,tmItemCau,tmFecha,tmIdConcepto,tmDescripcion,tmVrAbono,tmNit,tmVehiculo,tmTipOdp,tmOrdenPago,tmIdCiaOdp,tmTipMuc,tmManifiesto,tmIdCiaMuc
,tmItemFact,tmVrSaldo,tmEsVence,tmCdCuenta,tmCuePagar,tmFactura,tmConcValor,tmConcAbono,tmCdCCosto,tmCdSubCos)
 VALUES (@pmtmNumero,@pmtmItem,@pmtmTipCau,@pmtmCausacion,@pmtmIdCiaCau,@pmtmItemCau,@pmtmFecha,@pmtmIdConcepto,@pmtmDescripcion,@pmtmVrAbono,@pmtmNit,@pmtmVehiculo,@pmtmTipOdp,@pmtmOrdenPago,@pmtmIdCiaOdp
,@pmtmTipMuc,@pmtmManifiesto,@pmtmIdCiaMuc,@pmtmItemFact,@pmtmVrSaldo,@pmtmEsVence,@pmtmCdCuenta,@pmtmCuePagar,@pmtmFactura,@pmtmConcValor,@pmtmConcAbono,@pmtmCdCCosto,@pmtmCdSubCos)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE  paInstm_TraLiqCausac_Sel @pmtmNumero VARCHAR(5),@pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2)
 AS 
 INSERT INTO tm_TraLiqCausac (tmNumero,tmItem,tmTipCau,tmCausacion,tmIdCiaCau,tmItemCau,tmFecha,tmIdConcepto,tmDescripcion,tmVrAbono,tmNit,tmVehiculo,tmTipOdp,tmOrdenPago,tmIdCiaOdp
,tmTipMuc,tmManifiesto,tmIdCiaMuc,tmItemFact,tmVrSaldo,tmEsVence,tmCdCuenta,tmCuePagar,tmFactura,tmConcValor,tmConcAbono,tmCdCCosto,tmCdSubCos)
 SELECT @pmtmNumero,Item,TipCau,Causacion,IdCiaCau,ItemCau,FechaCau,IdConcepto,Descripcion,VrAbono,NitPoseedor,pVehiculo,TipOdp,OrdenPago,IdCiaOdp
,TipMuc,Manifiesto,IdCiaMuc,1,VrSaldoOrden,EsVence,CdCuenta,CdCuePagar,NumFactura,0,0,CdCCosto,CdSubCos
 FROM Trn_TraLiquidaDed
 WHERE TipDoc=@pmTipDoc AND Liquidacion=@pmLiquidacion AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInstm_TraRemCum @pmtmNumero VARCHAR(5),@pmtmItem INT,@pmtmTipRem VARCHAR(3),@pmtmRemesa INT,@pmtmIdCiaRem CHAR(2),@pmtmItemRem INT,@pmtmIdMercancia VARCHAR(16),@pmtmDescripMcias VARCHAR(250),@pmtmCantidad DECIMAL(14,4),@pmtmPesoNeto DECIMAL(14,4),@pmtmUndMed VARCHAR(10),@pmtmVolumen DECIMAL(14,4),@pmtmUndVol VARCHAR(10),@pmtmCases INT,@pmtmCajas INT,@pmtmPalets INT,@pmtmTarifClie MONEY
,@pmtmTarifPago MONEY,@pmtmUndTarif VARCHAR(10),@pmtmUndTarifPago VARCHAR(10),@pmtmCantCargue DECIMAL(14,4),@pmtmPesoCargue DECIMAL(14,4),@pmtmVolCargue DECIMAL(14,4),@pmtmCasesCargue INT,@pmtmCajasCargue INT,@pmtmPaletsCargue INT,@pmtmEstadoCump INT,@pmtmRemision DECIMAL(18,2),@pmtmDocCliente VARCHAR(30),@pmtmReferencia1 VARCHAR(50),@pmtmReferencia2 VARCHAR(50),@pmtmReferencia3 VARCHAR(50),@pmtmDetalle VARCHAR(250)
,@pmtmNitRemite VARCHAR(16),@pmtmRemitente VARCHAR(250),@pmtmDirOrigen VARCHAR(250),@pmtmIdOrigen VARCHAR(8),@pmtmNitDestntario VARCHAR(16),@pmtmDestinatario VARCHAR(250),@pmtmDirDestino VARCHAR(250),@pmtmIdDestino VARCHAR(8)
 AS 
 INSERT INTO tm_TraRemCum (tmNumero,tmItem,tmTipRem,tmRemesa,tmIdCiaRem,tmItemRem,tmIdMercancia,tmDescripMcias,tmCantidad,tmPesoNeto,tmUndMed,tmVolumen,tmUndVol,tmCases,tmCajas,tmPalets,tmTarifClie,tmTarifPago,tmUndTarif,tmUndTarifPago,tmCantCargue,tmPesoCargue,tmVolCargue,tmCasesCargue,tmCajasCargue,tmPaletsCargue,tmEstadoCump,tmRemision,tmDocCliente,tmReferencia1,tmReferencia2,tmReferencia3,tmDetalle,tmNitRemite,tmRemitente
,tmDirOrigen,tmIdOrigen,tmNitDestntario,tmDestinatario,tmDirDestino,tmIdDestino)
 VALUES (@pmtmNumero,@pmtmItem,@pmtmTipRem,@pmtmRemesa,@pmtmIdCiaRem,@pmtmItemRem,@pmtmIdMercancia,@pmtmDescripMcias,@pmtmCantidad,@pmtmPesoNeto,@pmtmUndMed,@pmtmVolumen,@pmtmUndVol,@pmtmCases,@pmtmCajas,@pmtmPalets,@pmtmTarifClie,@pmtmTarifPago,@pmtmUndTarif,@pmtmUndTarifPago,@pmtmCantCargue,@pmtmPesoCargue,@pmtmVolCargue,@pmtmCasesCargue,@pmtmCajasCargue,@pmtmPaletsCargue
,@pmtmEstadoCump,@pmtmRemision,@pmtmDocCliente,@pmtmReferencia1,@pmtmReferencia2,@pmtmReferencia3,@pmtmDetalle,@pmtmNitRemite,@pmtmRemitente,@pmtmDirOrigen,@pmtmIdOrigen,@pmtmNitDestntario,@pmtmDestinatario,@pmtmDirDestino,@pmtmIdDestino)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInstm_TraRemCum_Muc @pmtmNumero VARCHAR(5),@pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2)
 AS 
 INSERT INTO tm_TraRemCum (tmNumero,tmItem,tmTipRem,tmRemesa,tmIdCiaRem,tmItemRem,tmIdMercancia,tmDescripMcias,tmCantidad,tmPesoNeto,tmUndMed,tmVolumen,tmUndVol,tmCases,tmCajas,tmPalets,tmTarifClie,tmTarifPago,tmUndTarif,tmUndTarifPago,tmCantCargue
,tmPesoCargue,tmVolCargue,tmCasesCargue,tmCajasCargue,tmPaletsCargue,tmEstadoCump,tmRemision,tmDocCliente,tmReferencia1,tmReferencia2,tmReferencia3,tmDetalle,tmNitRemite,tmRemitente,tmDirOrigen,tmIdOrigen,tmNitDestntario,tmDestinatario,tmDirDestino,tmIdDestino)
SELECT @pmtmNumero,D.Item,TipRem,Remesa,IdCiaRem,ItemRem,IdMercancia,DescripMcias,Cantidad,PesoNeto,UndMed,Volumen,UndVol,Cases,Cajas,Palets,R.TarifClie,R.TarifPago,UndTarifa,UndTarifPago,Cantidad
,PesoNeto,Volumen,Cases,Cajas,Palets,1,Remision,DocCliente,Referencia1,Referencia2,Referencia3,DetalleCump,NitRemite,Remitente,DirOrigen,IdOrigen,NitDestntario,Destinatario,DirDestino,IdDestino
 FROM  Trn_TraManifRem AS D INNER JOIN Trn_TraRemMcias AS R ON D.TipRem=R.TipDoc AND D.Remesa=R.NumOrden AND D.IdCiaRem=R.IdCia AND D.ItemRem=R.Item
 WHERE D.TipDoc=@pmTipDoc AND D.Manifiesto=@pmManifiesto AND D.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 paInstm_TraRemCum_Sel @pmtmNumero VARCHAR(5),@pmTipDoc VARCHAR(3),@pmCumplido INT,@pmIdCia CHAR(2)
 AS 
 INSERT INTO tm_TraRemCum (tmNumero,tmItem,tmTipRem,tmRemesa,tmIdCiaRem,tmItemRem,tmIdMercancia,tmDescripMcias,tmCantidad,tmPesoNeto,tmUndMed,tmVolumen,tmUndVol,tmCases,tmCajas,tmPalets,tmTarifClie,tmTarifPago,tmUndTarif,tmUndTarifPago,tmCantCargue
,tmPesoCargue,tmVolCargue,tmCasesCargue,tmCajasCargue,tmPaletsCargue,tmEstadoCump,tmRemision,tmDocCliente,tmReferencia1,tmReferencia2,tmReferencia3,tmDetalle,tmNitRemite,tmRemitente,tmDirOrigen,tmIdOrigen,tmNitDestntario,tmDestinatario,tmDirDestino,tmIdDestino)
SELECT @pmtmNumero,Item,TipRem,Remesa,IdCiaRem,ItemRem,'0','0',Cantidad,PesoNeto,UndMed,Volumen,UndVol,Cases,Cajas,Palets,TarifClie,TarifPago,UndTarifClie,UndTarifPago,CantCargue,PesoCargue,VolCargue,CasesCargue,CajasCargue,PaletsCargue,EstadoCump
,Remision,DocCliente,Referencia1,Referencia2,Referencia3,Detalle,'0','','','0','0','','','0'
 FROM Trn_TraCumRemesas 
 WHERE TipDoc=@pmTipDoc AND Cumplido=@pmCumplido AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInstm_TraRemFact @pmtmNumero VARCHAR(5),@pmtmItem INT,@pmtmTipoReg INT,@pmtmTipRem VARCHAR(3),@pmtmRemesa INT,@pmtmIdCiaRem CHAR(2),@pmtmItemRem INT,@pmtmDescripcion VARCHAR(250),@pmtmCantidad DECIMAL(14,4),@pmtmVrUnitario MONEY,@pmtmVrCosto MONEY,@pmtmUndTarifa VARCHAR(10),@pmtmUndCosto VARCHAR(10),@pmtmUnidades DECIMAL(14,4),@pmtmPesoNeto DECIMAL(14,4),@pmtmUndMed VARCHAR(10),@pmtmVolumen DECIMAL(14,4)
,@pmtmUndVol VARCHAR(10),@pmtmCases INT,@pmtmCajas INT,@pmtmPalets INT,@pmtmTarifaIva DECIMAL(14,4),@pmtmVrIva MONEY,@pmtmTarifaDct DECIMAL(14,4),@pmtmVrDscto MONEY,@pmtmTarifaRet DECIMAL(14,4),@pmtmVrRetFte MONEY,@pmtmTarifaIca DECIMAL(14,4),@pmtmVrReteIca MONEY,@pmtmVrFaltante MONEY,@pmtmRemision DECIMAL(18,2),@pmtmDocCliente VARCHAR(30),@pmtmReferencia1 VARCHAR(50),@pmtmReferencia2 VARCHAR(50),@pmtmReferencia3 VARCHAR(50)
,@pmtmCdMercancia VARCHAR(16),@pmtmCdConc VARCHAR(4),@pmtmCdCCosto VARCHAR(16),@pmtmCdSubCos VARCHAR(16),@pmtmNitTercero VARCHAR(16),@pmtmCdAgencia VARCHAR(16),@pmtmpVehiculo VARCHAR(10),@pmtmTipoVehic VARCHAR(10),@pmtmNitRemite VARCHAR(16),@pmtmRemitente VARCHAR(250),@pmtmDirOrigen VARCHAR(250),@pmtmIdOrigen VARCHAR(8),@pmtmNitDestntario VARCHAR(16),@pmtmDestinatario VARCHAR(250),@pmtmDirDestino VARCHAR(250)
,@pmtmIdDestino VARCHAR(8),@pmtmCantFalt DECIMAL(14,4),@pmtmUnidadFalt VARCHAR(10),@pmtmCdTarRet VARCHAR(4),@pmtmCdTarIca VARCHAR(4),@pmtmCdTarDct VARCHAR(4),@pmtmPedRem INT,@pmtmCiaPed CHAR(2),@pmtmEtdoFact INT,@pmtmFecRemesa SMALLDATETIME
 AS 
 INSERT INTO tm_TraRemFact (tmNumero,tmItem,tmTipoReg,tmTipRem,tmRemesa,tmIdCiaRem,tmItemRem,tmDescripcion,tmCantidad,tmVrUnitario,tmVrCosto,tmUndTarifa,tmUndCosto,tmUnidades,tmPesoNeto,tmUndMed,tmVolumen,tmUndVol,tmCases,tmCajas,tmPalets,tmTarifaIva,tmVrIva,tmTarifaDct,tmVrDscto,tmTarifaRet,tmVrRetFte,tmTarifaIca,tmVrReteIca,tmVrFaltante,tmRemision,tmDocCliente,tmReferencia1,tmReferencia2,tmReferencia3,tmCdMercancia,tmCdConc,tmCdCCosto,tmCdSubCos,tmNitTercero,tmCdAgencia
,tmpVehiculo,tmTipoVehic,tmNitRemite,tmRemitente,tmDirOrigen,tmIdOrigen,tmNitDestntario,tmDestinatario,tmDirDestino,tmIdDestino,tmCantFalt,tmUnidadFalt,tmCdTarRet,tmCdTarIca,tmCdTarDct,tmPedRem,tmCiaPed,tmEtdoFact,tmFecRemesa)
 VALUES (@pmtmNumero,@pmtmItem,@pmtmTipoReg,@pmtmTipRem,@pmtmRemesa,@pmtmIdCiaRem,@pmtmItemRem,@pmtmDescripcion,@pmtmCantidad,@pmtmVrUnitario,@pmtmVrCosto,@pmtmUndTarifa,@pmtmUndCosto,@pmtmUnidades,@pmtmPesoNeto,@pmtmUndMed,@pmtmVolumen,@pmtmUndVol,@pmtmCases,@pmtmCajas,@pmtmPalets,@pmtmTarifaIva,@pmtmVrIva,@pmtmTarifaDct,@pmtmVrDscto,@pmtmTarifaRet,@pmtmVrRetFte,@pmtmTarifaIca,@pmtmVrReteIca,@pmtmVrFaltante,@pmtmRemision
,@pmtmDocCliente,@pmtmReferencia1,@pmtmReferencia2,@pmtmReferencia3,@pmtmCdMercancia,@pmtmCdConc,@pmtmCdCCosto,@pmtmCdSubCos,@pmtmNitTercero,@pmtmCdAgencia,@pmtmpVehiculo,@pmtmTipoVehic,@pmtmNitRemite,@pmtmRemitente,@pmtmDirOrigen,@pmtmIdOrigen,@pmtmNitDestntario,@pmtmDestinatario,@pmtmDirDestino,@pmtmIdDestino,@pmtmCantFalt,@pmtmUnidadFalt,@pmtmCdTarRet,@pmtmCdTarIca,@pmtmCdTarDct,@pmtmPedRem,@pmtmCiaPed,@pmtmEtdoFact,@pmtmFecRemesa)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInstm_TraRemFact_Sel @pmTipDoc VARCHAR(3),@pmFactura INT,@pmIdCia CHAR(2),@pmtmNumero VARCHAR(5)
 AS 
 INSERT INTO tm_TraRemFact (tmNumero,tmItem,tmTipoReg,tmTipRem,tmRemesa,tmIdCiaRem,tmItemRem,tmDescripcion,tmCantidad,tmVrUnitario,tmVrCosto,tmUndTarifa,tmUndCosto,tmUnidades,tmPesoNeto,tmUndMed,tmVolumen,tmUndVol,tmCases,tmCajas,tmPalets
,tmTarifaIva,tmVrIva,tmTarifaDct,tmVrDscto,tmTarifaRet,tmVrRetFte,tmTarifaIca,tmVrReteIca,tmVrFaltante,tmRemision,tmDocCliente,tmReferencia1,tmReferencia2,tmReferencia3,tmCdMercancia,tmCdConc,tmCdCCosto,tmCdSubCos,tmNitTercero,tmCdAgencia
,tmpVehiculo,tmTipoVehic,tmNitRemite,tmRemitente,tmDirOrigen,tmIdOrigen,tmNitDestntario,tmDestinatario,tmDirDestino,tmIdDestino,tmCantFalt,tmUnidadFalt,tmCdTarRet,tmCdTarIca,tmCdTarDct,tmPedRem,tmCiaPed,tmEtdoFact,tmFecRemesa)
 SELECT @pmtmNumero,Item,TipoReg,TipRem,Remesa,IdCiaRem,ItemRem,Descripcion,Cantidad,VrUnitario,VrCosto,UndTarifa,UndCosto,Unidades,PesoNeto,UndMed,Volumen,UndVol,Cases,Cajas,Palets
,TarifaIva,VrImpuesto,TarifaDct,VrDescuento,TarifaRet,VrRetencion,TarifaIca,VrReteIca,VrFaltante,Remision,DocCliente,Referencia1,Referencia2,Referencia3,CdMercancia,CdConcepto,CdCCosto,CdSubCos,NitTercero,CdAgencia
,pVehiculo,TipoAfiVehic,'0','','',IdOrigen,'0','','',IdDestino,CantidadFalt,UnidadFalt,CodTarRet,CodTarIca,CodTarDct,NumPedRem,CiaPedRem,0,FecRemesa
 FROM Trn_TraFacRemesas
 WHERE TipDoc=@pmTipDoc AND Factura=@pmFactura AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsTraAntAbonos @pmTipDoc VARCHAR(3),@pmDocumento INT,@pmIdCia CHAR(2),@pmItem INT,@pmFecha SMALLDATETIME,@pmTipAnt VARCHAR(3)
,@pmAnticipo INT,@pmIdCiaAnt CHAR(2),@pmVrAbono MONEY,@pmTipoAplica VARCHAR(10),@pmDetalle VARCHAR(100),@pmCdCuentaAnt VARCHAR(16)
 AS 
 INSERT INTO Trn_TraAntAbonos (TipDoc,Documento,IdCia,Item,Fecha,TipAnt,Anticipo,IdCiaAnt,VrAbono,TipoAplica,Detalle,CdCuentaAnt)
 VALUES (@pmTipDoc,@pmDocumento,@pmIdCia,@pmItem,@pmFecha,@pmTipAnt,@pmAnticipo,@pmIdCiaAnt,@pmVrAbono,@pmTipoAplica,@pmDetalle,@pmCdCuentaAnt)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraAnticipos @pmTipDoc VARCHAR(3),@pmAnticipo INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipMuc VARCHAR(3),@pmManifiesto INT,@pmIdCiaMuc CHAR(2),@pmIdVehiculo VARCHAR(10),@pmIdPoseedor VARCHAR(16),@pmIdConductor VARCHAR(16),@pmVrAnticipo MONEY,@pmVrAbonado MONEY
,@pmModalidad VARCHAR(10),@pmTipoPago VARCHAR(10),@pmNumCheque VARCHAR(20),@pmFecCheque SMALLDATETIME,@pmIdCta VARCHAR(4),@pmIdCuenta VARCHAR(16),@pmBeneficiario VARCHAR(150),@pmCantidad DECIMAL(14,4),@pmFechaVence SMALLDATETIME,@pmNumPresAnt INT, @pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmAnulado BIT
,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmOrigenAdd VARCHAR(10),@pmTimeSys SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraAnticipos (TipDoc,Anticipo,IdCia,Fecha,IdConcepto,TipMuc,Manifiesto,IdCiaMuc,IdVehiculo,IdPoseedor,IdConductor,VrAnticipo,VrAbonado,Modalidad,TipoPago,NumCheque,FecCheque,IdCta,IdCuenta,Beneficiario,Cantidad,FechaVence,NumPresAnt,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,IdEstado,OrigenAdd,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDoc,@pmAnticipo,@pmIdCia,@pmFecha,@pmIdConcepto,@pmTipMuc,@pmManifiesto,@pmIdCiaMuc,@pmIdVehiculo,@pmIdPoseedor,@pmIdConductor,@pmVrAnticipo,@pmVrAbonado,@pmModalidad,@pmTipoPago,@pmNumCheque,@pmFecCheque,@pmIdCta,@pmIdCuenta,@pmBeneficiario,@pmCantidad,@pmFechaVence,@pmNumPresAnt,@pmTipCom,@pmComprobante
,@pmIdCiaCom,@pmAnulado,@pmNumDev,@pmFecDev,@pmObservacion,@pmIdEstado,@pmOrigenAdd,@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 paInsTraCauDetalle @pmTipDoc VARCHAR(3),@pmCausacion INT,@pmIdCia CHAR(2),@pmItem INT,@pmIdConcepto VARCHAR(4),@pmDescripcion VARCHAR(250),@pmTipoConc VARCHAR(10),@pmVrDebito MONEY,@pmVrCredito MONEY
,@pmCdCuenta VARCHAR(16),@pmNitTercero VARCHAR(16),@pmCdCCosto VARCHAR(16),@pmCdSubCos VARCHAR(16),@pmpVehiculo VARCHAR(10),@pmTipoAfiVehic VARCHAR(10),@pmVrBase MONEY,@pmTarifBase DECIMAL(14,4)
,@pmReferencia VARCHAR(50),@pmTipDocRef VARCHAR(3),@pmDocRef INT,@pmTipFac VARCHAR(3),@pmFactura VARCHAR(15),@pmIdCiaFac CHAR(2),@pmItemFac INT,@pmFecVence SMALLDATETIME
,@pmEstadoReg INT,@pmTipoLiq VARCHAR(3),@pmNumLiquida INT,@pmCiaLiquida CHAR(2),@pmVrAbonado MONEY
 AS 
 INSERT INTO Trn_TraCauDetalle (TipDoc,Causacion,IdCia,Item,IdConcepto,Descripcion,TipoConc,VrDebito,VrCredito,CdCuenta,NitTercero,CdCCosto,CdSubCos,pVehiculo,TipoAfiVehic,VrBase,TarifBase,Referencia
,TipDocRef,DocRef,TipFac,Factura,IdCiaFac,ItemFac,FecVence,EstadoReg,TipoLiq,NumLiquida,CiaLiquida,VrAbonado)
 VALUES (@pmTipDoc,@pmCausacion,@pmIdCia,@pmItem,@pmIdConcepto,@pmDescripcion,@pmTipoConc,@pmVrDebito,@pmVrCredito,@pmCdCuenta,@pmNitTercero,@pmCdCCosto,@pmCdSubCos,@pmpVehiculo,@pmTipoAfiVehic,@pmVrBase
,@pmTarifBase,@pmReferencia,@pmTipDocRef,@pmDocRef,@pmTipFac,@pmFactura,@pmIdCiaFac,@pmItemFac,@pmFecVence,@pmEstadoReg,@pmTipoLiq,@pmNumLiquida,@pmCiaLiquida,@pmVrAbonado)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraCausacion @pmTipDoc VARCHAR(3),@pmCausacion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmIdProv VARCHAR(16),@pmFactura VARCHAR(20),@pmVrTotal MONEY,@pmVrOtros MONEY,@pmVrNeto MONEY
,@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmOrigenAdd VARCHAR(10),@pmTimeSys SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraCausacion (TipDoc,Causacion,IdCia,Fecha,IdConcepto,IdProv,Factura,VrTotal,VrOtros,VrNeto,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,IdEstado,OrigenAdd,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDoc,@pmCausacion,@pmIdCia,@pmFecha,@pmIdConcepto,@pmIdProv,@pmFactura,@pmVrTotal,@pmVrOtros,@pmVrNeto,@pmTipCom,@pmComprobante,@pmIdCiaCom,@pmAnulado,@pmNumDev,@pmFecDev,@pmObservacion,@pmIdEstado,@pmOrigenAdd,@pmTimeSys,@pmIdCiaCrea,@pmIdUsuario)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraConcCausac @pmIdConcepto VARCHAR(4),@pmConcepto VARCHAR(250)
,@pmIdCuenta VARCHAR(16),@pmTipoConc VARCHAR(10),@pmInactivo BIT
 AS 
 INSERT INTO TraConcCausac (IdConcepto,Concepto,IdCuenta,TipoConc,Inactivo)
 VALUES (@pmIdConcepto,@pmConcepto,@pmIdCuenta,@pmTipoConc,@pmInactivo)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsTraConceptos @pmTipDoc VARCHAR(3),@pmDocumento INT,@pmIdCia CHAR(2),@pmItem INT,@pmDescripcion VARCHAR(250),@pmTarifa DECIMAL(14,4),@pmTipoConc VARCHAR(10),@pmRubroConcep VARCHAR(20)
,@pmCantidad DECIMAL(14,4),@pmVrUnitario MONEY,@pmTarifIva DECIMAL(14,4),@pmIdConcepto VARCHAR(4),@pmCdCuenta VARCHAR(16),@pmNitTercero VARCHAR(16),@pmCdTipoEsc VARCHAR(4),@pmFechaNov SMALLDATETIME
,@pmVrBase MONEY,@pmTipoTarif CHAR(1),@pmRefConc VARCHAR(50),@pmFijos BIT
 AS 
 INSERT INTO Trn_TraConceptos (TipDoc,Documento,IdCia,Item,Descripcion,Tarifa,TipoConc,RubroConcep,Cantidad,VrUnitario,TarifIva,IdConcepto,CdCuenta,NitTercero,CdTipoEsc,FechaNov,VrBase,TipoTarif,RefConc,Fijos)
 VALUES (@pmTipDoc,@pmDocumento,@pmIdCia,@pmItem,@pmDescripcion,@pmTarifa,@pmTipoConc,@pmRubroConcep,@pmCantidad,@pmVrUnitario,@pmTarifIva,@pmIdConcepto,@pmCdCuenta,@pmNitTercero
,@pmCdTipoEsc,@pmFechaNov,@pmVrBase,@pmTipoTarif,@pmRefConc,@pmFijos)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraCumplido @pmTipDoc VARCHAR(3),@pmCumplido INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmTipMuc VARCHAR(3),@pmManifiesto INT,@pmIdCiaMuc CHAR(2),@pmIdVehiculo VARCHAR(10),@pmModalidad VARCHAR(10),@pmDiasPlazo INT
,@pmFecPago SMALLDATETIME,@pmTipoMargen VARCHAR(10),@pmMargenFalt DECIMAL(14,4),@pmUndCalcFalt VARCHAR(10),@pmTarifFaltPago MONEY,@pmTarifFaltCobro MONEY,@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(1000),@pmIdEstado VARCHAR(4),@pmOrigenAdd VARCHAR(10),@pmTimeSys SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraCumplido (TipDoc,Cumplido,IdCia,Fecha,TipMuc,Manifiesto,IdCiaMuc,IdVehiculo,Modalidad,DiasPlazo,FecPago,TipoMargen,MargenFalt,UndCalcFalt,TarifFaltPago,TarifFaltCobro,Anulado,FecDev,Observacion,IdEstado,OrigenAdd,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDoc,@pmCumplido,@pmIdCia,@pmFecha,@pmTipMuc,@pmManifiesto,@pmIdCiaMuc,@pmIdVehiculo,@pmModalidad,@pmDiasPlazo,@pmFecPago,@pmTipoMargen,@pmMargenFalt,@pmUndCalcFalt,@pmTarifFaltPago,@pmTarifFaltCobro,@pmAnulado,@pmFecDev,@pmObservacion
,@pmIdEstado,@pmOrigenAdd,@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 paInsTraCumRemesas @pmTipDoc VARCHAR(3),@pmCumplido INT,@pmIdCia CHAR(2),@pmItem INT,@pmTipRem VARCHAR(3),@pmRemesa INT,@pmIdCiaRem CHAR(2),@pmItemRem INT,@pmCantidad DECIMAL(14,4),@pmPesoNeto DECIMAL(14,4),@pmUndMed VARCHAR(10),@pmVolumen DECIMAL(14,4),@pmUndVol VARCHAR(10)
,@pmCases INT,@pmCajas INT,@pmPalets INT,@pmTarifClie MONEY,@pmTarifPago MONEY,@pmUndTarifClie VARCHAR(10),@pmUndTarifPago VARCHAR(10),@pmCantCargue DECIMAL(14,4),@pmPesoCargue DECIMAL(14,4),@pmVolCargue DECIMAL(14,4),@pmCasesCargue INT,@pmCajasCargue INT,@pmPaletsCargue INT,@pmEstadoCump INT
,@pmRemision DECIMAL(18,2),@pmDocCliente VARCHAR(30),@pmReferencia1 VARCHAR(50),@pmReferencia2 VARCHAR(50),@pmReferencia3 VARCHAR(50),@pmDetalle VARCHAR(250)
 AS 
 INSERT INTO Trn_TraCumRemesas (TipDoc,Cumplido,IdCia,Item,TipRem,Remesa,IdCiaRem,ItemRem,Cantidad,PesoNeto,UndMed,Volumen,UndVol,Cases,Cajas,Palets,TarifClie,TarifPago,UndTarifClie,UndTarifPago,CantCargue,PesoCargue,VolCargue,CasesCargue,CajasCargue,PaletsCargue,EstadoCump,Remision,DocCliente,Referencia1,Referencia2,Referencia3,Detalle)
 VALUES (@pmTipDoc,@pmCumplido,@pmIdCia,@pmItem,@pmTipRem,@pmRemesa,@pmIdCiaRem,@pmItemRem,@pmCantidad,@pmPesoNeto,@pmUndMed,@pmVolumen,@pmUndVol,@pmCases,@pmCajas,@pmPalets,@pmTarifClie,@pmTarifPago,@pmUndTarifClie,@pmUndTarifPago,@pmCantCargue,@pmPesoCargue,@pmVolCargue,@pmCasesCargue
,@pmCajasCargue,@pmPaletsCargue,@pmEstadoCump,@pmRemision,@pmDocCliente,@pmReferencia1,@pmReferencia2,@pmReferencia3,@pmDetalle)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsTraDespProgram @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2),@pmItem INT,@pmCdRuta VARCHAR(4),@pmIdPunto INT
,@pmHoraProg SMALLDATETIME,@pmTipoProg INT,@pmIdUsuario VARCHAR(11),@pmFechaCrea SMALLDATETIME,@pmObservProg VARCHAR(250)
 AS 
 INSERT INTO Trn_TraDespProgram (TipDoc,Manifiesto,IdCia,Item,CdRuta,IdPunto,HoraProg,TipoProg,IdUsuario,FechaCrea,ObservProg)
 VALUES (@pmTipDoc,@pmManifiesto,@pmIdCia,@pmItem,@pmCdRuta,@pmIdPunto,@pmHoraProg,@pmTipoProg,@pmIdUsuario,@pmFechaCrea,@pmObservProg)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraDespachos @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmFecCargue SMALLDATETIME,@pmFecDespacho SMALLDATETIME,@pmIdOrigen VARCHAR(8),@pmIdDestino VARCHAR(8),@pmIdRuta VARCHAR(4)
,@pmIdVehiculo VARCHAR(10),@pmIdConductor VARCHAR(16),@pmIdPoseedor VARCHAR(16),@pmNitRemite VARCHAR(16),@pmRemitente VARCHAR(250),@pmNitDestntario VARCHAR(16),@pmDestinatario VARCHAR(250),@pmDescMcia VARCHAR(150),@pmPesoTotal DECIMAL(14,4)
,@pmNumOrden INT,@pmIdCiaOrd CHAR(2),@pmRemesa INT,@pmIdCiaRem CHAR(2),@pmEstado INT,@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmTimeSys SMALLDATETIME,@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraDespachos (TipDoc,Manifiesto,IdCia,Fecha,FecCargue,FecDespacho,IdOrigen,IdDestino,IdRuta,IdVehiculo,IdConductor,IdPoseedor,NitRemite,Remitente,NitDestntario,Destinatario,DescMcia,PesoTotal,NumOrden,IdCiaOrd,Remesa,IdCiaRem,Estado,Anulado,FecDev,Observacion,TimeSys,IdUsuario)
 VALUES (@pmTipDoc,@pmManifiesto,@pmIdCia,@pmFecha,@pmFecCargue,@pmFecDespacho,@pmIdOrigen,@pmIdDestino,@pmIdRuta,@pmIdVehiculo,@pmIdConductor,@pmIdPoseedor,@pmNitRemite,@pmRemitente,@pmNitDestntario,@pmDestinatario,@pmDescMcia,@pmPesoTotal,@pmNumOrden
,@pmIdCiaOrd,@pmRemesa,@pmIdCiaRem,@pmEstado,@pmAnulado,@pmFecDev,@pmObservacion,@pmTimeSys,@pmIdUsuario)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraDevAnt @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipDoc VARCHAR(3),@pmAnticipo INT,@pmIdCiaDoc CHAR(2),@pmFecDoc SMALLDATETIME
,@pmIdVehiculo VARCHAR(10),@pmIdPoseedor VARCHAR(16),@pmIdConductor VARCHAR(16),@pmVrDevolucion MONEY,@pmCdCta VARCHAR(4),@pmCdCuenta VARCHAR(16),@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_TraDevAnt (TipDev,Devolucion,IdCia,Fecha,IdConcepto,TipDoc,Anticipo,IdCiaDoc,FecDoc,IdVehiculo,IdPoseedor,IdConductor,VrDevolucion,CdCta,CdCuenta,ModdDev,OrigenAdd,TipCom,Comprobante,IdCiaCom,Observacion,IdEstado,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDev,@pmDevolucion,@pmIdCia,@pmFecha,@pmIdConcepto,@pmTipDoc,@pmAnticipo,@pmIdCiaDoc,@pmFecDoc,@pmIdVehiculo,@pmIdPoseedor,@pmIdConductor,@pmVrDevolucion,@pmCdCta,@pmCdCuenta,@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 ON 
GO

CREATE PROCEDURE paInsTraDevCau @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipDoc VARCHAR(3),@pmCausacion INT,@pmIdCiaDoc CHAR(2),@pmFecDoc SMALLDATETIME,@pmIdProv VARCHAR(16),@pmFactura VARCHAR(20),@pmVrTotal MONEY,@pmVrOtros MONEY
,@pmVrNeto 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_TraDevCau (TipDev,Devolucion,IdCia,Fecha,IdConcepto,TipDoc,Causacion,IdCiaDoc,FecDoc,IdProv,Factura,VrTotal,VrOtros,VrNeto,ModdDev,OrigenAdd,TipCom,Comprobante,IdCiaCom,Observacion,IdEstado,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDev,@pmDevolucion,@pmIdCia,@pmFecha,@pmIdConcepto,@pmTipDoc,@pmCausacion,@pmIdCiaDoc,@pmFecDoc,@pmIdProv,@pmFactura,@pmVrTotal,@pmVrOtros,@pmVrNeto,@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 ON 
GO

CREATE PROCEDURE paInsTraDevLeg @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCiaDoc CHAR(2),@pmFecDoc SMALLDATETIME,@pmModalidad VARCHAR(10),@pmTipMuc VARCHAR(3),@pmManifiesto INT,@pmIdCiaMuc CHAR(2),@pmIdVehiculo VARCHAR(10),@pmIdConductor VARCHAR(16),@pmIdPropietario VARCHAR(16)
,@pmIdPoseedor VARCHAR(16),@pmNitEmpresa VARCHAR(16),@pmVrAnticipos MONEY,@pmVrGastos MONEY,@pmVrCombustible MONEY,@pmVrDiferencia MONEY,@pmgalsComb DECIMAL(14,4),@pmPesoTotal DECIMAL(14,4),@pmCantidad DECIMAL(14,4),@pmVolumen DECIMAL(14,4),@pmModdDev VARCHAR(10),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2)
,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmVrOtrosCred MONEY,@pmOrigenAdd VARCHAR(10),@pmTimeSys SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraDevLeg (TipDev,Devolucion,IdCia,Fecha,IdConcepto,TipDoc,Liquidacion,IdCiaDoc,FecDoc,Modalidad,TipMuc,Manifiesto,IdCiaMuc,IdVehiculo,IdConductor,IdPropietario,IdPoseedor,NitEmpresa,VrAnticipos,VrGastos,VrCombustible,VrDiferencia,VrOtrosCred,galsComb,PesoTotal,Cantidad,Volumen,ModdDev,OrigenAdd,TipCom,Comprobante,IdCiaCom,Observacion,IdEstado,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDev,@pmDevolucion,@pmIdCia,@pmFecha,@pmIdConcepto,@pmTipDoc,@pmLiquidacion,@pmIdCiaDoc,@pmFecDoc,@pmModalidad,@pmTipMuc,@pmManifiesto,@pmIdCiaMuc,@pmIdVehiculo,@pmIdConductor,@pmIdPropietario,@pmIdPoseedor,@pmNitEmpresa,@pmVrAnticipos,@pmVrGastos,@pmVrCombustible,@pmVrDiferencia,@pmVrOtrosCred,@pmgalsComb,@pmPesoTotal
,@pmCantidad,@pmVolumen,@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 ON 
GO

CREATE PROCEDURE paInsTraDevLiq @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCiaDoc CHAR(2),@pmFecDoc SMALLDATETIME
,@pmIdVehiculo VARCHAR(10),@pmIdPoseedor VARCHAR(16),@pmIdConductor VARCHAR(16),@pmVrTotal MONEY,@pmModdDev VARCHAR(10),@pmOrigenAdd VARCHAR(10),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2)
,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmTimeSys SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraDevLiq (TipDev,Devolucion,IdCia,Fecha,IdConcepto,TipDoc,Liquidacion,IdCiaDoc,FecDoc,IdVehiculo,IdPoseedor,IdConductor,VrTotal,ModdDev,OrigenAdd,TipCom,Comprobante,IdCiaCom,Observacion,IdEstado,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDev,@pmDevolucion,@pmIdCia,@pmFecha,@pmIdConcepto,@pmTipDoc,@pmLiquidacion,@pmIdCiaDoc,@pmFecDoc,@pmIdVehiculo,@pmIdPoseedor,@pmIdConductor,@pmVrTotal,@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 ON 
GO

CREATE PROCEDURE paInsTraDevOdp @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipDoc VARCHAR(3),@pmOrdPago INT,@pmIdCiaDoc CHAR(2),@pmFecDoc SMALLDATETIME
,@pmIdVehiculo VARCHAR(10),@pmIdPoseedor VARCHAR(16),@pmIdConductor VARCHAR(16),@pmCxPagar BIT,@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_TraDevOdp (TipDev,Devolucion,IdCia,Fecha,IdConcepto,TipDoc,OrdPago,IdCiaDoc,FecDoc,IdVehiculo,IdPoseedor,IdConductor,CxPagar,ModdDev,TipCom,Comprobante,IdCiaCom,Observacion,IdEstado,OrigenAdd,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDev,@pmDevolucion,@pmIdCia,@pmFecha,@pmIdConcepto,@pmTipDoc,@pmOrdPago,@pmIdCiaDoc,@pmFecDoc,@pmIdVehiculo,@pmIdPoseedor,@pmIdConductor,@pmCxPagar,@pmModdDev,@pmTipCom,@pmComprobante,@pmIdCiaCom
,@pmObservacion,@pmIdEstado,@pmOrigenAdd,@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 paInsTraFacRemesas @pmTipDoc VARCHAR(3),@pmFactura INT,@pmIdCia CHAR(2),@pmItem INT,@pmTipoReg INT,@pmFechaFact SMALLDATETIME,@pmTipRem VARCHAR(3),@pmRemesa INT,@pmIdCiaRem CHAR(2),@pmItemRem INT,@pmFecRemesa SMALLDATETIME,@pmDescripcion VARCHAR(250),@pmCantidad DECIMAL(14,4),@pmVrUnitario MONEY,@pmVrCosto MONEY,@pmUndTarifa VARCHAR(10),@pmUndCosto VARCHAR(10),@pmUnidades DECIMAL(14,4),@pmPesoNeto DECIMAL(14,4),@pmUndMed VARCHAR(10),@pmVolumen DECIMAL(14,4),@pmUndVol VARCHAR(10)
,@pmCases INT,@pmCajas INT,@pmPalets INT,@pmTarifaIva DECIMAL(14,4),@pmVrImpuesto MONEY,@pmTarifaDct DECIMAL(14,4),@pmVrDescuento MONEY,@pmTarifaRet DECIMAL(14,4),@pmVrRetencion MONEY,@pmTarifaIca DECIMAL(14,4),@pmVrReteIca MONEY,@pmVrFaltante MONEY,@pmRemision DECIMAL(18,2),@pmDocCliente VARCHAR(30),@pmReferencia1 VARCHAR(50),@pmReferencia2 VARCHAR(50),@pmReferencia3 VARCHAR(50),@pmCdMercancia VARCHAR(16),@pmCdConcepto VARCHAR(4),@pmCdCCosto VARCHAR(16),@pmCdSubCos VARCHAR(16)
,@pmNitTercero VARCHAR(16),@pmCdAgencia VARCHAR(16),@pmpVehiculo VARCHAR(10),@pmTipoAfiVehic VARCHAR(10),@pmIdOrigen VARCHAR(8),@pmIdDestino VARCHAR(8),@pmAnulado INT,@pmTipDocRef VARCHAR(3),@pmNumDocRef INT,@pmIdCiaRef CHAR(2),@pmFecDocRef SMALLDATETIME,@pmCantidadFalt DECIMAL(14,4),@pmUnidadFalt VARCHAR(10),@pmCodTarRet VARCHAR(4),@pmCodTarIca VARCHAR(4),@pmCodTarDct VARCHAR(4),@pmNumPedRem INT,@pmCiaPedRem CHAR(2)
 AS 
 INSERT INTO Trn_TraFacRemesas (TipDoc,Factura,IdCia,Item,TipoReg,FechaFact,TipRem,Remesa,IdCiaRem,ItemRem,FecRemesa,Descripcion,Cantidad,VrUnitario,VrCosto,UndTarifa,UndCosto,Unidades,PesoNeto,UndMed,Volumen,UndVol,Cases,Cajas,Palets,TarifaIva,VrImpuesto,TarifaDct,VrDescuento,TarifaRet,VrRetencion,TarifaIca,VrReteIca,VrFaltante,Remision,DocCliente,Referencia1,Referencia2,Referencia3,CdMercancia,CdConcepto,CdCCosto,CdSubCos,NitTercero,CdAgencia,pVehiculo,TipoAfiVehic,IdOrigen,IdDestino,Anulado,TipDocRef,NumDocRef,IdCiaRef,FecDocRef,CantidadFalt,UnidadFalt,CodTarRet,CodTarIca,CodTarDct,NumPedRem,CiaPedRem)
 VALUES (@pmTipDoc,@pmFactura,@pmIdCia,@pmItem,@pmTipoReg,@pmFechaFact,@pmTipRem,@pmRemesa,@pmIdCiaRem,@pmItemRem,@pmFecRemesa,@pmDescripcion,@pmCantidad,@pmVrUnitario,@pmVrCosto,@pmUndTarifa,@pmUndCosto,@pmUnidades,@pmPesoNeto,@pmUndMed,@pmVolumen,@pmUndVol,@pmCases,@pmCajas,@pmPalets,@pmTarifaIva,@pmVrImpuesto,@pmTarifaDct,@pmVrDescuento,@pmTarifaRet,@pmVrRetencion,@pmTarifaIca,@pmVrReteIca,@pmVrFaltante,@pmRemision,@pmDocCliente,@pmReferencia1,@pmReferencia2,@pmReferencia3
,@pmCdMercancia,@pmCdConcepto,@pmCdCCosto,@pmCdSubCos,@pmNitTercero,@pmCdAgencia,@pmpVehiculo,@pmTipoAfiVehic,@pmIdOrigen,@pmIdDestino,@pmAnulado,@pmTipDocRef,@pmNumDocRef,@pmIdCiaRef,@pmFecDocRef,@pmCantidadFalt,@pmUnidadFalt,@pmCodTarRet,@pmCodTarIca,@pmCodTarDct,@pmNumPedRem,@pmCiaPedRem)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraFijos @pmNumero INT,@pmIdConcepto VARCHAR(4),@pmDescConc VARCHAR(250),@pmTipoConc VARCHAR(10),@pmTarifa DECIMAL(14,4),@pmTipoTarif CHAR(1),@pmTipoAfilVeh VARCHAR(10),@pmCdTipoVeh VARCHAR(4),@pmAnulado BIT
 AS 
 INSERT INTO TraFijos (Numero,IdConcepto,DescConc,TipoConc,Tarifa,TipoTarif,TipoAfilVeh,CdTipoVeh,Anulado)
 VALUES (@pmNumero,@pmIdConcepto,@pmDescConc,@pmTipoConc,@pmTarifa,@pmTipoTarif,@pmTipoAfilVeh,@pmCdTipoVeh,@pmAnulado)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsTraLiqDetalle @pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2),@pmItem INT,@pmIdConcepto VARCHAR(4),@pmDescConcepto VARCHAR(250),@pmIdCuenta VARCHAR(16),@pmVrDebito MONEY,@pmVrCredito MONEY,@pmIdTercero VARCHAR(16),@pmCodAgncia VARCHAR(16)
,@pmCdCCosto VARCHAR(16),@pmCdSubCos VARCHAR(16),@pmpVehiculo VARCHAR(10),@pmRubroConc VARCHAR(10),@pmVrBase MONEY,@pmTarifBase DECIMAL(14,4),@pmCantComb DECIMAL(14,4),@pmTipFac VARCHAR(3),@pmFactura VARCHAR(15),@pmIdCiaFac CHAR(2),@pmItemFac INT
,@pmFecVence SMALLDATETIME,@pmRefConcep VARCHAR(50)
 AS 
 INSERT INTO Trn_TraLiqDetalle (TipDoc,Liquidacion,IdCia,Item,IdConcepto,DescConcepto,IdCuenta,VrDebito,VrCredito,IdTercero,CodAgncia,CdCCosto,CdSubCos,pVehiculo,RubroConc,VrBase,TarifBase,CantComb,TipFac,Factura,IdCiaFac,ItemFac,FecVence,RefConcep)
 VALUES (@pmTipDoc,@pmLiquidacion,@pmIdCia,@pmItem,@pmIdConcepto,@pmDescConcepto,@pmIdCuenta,@pmVrDebito,@pmVrCredito,@pmIdTercero,@pmCodAgncia,@pmCdCCosto,@pmCdSubCos,@pmpVehiculo,@pmRubroConc,@pmVrBase,@pmTarifBase
,@pmCantComb,@pmTipFac,@pmFactura,@pmIdCiaFac,@pmItemFac,@pmFecVence,@pmRefConcep)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsTraLiquida @pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmIdVehiculo VARCHAR(10),@pmIdPoseedor VARCHAR(16)
,@pmIdConductor VARCHAR(16),@pmVrTotal MONEY, @pmCxPagar BIT,@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250)
,@pmIdEstado VARCHAR(4),@pmOrigenAdd VARCHAR(10),@pmTimeSys SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraLiquida (TipDoc,Liquidacion,IdCia,Fecha,IdConcepto,IdVehiculo,IdPoseedor,IdConductor,VrTotal,CxPagar,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,IdEstado,OrigenAdd,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDoc,@pmLiquidacion,@pmIdCia,@pmFecha,@pmIdConcepto,@pmIdVehiculo,@pmIdPoseedor,@pmIdConductor,@pmVrTotal,@pmCxPagar,@pmTipCom,@pmComprobante,@pmIdCiaCom,@pmAnulado,@pmNumDev,@pmFecDev,@pmObservacion
,@pmIdEstado,@pmOrigenAdd,@pmTimeSys,@pmIdCiaCrea,@pmIdUsuario)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraLiqViajes @pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmModalidad VARCHAR(10),@pmTipMuc VARCHAR(3),@pmManifiesto INT,@pmIdCiaMuc CHAR(2),@pmFechaMuc SMALLDATETIME,@pmIdVehiculo VARCHAR(10)
,@pmIdConductor VARCHAR(16),@pmIdPropietario VARCHAR(16),@pmIdPoseedor VARCHAR(16),@pmNitEmpresa VARCHAR(16),@pmVrAnticipos MONEY,@pmVrGastos MONEY,@pmVrCombustible MONEY,@pmVrDiferencia MONEY,@pmgalsComb DECIMAL(14,4),@pmPesoTotal DECIMAL(14,4),@pmCantidad DECIMAL(14,4),@pmVolumen DECIMAL(14,4)
,@pmIdRuta VARCHAR(4),@pmIdLocOrigen VARCHAR(8),@pmIdLocDestino VARCHAR(8),@pmReferencia VARCHAR(50),@pmDescMcias VARCHAR(150),@pmkmtInicial DECIMAL(14,4),@pmkmtFinal DECIMAL(14,4),@pmEstFactura INT,@pmTipDocRef VARCHAR(3),@pmNumDocRef INT,@pmIdCiaRef CHAR(2),@pmFecDocRef SMALLDATETIME
,@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmVrOtrosCred MONEY,@pmOrigenAdd VARCHAR(10),@pmTimeSys SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraLiqViajes (TipDoc,Liquidacion,IdCia,Fecha,IdConcepto,Modalidad,TipMuc,Manifiesto,IdCiaMuc,FechaMuc,IdVehiculo,IdConductor,IdPropietario,IdPoseedor,NitEmpresa,VrAnticipos,VrGastos,VrCombustible,VrOtrosCred,VrDiferencia,galsComb,PesoTotal,Cantidad,Volumen,IdRuta,IdLocOrigen,IdLocDestino,Referencia,DescMcias
,kmtInicial,kmtFinal,EstFactura,TipDocRef,NumDocRef,IdCiaRef,FecDocRef,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,IdEstado,OrigenAdd,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDoc,@pmLiquidacion,@pmIdCia,@pmFecha,@pmIdConcepto,@pmModalidad,@pmTipMuc,@pmManifiesto,@pmIdCiaMuc,@pmFechaMuc,@pmIdVehiculo,@pmIdConductor,@pmIdPropietario,@pmIdPoseedor,@pmNitEmpresa,@pmVrAnticipos,@pmVrGastos,@pmVrCombustible,@pmVrOtrosCred,@pmVrDiferencia,@pmgalsComb
,@pmPesoTotal,@pmCantidad,@pmVolumen,@pmIdRuta,@pmIdLocOrigen,@pmIdLocDestino,@pmReferencia,@pmDescMcias,@pmkmtInicial,@pmkmtFinal,@pmEstFactura,@pmTipDocRef,@pmNumDocRef,@pmIdCiaRef,@pmFecDocRef,@pmTipCom,@pmComprobante,@pmIdCiaCom,@pmAnulado,@pmNumDev,@pmFecDev,@pmObservacion,@pmIdEstado,@pmOrigenAdd,@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 paInsTraLiquidaDed @pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2),@pmItem INT,@pmTipCau VARCHAR(3),@pmCausacion INT,@pmIdCiaCau CHAR(2),@pmItemCau INT,@pmFechaCau SMALLDATETIME,@pmIdConcepto VARCHAR(4)
,@pmDescripcion VARCHAR(250),@pmVrAbono MONEY,@pmNitPoseedor VARCHAR(16),@pmpVehiculo VARCHAR(10),@pmEsVence BIT,@pmTipOdp VARCHAR(3),@pmOrdenPago INT,@pmIdCiaOdp CHAR(2),@pmTipMuc VARCHAR(3),@pmManifiesto INT,@pmIdCiaMuc CHAR(2)
,@pmVrSaldoOrden MONEY,@pmCdCuenta VARCHAR(16),@pmCdCuePagar VARCHAR(16),@pmNumFactura VARCHAR(20),@pmCdCCosto  VARCHAR(16),@pmCdSubCos VARCHAR(16)
 AS 
 INSERT INTO Trn_TraLiquidaDed (TipDoc,Liquidacion,IdCia,Item,TipCau,Causacion,IdCiaCau,ItemCau,FechaCau,IdConcepto,Descripcion,VrAbono,NitPoseedor,pVehiculo,EsVence,TipOdp,OrdenPago,IdCiaOdp
,TipMuc,Manifiesto,IdCiaMuc,VrSaldoOrden,CdCuenta,CdCuePagar,NumFactura,CdCCosto,CdSubCos)
 VALUES (@pmTipDoc,@pmLiquidacion,@pmIdCia,@pmItem,@pmTipCau,@pmCausacion,@pmIdCiaCau,@pmItemCau,@pmFechaCau,@pmIdConcepto,@pmDescripcion,@pmVrAbono,@pmNitPoseedor,@pmpVehiculo,@pmEsVence,@pmTipOdp,@pmOrdenPago,@pmIdCiaOdp
,@pmTipMuc,@pmManifiesto,@pmIdCiaMuc,@pmVrSaldoOrden,@pmCdCuenta,@pmCdCuePagar,@pmNumFactura,@pmCdCCosto,@pmCdSubCos)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE 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)
 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)
 VALUES (@pmTipDoc,@pmManifiesto,@pmIdCia,@pmkmsTotal,@pmVrFleteTon,@pmTipoRuta,@pmCdLocTrao,@pmCdLocTrad,@pmKmsTraOri,@pmKmsTraDes,@pmIdMneda,@pmVrTasa
,@pmNomRemite,@pmNomDestino,@pmLugarFletes,@pmNumAnticipo,@pmNumCheque,@pmTipoMintrans,@pmMucMintrans,@pmContIntegral,@pmVolumenCarga,@pmNumPoliza)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraManifiesto @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmFecDespacho SMALLDATETIME,@pmFecEntrega SMALLDATETIME,@pmIdOrigen VARCHAR(8),@pmIdDestino VARCHAR(8),@pmIdRuta VARCHAR(4),@pmIdRutaFle VARCHAR(4),@pmIdVehiculo VARCHAR(10),@pmIdConductor VARCHAR(16),@pmnRemolque VARCHAR(10),@pmTipoAfiVehic VARCHAR(10),@pmIdPropietario VARCHAR(16),@pmIdPoseedor VARCHAR(16),@pmVrFletes MONEY,@pmVrRetencion MONEY
,@pmVrReteIca MONEY,@pmVrDescuento MONEY,@pmVrAnticipo MONEY,@pmVrAntAdic MONEY,@pmVrNeto MONEY,@pmVrPagos MONEY,@pmVrCargos MONEY,@pmVrDctos MONEY,@pmTarifaFlete MONEY,@pmCantidad DECIMAL(14,4),@pmPesoTotal DECIMAL(14,4),@pmBaseRet MONEY,@pmTarifaRet DECIMAL(14,4),@pmTarifaIca DECIMAL(14,4),@pmCodTarRet VARCHAR(4),@pmCodTarIca VARCHAR(4),@pmIdLocFletes VARCHAR(8),@pmFechaPago SMALLDATETIME,@pmPagoCargue VARCHAR(50),@pmPagoDescargue VARCHAR(50)
,@pmNumMintrans DECIMAL(14,2),@pmEdoMintrans VARCHAR(5),@pmRemesa INT,@pmIdCiaRem CHAR(2),@pmCumplido INT,@pmIdCiaCump CHAR(2),@pmFechaCump SMALLDATETIME,@pmEstCumplido INT,@pmTipOdp VARCHAR(3),@pmOrdPago INT,@pmIdCiaOdp CHAR(2),@pmFechaOdp SMALLDATETIME,@pmEstOrden INT, @pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmOrigenAdd VARCHAR(10),@pmTimeSys SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraManifiesto (TipDoc,Manifiesto,IdCia,Fecha,FecDespacho,FecEntrega,IdOrigen,IdDestino,IdRuta,IdRutaFle,IdVehiculo,IdConductor,nRemolque,TipoAfiVehic,IdPropietario,IdPoseedor,VrFletes,VrRetencion,VrReteIca,VrDescuento,VrAnticipo,VrAntAdic,VrNeto,VrPagos,VrCargos,VrDctos,TarifaFlete,Cantidad,PesoTotal,BaseRet,TarifaRet,TarifaIca,CodTarRet,CodTarIca,IdLocFletes,FechaPago,PagoCargue,PagoDescargue,NumMintrans,EdoMintrans,Remesa,IdCiaRem,Cumplido,IdCiaCump,FechaCump,EstCumplido
,TipOdp,OrdPago,IdCiaOdp,FechaOdp,EstOrden,OrigenAdd,Anulado,FecDev,Observacion,IdEstado,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDoc,@pmManifiesto,@pmIdCia,@pmFecha,@pmFecDespacho,@pmFecEntrega,@pmIdOrigen,@pmIdDestino,@pmIdRuta,@pmIdRutaFle,@pmIdVehiculo,@pmIdConductor,@pmnRemolque,@pmTipoAfiVehic,@pmIdPropietario,@pmIdPoseedor,@pmVrFletes,@pmVrRetencion,@pmVrReteIca,@pmVrDescuento,@pmVrAnticipo,@pmVrAntAdic,@pmVrNeto,@pmVrPagos,@pmVrCargos,@pmVrDctos,@pmTarifaFlete,@pmCantidad,@pmPesoTotal,@pmBaseRet,@pmTarifaRet,@pmTarifaIca
,@pmCodTarRet,@pmCodTarIca,@pmIdLocFletes,@pmFechaPago,@pmPagoCargue,@pmPagoDescargue,@pmNumMintrans,@pmEdoMintrans,@pmRemesa,@pmIdCiaRem,@pmCumplido,@pmIdCiaCump,@pmFechaCump,@pmEstCumplido,@pmTipOdp,@pmOrdPago,@pmIdCiaOdp,@pmFechaOdp,@pmEstOrden,@pmOrigenAdd,@pmAnulado,@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 paInsTraManifRem @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2),@pmItem INT,@pmTipRem VARCHAR(3)
,@pmRemesa INT,@pmIdCiaRem CHAR(2),@pmItemRem INT,@pmTarifTabla MONEY,@pmTarifPago MONEY,@pmRemMintrans DECIMAL(14,2),@pmEdoRemMin VARCHAR(5)
 AS 
 INSERT INTO Trn_TraManifRem (TipDoc,Manifiesto,IdCia,Item,TipRem,Remesa,IdCiaRem,ItemRem,TarifTabla,TarifPago,RemMintrans,EdoRemMin)
 VALUES (@pmTipDoc,@pmManifiesto,@pmIdCia,@pmItem,@pmTipRem,@pmRemesa,@pmIdCiaRem,@pmItemRem,@pmTarifTabla
,@pmTarifPago,@pmRemMintrans,@pmEdoRemMin)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraOrdenManif @pmTipDoc VARCHAR(3),@pmOrdPago INT,@pmIdCia CHAR(2),@pmItem INT,@pmTipMuc VARCHAR(3),@pmManifiesto INT,@pmIdCiaMuc CHAR(2),@pmIdVehiculo VARCHAR(10),@pmIdConductor VARCHAR(16),@pmIdPropietario VARCHAR(16),@pmIdPoseedor VARCHAR(16),@pmVrTotalFletes MONEY,@pmVrDescuento MONEY,@pmVrRetencion MONEY,@pmVrReteIca MONEY
,@pmVrAnticipos MONEY,@pmVrFaltantes MONEY,@pmVrSeguros MONEY,@pmVrFondos MONEY,@pmVrAportes MONEY,@pmVrOtrosDctos MONEY,@pmVrImpuestos MONEY,@pmVrEstampilla MONEY,@pmVrOtrosPagos MONEY,@pmVrNeto MONEY,@pmTarifaTabla MONEY,@pmTarifaFlete MONEY,@pmUnidTarifa VARCHAR(10),@pmPesoTotal DECIMAL(14,4),@pmUnidades DECIMAL(14,4),@pmVolumen DECIMAL(14,4),@pmPesoOrigen DECIMAL(14,4)
,@pmUnidOrigen DECIMAL(14,4),@pmVolOrigen DECIMAL(14,4),@pmPesoDestino  DECIMAL(14,4),@pmUnidDestino DECIMAL(14,4),@pmVolDestino DECIMAL(14,4),@pmBaseRet MONEY,@pmBaseIca MONEY,@pmBaseSeg MONEY,@pmBaseImp MONEY,@pmTarifaRet DECIMAL(14,4),@pmTarifaIca DECIMAL(14,4),@pmTarifaSeg DECIMAL(14,4),@pmTarifaImp DECIMAL(14,4),@pmCodTarRet VARCHAR(4),@pmCodTarIca VARCHAR(4),@pmTipoLiq INT
,@pmTipEgr VARCHAR(3),@pmEgreso INT,@pmIdCiaEgr CHAR(2),@pmNumCheque VARCHAR(20),@pmReferencia VARCHAR(50),@pmCantFaltante DECIMAL(14,4),@pmUnidadFalt VARCHAR(10),@pmTolFaltNeto DECIMAL(14,4),@pmVrConcPagos MONEY,@pmVrConcDctos MONEY,@pmVrConcFondo MONEY,@pmVrConcSeguro MONEY,@pmVrConcAporte MONEY,@pmVrConcImpuesto MONEY,@pmEdoLiqCausac INT
 AS 
 INSERT INTO Trn_TraOrdenManif (TipDoc,OrdPago,IdCia,Item,TipMuc,Manifiesto,IdCiaMuc,IdVehiculo,IdConductor,IdPropietario,IdPoseedor,VrTotalFletes,VrDescuento,VrRetencion,VrReteIca,VrAnticipos,VrFaltantes,VrSeguros,VrFondos,VrAportes,VrOtrosDctos,VrImpuestos,VrEstampilla,VrOtrosPagos,VrNeto,TarifaTabla
,TarifaFlete,UnidTarifa,PesoTotal,Unidades,Volumen,PesoOrigen,UnidOrigen,VolOrigen,PesoDestino,UnidDestino,VolDestino,BaseRet,BaseIca,BaseSeg,BaseImp,TarifaRet,TarifaIca,TarifaSeg,TarifaImp,CodTarRet,CodTarIca,TipoLiq,TipEgr,Egreso,IdCiaEgr,NumCheque,Referencia,CantFaltante,UnidadFalt,TolFaltNeto,VrConcPagos,VrConcDctos,VrConcFondo,VrConcSeguro,VrConcAporte,VrConcImpuesto,EdoLiqCausac)
 VALUES (@pmTipDoc,@pmOrdPago,@pmIdCia,@pmItem,@pmTipMuc,@pmManifiesto,@pmIdCiaMuc,@pmIdVehiculo,@pmIdConductor,@pmIdPropietario,@pmIdPoseedor,@pmVrTotalFletes,@pmVrDescuento,@pmVrRetencion,@pmVrReteIca,@pmVrAnticipos,@pmVrFaltantes,@pmVrSeguros
,@pmVrFondos,@pmVrAportes,@pmVrOtrosDctos,@pmVrImpuestos,@pmVrEstampilla,@pmVrOtrosPagos,@pmVrNeto,@pmTarifaTabla,@pmTarifaFlete,@pmUnidTarifa,@pmPesoTotal,@pmUnidades,@pmVolumen,@pmPesoOrigen,@pmUnidOrigen,@pmVolOrigen,@pmPesoDestino,@pmUnidDestino,@pmVolDestino,@pmBaseRet,@pmBaseIca,@pmBaseSeg,@pmBaseImp,@pmTarifaRet,@pmTarifaIca,@pmTarifaSeg,@pmTarifaImp,@pmCodTarRet,@pmCodTarIca,@pmTipoLiq
,@pmTipEgr,@pmEgreso,@pmIdCiaEgr,@pmNumCheque,@pmReferencia,@pmCantFaltante,@pmUnidadFalt,@pmTolFaltNeto,@pmVrConcPagos,@pmVrConcDctos,@pmVrConcFondo,@pmVrConcSeguro,@pmVrConcAporte,@pmVrConcImpuesto,@pmEdoLiqCausac)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraOrdenPago  @pmTipDoc VARCHAR(3),@pmOrdPago INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmModalidad VARCHAR(10),@pmLiqRemesas BIT,@pmCxPagar BIT,@pmMulPlazos BIT,@pmIdPlazo VARCHAR(4),@pmFechaVence SMALLDATETIME
,@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmOrigenAdd VARCHAR(10),@pmTimeSys SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraOrdenPago (TipDoc,OrdPago,IdCia,Fecha,IdConcepto,Modalidad,LiqRemesas,CxPagar,MulPlazos,IdPlazo,FechaVence,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,IdEstado,OrigenAdd,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDoc,@pmOrdPago,@pmIdCia,@pmFecha,@pmIdConcepto,@pmModalidad,@pmLiqRemesas,@pmCxPagar,@pmMulPlazos,@pmIdPlazo,@pmFechaVence,@pmTipCom,@pmComprobante,@pmIdCiaCom
,@pmAnulado,@pmNumDev,@pmFecDev,@pmObservacion,@pmIdEstado,@pmOrigenAdd,@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 paInsTraOrdenRemesas @pmTipDoc VARCHAR(3),@pmOrdPago INT,@pmIdCia CHAR(2),@pmItem INT,@pmTipMuc VARCHAR(3),@pmManifiesto INT,@pmIdCiaMuc CHAR(2),@pmTipRem VARCHAR(3),@pmRemesa INT,@pmIdCiaRem CHAR(2)
,@pmItemRem INT,@pmCantidad DECIMAL(14,4),@pmPesoNeto DECIMAL(14,4),@pmUndMed VARCHAR(10),@pmVolumen DECIMAL(14,4),@pmUndVol VARCHAR(10),@pmCases INT,@pmCajas INT,@pmPalets INT,@pmTarifPago MONEY,@pmTarifTabla MONEY
,@pmUndTarifa VARCHAR(10),@pmDetalle VARCHAR(250)
 AS 
 INSERT INTO Trn_TraOrdenRemesas (TipDoc,OrdPago,IdCia,Item,TipMuc,Manifiesto,IdCiaMuc,TipRem,Remesa,IdCiaRem,ItemRem,Cantidad,PesoNeto,UndMed,Volumen,UndVol,Cases,Cajas,Palets,TarifPago,TarifTabla,UndTarifa,Detalle)
 VALUES (@pmTipDoc,@pmOrdPago,@pmIdCia,@pmItem,@pmTipMuc,@pmManifiesto,@pmIdCiaMuc,@pmTipRem,@pmRemesa,@pmIdCiaRem,@pmItemRem,@pmCantidad,@pmPesoNeto,@pmUndMed,@pmVolumen,@pmUndVol
,@pmCases,@pmCajas,@pmPalets,@pmTarifPago,@pmTarifTabla,@pmUndTarifa,@pmDetalle)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsTraPedAnexo @pmTipDoc VARCHAR(3),@pmPedido INT,@pmIdCia CHAR(2),@pmNomCliente VARCHAR(150),@pmNomRemite VARCHAR(150),@pmNomDestino VARCHAR(150),@pmLugarCargue VARCHAR(150),@pmLugarDescargue VARCHAR(150),@pmNomContacto VARCHAR(150),@pmTelContacto VARCHAR(30),@pmemlContacto VARCHAR(100),@pmContacDestino VARCHAR(150),@pmTelContacDest VARCHAR(30),@pmemlContacDest VARCHAR(100),@pmPolizaEsp BIT
,@pmNumPolizaEsp VARCHAR(50),@pmNitCiaPoliza VARCHAR(16),@pmNomCiaPoliza VARCHAR(150),@pmFecVencePol SMALLDATETIME,@pmVrLimiteDesp MONEY,@pmSeguros VARCHAR(10),@pmCargue VARCHAR(20),@pmDescargue VARCHAR(20),@pmCdTipoEsc VARCHAR(4),@pmNitSIA VARCHAR(16),@pmNombreSIA VARCHAR(150),@pmContactoSIA VARCHAR(150),@pmTelContacSIA VARCHAR(30),@pmIdLocCont VARCHAR(8),@pmPatioCont VARCHAR(50),@pmCdTipoVeh VARCHAR(4)
,@pmTipoMargen VARCHAR(10),@pmMargenFalt DECIMAL(14,4),@pmEmbAdicional VARCHAR(150),@pmTipoRuta VARCHAR(10),@pmTipoTrans VARCHAR(10),@pmEmbarque VARCHAR(10),@pmCdTipCarga VARCHAR(4),@pmDevContenedor BIT,@pmUndCalcFalt VARCHAR(10),@pmTarifFaltPago MONEY,@pmTarifFaltCobro MONEY,@pmCdRutaTarif VARCHAR(4)
 AS 
 INSERT INTO Trn_TraPedAnexo (TipDoc,Pedido,IdCia,NomCliente,NomRemite,NomDestino,LugarCargue,LugarDescargue,NomContacto,TelContacto,emlContacto,ContacDestino,TelContacDest,emlContacDest,PolizaEsp,NumPolizaEsp,NitCiaPoliza,NomCiaPoliza,FecVencePol,VrLimiteDesp,Seguros,Cargue,Descargue,CdTipoEsc,NitSIA,NombreSIA,ContactoSIA,TelContacSIA
,TipoRuta,TipoTrans,Embarque,CdTipCarga,DevContenedor,IdLocCont,PatioCont,CdTipoVeh,MargenFalt,TipoMargen,UndCalcFalt,TarifFaltPago,TarifFaltCobro,EmbAdicional,CdRutaTarif)
 VALUES (@pmTipDoc,@pmPedido,@pmIdCia,@pmNomCliente,@pmNomRemite,@pmNomDestino,@pmLugarCargue,@pmLugarDescargue,@pmNomContacto,@pmTelContacto,@pmemlContacto,@pmContacDestino,@pmTelContacDest,@pmemlContacDest,@pmPolizaEsp,@pmNumPolizaEsp,@pmNitCiaPoliza,@pmNomCiaPoliza,@pmFecVencePol,@pmVrLimiteDesp,@pmSeguros,@pmCargue,@pmDescargue,@pmCdTipoEsc,@pmNitSIA,@pmNombreSIA,@pmContactoSIA,@pmTelContacSIA
,@pmTipoRuta,@pmTipoTrans,@pmEmbarque,@pmCdTipCarga,@pmDevContenedor, @pmIdLocCont,@pmPatioCont,@pmCdTipoVeh,@pmMargenFalt,@pmTipoMargen,@pmUndCalcFalt,@pmTarifFaltPago,@pmTarifFaltCobro,@pmEmbAdicional,@pmCdRutaTarif)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsTraPedido @pmTipDoc VARCHAR(3),@pmPedido INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmFechaVence SMALLDATETIME,@pmFecDespacho SMALLDATETIME,@pmFecEntrega SMALLDATETIME,@pmIdCliente VARCHAR(16),@pmIdAgencia VARCHAR(16),@pmIdClieFact VARCHAR(16),@pmIdRemitente VARCHAR(16),@pmIdDestinatario VARCHAR(16),@pmIdLocOrigen VARCHAR(8),@pmIdLocDestino VARCHAR(8),@pmIdVend VARCHAR(16),@pmIdTarifCom VARCHAR(4),@pmModalidad VARCHAR(10),@pmVigencia VARCHAR(10),@pmTipoTarifa VARCHAR(10)
,@pmVrCobro MONEY,@pmVrPagos MONEY,@pmVrFletes MONEY,@pmVrCargue MONEY,@pmVrDesCargue MONEY,@pmVrEscolta MONEY,@pmVrDevContdor MONEY,@pmVrTraUrbano MONEY,@pmVrEmbalajes MONEY,@pmVrCargos MONEY,@pmVrDctos MONEY,@pmVrDeclarado MONEY,@pmVrSeguro MONEY,@pmCantidad DECIMAL(14,4),@pmCantDesp DECIMAL(14,4),@pmIdMneda VARCHAR(5),@pmVrTasa DECIMAL(14,4),@pmCotizacion INT,@pmIdCiaCot CHAR(2),@pmNumAprob INT,@pmIdCiaApr CHAR(2),@pmFecAprob SMALLDATETIME,@pmTipOdc VARCHAR(3),@pmOCargue INT,@pmIdCiaOdc CHAR(2)
,@pmFechaOdc SMALLDATETIME,@pmTipRem VARCHAR(3),@pmRemesa INT,@pmIdCiaRem CHAR(2),@pmFechaRem SMALLDATETIME,@pmTipFac VARCHAR(3),@pmFactura INT,@pmIdCiaFac CHAR(2),@pmFechaFac SMALLDATETIME,@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmOrigenAdd VARCHAR(10),@pmTimeSys SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraPedido (TipDoc,Pedido,IdCia,Fecha,FechaVence,FecDespacho,FecEntrega,IdCliente,IdAgencia,IdClieFact,IdRemitente,IdDestinatario,IdLocOrigen,IdLocDestino,IdVend,IdTarifCom,Modalidad,Vigencia,TipoTarifa,VrCobro,VrPagos,VrFletes,VrCargue,VrDesCargue,VrEscolta,VrDevContdor,VrTraUrbano,VrEmbalajes,VrCargos,VrDctos,VrDeclarado,VrSeguro,Cantidad,CantDesp,IdMneda,VrTasa,Cotizacion,IdCiaCot,NumAprob,IdCiaApr,FecAprob,TipOdc,OCargue,IdCiaOdc,FechaOdc,TipRem,Remesa,IdCiaRem,FechaRem,TipFac,Factura,IdCiaFac,FechaFac,OrigenAdd,Anulado,FecDev,Observacion,IdEstado,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDoc,@pmPedido,@pmIdCia,@pmFecha,@pmFechaVence,@pmFecDespacho,@pmFecEntrega,@pmIdCliente,@pmIdAgencia,@pmIdClieFact,@pmIdRemitente,@pmIdDestinatario,@pmIdLocOrigen,@pmIdLocDestino,@pmIdVend,@pmIdTarifCom,@pmModalidad,@pmVigencia,@pmTipoTarifa,@pmVrCobro,@pmVrPagos,@pmVrFletes,@pmVrCargue,@pmVrDesCargue,@pmVrEscolta,@pmVrDevContdor,@pmVrTraUrbano,@pmVrEmbalajes,@pmVrCargos,@pmVrDctos,@pmVrDeclarado,@pmVrSeguro,@pmCantidad,@pmCantDesp,@pmIdMneda,@pmVrTasa,@pmCotizacion,@pmIdCiaCot,@pmNumAprob,@pmIdCiaApr
,@pmFecAprob,@pmTipOdc,@pmOCargue,@pmIdCiaOdc,@pmFechaOdc,@pmTipRem,@pmRemesa,@pmIdCiaRem,@pmFechaRem,@pmTipFac,@pmFactura,@pmIdCiaFac,@pmFechaFac,@pmOrigenAdd,@pmAnulado,@pmFecDev,@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 paInsTraPedMcias @pmTipDoc VARCHAR(3),@pmPedido INT,@pmIdCia CHAR(2),@pmItem INT,@pmIdMercancia VARCHAR(16),@pmDescripMcias VARCHAR(250),@pmCantidad DECIMAL(14,4),@pmPesoNeto DECIMAL(14,4),@pmUndMed VARCHAR(10),@pmdmsAlto DECIMAL(14,4),@pmdmsAncho DECIMAL(14,4),@pmdmsLargo DECIMAL(14,4),@pmVolumen DECIMAL(14,4),@pmUndVol VARCHAR(10),@pmIdUnd VARCHAR(4)
,@pmIdEmp VARCHAR(4),@pmIdNat VARCHAR(4),@pmIdMnjo VARCHAR(4),@pmIdTmcia VARCHAR(4),@pmCdRango VARCHAR(4),@pmCases INT,@pmCajas INT,@pmPalets INT,@pmNitRemite VARCHAR(16),@pmRemitente VARCHAR(250),@pmDirOrigen VARCHAR(250),@pmIdOrigen VARCHAR(8),@pmNitDestntario VARCHAR(16),@pmDestinatario VARCHAR(250),@pmDirDestino VARCHAR(250),@pmIdDestino VARCHAR(8),@pmTarifClie MONEY,@pmTarifPago MONEY
,@pmTarifTabla MONEY,@pmVrDeclarado MONEY,@pmVrSeguro MONEY,@pmTarifSeguro DECIMAL(14,4),@pmReferencia1 VARCHAR(50),@pmReferencia2 VARCHAR(50),@pmContenedor1 VARCHAR(50),@pmContenedor2 VARCHAR(50),@pmUndTarifa VARCHAR(10),@pmUndTarifPago VARCHAR(10)
 AS 
 INSERT INTO Trn_TraPedMcias (TipDoc,Pedido,IdCia,Item,IdMercancia,DescripMcias,Cantidad,PesoNeto,UndMed,dmsAlto,dmsAncho,dmsLargo,Volumen,UndVol,IdUnd,IdEmp,IdNat,IdMnjo,IdTmcia,CdRango,Cases,Cajas,Palets,NitRemite,Remitente,DirOrigen,IdOrigen,NitDestntario,Destinatario,DirDestino,IdDestino,TarifClie,TarifPago,TarifTabla,VrDeclarado,VrSeguro,TarifSeguro,Referencia1,Referencia2,Contenedor1,Contenedor2,UndTarifa,UndTarifPago)
 VALUES (@pmTipDoc,@pmPedido,@pmIdCia,@pmItem,@pmIdMercancia,@pmDescripMcias,@pmCantidad,@pmPesoNeto,@pmUndMed,@pmdmsAlto,@pmdmsAncho,@pmdmsLargo,@pmVolumen,@pmUndVol,@pmIdUnd,@pmIdEmp,@pmIdNat,@pmIdMnjo,@pmIdTmcia,@pmCdRango,@pmCases,@pmCajas,@pmPalets,@pmNitRemite,@pmRemitente,@pmDirOrigen,@pmIdOrigen,@pmNitDestntario,@pmDestinatario,@pmDirDestino
,@pmIdDestino,@pmTarifClie,@pmTarifPago,@pmTarifTabla,@pmVrDeclarado,@pmVrSeguro,@pmTarifSeguro,@pmReferencia1,@pmReferencia2,@pmContenedor1,@pmContenedor2,@pmUndTarifa,@pmUndTarifPago)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraPresAnt @pmNumPsto INT,@pmFecha SMALLDATETIME,@pmIdOrigen VARCHAR(8),@pmIdDestino VARCHAR(8),@pmFecInicio SMALLDATETIME,@pmFecFinal SMALLDATETIME,@pmVrGastos MONEY,@pmVrComb MONEY,@pmVrPeajes MONEY,@pmVrAnticipo MONEY,@pmCdCat VARCHAR(4)
,@pmCdTipoVeh VARCHAR(4),@pmTipoAfilVeh VARCHAR(10),@pmCdTipoMot VARCHAR(4),@pmCdCom VARCHAR(4),@pmCdRango VARCHAR(4),@pmValorFijo BIT,@pmObservacion VARCHAR(250),@pmInactivo BIT,@pmTipoRuta VARCHAR(10),@pmCdRuta  VARCHAR(4), @pmFechaCrea SMALLDATETIME,@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraPresAnt (NumPsto,Fecha,IdOrigen,IdDestino,TipoRuta,CdRuta,FecInicio,FecFinal,VrGastos,VrComb,VrPeajes,VrAnticipo,CdCat,CdTipoVeh,TipoAfilVeh,CdTipoMot,CdCom,CdRango,ValorFijo,Observacion,Inactivo,FechaCrea,IdUsuario)
 VALUES (@pmNumPsto,@pmFecha,@pmIdOrigen,@pmIdDestino,@pmTipoRuta,@pmCdRuta,@pmFecInicio,@pmFecFinal,@pmVrGastos,@pmVrComb,@pmVrPeajes,@pmVrAnticipo,@pmCdCat,@pmCdTipoVeh,@pmTipoAfilVeh,@pmCdTipoMot,@pmCdCom
,@pmCdRango,@pmValorFijo,@pmObservacion,@pmInactivo,@pmFechaCrea,@pmIdUsuario)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsTraPresItems @pmNumPsto INT,@pmItem INT,@pmIdConcepto VARCHAR(4),@pmDescripcion VARCHAR(250)
,@pmCantidad DECIMAL(14,4),@pmVrUnitario MONEY,@pmVrTotal MONEY,@pmTipoRubro VARCHAR(10),@pmCdClase VARCHAR(4)
 AS 
 INSERT INTO Trn_TraPresItems (NumPsto,Item,IdConcepto,Descripcion,Cantidad,VrUnitario,VrTotal,TipoRubro,CdClase)
 VALUES (@pmNumPsto,@pmItem,@pmIdConcepto,@pmDescripcion,@pmCantidad,@pmVrUnitario,@pmVrTotal,@pmTipoRubro,@pmCdClase)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraRemAnexo @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2),@pmIdVend VARCHAR(16),@pmIdTarifCom VARCHAR(4),@pmNomCliente VARCHAR(150),@pmNomRemite VARCHAR(150),@pmNomDestino VARCHAR(150),@pmLugarCargue VARCHAR(150),@pmLugarDescargue VARCHAR(150)
,@pmNomContacto VARCHAR(150),@pmTelContacto VARCHAR(30),@pmemlContacto VARCHAR(100),@pmContacDestino VARCHAR(150),@pmTelContacDest VARCHAR(30),@pmemlContacDest VARCHAR(100),@pmPolizaSeguro VARCHAR(50),@pmNitCiaPoliza VARCHAR(16),@pmNomCiaPoliza VARCHAR(150),@pmFecVencePol SMALLDATETIME
,@pmManifMintrans DECIMAL(14,2),@pmRemMintrans DECIMAL(14,2),@pmTipSal VARCHAR(3),@pmNumSalida INT,@pmIdCiaSal CHAR(2),@pmNumInvent INT,@pmIdCiaInv CHAR(2),@pmTomadorPoliza CHAR(1),@pmTipoRuta VARCHAR(10),@pmTipoMintrans VARCHAR(10)
 AS 
 INSERT INTO Trn_TraRemAnexo (TipDoc,NumOrden,IdCia,IdVend,IdTarifCom,NomCliente,NomRemite,NomDestino,LugarCargue,LugarDescargue,NomContacto,TelContacto,emlContacto,ContacDestino,TelContacDest,emlContacDest,TomadorPoliza,PolizaSeguro,NitCiaPoliza,NomCiaPoliza,FecVencePol,ManifMintrans,RemMintrans,TipSal,NumSalida,IdCiaSal,NumInvent,IdCiaInv,TipoRuta,TipoMintrans)
 VALUES (@pmTipDoc,@pmNumOrden,@pmIdCia,@pmIdVend,@pmIdTarifCom,@pmNomCliente,@pmNomRemite,@pmNomDestino,@pmLugarCargue,@pmLugarDescargue,@pmNomContacto,@pmTelContacto,@pmemlContacto,@pmContacDestino,@pmTelContacDest,@pmemlContacDest,@pmTomadorPoliza,@pmPolizaSeguro,@pmNitCiaPoliza,@pmNomCiaPoliza
,@pmFecVencePol,@pmManifMintrans,@pmRemMintrans,@pmTipSal,@pmNumSalida,@pmIdCiaSal,@pmNumInvent,@pmIdCiaInv,@pmTipoRuta,@pmTipoMintrans)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsTraRemCntdor @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2),@pmItem INT,@pmIdTipoCon VARCHAR(4),@pmNumContdor VARCHAR(50),@pmPesoNeto DECIMAL(14,4),@pmIdTipoPre VARCHAR(4)
,@pmNumPrecinto VARCHAR(30),@pmColorPrecinto VARCHAR(20),@pmSellos VARCHAR(30),@pmPeligroso BIT,@pmPerecedero BIT,@pmToxico BIT,@pmInflamable BIT,@pmDifmanejo BIT,@pmFragil BIT,@pmDevCont BIT
,@pmCdLocCont VARCHAR(8),@pmPatioCont VARCHAR(50),@pmObservacion VARCHAR(150)
 AS 
 INSERT INTO Trn_TraRemCntdor (TipDoc,NumOrden,IdCia,Item,IdTipoCon,NumContdor,PesoNeto,IdTipoPre,NumPrecinto,ColorPrecinto,Sellos,Peligroso,Perecedero,Toxico,Inflamable,Difmanejo,Fragil,DevCont,CdLocCont,PatioCont,Observacion)
 VALUES (@pmTipDoc,@pmNumOrden,@pmIdCia,@pmItem,@pmIdTipoCon,@pmNumContdor,@pmPesoNeto,@pmIdTipoPre,@pmNumPrecinto,@pmColorPrecinto,@pmSellos,@pmPeligroso,@pmPerecedero,@pmToxico,@pmInflamable
,@pmDifmanejo,@pmFragil,@pmDevCont,@pmCdLocCont,@pmPatioCont,@pmObservacion)

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paInsTraRemesa @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmFecDespacho SMALLDATETIME,@pmFecEntrega SMALLDATETIME,@pmHoraLlegada SMALLDATETIME,@pmIdCliente VARCHAR(16),@pmIdAgencia VARCHAR(16),@pmIdClieFact VARCHAR(16),@pmIdRemitente VARCHAR(16),@pmIdDestinatario VARCHAR(16),@pmIdLocOrigen VARCHAR(8),@pmIdLocDestino VARCHAR(8)
,@pmIdLocFletes VARCHAR(8),@pmIdVehiculo VARCHAR(10),@pmIdConductor VARCHAR(16),@pmnRemolque VARCHAR(10),@pmTipoAfiVehic VARCHAR(10),@pmModalidad VARCHAR(10),@pmTipoTarifa VARCHAR(10),@pmVrCobro MONEY,@pmVrPagos MONEY,@pmVrFletes MONEY,@pmVrCargue MONEY,@pmVrDesCargue MONEY,@pmVrEscolta MONEY,@pmVrDevContdor MONEY,@pmVrTraUrbano MONEY,@pmVrEmbalajes MONEY,@pmVrCargos MONEY
,@pmVrDctos MONEY,@pmVrDeclarado MONEY,@pmVrSeguro MONEY,@pmCantidad DECIMAL(14,4),@pmPesoTotal DECIMAL(14,4),@pmItems INT,@pmIdMneda VARCHAR(5),@pmVrTasa DECIMAL(14,4),@pmNumPedido INT,@pmIdCiaPed CHAR(2),@pmFechaPed SMALLDATETIME,@pmTipDcm VARCHAR(3),@pmNumDocmto INT,@pmIdCiaDcm CHAR(2),@pmFechaDcm SMALLDATETIME,@pmNumManif INT,@pmIdCiaManif CHAR(2),@pmEstCumplido INT
,@pmEstFactura INT,@pmCdConcepto VARCHAR(4),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmCdRutaTarif VARCHAR(4),@pmOrigenAdd VARCHAR(10),@pmTimeSys SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_TraRemesa (TipDoc,NumOrden,IdCia,Fecha,FecDespacho,FecEntrega,HoraLlegada,IdCliente,IdAgencia,IdClieFact,IdRemitente,IdDestinatario,IdLocOrigen,IdLocDestino,IdLocFletes,IdVehiculo,IdConductor,nRemolque,TipoAfiVehic,Modalidad,TipoTarifa,VrCobro,VrPagos,VrFletes,VrCargue,VrDesCargue,VrEscolta,VrDevContdor,VrTraUrbano,VrEmbalajes,VrCargos,VrDctos,VrDeclarado,VrSeguro,Cantidad,PesoTotal,Items,IdMneda,VrTasa,NumPedido,IdCiaPed,FechaPed
,TipDcm,NumDocmto,IdCiaDcm,FechaDcm,NumManif,IdCiaManif,EstCumplido,EstFactura,CdConcepto,CdRutaTarif,TipCom,Comprobante,IdCiaCom,OrigenAdd,Anulado,FecDev,Observacion,IdEstado,TimeSys,IdCiaCrea,IdUsuario)
 VALUES (@pmTipDoc,@pmNumOrden,@pmIdCia,@pmFecha,@pmFecDespacho,@pmFecEntrega,@pmHoraLlegada,@pmIdCliente,@pmIdAgencia,@pmIdClieFact,@pmIdRemitente,@pmIdDestinatario,@pmIdLocOrigen,@pmIdLocDestino,@pmIdLocFletes,@pmIdVehiculo,@pmIdConductor,@pmnRemolque,@pmTipoAfiVehic,@pmModalidad,@pmTipoTarifa,@pmVrCobro,@pmVrPagos,@pmVrFletes,@pmVrCargue,@pmVrDesCargue,@pmVrEscolta,@pmVrDevContdor,@pmVrTraUrbano
,@pmVrEmbalajes,@pmVrCargos,@pmVrDctos,@pmVrDeclarado,@pmVrSeguro,@pmCantidad,@pmPesoTotal,@pmItems,@pmIdMneda,@pmVrTasa,@pmNumPedido,@pmIdCiaPed,@pmFechaPed,@pmTipDcm,@pmNumDocmto,@pmIdCiaDcm,@pmFechaDcm,@pmNumManif,@pmIdCiaManif,@pmEstCumplido,@pmEstFactura,@pmCdConcepto,@pmCdRutaTarif,@pmTipCom,@pmComprobante,@pmIdCiaCom,@pmOrigenAdd,@pmAnulado,@pmFecDev,@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 paInsTraRemMcias @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2),@pmItem INT,@pmIdMercancia VARCHAR(16),@pmDescripMcias VARCHAR(250),@pmCantidad DECIMAL(14,4),@pmPesoNeto DECIMAL(14,4),@pmUndMed VARCHAR(10),@pmdmsAlto DECIMAL(14,4),@pmdmsAncho DECIMAL(14,4),@pmdmsLargo DECIMAL(14,4),@pmVolumen DECIMAL(14,4),@pmUndVol VARCHAR(10),@pmIdUnd VARCHAR(4)
,@pmIdEmp VARCHAR(4),@pmIdNat VARCHAR(4),@pmIdTmcia VARCHAR(4),@pmIdMnjo VARCHAR(4),@pmCdRango VARCHAR(4),@pmCases INT,@pmCajas INT,@pmPalets INT,@pmNitRemite VARCHAR(16),@pmRemitente VARCHAR(250),@pmDirOrigen VARCHAR(250),@pmIdOrigen VARCHAR(8),@pmNitDestntario VARCHAR(16),@pmDestinatario VARCHAR(250),@pmDirDestino VARCHAR(250),@pmIdDestino VARCHAR(8),@pmTarifClie MONEY
,@pmTarifPago MONEY,@pmTarifTabla MONEY,@pmVrDeclarado MONEY,@pmVrSeguro MONEY,@pmTarifSeguro DECIMAL(14,4),@pmUndTarifa VARCHAR(10),@pmRemision DECIMAL(18,2),@pmDocCliente VARCHAR(30),@pmReferencia1 VARCHAR(50),@pmReferencia2 VARCHAR(50),@pmReferencia3 VARCHAR(50),@pmContenedor1 VARCHAR(50),@pmContenedor2 VARCHAR(50),@pmCdAgencia VARCHAR(16),@pmCumplido INT,@pmIdCiaCump CHAR(2),@pmFechaCump SMALLDATETIME
,@pmDetalleCump VARCHAR(250),@pmCantidadCump DECIMAL(14,4),@pmPesoCump DECIMAL(14,4),@pmVolCump DECIMAL(14,4),@pmCasesCump INT,@pmCajasCump INT,@pmPaletsCump INT,@pmTarifCump MONEY,@pmPagoCump MONEY,@pmUndTarCump VARCHAR(10),@pmTipFac VARCHAR(3),@pmFactura INT,@pmIdCiaFac CHAR(2),@pmFechaFac SMALLDATETIME,@pmTarifClieFac MONEY,@pmTipOdp VARCHAR(3),@pmNumeroOdp INT
,@pmIdCiaOdp CHAR(2),@pmTarifOdp MONEY,@pmPesoCont DECIMAL(14,4),@pmUndTarifPago VARCHAR(10),@pmUndTarPagoCump VARCHAR(10)
 AS 
 INSERT INTO Trn_TraRemMcias (TipDoc,NumOrden,IdCia,Item,IdMercancia,DescripMcias,Cantidad,PesoNeto,UndMed,dmsAlto,dmsAncho,dmsLargo,Volumen,UndVol,IdUnd,IdEmp,IdNat,IdTmcia,IdMnjo,CdRango,Cases,Cajas,Palets,NitRemite,Remitente,DirOrigen,IdOrigen,NitDestntario,Destinatario,DirDestino,IdDestino,TarifClie,TarifPago,TarifTabla,VrDeclarado,VrSeguro,TarifSeguro,UndTarifa,UndTarifPago,Remision,DocCliente,Referencia1,Referencia2,Referencia3,Contenedor1,Contenedor2,CdAgencia
,Cumplido,IdCiaCump,FechaCump,DetalleCump,CantidadCump,PesoCump,VolCump,CasesCump,CajasCump,PaletsCump,TarifCump,PagoCump,UndTarCump,UndTarPagoCump,TipFac,Factura,IdCiaFac,FechaFac,TarifClieFac,TipOdp,NumeroOdp,IdCiaOdp,TarifOdp,PesoCont)
 VALUES (@pmTipDoc,@pmNumOrden,@pmIdCia,@pmItem,@pmIdMercancia,@pmDescripMcias,@pmCantidad,@pmPesoNeto,@pmUndMed,@pmdmsAlto,@pmdmsAncho,@pmdmsLargo,@pmVolumen,@pmUndVol,@pmIdUnd,@pmIdEmp,@pmIdNat,@pmIdTmcia,@pmIdMnjo,@pmCdRango,@pmCases,@pmCajas,@pmPalets,@pmNitRemite,@pmRemitente,@pmDirOrigen,@pmIdOrigen,@pmNitDestntario,@pmDestinatario,@pmDirDestino,@pmIdDestino,@pmTarifClie
,@pmTarifPago,@pmTarifTabla,@pmVrDeclarado,@pmVrSeguro,@pmTarifSeguro,@pmUndTarifa,@pmUndTarifPago,@pmRemision,@pmDocCliente,@pmReferencia1,@pmReferencia2,@pmReferencia3,@pmContenedor1,@pmContenedor2,@pmCdAgencia,@pmCumplido,@pmIdCiaCump,@pmFechaCump,@pmDetalleCump,@pmCantidadCump,@pmPesoCump,@pmVolCump,@pmCasesCump,@pmCajasCump,@pmPaletsCump,@pmTarifCump,@pmPagoCump,@pmUndTarCump,@pmUndTarPagoCump,@pmTipFac,@pmFactura
,@pmIdCiaFac,@pmFechaFac,@pmTarifClieFac,@pmTipOdp,@pmNumeroOdp,@pmIdCiaOdp,@pmTarifOdp,@pmPesoCont)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paInsTraReportes @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2),@pmItem INT,@pmCdRuta VARCHAR(4),@pmIdPunto INT,@pmFecReporte SMALLDATETIME,@pmTipoRep VARCHAR(10)
,@pmEstadoRep INT,@pmIdUsuario VARCHAR(11),@pmFechaCrea SMALLDATETIME,@pmCdNovedad VARCHAR(4),@pmObservRep VARCHAR(250),@pmTipoPunto VARCHAR(10),@pmCdPuesto VARCHAR(4),@pmNomConductor VARCHAR(150)
 AS 
 INSERT INTO Trn_TraReportes (TipDoc,Manifiesto,IdCia,Item,CdRuta,IdPunto,FecReporte,TipoRep,EstadoRep,IdUsuario,FechaCrea,CdNovedad,ObservRep,TipoPunto,CdPuesto,NomConductor)
 VALUES (@pmTipDoc,@pmManifiesto,@pmIdCia,@pmItem,@pmCdRuta,@pmIdPunto,@pmFecReporte,@pmTipoRep,@pmEstadoRep,@pmIdUsuario,@pmFechaCrea,@pmCdNovedad,@pmObservRep,@pmTipoPunto,@pmCdPuesto,@pmNomConductor)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpNovedadRep @pmIdNov VARCHAR(4),@pmNovedad VARCHAR(50),@pmInactivo BIT
 AS 
 UPDATE NovedadRep SET Novedad=@pmNovedad,Inactivo=@pmInactivo
 WHERE IdNov=@pmIdNov

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTarifAnticipos @pmNumero INT,@pmCuotaMax DECIMAL(14,4),@pmTipoCuota VARCHAR(10),@pmTipoAplica VARCHAR(10)
,@pmCdOrigen VARCHAR(8),@pmCdDestino VARCHAR(8),@pmNitCliente VARCHAR(16),@pmCdTipoVeh VARCHAR(4)
,@pmTipoAfilVeh VARCHAR(10),@pmInactivo BIT,@pmCdRuta VARCHAR(4)
 AS 
 UPDATE TarifAnticipos SET CuotaMax=@pmCuotaMax,TipoCuota=@pmTipoCuota,TipoAplica=@pmTipoAplica,CdOrigen=@pmCdOrigen,CdDestino=@pmCdDestino
,NitCliente=@pmNitCliente,CdTipoVeh=@pmCdTipoVeh,TipoAfilVeh=@pmTipoAfilVeh,CdRuta=@pmCdRuta,Inactivo=@pmInactivo
 WHERE Numero=@pmNumero
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paUpTarifasFletes @pmIdOrigen VARCHAR(8),@pmIdDestino VARCHAR(8),@pmNumero INT,@pmTipoTarifa VARCHAR(10),@pmTarifClie MONEY,@pmTarifPago MONEY,@pmTarifTabla MONEY,@pmIdMneda VARCHAR(5)
,@pmUndMed VARCHAR(10),@pmNitCliente VARCHAR(16),@pmCdNat VARCHAR(4),@pmCdTipoVeh VARCHAR(4),@pmCdRango VARCHAR(4)
,@pmUndTarifClie VARCHAR(10),@pmUndTarifPago VARCHAR(10),@pmInactivo BIT,@pmCdRuta VARCHAR(4)
 AS 
 UPDATE TarifasFletes SET TipoTarifa=@pmTipoTarifa,TarifClie=@pmTarifClie,TarifPago=@pmTarifPago,TarifTabla=@pmTarifTabla,IdMneda=@pmIdMneda,UndMed=@pmUndMed,NitCliente=@pmNitCliente
,CdNat=@pmCdNat,CdTipoVeh=@pmCdTipoVeh,CdRango=@pmCdRango,Inactivo=@pmInactivo,UndTarifClie=@pmUndTarifClie,UndTarifPago=@pmUndTarifPago,CdRuta=@pmCdRuta
,IdOrigen=@pmIdOrigen,IdDestino=@pmIdDestino
 WHERE  Numero=@pmNumero

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraAnticipos @pmTipDoc VARCHAR(3),@pmAnticipo INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipMuc VARCHAR(3),@pmManifiesto INT,@pmIdCiaMuc CHAR(2),@pmIdVehiculo VARCHAR(10),@pmIdPoseedor VARCHAR(16),@pmIdConductor VARCHAR(16),@pmVrAnticipo MONEY,@pmVrAbonado MONEY,@pmModalidad VARCHAR(10)
,@pmTipoPago VARCHAR(10),@pmNumCheque VARCHAR(20),@pmFecCheque SMALLDATETIME,@pmIdCta VARCHAR(4),@pmIdCuenta VARCHAR(16),@pmBeneficiario VARCHAR(150),@pmCantidad DECIMAL(14,4),@pmFechaVence SMALLDATETIME,@pmNumPresAnt INT, @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_TraAnticipos SET Fecha=@pmFecha,IdConcepto=@pmIdConcepto,TipMuc=@pmTipMuc,Manifiesto=@pmManifiesto,IdCiaMuc=@pmIdCiaMuc,IdVehiculo=@pmIdVehiculo,IdPoseedor=@pmIdPoseedor,IdConductor=@pmIdConductor,VrAnticipo=@pmVrAnticipo,VrAbonado=@pmVrAbonado,Modalidad=@pmModalidad,TipoPago=@pmTipoPago,NumCheque=@pmNumCheque,FecCheque=@pmFecCheque
,IdCta=@pmIdCta,IdCuenta=@pmIdCuenta,Beneficiario=@pmBeneficiario,Cantidad=@pmCantidad,FechaVence=@pmFechaVence,NumPresAnt=@pmNumPresAnt,TipCom=@pmTipCom,Comprobante=@pmComprobante,IdCiaCom=@pmIdCiaCom,Anulado=@pmAnulado,NumDev=@pmNumDev,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado,FecUpdate=@pmFecUpdate
 WHERE TipDoc=@pmTipDoc AND Anticipo=@pmAnticipo 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 paUpTraAnticiposAnu @pmTipDoc VARCHAR(3),@pmAnticipo INT,@pmIdCia CHAR(2),@pmVrAbonado MONEY
,@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4)
 AS 
 UPDATE Trn_TraAnticipos SET  VrAbonado=@pmVrAbonado,Anulado=@pmAnulado,NumDev=@pmNumDev,FecDev=@pmFecDev
,Observacion=@pmObservacion,IdEstado=@pmIdEstado
 WHERE TipDoc=@pmTipDoc AND Anticipo=@pmAnticipo 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 paUpTraAnticiposApl @pmTipDoc VARCHAR(3),@pmAnticipo INT,@pmIdCia CHAR(2)
 AS 
 UPDATE Trn_TraAnticipos SET  VrAbonado=(SELECT ISNULL(SUM(Trn_TraAntAbonos.VrAbono),0)
 FROM Trn_TraAntAbonos WHERE Trn_TraAntAbonos.TipAnt=Trn_TraAnticipos.TipDoc AND Trn_TraAntAbonos.Anticipo=Trn_TraAnticipos.Anticipo
  AND Trn_TraAntAbonos.IdCiaAnt=Trn_TraAnticipos.IdCia)
 WHERE TipDoc=@pmTipDoc AND Anticipo=@pmAnticipo AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraCausacion @pmTipDoc VARCHAR(3),@pmCausacion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmIdProv VARCHAR(16),@pmFactura VARCHAR(20),@pmVrTotal MONEY
,@pmVrOtros MONEY,@pmVrNeto 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_TraCausacion SET Fecha=@pmFecha,IdConcepto=@pmIdConcepto,IdProv=@pmIdProv,Factura=@pmFactura,VrTotal=@pmVrTotal,VrOtros=@pmVrOtros,VrNeto=@pmVrNeto,TipCom=@pmTipCom,Comprobante=@pmComprobante
,IdCiaCom=@pmIdCiaCom,Anulado=@pmAnulado,NumDev=@pmNumDev,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado,FecUpdate=@pmFecUpdate
 WHERE TipDoc=@pmTipDoc AND Causacion=@pmCausacion 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 paUpTraCausacionAnu @pmTipDoc VARCHAR(3),@pmCausacion INT,@pmIdCia CHAR(2)
,@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4)
 AS 
 UPDATE Trn_TraCausacion SET Anulado=@pmAnulado,NumDev=@pmNumDev,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado
 WHERE TipDoc=@pmTipDoc AND Causacion=@pmCausacion AND IdCia=@pmIdCia


GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraConcCausac @pmIdConcepto VARCHAR(4),@pmConcepto VARCHAR(250),@pmIdCuenta VARCHAR(16)
,@pmTipoConc VARCHAR(10),@pmInactivo BIT
 AS 
 UPDATE TraConcCausac SET Concepto=@pmConcepto,IdCuenta=@pmIdCuenta,TipoConc=@pmTipoConc,Inactivo=@pmInactivo
 WHERE IdConcepto=@pmIdConcepto

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paUpTraConceptos  @pmTipDoc VARCHAR(3),@pmDocumento INT,@pmIdCia CHAR(2),@pmItem INT,@pmDescripcion VARCHAR(250),@pmTarifa DECIMAL(14,4),@pmTipoConc VARCHAR(10),@pmRubroConcep VARCHAR(20),@pmCantidad DECIMAL(14,4)
,@pmVrUnitario MONEY,@pmTarifIva DECIMAL(14,4),@pmIdConcepto VARCHAR(4),@pmCdCuenta VARCHAR(16),@pmNitTercero VARCHAR(16),@pmCdTipoEsc VARCHAR(4),@pmFechaNov SMALLDATETIME,@pmVrBase MONEY,@pmTipoTarif CHAR(1),@pmRefConc VARCHAR(50)
,@pmFijos BIT
 AS 
 UPDATE Trn_TraConceptos SET Descripcion=@pmDescripcion,Tarifa=@pmTarifa,TipoConc=@pmTipoConc,RubroConcep=@pmRubroConcep,Cantidad=@pmCantidad,VrUnitario=@pmVrUnitario,TarifIva=@pmTarifIva,IdConcepto=@pmIdConcepto,CdCuenta=@pmCdCuenta
,NitTercero=@pmNitTercero,CdTipoEsc=@pmCdTipoEsc,FechaNov=@pmFechaNov,VrBase=@pmVrBase,TipoTarif=@pmTipoTarif,RefConc=@pmRefConc,Fijos=@pmFijos
 WHERE TipDoc=@pmTipDoc AND Documento=@pmDocumento AND IdCia=@pmIdCia AND Item=@pmItem
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraCumplido @pmTipDoc VARCHAR(3),@pmCumplido INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmTipMuc VARCHAR(3),@pmManifiesto INT,@pmIdCiaMuc CHAR(2),@pmIdVehiculo VARCHAR(10),@pmModalidad VARCHAR(10),@pmDiasPlazo INT
,@pmFecPago SMALLDATETIME,@pmTipoMargen VARCHAR(10),@pmMargenFalt DECIMAL(14,4),@pmUndCalcFalt VARCHAR(10),@pmTarifFaltPago MONEY,@pmTarifFaltCobro MONEY,@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(1000),@pmIdEstado VARCHAR(4),@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_TraCumplido SET Fecha=@pmFecha,TipMuc=@pmTipMuc,Manifiesto=@pmManifiesto,IdCiaMuc=@pmIdCiaMuc,IdVehiculo=@pmIdVehiculo,Modalidad=@pmModalidad,DiasPlazo=@pmDiasPlazo,FecPago=@pmFecPago,TipoMargen=@pmTipoMargen
,MargenFalt=@pmMargenFalt,UndCalcFalt=@pmUndCalcFalt,TarifFaltPago=@pmTarifFaltPago,TarifFaltCobro=@pmTarifFaltCobro,Anulado=@pmAnulado,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado,FecUpdate=@pmFecUpdate
 WHERE TipDoc=@pmTipDoc AND Cumplido=@pmCumplido 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 paUpTraCumplidoAnu @pmTipDoc VARCHAR(3),@pmCumplido INT,@pmIdCia CHAR(2)
,@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(1000),@pmIdEstado VARCHAR(4)
 AS 
 UPDATE Trn_TraCumplido SET Anulado=@pmAnulado,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado
 WHERE TipDoc=@pmTipDoc AND Cumplido=@pmCumplido AND IdCia=@pmIdCia

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraDespachos @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmFecCargue SMALLDATETIME,@pmFecDespacho SMALLDATETIME,@pmIdOrigen VARCHAR(8),@pmIdDestino VARCHAR(8),@pmIdRuta VARCHAR(4)
,@pmIdVehiculo VARCHAR(10),@pmIdConductor VARCHAR(16),@pmIdPoseedor VARCHAR(16),@pmNitRemite VARCHAR(16),@pmRemitente VARCHAR(250),@pmNitDestntario VARCHAR(16),@pmDestinatario VARCHAR(250),@pmDescMcia VARCHAR(150),@pmPesoTotal DECIMAL(14,4)
,@pmNumOrden INT,@pmIdCiaOrd CHAR(2),@pmRemesa INT,@pmIdCiaRem CHAR(2),@pmEstado INT,@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_TraDespachos SET Fecha=@pmFecha,FecCargue=@pmFecCargue,FecDespacho=@pmFecDespacho,IdOrigen=@pmIdOrigen,IdDestino=@pmIdDestino,IdRuta=@pmIdRuta,IdVehiculo=@pmIdVehiculo,IdConductor=@pmIdConductor,IdPoseedor=@pmIdPoseedor
,NitRemite=@pmNitRemite,Remitente=@pmRemitente,NitDestntario=@pmNitDestntario,Destinatario=@pmDestinatario,DescMcia=@pmDescMcia,PesoTotal=@pmPesoTotal,NumOrden=@pmNumOrden,IdCiaOrd=@pmIdCiaOrd,Remesa=@pmRemesa,IdCiaRem=@pmIdCiaRem
,Estado=@pmEstado,Anulado=@pmAnulado,FecDev=@pmFecDev,Observacion=@pmObservacion,FecUpdate=@pmFecUpdate
 WHERE TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto 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 paUpTraDespachosAnu @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2)
,@pmEstado INT,@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250)
 AS 
 UPDATE Trn_TraDespachos SET Estado=@pmEstado,Anulado=@pmAnulado,FecDev=@pmFecDev
,Observacion=@pmObservacion
 WHERE TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto 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 paUpTraDespProgram @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2),@pmItem INT,@pmCdRuta VARCHAR(4),@pmIdPunto INT,@pmHoraProg SMALLDATETIME
,@pmTipoProg INT,@pmObservProg VARCHAR(250)
 AS 
 UPDATE Trn_TraDespProgram SET CdRuta=@pmCdRuta,IdPunto=@pmIdPunto,HoraProg=@pmHoraProg,TipoProg=@pmTipoProg,ObservProg=@pmObservProg
 WHERE TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto AND IdCia=@pmIdCia AND Item=@pmItem
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraDevAnt @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipDoc VARCHAR(3),@pmAnticipo INT,@pmIdCiaDoc CHAR(2),@pmFecDoc SMALLDATETIME,@pmIdVehiculo VARCHAR(10)
,@pmIdPoseedor VARCHAR(16),@pmIdConductor VARCHAR(16),@pmVrDevolucion MONEY,@pmCdCta VARCHAR(4),@pmCdCuenta VARCHAR(16),@pmModdDev VARCHAR(10),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmObservacion VARCHAR(250)
,@pmIdEstado VARCHAR(4),@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_TraDevAnt SET Fecha=@pmFecha,IdConcepto=@pmIdConcepto,TipDoc=@pmTipDoc,Anticipo=@pmAnticipo,IdCiaDoc=@pmIdCiaDoc,FecDoc=@pmFecDoc,IdVehiculo=@pmIdVehiculo,IdPoseedor=@pmIdPoseedor,IdConductor=@pmIdConductor,VrDevolucion=@pmVrDevolucion
,CdCta=@pmCdCta,CdCuenta=@pmCdCuenta,ModdDev=@pmModdDev,TipCom=@pmTipCom,Comprobante=@pmComprobante,IdCiaCom=@pmIdCiaCom,Observacion=@pmObservacion,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 ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraDevCau @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipDoc VARCHAR(3),@pmCausacion INT,@pmIdCiaDoc CHAR(2),@pmFecDoc SMALLDATETIME,@pmIdProv VARCHAR(16),@pmFactura VARCHAR(20),@pmVrTotal MONEY,@pmVrOtros MONEY
,@pmVrNeto MONEY,@pmModdDev VARCHAR(10),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_TraDevCau SET Fecha=@pmFecha,IdConcepto=@pmIdConcepto,TipDoc=@pmTipDoc,Causacion=@pmCausacion,IdCiaDoc=@pmIdCiaDoc,FecDoc=@pmFecDoc,IdProv=@pmIdProv,Factura=@pmFactura,VrTotal=@pmVrTotal,VrOtros=@pmVrOtros,VrNeto=@pmVrNeto,ModdDev=@pmModdDev
,TipCom=@pmTipCom,Comprobante=@pmComprobante,IdCiaCom=@pmIdCiaCom,Observacion=@pmObservacion,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 ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraDevLeg @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCiaDoc CHAR(2),@pmFecDoc SMALLDATETIME,@pmModalidad VARCHAR(10),@pmTipMuc VARCHAR(3),@pmManifiesto INT,@pmIdCiaMuc CHAR(2),@pmIdVehiculo VARCHAR(10),@pmIdConductor VARCHAR(16),@pmIdPropietario VARCHAR(16),@pmIdPoseedor VARCHAR(16)
,@pmNitEmpresa VARCHAR(16),@pmVrAnticipos MONEY,@pmVrGastos MONEY,@pmVrCombustible MONEY,@pmVrDiferencia MONEY,@pmgalsComb DECIMAL(14,4),@pmPesoTotal DECIMAL(14,4),@pmCantidad DECIMAL(14,4),@pmVolumen DECIMAL(14,4),@pmModdDev VARCHAR(10),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmVrOtrosCred MONEY,@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_TraDevLeg SET Fecha=@pmFecha,IdConcepto=@pmIdConcepto,TipDoc=@pmTipDoc,Liquidacion=@pmLiquidacion,IdCiaDoc=@pmIdCiaDoc,FecDoc=@pmFecDoc,Modalidad=@pmModalidad,TipMuc=@pmTipMuc,Manifiesto=@pmManifiesto,IdCiaMuc=@pmIdCiaMuc,IdVehiculo=@pmIdVehiculo,IdConductor=@pmIdConductor,IdPropietario=@pmIdPropietario,IdPoseedor=@pmIdPoseedor,NitEmpresa=@pmNitEmpresa,VrAnticipos=@pmVrAnticipos,VrGastos=@pmVrGastos,VrCombustible=@pmVrCombustible
,VrDiferencia=@pmVrDiferencia,VrOtrosCred=@pmVrOtrosCred,galsComb=@pmgalsComb,PesoTotal=@pmPesoTotal,Cantidad=@pmCantidad,Volumen=@pmVolumen,ModdDev=@pmModdDev,TipCom=@pmTipCom,Comprobante=@pmComprobante,IdCiaCom=@pmIdCiaCom,Observacion=@pmObservacion,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 ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraDevOdp @pmTipDev VARCHAR(3),@pmDevolucion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmTipDoc VARCHAR(3),@pmOrdPago INT,@pmIdCiaDoc CHAR(2),@pmFecDoc SMALLDATETIME,@pmIdVehiculo VARCHAR(10)
,@pmIdPoseedor VARCHAR(16),@pmIdConductor VARCHAR(16),@pmCxPagar BIT,@pmModdDev VARCHAR(10),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_TraDevOdp SET Fecha=@pmFecha,IdConcepto=@pmIdConcepto,TipDoc=@pmTipDoc,OrdPago=@pmOrdPago,IdCiaDoc=@pmIdCiaDoc,FecDoc=@pmFecDoc,IdVehiculo=@pmIdVehiculo,IdPoseedor=@pmIdPoseedor,IdConductor=@pmIdConductor,CxPagar=@pmCxPagar,ModdDev=@pmModdDev
,TipCom=@pmTipCom,Comprobante=@pmComprobante,IdCiaCom=@pmIdCiaCom,Observacion=@pmObservacion,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 ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraFijos @pmNumero INT,@pmIdConcepto VARCHAR(4),@pmDescConc VARCHAR(250),@pmTipoConc VARCHAR(10),@pmTarifa DECIMAL(14,4),@pmTipoTarif CHAR(1),@pmTipoAfilVeh VARCHAR(10),@pmCdTipoVeh VARCHAR(4),@pmAnulado BIT
 AS 
 UPDATE TraFijos SET IdConcepto=@pmIdConcepto,DescConc=@pmDescConc,TipoConc=@pmTipoConc,Tarifa=@pmTarifa,TipoTarif=@pmTipoTarif,TipoAfilVeh=@pmTipoAfilVeh,CdTipoVeh=@pmCdTipoVeh,Anulado=@pmAnulado
 WHERE Numero=@pmNumero
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paUpTraLiquida @pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmIdVehiculo VARCHAR(10),@pmIdPoseedor VARCHAR(16),@pmIdConductor VARCHAR(16)
,@pmVrTotal MONEY,@pmCxPagar BIT,@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_TraLiquida SET Fecha=@pmFecha,IdConcepto=@pmIdConcepto,IdVehiculo=@pmIdVehiculo,IdPoseedor=@pmIdPoseedor,IdConductor=@pmIdConductor,VrTotal=@pmVrTotal,CxPagar=@pmCxPagar,TipCom=@pmTipCom,Comprobante=@pmComprobante
,IdCiaCom=@pmIdCiaCom,Anulado=@pmAnulado,NumDev=@pmNumDev,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado,FecUpdate=@pmFecUpdate
 WHERE TipDoc=@pmTipDoc AND Liquidacion=@pmLiquidacion 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 paUpTraLiquidaAnu @pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2)
,@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4)
 AS 
 UPDATE Trn_TraLiquida SET  Anulado=@pmAnulado,NumDev=@pmNumDev,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado
 WHERE TipDoc=@pmTipDoc AND Liquidacion=@pmLiquidacion AND IdCia=@pmIdCia

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraLiqViajes @pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmModalidad VARCHAR(10),@pmTipMuc VARCHAR(3),@pmManifiesto INT,@pmIdCiaMuc CHAR(2),@pmFechaMuc SMALLDATETIME,@pmIdVehiculo VARCHAR(10),@pmIdConductor VARCHAR(16),@pmIdPropietario VARCHAR(16),@pmIdPoseedor VARCHAR(16),@pmNitEmpresa VARCHAR(16),@pmVrAnticipos MONEY,@pmVrGastos MONEY,@pmVrCombustible MONEY
,@pmVrDiferencia MONEY,@pmgalsComb DECIMAL(14,4),@pmPesoTotal DECIMAL(14,4),@pmCantidad DECIMAL(14,4),@pmVolumen DECIMAL(14,4),@pmIdRuta VARCHAR(4),@pmIdLocOrigen VARCHAR(8),@pmIdLocDestino VARCHAR(8),@pmReferencia VARCHAR(50),@pmDescMcias VARCHAR(150),@pmkmtInicial DECIMAL(14,4),@pmkmtFinal DECIMAL(14,4),@pmEstFactura INT
,@pmTipDocRef VARCHAR(3),@pmNumDocRef INT,@pmIdCiaRef CHAR(2),@pmFecDocRef SMALLDATETIME,@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmVrOtrosCred MONEY,@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_TraLiqViajes SET Fecha=@pmFecha,IdConcepto=@pmIdConcepto,Modalidad=@pmModalidad,TipMuc=@pmTipMuc,Manifiesto=@pmManifiesto,IdCiaMuc=@pmIdCiaMuc,FechaMuc=@pmFechaMuc,IdVehiculo=@pmIdVehiculo,IdConductor=@pmIdConductor,IdPropietario=@pmIdPropietario,IdPoseedor=@pmIdPoseedor,NitEmpresa=@pmNitEmpresa,VrAnticipos=@pmVrAnticipos,VrGastos=@pmVrGastos,VrCombustible=@pmVrCombustible,VrDiferencia=@pmVrDiferencia,galsComb=@pmgalsComb
,PesoTotal=@pmPesoTotal,Cantidad=@pmCantidad,Volumen=@pmVolumen,IdRuta=@pmIdRuta,IdLocOrigen=@pmIdLocOrigen,IdLocDestino=@pmIdLocDestino,Referencia=@pmReferencia,DescMcias=@pmDescMcias,kmtInicial=@pmkmtInicial,kmtFinal=@pmkmtFinal,EstFactura=@pmEstFactura,TipDocRef=@pmTipDocRef,NumDocRef=@pmNumDocRef,IdCiaRef=@pmIdCiaRef,FecDocRef=@pmFecDocRef,TipCom=@pmTipCom,Comprobante=@pmComprobante,IdCiaCom=@pmIdCiaCom
,Anulado=@pmAnulado,NumDev=@pmNumDev,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado,VrOtrosCred=@pmVrOtrosCred,FecUpdate=@pmFecUpdate
 WHERE TipDoc=@pmTipDoc AND Liquidacion=@pmLiquidacion 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 paUpTraLiqViajesAnu @pmTipDoc VARCHAR(3),@pmLiquidacion INT,@pmIdCia CHAR(2)
,@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4)
 AS 
 UPDATE Trn_TraLiqViajes SET  Anulado=@pmAnulado,NumDev=@pmNumDev,FecDev=@pmFecDev
,Observacion=@pmObservacion,IdEstado=@pmIdEstado
 WHERE TipDoc=@pmTipDoc AND Liquidacion=@pmLiquidacion AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraManifiesto @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmFecDespacho SMALLDATETIME,@pmFecEntrega SMALLDATETIME,@pmIdOrigen VARCHAR(8),@pmIdDestino VARCHAR(8),@pmIdRuta VARCHAR(4),@pmIdRutaFle VARCHAR(4),@pmIdVehiculo VARCHAR(10)
,@pmIdConductor VARCHAR(16),@pmnRemolque VARCHAR(10),@pmTipoAfiVehic VARCHAR(10),@pmIdPropietario VARCHAR(16),@pmIdPoseedor VARCHAR(16),@pmVrFletes MONEY,@pmVrRetencion MONEY,@pmVrReteIca MONEY,@pmVrDescuento MONEY,@pmVrAnticipo MONEY,@pmVrAntAdic MONEY,@pmVrNeto MONEY,@pmVrPagos MONEY
,@pmVrCargos MONEY,@pmVrDctos MONEY,@pmTarifaFlete MONEY,@pmCantidad DECIMAL(14,4),@pmPesoTotal DECIMAL(14,4),@pmBaseRet MONEY,@pmTarifaRet DECIMAL(14,4),@pmTarifaIca DECIMAL(14,4),@pmCodTarRet VARCHAR(4),@pmCodTarIca VARCHAR(4),@pmIdLocFletes VARCHAR(8),@pmFechaPago SMALLDATETIME
,@pmPagoCargue VARCHAR(50),@pmPagoDescargue VARCHAR(50),@pmNumMintrans DECIMAL(14,2),@pmEdoMintrans VARCHAR(5),@pmRemesa INT,@pmIdCiaRem CHAR(2),@pmCumplido INT,@pmIdCiaCump CHAR(2),@pmFechaCump SMALLDATETIME,@pmEstCumplido INT,@pmTipOdp VARCHAR(3),@pmOrdPago INT,@pmIdCiaOdp CHAR(2)
,@pmFechaOdp SMALLDATETIME,@pmEstOrden INT,@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_TraManifiesto SET Fecha=@pmFecha,FecDespacho=@pmFecDespacho,FecEntrega=@pmFecEntrega,IdOrigen=@pmIdOrigen,IdDestino=@pmIdDestino,IdRuta=@pmIdRuta,IdRutaFle=@pmIdRutaFle,IdVehiculo=@pmIdVehiculo,IdConductor=@pmIdConductor,nRemolque=@pmnRemolque,TipoAfiVehic=@pmTipoAfiVehic,IdPropietario=@pmIdPropietario,IdPoseedor=@pmIdPoseedor
,VrFletes=@pmVrFletes,VrRetencion=@pmVrRetencion,VrReteIca=@pmVrReteIca,VrDescuento=@pmVrDescuento,VrAnticipo=@pmVrAnticipo,VrAntAdic=@pmVrAntAdic,VrNeto=@pmVrNeto,VrPagos=@pmVrPagos,VrCargos=@pmVrCargos,VrDctos=@pmVrDctos,TarifaFlete=@pmTarifaFlete,Cantidad=@pmCantidad,PesoTotal=@pmPesoTotal,BaseRet=@pmBaseRet,TarifaRet=@pmTarifaRet
,TarifaIca=@pmTarifaIca,CodTarRet=@pmCodTarRet,CodTarIca=@pmCodTarIca,IdLocFletes=@pmIdLocFletes,FechaPago=@pmFechaPago,PagoCargue=@pmPagoCargue,PagoDescargue=@pmPagoDescargue,NumMintrans=@pmNumMintrans,EdoMintrans=@pmEdoMintrans,Remesa=@pmRemesa,IdCiaRem=@pmIdCiaRem,Cumplido=@pmCumplido,IdCiaCump=@pmIdCiaCump
,FechaCump=@pmFechaCump,EstCumplido=@pmEstCumplido,TipOdp=@pmTipOdp,OrdPago=@pmOrdPago,IdCiaOdp=@pmIdCiaOdp,FechaOdp=@pmFechaOdp,Anulado=@pmAnulado,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado,EstOrden=@pmEstOrden,FecUpdate=@pmFecUpdate
 WHERE TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto 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 paUpTraManifiestoAnu @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2)
,@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4)
,@pmEdoMintrans VARCHAR(5)
 AS 
 UPDATE Trn_TraManifiesto SET   EdoMintrans=@pmEdoMintrans,Anulado=@pmAnulado,FecDev=@pmFecDev
,Observacion=@pmObservacion,IdEstado=@pmIdEstado
 WHERE TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto AND IdCia=@pmIdCia

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraOrdenPago @pmTipDoc VARCHAR(3),@pmOrdPago INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmModalidad VARCHAR(10),@pmLiqRemesas BIT,@pmCxPagar BIT,@pmMulPlazos BIT,@pmIdPlazo VARCHAR(4),@pmFechaVence SMALLDATETIME
,@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_TraOrdenPago SET Fecha=@pmFecha,IdConcepto=@pmIdConcepto,Modalidad=@pmModalidad,LiqRemesas=@pmLiqRemesas,CxPagar=@pmCxPagar,MulPlazos=@pmMulPlazos,IdPlazo=@pmIdPlazo,FechaVence=@pmFechaVence,TipCom=@pmTipCom,Comprobante=@pmComprobante,IdCiaCom=@pmIdCiaCom
,Anulado=@pmAnulado,NumDev=@pmNumDev,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado,FecUpdate=@pmFecUpdate
 WHERE TipDoc=@pmTipDoc AND OrdPago=@pmOrdPago 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 paUpTraOrdenPagoAnu @pmTipDoc VARCHAR(3),@pmOrdPago INT,@pmIdCia CHAR(2)
,@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4)
 AS 
 UPDATE Trn_TraOrdenPago SET Anulado=@pmAnulado,NumDev=@pmNumDev,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado
 WHERE TipDoc=@pmTipDoc AND OrdPago=@pmOrdPago AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paUpTraPedAnexo @pmTipDoc VARCHAR(3),@pmPedido INT,@pmIdCia CHAR(2),@pmNomCliente VARCHAR(150),@pmNomRemite VARCHAR(150),@pmNomDestino VARCHAR(150),@pmLugarCargue VARCHAR(150),@pmLugarDescargue VARCHAR(150),@pmNomContacto VARCHAR(150)
,@pmTelContacto VARCHAR(30),@pmemlContacto VARCHAR(100),@pmContacDestino VARCHAR(150),@pmTelContacDest VARCHAR(30),@pmemlContacDest VARCHAR(100),@pmPolizaEsp BIT,@pmNumPolizaEsp VARCHAR(50),@pmNitCiaPoliza VARCHAR(16),@pmNomCiaPoliza VARCHAR(150),@pmFecVencePol SMALLDATETIME
,@pmVrLimiteDesp MONEY,@pmSeguros VARCHAR(10),@pmCargue VARCHAR(20),@pmDescargue VARCHAR(20),@pmCdTipoEsc VARCHAR(4),@pmNitSIA VARCHAR(16),@pmNombreSIA VARCHAR(150),@pmContactoSIA VARCHAR(150),@pmTelContacSIA VARCHAR(30),@pmIdLocCont VARCHAR(8),@pmPatioCont VARCHAR(50)
,@pmCdTipoVeh VARCHAR(4),@pmTipoMargen VARCHAR(10),@pmMargenFalt DECIMAL(14,4),@pmEmbAdicional VARCHAR(150)
,@pmTipoRuta VARCHAR(10),@pmTipoTrans VARCHAR(10),@pmEmbarque VARCHAR(10),@pmCdTipCarga VARCHAR(4),@pmDevContenedor BIT,@pmUndCalcFalt VARCHAR(10),@pmTarifFaltPago MONEY,@pmTarifFaltCobro MONEY,@pmCdRutaTarif VARCHAR(4)
 AS 
 UPDATE Trn_TraPedAnexo SET NomCliente=@pmNomCliente,NomRemite=@pmNomRemite,NomDestino=@pmNomDestino,LugarCargue=@pmLugarCargue,LugarDescargue=@pmLugarDescargue,NomContacto=@pmNomContacto,TelContacto=@pmTelContacto,emlContacto=@pmemlContacto,ContacDestino=@pmContacDestino,TelContacDest=@pmTelContacDest,emlContacDest=@pmemlContacDest
,PolizaEsp=@pmPolizaEsp,NumPolizaEsp=@pmNumPolizaEsp,NitCiaPoliza=@pmNitCiaPoliza,NomCiaPoliza=@pmNomCiaPoliza,FecVencePol=@pmFecVencePol,VrLimiteDesp=@pmVrLimiteDesp,Seguros=@pmSeguros,Cargue=@pmCargue,Descargue=@pmDescargue,CdTipoEsc=@pmCdTipoEsc,NitSIA=@pmNitSIA,NombreSIA=@pmNombreSIA,ContactoSIA=@pmContactoSIA
,TelContacSIA=@pmTelContacSIA,IdLocCont=@pmIdLocCont,PatioCont=@pmPatioCont,CdTipoVeh=@pmCdTipoVeh,TipoMargen=@pmTipoMargen,MargenFalt=@pmMargenFalt,EmbAdicional=@pmEmbAdicional,UndCalcFalt=@pmUndCalcFalt,TarifFaltPago=@pmTarifFaltPago,TarifFaltCobro=@pmTarifFaltCobro
,TipoRuta=@pmTipoRuta,TipoTrans=@pmTipoTrans,Embarque=@pmEmbarque,CdTipCarga=@pmCdTipCarga,DevContenedor=@pmDevContenedor,CdRutaTarif=@pmCdRutaTarif
 WHERE TipDoc=@pmTipDoc AND Pedido=@pmPedido AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paUpTraPedido @pmTipDoc VARCHAR(3),@pmPedido INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmFechaVence SMALLDATETIME,@pmFecDespacho SMALLDATETIME,@pmFecEntrega SMALLDATETIME,@pmIdCliente VARCHAR(16),@pmIdAgencia VARCHAR(16),@pmIdClieFact VARCHAR(16),@pmIdRemitente VARCHAR(16),@pmIdDestinatario VARCHAR(16),@pmIdLocOrigen VARCHAR(8),@pmIdLocDestino VARCHAR(8)
,@pmIdVend VARCHAR(16),@pmIdTarifCom VARCHAR(4),@pmModalidad VARCHAR(10),@pmVigencia VARCHAR(10),@pmTipoTarifa VARCHAR(10),@pmVrCobro MONEY,@pmVrPagos MONEY,@pmVrFletes MONEY,@pmVrCargue MONEY,@pmVrDesCargue MONEY,@pmVrEscolta MONEY,@pmVrDevContdor MONEY,@pmVrTraUrbano MONEY,@pmVrEmbalajes MONEY,@pmVrCargos MONEY,@pmVrDctos MONEY,@pmVrDeclarado MONEY,@pmVrSeguro MONEY
,@pmCantidad DECIMAL(14,4),@pmCantDesp DECIMAL(14,4),@pmIdMneda VARCHAR(5),@pmVrTasa DECIMAL(14,4),@pmCotizacion INT,@pmIdCiaCot CHAR(2),@pmNumAprob INT,@pmIdCiaApr CHAR(2),@pmFecAprob SMALLDATETIME,@pmTipOdc VARCHAR(3),@pmOCargue INT,@pmIdCiaOdc CHAR(2),@pmFechaOdc SMALLDATETIME,@pmTipRem VARCHAR(3),@pmRemesa INT,@pmIdCiaRem CHAR(2),@pmFechaRem SMALLDATETIME,@pmTipFac VARCHAR(3)
,@pmFactura INT,@pmIdCiaFac CHAR(2),@pmFechaFac SMALLDATETIME,@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_TraPedido SET Fecha=@pmFecha,FechaVence=@pmFechaVence,FecDespacho=@pmFecDespacho,FecEntrega=@pmFecEntrega,IdCliente=@pmIdCliente,IdAgencia=@pmIdAgencia,IdClieFact=@pmIdClieFact,IdRemitente=@pmIdRemitente,IdDestinatario=@pmIdDestinatario,IdLocOrigen=@pmIdLocOrigen,IdLocDestino=@pmIdLocDestino,IdVend=@pmIdVend,IdTarifCom=@pmIdTarifCom,Modalidad=@pmModalidad,Vigencia=@pmVigencia
,TipoTarifa=@pmTipoTarifa,VrCobro=@pmVrCobro,VrPagos=@pmVrPagos,VrFletes=@pmVrFletes,VrCargue=@pmVrCargue,VrDesCargue=@pmVrDesCargue,VrEscolta=@pmVrEscolta,VrDevContdor=@pmVrDevContdor,VrTraUrbano=@pmVrTraUrbano,VrEmbalajes=@pmVrEmbalajes,VrCargos=@pmVrCargos,VrDctos=@pmVrDctos,VrDeclarado=@pmVrDeclarado,VrSeguro=@pmVrSeguro,Cantidad=@pmCantidad,CantDesp=@pmCantDesp
,IdMneda=@pmIdMneda,VrTasa=@pmVrTasa,Cotizacion=@pmCotizacion,IdCiaCot=@pmIdCiaCot,NumAprob=@pmNumAprob,IdCiaApr=@pmIdCiaApr,FecAprob=@pmFecAprob,TipOdc=@pmTipOdc,OCargue=@pmOCargue,IdCiaOdc=@pmIdCiaOdc,FechaOdc=@pmFechaOdc,TipRem=@pmTipRem,Remesa=@pmRemesa,IdCiaRem=@pmIdCiaRem,FechaRem=@pmFechaRem,TipFac=@pmTipFac,Factura=@pmFactura,IdCiaFac=@pmIdCiaFac,FechaFac=@pmFechaFac
,Anulado=@pmAnulado,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado,FecUpdate=@pmFecUpdate
 WHERE TipDoc=@pmTipDoc AND Pedido=@pmPedido 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  paUpTraPedidoAnu @pmTipDoc VARCHAR(3),@pmPedido INT,@pmIdCia CHAR(2)
,@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4)
 AS 
 UPDATE paUpTraPedido SET Anulado=@pmAnulado,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado
 WHERE TipDoc=@pmTipDoc AND Pedido=@pmPedido 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 paUpTraPedidoApr @pmTipDoc VARCHAR(3),@pmPedido INT,@pmIdCia CHAR(2)
,@pmNumAprob INT,@pmIdCiaApr CHAR(2),@pmFecAprob SMALLDATETIME,@pmIdEstado VARCHAR(4)
 AS 
 UPDATE Trn_TraPedido SET  NumAprob=@pmNumAprob,IdCiaApr=@pmIdCiaApr,FecAprob=@pmFecAprob,IdEstado=@pmIdEstado
 WHERE TipDoc=@pmTipDoc AND Pedido=@pmPedido AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraPresAnt @pmNumPsto INT,@pmFecha SMALLDATETIME,@pmIdOrigen VARCHAR(8),@pmIdDestino VARCHAR(8),@pmFecInicio SMALLDATETIME,@pmFecFinal SMALLDATETIME
,@pmVrGastos MONEY,@pmVrComb MONEY,@pmVrPeajes MONEY,@pmVrAnticipo MONEY,@pmCdCat VARCHAR(4),@pmCdTipoVeh VARCHAR(4),@pmTipoAfilVeh VARCHAR(10),@pmCdTipoMot VARCHAR(4)
,@pmCdCom VARCHAR(4),@pmCdRango VARCHAR(4),@pmValorFijo BIT,@pmObservacion VARCHAR(250),@pmInactivo BIT,@pmTipoRuta VARCHAR(10),@pmCdRuta  VARCHAR(4),@pmFechaAct SMALLDATETIME 
 AS 
 UPDATE Trn_TraPresAnt SET Fecha=@pmFecha,IdOrigen=@pmIdOrigen,IdDestino=@pmIdDestino,FecInicio=@pmFecInicio,FecFinal=@pmFecFinal,VrGastos=@pmVrGastos,VrComb=@pmVrComb,VrPeajes=@pmVrPeajes
,VrAnticipo=@pmVrAnticipo,CdCat=@pmCdCat,CdTipoVeh=@pmCdTipoVeh,TipoAfilVeh=@pmTipoAfilVeh,CdTipoMot=@pmCdTipoMot,CdCom=@pmCdCom,CdRango=@pmCdRango,ValorFijo=@pmValorFijo
,Observacion=@pmObservacion,Inactivo=@pmInactivo,TipoRuta=@pmTipoRuta,CdRuta=@pmCdRuta,FechaAct=@pmFechaAct
 WHERE NumPsto=@pmNumPsto
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraRemAnexo @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2),@pmIdVend VARCHAR(16),@pmIdTarifCom VARCHAR(4),@pmNomCliente VARCHAR(150),@pmNomRemite VARCHAR(150),@pmNomDestino VARCHAR(150),@pmLugarCargue VARCHAR(150),@pmLugarDescargue VARCHAR(150),@pmNomContacto VARCHAR(150),@pmTelContacto VARCHAR(30)
,@pmemlContacto VARCHAR(100),@pmContacDestino VARCHAR(150),@pmTelContacDest VARCHAR(30),@pmemlContacDest VARCHAR(100),@pmPolizaSeguro VARCHAR(50),@pmNitCiaPoliza VARCHAR(16),@pmNomCiaPoliza VARCHAR(150),@pmFecVencePol SMALLDATETIME,@pmManifMintrans DECIMAL(14,2),@pmRemMintrans DECIMAL(14,2),@pmTipSal VARCHAR(3),@pmNumSalida INT,@pmIdCiaSal CHAR(2)
,@pmNumInvent INT,@pmIdCiaInv CHAR(2),@pmTomadorPoliza CHAR(1),@pmTipoRuta VARCHAR(10),@pmTipoMintrans VARCHAR(10)
 AS 
 UPDATE Trn_TraRemAnexo SET IdVend=@pmIdVend,IdTarifCom=@pmIdTarifCom,NomCliente=@pmNomCliente,NomRemite=@pmNomRemite,NomDestino=@pmNomDestino,LugarCargue=@pmLugarCargue,LugarDescargue=@pmLugarDescargue,NomContacto=@pmNomContacto,TelContacto=@pmTelContacto,emlContacto=@pmemlContacto,ContacDestino=@pmContacDestino,TelContacDest=@pmTelContacDest
,emlContacDest=@pmemlContacDest,PolizaSeguro=@pmPolizaSeguro,NitCiaPoliza=@pmNitCiaPoliza,NomCiaPoliza=@pmNomCiaPoliza,FecVencePol=@pmFecVencePol,ManifMintrans=@pmManifMintrans,RemMintrans=@pmRemMintrans,TipSal=@pmTipSal,NumSalida=@pmNumSalida,IdCiaSal=@pmIdCiaSal,NumInvent=@pmNumInvent,IdCiaInv=@pmIdCiaInv,TomadorPoliza=@pmTomadorPoliza,TipoRuta=@pmTipoRuta,TipoMintrans=@pmTipoMintrans
 WHERE TipDoc=@pmTipDoc AND NumOrden=@pmNumOrden AND IdCia=@pmIdCia
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE paUpTraRemesa @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmFecDespacho SMALLDATETIME,@pmFecEntrega SMALLDATETIME,@pmHoraLlegada SMALLDATETIME,@pmIdCliente VARCHAR(16),@pmIdAgencia VARCHAR(16),@pmIdClieFact VARCHAR(16),@pmIdRemitente VARCHAR(16),@pmIdDestinatario VARCHAR(16),@pmIdLocOrigen VARCHAR(8),@pmIdLocDestino VARCHAR(8),@pmIdLocFletes VARCHAR(8),@pmIdVehiculo VARCHAR(10)
,@pmIdConductor VARCHAR(16),@pmnRemolque VARCHAR(10),@pmTipoAfiVehic VARCHAR(10),@pmModalidad VARCHAR(10),@pmTipoTarifa VARCHAR(10),@pmVrCobro MONEY,@pmVrPagos MONEY,@pmVrFletes MONEY,@pmVrCargue MONEY,@pmVrDesCargue MONEY,@pmVrEscolta MONEY,@pmVrDevContdor MONEY,@pmVrTraUrbano MONEY,@pmVrEmbalajes MONEY,@pmVrCargos MONEY,@pmVrDctos MONEY,@pmVrDeclarado MONEY,@pmVrSeguro MONEY,@pmCantidad DECIMAL(14,4)
,@pmPesoTotal DECIMAL(14,4),@pmItems INT,@pmIdMneda VARCHAR(5),@pmVrTasa DECIMAL(14,4),@pmNumPedido INT,@pmIdCiaPed CHAR(2),@pmFechaPed SMALLDATETIME,@pmTipDcm VARCHAR(3),@pmNumDocmto INT,@pmIdCiaDcm CHAR(2),@pmFechaDcm SMALLDATETIME,@pmNumManif INT,@pmIdCiaManif CHAR(2),@pmEstCumplido INT,@pmEstFactura INT,@pmCdConcepto VARCHAR(4),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmAnulado BIT
,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmCdRutaTarif VARCHAR(4),@pmFecUpdate SMALLDATETIME
 AS 
 UPDATE Trn_TraRemesa SET Fecha=@pmFecha,FecDespacho=@pmFecDespacho,FecEntrega=@pmFecEntrega,HoraLlegada=@pmHoraLlegada,IdCliente=@pmIdCliente,IdAgencia=@pmIdAgencia,IdClieFact=@pmIdClieFact,IdRemitente=@pmIdRemitente,IdDestinatario=@pmIdDestinatario,IdLocOrigen=@pmIdLocOrigen,IdLocDestino=@pmIdLocDestino,IdLocFletes=@pmIdLocFletes,IdVehiculo=@pmIdVehiculo,IdConductor=@pmIdConductor,nRemolque=@pmnRemolque,TipoAfiVehic=@pmTipoAfiVehic,Modalidad=@pmModalidad,TipoTarifa=@pmTipoTarifa
,VrCobro=@pmVrCobro,VrPagos=@pmVrPagos,VrFletes=@pmVrFletes,VrCargue=@pmVrCargue,VrDesCargue=@pmVrDesCargue,VrEscolta=@pmVrEscolta,VrDevContdor=@pmVrDevContdor,VrTraUrbano=@pmVrTraUrbano,VrEmbalajes=@pmVrEmbalajes,VrCargos=@pmVrCargos,VrDctos=@pmVrDctos,VrDeclarado=@pmVrDeclarado,VrSeguro=@pmVrSeguro,Cantidad=@pmCantidad,PesoTotal=@pmPesoTotal,Items=@pmItems,IdMneda=@pmIdMneda,VrTasa=@pmVrTasa,NumPedido=@pmNumPedido,IdCiaPed=@pmIdCiaPed,FechaPed=@pmFechaPed
,TipDcm=@pmTipDcm,NumDocmto=@pmNumDocmto,IdCiaDcm=@pmIdCiaDcm,FechaDcm=@pmFechaDcm,NumManif=@pmNumManif,IdCiaManif=@pmIdCiaManif,EstCumplido=@pmEstCumplido,EstFactura=@pmEstFactura,CdConcepto=@pmCdConcepto,TipCom=@pmTipCom,Comprobante=@pmComprobante,IdCiaCom=@pmIdCiaCom,Anulado=@pmAnulado,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado,CdRutaTarif=@pmCdRutaTarif,FecUpdate=@pmFecUpdate
 WHERE TipDoc=@pmTipDoc AND NumOrden=@pmNumOrden 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 paUpTraRemesaAnu @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2)
,@pmAnulado BIT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4)
 AS 
 UPDATE Trn_TraRemesa SET  Anulado=@pmAnulado,FecDev=@pmFecDev,Observacion=@pmObservacion
,IdEstado=@pmIdEstado
 WHERE TipDoc=@pmTipDoc AND NumOrden=@pmNumOrden 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 paUpTraRemMciasMuc @pmTipDoc VARCHAR(3),@pmNumOrden INT,@pmIdCia CHAR(2),@pmItem INT,@pmIdMercancia VARCHAR(16),@pmDescripMcias VARCHAR(250),@pmCantidad DECIMAL(14,4),@pmPesoNeto DECIMAL(14,4),@pmUndMed VARCHAR(10),@pmdmsAlto DECIMAL(14,4),@pmdmsAncho DECIMAL(14,4),@pmdmsLargo DECIMAL(14,4),@pmVolumen DECIMAL(14,4)
,@pmUndVol VARCHAR(10),@pmIdUnd VARCHAR(4),@pmIdEmp VARCHAR(4),@pmIdNat VARCHAR(4),@pmIdTmcia VARCHAR(4),@pmIdMnjo VARCHAR(4),@pmCdRango VARCHAR(4),@pmCases INT,@pmCajas INT,@pmPalets INT,@pmNitRemite VARCHAR(16),@pmRemitente VARCHAR(250),@pmDirOrigen VARCHAR(250),@pmIdOrigen VARCHAR(8),@pmNitDestntario VARCHAR(16),@pmDestinatario VARCHAR(250)
,@pmDirDestino VARCHAR(250),@pmIdDestino VARCHAR(8),@pmTarifPago MONEY,@pmTarifTabla MONEY,@pmRemision DECIMAL(18,2),@pmDocCliente VARCHAR(30),@pmReferencia1 VARCHAR(50),@pmReferencia2 VARCHAR(50),@pmReferencia3 VARCHAR(50)
 AS 
 UPDATE Trn_TraRemMcias SET IdMercancia=@pmIdMercancia,DescripMcias=@pmDescripMcias,Cantidad=@pmCantidad,PesoNeto=@pmPesoNeto,UndMed=@pmUndMed,dmsAlto=@pmdmsAlto,dmsAncho=@pmdmsAncho,dmsLargo=@pmdmsLargo,Volumen=@pmVolumen,UndVol=@pmUndVol,IdUnd=@pmIdUnd,IdEmp=@pmIdEmp,IdNat=@pmIdNat,IdTmcia=@pmIdTmcia,IdMnjo=@pmIdMnjo,CdRango=@pmCdRango
,Cases=@pmCases,Cajas=@pmCajas,Palets=@pmPalets,NitRemite=@pmNitRemite,Remitente=@pmRemitente,DirOrigen=@pmDirOrigen,IdOrigen=@pmIdOrigen,NitDestntario=@pmNitDestntario,Destinatario=@pmDestinatario,DirDestino=@pmDirDestino,IdDestino=@pmIdDestino,TarifPago=@pmTarifPago,TarifTabla=@pmTarifTabla,Remision=@pmRemision,DocCliente=@pmDocCliente,Referencia1=@pmReferencia1,Referencia2=@pmReferencia2,Referencia3=@pmReferencia3
 WHERE TipDoc=@pmTipDoc AND NumOrden=@pmNumOrden AND IdCia=@pmIdCia AND Item=@pmItem
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE paUpTraReportes @pmTipDoc VARCHAR(3),@pmManifiesto INT,@pmIdCia CHAR(2),@pmItem INT,@pmCdRuta VARCHAR(4),@pmIdPunto INT,@pmFecReporte SMALLDATETIME,@pmTipoRep VARCHAR(10)
,@pmEstadoRep INT,@pmCdNovedad VARCHAR(4),@pmObservRep VARCHAR(250),@pmTipoPunto VARCHAR(10),@pmCdPuesto VARCHAR(4),@pmNomConductor VARCHAR(150)
 AS 
 UPDATE Trn_TraReportes SET CdRuta=@pmCdRuta,IdPunto=@pmIdPunto,FecReporte=@pmFecReporte,TipoRep=@pmTipoRep,EstadoRep=@pmEstadoRep,CdNovedad=@pmCdNovedad,ObservRep=@pmObservRep
,TipoPunto=@pmTipoPunto,CdPuesto=@pmCdPuesto,NomConductor=@pmNomConductor
 WHERE TipDoc=@pmTipDoc AND Manifiesto=@pmManifiesto AND IdCia=@pmIdCia AND Item=@pmItem
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

