CREATE TABLE [dbo].[PlasticWebDeal]
(
[WebDealID] [int] NOT NULL IDENTITY(1, 1),
[ProviderFID] [int] NOT NULL,
[MoversConnectFID] [bigint] NOT NULL,
[ExternalID] [varchar] (90) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[PaymentUrl] [varchar] (176) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Description] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[BranchPriKey] [int] NOT NULL,
[CustomerNumber] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[OrderFID] [int] NULL,
[InvoicedHeaderFID] [int] NULL,
[StorageFID] [int] NULL,
[StorageInvoiceFID] [int] NULL,
[ItemAmount] [money] NOT NULL,
[SysUserFID] [int] NOT NULL,
[CreatedDate] [datetime] NOT NULL,
[EmailAddress] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[PaymentNotification] [bit] NOT NULL CONSTRAINT [DF_PlasticWebDeal_PaymentNotification] DEFAULT ((0)),
[NotificationEmailAddress] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CaptureCardInfoOnly] [bit] NOT NULL CONSTRAINT [DF_PlasticWebDeal_CaptureCardInfoOnly] DEFAULT ((0)),
[AttachCardToCustomer] [bit] NOT NULL CONSTRAINT [DF_PlasticWebDeal_AttachCardToCustomer] DEFAULT ((0)),
[SysEmailTypeCode] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_PlasticWebDeal_SysEmailTypeCode] DEFAULT ('O'),
[WasReprocessed] [bit] NOT NULL CONSTRAINT [DF_PlasticWebDeal_WasReprocessed] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PlasticWebDeal] ADD CONSTRAINT [CK_PlasticWebDeal_SysEmailTypeCode] CHECK (((1)=[dbo].[SysEmailTypeCodeIsValid]([SysEmailTypeCode])))
GO
ALTER TABLE [dbo].[PlasticWebDeal] ADD CONSTRAINT [PK_PlasticWebDeal] PRIMARY KEY CLUSTERED ([WebDealID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_PlasticWebDeal_MoversConnectFID] ON [dbo].[PlasticWebDeal] ([MoversConnectFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_PlasticWebDeal_OrderFID] ON [dbo].[PlasticWebDeal] ([OrderFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_PlasticWebDeal_StorageInvoiceFID] ON [dbo].[PlasticWebDeal] ([StorageInvoiceFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_PlasticWebDeal_SysUserFID] ON [dbo].[PlasticWebDeal] ([SysUserFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PlasticWebDeal] ADD CONSTRAINT [FK_PlasticWebDeal_BranchPriKey] FOREIGN KEY ([BranchPriKey]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[PlasticWebDeal] ADD CONSTRAINT [FK_PlasticWebDeal_OrderID] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[PlasticWebDeal] ADD CONSTRAINT [FK_PlasticWebDeal_ProviderFID] FOREIGN KEY ([ProviderFID]) REFERENCES [dbo].[PlasticProvider] ([ProviderID])
GO
ALTER TABLE [dbo].[PlasticWebDeal] ADD CONSTRAINT [FK_PlasticWebDeal_SysUserFID] FOREIGN KEY ([SysUserFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
GRANT SELECT ON [dbo].[PlasticWebDeal] TO [MssExec]
GRANT INSERT ON [dbo].[PlasticWebDeal] TO [MssExec]
GRANT DELETE ON [dbo].[PlasticWebDeal] TO [MssExec]
GRANT UPDATE ON [dbo].[PlasticWebDeal] TO [MssExec]
GO