UFN_BANKACCOUNT_GETENDINGBALANCE
This function returns the balance of a bank account.
Return
Return Type |
---|
decimal(19, 4) |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@BANKACCOUNTID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_BANKACCOUNT_GETENDINGBALANCE
(
@BANKACCOUNTID uniqueidentifier
)
returns decimal(19, 4)
with execute as caller
as begin
declare @BALANCE decimal(19, 4);
select
@BALANCE = coalesce(SUM(case when STATUSCODE = 4 then 0 else case when GENERALLEDGERTRANSACTION = 2 then -TRANSACTIONAMOUNT else TRANSACTIONAMOUNT end end ), 0)
from
dbo.BANKACCOUNTTRANSACTION
where
BANKACCOUNTTRANSACTION.BANKACCOUNTID = @BANKACCOUNTID
and BANKACCOUNTTRANSACTION.DELETED = 0
and BANKACCOUNTTRANSACTION.PROCESSING = 0
return @BALANCE
end