Done for all Callouts

1. Remove deprecated CalloutActive sets
2. BF [ 1874419 ] JDBC Statement not close in a finally block

Not tested, assume no new impact
This commit is contained in:
Redhuan D. Oon 2008-02-04 00:19:09 +00:00
parent 74a9558394
commit a5d9c4efff
17 changed files with 129 additions and 154 deletions

View File

@ -52,7 +52,6 @@ public class CalloutAssignment extends CalloutEngine
int S_ResourceAssignment_ID = ((Integer)value).intValue();
if (S_ResourceAssignment_ID == 0)
return "";
setCalloutActive(true);
int M_Product_ID = 0;
String Name = null;
@ -62,11 +61,13 @@ public class CalloutAssignment extends CalloutEngine
+ "FROM S_ResourceAssignment ra"
+ " INNER JOIN M_Product p ON (p.S_Resource_ID=ra.S_Resource_ID) "
+ "WHERE ra.S_ResourceAssignment_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, S_ResourceAssignment_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
M_Product_ID = rs.getInt (1);
@ -74,13 +75,16 @@ public class CalloutAssignment extends CalloutEngine
Description = rs.getString(3);
Qty = rs.getBigDecimal(4);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, "product", e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
log.fine("S_ResourceAssignment_ID=" + S_ResourceAssignment_ID + " - M_Product_ID=" + M_Product_ID);
if (M_Product_ID != 0)
@ -99,7 +103,6 @@ public class CalloutAssignment extends CalloutEngine
if (Qty != null)
mTab.setValue(variable, Qty);
}
setCalloutActive(false);
return "";
} // product

View File

@ -66,7 +66,6 @@ public class CalloutBankStatement extends CalloutEngine
{
if (isCalloutActive())
return "";
setCalloutActive(true);
// Get Stmt & Trx
BigDecimal stmt = (BigDecimal)mTab.getValue("StmtAmt");
@ -97,7 +96,6 @@ public class CalloutBankStatement extends CalloutEngine
// log.trace(log.l5_DData, "Charge (" + bd + ") = Stmt(" + stmt + ") - Trx(" + trx + ") - Interest(" + interest + ")");
mTab.setValue("ChargeAmt", bd);
}
setCalloutActive(false);
return "";
} // amount
@ -123,11 +121,13 @@ public class CalloutBankStatement extends CalloutEngine
stmt = Env.ZERO;
String sql = "SELECT PayAmt FROM C_Payment_v WHERE C_Payment_ID=?"; // 1
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_Payment_ID.intValue());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
BigDecimal bd = rs.getBigDecimal(1);
@ -135,14 +135,17 @@ public class CalloutBankStatement extends CalloutEngine
if (stmt.compareTo(Env.ZERO) == 0)
mTab.setValue("StmtAmt", bd);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, "BankStmt_Payment", e);
return e.getLocalizedMessage();
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
// Recalculate Amounts
amount (ctx, WindowNo, mTab, mField, value);
return "";

View File

@ -45,13 +45,11 @@ public class CalloutCashJournal extends CalloutEngine
{
if (isCalloutActive()) // assuming it is resetting value
return "";
setCalloutActive(true);
Integer C_Invoice_ID = (Integer)value;
if (C_Invoice_ID == null || C_Invoice_ID.intValue() == 0)
{
mTab.setValue("C_Currency_ID", null);
setCalloutActive(false);
return "";
}
@ -64,12 +62,14 @@ public class CalloutCashJournal extends CalloutEngine
+ "invoiceOpen(C_Invoice_ID, 0), IsSOTrx, " // 3..4
+ "paymentTermDiscount(invoiceOpen(C_Invoice_ID, 0),C_Currency_ID,C_PaymentTerm_ID,DateInvoiced,?) "
+ "FROM C_Invoice WHERE C_Invoice_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setTimestamp(1, ts);
pstmt.setInt(2, C_Invoice_ID.intValue());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
mTab.setValue("C_Currency_ID", new Integer(rs.getInt(2)));
@ -87,16 +87,17 @@ public class CalloutCashJournal extends CalloutEngine
mTab.setValue("WriteOffAmt", Env.ZERO);
Env.setContext(ctx, WindowNo, "InvTotalAmt", PayAmt.toString());
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, "invoice", e);
setCalloutActive(false);
return e.getLocalizedMessage();
}
setCalloutActive(false);
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
return "";
} // CashJournal_Invoice
@ -122,7 +123,6 @@ public class CalloutCashJournal extends CalloutEngine
if (total == null || total.length() == 0)
return "";
BigDecimal InvTotalAmt = new BigDecimal(total);
setCalloutActive(true);
BigDecimal PayAmt = (BigDecimal)mTab.getValue("Amount");
BigDecimal DiscountAmt = (BigDecimal)mTab.getValue("DiscountAmt");
@ -143,7 +143,6 @@ public class CalloutCashJournal extends CalloutEngine
mTab.setValue("Amount", PayAmt);
}
setCalloutActive(false);
return "";
} // amounts

View File

@ -101,7 +101,6 @@ public class CalloutEngine implements Callout
}
catch (Exception e)
{
setCalloutActive(false);
Throwable ex = e.getCause(); // InvocationTargetException
if (ex == null)
ex = e;
@ -151,7 +150,6 @@ public class CalloutEngine implements Callout
}
catch (Exception e)
{
setCalloutActive(false);
log.log(Level.SEVERE, "convert: " + methodName, e);
e.printStackTrace(System.err);
}
@ -218,11 +216,9 @@ public class CalloutEngine implements Callout
{
if (isCalloutActive()) // assuming it is resetting value
return "";
// setCalloutActive(true);
if (value == null || !(value instanceof Timestamp))
return "";
mTab.setValue("DateAcct", value);
// setCalloutActive(false);
return "";
} // dateAcct
@ -240,7 +236,6 @@ public class CalloutEngine implements Callout
{
if (isCalloutActive() || value == null) // assuming it is Conversion_Rate
return "";
setCalloutActive(true);
BigDecimal rate1 = (BigDecimal)value;
BigDecimal rate2 = Env.ZERO;
@ -254,7 +249,6 @@ public class CalloutEngine implements Callout
else
mTab.setValue("MultiplyRate", rate2);
log.info(mField.getColumnName() + "=" + rate1 + " => " + rate2);
setCalloutActive(false);
return "";
} // rate

View File

@ -46,7 +46,6 @@ public class CalloutGLJournal extends CalloutEngine
String colName = mField.getColumnName();
if (value == null || isCalloutActive())
return "";
setCalloutActive(true);
int AD_Client_ID = Env.getContextAsInt(ctx, WindowNo, "AD_Client_ID");
Timestamp DateAcct = null;
@ -91,7 +90,6 @@ public class CalloutGLJournal extends CalloutEngine
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
setCalloutActive(false);
return e.getLocalizedMessage();
}
if (C_Period_ID != 0)
@ -103,11 +101,13 @@ public class CalloutGLJournal extends CalloutEngine
{
String sql = "SELECT PeriodType, StartDate, EndDate "
+ "FROM C_Period WHERE C_Period_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_Period_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
String PeriodType = rs.getString(1);
@ -121,17 +121,18 @@ public class CalloutGLJournal extends CalloutEngine
mTab.setValue("DateAcct", EndDate);
}
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
setCalloutActive(false);
return e.getLocalizedMessage();
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
}
setCalloutActive(false);
return "";
} // Journal_Period
@ -191,8 +192,6 @@ public class CalloutGLJournal extends CalloutEngine
if (value == null || isCalloutActive())
return "";
setCalloutActive(true);
// Get Target Currency & Precision from C_AcctSchema.C_Currency_ID
int C_AcctSchema_ID = Env.getContextAsInt(ctx, WindowNo, "C_AcctSchema_ID");
MAcctSchema as = MAcctSchema.get(ctx, C_AcctSchema_ID);
@ -220,7 +219,6 @@ public class CalloutGLJournal extends CalloutEngine
AmtAcctCr = AmtAcctCr.setScale(Precision, BigDecimal.ROUND_HALF_UP);
mTab.setValue("AmtAcctCr", AmtAcctCr);
setCalloutActive(false);
return "";
} // amt

View File

@ -104,12 +104,14 @@ public class CalloutInOut extends CalloutEngine
+ "FROM C_DocType d, AD_Sequence s "
+ "WHERE C_DocType_ID=?" // 1
+ " AND d.DocNoSequence_ID=s.AD_Sequence_ID(+)";
try
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
Env.setContext(ctx, WindowNo, "C_DocTypeTarget_ID", C_DocType_ID.intValue());
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_DocType_ID.intValue());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
// Set Movement Type
@ -154,14 +156,17 @@ public class CalloutInOut extends CalloutEngine
mTab.setValue("DocumentNo", "<" + rs.getString("CurrentNext") + ">");
}
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
return e.getLocalizedMessage();
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
return "";
} // docType
@ -258,7 +263,6 @@ public class CalloutInOut extends CalloutEngine
Integer M_Warehouse_ID = (Integer)value;
if (M_Warehouse_ID == null || M_Warehouse_ID.intValue() == 0)
return "";
setCalloutActive(true);
String sql = "SELECT w.AD_Org_ID, l.M_Locator_ID "
+ "FROM M_Warehouse w"
@ -293,11 +297,9 @@ public class CalloutInOut extends CalloutEngine
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
setCalloutActive(false);
return e.getLocalizedMessage();
}
setCalloutActive(false);
return "";
} // warehouse
@ -316,7 +318,6 @@ public class CalloutInOut extends CalloutEngine
Integer C_OrderLine_ID = (Integer)value;
if (C_OrderLine_ID == null || C_OrderLine_ID.intValue() == 0)
return "";
setCalloutActive(true);
// Get Details
MOrderLine ol = new MOrderLine (ctx, C_OrderLine_ID.intValue(), null);
@ -343,7 +344,6 @@ public class CalloutInOut extends CalloutEngine
mTab.setValue("User1_ID", new Integer(ol.getUser1_ID()));
mTab.setValue("User2_ID", new Integer(ol.getUser2_ID()));
}
setCalloutActive(false);
return "";
} // orderLine
@ -363,7 +363,6 @@ public class CalloutInOut extends CalloutEngine
Integer M_Product_ID = (Integer)value;
if (M_Product_ID == null || M_Product_ID.intValue() == 0)
return "";
setCalloutActive(true);
// Set Attribute & Locator
int M_Locator_ID = 0;
@ -383,7 +382,6 @@ public class CalloutInOut extends CalloutEngine
boolean IsSOTrx = "Y".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"));
if (IsSOTrx)
{
setCalloutActive(false);
return "";
}
@ -404,7 +402,6 @@ public class CalloutInOut extends CalloutEngine
}
else
log.fine("No Locator for M_Product_ID=" + M_Product_ID);
setCalloutActive(false);
return "";
} // product
@ -423,7 +420,6 @@ public class CalloutInOut extends CalloutEngine
{
if (isCalloutActive() || value == null)
return "";
setCalloutActive(true);
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
// log.log(Level.WARNING,"qty - init - M_Product_ID=" + M_Product_ID);
@ -518,7 +514,6 @@ public class CalloutInOut extends CalloutEngine
mTab.setValue("QtyEntered", QtyEntered);
}
//
setCalloutActive(false);
return "";
} // qty
@ -538,7 +533,6 @@ public class CalloutInOut extends CalloutEngine
Integer M_ASI_ID = (Integer)value;
if (M_ASI_ID == null || M_ASI_ID.intValue() == 0)
return "";
setCalloutActive(true);
//
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
int M_Warehouse_ID = Env.getContextAsInt(ctx, WindowNo, "M_Warehouse_ID");
@ -558,7 +552,6 @@ public class CalloutInOut extends CalloutEngine
mTab.setValue("M_Locator_ID", new Integer (selectedM_Locator_ID));
}
}
setCalloutActive(false);
return "";
} // asi

View File

@ -63,7 +63,6 @@ public class CalloutInventory extends CalloutEngine
if (M_Locator_ID == 0)
return "";
setCalloutActive(true);
// Set Attribute
int M_AttributeSetInstance_ID = 0;
Integer ASI = (Integer)mTab.getValue("M_AttributeSetInstance_ID");
@ -89,35 +88,38 @@ public class CalloutInventory extends CalloutEngine
sql = "SELECT SUM(QtyOnHand) FROM M_Storage "
+ "WHERE M_Product_ID=?" // 1
+ " AND M_Locator_ID=?"; // 2
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, M_Product_ID);
pstmt.setInt(2, M_Locator_ID);
if (M_AttributeSetInstance_ID != 0)
pstmt.setInt(3, M_AttributeSetInstance_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
bd = rs.getBigDecimal(1);
if (bd != null)
mTab.setValue("QtyBook", bd);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
setCalloutActive(false);
return e.getLocalizedMessage();
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
//
log.info("M_Product_ID=" + M_Product_ID
+ ", M_Locator_ID=" + M_Locator_ID
+ ", M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID
+ " - QtyBook=" + bd);
setCalloutActive(false);
return "";
} // product

View File

@ -139,11 +139,13 @@ public class CalloutInvoice extends CalloutEngine
+ "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_BPartner_ID.intValue());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
//
if (rs.next())
{
@ -232,15 +234,17 @@ public class CalloutInvoice extends CalloutEngine
else
mTab.setValue("IsDiscountPrinted", "N");
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, "bPartner", e);
return e.getLocalizedMessage();
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
return "";
} // bPartner
@ -291,7 +295,6 @@ public class CalloutInvoice extends CalloutEngine
Integer M_Product_ID = (Integer)value;
if (M_Product_ID == null || M_Product_ID.intValue() == 0)
return "";
setCalloutActive(true);
mTab.setValue("C_Charge_ID", null);
// Set Attribute
@ -331,7 +334,6 @@ public class CalloutInvoice extends CalloutEngine
Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N");
Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N");
//
setCalloutActive(false);
return tax (ctx, WindowNo, mTab, mField, value);
} // product
@ -365,11 +367,13 @@ public class CalloutInvoice extends CalloutEngine
Env.setContext(ctx, WindowNo, "DiscountSchema", "N");
String sql = "SELECT ChargeAmt FROM C_Charge WHERE C_Charge_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_Charge_ID.intValue());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
mTab.setValue ("PriceEntered", rs.getBigDecimal (1));
@ -378,14 +382,17 @@ public class CalloutInvoice extends CalloutEngine
mTab.setValue ("PriceList", Env.ZERO);
mTab.setValue ("Discount", Env.ZERO);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql + e);
return e.getLocalizedMessage();
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
//
return tax (ctx, WindowNo, mTab, mField, value);
} // charge
@ -395,7 +402,7 @@ public class CalloutInvoice extends CalloutEngine
* Invoice Line - Tax.
* - basis: Product, Charge, BPartner Location
* - sets C_Tax_ID
* Calles Amount
* Calls Amount
* @param ctx context
* @param WindowNo window no
* @param mTab tab
@ -474,7 +481,6 @@ public class CalloutInvoice extends CalloutEngine
{
if (isCalloutActive() || value == null)
return "";
setCalloutActive(true);
// log.log(Level.WARNING,"amt - init");
int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, "C_UOM_ID");
@ -645,7 +651,6 @@ public class CalloutInvoice extends CalloutEngine
mTab.setValue("LineTotalAmt", LineNetAmt.add(TaxAmt));
}
setCalloutActive(false);
return "";
} // amt
@ -688,7 +693,6 @@ public class CalloutInvoice extends CalloutEngine
{
if (isCalloutActive() || value == null)
return "";
setCalloutActive(true);
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
// log.log(Level.WARNING,"qty - init - M_Product_ID=" + M_Product_ID);
@ -783,7 +787,6 @@ public class CalloutInvoice extends CalloutEngine
mTab.setValue("QtyEntered", QtyEntered);
}
//
setCalloutActive(false);
return "";
} // qty

View File

@ -238,23 +238,28 @@ public class CalloutInvoiceBatch extends CalloutEngine
return "";
String sql = "SELECT ChargeAmt FROM C_Charge WHERE C_Charge_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_Charge_ID.intValue());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
mTab.setValue ("PriceEntered", rs.getBigDecimal (1));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
return e.getLocalizedMessage();
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
//
return tax (ctx, WindowNo, mTab, mField, value);
} // charge
@ -334,7 +339,6 @@ public class CalloutInvoiceBatch extends CalloutEngine
{
if (isCalloutActive() || value == null)
return "";
setCalloutActive(true);
int StdPrecision = 2; // temporary
@ -384,7 +388,6 @@ public class CalloutInvoiceBatch extends CalloutEngine
mTab.setValue("LineNetAmt", LineNetAmt);
mTab.setValue("LineTotalAmt", LineNetAmt.add(TaxAmt));
}
setCalloutActive(false);
return "";
} // amt

View File

@ -74,12 +74,10 @@ public class CalloutMovement extends CalloutEngine
public String qty(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) {
if (isCalloutActive() || value == null)
return "";
setCalloutActive(true);
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
checkQtyAvailable(ctx, mTab, WindowNo, M_Product_ID, (BigDecimal)value);
//
setCalloutActive(false);
return "";
} // qty

View File

@ -61,14 +61,12 @@ public class CalloutPaySelection extends CalloutEngine
BigDecimal OpenAmt = (BigDecimal)mTab.getValue("OpenAmt");
BigDecimal PayAmt = (BigDecimal)mTab.getValue("PayAmt");
BigDecimal DiscountAmt = (BigDecimal)mTab.getValue("DiscountAmt");
setCalloutActive(true);
BigDecimal DifferenceAmt = OpenAmt.subtract(PayAmt).subtract(DiscountAmt);
log.fine(" - OpenAmt=" + OpenAmt + " - PayAmt=" + PayAmt
+ ", Discount=" + DiscountAmt + ", Difference=" + DifferenceAmt);
mTab.setValue("DifferenceAmt", DifferenceAmt);
setCalloutActive(false);
return "";
} // PaySel_PayAmt
@ -96,7 +94,6 @@ public class CalloutPaySelection extends CalloutEngine
/* ARHIPAC: TEO: BEGIN: END ------------------------------------------------------------------------------------------ */
if (PayDate == null)
PayDate = new Timestamp(System.currentTimeMillis());
setCalloutActive(true);
BigDecimal OpenAmt = Env.ZERO;
BigDecimal DiscountAmt = Env.ZERO;
@ -106,35 +103,37 @@ public class CalloutPaySelection extends CalloutEngine
+ " paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?), i.IsSOTrx "
+ "FROM C_Invoice_v i, C_BankAccount ba "
+ "WHERE i.C_Invoice_ID=? AND ba.C_BankAccount_ID=?"; // #1..2
ResultSet rs = null;
PreparedStatement pstmt = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(2, C_Invoice_ID);
pstmt.setInt(3, C_BankAccount_ID);
pstmt.setTimestamp(1, PayDate);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
OpenAmt = rs.getBigDecimal(1);
DiscountAmt = rs.getBigDecimal(2);
IsSOTrx = new Boolean ("Y".equals(rs.getString(3)));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
log.fine(" - OpenAmt=" + OpenAmt + " (Invoice=" + C_Invoice_ID + ",BankAcct=" + C_BankAccount_ID + ")");
mTab.setValue("OpenAmt", OpenAmt);
mTab.setValue("PayAmt", OpenAmt.subtract(DiscountAmt));
mTab.setValue("DiscountAmt", DiscountAmt);
mTab.setValue("DifferenceAmt", Env.ZERO);
mTab.setValue("IsSOTrx", IsSOTrx);
setCalloutActive(false);
return "";
} // PaySel_Invoice

View File

@ -52,7 +52,6 @@ public class CalloutPayment extends CalloutEngine
if (isCalloutActive() // assuming it is resetting value
|| C_Invoice_ID == null || C_Invoice_ID.intValue() == 0)
return "";
setCalloutActive(true);
mTab.setValue("C_Order_ID", null);
mTab.setValue("C_Charge_ID", null);
mTab.setValue("IsPrepayment", Boolean.FALSE);
@ -108,11 +107,9 @@ public class CalloutPayment extends CalloutEngine
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
setCalloutActive(false);
return e.getLocalizedMessage();
}
setCalloutActive(false);
return docType(ctx, WindowNo, mTab, mField, value);
} // invoice
@ -137,7 +134,6 @@ public class CalloutPayment extends CalloutEngine
if (isCalloutActive() // assuming it is resetting value
|| C_Order_ID == null || C_Order_ID.intValue() == 0)
return "";
setCalloutActive(true);
mTab.setValue("C_Invoice_ID", null);
mTab.setValue("C_Charge_ID", null);
mTab.setValue("IsPrepayment", Boolean.TRUE);
@ -176,11 +172,9 @@ public class CalloutPayment extends CalloutEngine
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
setCalloutActive(false);
return e.getLocalizedMessage();
}
setCalloutActive(false);
return docType(ctx, WindowNo, mTab, mField, value);
} // order
@ -201,9 +195,7 @@ public class CalloutPayment extends CalloutEngine
if (isCalloutActive() // assuming it is resetting value
|| C_Project_ID == null || C_Project_ID.intValue() == 0)
return "";
setCalloutActive(true);
mTab.setValue("C_Charge_ID", null);
setCalloutActive(false);
return "";
} // project
@ -224,7 +216,6 @@ public class CalloutPayment extends CalloutEngine
if (isCalloutActive() // assuming it is resetting value
|| C_Charge_ID == null || C_Charge_ID.intValue() == 0)
return "";
setCalloutActive(true);
mTab.setValue("C_Invoice_ID", null);
mTab.setValue("C_Order_ID", null);
mTab.setValue("C_Project_ID", null);
@ -234,7 +225,6 @@ public class CalloutPayment extends CalloutEngine
mTab.setValue("WriteOffAmt", Env.ZERO);
mTab.setValue("IsOverUnderPayment", Boolean.FALSE);
mTab.setValue("OverUnderAmt", Env.ZERO);
setCalloutActive(false);
return "";
} // charge
@ -315,7 +305,6 @@ public class CalloutPayment extends CalloutEngine
&& Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID") == 0
&& C_Invoice_ID == 0)
return "";
setCalloutActive(true);
// Changed Column
String colName = mField.getColumnName();
@ -340,14 +329,16 @@ public class CalloutPayment extends CalloutEngine
+ " invoiceOpen(C_Invoice_ID,?)," // 3 #1
+ " invoiceDiscount(C_Invoice_ID,?,?), IsSOTrx " // 4..5 #2/3
+ "FROM C_Invoice WHERE C_Invoice_ID=?"; // #4
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_InvoicePaySchedule_ID);
pstmt.setTimestamp(2, ts);
pstmt.setInt(3, C_InvoicePaySchedule_ID);
pstmt.setInt(4, C_Invoice_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
C_Currency_Invoice_ID= rs.getInt(2);
@ -355,15 +346,17 @@ public class CalloutPayment extends CalloutEngine
if (InvoiceOpenAmt == null)
InvoiceOpenAmt = Env.ZERO;
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
setCalloutActive(false);
return e.getLocalizedMessage();
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
} // get Invoice Info
log.fine("Open=" + InvoiceOpenAmt + ", C_Invoice_ID=" + C_Invoice_ID
+ ", C_Currency_ID=" + C_Currency_Invoice_ID);
@ -399,7 +392,6 @@ public class CalloutPayment extends CalloutEngine
if (CurrencyRate == null || CurrencyRate.compareTo(Env.ZERO) == 0)
{
// mTab.setValue("C_Currency_ID", new Integer(C_Currency_Invoice_ID)); // does not work
setCalloutActive(false);
if (C_Currency_Invoice_ID == 0)
return ""; // no error message when no invoice is selected
return "NoCurrencyConversion";
@ -467,8 +459,6 @@ public class CalloutPayment extends CalloutEngine
PayAmt = InvoiceOpenAmt.subtract(DiscountAmt).subtract(WriteOffAmt).subtract(OverUnderAmt);
mTab.setValue("PayAmt", PayAmt);
}
setCalloutActive(false);
return "";
} // amounts

View File

@ -58,7 +58,6 @@ public class CalloutPaymentAllocate extends CalloutEngine
|| payment.getC_Order_ID() != 0)
return Msg.getMsg(ctx, "PaymentIsAllocated");
setCalloutActive(true);
//
mTab.setValue("DiscountAmt", Env.ZERO);
mTab.setValue("WriteOffAmt", Env.ZERO);
@ -76,14 +75,16 @@ public class CalloutPaymentAllocate extends CalloutEngine
+ " invoiceOpen(C_Invoice_ID, ?)," // 3 #1
+ " invoiceDiscount(C_Invoice_ID,?,?), IsSOTrx " // 4..5 #2/3
+ "FROM C_Invoice WHERE C_Invoice_ID=?"; // #4
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_InvoicePaySchedule_ID);
pstmt.setTimestamp(2, ts);
pstmt.setInt(3, C_InvoicePaySchedule_ID);
pstmt.setInt(4, C_Invoice_ID.intValue());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
// mTab.setValue("C_BPartner_ID", new Integer(rs.getInt(1)));
@ -103,17 +104,17 @@ public class CalloutPaymentAllocate extends CalloutEngine
Env.setContext(ctx, WindowNo, "C_Invoice_ID", C_Invoice_ID.toString());
mTab.setValue("C_Invoice_ID", C_Invoice_ID);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
setCalloutActive(false);
return e.getLocalizedMessage();
}
setCalloutActive(false);
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
return "";
} // invoice
@ -141,7 +142,6 @@ public class CalloutPaymentAllocate extends CalloutEngine
int C_Invoice_ID = Env.getContextAsInt(ctx, WindowNo, "C_Invoice_ID");
if (C_Invoice_ID == 0)
return "";
setCalloutActive(true);
// Get Info from Tab
BigDecimal Amount = (BigDecimal)mTab.getValue("Amount");
BigDecimal DiscountAmt = (BigDecimal)mTab.getValue("DiscountAmt");
@ -166,7 +166,6 @@ public class CalloutPaymentAllocate extends CalloutEngine
mTab.setValue("Amount", Amount);
}
setCalloutActive(false);
return "";
} // amounts

View File

@ -50,40 +50,38 @@ public class CalloutProductCategory extends CalloutEngine
{
if (isCalloutActive() || value == null)
return "";
setCalloutActive(true);
// get values
Integer newParentCategoryId = (Integer) mTab.getValue(MProductCategory.COLUMNNAME_M_Product_Category_Parent_ID);
Integer productCategoryId = (Integer) mTab.getValue(MProductCategory.COLUMNNAME_M_Product_Category_ID);
if (productCategoryId == null)
productCategoryId = new Integer(0);
ResultSet rs = null;
Statement stmt = null;
String sql = " SELECT M_Product_Category_ID, M_Product_Category_Parent_ID FROM M_Product_Category";
final Vector<SimpleTreeNode> categories = new Vector<SimpleTreeNode>(100);
try {
Statement stmt = DB.createStatement();
ResultSet rs = stmt.executeQuery(sql);
stmt = DB.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
if(rs.getInt(1)==productCategoryId.intValue()) {
categories.add(new SimpleTreeNode(rs.getInt(1), newParentCategoryId));
}
categories.add(new SimpleTreeNode(rs.getInt(1), rs.getInt(2)));
}
rs.close();
stmt.close();
if (hasLoop(newParentCategoryId, categories, productCategoryId.intValue())) {
if (hasLoop(newParentCategoryId, categories, productCategoryId.intValue())) {
mTab.setValue(MProductCategory.COLUMNNAME_M_Product_Category_Parent_ID, oldValue);
setCalloutActive(false);
return "ProductCategoryLoopDetected";
}
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
setCalloutActive(false);
return e.getMessage();
}
setCalloutActive(false);
finally
{
DB.close(rs, stmt);
rs = null; stmt = null;
}
return "";
} // testForLoop

View File

@ -44,7 +44,6 @@ public class CalloutProject extends CalloutEngine
{
if (isCalloutActive() || value == null)
return "";
setCalloutActive(true);
BigDecimal PlannedQty, PlannedPrice;
int StdPrecision = Env.getContextAsInt(ctx, WindowNo, "StdPrecision");
@ -64,7 +63,6 @@ public class CalloutProject extends CalloutEngine
//
log.fine("PlannedQty=" + PlannedQty + " * PlannedPrice=" + PlannedPrice + " -> PlannedAmt=" + PlannedAmt + " (Precision=" + StdPrecision+ ")");
mTab.setValue("PlannedAmt", PlannedAmt);
setCalloutActive(false);
return "";
} // planned

View File

@ -89,7 +89,6 @@ public class CalloutRequisition extends CalloutEngine
{
if (isCalloutActive() || value == null)
return "";
setCalloutActive(true);
// Qty changed - recalc price
if (mField.getColumnName().equals("Qty")
@ -126,7 +125,6 @@ public class CalloutRequisition extends CalloutEngine
mTab.setValue("LineNetAmt", LineNetAmt);
log.info("amt - LineNetAmt=" + LineNetAmt);
//
setCalloutActive(false);
return "";
} // amt

View File

@ -47,7 +47,6 @@ public class CalloutTimeExpense extends CalloutEngine
Integer M_Product_ID = (Integer)value;
if (M_Product_ID == null || M_Product_ID.intValue() == 0)
return "";
setCalloutActive(true);
BigDecimal priceActual = null;
// get expense date - or default to today's date
@ -56,6 +55,8 @@ public class CalloutTimeExpense extends CalloutEngine
DateExpense = new Timestamp(System.currentTimeMillis());
String sql = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
boolean noPrice = true;
@ -73,10 +74,10 @@ public class CalloutTimeExpense extends CalloutEngine
+ " AND p.M_Product_ID=?" // 1
+ " AND pl.M_PriceList_ID=?" // 2
+ " ORDER BY pv.ValidFrom DESC";
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, M_Product_ID.intValue());
pstmt.setInt(2, Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"));
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next() && noPrice)
{
java.sql.Date plDate = rs.getDate("ValidFrom");
@ -97,8 +98,6 @@ public class CalloutTimeExpense extends CalloutEngine
mTab.setValue("C_Currency_ID", ii);
}
}
rs.close();
pstmt.close();
// no prices yet - look base pricelist
if (noPrice)
@ -142,19 +141,19 @@ public class CalloutTimeExpense extends CalloutEngine
mTab.setValue("C_Currency_ID", ii);
}
}
rs.close();
pstmt.close();
}
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
setCalloutActive(false);
return e.getLocalizedMessage();
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
// finish
setCalloutActive(false); // calculate amount
if (priceActual == null)
priceActual = Env.ZERO;
mTab.setValue("ExpenseAmt", priceActual);
@ -176,7 +175,6 @@ public class CalloutTimeExpense extends CalloutEngine
{
if (isCalloutActive())
return "";
setCalloutActive(true);
// get values
BigDecimal ExpenseAmt = (BigDecimal)mTab.getValue("ExpenseAmt");
@ -199,7 +197,6 @@ public class CalloutTimeExpense extends CalloutEngine
mTab.setValue("ConvertedAmt", ConvertedAmt);
log.fine("= ConvertedAmt=" + ConvertedAmt);
setCalloutActive(false);
return "";
} // Expense_Amount