CREATE TABLE [dbo].[BillingMinorDist]
(
[BMinDistPriKey] [int] NOT NULL IDENTITY(2, 1),
[BMinPriKey] [int] NULL,
[ANPriKey] [int] NULL,
[ICPriKey] [int] NULL,
[InvoiceFlag] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Description] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Amount] [money] NULL CONSTRAINT [DF_BillingMinorDist_Amount] DEFAULT (0),
[InvoiceAmount] [money] NOT NULL,
[Percentage] [float] NULL CONSTRAINT [DF_BillingMinorDist_Percentage] DEFAULT (0),
[Quantity] [int] NULL,
[Rate] [money] NULL CONSTRAINT [DF_BillingMinorDist_Rate] DEFAULT (0),
[GrossAmount] [money] NULL CONSTRAINT [DF_BillingMinorDist_GrossAmount] DEFAULT (0),
[Discount] [float] NULL CONSTRAINT [DF_BillingMinorDist_Discount] DEFAULT (0),
[ApplyToDoc] [int] NULL,
[DocDate] [datetime] NULL,
[JournalDate] [datetime] NULL,
[PostedDate] [datetime] NULL,
[PostedBy] [int] NULL,
[DivisionFID] [int] NULL,
[BranchFID] [int] NULL,
[DocumentNumber] [varchar] (21) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[BillingMinorDist] ADD CONSTRAINT [PK_BillingMinorDist] PRIMARY KEY NONCLUSTERED ([BMinDistPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_BillingMinorDist_ANPriKey] ON [dbo].[BillingMinorDist] ([ANPriKey]) ON [PRIMARY]
GO
CREATE CLUSTERED INDEX [IX_BillingMinorDist_BMinPriKey] ON [dbo].[BillingMinorDist] ([BMinPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_BillingMinorDist_Branch] ON [dbo].[BillingMinorDist] ([BranchFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_BillingMinorDist_PostedBy] ON [dbo].[BillingMinorDist] ([PostedBy]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[BillingMinorDist] ADD CONSTRAINT [FK_BillingMinorDist_AccountingNote] FOREIGN KEY ([ANPriKey]) REFERENCES [dbo].[AccountingNote] ([ANPriKey])
GO
ALTER TABLE [dbo].[BillingMinorDist] ADD CONSTRAINT [FK_BillingMinorDist_BillingMinorItem] FOREIGN KEY ([BMinPriKey]) REFERENCES [dbo].[BillingMinorItem] ([BMinPriKey])
GO
ALTER TABLE [dbo].[BillingMinorDist] ADD CONSTRAINT [FK_BillingMinorDist_BranchFID] FOREIGN KEY ([BranchFID]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[BillingMinorDist] ADD CONSTRAINT [FK_BillingMinorDist_Division] FOREIGN KEY ([DivisionFID]) REFERENCES [dbo].[Division] ([DivisionID])
GO
ALTER TABLE [dbo].[BillingMinorDist] ADD CONSTRAINT [FK_BillingMinorDist_ItemCode] FOREIGN KEY ([ICPriKey]) REFERENCES [dbo].[ItemCode] ([ICPriKey])
GO
ALTER TABLE [dbo].[BillingMinorDist] ADD CONSTRAINT [FK_BillingMinorDist_Sysuser] FOREIGN KEY ([PostedBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
GRANT SELECT ON [dbo].[BillingMinorDist] TO [MssExec]
GRANT INSERT ON [dbo].[BillingMinorDist] TO [MssExec]
GRANT DELETE ON [dbo].[BillingMinorDist] TO [MssExec]
GRANT UPDATE ON [dbo].[BillingMinorDist] TO [MssExec]
GO
EXEC sp_addextendedproperty N'MS_Description', N'Refers to the original BillingMinorDist transaction', 'SCHEMA', N'dbo', 'TABLE', N'BillingMinorDist', 'COLUMN', N'ApplyToDoc'
GO