CREATE TABLE [dbo].[JobCostingItem]
(
[OrderFID] [int] NOT NULL,
[Date] [date] NULL,
[ExpenseCategoryFID] [int] NOT NULL,
[ExpenseType] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Quantity] [decimal] (12, 2) NULL,
[Cost] [decimal] (12, 2) NOT NULL,
[RatedAmount] [decimal] (12, 2) NULL,
[LocServFID] [int] NULL,
[QuantityPerUnit] [decimal] (12, 2) NULL,
[LaborTotal] [int] NULL,
[RatePerHour] [decimal] (12, 2) NULL,
[LaborRatingTypeFID] [int] NULL
) ON [PRIMARY]
GO
CREATE CLUSTERED INDEX [IX_JobCostingItem_OrderFID] ON [dbo].[JobCostingItem] ([OrderFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[JobCostingItem] ADD CONSTRAINT [FK_JobCostingItem_ExpenseCategory] FOREIGN KEY ([ExpenseCategoryFID]) REFERENCES [dbo].[ExpenseCategory] ([ExpenseCategoryID])
GO
ALTER TABLE [dbo].[JobCostingItem] ADD CONSTRAINT [FK_JobCostingItem_LaborRatingType] FOREIGN KEY ([LaborRatingTypeFID]) REFERENCES [dbo].[LaborRatingType] ([LaborRatingTypeID])
GO
ALTER TABLE [dbo].[JobCostingItem] ADD CONSTRAINT [FK_JobCostingItem_LocServ] FOREIGN KEY ([LocServFID]) REFERENCES [dbo].[LocServ] ([PriKey]) ON DELETE SET NULL
GO
ALTER TABLE [dbo].[JobCostingItem] ADD CONSTRAINT [FK_JobCostingItem_Orders] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey])
GO
GRANT SELECT ON [dbo].[JobCostingItem] TO [MssExec]
GRANT INSERT ON [dbo].[JobCostingItem] TO [MssExec]
GRANT DELETE ON [dbo].[JobCostingItem] TO [MssExec]
GRANT UPDATE ON [dbo].[JobCostingItem] TO [MssExec]
GO