[dbo].[CommissionedDetail]
CREATE TABLE [dbo].[CommissionedDetail]
(
[CDPriKey] [int] NOT NULL IDENTITY(1, 1),
[BMinPriKey] [int] NULL,
[BminDistPriKey] [int] NULL,
[SysUserPriKey] [int] NOT NULL,
[Amount] [money] NOT NULL,
[CommissionType] [varchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CommissionPerc] [float] NULL,
[CommissionFactor] [money] NULL,
[DivisionFID] [int] NULL,
[ANPriKey] [int] NULL,
[OverRideBy] [int] NULL,
[OverRideOn] [datetime] NULL,
[Description] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DocDate] [datetime] NULL,
[JournalDate] [datetime] NULL,
[PostedDate] [datetime] NULL,
[PostedBy] [int] NULL,
[CommissionAfterSplit] [money] NULL,
[ApplyToDoc] [int] NULL,
[CBPriKey] [int] NULL,
[1099Flag] [bit] NOT NULL CONSTRAINT [DF_CommissionedDetail_1099Flag] DEFAULT ((0)),
[VendorID] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LaborTypeFID] [int] NOT NULL,
[DocumentNumber] [varchar] (21) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Miles] [int] NULL,
[Hours] [float] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[CommissionedDetail] ADD CONSTRAINT [PK_CommissionedDetail] PRIMARY KEY NONCLUSTERED ([CDPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_CommissionedDetail_ANPriKey] ON [dbo].[CommissionedDetail] ([ANPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_CommissionedDetail_BminDistPriKey] ON [dbo].[CommissionedDetail] ([BminDistPriKey]) ON [PRIMARY]
GO
CREATE CLUSTERED INDEX [IX_CommissionedDetail_BMinPriKey] ON [dbo].[CommissionedDetail] ([BMinPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_CommissionedDetail_CBPriKey] ON [dbo].[CommissionedDetail] ([CBPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_CommissionedDetail_CommissionType] ON [dbo].[CommissionedDetail] ([CommissionType]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_CommissionedDetail_DocumentNumber] ON [dbo].[CommissionedDetail] ([DocumentNumber]) INCLUDE ([BminDistPriKey], [BMinPriKey], [CDPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_CommissionedDetail_OverRideBy] ON [dbo].[CommissionedDetail] ([OverRideBy]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_CommissionedDetail_PostedBy] ON [dbo].[CommissionedDetail] ([PostedBy]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_CommissionedDetail_SysUserPriKey] ON [dbo].[CommissionedDetail] ([SysUserPriKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[CommissionedDetail] ADD CONSTRAINT [FK_CommissionedDetail_AccountingNote] FOREIGN KEY ([ANPriKey]) REFERENCES [dbo].[AccountingNote] ([ANPriKey])
GO
ALTER TABLE [dbo].[CommissionedDetail] ADD CONSTRAINT [FK_CommissionedDetail_BillingMinorDist] FOREIGN KEY ([BminDistPriKey]) REFERENCES [dbo].[BillingMinorDist] ([BMinDistPriKey])
GO
ALTER TABLE [dbo].[CommissionedDetail] ADD CONSTRAINT [FK_CommissionedDetail_BillingMinorItem] FOREIGN KEY ([BMinPriKey]) REFERENCES [dbo].[BillingMinorItem] ([BMinPriKey])
GO
ALTER TABLE [dbo].[CommissionedDetail] ADD CONSTRAINT [FK_CommissionedDetail_CommissionBasis] FOREIGN KEY ([CBPriKey]) REFERENCES [dbo].[CommissionBasis] ([CBPriKey])
GO
ALTER TABLE [dbo].[CommissionedDetail] ADD CONSTRAINT [FK_CommissionedDetail_Division] FOREIGN KEY ([DivisionFID]) REFERENCES [dbo].[Division] ([DivisionID])
GO
ALTER TABLE [dbo].[CommissionedDetail] ADD CONSTRAINT [FK_CommissionedDetail_LaborType] FOREIGN KEY ([LaborTypeFID]) REFERENCES [dbo].[LaborType] ([PriKey])
GO
ALTER TABLE [dbo].[CommissionedDetail] ADD CONSTRAINT [FK_CommissionedDetail_Sysuser1] FOREIGN KEY ([OverRideBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[CommissionedDetail] ADD CONSTRAINT [FK_CommissionedDetail_Sysuser2] FOREIGN KEY ([PostedBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[CommissionedDetail] ADD CONSTRAINT [FK_CommissionedDetail_Sysuser] FOREIGN KEY ([SysUserPriKey]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
GRANT SELECT ON [dbo].[CommissionedDetail] TO [MssExec]
GRANT INSERT ON [dbo].[CommissionedDetail] TO [MssExec]
GRANT DELETE ON [dbo].[CommissionedDetail] TO [MssExec]
GRANT UPDATE ON [dbo].[CommissionedDetail] TO [MssExec]
GO
EXEC sp_addextendedproperty N'MS_Description', N'Refers to the original CommissionedDetail transaction', 'SCHEMA', N'dbo', 'TABLE', N'CommissionedDetail', 'COLUMN', N'ApplyToDoc'
GO
EXEC sp_addextendedproperty N'MS_Description', N'(FK) to CommissionBasis', 'SCHEMA', N'dbo', 'TABLE', N'CommissionedDetail', 'COLUMN', N'CBPriKey'
GO