Revision: 10193
http://adempiere.svn.sourceforge.net/adempiere/?rev=10193&view=rev
Author: vpj-cd
Date: 2009-09-14 03:44:11 +0000 (Mon, 14 Sep 2009)
Log Message:
-----------
move code for branch/liberoHR the official branch to Libero Human Resource & Payroll
Removed Paths:
-------------
branches/libero/extension/eevolution/libero/src/main/java/org/compiere/acct/DocLine_Payroll.java
branches/libero/extension/eevolution/libero/src/main/java/org/compiere/acct/Doc_Payroll.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/form/VHRActionNotice.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/CalloutPayroll.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRAttribute.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRConcept.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRConceptCategory.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRDepartment.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHREmployee.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRMovement.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRPayroll.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRPayrollConcept.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRPeriod.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRProcess.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRYear.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/process/HRAttributeEmployee.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/process/HRCreateConcept.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/process/HRCreatePeriods.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/process/PayrollProcessing.java
branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/process/PayrollViaEMail.java
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/compiere/acct/DocLine_Payroll.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/compiere/acct/DocLine_Payroll.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/compiere/acct/DocLine_Payroll.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,98 +0,0 @@
-/******************************************************************************
- * 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 http://www.e-evolution.com *
- *****************************************************************************/
-package org.compiere.acct;
-
-import java.math.BigDecimal;
-
-import org.compiere.model.MBPartner;
-import org.compiere.util.Env;
-import org.eevolution.model.MHRConcept;
-import org.eevolution.model.MHRMovement;
-
-/**
- * Payroll Line
- *
- * @author Jorg Janke
- * @version $Id: DocLine_Payroll.java,v 1.4 2005/10/17 23:43:52 jjanke Exp $
- */
-public class DocLine_Payroll extends DocLine
-{
- /**
- * Constructor
- * @param line Payroll line
- * @param doc header
- */
- public DocLine_Payroll (MHRMovement line, Doc_Payroll doc)
- {
- super (line, doc);
- int C_BPartner_ID = line.getC_BPartner_ID();
- MBPartner bpartner = new MBPartner(Env.getCtx(),C_BPartner_ID,null);
- MHRConcept concept = MHRConcept.get(Env.getCtx(), line.getHR_Concept_ID());
- //
- m_HR_Concept_ID = concept.getHR_Concept_ID();
- m_HR_Process_ID = line.getHR_Process_ID();
- m_C_BPartner_ID = C_BPartner_ID;
- m_HR_Department_ID = line.getHR_Department_ID();
- m_C_BP_Group_ID = bpartner.getC_BP_Group_ID();
- m_AccountSign = concept.getAccountSign();
- m_Amount = line.getAmount();
- setAmount(line.getAmount());
- } // DocLine_Payroll
-
- // References
- private int m_HR_Process_ID = 0;
- private int m_HR_Concept_ID = 0;
- private int m_C_BPartner_ID = 0;
- private int m_C_Activity_ID = 0;
- private String m_AccountSign = "";
- private BigDecimal m_Amount = Env.ZERO;
- private int m_HR_Department_ID = 0;
- private int m_C_BP_Group_ID = 0;
-
- public int getHR_Process_ID(){
- return m_HR_Process_ID;
- }
-
- public int getHR_Concept_ID(){
- return m_HR_Concept_ID;
- }
-
- public String getAccountSign(){
- return m_AccountSign;
- }
-
- public int getC_BPartner_ID(){
- return m_C_BPartner_ID;
- }
-
- public int getC_Activity_ID(){
- return m_C_Activity_ID;
- }
-
-
- public BigDecimal getAmount() {
- return m_Amount;
- }
-
- public int getHR_Department_ID() {
- return m_HR_Department_ID;
- }
-
- public int getC_BP_Group_ID() {
- return m_C_BP_Group_ID;
- }
-
-} // DocLine_Payroll
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/compiere/acct/Doc_Payroll.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/compiere/acct/Doc_Payroll.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/compiere/acct/Doc_Payroll.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,195 +0,0 @@
-/******************************************************************************
- * 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 http://www.e-evolution.com *
- *****************************************************************************/
-package org.compiere.acct;
-
-import java.math.BigDecimal;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.logging.Level;
-
-import org.compiere.model.MAccount;
-import org.compiere.model.MAcctSchema;
-import org.compiere.model.MElementValue;
-import org.compiere.util.DB;
-import org.compiere.util.Env;
-import org.eevolution.model.MHRMovement;
-import org.eevolution.model.MHRProcess;
-import org.eevolution.model.X_HR_Concept_Acct;
-
-
-/**
- * Post Payroll Documents.
- * <pre>
- * Table: HR_Process (??)
- * Document Types: HR_Process
- * </pre>
- * @author Oscar Gomez Islas
- * @version $Id: Doc_Payroll.java,v 1.1 2007/01/20 00:40:02 ogomezi Exp $
- * @author Cristina Ghita, http://www.arhipac.ro
- */
-public class Doc_Payroll extends Doc
-{
- public MHRProcess process = null;
-
- /**
- * Constructor
- * @param ass accounting schema
- * @param rs record
- * @parem trxName trx
- */
- protected Doc_Payroll (MAcctSchema[] ass, ResultSet rs, String trxName)
- {
- super(ass, MHRProcess.class, rs, DOCTYPE_Payroll, trxName);
- } // Doc_Payroll
-
- @Override
- protected String loadDocumentDetails ()
- {
- process = (MHRProcess)getPO();
- setDateDoc(getDateAcct());
- // Contained Objects
- p_lines = loadLines(process);
- log.fine("Lines=" + p_lines.length);
- return null;
- } // loadDocumentDetails
-
-
- /**
- * Load Payroll Line
- * @param Payroll Process
- * @return DocLine Array
- */
- private DocLine[] loadLines(MHRProcess process)
- {
- ArrayList<DocLine> list = new ArrayList<DocLine>();
- MHRMovement[] lines = process.getLines(true);
- for (int i = 0; i < lines.length; i++)
- {
- MHRMovement line = lines[i];
- DocLine_Payroll docLine = new DocLine_Payroll (line, this);
- //
- log.fine(docLine.toString());
- list.add(docLine);
- }
- // Return Array
- DocLine[] dls = new DocLine[list.size()];
- list.toArray(dls);
- return dls;
- } // loadLines
-
- @Override
- public BigDecimal getBalance()
- {
- BigDecimal retValue = Env.ZERO;
- return retValue;
- } // getBalance
-
- @Override
- public ArrayList<Fact> createFacts (MAcctSchema as)
- {
- Fact fact = new Fact(this, as, Fact.POST_Actual);
- String sql= "SELECT m.HR_Concept_id, MAX(c.Name), SUM(m.Amount), MAX(c.AccountSign), MAX(CA.IsBalancing), e.AD_Org_ID, d.C_Activity_ID" // 1,2,3,4,5,6,7
- + " FROM HR_Movement m"
- + " INNER JOIN HR_Concept_Acct ca ON (ca.HR_Concept_ID=m.HR_Concept_ID AND ca.IsActive = 'Y')"
- + " INNER JOIN HR_Concept c ON (c.HR_Concept_ID=m.HR_Concept_ID AND c.IsActive = 'Y')"
- + " INNER JOIN C_BPartner bp ON (bp.C_BPartner_ID = m.C_BPartner_ID)"
- + " INNER JOIN HR_Employee e ON (bp.C_BPartner_ID=e.C_BPartner_ID)"
- + " INNER JOIN HR_Department d ON (d.HR_Department_ID=e.HR_Department_ID)"
- + " WHERE m.HR_Process_ID=? AND (m.Qty <> 0 OR m.Amount <> 0) AND c.AccountSign != 'N' AND ca.IsBalancing != 'Y'"
- + " GROUP BY m.HR_Concept_ID,e.AD_Org_ID,d.C_Activity_ID"
- + " ORDER BY e.AD_Org_ID,d.C_Activity_ID";
-
- ResultSet rs = null;
- PreparedStatement pstmt = null;
- try
- {
- pstmt = DB.prepareStatement (sql, process.get_TrxName());
- pstmt.setInt (1, process.getHR_Process_ID());
- rs = pstmt.executeQuery ();
- while (rs.next())
- {
- int HR_Concept_ID = rs.getInt(1);
- BigDecimal sumAmount = rs.getBigDecimal(3);
- // round amount according to currency
- sumAmount = sumAmount.setScale(as.getStdPrecision(), BigDecimal.ROUND_HALF_UP);
- String AccountSign = rs.getString(4);
- int AD_OrgTrx_ID=rs.getInt(6);
- int C_Activity_ID=rs.getInt(7);
- //
- if (AccountSign != null && AccountSign.length() > 0 && (AccountSign.equals("D") || AccountSign.equals("C"))) {
- // HR_Expense_Acct DR
- // HR_Revenue_Acct CR
- MAccount accountBPD = MAccount.get (getCtx(), getAccountBalancing(as.getC_AcctSchema_ID(),HR_Concept_ID,"D"));
- FactLine debit=fact.createLine(null, accountBPD,as.getC_Currency_ID(),sumAmount, null);
- debit.setAD_OrgTrx_ID(AD_OrgTrx_ID);
- debit.setC_Activity_ID(C_Activity_ID);
- debit.saveEx();
- MAccount accountBPC = MAccount.get (getCtx(),this.getAccountBalancing(as.getC_AcctSchema_ID(),HR_Concept_ID,"C"));
- FactLine credit = fact.createLine(null,accountBPC ,as.getC_Currency_ID(),null,sumAmount);
- credit.setAD_OrgTrx_ID(AD_OrgTrx_ID);
- credit.setC_Activity_ID(C_Activity_ID);
- credit.saveEx();
- }
- }
- }
- catch (Exception e)
- {
- log.log(Level.SEVERE, sql, e);
- p_Error = e.getLocalizedMessage();
- return null;
- }
- finally
- {
- DB.close(rs, pstmt);
- pstmt = null;
- rs = null;
- }
-
- ArrayList<Fact> facts = new ArrayList<Fact>();
- facts.add(fact);
- return facts;
- }
-
- /**
- * get account balancing
- * @param AcctSchema_ID
- * @param HR_Concept_ID
- * @param AccountSign D or C only
- * @return
- */
- private int getAccountBalancing (int AcctSchema_ID, int HR_Concept_ID, String AccountSign)
- {
- String field;
- if (MElementValue.ACCOUNTSIGN_Debit.equals(AccountSign))
- {
- field = X_HR_Concept_Acct.COLUMNNAME_HR_Expense_Acct;
- }
- else if (MElementValue.ACCOUNTSIGN_Credit.equals(AccountSign))
- {
- field = X_HR_Concept_Acct.COLUMNNAME_HR_Revenue_Acct;
- }
- else
- {
- throw new IllegalArgumentException("Invalid value for AccountSign="+AccountSign);
- }
- final String sqlAccount = "SELECT "+field+" FROM HR_Concept_Acct"
- + " WHERE HR_Concept_ID=? AND C_AcctSchema_ID=?";
- int Account_ID = DB.getSQLValueEx(getTrxName(), sqlAccount, HR_Concept_ID, AcctSchema_ID);
- return Account_ID;
- }
-
-} // Doc_Payroll
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/form/VHRActionNotice.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/form/VHRActionNotice.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/form/VHRActionNotice.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,719 +0,0 @@
-/******************************************************************************
- * 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 *
- * Contributor(s): Oscar Gomez & Victor Perez http://www.e-evolution.com *
- * Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
- *****************************************************************************/
-package org.eevolution.form;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
-import java.math.BigDecimal;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Timestamp;
-import java.util.EventObject;
-import java.util.logging.Level;
-
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JScrollPane;
-
-import org.compiere.apps.ADialog;
-import org.compiere.apps.ConfirmPanel;
-import org.compiere.apps.form.FormFrame;
-import org.compiere.apps.form.FormPanel;
-import org.compiere.grid.ed.VComboBox;
-import org.compiere.grid.ed.VDate;
-import org.compiere.grid.ed.VNumber;
-import org.compiere.minigrid.IDColumn;
-import org.compiere.minigrid.MiniTable;
-import org.compiere.model.MRefList;
-import org.compiere.model.MRole;
-import org.compiere.model.MTable;
-import org.compiere.plaf.CompiereColor;
-import org.compiere.swing.CLabel;
-import org.compiere.swing.CPanel;
-import org.compiere.swing.CTextField;
-import org.compiere.util.CLogger;
-import org.compiere.util.DB;
-import org.compiere.util.DisplayType;
-import org.compiere.util.Env;
-import org.compiere.util.KeyNamePair;
-import org.compiere.util.Msg;
-import org.eevolution.model.MHRConcept;
-import org.eevolution.model.MHREmployee;
-import org.eevolution.model.MHRMovement;
-import org.eevolution.model.MHRPeriod;
-import org.eevolution.model.MHRProcess;
-
-/**
- * @author Oscar Gomez
- * @author Cristina Ghita, http://www.arhipac.ro
- * @version $Id: VHRActionNotice.java
- *
- * Contributor: Carlos Ruiz (globalqss)
- * [ adempiere-Libero-2840048 ] Apply ABP to VHRActionNotice
- * [ adempiere-Libero-2840056 ] Payroll Action Notice - concept list wrong
- */
-public class VHRActionNotice extends CPanel implements FormPanel,VetoableChangeListener, ActionListener
-{
- /** @todo withholding */
-
- /**
- *
- */
- private static final long serialVersionUID = 5905687280280831354L;
- /**
- * Initialize Panel
- * @param WindowNo window
- * @param frame frame
- */
- public void init (int WindowNo, FormFrame frame)
- {
- log.info("");
- m_WindowNo = WindowNo;
- m_frame = frame;
- jbInit();
- dynInit();
- frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
- frame.setSize(1000, 400);
- } // init
-
- /** Window No */
- private int m_WindowNo = 0;
- /** FormFrame */
- private FormFrame m_frame;
-
- private int HR_Process_ID = 0;
- private int HR_Payroll_ID = 0;
- private int sHR_Movement_ID = 0; // // initial not exist record in Movement to actual date
- private Timestamp dateStart = null;
- private Timestamp dateEnd = null;
- /** Logger */
- private static CLogger log = CLogger.getCLogger(VHRActionNotice.class);
- //
- private CPanel mainPanel = new CPanel();
- private BorderLayout mainLayout = new BorderLayout();
- private CPanel parameterPanel = new CPanel();
- private CLabel labelProcess = new CLabel();
- private VComboBox fieldProcess; // = new VComboBox();
- private CLabel labelEmployee = new CLabel();
- private VComboBox fieldEmployee = new VComboBox();
- private CLabel labelColumnType = new CLabel();
- private CTextField fieldColumnType = new CTextField(18);
- private CLabel labelConcept = new CLabel();
- private VComboBox fieldConcept = new VComboBox();
- private JLabel labelValue = new JLabel();
- private VNumber fieldQty = new VNumber();
- private VNumber fieldAmount = new VNumber();
- private VDate fieldDate = new VDate();
- private CTextField fieldText = new CTextField(22);
- private VNumber fieldRuleE = new VNumber();
- private JLabel dataStatus = new JLabel();
- private JScrollPane dataPane = new JScrollPane();
- private MiniTable miniTable = new MiniTable();
- private CPanel commandPanel = new CPanel();
- private FlowLayout commandLayout = new FlowLayout();
- private JButton bOk = ConfirmPanel.createOKButton(true);
- private CLabel labelValidFrom = new CLabel();
- private VDate fieldValidFrom = new VDate();
- private CLabel labelDescription = new CLabel();
- private CTextField fieldDescription = new CTextField(22);
- private GridBagLayout parameterLayout = new GridBagLayout();
- /**
- * Static Init
- * @throws Exception
- */
- private void jbInit()
- {
- CompiereColor.setBackground(this);
- mainPanel.setLayout(mainLayout);
- ///mainPanel.setSize(500, 500);
- mainPanel.setPreferredSize(new Dimension(1000, 400));
- parameterPanel.setLayout(parameterLayout);
- // Process
- labelProcess.setText(Msg.translate(Env.getCtx(), "HR_Process_ID"));
- fieldProcess = new VComboBox(getProcess());
- fieldProcess.setMandatory(true);
- fieldProcess.addActionListener(this);
- // Employee
- labelEmployee.setText(Msg.translate(Env.getCtx(), "HR_Employee_ID"));
- fieldEmployee.setReadWrite(false);
- fieldEmployee.setMandatory(true);
- fieldEmployee.addActionListener(this);
- fieldEmployee.addVetoableChangeListener(this);
- // Concept
- labelConcept.setText(Msg.translate(Env.getCtx(), "HR_Concept_ID"));
- getConceptValid();
- fieldConcept.setReadWrite(false);
- fieldConcept.setMandatory(true);
- fieldConcept.addActionListener(this);
- // ValidFrom
- labelValidFrom.setText(Msg.translate(Env.getCtx(), "Date"));
- fieldValidFrom.setReadWrite(false);
- fieldValidFrom.setMandatory(true);
- fieldValidFrom.addVetoableChangeListener(this);
- // Description
- labelDescription.setText(Msg.translate(Env.getCtx(), "Description"));
- fieldDescription.setValue("");
- fieldDescription.setReadWrite(false);
- // ColumnType
- labelColumnType.setText(Msg.translate(Env.getCtx(), "ColumnType"));
- fieldColumnType.setReadWrite(false);
- // Qty-Amount-Date-Text-RuleEngine
- fieldQty.setReadWrite(false);
- fieldQty.setDisplayType(DisplayType.Quantity);
- fieldQty.setVisible(true);
- fieldAmount.setDisplayType(DisplayType.Amount);
- fieldAmount.setVisible(false);
- fieldDate.setVisible(false);
- fieldText.setVisible(false);
- fieldRuleE.setVisible(false);
- //
- bOk.addActionListener(this);
- //
- mainPanel.add(parameterPanel, BorderLayout.NORTH);
- // Process
- parameterPanel.add(labelProcess, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- parameterPanel.add(fieldProcess, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
- // Employee
- parameterPanel.add(labelEmployee, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- parameterPanel.add(fieldEmployee, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
- // ValidFrom
- parameterPanel.add(labelValidFrom, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
- ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- parameterPanel.add(fieldValidFrom, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
- // Concepto
- parameterPanel.add(labelConcept, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0
- ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- parameterPanel.add(fieldConcept, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- // ColumnType
- parameterPanel.add(labelColumnType, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
- ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- parameterPanel.add(fieldColumnType, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
- ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- // Qty-Amount-Date-Text-RuleEngine
- parameterPanel.add(labelValue, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
- ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- parameterPanel.add(fieldQty, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- parameterPanel.add(fieldAmount, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- parameterPanel.add(fieldDate, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- parameterPanel.add(fieldText, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- // Description
- parameterPanel.add(labelDescription, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
- ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- parameterPanel.add(fieldDescription, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- // Refresh
- parameterPanel.add(bOk, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0
- ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
- // Agree
- mainPanel.add(dataStatus, BorderLayout.SOUTH);
- mainPanel.add(dataPane, BorderLayout.CENTER);
- dataPane.getViewport().add(miniTable, null);
- //
- commandPanel.setLayout(commandLayout);
- commandLayout.setAlignment(FlowLayout.RIGHT);
- commandLayout.setHgap(10);
- } // jbInit
-
-
- /**
- * Dynamic Init.
- * - Load Bank Info
- * - Load BPartner
- * - Init Table
- */
- private void dynInit()
- {
- miniTable.addColumn("HR_Movement_ID"); // 0
- miniTable.addColumn("AD_Org_ID"); // 1
- miniTable.addColumn("HR_Concept_ID"); // 2
- miniTable.addColumn("ValidFrom"); // 3
- miniTable.addColumn("ColumnType"); // 4
- miniTable.addColumn("Qty"); // 5
- miniTable.addColumn("Amount"); // 6
- miniTable.addColumn("ServiceDate"); // 7
- miniTable.addColumn("Text"); // 8
- miniTable.addColumn("AD_Rule_ID"); // 9
- miniTable.addColumn("Description"); // 10
- // set details
- miniTable.setColumnClass(0, IDColumn.class, false, " ");
- miniTable.setColumnClass(1, String.class, true, Msg.translate(Env.getCtx(), "AD_Org_ID"));
- miniTable.setColumnClass(2, String.class, true, Msg.translate(Env.getCtx(), "HR_Concept_ID"));
- miniTable.setColumnClass(3, Timestamp.class, true, Msg.translate(Env.getCtx(), "ValidFrom"));
- miniTable.setColumnClass(4, String.class, true, Msg.translate(Env.getCtx(), "ColumnType"));
- miniTable.setColumnClass(5, BigDecimal.class, true, Msg.translate(Env.getCtx(), "Qty"));
- miniTable.setColumnClass(6, BigDecimal.class, true, Msg.translate(Env.getCtx(), "Amount"));
- miniTable.setColumnClass(7, Timestamp.class, true, Msg.translate(Env.getCtx(), "ServiceDate"));
- miniTable.setColumnClass(8, String.class, true, Msg.translate(Env.getCtx(), "Text"));
- miniTable.setColumnClass(9, String.class, true, Msg.translate(Env.getCtx(), "AD_Rule_ID"));
- miniTable.setColumnClass(10, String.class, true, Msg.translate(Env.getCtx(), "Description"));
- //
- miniTable.autoSize();
- } // dynInit
-
-
- /**
- * Dispose
- */
- public void dispose()
- {
- if (m_frame != null)
- m_frame.dispose();
- m_frame = null;
- } // dispose
-
-
- /**************************************************************************
- * vetoableChange
- * @param e event
- */
- public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
- {
- fieldConcept.setReadWrite(true);
- log.fine("Event"+ e);
- log.fine("Event Source "+ e.getSource());
- log.fine("Event Property "+ e.getPropertyName());
- processChangeEvent(e);
- Integer HR_Period_ID = new MHRProcess(Env.getCtx(),(Integer)fieldProcess.getValue(),null).getHR_Period_ID();
- String date = DB.TO_DATE((Timestamp)fieldValidFrom.getValue());
- int existRange = DB.getSQLValueEx(null,"SELECT * FROM HR_Period WHERE " +date+
- " >= StartDate AND "+date+ " <= EndDate AND HR_Period_ID = "+HR_Period_ID);
- // Exist of Range Payroll
- if ( existRange < 0){
- fieldConcept.setReadWrite(false);
- return;
- }
- if (fieldConcept != null)
- sHR_Movement_ID = seekMovement(); // exist movement record to date actual
- } // vetoableChange
-
-
- /**************************************************************************
- * Action Listener
- * @param e event
- */
- public void actionPerformed(ActionEvent e)
- {
- log.fine("Event "+ e);
- log.fine("Event Source "+ e.getSource());
-
- processChangeEvent(e);
- } // actionPerformed
-
-
- private void processChangeEvent(EventObject e) {
- if ( e.getSource().equals(fieldProcess) ) { // Process
- KeyNamePair pp = (KeyNamePair)fieldProcess.getSelectedItem();
- if (pp != null){
- HR_Process_ID = pp.getKey();
- MHRProcess process = new MHRProcess(Env.getCtx(),HR_Process_ID, null);
- MHRPeriod period = MHRPeriod.get(Env.getCtx(), process.getHR_Period_ID());
- dateStart= period.getStartDate();
- dateEnd = period.getEndDate();
- HR_Payroll_ID = process.getHR_Payroll_ID();
- getEmployeeValid(process);
- fieldEmployee.setReadWrite(true);
- }
- }
- else if ( e.getSource().equals(fieldEmployee) ){ // Employee
- KeyNamePair pp = (KeyNamePair)fieldEmployee.getSelectedItem();
- int C_BPartner_ID = 0;
- if ( pp != null )
- C_BPartner_ID = pp.getKey();
- if ( C_BPartner_ID > 0){
- fieldValidFrom.setValue(dateEnd);
- fieldValidFrom.setReadWrite(true);
- getConceptValid();
- fieldConcept.setReadWrite(true);
- executeQuery();
- }
- }
- else if ( e.getSource().equals(fieldConcept) ) { // Concept
- KeyNamePair pp = (KeyNamePair)fieldConcept.getSelectedItem();
- int HR_Concept_ID = 0;
- if (pp != null)
- HR_Concept_ID = pp.getKey();
- if (HR_Concept_ID > 0) {
- MHRConcept concept = MHRConcept.get(Env.getCtx(),HR_Concept_ID);
- // Name To Type Column
- fieldColumnType.setValue(DB.getSQLValueStringEx(null, getSQL_ColumnType("?"), concept.getColumnType() ));
- sHR_Movement_ID = seekMovement(); // exist movement record to date actual
- //
- if (concept.getColumnType().equals(MHRConcept.COLUMNTYPE_Quantity)){ // Concept Type
- fieldQty.setVisible(true);
- fieldQty.setReadWrite(true);
- fieldAmount.setVisible(false);
- fieldDate.setVisible(false);
- fieldText.setVisible(false);
- fieldRuleE.setVisible(false);
- } else if (concept.getColumnType().equals(MHRConcept.COLUMNTYPE_Amount)){
- fieldQty.setVisible(false);
- fieldAmount.setVisible(true);
- fieldAmount.setReadWrite(true);
- fieldDate.setVisible(false);
- fieldText.setVisible(false);
- fieldRuleE.setVisible(false);
- } else if (concept.getColumnType().equals(MHRConcept.COLUMNTYPE_Date)){
- fieldQty.setVisible(false);
- fieldAmount.setVisible(false);
- fieldDate.setVisible(true);
- fieldDate.setReadWrite(true);
- fieldText.setVisible(false);
- fieldRuleE.setVisible(false);
- } else if (concept.getColumnType().equals(MHRConcept.COLUMNTYPE_Text)){
- fieldText.setVisible(true);
- fieldText.setReadWrite(true);
- fieldAmount.setVisible(false);
- fieldDate.setVisible(false);
- fieldRuleE.setVisible(false);
- }
- fieldDescription.setReadWrite(true);
- }
- } // Concept
- else if (e instanceof ActionEvent && e.getSource().equals(bOk) ){ // Movement SAVE
- KeyNamePair pp = (KeyNamePair)fieldConcept.getSelectedItem();
- int HR_Concept_ID = pp.getKey();
- if ( HR_Concept_ID <= 0
- || fieldProcess.getValue() == null
- || ((Integer)fieldProcess.getValue()).intValue() <= 0
- || fieldEmployee.getValue() == null
- || ((Integer)fieldEmployee.getValue()).intValue() <= 0) { // required fields
- ADialog.error(m_WindowNo, this, Msg.translate(Env.getCtx(), "FillMandatory")
- + Msg.translate(Env.getCtx(), "HR_Process_ID") + ", "
- + Msg.translate(Env.getCtx(), "HR_Employee_ID") + ", "
- + Msg.translate(Env.getCtx(), "HR_Concept_ID"));
- } else {
- MHRConcept conceptOK = MHRConcept.get(Env.getCtx(),HR_Concept_ID);
- int mov = sHR_Movement_ID > 0 ? sHR_Movement_ID : 0;
- MHRMovement movementOK = new MHRMovement(Env.getCtx(),mov,null);
- movementOK.setDescription(fieldDescription.getValue() != null ? (String)fieldDescription.getValue().toString() : "");
- movementOK.setHR_Process_ID((Integer)fieldProcess.getValue());
- movementOK.setC_BPartner_ID((Integer)fieldEmployee.getValue());
- movementOK.setHR_Concept_ID((Integer)fieldConcept.getValue());
- movementOK.setHR_Concept_Category_ID(conceptOK.getHR_Concept_Category_ID());
- movementOK.setColumnType(conceptOK.getColumnType());
- movementOK.setQty(fieldQty.getValue() != null ? (BigDecimal)fieldQty.getValue() : Env.ZERO);
- movementOK.setAmount(fieldAmount.getValue() != null ? (BigDecimal)fieldAmount.getValue() : Env.ZERO );
- movementOK.setTextMsg(fieldText.getValue() != null ? (String)fieldText.getValue().toString() : "");
- movementOK.setServiceDate(fieldDate.getValue() != null ? (Timestamp)fieldDate.getValue() : null);
- movementOK.setValidFrom((Timestamp)fieldValidFrom.getTimestamp());
- movementOK.setValidTo((Timestamp)fieldValidFrom.getTimestamp());
- MHREmployee employee = MHREmployee.getActiveEmployee(Env.getCtx(), movementOK.getC_BPartner_ID(), null);
- if (employee != null) {
- movementOK.setHR_Department_ID(employee.getHR_Department_ID());
- movementOK.setHR_Job_ID(employee.getHR_Job_ID());
- movementOK.setC_Activity_ID(employee.getC_Activity_ID());
- }
- movementOK.setIsRegistered(true);
- movementOK.saveEx();
- executeQuery();
- fieldValidFrom.setValue(dateEnd);
- fieldColumnType.setValue("");
- fieldQty.setValue(Env.ZERO);
- fieldAmount.setValue(Env.ZERO);
- fieldQty.setReadWrite(false);
- fieldAmount.setReadWrite(false);
- fieldText.setReadWrite(false);
- fieldDescription.setReadWrite(false);
- sHR_Movement_ID = 0; // Initial not exist record in Movement to actual date
- // clear fields
- fieldDescription.setValue("");
- fieldText.setValue("");
- fieldDate.setValue(null);
- fieldQty.setValue(Env.ZERO);
- fieldAmount.setValue(Env.ZERO);
- fieldConcept.setSelectedIndex(0);
- }
- }
- } // processChangeEvent
-
-
- /**
- * Query Info
- */
- private void executeQuery()
- {
- StringBuffer sqlQuery = new StringBuffer("SELECT DISTINCT o.Name,hp.Name," // AD_Org_ID, HR_Process_ID -- 1,2
- + " bp.Name,hc.Name,hm.ValidFrom," // HR_Employee_ID,HR_Concept_ID,ValidFrom,ColumnType -- 3,4,5
- + "("+getSQL_ColumnType("hc.ColumnType")+") AS ColumnType," // 6 ColumnType(Reference Name)
- + " hm.Qty,hm.Amount,hm.ServiceDate,hm.TextMsg,er.Name,hm.Description " // Qty,Amount,ServiceDate,Text,AD_Rule_ID,Description -- 7,8,9,10,11,12
- + " , HR_Movement_id, hm.AD_Org_ID,hp.HR_Process_ID,hm.HR_Concept_ID " // to make the distinct useful
- + " FROM HR_Movement hm "
- + " INNER JOIN AD_Org o ON (hm.AD_Org_ID=o.AD_Org_ID)"
- + " INNER JOIN HR_Process hp ON (hm.HR_Process_ID=hp.HR_Process_ID)"
- + " INNER JOIN C_BPartner bp ON (hm.C_BPartner_ID=bp.C_BPartner_ID)"
- + " INNER JOIN HR_Employee e ON (e.C_BPartner_ID=bp.C_BPartner_ID)"
- + " INNER JOIN HR_Concept hc ON (hm.HR_Concept_ID=hc.HR_Concept_ID)"
- + " LEFT OUTER JOIN AD_Rule er ON (hm.AD_Rule_ID=er.AD_Rule_ID)"
- + " WHERE hm.Processed='N' AND hp.HR_Process_ID = " +fieldProcess.getValue()
- //+ " AND IsStatic = 'Y' " // Just apply incidences [add 30Dic2006 to see everything]
- + " AND hm.C_BPartner_ID = " + fieldEmployee.getValue()
- // + " AND (Qty > 0 OR Amount > 0 OR hm.TextMsg IS NOT NULL OR ServiceDate IS NOT NULL) "
- );
- if (fieldValidFrom.getValue() == null) {
- sqlQuery.append(" AND " +DB.TO_DATE(dateStart)+" >= hm.ValidFrom AND "+DB.TO_DATE(dateEnd)+" <= hm.ValidTo ");
- }
- sqlQuery.append(" ORDER BY hm.AD_Org_ID,hp.HR_Process_ID,bp.Name,hm.ValidFrom,hm.HR_Concept_ID");
- // reset table
- int row = 0;
- miniTable.setRowCount(row);
- // Execute
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- pstmt = DB.prepareStatement(sqlQuery.toString(), null);
- rs = pstmt.executeQuery();
- while (rs.next()) {
- // extend table
- miniTable.setRowCount(row+1);
- // set values
- miniTable.setColumnClass(0, IDColumn.class, false, " ");
- miniTable.setValueAt(rs.getString(1), row, 1); // AD_Org_ID
- miniTable.setValueAt(rs.getString(4), row, 2); // HR_Concept_ID
- miniTable.setValueAt(rs.getTimestamp(5), row, 3); // ValidFrom
- miniTable.setValueAt(rs.getString(6), row, 4); // ColumnType
- miniTable.setValueAt(rs.getObject(7) != null ? rs.getBigDecimal(7) : Env.ZERO, row, 5); // Qty
- miniTable.setValueAt(rs.getObject(8) != null ? rs.getBigDecimal(8) : Env.ZERO, row, 6); // Amount
- miniTable.setValueAt(rs.getTimestamp(9), row, 7); // ServiceDate
- miniTable.setValueAt(rs.getString(10), row, 8); // TextMsg
- miniTable.setValueAt(rs.getString(11), row, 9); // AD_Rule_ID
- miniTable.setValueAt(rs.getString(12), row, 10); // Description
- // prepare next
- row++;
- }
- }
- catch (SQLException e) {
- log.log(Level.SEVERE, sqlQuery.toString(), e);
- }
- finally {
- DB.close(rs, pstmt);
- rs = null; pstmt = null;
- }
- miniTable.autoSize();
- } // executeQuery
-
-
-
- /**
- * get Process
- * parameter: MHRProcess
- */
- private KeyNamePair[] getProcess()
- {
- String sql = MRole.getDefault().addAccessSQL(
- "SELECT hrp.HR_Process_ID,hrp.DocumentNo ||'-'|| hrp.Name,hrp.DocumentNo,hrp.Name FROM HR_Process hrp",
- "hrp",MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO) + " AND hrp.IsActive = 'Y' ";
- sql += " ORDER BY hrp.DocumentNo, hrp.Name";
-
- return DB.getKeyNamePairs(sql, true);
- } //getProcess
-
-
-
- /**
- * get Employee
- * to Valid Payroll-Departmant-Employee of Process Actual
- * parameter: MHRProcess
- */
- private void getEmployeeValid(MHRProcess process)
- {
- if (process == null)
- return;
- fieldEmployee.removeAllItems(); // Clean before adding
- KeyNamePair pp = new KeyNamePair(0, "");
- fieldEmployee.addItem(pp);
- String sql = MRole.getDefault().addAccessSQL(
- "SELECT DISTINCT bp.C_BPartner_ID,bp.Name FROM HR_Employee hrpe INNER JOIN C_BPartner bp ON(bp.C_BPartner_ID=hrpe.C_BPartner_ID)",
- "hrpe",MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO) + " AND hrpe.IsActive = 'Y' ";
- if ( process.getHR_Payroll_ID() != 0){
- sql += " AND (hrpe.HR_Payroll_ID =" +process.getHR_Payroll_ID()+ " OR hrpe.HR_Payroll_ID is NULL)" ;
- /*if ( process.getHR_Department_ID() != 0 );
- sql += " AND (hrpe.HR_Department_ID =" +process.getHR_Department_ID()+" OR hrpe.HR_Department_ID is NULL)" ;
- if ( process.getHR_Employee_ID() != 0 );
- sql += " AND (hrpe.HR_Employee_ID =" + process.getHR_Employee_ID()+" OR hrpe.HR_Employee_ID is NULL)" ;*/
- }
- sql += " ORDER BY bp.Name ";
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- try{
- pstmt = DB.prepareStatement(sql, null);
- rs = pstmt.executeQuery();
- while (rs.next())
- {
- pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
- fieldEmployee.addItem(pp);
- }
- }
- catch (SQLException e)
- {
- log.log(Level.SEVERE, sql, e);
- }
- finally
- {
- DB.close(rs, pstmt);
- rs = null; pstmt = null;
- }
- fieldEmployee.setSelectedIndex(0);
- } //getEmployeeValid
-
-
-
- /**
- * get Concept
- * to Valide Dates of Process
- * parameter: MHRProcess
- */
- private void getConceptValid()
- {
- if( fieldProcess == null )
- return;
- fieldConcept.removeAllItems(); // Clean list before adding
- KeyNamePair pp = new KeyNamePair(0, "");
- fieldConcept.addItem(pp);
- 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.IsRegistered = 'Y' AND hrpc.Type != 'E'"
- + " AND (hrpa.HR_Payroll_ID = " +HR_Payroll_ID+ " OR hrpa.HR_Payroll_ID IS NULL)";
- if (fieldProcess != null)
- { // Process
- ; //sql += " AND " +DB.TO_DATE(dateStart)+ " >= hrpa.ValidFrom AND " +DB.TO_DATE(dateEnd)+ "<= hrpa.ValidTo";
- /* if (process.getHR_Payroll_ID() != 0) // Process & Payroll
- sql = sql + " AND (hrpa.HR_Payroll_ID = " +process.getHR_Payroll_ID()+ " OR hrpa.HR_Payroll_ID is NULL)" ;
- if (process.getHR_Department_ID() != 0 ); // Process & Department
- sql = sql + " AND (hrpa.HR_Department_ID = " +process.getHR_Department_ID()+" OR hrpa.HR_Department_ID is NULL)" ;
- if (process.getHR_Department_ID() != 0 ); // Process & Employee
- sql = sql + " AND (hrpa.HR_Employee_ID = " + process.getHR_Employee_ID()+" OR hrpa.HR_Employee_ID is NULL)" ;*/
- }
- sql = sql +" ORDER BY hrpc.Value";
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- pstmt = DB.prepareStatement(sql, null);
- rs = pstmt.executeQuery();
- while (rs.next()){
- pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
- fieldConcept.addItem(pp);
- }
- rs.close();
- pstmt.close();
- }
- catch (SQLException e)
- {
- log.log(Level.SEVERE, sql, e);
- }
- finally
- {
- DB.close(rs,pstmt);
- rs=null; pstmt = null;
- }
- fieldConcept.setSelectedIndex(0);
- } //getConceptValid
-
-
- /**
- * get record Found to Movement Payroll
- * parameter:
- */
- public int seekMovement()
- {
- if(fieldConcept.getValue() == null )
- return 0;
- int HR_Movement_ID = 0;
- String date = DB.TO_DATE((Timestamp)fieldValidFrom.getValue());
- int Process_ID = 0; KeyNamePair ppp = (KeyNamePair)fieldProcess.getSelectedItem();
- int Employee_ID = 0; KeyNamePair ppe = (KeyNamePair)fieldEmployee.getSelectedItem();
- int Concept_ID = 0; KeyNamePair ppc = (KeyNamePair)fieldConcept.getSelectedItem();
- //
- Process_ID = ppp != null ? ppp.getKey(): null;
- Employee_ID = ppe != null ? ppe.getKey(): null;
- Concept_ID = ppc != null ? ppc.getKey(): null;
- MHRConcept concept = MHRConcept.get(Env.getCtx(),Concept_ID);
- //
- if ( (Process_ID+Employee_ID+Concept_ID) > 0 ){
- HR_Movement_ID = DB.getSQLValue(null,"SELECT HR_Movement_ID "
- +" FROM HR_Movement WHERE HR_Process_ID = "+Process_ID
- +" AND C_BPartner_ID =" +Employee_ID+ " AND HR_Concept_ID = "+Concept_ID
- +" AND TRUNC(ValidFrom) = TRUNC(" + date +")");
- if (HR_Movement_ID > 0){ // exist record in Movement Payroll
- sHR_Movement_ID = HR_Movement_ID;
- MHRMovement movementFound = new MHRMovement(Env.getCtx(),sHR_Movement_ID,null);
- //
- fieldDescription.setValue(movementFound.getDescription());
- // clear fields
- fieldText.setValue("");
- fieldDate.setValue(null);
- fieldQty.setValue(Env.ZERO);
- fieldAmount.setValue(Env.ZERO);
- // assign just corresponding field
- if ( concept.getColumnType().equals(MHRConcept.COLUMNTYPE_Quantity) ) // Quantity
- fieldQty.setValue(movementFound.getQty());
- else if (concept.getColumnType().equals(MHRConcept.COLUMNTYPE_Amount) ) // Amount
- fieldAmount.setValue(movementFound.getAmount());
- else if (concept.getColumnType().equals(MHRConcept.COLUMNTYPE_Text) ) // Text
- fieldText.setValue(movementFound.getTextMsg());
- else if (concept.getColumnType().equals(MHRConcept.COLUMNTYPE_Date) ) // Date
- fieldDate.setValue(movementFound.getServiceDate());
- }
- }
- return HR_Movement_ID;
- } //seekMovement
-
- /**
- * Get SQL Code of ColumnType for given sqlValue
- * @param sqlValue
- * @return sql select code
- */
- private String getSQL_ColumnType(String sqlValue) {
- int columnType_Ref_ID = MTable.get(Env.getCtx(), MHRConcept.Table_ID)
- .getColumn(MHRConcept.COLUMNNAME_ColumnType)
- .getAD_Reference_Value_ID();
- String sql;
- if (Env.isBaseLanguage(Env.getCtx(), MRefList.Table_Name)) {
- sql = "SELECT zz.Name FROM AD_Ref_List zz WHERE zz.AD_Reference_ID="+columnType_Ref_ID;
- }
- else {
- sql = "SELECT zz.Name FROM AD_Ref_List zz, AD_Ref_List_Trl zzt"
- +" WHERE zz.AD_Reference_ID="+columnType_Ref_ID
- +" AND zzt.AD_Ref_List_ID=zz.AD_Ref_List_ID"
- +" AND zzt.AD_Language="+DB.TO_STRING(Env.getAD_Language(Env.getCtx()));
- }
- sql += " AND zz.Value = "+sqlValue;
- return sql;
- } // getSQL_ColumnType
-
-} // VHRActionNotice
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/CalloutPayroll.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/CalloutPayroll.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/CalloutPayroll.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,46 +0,0 @@
-/******************************************************************************
- * The contents of this file are subject to the Compiere License Version 1.1
- * ("License"); You may not use this file except in compliance with the License
- * You may obtain a copy of the License at http://www.compiere.org/license.html
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
- * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
- * are Copyright (C) 1999-2005 Jorg Janke.
- * All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
- * Contributor(s): ______________________________________.
- *****************************************************************************/
-package org.eevolution.model;
-
-import java.util.Properties;
-
-import org.compiere.model.CalloutEngine;
-import org.compiere.model.GridField;
-import org.compiere.model.GridTab;
-import org.compiere.util.DB;
-
-/**
- * Payroll Callouts.
- * org.eevolution.model.CalloutPayroll.*
- *
- *
- * @version $Id: CalloutPayment.java,v 1.17 2005/11/06 01:17:27 jjanke Exp $
- */
-public class CalloutPayroll extends CalloutEngine
-{
- public String ColumnType (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
- {
- if (value == null)
- return "";
- final int HR_Concept_ID = (Integer) value;
- if (HR_Concept_ID == 0)
- return "";
- //
- final String columnType = DB.getSQLValueStringEx(null,
- "SELECT ColumnType FROM HR_Concept WHERE HR_Concept_ID=?",
- HR_Concept_ID);
- mTab.setValue(MHRAttribute.COLUMNNAME_ColumnType, columnType);
- return "";
- }
-} // CalloutPayroll
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRAttribute.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRAttribute.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRAttribute.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,126 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 2008 SC ARHIPAC SERVICE SRL. All Rights Reserved. *
- * 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. *
- *****************************************************************************/
-package org.eevolution.model;
-
-import java.sql.ResultSet;
-import java.sql.Timestamp;
-import java.util.Properties;
-
-import org.compiere.model.Query;
-import org.compiere.util.Env;
-import org.compiere.util.Util;
-
-/**
- * HR Attribute Model
- * @author Cristina Ghita, http://www.arhipac.ro
- *
- */
-public class MHRAttribute extends X_HR_Attribute
-{
- private static final long serialVersionUID = 3783311896401143394L;
-
-
- /**
- * @deprecated since 3.5.3a
- * Get Concept by Value
- * @param ctx
- * @param value
- * @param C_BPartner_ID
- * @param startDate
- * @return attribute
- */
- public static MHRAttribute forValue(Properties ctx, String value, int C_BPartner_ID, Timestamp date)
- {
- if (Util.isEmpty(value, true))
- {
- return null;
- }
-
- int AD_Client_ID = Env.getAD_Client_ID(ctx);
-
- final String whereClause = COLUMNNAME_C_BPartner_ID+"=? AND AD_Client_ID IN (?,?) "
- + " AND " + COLUMNNAME_ValidFrom +"<=?"
- + " AND EXISTS (SELECT 1 FROM HR_Concept c WHERE HR_Attribute.HR_Concept_ID = c.HR_Concept_ID"
- + " AND c.Value=?)";
- MHRAttribute att = new Query(ctx, Table_Name, whereClause, null)
- .setParameters(new Object[]{C_BPartner_ID, 0, AD_Client_ID, date, value})
- .setOnlyActiveRecords(true)
- .setOrderBy(COLUMNNAME_ValidFrom + " DESC")
- .first();
- return att;
- }
-
- /**
- * Get Concept by Value
- * @param ctx
- * @param value
- * @param C_BPartner_ID
- * @param startDate
- * @param endDate
- * @return attribute
- */
- public static MHRAttribute forValue(Properties ctx, String value, int C_BPartner_ID, Timestamp startDate, Timestamp endDate)
- {
- if (Util.isEmpty(value, true))
- {
- return null;
- }
-
- if (endDate == null)
- {
- return forValue(ctx, value, C_BPartner_ID, startDate);
- }
- else
- {
- int AD_Client_ID = Env.getAD_Client_ID(ctx);
-
- final String whereClause = COLUMNNAME_C_BPartner_ID+"=? AND AD_Client_ID IN (?,?) "
- + " AND " + COLUMNNAME_ValidFrom +"<=? AND " + COLUMNNAME_ValidTo +">=?"
- + " AND EXISTS (SELECT 1 FROM HR_Concept c WHERE HR_Attribute.HR_Concept_ID = c.HR_Concept_ID"
- + " AND c.Value=?)";
- MHRAttribute att = new Query(ctx, Table_Name, whereClause, null)
- .setParameters(new Object[]{C_BPartner_ID, 0, AD_Client_ID, startDate, endDate, value})
- .setOnlyActiveRecords(true)
- .setOrderBy(COLUMNNAME_ValidFrom + " DESC")
- .first();
- return att;
- }
- }
-
- /**
- * @param ctx
- * @param HR_Attribute_ID
- * @param trxName
- */
- public MHRAttribute(Properties ctx, int HR_Attribute_ID, String trxName)
- {
- super(ctx, HR_Attribute_ID, trxName);
- }
-
- /**
- * @param ctx
- * @param rs
- * @param trxName
- */
- public MHRAttribute(Properties ctx, ResultSet rs, String trxName)
- {
- super(ctx, rs, trxName);
- }
-
- @Override
- public I_HR_Concept getHR_Concept()
- {
- return MHRConcept.get(getCtx(), getHR_Concept_ID());
- }
-}
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRConcept.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRConcept.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRConcept.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,201 +0,0 @@
-/******************************************************************************
- * 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 http://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, http://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
\ No newline at end of file
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRConceptCategory.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRConceptCategory.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRConceptCategory.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,91 +0,0 @@
-/**
- *
- */
-package org.eevolution.model;
-
-import java.sql.ResultSet;
-import java.util.Properties;
-
-import org.compiere.model.Query;
-import org.compiere.util.CCache;
-import org.compiere.util.Env;
-
-/**
- * HR Concept Category
- *
- * @author Cristina Ghita, http://www.arhipac.ro
- */
-public class MHRConceptCategory extends X_HR_Concept_Category
-{
-
- /**
- *
- */
- private static final long serialVersionUID = 8470029939291479283L;
-
- private static CCache<Integer, MHRConceptCategory> s_cache = new CCache<Integer, MHRConceptCategory>(Table_Name, 20);
- private static CCache<String, MHRConceptCategory> s_cacheValue = new CCache<String, MHRConceptCategory>(Table_Name+"_Value", 20);
-
- public static MHRConceptCategory get(Properties ctx, int HR_Concept_Category_ID)
- {
- if (HR_Concept_Category_ID <= 0)
- {
- return null;
- }
- // Try cache
- MHRConceptCategory cc = s_cache.get(HR_Concept_Category_ID);
- if (cc != null)
- {
- return cc;
- }
- // Load from DB
- cc = new MHRConceptCategory(ctx, HR_Concept_Category_ID, null);
- if (cc.get_ID() != HR_Concept_Category_ID)
- {
- return null;
- }
- if (cc != null)
- {
- s_cache.put(HR_Concept_Category_ID, cc);
- }
- return cc;
- }
-
- public static MHRConceptCategory forValue(Properties ctx, String value)
- {
- if (value == null)
- {
- return null;
- }
- final int AD_Client_ID = Env.getAD_Client_ID(ctx);
- // Try cache
- final String key = AD_Client_ID+"#"+value;
- MHRConceptCategory cc = s_cacheValue.get(key);
- if (cc != null)
- {
- return cc;
- }
- // Try database
- final String whereClause = COLUMNNAME_Value+"=? AND AD_Client_ID IN (?,?)";
- cc = new Query(ctx, Table_Name, whereClause, null)
- .setParameters(new Object[]{value, 0, AD_Client_ID})
- .setOnlyActiveRecords(true)
- .setOrderBy("AD_Client_ID DESC")
- .first();
- if (cc != null)
- {
- s_cacheValue.put(key, cc);
- s_cache.put(cc.get_ID(), cc);
- }
- return cc;
- }
-
- public MHRConceptCategory(Properties ctx, int HR_Concept_Category_ID, String trxName)
- {
- super(ctx, HR_Concept_Category_ID, trxName);
- }
- public MHRConceptCategory(Properties ctx, ResultSet rs, String trxName)
- {
- super(ctx, rs, trxName);
- }
-}
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRDepartment.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRDepartment.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRDepartment.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,93 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 2008 SC ARHIPAC SERVICE SRL. All Rights Reserved. *
- * 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. *
- *****************************************************************************/
-package org.eevolution.model;
-
-import java.sql.ResultSet;
-import java.util.List;
-import java.util.Properties;
-
-import org.compiere.model.Query;
-import org.compiere.util.CCache;
-import org.compiere.util.Env;
-
-/**
- * @author Cristina Ghita, http://www.arhipac.ro
- *
- */
-public class MHRDepartment extends X_HR_Department
-{
- /**
- *
- */
- private static final long serialVersionUID = 83878114891519775L;
-
- public static List<MHRDepartment> getAll(Properties ctx)
- {
- List<MHRDepartment> list = new Query(Env.getCtx(), X_HR_Department.Table_Name, "AD_Client_ID=?", null)
- .setParameters(new Object[] {Env.getAD_Client_ID(ctx)})
- .setOrderBy(COLUMNNAME_Name)
- .list();
- for (MHRDepartment dep : list)
- {
- s_cache.put(dep.get_ID(), dep);
- }
- return list;
- }
-
- public static MHRDepartment get(Properties ctx, int HR_Department_ID)
- {
- if (HR_Department_ID <= 0)
- {
- return null;
- }
-
- if (s_cache.size() == 0)
- {
- getAll(ctx);
- }
- MHRDepartment dep = s_cache.get(HR_Department_ID);
- if (dep != null)
- {
- return dep;
- }
- dep = new MHRDepartment(ctx, HR_Department_ID, null);
- if (dep.get_ID() == HR_Department_ID)
- {
- s_cache.put(HR_Department_ID, dep);
- }
- return dep;
- }
-
- private static CCache<Integer, MHRDepartment> s_cache = new CCache<Integer, MHRDepartment>(Table_Name, 50, 0);
-
- /**
- * @param ctx
- * @param HR_Department_ID
- * @param trxName
- */
- public MHRDepartment(Properties ctx, int HR_Department_ID, String trxName)
- {
- super(ctx, HR_Department_ID, trxName);
- }
-
- /**
- * @param ctx
- * @param rs
- * @param trxName
- */
- public MHRDepartment(Properties ctx, ResultSet rs, String trxName)
- {
- super(ctx, rs, trxName);
- }
-}
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHREmployee.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHREmployee.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHREmployee.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,157 +0,0 @@
-/******************************************************************************
- * 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 http://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.MBPartner;
-import org.compiere.model.Query;
-import org.compiere.util.CCache;
-import org.compiere.util.Env;
-
-
-/**
- * HR Employee Model
- *
- * @author Victor Perez
- * @author Cristina Ghita, http://www.arhipac.ro
- */
-public class MHREmployee extends X_HR_Employee
-{
- private static final long serialVersionUID = -7083160315471023587L;
-
- public static MHREmployee get(Properties ctx, int HR_Employee_ID)
- {
- if (HR_Employee_ID <= 0)
- return null;
- //
- MHREmployee employee = s_cache.get(HR_Employee_ID);
- if (employee != null)
- return employee;
- //
- employee = new MHREmployee(ctx, HR_Employee_ID, null);
- if (employee.get_ID() == HR_Employee_ID)
- {
- s_cache.put(HR_Employee_ID, employee);
- }
- else
- {
- employee = null;
- }
- return employee;
- }
-
- /**
- * Get Employees of Process
- * @param p HR Process
- * @return Array of Business Partners
- */
- public static MBPartner[] getEmployees (MHRProcess p)
- {
- List<Object> params = new ArrayList<Object>();
- StringBuffer whereClause = new StringBuffer();
- whereClause.append(" C_BPartner.C_BPartner_ID IN (SELECT e.C_BPartner_ID FROM HR_Employee e WHERE e.IsActive=?");
- // Just active employee
- params.add(true);
-
- // This payroll not content periods, NOT IS a Regular Payroll > ogi-cd 28Nov2007
- if(p.getHR_Payroll_ID() != 0 && p.getHR_Period_ID() != 0)
- {
- whereClause.append(" AND (e.HR_Payroll_ID IS NULL OR e.HR_Payroll_ID=?) " );
- params.add(p.getHR_Payroll_ID());
- }
-
- // HR Period
- if(p.getHR_Period_ID() == 0)
- {
- whereClause.append(" AND e.StartDate <=? ");
- params.add(p.getDateAcct());
- }
- else
- {
- whereClause.append(" AND e.StartDate <=? ");
- params.add(new X_HR_Period(p.getCtx(), p.getHR_Period_ID(), null).getEndDate());
- }
-
- // Selected Department
- if (p.getHR_Department_ID() != 0)
- {
- whereClause.append(" AND e.HR_Department_ID =? ");
- params.add(p.getHR_Department_ID());
- }
-
- whereClause.append(" ) "); // end select from HR_Employee
-
- // Selected Employee
- if (p.getC_BPartner_ID() != 0)
- {
- whereClause.append(" AND C_BPartner_ID =? ");
- params.add(p.getC_BPartner_ID());
- }
-
- //client
- whereClause.append(" AND AD_Client_ID =? ");
- params.add(p.getAD_Client_ID());
-
- List<MBPartner> list = new Query(p.getCtx(), MBPartner.Table_Name, whereClause.toString(), p.get_TrxName())
- .setParameters(params)
- .setOnlyActiveRecords(true)
- .setOrderBy(COLUMNNAME_Name)
- .list();
-
- return list.toArray(new MBPartner[list.size()]);
- } // getEmployees
-
- public static MHREmployee getActiveEmployee(Properties ctx, int C_BPartner_ID, String trxName)
- {
- return new Query(ctx, Table_Name, COLUMNNAME_C_BPartner_ID+"=?", trxName)
- .setOnlyActiveRecords(true)
- .setParameters(new Object[]{C_BPartner_ID})
- .setOrderBy(COLUMNNAME_HR_Employee_ID+" DESC") // just in case...
- .first();
- }
-
- /** Cache */
- private static CCache<Integer, MHREmployee> s_cache = new CCache<Integer, MHREmployee>(Table_Name, 1000);
-
- /**************************************************************************
- * Invoice Line Constructor
- * @param ctx context
- * @param HR_Employee_ID ID Employee
- * @param trxName transaction name
- */
- public MHREmployee (Properties ctx, int HR_Employee_ID, String trxName) //--
- {
- super (ctx, HR_Employee_ID, trxName);
- if (HR_Employee_ID == 0)
- {
- setClientOrg(Env.getAD_Client_ID(Env.getCtx()), Env.getAD_Org_ID(Env.getCtx()));
- }
- } // MHREmployee
-
- /**
- * Load Constructor
- * @param ctx context
- * @param rs result set record
- */
- public MHREmployee (Properties ctx, ResultSet rs, String trxName)
- {
- super(ctx, rs, trxName);
- } // MHREmployee
-} // MHREmployee
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRMovement.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRMovement.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRMovement.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,133 +0,0 @@
-/******************************************************************************
- * 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 http://www.e-evolution.com *
- *****************************************************************************/
-package org.eevolution.model;
-import java.math.BigDecimal;
-import java.sql.ResultSet;
-import java.sql.Timestamp;
-import java.util.Properties;
-
-import org.adempiere.exceptions.AdempiereException;
-import org.compiere.util.Env;
-import org.compiere.util.Util;
-
-/**
- * Payroll Concept for HRayroll Module
- *
- * @author Oscar Gómez Islas
- * @author Teo Sarca, http://www.arhipac.ro
- */
-public class MHRMovement extends X_HR_Movement
-{
- /**
- *
- */
- private static final long serialVersionUID = 6705848510397126140L;
-
- /**
- * Standard Constructor
- * @param ctx context
- * @param HR_Concept_ID
- * @param trxName
- */
- public MHRMovement (Properties ctx, int HR_Movement_ID, String trxName)
- {
- super (ctx, HR_Movement_ID, trxName);
- }
-
- /**
- * Load Constructor
- * @param ctx context
- * @param rs result set
- * @param trxName
- */
- public MHRMovement (Properties ctx, ResultSet rs, String trxName)
- {
- super(ctx, rs, trxName);
- }
-
- public MHRMovement (MHRProcess proc, I_HR_Concept concept)
- {
- this(proc.getCtx(), 0, proc.get_TrxName());
- // Process
- this.setHR_Process_ID(proc.getHR_Process_ID());
- // Concept
- this.setHR_Concept_Category_ID(concept.getHR_Concept_Category_ID());
- this.setHR_Concept_ID(concept.getHR_Concept_ID());
- this.setColumnType(concept.getColumnType());
- }
-
- public void addAmount(BigDecimal amount)
- {
- setAmount(getAmount().add(amount == null ? Env.ZERO : amount));
- }
-
- public void addQty(BigDecimal qty)
- {
- setQty(getAmount().add(qty == null ? Env.ZERO : qty));
- }
-
- /**
- * @return true if all movement values (Amount, Qty, Text) are empty
- */
- public boolean isEmpty()
- {
- return getQty().signum() == 0
- && getAmount().signum() == 0
- && Util.isEmpty(getTextMsg());
- }
-
- /**
- * According to the concept type, it's saved in the column specified for the purpose
- * @param columnType column type (see MHRConcept.COLUMNTYPE_*)
- * @param value
- */
- public void setColumnValue(Object value)
- {
- final String columnType = getColumnType();
- if (MHRConcept.COLUMNTYPE_Quantity.equals(columnType))
- {
- BigDecimal qty = new BigDecimal(value.toString());
- setQty(qty);
- setAmount(Env.ZERO);
- }
- else if(MHRConcept.COLUMNTYPE_Amount.equals(columnType))
- {
- BigDecimal amount = new BigDecimal(value.toString());
- setAmount(amount);
- setQty(Env.ZERO);
- }
- else if(MHRConcept.COLUMNTYPE_Text.equals(columnType))
- {
- setTextMsg(value.toString().trim());
- }
- else if(MHRConcept.COLUMNTYPE_Date.equals(columnType))
- {
- if (value instanceof Timestamp)
- {
- setServiceDate((Timestamp)value);
- }
- else
- {
- setServiceDate(Timestamp.valueOf(value.toString().trim().substring(0, 10)+ " 00:00:00.0"));
- }
- }
- else
- {
- throw new AdempiereException("@NotSupported@ @ColumnType@ - "+columnType);
- }
-
- }
-} // HRMovement
\ No newline at end of file
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRPayroll.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRPayroll.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRPayroll.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,142 +0,0 @@
-/******************************************************************************
- * 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 http://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, http://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
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRPayrollConcept.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRPayrollConcept.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRPayrollConcept.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,107 +0,0 @@
-/******************************************************************************
- * 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 http://www.e-evolution.com *
- *****************************************************************************/
-package org.eevolution.model;
-
-import java.sql.ResultSet;
-import java.util.List;
-import java.util.Properties;
-
-import org.compiere.model.Query;
-import org.compiere.util.DB;
-
-/**
- * Payroll Concept for HRayroll Module
- *
- * @author Oscar Gómez Islas
- * @version $Id: HRPayrollConcept.java,v 1.0 2005/10/05 ogomezi
- *
- * @author Cristina Ghita, http://www.arhipac.ro
- */
-public class MHRPayrollConcept extends X_HR_PayrollConcept
-{
- /**
- *
- */
- private static final long serialVersionUID = -4335196239535511224L;
-
- /**
- * Standard Constructor
- * @param ctx context
- * @param HR_Concept_ID id
- */
- public MHRPayrollConcept (Properties ctx, int HR_Concept_ID, String trxName)
- {
- super (ctx, HR_Concept_ID, trxName);
- } // HRConcept
-
- /**
- * Load Constructor
- * @param ctx context
- * @param rs result set
- */
- public MHRPayrollConcept (Properties ctx, ResultSet rs, String trxName)
- {
- super(ctx, rs, trxName);
- }
-
- /**
- * Concept constructor
- * @param concept
- */
- public MHRPayrollConcept (MHRConcept concept, int payroll_id, String trxName)
- {
- super(concept.getCtx(), 0, trxName);
- setHR_Payroll_ID(payroll_id);
- setHR_Concept_ID(concept.get_ID());
- setName(concept.getName());
- setSeqNo(concept.getSeqNo());
- //setAD_Rule_Engine_ID(concept.getAD_Rule_Engine_ID());
- //setIsIncluded(true);
- setIsActive(true);
- }
-
- /**
- * Get Concept's of Payroll Type
- * @param p HR process
- * @return array of HR concepts
- */
- public static MHRPayrollConcept[] getPayrollConcepts (MHRProcess p)
- {
- List<MHRPayrollConcept> list = new Query(p.getCtx(), Table_Name, COLUMNNAME_HR_Payroll_ID+"=?", null)
- .setOnlyActiveRecords(true)
- .setParameters(new Object[]{p.getHR_Payroll_ID()})
- .setOrderBy(COLUMNNAME_SeqNo)
- .list();
- return list.toArray(new MHRPayrollConcept[list.size()]);
- }
-
- @Override
- protected boolean beforeSave(boolean newRecord)
- {
- if (getSeqNo() == 0)
- {
- String sql = "SELECT COALESCE(MAX(SeqNo),0) FROM HR_PayrollConcept WHERE HR_Payroll_ID=?";
- int lastSeqNo = DB.getSQLValueEx(get_TrxName(), sql, getHR_Payroll_ID());
- if (lastSeqNo < 0)
- lastSeqNo = 0;
- setSeqNo(lastSeqNo + 10);
- }
-
- return true;
- }
-
-
-}
\ No newline at end of file
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRPeriod.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRPeriod.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRPeriod.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,58 +0,0 @@
-/**
- *
- */
-package org.eevolution.model;
-
-import java.sql.ResultSet;
-import java.util.Properties;
-
-import org.compiere.util.CCache;
-
-/**
- * HR Period
- * @author Teo Sarca, http://www.arhipac.ro
- */
-public class MHRPeriod extends X_HR_Period
-{
- /**
- *
- */
- private static final long serialVersionUID = -7787966459848200539L;
-
- private static CCache<Integer, MHRPeriod> s_cache = new CCache<Integer, MHRPeriod>(Table_Name, 20);
-
- public static MHRPeriod get(Properties ctx, int HR_Period_ID)
- {
- if (HR_Period_ID <= 0)
- {
- return null;
- }
- //
- MHRPeriod period = s_cache.get(HR_Period_ID);
- if (period != null)
- {
- return period;
- }
- // Try Load
- period = new MHRPeriod(ctx, HR_Period_ID, null);
- if (period.get_ID() == HR_Period_ID)
- {
- s_cache.put(HR_Period_ID, period);
- }
- else
- {
- period = null;
- }
- return period;
- }
-
- public MHRPeriod(Properties ctx, int HR_Period_ID, String trxName)
- {
- super(ctx, HR_Period_ID, trxName);
- }
- public MHRPeriod(Properties ctx, ResultSet rs, String trxName)
- {
- super(ctx, rs, trxName);
- }
-
-}
Deleted: branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRProcess.java
===================================================================
--- branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRProcess.java 2009-09-14 03:35:29 UTC (rev 10192)
+++ branches/libero/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRProcess.java 2009-09-14 03:44:11 UTC (rev 10193)
@@ -1,1486 +0,0 @@
-/******************************************************************************
- * 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 http://www.e-evolution.com *
- *****************************************************************************/
-package org.eevolution.model;
-
-import java.io.File;
-import java.math.BigDecimal;
-import java.sql.ResultSet;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Properties;
-
-import org.adempiere.exceptions.AdempiereException;
-import org.compiere.model.MBPartner;
-import org.compiere.model.MDocType;
-import org.compiere.model.MPeriod;
-import org.compiere.model.MRule;
-import org.compiere.model.ModelValidationEngine;
-import org.compiere.model.ModelValidator;
-import org.compiere.model.Query;
-import org.compiere.model.Scriptlet;
-import org.compiere.print.ReportEngine;
-import org.compiere.process.DocAction;
-import org.compiere.process.DocumentEngine;
-import org.compiere.util.CLogger;
-import org.compiere.util.DB;
-import org.compiere.util.Env;
-import org.compiere.util.TimeUtil;
-
-/**
- * HR Process Model
- *
- * @author oscar.gomez@..., e-Evolution http://www.e-evolution.com
- * <li> Original contributor of Payroll Functionality
- * @author victor.perez@..., e-Evolution http://www.e-evolution.com
- * <li> FR [ 2520591 ] Support multiples calendar for Org
- * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
- * @author Cristina Ghita, http://www.arhipac.ro
- */
-public class MHRProcess extends X_HR_Process implements DocAction
-{
- /**
- *
- */
- private static final long serialVersionUID = 570699817555475782L;
-
- public int m_C_BPartner_ID = 0;
- public int m_AD_User_ID = 0;
- public int m_HR_Concept_ID = 0;
- public String m_columnType = "";
- public Timestamp m_dateFrom;
- public Timestamp m_dateTo;
- /** HR_Concept_ID->MHRMovement */
- public Hashtable<Integer, MHRMovement> m_movement = new Hashtable<Integer, MHRMovement>();
- public MHRPayrollConcept[] linesConcept;
-
- /** Static Logger */
- private static CLogger s_log = CLogger.getCLogger (MHREmployee.class);
- public static final String CONCEPT_PP_COST_COLLECTOR_LABOR = "PP_COST_COLLECTOR_LABOR"; // HARDCODED
-
-
- private static StringBuffer s_scriptImport = new StringBuffer( " import org.eevolution.model.*;"
- +" import org.compiere.util.DB;"
- +" import java.math.*;"
- +" import java.sql.*;");
-
- public static void addScriptImportPackage(String packageName)
- {
- s_scriptImport.append(" import ").append(packageName).append(";");
- }
-
- /**************************************************************************
- * Default Constructor
- * @param ctx context
- * @param HR_Process_ID To load, (0 create new order)
- */
- public MHRProcess(Properties ctx, int HR_Process_ID, String trxName)
- {
- super(ctx, HR_Process_ID,trxName);
- if (HR_Process_ID == 0)
- {
- setDocStatus(DOCSTATUS_Drafted);
- setDocAction(DOCACTION_Prepare);
- setC_DocType_ID(0);
- set_ValueNoCheck ("DocumentNo", null);
- setProcessed(false);
- setProcessing(false);
- setPosted(false);
- setHR_Department_ID(0);
- setC_BPartner_ID(0);
- }
- }
-
- /**
- * Load Constructor
- * @param ctx context
- * @param rs result set record
- */
- public MHRProcess(Properties ctx, ResultSet rs, String trxName)
- {
- super(ctx, rs,trxName);
- } // MHRProcess
-
- @Override
- public final void setProcessed(boolean processed)
- {
- super.setProcessed(processed);
- if (get_ID() <= 0)
- {
- return;
- }
- final String sql = "UPDATE HR_Process SET Processed=? WHERE HR_Process_ID=?";
- DB.executeUpdateEx(sql, new Object[]{processed, get_ID()}, get_TrxName());
- } // setProcessed
-
- @Override
- protected boolean beforeSave(boolean newRecord)
- {
- if (getAD_Client_ID() == 0)
- {
- throw new AdempiereException("@AD_Client_ID@ = 0");
- }
- if (getAD_Org_ID() == 0)
- {
- int context_AD_Org_ID = getAD_Org_ID();
- if (context_AD_Org_ID == 0)
- {
- throw new AdempiereException("@AD_Org_ID@ = *");
- }
- setAD_Org_ID(context_AD_Org_ID);
- log.warning("Changed Org to Context=" + context_AD_Org_ID);
- }
- setC_DocType_ID(getC_DocTypeTarget_ID());
-
- return true;
- }
-
-
- /**
- * Process document
- * @param processAction document action
- * @return true if performed
- */
- public boolean processIt(String processAction)
- {
- DocumentEngine engine = new DocumentEngine(this, getDocStatus());
- return engine.processIt(processAction, getDocAction());
- } // processIt
-
- /** Process Message */
- private String m_processMsg = null;
- /** Just Prepared Flag */
- private boolean m_justPrepared = false;
-
-
- /**
- * Unlock Document.
- * @return true if success
- */
- public boolean unlockIt()
- {
- log.info("unlockIt - " + toString());
- setProcessing(false);
- return true;
- } // unlockIt
-
-
- /**
- * Invalidate Document
- * @return true if success
- */
- public boolean invalidateIt()
- {
- log.info("invalidateIt - " + toString());
- setDocAction(DOCACTION_Prepare);
- return true;
- } // invalidateIt
-
-
- /**************************************************************************
- * Prepare Document
- * @return new status (In Progress or Invalid)
- */
- public String prepareIt()
- {
- log.info("prepareIt - " + toString());
-
- m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE);
- if (m_processMsg != null)
- {
- return DocAction.STATUS_Invalid;
- }
-
- // Std Period open?
- MHRPeriod period = MHRPeriod.get(getCtx(), getHR_Period_ID());
- MPeriod.testPeriodOpen(getCtx(), getHR_Period_ID() > 0 ? period.getDateAcct():getDateAcct(), getC_DocTypeTarget_ID(), getAD_Org_ID());
-
- // New or in Progress/Invalid
- if ( DOCSTATUS_Drafted.equals(getDocStatus())
- || DOCSTATUS_InProgress.equals(getDocStatus())
- || DOCSTATUS_Invalid.equals(getDocStatus())
- || getC_DocType_ID() == 0)
- {
- setC_DocType_ID(getC_DocTypeTarget_ID());
- }
-
- try
- {
- createMovements();
- }
- catch (Exception e)
- {
- throw new AdempiereException(e);
- }
-
- m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE);
- if (m_processMsg != null)
- return DocAction.STATUS_Invalid;
- //
- m_justPrepared = true;
- if (!DOCACTION_Complete.equals(getDocAction()))
- setDocAction(DOCACTION_Complete);
- return DocAction.STATUS_InProgress;
- } // prepareIt
-
-
- /**
- * Complete Document
- * @return new status (Complete, In Progress, Invalid, Waiting ..)
- */
- public String completeIt()
- {
- // Re-Check
- if (!m_justPrepared)
- {
- String status = prepareIt();
- if (!DocAction.STATUS_InProgress.equals(status))
- return status;
- }
-
- m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
- if (m_processMsg != null)
- return DocAction.STATUS_Invalid;
-
- // User Validation
- m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
- if (m_processMsg != null)
- {
- return DocAction.STATUS_Invalid;
- }
- //
- setProcessed(true);
- setDocAction(DOCACTION_Close);
- return DocAction.STATUS_Completed;
- } // completeIt
-
- /**
- * Approve Document
- * @return true if success
- */
- public boolean approveIt() {
- return true;
- } // approveIt
-
-
- /**
- * Reject Approval
- * @return true if success
- */
- public boolean rejectIt() {
- log.info("rejectIt - " + toString());
- return true;
- } // rejectIt
-
- /**
- * Post Document - nothing
- * @return true if success
- */
- public boolean postIt() {
- log.info("postIt - " + toString());
- return false;
- } // postIt
-
-
- /**
- * Void Document.
- * Set Qtys to 0 - Sales: reverse all documents
- * @return true if success
- */
- public boolean voidIt() {
- log.info("voidIt - " + toString());
- setProcessed(true);
- setDocAction(DOCACTION_None);
- return true;
- } // voidIt
-
-
- /**
- * Close Document.
- * Cancel not delivered Qunatities
- * @return true if success
- */
- public boolean closeIt()
- {
- if (isProcessed())
- {
- log.info(toString());
- setProcessed(true);
- setDocAction(DOCACTION_None);
- return true;
- }
- return false;
- } // closeIt
-
-
- /**
- * Reverse Correction - same void
- * @return true if success
- */
- public boolean reverseCorrectIt() {
- log.info("reverseCorrectIt - " + toString());
- return voidIt();
- } // reverseCorrectionIt
-
-
- /**
- * Reverse Accrual - none
- * @return true if success
- */
- public boolean reverseAccrualIt() {
- log.info("reverseAccrualIt - " + toString());
- return false;
- } // reverseAccrualIt
-
-
- /**
- * Re-activate.
- * @return true if success
- */
- public boolean reActivateIt() {
- log.info("reActivateIt - " + toString());
-
- org.compiere.model.MDocType dt = org.compiere.model.MDocType.get(getCtx(), getC_DocType_ID());
- String DocSubTypeSO = dt.getDocSubTypeSO();
-
- // Reverse Direct Documents
- if ( MDocType.DOCSUBTYPESO_OnCreditOrder.equals(DocSubTypeSO) // (W)illCall(I)nvoice
- || MDocType.DOCSUBTYPESO_WarehouseOrder.equals(DocSubTypeSO) // (W)illCall(P)ickup
- || MDocType.DOCSUBTYPESO_POSOrder.equals(DocSubTypeSO)) // (W)alkIn(R)eceipt
- {
- return false;
- }
- else {
- log.fine("reActivateIt - Existing documents not modified - SubType=" + DocSubTypeSO);
- }
-
- // Delete
- String sql = "DELETE FROM HR_Movement WHERE HR_Process_ID =" + this.getHR_Process_ID() + " AND IsRegistered = 'N'" ;
- int no = DB.executeUpdate(sql, get_TrxName());
- log.fine("HR_Process deleted #" + no);
-
- setDocAction(DOCACTION_Complete);
- setProcessed(false);
- return true;
- } // reActivateIt
-
-
- /**
- * Get Document Owner (Responsible)
- * @return AD_User_ID
- */
- public int getDoc_User_ID() {
- return 0;
- } // getDoc_User_ID
-
-
- /**
- * Get Document Approval Amount
- * @return amount
- */
- public java.math.BigDecimal getApprovalAmt()
- {
- return BigDecimal.ZERO;
- } // getApprovalAmt
-
- /**
- *
- */
- public int getC_Currency_ID()
- {
- return 0;
- }
-
- public String getProcessMsg()
- {
- return m_processMsg;
- }
-
- public String getSummary()
- {
- return "";
- }
-
- /**
- * Create PDF
- * @return File or null
- */
- public File createPDF ()
- {
- try
- {
- File temp = File.createTempFile(get_TableName()+get_ID()+"_", ".pdf");
- return createPDF (temp);
- }
- catch (Exception e)
- {
- log.severe("Could not create PDF - " + e.getMessage());
- }
- return null;
- } // getPDF
-
- /**
- * Create PDF file
- * @param file output file
- * @return file if success
- */
- public File createPDF (File file)
- {
- ReportEngine re = ReportEngine.get (getCtx(), ReportEngine.ORDER, 0);
- if (re == null)
- return null;
- return re.getPDF(file);
- } // createPDF
-
- /**
- * Get Document Info
- * @return document info (untranslated)
- */
- public String getDocumentInfo()
- {
- org.compiere.model.MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
- return dt.getName() + " " + getDocumentNo();
- } // getDocumentInfo
-
-
- /**
- * Get Lines
- * @param requery requery
- * @return lines
- */
- public MHRMovement[] getLines (boolean requery)
- {
- ArrayList<Object> params = new ArrayList<Object>();
- StringBuffer whereClause = new StringBuffer();
- // For HR_Process:
- whereClause.append(MHRMovement.COLUMNNAME_HR_Process_ID+"=?");
- params.add(getHR_Process_ID());
- // With Qty or Amounts
- whereClause.append("AND (Qty <> 0 OR Amount <> 0)"); // TODO: it's really needed ?
- // Only Active Concepts
- whereClause.append(" AND EXISTS(SELECT 1 FROM HR_Concept c WHERE c.HR_Concept_ID=HR_Movement.HR_Concept_ID"
- +" AND c.IsActive=?"
- +" AND c.AccountSign<>?)"); // TODO : why ?
- params.add(true);
- params.add(MHRConcept.ACCOUNTSIGN_Natural); // TODO : why ?
- // Concepts with accounting
- whereClause.append(" AND EXISTS(SELECT 1 FROM HR_Concept_Acct ca WHERE ca.HR_Concept_ID=HR_Movement.HR_Concept_ID"
- +" AND ca.IsActive=? AND ca.IsBalancing<>?)");
- params.add(true);
- params.add(true);
- // BPartner field is filled
- whereClause.append(" AND C_BPartner_ID IS NOT NULL");
- //
- // ORDER BY
- StringBuffer orderByClause = new StringBuffer();
- orderByClause.append("(SELECT bp.C_BP_Group_ID FROM C_BPartner bp WHERE bp.C_BPartner_ID=HR_Movement.C_BPartner_ID)");
- //
- List<MHRMovement> list = new Query (getCtx(), MHRMovement.Table_Name, whereClause.toString(), get_TrxName())
- .setParameters(params)
- .setOrderBy(orderByClause.toString())
- .list();
- return list.toArray(new MHRMovement[list.size()]);
- }
-
- /**
- * Load HR_Movements and store them in a HR_Concept_ID->MHRMovement hashtable
- * @param movements hashtable
- * @param C_PBartner_ID
- */
- private void loadMovements(Hashtable<Integer,MHRMovement> movements, int C_PBartner_ID)
- {
- final String whereClause = MHRMovement.COLUMNNAME_HR_Process_ID+"=?"
- +" AND "+MHRMovement.COLUMNNAME_C_BPartner_ID+"=?";
- List<MHRMovement> list = new Query(getCtx(), MHRMovement.Table_Name, whereClause, get_TrxName())
- .setParameters(new Object[]{getHR_Process_ID(), C_PBartner_ID})
- .list();
- for (MHRMovement mvm : list)
- {
- if(movements.containsKey(mvm.getHR_Concept_ID()))
- {
- MHRMovement lastM = movements.get(mvm.getHR_Concept_ID());
- String columntype = lastM.getColumnType();
- if (columntype.equals(MHRConcept.COLUMNTYPE_Amount))
- {
- mvm.addAmount(lastM.getAmount());
- }
- else if (columntype.equals(MHRConcept.COLUMNTYPE_Quantity))
- {
- mvm.addQty(lastM.getQty());
- }
- }
- movements.put(mvm.getHR_Concept_ID(), mvm);
- }
- }
-
- /**
- * Execute the script
- * @param scriptCtx
- * @param AD_Rule_ID
- * @return
- */
- private Object executeScript(HashMap<String, Object> scriptCtx, int AD_Rule_ID)
- {
- MRule rulee = MRule.get(getCtx(), AD_Rule_ID);
- Object result = null;
- try
- {
- String text = "";
- if(rulee.getScript() != null)
- {
- text = rulee.getScript().trim().replace("get", "process.get")
- .replace(".process.get", ".get");
- }
- final String script =
- s_scriptImport.toString()
- +" double result = 0;"
- + text;
- Scriptlet engine = new Scriptlet (Scriptlet.VARIABLE, script, scriptCtx);
- Exception ex = engine.execute();
- if (ex != null)
- {
- throw ex;
- }
- result = engine.getResult(false);
- }
- catch (Exception e)
- {
- throw new AdempiereException("Execution error - @AD_Rule_ID@...());
- }
- return result;
- }
-
- /**
- * creates movements for concepts related to labor
- * @param C_BPartner_ID
- * @param period
- * @param scriptCtx
- */
- private void createCostCollectorMovements(int C_BPartner_ID, MHRPeriod period ,HashMap<String, Object> scriptCtx)
- {
- List<Object> params = new ArrayList<Object>();
- StringBuffer whereClause = new StringBuffer();
- whereClause.append("EXISTS (SELECT 1 FROM AD_User u WHERE u.AD_User_ID=PP_Cost_Collector.AD_User_ID AND u.C_BPartner_ID=?)");
- params.add(C_BPartner_ID);
- whereClause.append(" AND "+MPPCostCollector.COLUMNNAME_MovementDate + ">=?");
- params.add(period.getStartDate());
- whereClause.append(" AND "+MPPCostCollector.COLUMNNAME_MovementDate + "<=?");
- params.add(period.getEndDate());
- whereClause.append(" AND "+MPPCostCollector.COLUMNNAME_DocStatus + " IN (?,?)");
- params.add(MPPCostCollector.DOCSTATUS_Completed);
- params.add(MPPCostCollector.DOCSTATUS_Closed);
-
- List<MPPCostCollector> listColector = new Query(getCtx(), MPPCostCollector.Table_Name,
- whereClause.toString(), get_TrxName())
- .setOnlyActiveRecords(true)
- .setParameters(params)
- .setOrderBy(MPPCostCollector.COLUMNNAME_PP_Cost_Collector_ID+" DESC")
- .list();
-
-
- for (MPPCostCollector cc : listColector)
- {
- createMovementForCC(C_BPartner_ID, cc, scriptCtx);
- }
- }
-
- /**
- * create movement for cost collector
- * @param C_BPartner_ID
- * @param cc
- * @param scriptCtx
- * @return
- */
- private MHRMovement createMovementForCC(int C_BPartner_ID, I_PP_Cost_Collector cc, HashMap<String, Object> scriptCtx)
- {
- //get the concept that should store the labor
- MHRConcept concept = MHRConcept.forValue(getCtx(), CONCEPT_PP_COST_COLLECTOR_LABOR);
-
- //get the attribute for specific concept
- List<Object> params = new ArrayList<Object>();
- StringBuffer whereClause = new StringBuffer();
- whereClause.append("? >= ValidFrom AND ( ? <= ValidTo OR ValidTo IS NULL)");
- params.add(m_dateFrom);
- params.add(m_dateTo);
- whereClause.append(" AND HR_Concept_ID = ? ");
- params.add(concept.get_ID());
- whereClause.append(" AND EXISTS (SELECT 1 FROM HR_Concept conc WHERE conc.HR_Concept_ID = HR_Attribute.HR_Concept_ID )");
- MHRAttribute att = new Query(getCtx(), MHRAttribute.Table_Name, whereClause.toString(), get_TrxName())
- .setParameters(params)
- .setOnlyActiveRecords(true)
- .setOrderBy(MHRAttribute.COLUMNNAME_ValidFrom + " DESC")
- .first();
- if (att == null)
- {
- throw new AdempiereException(); // TODO ?? is necessary
- }
-
- if (MHRConcept.TYPE_RuleEngine.equals(concept.getType()))
- {
- Object result = null;
-
- scriptCtx.put("_CostCollector", cc);
- try
- {
- result = executeScript(scriptCtx, att.getAD_Rule_ID());
- }
- finally
- {
- scriptCtx.remove("_CostCollector");
- }
- if(result == null)
- {
- // TODO: throw exception ???
- log.warning("Variable (result) is null");
- }
-
- //get employee
- MHREmployee employee = MHREmployee.getActiveEmployee(getCtx(), C_BPartner_ID, get_TrxName());
-
- //create movement
- MHRMovement mv = new MHRMovement(this, concept);
- mv.setC_BPartner_ID(C_BPartner_ID);
- mv.setAD_Rule_ID(att.getAD_Rule_ID());
- mv.setHR_Job_ID(employee.getHR_Job_ID());
- mv.setHR_Department_ID(employee.getHR_Department_ID());
- mv.setC_Activity_ID(employee.getC_Activity_ID());
- mv.setValidFrom(m_dateFrom);
- mv.setValidTo(m_dateTo);
- mv.setPP_Cost_Collector_ID(cc.getPP_Cost_Collector_ID());
- mv.setIsRegistered(true);
- mv.setColumnValue(result);
- mv.setProcessed(true);
- mv.saveEx();
- return mv;
- }
- else
- {
- throw new AdempiereException(); //TODO ?? is necessary
- }
-
- }
-
-
-
- /**
- * create Movements for corresponding process , period
- */
- private void createMovements() throws Exception
- {
- HashMap<String, Object> scriptCtx = new HashMap<String, Object>();
- scriptCtx.put("process", this);
- scriptCtx.put("_Process", getHR_Process_ID());
- scriptCtx.put("_Period", getHR_Period_ID());
- scriptCtx.put("_Payroll", getHR_Payroll_ID());
- scriptCtx.put("_Department", getHR_Department_ID());
-
- log.info("info data - " + " Process: " +getHR_Process_ID()+ ", Period: " +getHR_Period_ID()+ ", Payroll: " +getHR_Payroll_ID()+ ", Department: " +getHR_Department_ID());
- MHRPeriod period = new MHRPeriod(getCtx(), getHR_Period_ID(), get_TrxName());
- if (period != null)
- {
- m_dateFrom = period.getStartDate();
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|