BigDecimal baseAmt = Env.ZERO;
String sql = "SELECT il.LineNetAmt, COALESCE(il.TaxAmt,0), i.IsSOTrx "
+ "FROM C_InvoiceLine il"
+ " INNER JOIN C_Invoice i ON (il.C_Invoice_ID=i.C_Invoice_ID) "
+ "WHERE il.C_Invoice_ID=? AND il.C_Tax_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_Invoice_ID());
pstmt.setInt (2, getC_Tax_ID());
rs = pstmt.executeQuery ();
/*MInvoiceLine[] lines1 = getLines(false);
for (int a = 0; a < lines1.length; a++)
{MInvoiceLine sLine = lines1[a];*/
while (rs.next ())
{
MInvoiceLine[] lines1 = getLines(false);
for (int a = 0; a < lines1.length; a++)
{
MInvoiceLine sLine = lines1[a];
// BaseAmt
baseAmt = rs.getBigDecimal(1);
for (int j = 0; j < cTaxes.length; j++)
{
/*if (!iTax.calculateTaxFromLines1())
return false;*/
MTax cTax = cTaxes[j];
BigDecimal taxAmt = cTax.calculateTax1(baseAmt, isTaxIncluded(), getPrecision());
MInvoiceTaxLine newITax = new MInvoiceTaxLine(getCtx(), 0, get_TrxName());
MProduct product = MProduct.get (getCtx(), sLine.getM_Product_ID());
newITax.setClientOrg(this);
newITax.setC_Invoice_ID(getC_Invoice_ID());
newITax.setC_Tax_ID(cTax.getC_Tax_ID());
//newITax.setPrecision(getPrecision());
//newITax.setIsTaxIncluded(isTaxIncluded());
newITax.setBaseAmount(sLine.getPriceEntered());
newITax.setM_Product_ID(product.getName());
newITax.setBaseAmount(baseAmt);
newITax.setCaculatedTaxAmt(taxAmt);
newITax.saveEx(get_TrxName());
//
if (!isTaxIncluded())
grandTotal = grandTotal.add(taxAmt);
}
}
}
}
catch (SQLException e)
{
throw new DBException(e, sql);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
}
在上面的代码执行是1)查询进入while循环,第二个循环但我想首先它应该line1和第二次它应该去,然后在它内部shloud取第二个值的行。
请帮帮我