﻿if not Exists(SELECT * FROM information_schema.tables where Table_name = 'ConvertGood')
begin
	create table ConvertGood
	(
		ID	int Primary key,
		FC_ID	int references finance_cycle(ID) not null,
		Pro_ID_VahedMali	int references OtherProperties(ID) not null,
		Mat_ID	bigint references Matter(ID) not null,
		Code	int not null,
		Tarikh	int not null,
		Saat	int not null,
		Dom_ID_Vaziat	int references domain(ID) not null,
		Description	nvarchar(1000),
		Kar_ID_Creator	int references Karbar(ID) not null,
		TarikhSabt	int not null,
		SaatSabt	smallint not null
	)
end 
;
if not Exists(SELECT * FROM information_schema.tables where Table_name = 'ConvertGoodDetail')
begin
	create table ConvertGoodDetail
	(
		ID	int primary key identity(1,1),
		CG_ID	int references ConvertGood(ID) not null,
		Dom_ID_Noe	int references Domain(ID) not null,
		Pro_ID_Anbar	int references OtherProperties(ID) not null,
		Kal_ID	int references Kala(ID) not null,
		Pro_ID_Unit	int references OtherProperties(ID) not null,
		Dom_ID_Restoration	int references domain(ID) not null,
		Tedad	decimal(19,4) not null,
		Price	decimal(19,4) not null,
		Description	nvarchar(1000)
	)
end