use of org.eevolution.model.MHRAttribute 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@";
}
Aggregations