ALTER TABLE Trn_OilTraslado ALTER COLUMN Total_MP DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTraslado ALTER COLUMN VU_MP DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTraslado ALTER COLUMN Total_TRA DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTraslado ALTER COLUMN VU_TRA DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTraslado ALTER COLUMN Total_TVacio DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTraslado ALTER COLUMN VU_TVacio DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTraslado ALTER COLUMN Total_Standby DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTraslado ALTER COLUMN VU_Standby DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTraslado ALTER COLUMN Total_MOD DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTraslado ALTER COLUMN Total_CIF DECIMAL(20,6) NOT NULL
GO
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN CostoAnt DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN VrUnitario DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN VrTotal DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN CostoMPAnt DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN CostoMPMes DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN CostoUndMP DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN CostoUndTra DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN CostoTotalTra DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN CostoTotalSB DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN CostoUndVco DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN CostoTotalVco DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN CostoTotalMod DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoProd ALTER COLUMN CostoTotalCif DECIMAL(20,6) NOT NULL
GO
ALTER TABLE Trn_OilTrasladoRubros ALTER COLUMN VrUnitario DECIMAL(20,6) NOT NULL
ALTER TABLE Trn_OilTrasladoRubros ALTER COLUMN VrTotal DECIMAL(20,6) NOT NULL
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsOilTraslado]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paInsOilTraslado]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paUpOilTraslado]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paUpOilTraslado]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsOilTrasladoProd]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paInsOilTrasladoProd]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInsOilTraslado] @pmTipDoc VARCHAR(3),@pmNumNota INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmFechaInicio SMALLDATETIME,@pmFechaFinal SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmIdTercero VARCHAR(16),@pmCantMP DECIMAL(16,6),@pmCantProducido DECIMAL(16,6),@pmCantConsumo DECIMAL(16,6),@pmCantCrudoCom DECIMAL(16,6),@pmTotal_MP DECIMAL(20,6),@pmVU_MP DECIMAL(20,6),@pmCantBrutoMP DECIMAL(16,6),@pmCantNetoMP DECIMAL(16,6),@pmCantFactMP DECIMAL(16,6),@pmTotal_TRA DECIMAL(20,6),@pmVU_TRA DECIMAL(20,6)
,@pmCantNetoTRA DECIMAL(16,6),@pmCantFactTRA DECIMAL(16,6),@pmTotal_TVacio DECIMAL(20,6),@pmVU_TVacio DECIMAL(20,6),@pmCantNetoTv DECIMAL(16,6),@pmCantFactTv DECIMAL(16,6),@pmTotal_Standby DECIMAL(20,6),@pmVU_Standby DECIMAL(20,6),@pmCant_Standby DECIMAL(16,6),@pmTotal_MOD DECIMAL(20,6),@pmTotal_CIF DECIMAL(20,6),@pmCdCCosto VARCHAR(16),@pmCdSubCos VARCHAR(16),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(2000),@pmIdEstado VARCHAR(4),@pmFechaCrea SMALLDATETIME,@pmIdCiaCrea CHAR(2),@pmOrigenAdd VARCHAR(10),@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Trn_OilTraslado (TipDoc,NumNota,IdCia,Fecha,FechaInicio,FechaFinal,IdConcepto,IdTercero,CantMP,CantProducido,CantConsumo,CantCrudoCom,Total_MP,VU_MP,CantBrutoMP,CantNetoMP,CantFactMP,Total_TRA,VU_TRA,CantNetoTRA,CantFactTRA,Total_TVacio,VU_TVacio,CantNetoTv,CantFactTv,Total_Standby,VU_Standby,Cant_Standby,Total_MOD,Total_CIF,CdCCosto,CdSubCos,TipCom,Comprobante,IdCiaCom,Anulado,NumDev,FecDev,Observacion,IdEstado,FechaCrea,IdCiaCrea,OrigenAdd,IdUsuario)
 VALUES (@pmTipDoc,@pmNumNota,@pmIdCia,@pmFecha,@pmFechaInicio,@pmFechaFinal,@pmIdConcepto,@pmIdTercero,@pmCantMP,@pmCantProducido,@pmCantConsumo,@pmCantCrudoCom,@pmTotal_MP,@pmVU_MP,@pmCantBrutoMP,@pmCantNetoMP,@pmCantFactMP,@pmTotal_TRA,@pmVU_TRA,@pmCantNetoTRA,@pmCantFactTRA,@pmTotal_TVacio,@pmVU_TVacio,@pmCantNetoTv,@pmCantFactTv,@pmTotal_Standby,@pmVU_Standby,@pmCant_Standby,@pmTotal_MOD,@pmTotal_CIF,@pmCdCCosto,@pmCdSubCos,@pmTipCom,@pmComprobante,@pmIdCiaCom,@pmAnulado,@pmNumDev,@pmFecDev,@pmObservacion,@pmIdEstado,@pmFechaCrea,@pmIdCiaCrea,@pmOrigenAdd,@pmIdUsuario)
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paUpOilTraslado] @pmTipDoc VARCHAR(3),@pmNumNota INT,@pmIdCia CHAR(2),@pmFecha SMALLDATETIME,@pmFechaInicio SMALLDATETIME,@pmFechaFinal SMALLDATETIME,@pmIdConcepto VARCHAR(4),@pmIdTercero VARCHAR(16),@pmCantMP DECIMAL(16,6),@pmCantProducido DECIMAL(16,6),@pmCantConsumo DECIMAL(16,6),@pmCantCrudoCom DECIMAL(16,6),@pmTotal_MP DECIMAL(20,6),@pmVU_MP DECIMAL(20,6),@pmCantBrutoMP DECIMAL(16,6),@pmCantNetoMP DECIMAL(16,6),@pmCantFactMP DECIMAL(16,6),@pmTotal_TRA DECIMAL(20,6),@pmVU_TRA DECIMAL(20,6)
,@pmCantNetoTRA DECIMAL(16,6),@pmCantFactTRA DECIMAL(16,6),@pmTotal_TVacio DECIMAL(20,6),@pmVU_TVacio DECIMAL(20,6),@pmCantNetoTv DECIMAL(16,6),@pmCantFactTv DECIMAL(16,6),@pmTotal_Standby DECIMAL(20,6),@pmVU_Standby DECIMAL(20,6),@pmCant_Standby DECIMAL(16,6),@pmTotal_MOD DECIMAL(20,6),@pmTotal_CIF DECIMAL(20,6),@pmCdCCosto VARCHAR(16),@pmCdSubCos VARCHAR(16),@pmTipCom VARCHAR(3),@pmComprobante INT,@pmIdCiaCom CHAR(2),@pmAnulado BIT,@pmNumDev INT,@pmFecDev SMALLDATETIME,@pmObservacion VARCHAR(2000),@pmIdEstado VARCHAR(4)
 AS 
 UPDATE Trn_OilTraslado SET Fecha=@pmFecha,FechaInicio=@pmFechaInicio,FechaFinal=@pmFechaFinal,IdConcepto=@pmIdConcepto,IdTercero=@pmIdTercero,CantMP=@pmCantMP,CantProducido=@pmCantProducido,CantConsumo=@pmCantConsumo,CantCrudoCom=@pmCantCrudoCom,Total_MP=@pmTotal_MP,VU_MP=@pmVU_MP,CantBrutoMP=@pmCantBrutoMP,CantNetoMP=@pmCantNetoMP,CantFactMP=@pmCantFactMP,Total_TRA=@pmTotal_TRA,VU_TRA=@pmVU_TRA,CantNetoTRA=@pmCantNetoTRA,CantFactTRA=@pmCantFactTRA,Total_TVacio=@pmTotal_TVacio,VU_TVacio=@pmVU_TVacio,CantNetoTv=@pmCantNetoTv,CantFactTv=@pmCantFactTv
,Total_Standby=@pmTotal_Standby,VU_Standby=@pmVU_Standby,Cant_Standby=@pmCant_Standby,Total_MOD=@pmTotal_MOD,Total_CIF=@pmTotal_CIF,CdCCosto=@pmCdCCosto,CdSubCos=@pmCdSubCos,TipCom=@pmTipCom,Comprobante=@pmComprobante,IdCiaCom=@pmIdCiaCom,Anulado=@pmAnulado,NumDev=@pmNumDev,FecDev=@pmFecDev,Observacion=@pmObservacion,IdEstado=@pmIdEstado
 WHERE TipDoc=@pmTipDoc AND NumNota=@pmNumNota AND IdCia=@pmIdCia
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInsOilTrasladoProd] @pmTipDoc VARCHAR(3),@pmNumNota INT,@pmIdCia CHAR(2),@pmItem INT,@pmIdProducto VARCHAR(16),@pmDescripcion VARCHAR(500),@pmTipoProd VARCHAR(10),@pmSaldoInicial DECIMAL(16,6),@pmSaldoFinal DECIMAL(16,6),@pmEntradas DECIMAL(16,6),@pmDespachos DECIMAL(16,6),@pmDespMezcla DECIMAL(16,6),@pmSalidas DECIMAL(16,6),@pmAjuSobrante DECIMAL(16,6),@pmAjuFaltante DECIMAL(16,6),@pmCantidad DECIMAL(16,6),@pmUndMed VARCHAR(10),@pmPorcRend DECIMAL(16,6)
,@pmCostoAnt DECIMAL(20,6),@pmVrUnitario DECIMAL(20,6),@pmVrTotal DECIMAL(20,6),@pmSaldoMPAnt DECIMAL(16,6),@pmCantProdAnt DECIMAL(16,6),@pmCostoMPAnt DECIMAL(20,6),@pmCostoMPMes DECIMAL(20,6),@pmCostoUndMP DECIMAL(20,6),@pmCostoUndTra DECIMAL(20,6),@pmCostoTotalTra DECIMAL(20,6),@pmCostoTotalSB DECIMAL(20,6),@pmCostoUndVco DECIMAL(20,6),@pmCostoTotalVco DECIMAL(20,6),@pmCostoTotalMod DECIMAL(20,6),@pmCostoTotalCif DECIMAL(20,6),@pmCodMezcla VARCHAR(16),@pmCdoSubMezcla VARCHAR(8)
,@pmProducido DECIMAL(16,6),@pmCantVehTnsto DECIMAL(16,6),@pmCantBrutoDesp DECIMAL(16,6),@pmCantNetoDesp DECIMAL(16,6),@pmCantTraDesp DECIMAL(16,6)
 AS 
 INSERT INTO Trn_OilTrasladoProd (TipDoc,NumNota,IdCia,Item,IdProducto,Descripcion,TipoProd,SaldoInicial,SaldoFinal,Entradas,Despachos,DespMezcla,Salidas,AjuSobrante,AjuFaltante,Cantidad,UndMed,PorcRend,CostoAnt,VrUnitario,VrTotal,SaldoMPAnt,CantProdAnt,CostoMPAnt,CostoMPMes,CostoUndMP,CostoUndTra,CostoTotalTra,CostoTotalSB,CostoUndVco,CostoTotalVco,CostoTotalMod,CostoTotalCif,CodMezcla,CdoSubMezcla,Producido,CantVehTnsto,CantBrutoDesp,CantNetoDesp,CantTraDesp)
 VALUES (@pmTipDoc,@pmNumNota,@pmIdCia,@pmItem,@pmIdProducto,@pmDescripcion,@pmTipoProd,@pmSaldoInicial,@pmSaldoFinal,@pmEntradas,@pmDespachos,@pmDespMezcla,@pmSalidas,@pmAjuSobrante,@pmAjuFaltante,@pmCantidad,@pmUndMed,@pmPorcRend,@pmCostoAnt,@pmVrUnitario,@pmVrTotal,@pmSaldoMPAnt,@pmCantProdAnt,@pmCostoMPAnt,@pmCostoMPMes,@pmCostoUndMP,@pmCostoUndTra,@pmCostoTotalTra,@pmCostoTotalSB,@pmCostoUndVco,@pmCostoTotalVco,@pmCostoTotalMod
,@pmCostoTotalCif,@pmCodMezcla,@pmCdoSubMezcla,@pmProducido,@pmCantVehTnsto,@pmCantBrutoDesp,@pmCantNetoDesp,@pmCantTraDesp)
GO
