use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class HRPayPrint method loadPaymentRule.
// loadPaySelectInfo
/**
* Bank changed - load PaymentRule
*/
public ArrayList<ValueNamePair> loadPaymentRule(int C_PaySelection_ID) {
ArrayList<ValueNamePair> data = new ArrayList<ValueNamePair>();
// load PaymentRule for Bank
// MLookupInfo.getAD_Reference_ID("All_Payment Rule");
int AD_Reference_ID = 195;
Language language = Language.getLanguage(Env.getAD_Language(Env.getCtx()));
MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
String sql = info.Query.substring(0, info.Query.indexOf(" ORDER BY")) + " AND " + info.KeyColumn + " IN (SELECT PaymentRule FROM HR_PaySelectionCheck WHERE HR_PaySelection_ID=?) " + info.Query.substring(info.Query.indexOf(" ORDER BY"));
try {
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_PaySelection_ID);
ResultSet rs = pstmt.executeQuery();
//
while (rs.next()) {
ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3));
data.add(pp);
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
}
if (data.size() == 0)
log.config("PaySel=" + C_PaySelection_ID + ", BAcct=" + m_C_BankAccount_ID + " - " + sql);
return data;
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class HRActionNotice method getConcept.
//getEmployeeValid
public ArrayList<ValueNamePair> getConcept(MHRProcess process, boolean isFieldProcessNull) {
if (process == null)
return null;
ArrayList<ValueNamePair> data = new ArrayList<ValueNamePair>();
String sql = "SELECT DISTINCT hrpc.HR_Concept_ID,hrpc.Name,hrpc.Value " + " FROM HR_Concept hrpc " + " INNER JOIN HR_Attribute hrpa ON (hrpa.HR_Concept_ID=hrpc.HR_Concept_ID)" + " WHERE hrpc.AD_Client_ID = " + Env.getAD_Client_ID(Env.getCtx()) + " AND hrpc.IsActive = 'Y' AND hrpc.IsManual = 'Y' AND hrpc.Type != 'E'" + " AND (hrpa.HR_Payroll_ID = " + m_HR_Payroll_ID + " OR hrpa.HR_Payroll_ID IS NULL)";
if (!isFieldProcessNull) {
// Process
if (// Process & Payroll
process.getHR_Payroll_ID() != 0)
sql = sql + " AND (hrpa.HR_Payroll_ID = " + process.getHR_Payroll_ID() + " OR hrpa.HR_Payroll_ID is NULL)";
// Process & Department
if (process.getHR_Department_ID() != 0)
;
sql = sql + " AND (hrpa.HR_Department_ID = " + process.getHR_Department_ID() + " OR hrpa.HR_Department_ID is NULL)";
// Process & Employee
if (process.getHR_Department_ID() != 0)
;
sql = sql + " AND (hrpa.HR_Employee_ID = " + process.getHR_Employee_ID() + " OR hrpa.HR_Employee_ID is NULL)";
}
sql = sql + " ORDER BY hrpc.Name";
try {
PreparedStatement pstmt = DB.prepareStatement(sql, null);
//pstmt.setInt(1, bi.C_BankAccount_ID);
ResultSet rs = pstmt.executeQuery();
ValueNamePair vp = null;
data.add(new ValueNamePair("", ""));
while (rs.next()) {
// returns also not active
vp = new ValueNamePair(rs.getString(1), rs.getString(2));
data.add(vp);
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
}
return data;
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class VHRPayPrint method cmd_print.
// cmd_EFT
/**
* Print Checks and/or Remittance
*/
private void cmd_print() {
String PaymentRule = ((ValueNamePair) fPaymentRule.getSelectedItem()).getValue();
log.info(PaymentRule);
if (!getChecks(PaymentRule))
return;
panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
boolean somethingPrinted = false;
boolean directPrint = !Ini.isPropertyBool(Ini.P_PRINTPREVIEW);
// for all checks
for (MHRPaySelectionCheck check : m_checks) {
// ReportCtrl will check BankAccountDoc for PrintFormat
boolean ok = ReportCtl.startDocumentPrint(ReportEngine.HR_CHECK, check.get_ID(), null, Env.getWindowNo(panel), directPrint);
if (!somethingPrinted && ok)
somethingPrinted = true;
}
// Confirm Print and Update BankAccountDoc
if (somethingPrinted && ADialog.ask(m_WindowNo, panel, "VPayPrintSuccess?")) {
int lastDocumentNo = MHRPaySelectionCheck.confirmPrint(m_checks, m_batch);
if (lastDocumentNo != 0) {
StringBuffer sb = new StringBuffer();
sb.append("UPDATE C_BankAccountDoc SET CurrentNext=").append(++lastDocumentNo).append(" WHERE C_BankAccount_ID=").append(m_C_BankAccount_ID).append(" AND PaymentRule='").append(PaymentRule).append("'");
DB.executeUpdate(sb.toString(), null);
}
}
if (ADialog.ask(m_WindowNo, panel, "VPayPrintPrintRemittance")) {
for (MHRPaySelectionCheck check : m_checks) {
ReportCtl.startDocumentPrint(ReportEngine.HR_REMITTANCE, check.get_ID(), null, Env.getWindowNo(panel), directPrint);
}
}
// remittance
panel.setCursor(Cursor.getDefaultCursor());
dispose();
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class VHRPayPrint method loadPaymentRuleInfo.
// loadPaymentRule
/**
* PaymentRule changed - load DocumentNo, NoPayments,
* enable/disable EFT, Print
*/
private void loadPaymentRuleInfo() {
ValueNamePair pp = (ValueNamePair) fPaymentRule.getSelectedItem();
if (pp == null)
return;
String PaymentRule = pp.getValue();
log.info("PaymentRule=" + PaymentRule);
fNoPayments.setText(" ");
int C_PaySelection_ID = ((KeyNamePair) fPaySelect.getSelectedItem()).getKey();
String msg = loadPaymentRuleInfo(C_PaySelection_ID, PaymentRule);
if (noPayments != null)
fNoPayments.setText(noPayments);
bProcess.setEnabled(PaymentRule.equals("T"));
if (documentNo != null)
fDocumentNo.setValue(documentNo);
if (msg != null && msg.length() > 0)
ADialog.error(m_WindowNo, panel, msg);
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class MRefList method getList.
// getListDescription
/**
* Get Reference List (translated)
* @param ctx context
* @param AD_Reference_ID reference
* @param optional if true add "",""
* @return List or null
*/
public static ValueNamePair[] getList(Properties ctx, int AD_Reference_ID, boolean optional) {
String ad_language = Env.getAD_Language(ctx);
boolean isBaseLanguage = Env.isBaseLanguage(ad_language, "AD_Ref_List");
String sql = isBaseLanguage ? "SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=? AND IsActive='Y' ORDER BY Name" : "SELECT r.Value, t.Name FROM AD_Ref_List_Trl t" + " INNER JOIN AD_Ref_List r ON (r.AD_Ref_List_ID=t.AD_Ref_List_ID)" + " WHERE r.AD_Reference_ID=? AND t.AD_Language=? AND r.IsActive='Y'" + " ORDER BY t.Name";
PreparedStatement pstmt = null;
ResultSet rs = null;
ArrayList<ValueNamePair> list = new ArrayList<ValueNamePair>();
if (optional)
list.add(new ValueNamePair("", ""));
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Reference_ID);
if (!isBaseLanguage)
pstmt.setString(2, ad_language);
rs = pstmt.executeQuery();
while (rs.next()) list.add(new ValueNamePair(rs.getString(1), rs.getString(2)));
rs.close();
pstmt.close();
pstmt = null;
} catch (SQLException e) {
s_log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
ValueNamePair[] retValue = new ValueNamePair[list.size()];
list.toArray(retValue);
return retValue;
}
Aggregations