CREATE TABLE [dbo].[StatementPayable]
(
[StatementPayableID] [int] NOT NULL IDENTITY(1, 1),
[StatementDetailFID] [int] NOT NULL,
[StatementDetailDistFID] [int] NULL,
[Description] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BranchFID] [int] NOT NULL,
[DivisionFID] [int] NULL,
[VendorID] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Amount] [money] NOT NULL CONSTRAINT [DF_StatementPayable_Amount] DEFAULT ((0)),
[1099Flag] [bit] NOT NULL CONSTRAINT [DF_StatementPayable_1099Flag] DEFAULT ((0)),
[DocumentNumber] [varchar] (23) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ApplyAmount] [money] NOT NULL CONSTRAINT [DF_StatementPayable_ApplyAmount] DEFAULT ((0)),
[GPFlag] [bit] NOT NULL CONSTRAINT [DF_StatementPayable_GPFlag] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StatementPayable] ADD CONSTRAINT [PK_StatementPayable] PRIMARY KEY CLUSTERED ([StatementPayableID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementPayable_StatementDetailDist] ON [dbo].[StatementPayable] ([StatementDetailFID], [StatementDetailDistFID], [VendorID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_StatementPayable_StatementDetail] ON [dbo].[StatementPayable] ([StatementDetailFID], [StatementPayableID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[StatementPayable] ADD CONSTRAINT [FK_StatementPayable_Branch] FOREIGN KEY ([BranchFID]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[StatementPayable] ADD CONSTRAINT [FK_StatementPayable_Division] FOREIGN KEY ([DivisionFID]) REFERENCES [dbo].[Division] ([DivisionID])
GO
ALTER TABLE [dbo].[StatementPayable] ADD CONSTRAINT [FK_StatementPayable_StatementDetailDist] FOREIGN KEY ([StatementDetailDistFID]) REFERENCES [dbo].[StatementDetailDist] ([SDDPriKey])
GO
ALTER TABLE [dbo].[StatementPayable] ADD CONSTRAINT [FK_StatementPayable_StatementDetail] FOREIGN KEY ([StatementDetailFID]) REFERENCES [dbo].[StatementDetail] ([SDPriKey])
GO
GRANT SELECT ON [dbo].[StatementPayable] TO [MssExec]
GRANT INSERT ON [dbo].[StatementPayable] TO [MssExec]
GRANT DELETE ON [dbo].[StatementPayable] TO [MssExec]
GRANT UPDATE ON [dbo].[StatementPayable] TO [MssExec]
GO