CREATE TABLE LogMudInvent ( 
Id VARCHAR(5) NOT NULL,
Item INT DEFAULT ((0)) NOT NULL,
IdArticulo VARCHAR(16) NOT NULL,
Descripcion VARCHAR(500) NOT NULL,
Cantidad DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
IdEstado VARCHAR(4),
Observacion VARCHAR(500),
Estado VARCHAR(50),
Articulo VARCHAR(250)
 CONSTRAINT PK_LogMudInvent PRIMARY KEY CLUSTERED (Id,Item),
 CONSTRAINT CK_LogMudInventDescripcion CHECK ((len([Descripcion])>(0))),
 CONSTRAINT CK_LogMudInventId CHECK ((len([Id])>(0))),
 CONSTRAINT CK_LogMudInventIdArticulo CHECK ((len([IdArticulo])>(0))))
GO
CREATE TABLE LogMudConc ( 
Id VARCHAR(5) NOT NULL,
Item INT DEFAULT ((0)) NOT NULL,
IdConcepto VARCHAR(4) NOT NULL,
Descripcion VARCHAR(500) NOT NULL,
ValorTotal MONEY DEFAULT ((0)) NOT NULL,
TarifaIva DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
TipoConc VARCHAR(10) NOT NULL,
TipoRubro VARCHAR(20) NOT NULL,
TipoReg INT DEFAULT ((0)) NOT NULL,
CdCuenta VARCHAR(16),
NitTercero VARCHAR(16),
Referencia VARCHAR(50),
NumDocRef VARCHAR(20),
CodTarIva VARCHAR(4),
RazonSocial VARCHAR(250),
Concepto VARCHAR(250)
 CONSTRAINT PK_LogMudConc PRIMARY KEY CLUSTERED (Id,Item),
 CONSTRAINT CK_LogMudConcDescripcion CHECK ((len([Descripcion])>(0))),
 CONSTRAINT CK_LogMudConcId CHECK ((len([Id])>(0))),
 CONSTRAINT CK_LogMudConcIdConcepto CHECK ((len([IdConcepto])>(0))),
 CONSTRAINT CK_LogMudConcTipoConc CHECK ((len([TipoConc])>(0))),
 CONSTRAINT CK_LogMudConcTipoRubro CHECK ((len([TipoRubro])>(0))))
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInsLogMudConc] @pmId VARCHAR(5),@pmItem INT,@pmIdConcepto VARCHAR(4),@pmDescripcion VARCHAR(500),@pmValorTotal MONEY,@pmTarifaIva DECIMAL(14,4),@pmTipoConc VARCHAR(10),@pmTipoRubro VARCHAR(20)
,@pmTipoReg INT,@pmCdCuenta VARCHAR(16),@pmNitTercero VARCHAR(16),@pmReferencia VARCHAR(50),@pmNumDocRef VARCHAR(20),@pmCodTarIva VARCHAR(4),@pmRazonSocial VARCHAR(250),@pmConcepto VARCHAR(250)
 AS 
 INSERT INTO LogMudConc (Id,Item,IdConcepto,Descripcion,ValorTotal,TarifaIva,TipoConc,TipoRubro,TipoReg,CdCuenta,NitTercero,Referencia,NumDocRef,CodTarIva,RazonSocial,Concepto)
 VALUES (@pmId,@pmItem,@pmIdConcepto,@pmDescripcion,@pmValorTotal,@pmTarifaIva,@pmTipoConc,@pmTipoRubro,@pmTipoReg,@pmCdCuenta,@pmNitTercero,@pmReferencia,@pmNumDocRef,@pmCodTarIva,@pmRazonSocial,@pmConcepto)
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paUpLogMudConc] @pmId VARCHAR(5),@pmItem INT,@pmIdConcepto VARCHAR(4),@pmDescripcion VARCHAR(500),@pmValorTotal MONEY,@pmTarifaIva DECIMAL(14,4),@pmTipoConc VARCHAR(10),@pmTipoRubro VARCHAR(20)
,@pmTipoReg INT,@pmCdCuenta VARCHAR(16),@pmNitTercero VARCHAR(16),@pmReferencia VARCHAR(50),@pmNumDocRef VARCHAR(20),@pmCodTarIva VARCHAR(4),@pmRazonSocial VARCHAR(250),@pmConcepto VARCHAR(250)
 AS 
 UPDATE LogMudConc SET IdConcepto=@pmIdConcepto,Descripcion=@pmDescripcion,ValorTotal=@pmValorTotal,TarifaIva=@pmTarifaIva,TipoConc=@pmTipoConc,TipoRubro=@pmTipoRubro,TipoReg=@pmTipoReg,CdCuenta=@pmCdCuenta
,NitTercero=@pmNitTercero,Referencia=@pmReferencia,NumDocRef=@pmNumDocRef,CodTarIva=@pmCodTarIva,RazonSocial=@pmRazonSocial,Concepto=@pmConcepto
 WHERE Id=@pmId AND Item=@pmItem
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paQryLogMudConc] @pmId VARCHAR(5),@pmItem INT
 AS 
 SELECT Id,Item,IdConcepto,Descripcion,ValorTotal,TarifaIva,TipoConc,TipoRubro,TipoReg,CdCuenta,NitTercero,Referencia,NumDocRef,CodTarIva,RazonSocial,Concepto
 FROM LogMudConc
 WHERE Id=@pmId AND Item=@pmItem
GO
