Search in sources :

Example 1 with MHRAttribute

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@";
}
Also used : Arrays(java.util.Arrays) MHREmployee(org.eevolution.model.MHREmployee) MHRAttribute(org.eevolution.model.MHRAttribute) Timestamp(java.sql.Timestamp) Env(org.compiere.util.Env) MPaymentTerm(org.compiere.model.MPaymentTerm) MBPartnerLocation(org.compiere.model.MBPartnerLocation) Level(java.util.logging.Level) MInvoice(org.compiere.model.MInvoice) MHRProcess(org.eevolution.model.MHRProcess) BigDecimal(java.math.BigDecimal) List(java.util.List) Query(org.compiere.model.Query) MHRMovement(org.eevolution.model.MHRMovement) MBPartner(org.compiere.model.MBPartner) MInvoiceLine(org.compiere.model.MInvoiceLine) Msg(org.compiere.util.Msg) Trx(org.compiere.util.Trx) DocAction(org.compiere.process.DocAction) I_C_BPartner(org.compiere.model.I_C_BPartner) I_C_BPartner_Location(org.compiere.model.I_C_BPartner_Location) MHRProcess(org.eevolution.model.MHRProcess) MHRAttribute(org.eevolution.model.MHRAttribute) MInvoice(org.compiere.model.MInvoice) MBPartner(org.compiere.model.MBPartner) Timestamp(java.sql.Timestamp) MHREmployee(org.eevolution.model.MHREmployee) MHRMovement(org.eevolution.model.MHRMovement)

Aggregations

BigDecimal (java.math.BigDecimal)1 Timestamp (java.sql.Timestamp)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Level (java.util.logging.Level)1 I_C_BPartner (org.compiere.model.I_C_BPartner)1 I_C_BPartner_Location (org.compiere.model.I_C_BPartner_Location)1 MBPartner (org.compiere.model.MBPartner)1 MBPartnerLocation (org.compiere.model.MBPartnerLocation)1 MInvoice (org.compiere.model.MInvoice)1 MInvoiceLine (org.compiere.model.MInvoiceLine)1 MPaymentTerm (org.compiere.model.MPaymentTerm)1 Query (org.compiere.model.Query)1 DocAction (org.compiere.process.DocAction)1 Env (org.compiere.util.Env)1 Msg (org.compiere.util.Msg)1 Trx (org.compiere.util.Trx)1 MHRAttribute (org.eevolution.model.MHRAttribute)1 MHREmployee (org.eevolution.model.MHREmployee)1 MHRMovement (org.eevolution.model.MHRMovement)1