crystal公式解释

crystal formula explanation

谁能解释一下这个公式?

shared numbervar amount121 ;

if  {hdr.postdate} <= DateAdd("d", - (181+{@PatermDays}), {@postto})
and ({dtl.cleardate} = cdate('01/01/1900') or {dtl.cleardate} > {@postto})then 
(    if not isnull({#RInvAmount}) and not isnull({#RPaymentAmount}) and {#RInvAmount} >0 then
       ( amount121 := amount121 + ({#RInvAmount}-{#RPaymentAmount});
        {#RInvAmount}-{#RPaymentAmount};)
    else if not isnull({#RInvAmount})and {#RInvAmount} >0 then
        (amount121 := amount121 + {#RInvAmount};
        {#RInvAmount};)
    else 
    0

)

patterm days, post to , #Rinvamount, #RPaymentAmount 是在公式

中链接的另一个公式

好的会尽量解释:查看//

后的文字
shared numbervar amount121 ; //Varible decleration with shared scope

if  {hdr.postdate} <= DateAdd("d", - (181+{@PatermDays}), {@postto})     //"d" deleting those many number of days and coverting resultant to datetime

and ({dtl.cleardate} = cdate('01/01/1900') or {dtl.cleardate} > {@postto})then     //Cdate converting string to date used for comparing the date field

(    if not isnull({#RInvAmount}) and not isnull({#RPaymentAmount}) and {#RInvAmount} >0 then     //Comparing the running totals that are not null

       ( amount121 := amount121 + ({#RInvAmount}-{#RPaymentAmount});     //subtracting and storing values in variable

        {#RInvAmount}-{#RPaymentAmount};)     //Not sure what is this doing here

    else if not isnull({#RInvAmount})and {#RInvAmount} >0 then     //If fails then using other running totals in else if

        (amount121 := amount121 + {#RInvAmount};     //Again storing values in else if

        {#RInvAmount};)     //Not sure what is this doing here

    else      //if and else if fails then control comes to this part
    0 

)