UFN_OPPORTUNITY_TRANSACTIONAMOUNT
Calculates the total amount of an ask in the transaction currency.
Return
Return Type |
---|
money |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_OPPORTUNITY_TRANSACTIONAMOUNT(@ID uniqueidentifier)
returns money
with execute as caller
as begin
return
-- Outer coalesce in case of bad @ID
coalesce(
(
select
case when STATUSCODE = 3 then -- Accepted
coalesce(TRANSACTIONACCEPTEDASKAMOUNT,
(
select
sum(TRANSACTIONAMOUNT)
from
dbo.OPPORTUNITYDESIGNATION
where
OPPORTUNITYID=@ID
),
0
)
else
case when TRANSACTIONASKAMOUNT > 0 then TRANSACTIONASKAMOUNT
else TRANSACTIONEXPECTEDASKAMOUNT
end
end
from
dbo.OPPORTUNITY
where
ID = @ID
),
0
)
end