[dbo].[ReductionTemplateHeader]
CREATE TABLE [dbo].[ReductionTemplateHeader]
(
[ReductionTemplateID] [int] NOT NULL IDENTITY(1, 1),
[ItemCodeFID] [int] NULL,
[DivisionFID] [int] NULL,
[Description] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BranchFID] [int] NULL,
[DateBasisFID] [int] NULL,
[AgentTypeName] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Inactive] [bit] NOT NULL CONSTRAINT [DF_ReductionTemplateHeader_Inactive] DEFAULT ((0)),
[IsAddbackBasedOnAgentPercentage] [bit] NOT NULL CONSTRAINT [DF_ReductionTemplateHeader_IsAddbackBasedOnAgentPercentage] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ReductionTemplateHeader] ADD CONSTRAINT [CK_ReductionTemplateHeader_Branch_AgentTypeName] CHECK (([BranchFID] IS NULL AND [AgentTypeName] IS NULL OR [BranchFID] IS NULL AND [AgentTypeName] IS NOT NULL OR [BranchFID] IS NOT NULL AND [AgentTypeName] IS NULL))
GO
ALTER TABLE [dbo].[ReductionTemplateHeader] ADD CONSTRAINT [CK_ReductionTemplateHeader_Branch_Division] CHECK (((1)=[dbo].[IsDivisionValidForBranch]([BranchFID],[DivisionFID])))
GO
ALTER TABLE [dbo].[ReductionTemplateHeader] ADD CONSTRAINT [PK_ReductionTemplateHeader] PRIMARY KEY NONCLUSTERED ([ReductionTemplateID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ReductionTemplateHeader] ADD CONSTRAINT [FK_ReductionTemplateHeader_BranchFID] FOREIGN KEY ([BranchFID]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[ReductionTemplateHeader] ADD CONSTRAINT [FK_ReductionTemplateHeader_DateBasisFID] FOREIGN KEY ([DateBasisFID]) REFERENCES [dbo].[DateBasis] ([DateBasisID])
GO
ALTER TABLE [dbo].[ReductionTemplateHeader] ADD CONSTRAINT [FK_ReductionTemplateHeader_Division] FOREIGN KEY ([DivisionFID]) REFERENCES [dbo].[Division] ([DivisionID])
GO
ALTER TABLE [dbo].[ReductionTemplateHeader] ADD CONSTRAINT [FK_ReductionTemplateHeader_ItemCode] FOREIGN KEY ([ItemCodeFID]) REFERENCES [dbo].[ItemCode] ([ICPriKey])
GO
GRANT SELECT ON [dbo].[ReductionTemplateHeader] TO [MssExec]
GRANT INSERT ON [dbo].[ReductionTemplateHeader] TO [MssExec]
GRANT DELETE ON [dbo].[ReductionTemplateHeader] TO [MssExec]
GRANT UPDATE ON [dbo].[ReductionTemplateHeader] TO [MssExec]
GO