CREATE TABLE [dbo].[LoanRepayment] (
	[Id]            INT           IDENTITY (1, 1) NOT NULL,
	[LoanId]        INT           NOT NULL,
	[PaymentAmount] FLOAT (53)    NOT NULL,
	[PaymentDate]   DATETIME      NOT NULL,
	[PaymentMethod] NVARCHAR (50) NOT NULL,
	[LoanScheduleId] INT NULL,
	[LoanRepaymentStatusId] INT NOT NULL, 
	--[Balance] FLOAT NOT NULL DEFAULT 0, 
	--[PaymentBalance] FLOAT NOT NULL DEFAULT 0, 
	CONSTRAINT [PK_LoanRepayment] PRIMARY KEY CLUSTERED ([Id] ASC),
	CONSTRAINT [FK_LoanRepayment_Loan] FOREIGN KEY ([LoanId]) REFERENCES [dbo].[Loan] ([Id]), 
	CONSTRAINT [FK_LoanRepayment_LoanSchedule] FOREIGN KEY ([LoanScheduleId]) REFERENCES  [dbo].[LoanSchedule]([Id]),
	CONSTRAINT [FK_LoanRepayment_LoanRepaymentStatus] FOREIGN KEY ([LoanRepaymentStatusId]) REFERENCES  [dbo].[LoanRepaymentStatus]([Id])
);

