UFN_CHARGE_GETCREDITID

Returns the billing cycle by date

Return

Return Type
uniqueidentifier

Parameters

Parameter Parameter Type Mode Description
@CHARGEID uniqueidentifier IN

Definition

Copy


CREATE function dbo.UFN_CHARGE_GETCREDITID
(
    @CHARGEID uniqueidentifier
)
returns uniqueidentifier
with execute as caller
as begin
    declare @CREDITID uniqueidentifier

    if not @CHARGEID is null
    begin
        select
                    @CREDITID=FTLI_CR.FINANCIALTRANSACTIONID
                from
                    dbo.CHARGERECEIVABLECREDITLINEITEMS CHCRLI
          inner join dbo.FINANCIALTRANSACTIONLINEITEM FTLI_CH on CHCRLI.CHARGELINEITEMID=FTLI_CH.ID          
          inner join dbo.FINANCIALTRANSACTIONLINEITEM FTLI_CR on CHCRLI.RECEIVABLECREDITLINEITEMID=FTLI_CR.ID          
                where
                    FTLI_CH.FINANCIALTRANSACTIONID=@CHARGEID AND FTLI_CH.TYPECODE=0 AND FTLI_CH.DELETEDON is null AND FTLI_CR.TYPECODE=0 AND FTLI_CR.DELETEDON is null;
    end

    return @CREDITID
end