📄 infoinvoice.java
字号:
*/
private boolean initInfo ()
{
// Set Defaults
String bp = Env.getContext(Env.getCtx(), p_WindowNo, "C_BPartner_ID");
if (bp != null && bp.length() != 0)
fBPartner_ID.setValue(new Integer(bp));
// prepare table
StringBuffer where = new StringBuffer("i.IsActive='Y'");
if (p_whereClause.length() > 0)
where.append(" AND ").append(Util.replace(p_whereClause, "C_Invoice.", "i."));
prepareTable(s_invoiceLayout,
" C_Invoice_v i", // corrected for CM
where.toString(),
"2,3,4");
//
// MAllocationLine.setIsPaid(Env.getCtx(), 0, null);
return true;
} // initInfo
/**************************************************************************
* Construct SQL Where Clause and define parameters.
* (setParameters needs to set parameters)
* Includes first AND
* @return sql
*/
String getSQLWhere()
{
StringBuffer sql = new StringBuffer();
if (fDocumentNo.getText().length() > 0)
sql.append(" AND UPPER(i.DocumentNo) LIKE ?");
if (fDescription.getText().length() > 0)
sql.append(" AND UPPER(i.Description) LIKE ?");
// if (fPOReference.getText().length() > 0)
// sql.append(" AND UPPER(i.POReference) LIKE ?");
//
if (fBPartner_ID.getValue() != null)
sql.append(" AND i.C_BPartner_ID=?");
//
if (fOrder_ID.getValue() != null)
sql.append(" AND i.C_Order_ID=?");
//
if (fDateFrom.getValue() != null || fDateTo.getValue() != null)
{
Timestamp from = (Timestamp)fDateFrom.getValue();
Timestamp to = (Timestamp)fDateTo.getValue();
if (from == null && to != null)
sql.append(" AND TRUNC(i.DateInvoiced) <= ?");
else if (from != null && to == null)
sql.append(" AND TRUNC(i.DateInvoiced) >= ?");
else if (from != null && to != null)
sql.append(" AND TRUNC(i.DateInvoiced) BETWEEN ? AND ?");
}
//
if (fAmtFrom.getValue() != null || fAmtTo.getValue() != null)
{
BigDecimal from = (BigDecimal)fAmtFrom.getValue();
BigDecimal to = (BigDecimal)fAmtTo.getValue();
if (from == null && to != null)
sql.append(" AND i.GrandTotal <= ?");
else if (from != null && to == null)
sql.append(" AND i.GrandTotal >= ?");
else if (from != null && to != null)
sql.append(" AND i.GrandTotal BETWEEN ? AND ?");
}
//
sql.append(" AND i.IsPaid=? AND i.IsSOTrx=?");
// log.fine( "InfoInvoice.setWhereClause", sql.toString());
return sql.toString();
} // getSQLWhere
/**
* Set Parameters for Query.
* (as defined in getSQLWhere)
* @param pstmt statement
* @param forCount for counting records
* @throws SQLException
*/
void setParameters(PreparedStatement pstmt, boolean forCount) throws SQLException
{
int index = 1;
if (fDocumentNo.getText().length() > 0)
pstmt.setString(index++, getSQLText(fDocumentNo));
if (fDescription.getText().length() > 0)
pstmt.setString(index++, getSQLText(fDescription));
// if (fPOReference.getText().length() > 0)
// pstmt.setString(index++, getSQLText(fPOReference));
//
if (fBPartner_ID.getValue() != null)
{
Integer bp = (Integer)fBPartner_ID.getValue();
pstmt.setInt(index++, bp.intValue());
log.fine("BPartner=" + bp);
}
//
if (fOrder_ID.getValue() != null)
{
Integer order = (Integer)fOrder_ID.getValue();
pstmt.setInt(index++, order.intValue());
log.fine("Order=" + order);
}
//
if (fDateFrom.getValue() != null || fDateTo.getValue() != null)
{
Timestamp from = (Timestamp)fDateFrom.getValue();
Timestamp to = (Timestamp)fDateTo.getValue();
log.fine("Date From=" + from + ", To=" + to);
if (from == null && to != null)
pstmt.setTimestamp(index++, to);
else if (from != null && to == null)
pstmt.setTimestamp(index++, from);
else if (from != null && to != null)
{
pstmt.setTimestamp(index++, from);
pstmt.setTimestamp(index++, to);
}
}
//
if (fAmtFrom.getValue() != null || fAmtTo.getValue() != null)
{
BigDecimal from = (BigDecimal)fAmtFrom.getValue();
BigDecimal to = (BigDecimal)fAmtTo.getValue();
log.fine("Amt From=" + from + ", To=" + to);
if (from == null && to != null)
pstmt.setBigDecimal(index++, to);
else if (from != null && to == null)
pstmt.setBigDecimal(index++, from);
else if (from != null && to != null)
{
pstmt.setBigDecimal(index++, from);
pstmt.setBigDecimal(index++, to);
}
}
pstmt.setString(index++, fIsPaid.isSelected() ? "Y" : "N");
pstmt.setString(index++, fIsSOTrx.isSelected() ? "Y" : "N");
} // setParameters
/**
* Get SQL WHERE parameter
* @param f field
* @return sql
*/
private String getSQLText (CTextField f)
{
String s = f.getText().toUpperCase();
if (!s.endsWith("%"))
s += "%";
log.fine( "String=" + s);
return s;
} // getSQLText
/**
* Zoom
*/
void zoom()
{
log.info( "InfoInvoice.zoom");
Integer C_Invoice_ID = getSelectedRowKey();
if (C_Invoice_ID == null)
return;
MQuery query = new MQuery("C_Invoice");
query.addRestriction("C_Invoice_ID", MQuery.EQUAL, C_Invoice_ID);
query.setRecordCount(1);
int AD_WindowNo = getAD_Window_ID("C_Invoice", fIsSOTrx.isSelected());
zoom (AD_WindowNo, query);
} // zoom
/**
* Has Zoom
* @return true
*/
boolean hasZoom()
{
return true;
} // hasZoom
/**
* Save Selection Settings
*/
void saveSelectionDetail()
{
// publish for Callout to read
Integer ID = getSelectedRowKey();
Env.setContext(Env.getCtx(), Env.WINDOW_INFO, Env.TAB_INFO, "C_Invoice_ID", ID == null ? "0" : ID.toString());
//
int C_InvoicePaySchedule_ID = 0;
int row = p_table.getSelectedRow();
if (row >= 0)
{
Object value = p_table.getValueAt(row, INDEX_PAYSCHEDULE);
if (value != null && value instanceof KeyNamePair)
C_InvoicePaySchedule_ID = ((KeyNamePair)value).getKey();
}
if (C_InvoicePaySchedule_ID <= 0) // not selected
Env.setContext(Env.getCtx(), Env.WINDOW_INFO, Env.TAB_INFO, "C_InvoicePaySchedule_ID", "0");
else
Env.setContext(Env.getCtx(), Env.WINDOW_INFO, Env.TAB_INFO, "C_InvoicePaySchedule_ID", String.valueOf(C_InvoicePaySchedule_ID));
} // saveSelectionDetail
} // InfoInvoice
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -