CREATE TABLE [dbo].[SCBillingEquipmentMiscCharges]
(
[BillingEquipmentMiscChargeID] [int] NOT NULL IDENTITY(1, 1),
[InvoiceID] [int] NOT NULL,
[ContractDetailID] [int] NOT NULL,
[EquipmentDetailID] [int] NOT NULL,
[BillingEquipmentID] [int] NOT NULL,
[BaseFromDate] [datetime] NULL,
[BaseToDate] [datetime] NULL,
[OverageFromDate] [datetime] NULL,
[OverageToDate] [datetime] NULL,
[ContractDetailMiscChargeID] [int] NOT NULL,
[MiscChargeCodeID] [int] NULL,
[Description] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Quantity] [decimal] (18, 6) NOT NULL,
[Rate] [decimal] (18, 6) NOT NULL,
[GLID] [int] NOT NULL,
[DeptID] [int] NULL,
[TaxFlag] [int] NOT NULL,
[BranchID] [int] NOT NULL,
[DivisionID] [int] NOT NULL,
[BalanceSheetGroupID] [int] NOT NULL,
[TaxCodeID] [int] NULL,
[BillWithID] [int] NOT NULL,
[BillFrequencyID] [int] NOT NULL,
[Amount] [money] NOT NULL,
[CreatorID] [varchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CreateDate] [datetime] NOT NULL CONSTRAINT [DF_SCBillingEquipmentMiscCharges_CreateDate] DEFAULT (getdate()),
[UpdatorID] [varchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LastUpdate] [datetime] NOT NULL CONSTRAINT [DF_SCBillingEquipmentMiscCharges_LastUpdate] DEFAULT (getdate()),
[TaxExemptCodeID] [int] NULL,
[Taxable] [bit] NOT NULL CONSTRAINT [DF_SCBillingEquipmentMiscCharges_Taxable] DEFAULT ((0)),
[Method] [int] NOT NULL CONSTRAINT [DF_SCBillingEquipmentMiscCharges_Method] DEFAULT ((0)),
[PercentMinimumAmount] [money] NULL,
[PercentMaximumAmount] [money] NULL,
[TaxFlagID] [int] NOT NULL,
[LocationID] [int] NULL,
[Address] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SCBillingEquipmentMiscCharges_Address] DEFAULT (''),
[City] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SCBillingEquipmentMiscCharges_City] DEFAULT (''),
[State] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SCBillingEquipmentMiscCharges_State] DEFAULT (''),
[Zip] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SCBillingEquipmentMiscCharges_Zip] DEFAULT (''),
[County] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SCBillingEquipmentMiscCharges_County] DEFAULT (''),
[Country] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SCBillingEquipmentMiscCharges_Country] DEFAULT ('')
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [PK__SCBillin__F208A00AE531BCD7] PRIMARY KEY CLUSTERED ([BillingEquipmentMiscChargeID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [FK_SCBillingEquipmentMiscCharges_BalanceSheetGroupID_GLBalanceSheetGroups] FOREIGN KEY ([BalanceSheetGroupID]) REFERENCES [dbo].[GLBalanceSheetGroups] ([BalanceSheetGroupID])
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [FK_SCBillingEquipmentMiscCharges_BillingEquipmentID_SCBillingEquipments] FOREIGN KEY ([BillingEquipmentID]) REFERENCES [dbo].[SCBillingEquipments] ([BillingEquipmentID])
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [FK_SCBillingEquipmentMiscCharges_BranchID_GLBranches] FOREIGN KEY ([BranchID]) REFERENCES [dbo].[GLBranches] ([BranchID])
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [FK_SCBillingEquipmentMiscCharges_ContractDetailMiscChargeID_SCContractDetailMiscCharges] FOREIGN KEY ([ContractDetailMiscChargeID]) REFERENCES [dbo].[SCContractDetailMiscCharges] ([MiscChargeID])
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [FK_SCBillingEquipmentMiscCharges_DeptID_GLDepts] FOREIGN KEY ([DeptID]) REFERENCES [dbo].[GLDepts] ([DeptID])
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [FK_SCBillingEquipmentMiscCharges_DivisionID_GLDivisions] FOREIGN KEY ([DivisionID]) REFERENCES [dbo].[GLDivisions] ([DivisionID])
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [FK_SCBillingEquipmentMiscCharges_GLID_GLAccounts] FOREIGN KEY ([GLID]) REFERENCES [dbo].[GLAccounts] ([AccountID])
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [FK_SCBillingEquipmentMiscCharges_LocationID_ARCustomers] FOREIGN KEY ([LocationID]) REFERENCES [dbo].[ARCustomers] ([CustomerID])
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [FK_SCBillingEquipmentMiscCharges_MiscChargeCodeID_SCContractMiscChargeCodes] FOREIGN KEY ([MiscChargeCodeID]) REFERENCES [dbo].[SCContractMiscChargeCodes] ([MiscChargeCodeID])
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [FK_SCBillingEquipmentMiscCharges_TaxcodeID_ShTaxCodes] FOREIGN KEY ([TaxCodeID]) REFERENCES [dbo].[ShTaxCodes] ([TaxCodeID])
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [FK_SCBillingEquipmentMiscCharges_TaxExemptCodeID_SHTaxExemptCodes] FOREIGN KEY ([TaxExemptCodeID]) REFERENCES [dbo].[SHTaxExemptCodes] ([TaxExemptCodeID])
GO
ALTER TABLE [dbo].[SCBillingEquipmentMiscCharges] ADD CONSTRAINT [FK_SCBillingEquipmentMiscCharges_TaxFlagID_ShTaxFlags] FOREIGN KEY ([TaxFlagID]) REFERENCES [dbo].[ShTaxFlags] ([TaxFlagID])
GO