﻿CREATE TABLE [dbo].[ClientBilling] (
    [Id]                        UNIQUEIDENTIFIER CONSTRAINT [DF_ClientBilling_Id] DEFAULT (newid()) NOT NULL,
    [ClientId]                  UNIQUEIDENTIFIER CONSTRAINT [DF_ClientBilling_ClientId] DEFAULT (newid()) NOT NULL,
    [TransactionCode]           NVARCHAR (50)    NULL,
    [BillingPeriodStart]        DATETIME         NULL,
    [BillingPeriodEnd]          DATETIME         NULL,
    [BillingDate]               DATETIME         NULL,
    [BillingAmountSubscription] NUMERIC (12, 4)  NULL,
    [BillingAmountSetup]        NUMERIC (12, 4)  NULL,
    [BillingAmountSow]          NUMERIC (12, 4)  NULL,
    [BillingDiscountApplied]    NUMERIC (12, 4)  NULL,
    CONSTRAINT [PK_ClientBilling] PRIMARY KEY CLUSTERED ([Id] ASC)
);




GO



GO



GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Alpha-numeric value specifying the unique transaction code for the Billing row.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'ClientBilling', @level2type = N'COLUMN', @level2name = N'TransactionCode';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Start date of the Billing period.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'ClientBilling', @level2type = N'COLUMN', @level2name = N'BillingPeriodStart';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'End date of the Billing period.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'ClientBilling', @level2type = N'COLUMN', @level2name = N'BillingPeriodEnd';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Actual date the Billing was produced.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'ClientBilling', @level2type = N'COLUMN', @level2name = N'BillingDate';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Subscription amount being billed.  Calculated from (ClientInformation.MaxUsers * SubscriptionGroup.PerSeatCost * ClientInformation.BillingFrequency).  ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'ClientBilling', @level2type = N'COLUMN', @level2name = N'BillingAmountSubscription';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'One-time Setup Fee being billed.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'ClientBilling', @level2type = N'COLUMN', @level2name = N'BillingAmountSetup';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Any Statement of Work (SoW) amount being billed.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'ClientBilling', @level2type = N'COLUMN', @level2name = N'BillingAmountSow';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Any subscription group discount applied for subscription seat billing.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'ClientBilling', @level2type = N'COLUMN', @level2name = N'BillingDiscountApplied';

