CREATE TABLE [dbo].[InvoicedGroup]
(
[IGPriKey] [int] NOT NULL IDENTITY(1, 1),
[IHPriKey] [int] NOT NULL,
[Description] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Amount] [money] NULL,
[ItemCode] [int] NULL,
[Quantity] [float] NULL,
[Rate] [float] NULL,
[Discount] [float] NULL,
[GrossAmount] [money] NULL,
[SortOrder] [int] NOT NULL,
[BillingMajorFID] [int] NULL,
[BillingMinorFID] [int] NULL,
[Rollup] [bit] NOT NULL CONSTRAINT [DF_InvoicedGroup_Rollup] DEFAULT ((0)),
[Adhoc] [bit] NOT NULL CONSTRAINT [DF_InvoicedGroup_Adhoc] DEFAULT ((0)),
[ClaimHandlingRevenueFID] [int] NULL,
[ClaimItemDueFromFID] [int] NULL,
[Quantity2] [float] NULL,
[RateTypeFID] [int] NULL,
[SubTotalFlag] [bit] NOT NULL CONSTRAINT [DF_InvoicedGroup_SubTotalFlag] DEFAULT ((0)),
[CustomerInvoiceReportEDIItemFID] [int] NULL,
[PointOfServiceFID] [int] NULL,
[ExtraStopFID] [int] NULL,
[NoteText] [varchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LaborRatingTypeFID] [int] NULL,
[RateSource] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[RateSourceRecord] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InvoicedGroup] ADD CONSTRAINT [PK_InvoicedGroup] PRIMARY KEY CLUSTERED ([IGPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_InvoicedGroup_BillingMajor] ON [dbo].[InvoicedGroup] ([BillingMajorFID]) INCLUDE ([IHPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_InvoicedGroup_BillingMinor] ON [dbo].[InvoicedGroup] ([BillingMinorFID]) INCLUDE ([IHPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_InvoicedGroup_ExtraStopFID] ON [dbo].[InvoicedGroup] ([ExtraStopFID]) INCLUDE ([IHPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_InvoicedGroup_IHPriKey] ON [dbo].[InvoicedGroup] ([IHPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InvoicedGroup] ADD CONSTRAINT [FK_InvoicedGroup_CustomerInvoiceReportEDIItem] FOREIGN KEY ([CustomerInvoiceReportEDIItemFID]) REFERENCES [dbo].[CustomerInvoiceReportEDIItem] ([CustomerInvoiceReportEDIItemID])
GO
ALTER TABLE [dbo].[InvoicedGroup] ADD CONSTRAINT [FK_InvoicedGroup_ExtraStop] FOREIGN KEY ([ExtraStopFID]) REFERENCES [dbo].[XtraStop] ([PriKey])
GO
ALTER TABLE [dbo].[InvoicedGroup] ADD CONSTRAINT [FK_InvoicedGroup_InvoicedHeader] FOREIGN KEY ([IHPriKey]) REFERENCES [dbo].[InvoicedHeader] ([IHPriKey]) ON DELETE CASCADE ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[InvoicedGroup] ADD CONSTRAINT [FK_InvoicedGroup_LaborRatingTypeFID] FOREIGN KEY ([LaborRatingTypeFID]) REFERENCES [dbo].[LaborRatingType] ([LaborRatingTypeID])
GO
ALTER TABLE [dbo].[InvoicedGroup] ADD CONSTRAINT [FK_InvoicedGroup_PointOfService] FOREIGN KEY ([PointOfServiceFID]) REFERENCES [dbo].[PointOfService] ([PointOfServiceID])
GO
ALTER TABLE [dbo].[InvoicedGroup] ADD CONSTRAINT [FK_InvoicedGroup_RateType] FOREIGN KEY ([RateTypeFID]) REFERENCES [dbo].[RateTypes] ([RTypePriKey])
GO
GRANT SELECT ON [dbo].[InvoicedGroup] TO [MssExec]
GRANT INSERT ON [dbo].[InvoicedGroup] TO [MssExec]
GRANT DELETE ON [dbo].[InvoicedGroup] TO [MssExec]
GRANT UPDATE ON [dbo].[InvoicedGroup] TO [MssExec]
GO