View: dbo.Transfer_Bank_Transaction_View | |||
View definition | |||
create view dbo.Transfer_Bank_Transaction_View as select tbt.client__bank_transaction_KEY , tbt.impound__bank_transaction_KEY , bank_transaction_transfer_type_KEY = case when exists(select funding_withdrawal_liability_detail_KEY from dbo.Funding_Withdrawal_Liability_Detail where funding_withdrawal__bank_transaction_KEY = tbt.client__bank_transaction_KEY) or exists(select funding_withdrawal_bank_transaction_detail_KEY from dbo.Funding_Withdrawal_Bank_Transaction_Detail where funding_withdrawal__bank_transaction_KEY = tbt.client__bank_transaction_KEY) then 2 -- Funding Transfer else 3 -- Manual Funding Transfer end -- For funding type transfers, this column indicates if the deposit's bank account is the accountant's impound -- account (which would then mean the withdrawal is from a client bank account) or is a client account (which means -- the withdrawal is from the accountant's impound account). , deposit__account_source_selection_KEY = case when impound_bt.bank_transaction_type_KEY = 2 then 2 else 1 end from dbo.Transfer_Bank_Transaction as tbt inner join dbo.Bank_Transaction as client_bt on tbt.client__bank_transaction_KEY = client_bt.bank_transaction_KEY inner join dbo.Bank_Transaction as impound_bt on tbt.impound__bank_transaction_KEY = impound_bt.bank_transaction_KEY | |||