﻿if not Exists(SELECT * FROM information_schema.tables where Table_name = 'Guarantee')
begin
	create table dbo.Guarantee
	(
		ID	int primary key,
		FC_ID	int references dbo.Finance_Cycle(ID) not null,
		Pro_ID_VahedMali	int references dbo.OtherProperties(ID) not null,
		Mat_ID	bigint references dbo.matter(ID) not null,
		Code	int not null,
		Tarikh	int not null,
		Dom_ID_RowType	int references dbo.Domain(ID) not null,
		Dom_ID_Status	int references dbo.Domain(ID) not null,
		Dom_ID_Marja	int references dbo.Domain(ID) not null, -- پیش پرداخت قرارداد | حسن انجام کار
		Dom_ID_Type	int references dbo.Domain(ID) not null,	-- چک | سفته | ضمانتنامه بانکی | سند ملکی
		Con_ID	int references dbo.Contract(ID) null,
		Taf_ID	bigint references dbo.Tafsili(ID) null,
		
		DocumentNumber	nvarchar(200) null, -- شماره سند
		Pro_ID_Bank	int references dbo.OtherProperties(ID) null, -- بانک
		BranchTitle	nvarchar(200) null, -- نام شعبه
		
		DeliveryDate	int null, -- تاریخ تحویل
		DueDate	int null, -- تاریخ سرسید
		Price	decimal(19,4) not null,
		Description	nvarchar(1000) null
	)
end