﻿CREATE TABLE [dbo].[fds__reminder] (
    [Id]            VARCHAR (10)    NOT NULL,
    [Version]       INT             CONSTRAINT [DF_fds__reminder_Version] DEFAULT ((0)) NOT NULL,
    [DocumentName]  VARCHAR (100)   NULL,
    [InvId]         VARCHAR (15)    NOT NULL,
    [CustomerId]    BIGINT          NULL,
    [SendToAddress] NVARCHAR (1000) NULL,
    [SendToEmail]   NVARCHAR (255)  NULL,
    [type]          VARCHAR (3)     NOT NULL,
    [amount]        NUMERIC (10, 3) NULL,
    [amount_payed]  NUMERIC (10, 3) NULL,
    [amount_open]   AS              (CONVERT([numeric](10,3),isnull([amount],(0))-isnull([amount_payed],(0)))),
    [subject]       NVARCHAR (255)  NULL,
    [text]          NVARCHAR (2000) NULL,
    [IsSent]        BIT             CONSTRAINT [DF_fds__reminder_IsSent] DEFAULT ((0)) NOT NULL,
    [IsFinal]       AS              (CONVERT([bit],case when [DateFinalized] IS NULL then (0) else (1) end)),
    [CustomValues]  NVARCHAR (MAX)  NULL,
    [DateSent]      DATETIME        NULL,
    [UserSent]      VARCHAR (25)    NULL,
    [DateFinalized] DATETIME        NULL,
    [UserFinalized] VARCHAR (25)    NULL,
    [DateCreated]   DATETIME        NOT NULL,
    [UserCreated]   VARCHAR (25)    NOT NULL,
    [DateModified]  DATETIME        NOT NULL,
    [UserModified]  VARCHAR (25)    NOT NULL,
    [file]          VARBINARY (MAX) NULL,
    CONSTRAINT [PK_fds__reminder] PRIMARY KEY CLUSTERED ([Id] ASC)
);

