Print Payroll Checks
kind regards Victor Perez www.e-evolution.com Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=3015725
This commit is contained in:
parent
6b4650dd28
commit
0b0ba98a98
|
@ -0,0 +1,201 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||
*****************************************************************************/
|
||||
package org.eevolution.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
/**
|
||||
* Payroll Concept for HRayroll Module
|
||||
*
|
||||
* @author Oscar Gómez Islas
|
||||
* @version $Id: HRPayroll.java,v 1.0 2005/10/05 ogomezi
|
||||
*
|
||||
* @author Cristina Ghita, www.arhipac.ro
|
||||
*/
|
||||
public class MHRConcept extends X_HR_Concept
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8736925494645172953L;
|
||||
|
||||
/** Cache */
|
||||
private static CCache<Integer, MHRConcept> s_cache = new CCache<Integer, MHRConcept>(Table_Name, 100);
|
||||
/** Cache by Value */
|
||||
private static CCache<String, MHRConcept> s_cacheValue = new CCache<String, MHRConcept>(Table_Name+"_Value", 100);
|
||||
|
||||
public static MHRConcept get(Properties ctx, int HR_Concept_ID)
|
||||
{
|
||||
if (HR_Concept_ID <= 0)
|
||||
return null;
|
||||
//
|
||||
MHRConcept concept = s_cache.get(HR_Concept_ID);
|
||||
if (concept != null)
|
||||
return concept;
|
||||
//
|
||||
concept = new MHRConcept(ctx, HR_Concept_ID, null);
|
||||
if (concept.get_ID() == HR_Concept_ID)
|
||||
{
|
||||
s_cache.put(HR_Concept_ID, concept);
|
||||
}
|
||||
else
|
||||
{
|
||||
concept = null;
|
||||
}
|
||||
return concept;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Concept by Value
|
||||
* @param ctx
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static MHRConcept forValue(Properties ctx, String value)
|
||||
{
|
||||
if (Util.isEmpty(value, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int AD_Client_ID = Env.getAD_Client_ID(ctx);
|
||||
final String key = AD_Client_ID+"#"+value;
|
||||
MHRConcept concept = s_cacheValue.get(key);
|
||||
if (concept != null)
|
||||
{
|
||||
return concept;
|
||||
}
|
||||
|
||||
final String whereClause = COLUMNNAME_Value+"=? AND AD_Client_ID IN (?,?)";
|
||||
concept = new Query(ctx, Table_Name, whereClause, null)
|
||||
.setParameters(new Object[]{value, 0, AD_Client_ID})
|
||||
.setOnlyActiveRecords(true)
|
||||
.setOrderBy("AD_Client_ID DESC")
|
||||
.first();
|
||||
if (concept != null)
|
||||
{
|
||||
s_cacheValue.put(key, concept);
|
||||
s_cache.put(concept.get_ID(), concept);
|
||||
}
|
||||
return concept;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Employee's of Payroll Type
|
||||
* @param payroll_id Payroll ID
|
||||
* @param department_id Department ID
|
||||
* @param employee_id Employee_ID
|
||||
* @param sqlwhere Clause SQLWhere
|
||||
* @return lines
|
||||
*/
|
||||
public static MHRConcept[] getConcepts (int payroll_id, int department_id, int employee_id, String sqlWhere)
|
||||
{
|
||||
Properties ctx = Env.getCtx();
|
||||
List<Object> params = new ArrayList<Object>();
|
||||
StringBuffer whereClause = new StringBuffer();
|
||||
|
||||
whereClause.append("AD_Client_ID in (?,?)");
|
||||
params.add(0);
|
||||
params.add(Env.getAD_Client_ID(Env.getCtx()));
|
||||
|
||||
whereClause.append(" AND (" + COLUMNNAME_HR_Payroll_ID + " =? OR "
|
||||
+COLUMNNAME_HR_Payroll_ID +" IS NULL)");
|
||||
params.add(payroll_id);
|
||||
|
||||
if (department_id != 0 )
|
||||
{
|
||||
whereClause.append(" AND HR_Concept.HR_Department_ID=?");
|
||||
params.add(department_id);
|
||||
}
|
||||
|
||||
if (!Util.isEmpty(sqlWhere))
|
||||
{
|
||||
whereClause.append(sqlWhere);
|
||||
}
|
||||
|
||||
List<MHRConcept> list = new Query(ctx, Table_Name, whereClause.toString(), null)
|
||||
.setParameters(params)
|
||||
.setOnlyActiveRecords(true)
|
||||
.setOrderBy("COALESCE("+COLUMNNAME_SeqNo + ",999999999999) DESC, " + COLUMNNAME_Value)
|
||||
.list();
|
||||
return list.toArray(new MHRConcept[list.size()]);
|
||||
} // getConcept
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
* @param ctx context
|
||||
* @param HR_Concept_ID
|
||||
* @param trxName
|
||||
*/
|
||||
public MHRConcept (Properties ctx, int HR_Concept_ID, String trxName)
|
||||
{
|
||||
super (ctx, HR_Concept_ID, trxName);
|
||||
if (HR_Concept_ID == 0)
|
||||
{
|
||||
setValue("");
|
||||
setName("");
|
||||
setDescription("");
|
||||
setIsEmployee(false);
|
||||
setIsPrinted(false);
|
||||
setHR_Payroll_ID(0);
|
||||
setHR_Job_ID(0);
|
||||
setHR_Department_ID(0);
|
||||
}
|
||||
} // HRConcept
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
* @param trxName
|
||||
*/
|
||||
public MHRConcept (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super(ctx, rs, trxName);
|
||||
}
|
||||
|
||||
public int getConceptAccountCR()
|
||||
{
|
||||
String sql = " HR_Expense_Acct FROM HR_Concept c " +
|
||||
" INNER JOIN HR_Concept_Acct ca ON (c.HR_Concept_ID=ca.HR_Concept_ID)" +
|
||||
" WHERE c.HR_Concept_ID " + getHR_Concept_ID();
|
||||
int result = DB.getSQLValue("ConceptCR", sql);
|
||||
if (result > 0)
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getConceptAccountDR()
|
||||
{
|
||||
String sql = " HR_Revenue_Acct FROM HR_Concept c " +
|
||||
" INNER JOIN HR_Concept_Acct ca ON (c.HR_Concept_ID=ca.HR_Concept_ID)" +
|
||||
" WHERE c.HR_Concept_ID " + getHR_Concept_ID();
|
||||
int result = DB.getSQLValue("ConceptCR", sql);
|
||||
if (result > 0)
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // HRConcept
|
|
@ -21,6 +21,7 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
@ -62,7 +63,7 @@ public final class MHRPaySelectionCheck extends X_HR_PaySelectionCheck
|
|||
public static MHRPaySelectionCheck getOfPayment (Properties ctx, int C_Payment_ID, String trxName)
|
||||
{
|
||||
final String where = I_C_Payment.COLUMNNAME_C_Payment_ID + "=?";
|
||||
Collection<MHRPaySelectionCheck> pscs = new Query(ctx, I_HR_PaySelectionCheck.Table_Name, where , trxName)
|
||||
List<MHRPaySelectionCheck> pscs = new Query(ctx, I_HR_PaySelectionCheck.Table_Name, where , trxName)
|
||||
.setParameters(new Object[]{C_Payment_ID})
|
||||
.list();
|
||||
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||
*****************************************************************************/
|
||||
package org.eevolution.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.model.MCalendar;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
/**
|
||||
* Payroll for HRayroll Module
|
||||
*
|
||||
* @author Oscar Gómez Islas
|
||||
* @version $Id: HRPayroll.java,v 1.0 2005/10/05 ogomezi
|
||||
*
|
||||
* @author Cristina Ghita, www.arhipac.ro
|
||||
*/
|
||||
public class MHRPayroll extends X_HR_Payroll
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1407037967021019961L;
|
||||
/** Cache */
|
||||
private static CCache<Integer, MHRPayroll> s_cache = new CCache<Integer, MHRPayroll>(Table_Name, 10);
|
||||
/** Cache */
|
||||
private static CCache<String, MHRPayroll> s_cacheValue = new CCache<String, MHRPayroll>(Table_Name+"_Value", 10);
|
||||
|
||||
/**
|
||||
* Get Payroll by Value
|
||||
* @param ctx
|
||||
* @param value
|
||||
* @return payroll
|
||||
*/
|
||||
public static MHRPayroll forValue(Properties ctx, String value)
|
||||
{
|
||||
if (Util.isEmpty(value, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int AD_Client_ID = Env.getAD_Client_ID(ctx);
|
||||
final String key = AD_Client_ID+"#"+value;
|
||||
MHRPayroll payroll = s_cacheValue.get(key);
|
||||
if (payroll != null)
|
||||
{
|
||||
return payroll;
|
||||
}
|
||||
|
||||
final String whereClause = COLUMNNAME_Value+"=? AND AD_Client_ID IN (?,?)";
|
||||
payroll = new Query(ctx, Table_Name, whereClause, null)
|
||||
.setParameters(new Object[]{value, 0, AD_Client_ID})
|
||||
.setOnlyActiveRecords(true)
|
||||
.setOrderBy("AD_Client_ID DESC")
|
||||
.first();
|
||||
if (payroll != null)
|
||||
{
|
||||
s_cacheValue.put(key, payroll);
|
||||
s_cache.put(payroll.get_ID(), payroll);
|
||||
}
|
||||
return payroll;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Payroll by ID
|
||||
* @param ctx
|
||||
* @param HR_Payroll_ID
|
||||
* @return payroll
|
||||
*/
|
||||
public static MHRPayroll get(Properties ctx, int HR_Payroll_ID)
|
||||
{
|
||||
if (HR_Payroll_ID <= 0)
|
||||
return null;
|
||||
//
|
||||
MHRPayroll payroll = s_cache.get(HR_Payroll_ID);
|
||||
if (payroll != null)
|
||||
return payroll;
|
||||
//
|
||||
payroll = new MHRPayroll(ctx, HR_Payroll_ID, null);
|
||||
if (payroll.get_ID() == HR_Payroll_ID)
|
||||
{
|
||||
s_cache.put(HR_Payroll_ID, payroll);
|
||||
}
|
||||
else
|
||||
{
|
||||
payroll = null;
|
||||
}
|
||||
return payroll;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
* @param ctx context
|
||||
* @param HR_Payroll_ID id
|
||||
*/
|
||||
public MHRPayroll (Properties ctx, int HR_Payroll_ID, String trxName)
|
||||
{
|
||||
super (ctx, HR_Payroll_ID, trxName);
|
||||
if (HR_Payroll_ID == 0)
|
||||
{
|
||||
setProcessing (false); // N
|
||||
}
|
||||
} // HRPayroll
|
||||
|
||||
/**
|
||||
* Load Constructor
|
||||
* @param ctx context
|
||||
* @param rs result set
|
||||
*/
|
||||
public MHRPayroll (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super(ctx, rs, trxName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parent Constructor
|
||||
* @param parent parent
|
||||
*/
|
||||
public MHRPayroll (MCalendar calendar)
|
||||
{
|
||||
this (calendar.getCtx(), 0, calendar.get_TrxName());
|
||||
setClientOrg(calendar);
|
||||
//setC_Calendar_ID(calendar.getC_Calendar_ID());
|
||||
} // HRPayroll
|
||||
} // MPayroll
|
Loading…
Reference in New Issue