CREATE TABLE [dbo].[AdvanceSetup]
(
[AdvanceSetupID] [int] NOT NULL IDENTITY(1, 1),
[ManualGLFlag] [bit] NOT NULL,
[ManualGL] [varchar] (66) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Account] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[SubAccount] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[OnHoldFlag] [bit] NULL,
[AmountBeyondPercentage] [money] NULL,
[ManagerCapAmount] [money] NULL,
[CreateAdvancesFromCommissions] [bit] NOT NULL CONSTRAINT [DF_AdvanceSetup_CreateAdvancesFromCommissions] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AdvanceSetup] ADD CONSTRAINT [CK_AdvanceSetupCount] CHECK (((1)>=[dbo].[AdvanceSetupCount]()))
GO
ALTER TABLE [dbo].[AdvanceSetup] ADD CONSTRAINT [CK_ManualGLFlagSetup] CHECK (([ManualGLFlag]=(1) AND [ManualGL] IS NOT NULL OR [ManualGLFlag]=(0) AND [Account] IS NOT NULL AND [SubAccount] IS NOT NULL))
GO
ALTER TABLE [dbo].[AdvanceSetup] ADD CONSTRAINT [PK_AdvanceSetup] PRIMARY KEY CLUSTERED ([AdvanceSetupID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
GRANT SELECT ON [dbo].[AdvanceSetup] TO [MssExec]
GRANT INSERT ON [dbo].[AdvanceSetup] TO [MssExec]
GRANT DELETE ON [dbo].[AdvanceSetup] TO [MssExec]
GRANT UPDATE ON [dbo].[AdvanceSetup] TO [MssExec]
GO
EXEC sp_addextendedproperty N'MS_Description', N'The account section of the advance expense account.', 'SCHEMA', N'dbo', 'TABLE', N'AdvanceSetup', 'COLUMN', N'Account'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Primary key.', 'SCHEMA', N'dbo', 'TABLE', N'AdvanceSetup', 'COLUMN', N'AdvanceSetupID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'The manual advance expense account.', 'SCHEMA', N'dbo', 'TABLE', N'AdvanceSetup', 'COLUMN', N'ManualGL'
GO
EXEC sp_addextendedproperty N'MS_Description', N'0 if the manual advance expense account is not used, 1 if it is used.', 'SCHEMA', N'dbo', 'TABLE', N'AdvanceSetup', 'COLUMN', N'ManualGLFlag'
GO
EXEC sp_addextendedproperty N'MS_Description', N'The sub-account section of the advance expense account.', 'SCHEMA', N'dbo', 'TABLE', N'AdvanceSetup', 'COLUMN', N'SubAccount'
GO