UFN_CREDIT_REFUND_GETMEMBERSHIPTOTAL

Returns the total for memberships in this credit.

Return

Return Type
money

Parameters

Parameter Parameter Type Mode Description
@CREDITID uniqueidentifier IN

Definition

Copy



CREATE function dbo.UFN_CREDIT_REFUND_GETMEMBERSHIPTOTAL
(
    @CREDITID uniqueidentifier
)
returns money
as begin
    declare @MEMBERSHIPTOTAL money;

    select @MEMBERSHIPTOTAL = coalesce(sum((LI.QUANTITY * LI.UNITVALUE) - EXT.DISCOUNTS), 0)
    from dbo.FINANCIALTRANSACTIONLINEITEM as LI
    inner join dbo.CREDITITEM_EXT as EXT on EXT.ID = LI.ID
    where 
        LI.FINANCIALTRANSACTIONID = @CREDITID and
        EXT.TYPECODE = 1  -- Membership


    return @MEMBERSHIPTOTAL;
end