CREATE TABLE [dbo].[APPaymentDetails]
(
[PaymentID] [int] NOT NULL,
[DetailID] [int] NOT NULL,
[VoucherID] [int] NULL,
[TermDiscountGLID] [int] NULL,
[TermDiscount] [money] NOT NULL,
[GLID] [int] NOT NULL,
[Amount] [money] NOT NULL,
[CreatorID] [char] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[UpdatorID] [char] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[CreateDate] [datetime] NOT NULL CONSTRAINT [DF_APPaymentDetails_CreateDate] DEFAULT (getdate()),
[LastUpdate] [datetime] NOT NULL CONSTRAINT [DF_APPaymentDetails_LastUpdate] DEFAULT (getdate()),
[timestamp] [timestamp] NULL,
[TermDiscountDeptID] [int] NULL,
[ApplyToPaymentID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[APPaymentDetails] ADD CONSTRAINT [PK_APPaymentDetails] PRIMARY KEY CLUSTERED ([PaymentID], [DetailID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[APPaymentDetails] ADD CONSTRAINT [FK_APPaymentDetails_ApplyToPaymentID_APPayments] FOREIGN KEY ([ApplyToPaymentID]) REFERENCES [dbo].[APPayments] ([PaymentID])
GO
ALTER TABLE [dbo].[APPaymentDetails] ADD CONSTRAINT [FK_APPaymentDetails_GLID_GLAccounts1] FOREIGN KEY ([GLID]) REFERENCES [dbo].[GLAccounts1] ([AccountID])
GO
ALTER TABLE [dbo].[APPaymentDetails] ADD CONSTRAINT [FK_APPaymentDetails_PaymentID_APPayments] FOREIGN KEY ([PaymentID]) REFERENCES [dbo].[APPayments] ([PaymentID])
GO
ALTER TABLE [dbo].[APPaymentDetails] ADD CONSTRAINT [FK_APPaymentDetails_TermDiscountDeptID_GLDepts] FOREIGN KEY ([TermDiscountDeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[APPaymentDetails] ADD CONSTRAINT [FK_APPaymentDetails_TermDiscountGLID_GLAccounts1] FOREIGN KEY ([TermDiscountGLID]) REFERENCES [dbo].[GLAccounts1] ([AccountID])
GO
ALTER TABLE [dbo].[APPaymentDetails] ADD CONSTRAINT [FK_APPaymentDetails_VoucherID_APVouchers] FOREIGN KEY ([VoucherID]) REFERENCES [dbo].[APVouchers] ([VoucherID])
GO