use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class VHRPayPrint method loadPaymentRule.
// loadPaySelectInfo
/**
* Bank changed - load PaymentRule
*/
private void loadPaymentRule() {
log.info("");
if (m_C_BankAccount_ID == -1)
return;
fPaymentRule.removeAllItems();
int C_PaySelection_ID = ((KeyNamePair) fPaySelect.getSelectedItem()).getKey();
ArrayList<ValueNamePair> data = loadPaymentRule(C_PaySelection_ID);
for (ValueNamePair pp : data) fPaymentRule.addItem(pp);
if (fPaymentRule.getItemCount() > 0)
fPaymentRule.setSelectedIndex(0);
loadPaymentRuleInfo();
}
use of org.compiere.util.ValueNamePair in project adempiere by adempiere.
the class WHRActionNotice method onEvent.
/**************************************************************************
* Action Listener. - MultiCurrency - Allocate
*
* @param e
* event
*/
@Override
public void onEvent(Event e) {
KeyNamePair processKeyNamePair = (KeyNamePair) fieldProcess.getSelectedItem().getValue();
if (e.getTarget() == fieldProcess && processKeyNamePair != null && processKeyNamePair.getKey() > 0) {
payrollProcess = new MHRProcess(Env.getCtx(), processKeyNamePair.getKey(), null);
payrollProcessId = payrollProcess.getHR_Process_ID();
if (payrollProcess.getHR_Period_ID() > 0) {
MHRPeriod period = MHRPeriod.get(Env.getCtx(), payrollProcess.getHR_Period_ID());
dateStart = period.getStartDate();
dateEnd = period.getEndDate();
} else {
dateEnd = payrollProcess.getDateAcct();
}
fieldEmployee.removeAllItems();
KeyNamePair[] employeeData = getEmployeeValid(payrollProcess);
for (KeyNamePair vp : employeeData) {
fieldEmployee.appendItem(vp.getName(), vp);
}
}
//
if (e.getTarget() == fieldEmployee) {
partnerId = ((KeyNamePair) fieldEmployee.getSelectedItem().getValue()).getKey();
// Validate
if (partnerId > 0) {
fieldValidFrom.setValue(dateEnd);
fieldConcept.removeAllItems();
KeyNamePair[] conceptData = getConcept(getPayrollProcess(), fieldProcess != null);
for (KeyNamePair vp : conceptData) {
fieldConcept.appendItem(vp.getName(), vp);
}
}
}
if (e.getTarget() == fieldConcept) {
KeyNamePair valueNamePair = (KeyNamePair) fieldConcept.getSelectedItem().getValue();
if (valueNamePair != null) {
conceptId = ((KeyNamePair) fieldConcept.getSelectedItem().getValue()).getKey();
}
//
if (conceptId > 0) {
MHRConcept concept = MHRConcept.get(Env.getCtx(), conceptId);
// Load Data Combo Box
loadTextMsgLookup(concept.getAD_Reference_ID());
//
String columnType = MRefList.getListName(Env.getCtx(), MHRConcept.COLUMNTYPE_AD_Reference_ID, concept.getColumnType());
fieldColumnType.setValue(columnType);
fieldColumnType.setVisible(true);
movementId = seekMovement((Timestamp) fieldValidFrom.getValue());
if (movementId > 0) {
MHRMovement movementFound = new MHRMovement(Env.getCtx(), movementId, null);
fieldDescription.setValue(movementFound.getDescription());
fieldText.setValue("");
fieldDate.setValue(null);
fieldQty.setValue(Env.ZERO);
fieldAmount.setValue(Env.ZERO);
if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Quantity)) {
// Quantity
fieldQty.setValue(movementFound.getQty());
} else if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Amount)) {
// Amount
fieldAmount.setValue(movementFound.getAmount());
} else if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Text)) {
// Verify Reference
if (isLookupTextMsg) {
fieldTextLookup.setValue(movementFound.getTextMsg());
} else {
fieldText.setValue(movementFound.getTextMsg());
}
} else if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Date)) {
// Date
fieldDate.setValue(movementFound.getServiceDate());
}
}
if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Quantity)) {
// Concept Type
fieldQty.setVisible(true);
fieldQty.setReadWrite(true);
fieldAmount.setVisible(false);
fieldDate.setVisible(false);
fieldText.setVisible(false);
fieldTextLookup.setVisible(false);
} else if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Amount)) {
fieldQty.setVisible(false);
fieldAmount.setVisible(true);
fieldAmount.setReadWrite(true);
fieldDate.setVisible(false);
fieldText.setVisible(false);
fieldTextLookup.setVisible(false);
} else if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Date)) {
fieldQty.setVisible(false);
fieldAmount.setVisible(false);
fieldDate.setVisible(true);
fieldDate.setReadWrite(true);
fieldText.setVisible(false);
fieldTextLookup.setVisible(false);
} else if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Text)) {
// Verify Reference
if (isLookupTextMsg) {
fieldText.setVisible(false);
fieldText.setReadWrite(false);
fieldTextLookup.setVisible(true);
} else {
fieldTextLookup.setVisible(false);
fieldText.setVisible(true);
fieldText.setReadWrite(true);
}
fieldAmount.setVisible(false);
fieldDate.setVisible(false);
}
}
}
if (e.getTarget() == bOk) {
if (fieldConcept.getSelectedItem() != null)
conceptId = ((KeyNamePair) fieldConcept.getSelectedItem().getValue()).getKey();
partnerId = ((KeyNamePair) fieldEmployee.getSelectedItem().getValue()).getKey();
payrollId = getPayrollProcess().getHR_Payroll_ID();
if (payrollProcess.getHR_Period_ID() > 0) {
MHRPeriod period = MHRPeriod.get(Env.getCtx(), payrollProcess.getHR_Period_ID());
dateStart = period.getStartDate();
dateEnd = period.getEndDate();
} else {
dateEnd = payrollProcess.getDateAcct();
}
quantity = (BigDecimal) fieldQty.getValue();
amount = (BigDecimal) fieldAmount.getValue();
// Get from List
if (isLookupTextMsg) {
text = (String) ((ValueNamePair) fieldTextLookup.getSelectedItem().getValue()).getValue();
} else {
text = (String) fieldText.getValue();
}
serviceDate = (Timestamp) fieldDate.getValue();
description = (String) fieldDescription.getValue();
validFrom = (Timestamp) fieldValidFrom.getValue();
validTo = (Timestamp) fieldValidFrom.getValue();
if (conceptId <= 0 || fieldProcess.getSelectedItem().getValue() == null || ((KeyNamePair) fieldProcess.getSelectedItem().getValue()).getKey() <= 0 || fieldEmployee.getSelectedItem().getValue() == null || ((KeyNamePair) fieldEmployee.getSelectedItem().getValue()).getKey() <= 0) {
// required fields
} else {
saveMovement();
}
}
//
executeQuery();
return;
}
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();
}
Aggregations