anchor.diff:    acc : Account( $accountNo : accountNo )
     CashFlow( type == CREDIT,
               accountNo == $accountNo,
  -            date &gt;= ap.start &amp;&amp; &lt;= ap.end,
  +            date >= ap.start && <= ap.end,
               $amount : amount )
   then
     acc.balance  += $amount;
  
positive.code:               AccountPeriod ap      
  where acc.accountNo == cf.accountNo and 
        cf.type == CREDIT and
        cf.date &gt;= ap.start and 
        cf.date &lt;= ap.end
  ----
  |[source,sql]
  ----
  
negative.code:               AccountPeriod ap 
  where acc.accountNo == cf.accountNo and 
        cf.type == DEBIT and
        cf.date >= ap.start and 
        cf.date <= ap.end
  ----
  |[source]
  ----
  