/****** Object:  View [dbo].[viwPayaInOutList]    Script Date: 24/08/2021 06:52:59 ق.ظ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

--select * from [viwPayaInOutList]
--select * from [viwCashInOutList]
CREATE VIEW [dbo].[viwPayaInOutList]
AS
SELECT    Item.ID, CAST(SUBSTRING(dbo.GetFormdataItem(Item.FormData, 1), 5, 1) AS int) AS Type, dbo.GetFormdataItem(Item.FormData, 2) AS acDebit, dbo.GetFormdataItem(Item.FormData, 3) AS acCredit, CONVERT(Datetime,dbo.GetFormdataItem(Item.FormData, 4),104) AS FormDate, 
                         CAST(dbo.GetFormdataItem(Item.FormData, 5) AS decimal) AS Value, dbo.GetFormdataItem(Item.FormData, 6) AS Description, CAST(dbo.GetFormdataItem(Item.FormData, 7) AS bigint) AS CostCenter, CAST(dbo.GetFormdataItem(Item.FormData, 8) 
                         AS bigint) AS Project, CAST(dbo.GetFormdataItem(Item.FormData, 9) AS integer) AS ForType, CAST(dbo.GetFormdataItem(Item.FormData, 10) AS bigint) AS ForID,
						 cast(0 as bit) as Selected, Header.Number as DocNumber, Item.Description as DocDescription, item.UpdateDate, item.Updater, [dbo].[FARSI_DATE2](CONVERT(Datetime,dbo.GetFormdataItem(Item.FormData, 4),104)) as FormDatePer,
				CAST(dbo.GetFormdataItem(Item.FormData, 11) AS integer) AS CashNumber, dbo.GetFormdataItem(Item.FormData, 12) AS AccFrom, dbo.GetFormdataItem(Item.FormData, 13) AS AccTo
FROM            dbo.AccDocItem as Item left outer join AccDocHeader as Header on Item.HeaderID=Header.id
WHERE        (LEFT(Item.FormData, 4) = 'Paya')
GO


