﻿if not Exists(SELECT * FROM information_schema.tables where Table_name = 'OnlineInvoice')
begin
	create table dbo.OnlineInvoice
	(
		ID	int primary key identity(1,1),
		Bar_ID	int references dbo.Bargeh(ID) null,	 -- آیدی  پیش فاکتور
		Pro_ID_Gateway	int references dbo.OtherProperties(ID) not null default -1, -- آیدی درگاه آنلاین
		AllowedGateways	nvarchar(200), --  درگاه آنلاین های مجاز
		Mat_ID	bigint references dbo.Matter(ID) not null, -- رهگیری
		ValidityDate	int not null, -- تاریخ اعتبار
		PaymentDate	datetime null, -- تاریخ پرداخت
		Dom_ID_RowType	int references dbo.Domain(ID) not null, -- نوع ردیف: پیش فاکتور | نوع داده جی سون
		Dom_ID_Status	int references dbo.Domain(ID) not null, -- پرداخت نشده، پرداخت شده، ابطال
		Dom_ID_Action	int references dbo.Domain(ID) not null, -- اسکریپت اجرایی پس از پرداخت
		JsonItems	nvarchar(max) null, -- اقلام فاکتور
		Serial	nvarchar(200) null
	)
end