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