use of org.compiere.model.Query in project adempiere by adempiere.
the class A_Depreciation_Exp_Check method getAsset_IDs.
private int[] getAsset_IDs() {
ArrayList<Object> params = new ArrayList<Object>();
String whereClause = null;
if (p_A_Asset_ID > 0) {
whereClause = "A_Asset_ID=?";
params.add(p_A_Asset_ID);
} else {
whereClause = p_WhereClause;
}
return new Query(getCtx(), MAsset.Table_Name, whereClause, get_TrxName()).setParameters(params).setOrderBy("A_Asset_ID").getIDs();
}
use of org.compiere.model.Query in project adempiere by adempiere.
the class ImportEmployeeAttributes method getAttributeIds.
/**
* Get Import Attribute List
* @param isImported
* @param isProcessed
* @return
*/
private int[] getAttributeIds(boolean isImported, boolean isProcessed, String trxName) {
StringBuilder whereClause = new StringBuilder();
whereClause.append(I_I_HR_Attribute.COLUMNNAME_I_IsImported).append("=? AND ").append(I_I_HR_Attribute.COLUMNNAME_Processed).append("=?");
return new Query(getCtx(), X_I_HR_Attribute.Table_Name, whereClause.toString(), trxName).setOnlyActiveRecords(true).setParameters(isImported, isProcessed).getIDs();
}
use of org.compiere.model.Query in project adempiere by adempiere.
the class PayrollViaEMail method sendIndividualMail.
// sendBPGroup
/**
* Send Individual Mail
* @param bPartnerId user
* @param unSubscribe unsubscribe message
* @return true if mail has been sent
*/
private Boolean sendIndividualMail(int bPartnerId, String unSubscribe) {
try {
MBPartner employee = new MBPartner(getCtx(), bPartnerId, null);
String message = mailText.getMailText(true);
if (unSubscribe != null)
message += unSubscribe;
StringBuffer whereClause = new StringBuffer();
whereClause.append(MBPartnerLocation.COLUMNNAME_C_BPartner_ID).append(" = ? AND ").append(MBPartnerLocation.COLUMNNAME_ContactType).append("=?");
MBPartnerLocation location = new Query(getCtx(), MBPartnerLocation.Table_Name, whereClause.toString(), get_TrxName()).setOnlyActiveRecords(true).setParameters(bPartnerId, MBPartnerLocation.CONTACTTYPE_Primary).first();
if (location == null) {
addLog(0, null, null, employee.getName() + " @Email@ @NotFound@");
return false;
}
MClient client = MClient.get(getCtx());
String eMailFrom = client.getRequestEMail();
String emailFrom = location.get_ValueAsString("EMail");
String userMailFrom = client.getRequestUser();
String password = client.getRequestUserPW();
// FR [ 402 ]
// Add support to new send mail
EMail email = new EMail(client, eMailFrom, emailFrom, mailText.getMailHeader(), message);
if (mailText.isHtml())
email.setMessageHTML(mailText.getMailHeader(), message);
else {
email.setSubject(mailText.getMailHeader());
email.setMessageText(message);
}
email.addAttachment(CreatePDF(bPartnerId));
if (!email.isValid() && !email.isValid(true)) {
log.warning("NOT VALID - " + email);
employee.setIsActive(false);
employee.save();
return Boolean.FALSE;
}
email.createAuthenticator(userMailFrom, password);
boolean OK = EMail.SENT_OK.equals(email.send());
if (OK) {
addLog(0, null, null, employee.getName() + " @Email@ @OK@");
log.fine(employee.getURL());
} else
log.warning("FAILURE - " + employee.getURL());
addLog(0, null, null, (OK ? "@OK@" : "@ERROR@") + " - " + emailFrom);
return OK;
} catch (Exception e) {
return Boolean.FALSE;
}
}
use of org.compiere.model.Query in project adempiere by adempiere.
the class MHRSalaryStructure method getByValue.
/**
* Get Salary Structure by search key
* @param ctx
* @param value
* @return
*/
public static MHRSalaryStructure getByValue(Properties ctx, String value) {
if (value == null)
return null;
if (salaryStructureCacheValues.size() == 0)
getAll(ctx, true);
int clientId = Env.getAD_Client_ID(ctx);
String key = clientId + "#" + value;
MHRSalaryStructure salaryStructure = new Query(ctx, Table_Name, COLUMNNAME_Value + "=?", null).setClient_ID().setParameters(key).first();
if (salaryStructure != null && salaryStructure.getHR_SalaryStructure_ID() > 0) {
salaryStructureCacheValues.put(key, salaryStructure);
salaryStructureCacheIds.put(salaryStructure.get_ID(), salaryStructure);
}
return salaryStructure;
}
use of org.compiere.model.Query in project adempiere by adempiere.
the class HRCreateInvoice method getPayrollMovement.
/**
* Get Payroll movement with concept is paid and is invoiced
* @param processId
* @param partnerId
* @param trxName
* @return
*/
private List<MHRMovement> getPayrollMovement(int processId, int partnerId, String trxName) {
StringBuilder whereClause = new StringBuilder();
whereClause.append("HR_Movement.HR_Process_ID = ? AND HR_Movement.C_BPartner_ID=? AND ").append("EXISTS (SELECT 1 FROM HR_Concept c INNER JOIN HR_Attribute a ON (c.HR_Concept_ID = a.HR_Concept_ID) ").append("WHERE HR_Movement.C_InvoiceLine_ID IS NULL AND c.HR_Concept_ID=HR_Movement.HR_Concept_ID AND a.IsActive = ? AND c.IsPaid=? AND c.IsInvoiced=? AND a.C_DocType_ID > 0 AND a.C_Charge_ID > 0)");
return new Query(getCtx(), MHRMovement.Table_Name, whereClause.toString(), trxName).setClient_ID().setParameters(processId, partnerId, true, true, true).list();
}
Aggregations