UFN_BANKACCOUNTDEPOSIT_UNLINKEDPAYMENTS

This function returns a table of unlinked payments.

Return

Return Type
table

Definition

Copy


            CREATE function dbo.UFN_BANKACCOUNTDEPOSIT_UNLINKEDPAYMENTS() 
            returns table
            as return
                select 
                    FT.ID,
                    FT.DATE as TRANSACTIONDATE,
                    RP.PAYMENTMETHOD,
                    FT.BASEAMOUNT as AMOUNT,
                      case FT.TYPECODE 
                            when 0 then N'Payment' 
                            when 1 then N'Pledge' 
                            when 2 then N'Recurring gift' 
                            when 3 then N'Matching gift claim' 
                            when 4 then N'Planned gift' 
                            when 5 then N'Order' 
                            when 6 then N'Grant award' 
                            when 7 then N'Auction donation' 
                            when 8 then N'Donor challenge claim' 
                            when 9 then N'Pending gift'
                            end as TRANSACTIONTYPE
                from 
                    dbo.FINANCIALTRANSACTION FT
                    inner join dbo.FINANCIALTRANSACTIONLINEITEM FTLI on FT.ID = FTLI.FINANCIALTRANSACTIONID 
                    inner join dbo.REVENUESPLIT_EXT RSE on FTLI.ID = RSE.ID and RSE.APPLICATIONCODE=11 and RSE.TYPECODE=8
                    inner join dbo.REVENUEPAYMENTMETHOD RP on FT.ID = RP.REVENUEID
                    left join dbo.BANKACCOUNTDEPOSITPAYMENT BP on FT.ID = BP.ID
                    left join dbo.BANKACCOUNTTRANSACTION BT on BP.DEPOSITID = BT.ID
                where
                    FT.TYPECODE = 0
          and FT.DELETEDON is null
          and FTLI.DELETEDON is null
          and FTLI.TYPECODE != 1
          and BP.DEPOSITID is null