Search in sources :

Example 6 with MHRMovement

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

the class Doc_HRProcess method loadLines.

//  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;
}
Also used : ArrayList(java.util.ArrayList) MHRMovement(org.eevolution.model.MHRMovement)

Example 7 with MHRMovement

use of org.eevolution.model.MHRMovement 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

MHRMovement (org.eevolution.model.MHRMovement)7 BigDecimal (java.math.BigDecimal)5 Timestamp (java.sql.Timestamp)3 MHRConcept (org.eevolution.model.MHRConcept)3 MHRProcess (org.eevolution.model.MHRProcess)3 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2 I_C_BPartner (org.compiere.model.I_C_BPartner)2 Query (org.compiere.model.Query)2 KeyNamePair (org.compiere.util.KeyNamePair)2 MHREmployee (org.eevolution.model.MHREmployee)2 MHRPeriod (org.eevolution.model.MHRPeriod)2 ActionEvent (java.awt.event.ActionEvent)1 SQLException (java.sql.SQLException)1 java.util (java.util)1 Arrays (java.util.Arrays)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Level (java.util.logging.Level)1