ALTER TABLE TercClieLineas ADD CdTasaConv VARCHAR(4),NitConvenio VARCHAR(16),CuotasConv INT DEFAULT(0)
GO
ALTER TABLE Trn_FinPrestamo ADD  TipoCredito VARCHAR(10) DEFAULT('PRESTAMO') NOT NULL
,CalcIntMora BIT DEFAULT(0) NOT NULL,NitEmpConv VARCHAR(16),CuotasConv INT DEFAULT(0)
GO
ALTER TABLE Trn_FinCuotas ADD FecUltCausac SMALLDATETIME,VrAcumCapital MONEY DEFAULT(0)
GO
ALTER TABLE tm_PreCuotas ADD tmVrSaldo MONEY DEFAULT(0),tmUltCausac SMALLDATETIME
,tmVrAcumCap MONEY DEFAULT(0),tmNitConv VARCHAR(16)
GO
ALTER TABLE Trn_FinFacturas ADD FecInicio SMALLDATETIME,FecFinal SMALLDATETIME,VrAbono MONEY DEFAULT(0)
,Facturado BIT DEFAULT(0),TipFac VARCHAR(3),FacturaInt INT DEFAULT(0),FecFactura SMALLDATETIME
GO
ALTER TABLE adm_Registro ADD FechaPrest SMALLDATETIME
GO
CREATE TABLE Trn_FinAmtza ( 
TipDoc VARCHAR(3) DEFAULT ('PR1') NOT NULL,
IdPrestamo INT DEFAULT (0) NOT NULL,
IdCia CHAR(2) DEFAULT ('01') NOT NULL,
Item INT DEFAULT (1) NOT NULL,
FecCausac SMALLDATETIME NOT NULL,
FecVence SMALLDATETIME NOT NULL,
NumDias INT DEFAULT (0) NOT NULL,
VrCuota MONEY DEFAULT (0) NOT NULL,
VrCapital MONEY DEFAULT (0) NOT NULL,
VrInteres MONEY DEFAULT (0) NOT NULL,
VrSaldo MONEY DEFAULT (0) NOT NULL,
TasaEfeMes DECIMAL(16,8) DEFAULT (0) NOT NULL,
TasaEfeDia DECIMAL(16,8) DEFAULT (0) NOT NULL,
Causacion INT DEFAULT (0) NOT NULL,
CdCiaCausac CHAR(2),
VrCuoCausac MONEY DEFAULT (0) NOT NULL,
VrIntCausac MONEY DEFAULT (0) NOT NULL,
VrSaldoCausac MONEY DEFAULT (0) NOT NULL
 CONSTRAINT PK_Trn_FinAmtza PRIMARY KEY CLUSTERED (TipDoc,IdPrestamo,IdCia,Item),
 CONSTRAINT CK_Trn_FinAmtzaIdCia CHECK ((len([IdCia]) > 0)),
 CONSTRAINT CK_Trn_FinAmtzaTipDoc CHECK ((len([TipDoc]) > 0)))
GO
ALTER TABLE Trn_FinAmtza ADD 
 CONSTRAINT FK_Trn_FinAmtza_Trn_FinPrestamo FOREIGN KEY (TipDoc,IdPrestamo,IdCia) REFERENCES [dbo].[Trn_FinPrestamo] (TipDoc,IdPrestamo,IdCia)
 CREATE NONCLUSTERED INDEX IX_Trn_FinAmtzaFecCausac ON Trn_FinAmtza(FecCausac)
 CREATE NONCLUSTERED INDEX IX_Trn_FinAmtzaFecVence ON Trn_FinAmtza(FecVence)

ALTER TABLE Trn_FinPrestamo DROP CONSTRAINT  FK_Trn_FinPrestamo_TasasIntmora
