use of org.eevolution.model.MHRProcess in project adempiere by adempiere.
the class PayrollProcessing method doIt.
@Override
protected String doIt() throws Exception {
if (m_HR_Process_ID <= 0)
throw new FillMandatoryException(PARAM_HR_Process_ID);
MHRProcess process = new MHRProcess(getCtx(), m_HR_Process_ID, get_TrxName());
long start = System.currentTimeMillis();
boolean ok = process.processIt(MHRProcess.ACTION_Complete);
process.saveEx();
if (!ok) {
throw new AdempiereException(process.getProcessMsg());
}
return "@Processed@ " + process.getName() + " - " + (System.currentTimeMillis() - start) + "ms";
}
use of org.eevolution.model.MHRProcess 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;
}
use of org.eevolution.model.MHRProcess in project adempiere by adempiere.
the class HRCreateInvoice method doIt.
// prepare
/**
* Process
* @return message
* @throws Exception
*/
protected String doIt() throws Exception {
MHRProcess process = new MHRProcess(getCtx(), getPayrollProcessId(), get_TrxName());
final Timestamp dateInvoice = getDateInvoiced() != null ? getDateInvoiced() : process.getHR_Period_ID() > 0 ? process.getHR_Period().getStartDate() : process.getDateAcct();
Arrays.stream(getEmployeeIds(process)).filter(partnerId -> partnerId > 0).forEach(partnerId -> {
Trx.run(trxName -> {
int lastPartnerId = 0;
MHREmployee employee = null;
MInvoice invoice = null;
for (MHRMovement movement : getPayrollMovement(getPayrollProcessId(), partnerId, trxName)) {
MBPartner partner = new MBPartner(getCtx(), partnerId, trxName);
MHRAttribute attribute = MHRAttribute.getByConceptIdAndPartnerId(movement.getCtx(), movement.getHR_Concept_ID(), movement.getC_BPartner_ID(), movement.getValidFrom(), trxName);
if (attribute != null && attribute.getC_DocType_ID() == 0) {
log.log(Level.SEVERE, "@HR_Employee_ID@ " + partner.getName() + " @HR_Concept_ID@ " + movement.getHR_Concept().getName() + " @C_DocType_ID@ @NotFound@ : ");
addLog(0, null, null, "@HR_Employee_ID@ " + partner.getName() + " @HR_Concept_ID@ " + movement.getHR_Concept().getName() + " @C_DocType_ID@ @NotFound@ : ");
continue;
}
if (attribute != null && attribute.getC_Charge_ID() == 0) {
log.log(Level.SEVERE, "@HR_Employee_ID@ " + partner.getName() + " @HR_Concept_ID@ " + movement.getHR_Concept().getName() + " @C_Charge_ID@ @NotFound@ : ");
addLog(0, null, null, "@HR_Employee_ID@ " + partner.getName() + " @HR_Concept_ID@ " + movement.getHR_Concept().getName() + " @C_Charge_ID@ @NotFound@ : ");
continue;
}
if (movement.getC_BPartner_ID() != lastPartnerId) {
lastPartnerId = movement.getC_BPartner_ID();
employee = MHREmployee.getActiveEmployee(getCtx(), partner.getC_BPartner_ID(), trxName);
invoice = createInvoice(process, partner, employee, attribute.getC_DocType_ID(), dateInvoice);
if (invoice == null)
continue;
}
if (invoice != null)
createInvoiceLine(invoice, employee, movement, attribute.getC_Charge_ID());
}
});
});
return "@OK@";
}
use of org.eevolution.model.MHRProcess 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;
}
Aggregations