Buggy code:
public class MLVECashTax extends X_LVE_CashTax { private static final long serialVersionUID = 1L ; public static MLVECashTax [ ] m_taxes ; public static MLVECashTax get ( MCashLine line , int precision , boolean oldTax , String trx ) { } private static CLogger s_log = CLogger . getCLogger ( MLVECashTax . class ) ; public MLVECashTax ( Properties ctx , int ignored , String trx ) { } public MLVECashTax ( Properties ctx , ResultSet rs , String trx ) { } private MTax m_tax = null ; public static Integer m_precision = null ; public static int getPrecision ( ) { } public void setPrecision ( int precision ) { } public MTax getTax ( ) { } public boolean calculateTaxFromLines ( ) { BigDecimal taxBaseAmt = Env . ZERO ; BigDecimal taxAmt = Env . ZERO ; boolean documentLevel = getTax ( ) . isDocumentLevel ( ) ; MTax tax = getTax ( ) ; <START_BUG> String sql = "SELECT<seq2seq4repair_space>COALESCE(cl.A_Base_Amount,cl.Amount),<seq2seq4repair_space>cl.Amount-COALESCE(cl.A_Base_Amount,0),cl.AffectsBook<seq2seq4repair_space>" + ( ( "<seq2seq4repair_space>FROM<seq2seq4repair_space>C_CashLine<seq2seq4repair_space>cl<seq2seq4repair_space>" + "<seq2seq4repair_space>INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>C_Cash<seq2seq4repair_space>c<seq2seq4repair_space>ON<seq2seq4repair_space>(cl.C_Cash_ID=c.C_Cash_ID)<seq2seq4repair_space>" ) + "<seq2seq4repair_space>WHERE<seq2seq4repair_space>cl.C_Cash_ID=?<seq2seq4repair_space>AND<seq2seq4repair_space>cl.C_Tax_ID=?<seq2seq4repair_space>And<seq2seq4repair_space>cl.AffectsBook='Y'" ) ; <END_BUG> PreparedStatement pstmt = null ; try { pstmt = DB . prepareStatement ( sql , get_TrxName ( ) ) ; pstmt . setInt ( 1 , getC_Cash_ID ( ) ) ; pstmt . setInt ( 2 , getC_Tax_ID ( ) ) ; ResultSet rs = pstmt . executeQuery ( ) ; while ( rs . next ( ) ) { BigDecimal baseAmt = rs . getBigDecimal ( 1 ) ; taxBaseAmt = taxBaseAmt . add ( baseAmt ) ; BigDecimal amt = rs . getBigDecimal ( 2 ) ; if ( amt == null ) amt = Env . ZERO ; if ( documentLevel || ( ( baseAmt . signum ( ) ) == 0 ) ) amt = Env . ZERO ; else amt = tax . calculateTax ( baseAmt , MLVECashTax . isTaxIncluded ( ) , MLVECashTax . getPrecision ( ) ) ; taxAmt = taxAmt . add ( amt ) ; } rs . close ( ) ; pstmt . close ( ) ; pstmt = null ; } catch ( Exception e ) { log . log ( Level . SEVERE , "setTaxBaseAmt" , e ) ; taxBaseAmt = null ; } try { if ( pstmt != null ) pstmt . close ( ) ; pstmt = null ; } catch ( Exception e ) { pstmt = null ; } if ( taxBaseAmt == null ) return false ; if ( documentLevel || ( ( taxAmt . signum ( ) ) == 0 ) ) taxAmt = tax . calculateTax ( taxBaseAmt , MLVECashTax . isTaxIncluded ( ) , MLVECashTax . getPrecision ( ) ) ; setTaxAmt ( taxAmt ) ; if ( MLVECashTax . isTaxIncluded ( ) ) setTaxBaseAmt ( taxBaseAmt . subtract ( taxAmt ) ) ; else setTaxBaseAmt ( taxBaseAmt ) ; return true ; } @ Override public String toString ( ) { } public static boolean isTaxIncluded ( MCashLine line ) { } public static MLVECashTax [ ] getTaxes ( boolean requery , MCash cash ) { } public static boolean calculateTaxTotal ( MCash cash ) { } No newline ; at end ; of file ; }

Fix:
String sql = "SELECT<seq2seq4repair_space>COALESCE(cl.A_Base_Amount,cl.Amount),<seq2seq4repair_space>cl.Amount-COALESCE(cl.A_Base_Amount,0),cl.AffectsBook<seq2seq4repair_space>" + ( ( "<seq2seq4repair_space>FROM<seq2seq4repair_space>C_CashLine<seq2seq4repair_space>cl<seq2seq4repair_space>" + "<seq2seq4repair_space>INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>C_Cash<seq2seq4repair_space>c<seq2seq4repair_space>ON<seq2seq4repair_space>(cl.C_Cash_ID=c.C_Cash_ID)<seq2seq4repair_space>" ) + "<seq2seq4repair_space>WHERE<seq2seq4repair_space>cl.C_Cash_ID=?<seq2seq4repair_space>AND<seq2seq4repair_space>cl.C_Tax_ID=?" ) ;