CREATE TABLE [dbo].[PRPaymentDetails]
(
[PaymentID] [int] NOT NULL,
[DetailID] [int] NOT NULL,
[Description] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[GLID] [int] NOT NULL,
[DeptID] [int] 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_PRPaymentDetails_CreateDate] DEFAULT (getdate()),
[LastUpdate] [datetime] NOT NULL CONSTRAINT [DF_PRPaymentDetails_LastUpdate] DEFAULT (getdate()),
[timestamp] [timestamp] NULL,
[BranchID] [int] NOT NULL,
[DivisionID] [int] NULL,
[BalanceSheetGroupID] [int] NULL,
[IntercompanyGLID] [int] NULL,
[CashbookIntercompanyGLID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PRPaymentDetails] ADD CONSTRAINT [PK_PRPaymentDetails] PRIMARY KEY CLUSTERED ([PaymentID], [DetailID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PRPaymentDetails] ADD CONSTRAINT [FK_PRPaymentDetails_BalanceSheetGroupID_GLBalanceSheetGroups] FOREIGN KEY ([BalanceSheetGroupID]) REFERENCES [dbo].[GLBalanceSheetGroups] ([BalanceSheetGroupID])
GO
ALTER TABLE [dbo].[PRPaymentDetails] ADD CONSTRAINT [FK_PRPaymentDetails_BranchID_GLBranches] FOREIGN KEY ([BranchID]) REFERENCES [dbo].[GLBranches] ([BranchID])
GO
ALTER TABLE [dbo].[PRPaymentDetails] ADD CONSTRAINT [FK_PRPaymentDetails_CashbookIntercompanyGLID_GLAccounts] FOREIGN KEY ([CashbookIntercompanyGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[PRPaymentDetails] ADD CONSTRAINT [FK_PRPaymentDetails_DeptID_GLDepts5] FOREIGN KEY ([DeptID]) REFERENCES [dbo].[GLDepts5] ([DeptID])
GO
ALTER TABLE [dbo].[PRPaymentDetails] ADD CONSTRAINT [FK_PRPaymentDetails_DivisionID_GLDivisions] FOREIGN KEY ([DivisionID]) REFERENCES [dbo].[GLDivisions] ([DivisionID])
GO
ALTER TABLE [dbo].[PRPaymentDetails] ADD CONSTRAINT [FK_PRPaymentDetails_GLID_GLAccounts5] FOREIGN KEY ([GLID]) REFERENCES [dbo].[GLAccounts5] ([AccountID])
GO
ALTER TABLE [dbo].[PRPaymentDetails] ADD CONSTRAINT [FK_PRPaymentDetails_IntercompanyGLID_GLAccounts] FOREIGN KEY ([IntercompanyGLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[PRPaymentDetails] ADD CONSTRAINT [FK_PRPaymentDetails_PaymentID_PRPayments] FOREIGN KEY ([PaymentID]) REFERENCES [dbo].[PRPayments] ([PaymentID])
GO