use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class Charge method getData.
/**
* Dynamic Init
* - Get defaults for primary AcctSchema
* - Create Table with Accounts
*/
public Vector<Vector<Object>> getData() {
// Table
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
String sql = "SELECT C_ElementValue_ID,Value, Name, AccountType " + "FROM C_ElementValue " + "WHERE AccountType IN ('R','E')" + " AND IsSummary='N'" + " AND C_Element_ID=? " + "ORDER BY 2";
try {
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_C_Element_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
Vector<Object> line = new Vector<Object>(4);
// 0-C_ElementValue_ID
line.add(new IDColumn(rs.getInt(1)));
// 1-Value
line.add(rs.getString(2));
// 2-Name
line.add(rs.getString(3));
boolean isExpenseType = rs.getString(4).equals("E");
// 3-Expense
line.add(new Boolean(isExpenseType));
data.add(line);
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
}
return data;
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class Allocation method getPaymentData.
/**
* Get Payment data
* @param isMultiCurrency
* @param date
* @param paymentTable
* @return
*/
public Vector<Vector<Object>> getPaymentData(boolean isMultiCurrency, Object date, IMiniTable paymentTable) {
/********************************
* Load unallocated Payments
* 1-TrxDate, 2-DocumentNo, (3-Currency, 4-PayAmt,)
* 5-ConvAmt, 6-ConvOpen, 7-Allocated
*/
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
StringBuffer sql = new StringBuffer(// 1..3
"SELECT p.DateTrx,p.DocumentNo,p.C_Payment_ID," + // 4..5
"c.ISO_Code,p.PayAmt," + // 6 #1, #2
"currencyConvert(p.PayAmt,p.C_Currency_ID,?,?,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID)," + // 7 #3, #4
"currencyConvert(paymentAvailable(C_Payment_ID),p.C_Currency_ID,?,?,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID)," + // 8..10
"p.MultiplierAP, p.IsReceipt, p.AD_Org_ID " + // Corrected for AP/AR
"FROM C_Payment_v p" + " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID) " + "WHERE p.IsAllocated='N' AND p.Processed='Y'" + // Prepayments OK
" AND p.C_Charge_ID IS NULL" + // #5
" AND p.C_BPartner_ID=?");
if (!isMultiCurrency)
// #6
sql.append(" AND p.C_Currency_ID=?");
if (m_AD_Org_ID != 0)
sql.append(" AND p.AD_Org_ID=" + m_AD_Org_ID);
if (apar != null && !apar.equals(APAR_A)) {
sql.append(" AND p.IsReceipt= '" + (apar.equals(APAR_R) ? "Y" : "N") + "'");
}
sql.append(" ORDER BY p.DateTrx,p.DocumentNo");
// role security
sql = new StringBuffer(MRole.getDefault(Env.getCtx(), false).addAccessSQL(sql.toString(), "p", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO));
log.fine("PaySQL=" + sql.toString());
try {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, m_C_Currency_ID);
pstmt.setTimestamp(2, (Timestamp) date);
pstmt.setInt(3, m_C_Currency_ID);
pstmt.setTimestamp(4, (Timestamp) date);
pstmt.setInt(5, m_C_BPartner_ID);
if (!isMultiCurrency)
pstmt.setInt(6, m_C_Currency_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
Vector<Object> line = new Vector<Object>();
// 0-C_Payment_ID
line.add(new IDColumn(rs.getInt(3)));
// 1-TrxDate
line.add(rs.getTimestamp(1));
if (// Ar/Ap
rs.getString(9).equals("Y"))
line.add("AR");
else
line.add("AP");
// 10 AD_Org_ID
int orgID = rs.getInt(10);
if (orgID == 0)
line.add("*");
else
line.add((new MOrg(Env.getCtx(), orgID, null).getName()));
KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(2));
// 4-DocumentNo
line.add(pp);
if (isMultiCurrency) {
// 5-Currency
line.add(rs.getString(4));
// 6-PayAmt
line.add(rs.getBigDecimal(5));
}
// 5/7-ConvAmt
line.add(rs.getBigDecimal(6));
BigDecimal available = rs.getBigDecimal(7);
if (// nothing available
available == null || available.signum() == 0)
continue;
// 6/8-ConvOpen/Available
line.add(available);
// 7/9-Paymentr
line.add(Env.ZERO);
//
data.add(line);
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql.toString(), e);
}
return data;
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class Match method cmd_process.
// cmd_search
/**
* Process Button Pressed - Process Matching
*/
protected void cmd_process(IMiniTable xMatchedTable, IMiniTable xMatchedToTable, int matchMode, int matchFrom, Object matchTo, BigDecimal m_xMatched) {
log.config("");
// Matched From
int matchedRow = xMatchedTable.getSelectedRow();
if (matchedRow < 0)
return;
// KeyNamePair BPartner = (KeyNamePair)xMatchedTable.getValueAt(matchedRow, I_BPartner);
KeyNamePair lineMatched = (KeyNamePair) xMatchedTable.getValueAt(matchedRow, I_Line);
KeyNamePair Product = (KeyNamePair) xMatchedTable.getValueAt(matchedRow, I_Product);
double totalQty = m_xMatched.doubleValue();
// Matched To
for (int row = 0; row < xMatchedToTable.getRowCount(); row++) {
IDColumn id = (IDColumn) xMatchedToTable.getValueAt(row, 0);
if (id != null && id.isSelected()) {
// need to be the same product
KeyNamePair ProductCompare = (KeyNamePair) xMatchedToTable.getValueAt(row, I_Product);
if (Product.getKey() != ProductCompare.getKey())
continue;
KeyNamePair lineMatchedTo = (KeyNamePair) xMatchedToTable.getValueAt(row, I_Line);
// Qty
double qty = 0.0;
if (matchMode == MODE_NOTMATCHED)
// doc
qty = ((Double) xMatchedToTable.getValueAt(row, I_QTY)).doubleValue();
// matched
qty -= ((Double) xMatchedToTable.getValueAt(row, I_MATCHED)).doubleValue();
if (qty > totalQty)
qty = totalQty;
totalQty -= qty;
// Invoice or PO
boolean invoice = true;
if (matchFrom == MATCH_ORDER || matchTo.equals(m_matchOptions[MATCH_ORDER]))
invoice = false;
// Get Shipment_ID
int M_InOutLine_ID = 0;
int Line_ID = 0;
if (matchFrom == MATCH_SHIPMENT) {
// upper table
M_InOutLine_ID = lineMatched.getKey();
Line_ID = lineMatchedTo.getKey();
} else {
// lower table
M_InOutLine_ID = lineMatchedTo.getKey();
Line_ID = lineMatched.getKey();
}
// Create it
String innerTrxName = Trx.createTrxName("Match");
Trx innerTrx = Trx.get(innerTrxName, true);
if (createMatchRecord(invoice, M_InOutLine_ID, Line_ID, new BigDecimal(qty), innerTrxName))
innerTrx.commit();
else
innerTrx.rollback();
innerTrx.close();
innerTrx = null;
}
}
// requery
//cmd_search();
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class PaySelect method generatePaySelect.
/**
* Generate PaySelection
*/
public String generatePaySelect(IMiniTable miniTable, ValueNamePair paymentRule, Timestamp payDate, BankInfo bi) {
log.info("");
// String trxName Trx.createTrxName("PaySelect");
// Trx trx = Trx.get(trxName, true); trx needs to be committed too
String trxName = null;
trx = null;
String PaymentRule = paymentRule.getValue();
// Create Header
m_ps = new MPaySelection(Env.getCtx(), 0, trxName);
// FR [ 297 ]
m_ps.setDescription(Msg.getMsg(Env.getCtx(), "VPaySelect") + " - " + paymentRule.getName() + " - " + payDate);
m_ps.setPayDate(payDate);
m_ps.setC_BankAccount_ID(bi.C_BankAccount_ID);
m_ps.setIsApproved(true);
if (!m_ps.save()) {
m_ps = null;
return Msg.translate(Env.getCtx(), "C_PaySelection_ID");
}
log.config(m_ps.toString());
// Create Lines
int rows = miniTable.getRowCount();
int line = 0;
for (int i = 0; i < rows; i++) {
IDColumn id = (IDColumn) miniTable.getValueAt(i, 0);
Object ips_id = miniTable.getValueAt(i, 11);
if (id.isSelected()) {
line += 10;
MPaySelectionLine psl = new MPaySelectionLine(m_ps, line, PaymentRule);
int C_Invoice_ID = id.getRecord_ID().intValue();
int C_InvoicePaySchedule_ID = Integer.parseInt(ips_id.toString());
BigDecimal OpenAmt = (BigDecimal) miniTable.getValueAt(i, 9);
BigDecimal PayAmt = (BigDecimal) miniTable.getValueAt(i, 10);
boolean isSOTrx = false;
//
psl.setInvoice(C_Invoice_ID, C_InvoicePaySchedule_ID, isSOTrx, OpenAmt, PayAmt, OpenAmt.subtract(PayAmt));
if (!psl.save(trxName)) {
return Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID");
}
log.fine("C_Invoice_ID=" + C_Invoice_ID + ", PayAmt=" + PayAmt);
}
}
return null;
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class InOutGen method saveSelection.
// executeQuery
/**
* Save Selection & return selection Query or ""
* @return where clause like C_Order_ID IN (...)
*/
public void saveSelection(IMiniTable miniTable) {
log.info("");
// Array of Integers
ArrayList<Integer> results = new ArrayList<Integer>();
setSelection(null);
// Get selected entries
int rows = miniTable.getRowCount();
for (int i = 0; i < rows; i++) {
// ID in column 0
IDColumn id = (IDColumn) miniTable.getValueAt(i, 0);
// log.fine( "Row=" + i + " - " + id);
if (id != null && id.isSelected())
results.add(id.getRecord_ID());
}
if (results.size() == 0)
return;
log.config("Selected #" + results.size());
setSelection(results);
}
Aggregations