Search in sources :

Example 1 with MHRPeriod

use of org.eevolution.model.MHRPeriod in project adempiere by adempiere.

the class WHRActionNotice method onEvent.

/**************************************************************************
	 * Action Listener. - MultiCurrency - Allocate
	 * 
	 * @param e
	 *            event
	 */
@Override
public void onEvent(Event e) {
    KeyNamePair processKeyNamePair = (KeyNamePair) fieldProcess.getSelectedItem().getValue();
    if (e.getTarget() == fieldProcess && processKeyNamePair != null && processKeyNamePair.getKey() > 0) {
        payrollProcess = new MHRProcess(Env.getCtx(), processKeyNamePair.getKey(), null);
        payrollProcessId = payrollProcess.getHR_Process_ID();
        if (payrollProcess.getHR_Period_ID() > 0) {
            MHRPeriod period = MHRPeriod.get(Env.getCtx(), payrollProcess.getHR_Period_ID());
            dateStart = period.getStartDate();
            dateEnd = period.getEndDate();
        } else {
            dateEnd = payrollProcess.getDateAcct();
        }
        fieldEmployee.removeAllItems();
        KeyNamePair[] employeeData = getEmployeeValid(payrollProcess);
        for (KeyNamePair vp : employeeData) {
            fieldEmployee.appendItem(vp.getName(), vp);
        }
    }
    //	
    if (e.getTarget() == fieldEmployee) {
        partnerId = ((KeyNamePair) fieldEmployee.getSelectedItem().getValue()).getKey();
        //	Validate
        if (partnerId > 0) {
            fieldValidFrom.setValue(dateEnd);
            fieldConcept.removeAllItems();
            KeyNamePair[] conceptData = getConcept(getPayrollProcess(), fieldProcess != null);
            for (KeyNamePair vp : conceptData) {
                fieldConcept.appendItem(vp.getName(), vp);
            }
        }
    }
    if (e.getTarget() == fieldConcept) {
        KeyNamePair valueNamePair = (KeyNamePair) fieldConcept.getSelectedItem().getValue();
        if (valueNamePair != null) {
            conceptId = ((KeyNamePair) fieldConcept.getSelectedItem().getValue()).getKey();
        }
        //	
        if (conceptId > 0) {
            MHRConcept concept = MHRConcept.get(Env.getCtx(), conceptId);
            //	Load Data Combo Box
            loadTextMsgLookup(concept.getAD_Reference_ID());
            //	
            String columnType = MRefList.getListName(Env.getCtx(), MHRConcept.COLUMNTYPE_AD_Reference_ID, concept.getColumnType());
            fieldColumnType.setValue(columnType);
            fieldColumnType.setVisible(true);
            movementId = seekMovement((Timestamp) fieldValidFrom.getValue());
            if (movementId > 0) {
                MHRMovement movementFound = new MHRMovement(Env.getCtx(), movementId, null);
                fieldDescription.setValue(movementFound.getDescription());
                fieldText.setValue("");
                fieldDate.setValue(null);
                fieldQty.setValue(Env.ZERO);
                fieldAmount.setValue(Env.ZERO);
                if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Quantity)) {
                    // Quantity
                    fieldQty.setValue(movementFound.getQty());
                } else if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Amount)) {
                    // Amount
                    fieldAmount.setValue(movementFound.getAmount());
                } else if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Text)) {
                    //	Verify Reference
                    if (isLookupTextMsg) {
                        fieldTextLookup.setValue(movementFound.getTextMsg());
                    } else {
                        fieldText.setValue(movementFound.getTextMsg());
                    }
                } else if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Date)) {
                    // Date
                    fieldDate.setValue(movementFound.getServiceDate());
                }
            }
            if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Quantity)) {
                // Concept Type
                fieldQty.setVisible(true);
                fieldQty.setReadWrite(true);
                fieldAmount.setVisible(false);
                fieldDate.setVisible(false);
                fieldText.setVisible(false);
                fieldTextLookup.setVisible(false);
            } else if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Amount)) {
                fieldQty.setVisible(false);
                fieldAmount.setVisible(true);
                fieldAmount.setReadWrite(true);
                fieldDate.setVisible(false);
                fieldText.setVisible(false);
                fieldTextLookup.setVisible(false);
            } else if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Date)) {
                fieldQty.setVisible(false);
                fieldAmount.setVisible(false);
                fieldDate.setVisible(true);
                fieldDate.setReadWrite(true);
                fieldText.setVisible(false);
                fieldTextLookup.setVisible(false);
            } else if (concept.getColumnType().equals(X_HR_Concept.COLUMNTYPE_Text)) {
                //	Verify Reference
                if (isLookupTextMsg) {
                    fieldText.setVisible(false);
                    fieldText.setReadWrite(false);
                    fieldTextLookup.setVisible(true);
                } else {
                    fieldTextLookup.setVisible(false);
                    fieldText.setVisible(true);
                    fieldText.setReadWrite(true);
                }
                fieldAmount.setVisible(false);
                fieldDate.setVisible(false);
            }
        }
    }
    if (e.getTarget() == bOk) {
        if (fieldConcept.getSelectedItem() != null)
            conceptId = ((KeyNamePair) fieldConcept.getSelectedItem().getValue()).getKey();
        partnerId = ((KeyNamePair) fieldEmployee.getSelectedItem().getValue()).getKey();
        payrollId = getPayrollProcess().getHR_Payroll_ID();
        if (payrollProcess.getHR_Period_ID() > 0) {
            MHRPeriod period = MHRPeriod.get(Env.getCtx(), payrollProcess.getHR_Period_ID());
            dateStart = period.getStartDate();
            dateEnd = period.getEndDate();
        } else {
            dateEnd = payrollProcess.getDateAcct();
        }
        quantity = (BigDecimal) fieldQty.getValue();
        amount = (BigDecimal) fieldAmount.getValue();
        //	Get from List
        if (isLookupTextMsg) {
            text = (String) ((ValueNamePair) fieldTextLookup.getSelectedItem().getValue()).getValue();
        } else {
            text = (String) fieldText.getValue();
        }
        serviceDate = (Timestamp) fieldDate.getValue();
        description = (String) fieldDescription.getValue();
        validFrom = (Timestamp) fieldValidFrom.getValue();
        validTo = (Timestamp) fieldValidFrom.getValue();
        if (conceptId <= 0 || fieldProcess.getSelectedItem().getValue() == null || ((KeyNamePair) fieldProcess.getSelectedItem().getValue()).getKey() <= 0 || fieldEmployee.getSelectedItem().getValue() == null || ((KeyNamePair) fieldEmployee.getSelectedItem().getValue()).getKey() <= 0) {
        // required fields
        } else {
            saveMovement();
        }
    }
    //	
    executeQuery();
    return;
}
Also used : MHRProcess(org.eevolution.model.MHRProcess) MHRPeriod(org.eevolution.model.MHRPeriod) KeyNamePair(org.compiere.util.KeyNamePair) ValueNamePair(org.compiere.util.ValueNamePair) Timestamp(java.sql.Timestamp) MHRConcept(org.eevolution.model.MHRConcept) MHRMovement(org.eevolution.model.MHRMovement)

Example 2 with MHRPeriod

use of org.eevolution.model.MHRPeriod in project adempiere by adempiere.

the class VHRActionNotice method actionPerformed.

/**************************************************************************
	 *	Action Listener
	 *  @param e event
	 */
public void actionPerformed(ActionEvent e) {
    log.fine("Event " + e);
    log.fine("Event Source " + e.getSource());
    if (e.getSource().equals(fieldProcess)) {
        // Process
        KeyNamePair pp = (KeyNamePair) fieldProcess.getSelectedItem();
        if (pp != null) {
            payrollProcessId = pp.getKey();
            payrollProcess = new MHRProcess(Env.getCtx(), payrollProcessId, null);
            if (payrollProcess.getHR_Period_ID() > 0) {
                MHRPeriod period = MHRPeriod.get(Env.getCtx(), payrollProcess.getHR_Period_ID());
                dateStart = period.getStartDate();
                dateEnd = period.getEndDate();
            } else {
                dateEnd = payrollProcess.getDateAcct();
            }
            payrollId = payrollProcess.getHR_Payroll_ID();
            fieldEmployee.removeAllItems();
            for (KeyNamePair ppt : getEmployeeValid(payrollProcess)) {
                fieldEmployee.addItem(ppt);
            }
            fieldEmployee.setSelectedIndex(0);
            fieldEmployee.setReadWrite(true);
        }
    } else if (e.getSource().equals(fieldEmployee)) {
        // Employee
        KeyNamePair keyNamePair = (KeyNamePair) fieldEmployee.getSelectedItem();
        if (keyNamePair != null) {
            partnerId = keyNamePair.getKey();
        }
        if (partnerId > 0) {
            fieldValidFrom.setValue(dateEnd);
            fieldValidFrom.setReadWrite(true);
            fieldConcept.removeAllItems();
            for (KeyNamePair vp : getConcept(payrollProcess, fieldProcess != null)) {
                fieldConcept.addItem(vp);
            }
            //	
            fieldConcept.setReadWrite(true);
        }
    } else if (e.getSource().equals(fieldConcept)) {
        // Concept
        KeyNamePair conceptPair = (KeyNamePair) fieldConcept.getSelectedItem();
        if (conceptPair != null) {
            conceptId = conceptPair.getKey();
        }
        //	
        if (conceptId > 0) {
            MHRConcept concept = MHRConcept.get(Env.getCtx(), conceptId);
            //	Load Data Combo Box
            loadTextMsgLookup(concept.getAD_Reference_ID());
            // Name To Type Column
            fieldColumnType.setValue(concept.getColumnType());
            fieldColumnType.setVisible(true);
            //  exist movement record to date actual
            movementId = seekMovement((Timestamp) fieldValidFrom.getValue());
            if (movementId > 0) {
                MHRMovement movementFound = new MHRMovement(Env.getCtx(), movementId, null);
                fieldDescription.setValue(movementFound.getDescription());
                fieldText.setValue("");
                fieldDate.setValue(null);
                fieldQty.setValue(Env.ZERO);
                fieldAmount.setValue(Env.ZERO);
                if (concept.getColumnType().equals(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)) {
                    //	Verify Reference
                    if (isLookupTextMsg) {
                        fieldTextLookup.setValue(movementFound.getTextMsg());
                    } else {
                        fieldText.setValue(movementFound.getTextMsg());
                    }
                } else if (concept.getColumnType().equals(MHRConcept.COLUMNTYPE_Date)) {
                    // Date
                    fieldDate.setValue(movementFound.getServiceDate());
                }
            } else {
                fieldQty.setValue(null);
                fieldAmount.setValue(null);
                fieldDescription.setValue(null);
                fieldText.setValue(null);
                fieldTextLookup.setValue(null);
                fieldDate.setValue(null);
            }
            //	
            if (concept.getColumnType().equals(MHRConcept.COLUMNTYPE_Quantity)) {
                // Concept Type
                fieldQty.setVisible(true);
                fieldQty.setReadWrite(true);
                fieldAmount.setVisible(false);
                fieldDate.setVisible(false);
                fieldText.setVisible(false);
                fieldTextLookup.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);
                fieldTextLookup.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);
                fieldTextLookup.setVisible(false);
                fieldRuleE.setVisible(false);
            } else if (concept.getColumnType().equals(MHRConcept.COLUMNTYPE_Text)) {
                //	Verify Reference
                if (isLookupTextMsg) {
                    fieldText.setVisible(false);
                    fieldText.setReadWrite(false);
                    fieldTextLookup.setVisible(true);
                    fieldTextLookup.setReadWrite(true);
                } else {
                    fieldTextLookup.setVisible(false);
                    fieldTextLookup.setReadWrite(false);
                    fieldText.setVisible(true);
                    fieldText.setReadWrite(true);
                }
                fieldAmount.setVisible(false);
                fieldDate.setVisible(false);
                fieldRuleE.setVisible(false);
            }
            fieldDescription.setReadWrite(true);
        }
    } else // Concept
    if (e instanceof ActionEvent && e.getSource().equals(bOk)) {
        // Movement SAVE
        conceptId = ((KeyNamePair) fieldConcept.getSelectedItem()).getKey();
        partnerId = ((KeyNamePair) fieldEmployee.getSelectedItem()).getKey();
        payrollId = getPayrollProcess().getHR_Payroll_ID();
        if (payrollProcess.getHR_Period_ID() > 0) {
            MHRPeriod period = MHRPeriod.get(Env.getCtx(), payrollProcess.getHR_Period_ID());
            dateStart = period.getStartDate();
            dateEnd = period.getEndDate();
        } else {
            dateEnd = payrollProcess.getDateAcct();
        }
        quantity = (BigDecimal) fieldQty.getValue();
        amount = (BigDecimal) fieldAmount.getValue();
        //	Get from List
        if (isLookupTextMsg) {
            text = (String) fieldTextLookup.getValue();
        } else {
            text = (String) fieldText.getValue();
        }
        serviceDate = (Timestamp) fieldDate.getValue();
        description = (String) fieldDescription.getValue();
        validFrom = (Timestamp) fieldValidFrom.getValue();
        validTo = (Timestamp) fieldValidFrom.getValue();
        if (conceptId <= 0 || fieldProcess.getValue() == null || ((Integer) fieldProcess.getValue()).intValue() <= 0 || fieldEmployee.getValue() == null || ((Integer) fieldEmployee.getValue()).intValue() <= 0) {
            // required fields
            ADialog.error(m_WindowNo, this.mainPanel, 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 {
            saveMovement();
        }
    }
    executeQuery();
    return;
}
Also used : MHRProcess(org.eevolution.model.MHRProcess) ActionEvent(java.awt.event.ActionEvent) MHRPeriod(org.eevolution.model.MHRPeriod) KeyNamePair(org.compiere.util.KeyNamePair) Timestamp(java.sql.Timestamp) BigDecimal(java.math.BigDecimal) MHRConcept(org.eevolution.model.MHRConcept) MHRMovement(org.eevolution.model.MHRMovement)

Aggregations

Timestamp (java.sql.Timestamp)2 KeyNamePair (org.compiere.util.KeyNamePair)2 MHRConcept (org.eevolution.model.MHRConcept)2 MHRMovement (org.eevolution.model.MHRMovement)2 MHRPeriod (org.eevolution.model.MHRPeriod)2 MHRProcess (org.eevolution.model.MHRProcess)2 ActionEvent (java.awt.event.ActionEvent)1 BigDecimal (java.math.BigDecimal)1 ValueNamePair (org.compiere.util.ValueNamePair)1