CREATE TABLE [dbo].[BillingMajorItem]
(
[BMajPriKey] [int] NOT NULL IDENTITY(1, 1),
[ANPriKey] [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_BillingMajorItem_Amount] DEFAULT (0),
[OrdPriKey] [int] NOT NULL,
[GrossAmount] [money] NULL CONSTRAINT [DF_BillingMajorItem_GrossAmount] DEFAULT (0),
[Discount] [float] NULL CONSTRAINT [DF_BillingMajorItem_Discount] DEFAULT (0),
[RevGroupPriKey] [int] NULL,
[LSPriKey] [int] NULL,
[IHPriKey] [int] NULL,
[ReductionAmount] [decimal] (12, 2) NULL,
[ReducedInvoiceAmount] [decimal] (12, 2) NULL,
[CustomerInvoiceReportEDIItemFID] [int] NULL,
[ItemCodeFID] [int] NULL,
[RateTypeFID] [int] NULL,
[Quantity] [float] NULL,
[Quantity2] [float] NULL,
[Rate] [float] NULL,
[PointOfServiceFID] [int] NULL,
[ExtraStopFID] [int] NULL,
[LaborRatingTypeFID] [int] NULL,
[RateSource] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[RateSourceRecord] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[BillingMajorItem] ADD CONSTRAINT [PK_BillingMajorItem] PRIMARY KEY NONCLUSTERED ([BMajPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_BillingMajorItem_ANPriKey] ON [dbo].[BillingMajorItem] ([ANPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_BillingMajorItem_ExtraStopFID] ON [dbo].[BillingMajorItem] ([ExtraStopFID]) INCLUDE ([BMajPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_BillingMajorItem_IHPriKey] ON [dbo].[BillingMajorItem] ([IHPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_BillingMajorItem_LSPrikey] ON [dbo].[BillingMajorItem] ([LSPriKey]) ON [PRIMARY]
GO
CREATE CLUSTERED INDEX [IX_BillingMajorItem_OrdPriKey] ON [dbo].[BillingMajorItem] ([OrdPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[BillingMajorItem] ADD CONSTRAINT [FK_BillingMajorItem_AccountingNote] FOREIGN KEY ([ANPriKey]) REFERENCES [dbo].[AccountingNote] ([ANPriKey])
GO
ALTER TABLE [dbo].[BillingMajorItem] ADD CONSTRAINT [FK_BillingMajorItem_CustomerInvoiceReportEDIItem] FOREIGN KEY ([CustomerInvoiceReportEDIItemFID]) REFERENCES [dbo].[CustomerInvoiceReportEDIItem] ([CustomerInvoiceReportEDIItemID])
GO
ALTER TABLE [dbo].[BillingMajorItem] ADD CONSTRAINT [FK_BillingMajorItem_ExtraStop] FOREIGN KEY ([ExtraStopFID]) REFERENCES [dbo].[XtraStop] ([PriKey])
GO
ALTER TABLE [dbo].[BillingMajorItem] ADD CONSTRAINT [FK_BillingMajorItem_ItemCode] FOREIGN KEY ([ItemCodeFID]) REFERENCES [dbo].[ItemCode] ([ICPriKey])
GO
ALTER TABLE [dbo].[BillingMajorItem] ADD CONSTRAINT [FK_BillingMajorItem_LaborRatingTypeFID] FOREIGN KEY ([LaborRatingTypeFID]) REFERENCES [dbo].[LaborRatingType] ([LaborRatingTypeID])
GO
ALTER TABLE [dbo].[BillingMajorItem] ADD CONSTRAINT [FK_BillingMajorItem_LocServ] FOREIGN KEY ([LSPriKey]) REFERENCES [dbo].[LocServ] ([PriKey])
GO
ALTER TABLE [dbo].[BillingMajorItem] ADD CONSTRAINT [FK_BillingMajorItem_ORDERS] FOREIGN KEY ([OrdPriKey]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[BillingMajorItem] ADD CONSTRAINT [FK_BillingMajorItem_PointOfService] FOREIGN KEY ([PointOfServiceFID]) REFERENCES [dbo].[PointOfService] ([PointOfServiceID])
GO
ALTER TABLE [dbo].[BillingMajorItem] ADD CONSTRAINT [FK_BillingMajorItem_RateType] FOREIGN KEY ([RateTypeFID]) REFERENCES [dbo].[RateTypes] ([RTypePriKey])
GO
ALTER TABLE [dbo].[BillingMajorItem] ADD CONSTRAINT [FK_BillingMajorItem_RevGroups] FOREIGN KEY ([RevGroupPriKey]) REFERENCES [dbo].[RevGroups] ([RGPriKey])
GO
GRANT SELECT ON [dbo].[BillingMajorItem] TO [MssExec]
GRANT INSERT ON [dbo].[BillingMajorItem] TO [MssExec]
GRANT DELETE ON [dbo].[BillingMajorItem] TO [MssExec]
GRANT UPDATE ON [dbo].[BillingMajorItem] TO [MssExec]
GO