/****** Object:  View [dbo].[ViewChequeInReport]    Script Date: 13/11/2024 11:22:46 ق.ظ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



ALTER VIEW [dbo].[ViewChequeInReport]
AS
SELECT   dbo.AccChequeIn.ID, dbo.AccChequeIn.DebitTotalID, dbo.AccChequeIn.DebitControlID, dbo.AccChequeIn.DebitDetailID1, dbo.AccChequeIn.DebitDetailID2, AccDocHeader.Number AS DocNumber, dbo.AccChequeIn.DocItemRelationID, 
                dbo.AccChequeIn.BankName, dbo.AccChequeIn.BankBranch, dbo.AccChequeIn.ChequeNo, dbo.AccChequeIn.ChequeDate, dbo.AccChequeIn.ChequeValue, dbo.AccChequeIn.Description, dbo.AccChequeIn.Status, dbo.AccChequeIn.CashDate, 
                CashHeader.Number AS CashDocNumber, CashHeader.Flags AS CashFlag, CashHeader.IsPermanent AS CashIsPermanent, dbo.AccChequeIn.CashItemRelationID, dbo.AccChequeIn.UpdateDate, dbo.AccChequeIn.Updater, 
                dbo.FARSI_DATE2(dbo.AccChequeIn.ChequeDate) AS ChequeDatePer, CAST(0 AS bit) AS Selected, AccDocHeader.Flags AS DocFlags, AccDocHeader.IsPermanent, dbo.AccChequeIn.CashDocItemID, dbo.AccChequeIn.DocItemID, 
                DocItem.Description AS ItemDescription, CashItem.Description AS CashItemDescription, dbo.AccChequeInOwner.TotalID AS OwnerTotalID, dbo.AccChequeInOwner.ControlID AS OwnerControlID, 
                dbo.AccChequeInOwner.DetailID1 AS OwnerDetailID1, dbo.AccChequeInOwner.DetailID2 AS OwnerDetailID2, dbo.AccChequeInCredit.TotalID AS PersonTotalID, dbo.AccChequeInCredit.ControlID AS PersonControlID, 
                dbo.AccChequeInCredit.DetailID1 AS PersonDetailID1, dbo.AccChequeInCredit.DetailID2 AS PersonDetailID2, ReturnItem.Description AS ReturnDescription, ReturnHeader.Number AS ReturnNumber, ReturnHeader.Flags AS ReturnFlags, 
                ReturnHeader.IsPermanent AS ReturnIsPermanent, dbo.AccChequeIn.ReturnDocItemID, DocItem.HeaderID as DocHeaderID, ReturnItem.headerID as ReturnDocHeaderID, CashItem.HeaderID as CashDocHeaderID
FROM      dbo.AccDocHeader AS ReturnHeader RIGHT OUTER JOIN
                dbo.AccDocHeader AS CashHeader WITH (NOLOCK) RIGHT OUTER JOIN
                dbo.AccDocItem AS CashItem ON CashHeader.ID = CashItem.HeaderID RIGHT OUTER JOIN
                dbo.AccChequeInCredit RIGHT OUTER JOIN
                dbo.AccDocHeader AS AccDocHeader RIGHT OUTER JOIN
                dbo.AccDocItem AS ReturnItem RIGHT OUTER JOIN
                dbo.AccChequeIn ON ReturnItem.ID = dbo.AccChequeIn.ReturnDocItemID LEFT OUTER JOIN
                dbo.AccDocItem AS DocItem ON dbo.AccChequeIn.DocItemID = DocItem.ID ON AccDocHeader.ID = DocItem.HeaderID ON dbo.AccChequeInCredit.ChequeInID = dbo.AccChequeIn.ID LEFT OUTER JOIN
                dbo.AccChequeInOwner ON dbo.AccChequeIn.ID = dbo.AccChequeInOwner.ChequeInID ON CashItem.ID = dbo.AccChequeIn.CashDocItemID ON ReturnHeader.ID = ReturnItem.HeaderID
GO


