CREATE TABLE [dbo].[SplitCommissions]
(
[SCPriKey] [int] NOT NULL IDENTITY(1, 1),
[CDPriKey] [int] NOT NULL,
[SysUserPriKey] [int] NOT NULL,
[Amount] [money] NOT NULL,
[CommissionType] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CommissionPerc] [float] NULL,
[FlatRate] [money] NULL,
[HaulingWeight] [int] NULL,
[ANPriKey] [int] NULL,
[Description] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Miles] [int] NULL,
[ApplyToDoc] [int] NULL,
[DocDate] [datetime] NULL,
[JournalDate] [datetime] NULL,
[PostedDate] [datetime] NULL,
[PostedBy] [int] NULL,
[DivisionFID] [int] NULL,
[1099Flag] [bit] NOT NULL CONSTRAINT [DF_SplitCommissions_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
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SplitCommissions] ADD CONSTRAINT [PK_SplitCommissions] PRIMARY KEY NONCLUSTERED ([SCPriKey]) ON [PRIMARY]
GO
CREATE CLUSTERED INDEX [IX_SplitCommissions_CDPriKey] ON [dbo].[SplitCommissions] ([CDPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_SplitCommissions_PostedBy] ON [dbo].[SplitCommissions] ([PostedBy]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_SplitCommissions_SysUserPriKey] ON [dbo].[SplitCommissions] ([SysUserPriKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SplitCommissions] ADD CONSTRAINT [FK_SplitCommissions_AccountingNote] FOREIGN KEY ([ANPriKey]) REFERENCES [dbo].[AccountingNote] ([ANPriKey])
GO
ALTER TABLE [dbo].[SplitCommissions] ADD CONSTRAINT [FK_SplitCommissions_CommissionedDetail] FOREIGN KEY ([CDPriKey]) REFERENCES [dbo].[CommissionedDetail] ([CDPriKey])
GO
ALTER TABLE [dbo].[SplitCommissions] ADD CONSTRAINT [FK_SplitCommissions_LaborType] FOREIGN KEY ([LaborTypeFID]) REFERENCES [dbo].[LaborType] ([PriKey])
GO
ALTER TABLE [dbo].[SplitCommissions] ADD CONSTRAINT [FK_SplitCommissions_Sysuser1] FOREIGN KEY ([PostedBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[SplitCommissions] ADD CONSTRAINT [FK_SplitCommissions_Sysuser] FOREIGN KEY ([SysUserPriKey]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
GRANT SELECT ON [dbo].[SplitCommissions] TO [MssExec]
GRANT INSERT ON [dbo].[SplitCommissions] TO [MssExec]
GRANT DELETE ON [dbo].[SplitCommissions] TO [MssExec]
GRANT UPDATE ON [dbo].[SplitCommissions] TO [MssExec]
GO