/*
   پنجشنبه, 14 اردیبهشت 140205:13:47 ب.ظ
   User: 
   Server: TAHERIAN
   Database: ATNDB
   Application: 
*/


Use ATNDBTest
Go
/*=============================================================================================================*/

BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
----------------------------------------------------------------------
ALTER TABLE dbo.OfficeDetail ADD
	TaxMemoryID char(6) NULL,
	TaxFolderUrl varchar(MAX) NULL,
	TaxPrivateKey varchar(MAX) NULL
GO
ALTER TABLE dbo.OfficeDetail SET (LOCK_ESCALATION = TABLE)
GO
----------------------------------------------------------------------
ALTER TABLE dbo.Part ADD PartID Varchar(50) Null
Go
----------------------------------------------------------------------
If Exists(Select * From INFORMATION_SCHEMA.TABLES Where TABLE_NAME = 'FactorTaxStatus' AND TABLE_SCHEMA = 'dbo') Drop Table dbo.FactorTaxStatus
Create Table dbo.FactorTaxStatus(
	Serial Smallint Not Null,
	FA_Description Varchar(50) Null,
	EN_Description Varchar(50) Null,
	Stream char(1) Null,
	Priority smallint Null)
GO
INSERT [dbo].[FactorTaxStatus] ([Serial], [FA_Description], [EN_Description], [Stream], [Priority]) VALUES (0, N'وضعیت نامشخص', N'Unknown status', Null, Null)
INSERT [dbo].[FactorTaxStatus] ([Serial], [FA_Description], [EN_Description], [Stream], [Priority]) VALUES (1, N'ارسال اولیه به سازمان', N'First send to the tax', Null, Null)
INSERT [dbo].[FactorTaxStatus] ([Serial], [FA_Description], [EN_Description], [Stream], [Priority]) VALUES (2, N'ارسال مجدد به سازمان', N'Send back to the tax', Null, Null)
INSERT [dbo].[FactorTaxStatus] ([Serial], [FA_Description], [EN_Description], [Stream], [Priority]) VALUES (3, N'خطا در اطلاعات ارسالی', N'Error in sent data', Null, Null)
INSERT [dbo].[FactorTaxStatus] ([Serial], [FA_Description], [EN_Description], [Stream], [Priority]) VALUES (4, N'هشدار در اطلاعات ارسالی', N'Warning on sent data', Null, Null)
INSERT [dbo].[FactorTaxStatus] ([Serial], [FA_Description], [EN_Description], [Stream], [Priority]) VALUES (5, N'درخواست ابطال صورت حساب', N'Request for deletion', Null, Null)
INSERT [dbo].[FactorTaxStatus] ([Serial], [FA_Description], [EN_Description], [Stream], [Priority]) VALUES (6, N'ارسال موفقیت آمیز', N'Succeeded submission', Null, Null)
INSERT [dbo].[FactorTaxStatus] ([Serial], [FA_Description], [EN_Description], [Stream], [Priority]) VALUES (7, N'ابطال موفقیت آمیز', N'Succeeded deletion', Null, Null)
INSERT [dbo].[FactorTaxStatus] ([Serial], [FA_Description], [EN_Description], [Stream], [Priority]) VALUES (8, N'خطا در ابطال', N'Error in deletion', Null, Null)
INSERT [dbo].[FactorTaxStatus] ([Serial], [FA_Description], [EN_Description], [Stream], [Priority]) VALUES (9, N'هشدار در ابطال', N'Warning on deletion', Null, Null)
Go
----------------------------------------------------------------------
If Exists(Select * From INFORMATION_SCHEMA.TABLES Where TABLE_NAME = 'FactorTaxpayer' AND TABLE_SCHEMA = 'dbo') Drop Table dbo.FactorTaxpayer
Create Table dbo.FactorTaxpayer(
	Serial Bigint Identity(1,1) Not Null, --
	FactorHeaderRef Bigint Not Null, -------
	FactorTaxStatusRef Smallint Null, ------
	TaxUniqueId Char(22) Null, -------------
	TaxFactorKindRef Smallint Null, --------
	TaxReferenceId UNIQUEIDENTIFIER Null, --
	TaxSenderRef Int Null, -----------------
	TaxSendDate char(10) Null, -------------
	TaxSendError Varchar(Max) Null, --------
	TaxSendWarning Varchar(Max) Null, ------
	TaxSendDateRowVersion DateTime Null, ---
	LastState Int Null, --------------------
	Tag Varchar(50) Null)
Go
----------------------------------------------------------------------
If Exists(Select * From INFORMATION_SCHEMA.TABLES Where TABLE_NAME = 'License' AND TABLE_SCHEMA = 'dbo') Drop Table dbo.License
Create Table dbo.License(
	Serial Bigint Identity(1,1) Not Null,
	LockSerial Bigint Null,
	Name Varchar(max) Null,
	ActivationDate Char(10) Null,
	ValidityDuration Int Null,
	ExpirationDate Char(10) Null,
	ExpirationDate_Miladi DateTime Null)
GO
----------------------------------------------------------------------
COMMIT