Search in sources :

Example 6 with MOrg

use of org.compiere.model.MOrg in project adempiere by adempiere.

the class ReportEngineEx method createEXCEL_HTML.

//	createHTML
/**
	 * 	Write EXCEL HTML to writer
	 * 	@param writer writer
	 *  @param onlyTable if false create complete HTML document
	 *  @param language optional language - if null nubers/dates are not formatted
	 * 	@return true if success
	 */
public static boolean createEXCEL_HTML(ReportEngine re, Properties m_ctx, Writer writer, boolean onlyTable, Language language) {
    PrintData m_printData = re.getPrintData();
    MPrintFormat m_printFormat = re.getPrintFormat();
    ///Properties m_ctx = new Properties();
    MQuery m_query = re.getQuery();
    try {
        table table = new table();
        //	for all rows (-1 = header row)
        for (int row = -1; row < m_printData.getRowCount(); row++) {
            tr tr = new tr();
            table.addElement(tr);
            if (row != -1)
                m_printData.setRowIndex(row);
            //	for all columns
            for (int col = 0; col < m_printFormat.getItemCount(); col++) {
                MPrintFormatItem item = m_printFormat.getItem(col);
                if (item.isPrinted()) {
                    //	header row
                    if (row == -1) {
                        th th = new th();
                        tr.addElement(th);
                        th.addElement(Util.maskHTML(item.getPrintName(language)));
                        th.setClass("xl_head");
                    } else {
                        td td = new td();
                        tr.addElement(td);
                        Object obj = m_printData.getNode(new Integer(item.getAD_Column_ID()));
                        if (obj == null)
                            td.addElement("&nbsp;");
                        else if (obj instanceof PrintDataElement) {
                            //	formatted
                            String value = ((PrintDataElement) obj).getValueDisplay(null);
                            int displayType = ((PrintDataElement) obj).getDisplayType();
                            if (((PrintDataElement) obj).isNumeric()) {
                                if (displayType == DisplayType.Integer) {
                                    td.addAttribute("x:num", value);
                                    td.addElement(Util.maskHTML(value));
                                } else if (displayType == DisplayType.Quantity) {
                                    td.addAttribute("x:num", value);
                                    td.addElement(Util.maskHTML(value));
                                } else if (displayType == DisplayType.Amount) {
                                    td.addAttribute("x:num", value);
                                    td.addElement(Util.maskHTML(value));
                                } else if (displayType == DisplayType.CostPrice) {
                                    td.addAttribute("x:num", "");
                                    td.addAttribute("u1:num", value);
                                    td.setClass("xl25");
                                    td.addElement(Util.maskHTML(value));
                                } else //else if (displayType == DisplayType.YesNo)
                                //{
                                //}
                                //	if (displayType == Number)										
                                {
                                    td.addElement(Util.maskHTML(value));
                                }
                            } else if (((PrintDataElement) obj).isDate()) {
                                if (displayType == DisplayType.Date) {
                                    td.setClass("xl24");
                                    td.addElement(Util.maskHTML(value));
                                } else if (displayType == DisplayType.DateTime) {
                                    td.setClass("xl26");
                                    td.addElement(Util.maskHTML(value));
                                } else {
                                    td.addElement(Util.maskHTML(value));
                                }
                            } else
                                td.addElement(Util.maskHTML(value));
                        } else if (obj instanceof PrintData) {
                        //	ignore contained Data
                        } else
                            log.log(Level.SEVERE, "createHTML - Element not PrintData(Element) " + obj.getClass());
                    }
                }
            //	printed
            }
        //	for all columns
        }
        //	for all rows
        table table1 = new table();
        table1.setBorder(0).setCols(10).setCellPadding(0).setCellSpacing(2);
        table1.addElement(new tr().addElement(new td().setColSpan(10).addElement(new h1(re.getName())).setStyle("border:none;")));
        tr tr1;
        String tmp = "Jednostka: ";
        MOrg o = MOrg.get(m_ctx, Env.getAD_Org_ID(m_ctx));
        tmp += o.getName();
        tr1 = new tr();
        tr1.addElement(new td().addElement(tmp).setColSpan(10).setStyle("border:none;"));
        table1.addElement(tr1);
        java.text.DateFormat dateFormat = java.text.DateFormat.getDateInstance(java.text.DateFormat.FULL, new Locale("pl_PL"));
        String dateData = "Czas wygenerowania: " + dateFormat.format(new java.util.Date());
        tr1 = new tr();
        tr1.addElement(new td().addElement(dateData).setColSpan(10).setStyle("border:none;"));
        table1.addElement(tr1);
        for (int r = 0; r < m_query.getRestrictionCount(); r++) {
            tr1 = new tr();
            td td1 = new td().addElement(new i(m_query.getInfoName(r)));
            td1.addElement("   " + m_query.getInfoOperator(r) + "   " + m_query.getInfoDisplayAll(r)).setColSpan(10);
            td1.setStyle("border:none;");
            tr1.addElement(td1);
            table1.addElement(tr1);
        }
        tr1 = new tr();
        tr1.addElement(new td().addElement("&nbsp;").setColSpan(10).setStyle("border:none;height:20px;"));
        table1.addElement(tr1);
        //
        PrintWriter w = new PrintWriter(writer);
        if (onlyTable)
            table.output(w);
        else {
            XhtmlDocument doc = new XhtmlDocument();
            String st = "<!--table " + "	{mso-displayed-decimal-separator:\".\"; " + "	mso-displayed-thousand-separator:\" \";} " + "@page " + "	{margin:.98in .79in .98in .79in; " + "	mso-header-margin:.5in; " + "	mso-footer-margin:.5in;} " + "tr " + "	{mso-height-source:auto;} " + "col " + "	{mso-width-source:auto;} " + "br " + "	{mso-data-placement:same-cell;} " + ".style0 " + "	{mso-number-format:General; " + "	text-align:general; " + "	vertical-align:bottom; " + "	white-space:nowrap; " + "	mso-rotate:0; " + "	mso-background-source:auto; " + "	mso-pattern:auto; " + "	color:windowtext; " + "	font-size:10.0pt; " + "	font-weight:400; " + "	font-style:normal; " + "	text-decoration:none; " + "	font-family:Arial; " + "	mso-generic-font-family:auto; " + "	mso-font-charset:238; " + "	border:none; " + "	mso-protection:locked visible; " + "	mso-style-name:Normalny; " + "	mso-style-id:0;} " + "td " + "	{mso-style-parent:style0; " + "	padding-top:1px; " + "	padding-right:1px; " + "	padding-left:1px; " + "	mso-ignore:padding; " + "	color:windowtext; " + "	font-size:10.0pt; " + "	font-weight:400; " + "	font-style:normal; " + "	text-decoration:none; " + "	font-family:Arial; " + "	mso-generic-font-family:auto; " + "	mso-font-charset:238; " + "	mso-number-format:General; " + "	text-align:general; " + "	vertical-align:bottom; " + //"	border:none; "+
            "border:.5pt solid #a0a0a0; " + //windowtext
            "	mso-background-source:auto; " + "	mso-pattern:auto; " + "	mso-protection:locked visible; " + "	white-space:nowrap; " + "	mso-rotate:0;} " + ".xl24 " + "{mso-style-parent:style0; " + "mso-number-format:\"Short Date\";} " + ".xl25 " + "{mso-style-parent:style0; " + "mso-number-format:Fixed;} " + ".xl26 " + "{mso-style-parent:style0; " + "mso-number-format:\"yy\\/mm\\/dd\\ h\\:mm\\;\\@\";} " + ".xl_head " + "{text-align:center; mso-style-parent:style0; " + "font-weight:700; " + "font-family:Arial, sans-serif; " + "mso-font-charset:238; " + "border:.5pt solid windowtext; " + "background:silver; " + "mso-pattern:auto none;} " + "-->  ";
            doc.appendHead(new style().addElement(st));
            doc.appendBody(table1);
            doc.appendBody(table);
            doc.output(w);
        }
        w.flush();
        w.close();
    } catch (Exception e) {
        log.log(Level.SEVERE, "createHTML(w)", e);
    }
    return false;
}
Also used : Locale(java.util.Locale) org.apache.ecs.xhtml.h1(org.apache.ecs.xhtml.h1) XhtmlDocument(org.apache.ecs.XhtmlDocument) PrintData(org.compiere.print.PrintData) org.apache.ecs.xhtml.table(org.apache.ecs.xhtml.table) PrintWriter(java.io.PrintWriter) MPrintFormatItem(org.compiere.print.MPrintFormatItem) org.apache.ecs.xhtml.i(org.apache.ecs.xhtml.i) MQuery(org.compiere.model.MQuery) FileNotFoundException(java.io.FileNotFoundException) org.apache.ecs.xhtml.td(org.apache.ecs.xhtml.td) MPrintFormat(org.compiere.print.MPrintFormat) MOrg(org.compiere.model.MOrg) org.apache.ecs.xhtml.th(org.apache.ecs.xhtml.th) PrintDataElement(org.compiere.print.PrintDataElement) org.apache.ecs.xhtml.style(org.apache.ecs.xhtml.style) org.apache.ecs.xhtml.tr(org.apache.ecs.xhtml.tr)

Example 7 with MOrg

use of org.compiere.model.MOrg in project adempiere by adempiere.

the class ReleaseInOutBound method createDistributionOrder.

/**
	 * get Out Bound Order Lines from Smart Browser
	 * @return
     */
/*private List <MWMInOutBoundLine> getOutBoundOrderLine()
	{
		StringBuilder whereClause = new StringBuilder();
		whereClause.append("EXISTS (SELECT 1 FROM WM_InOutBound o WHERE o.WM_InOutBound_ID=WM_InOutBoundLine.WM_InOutBound_ID AND o.Processed='N' AND o.DocAction NOT IN ('CO','CL','VO')) AND ");
		whereClause.append("EXISTS (SELECT T_Selection_ID FROM T_Selection WHERE  T_Selection.AD_PInstance_ID=? AND T_Selection.T_Selection_ID=WM_InOutBoundLine.WM_InOutboundLine_ID)");
		return new Query(getCtx(), I_WM_InOutBoundLine.Table_Name, whereClause.toString(), get_TrxName())
				.setClient_ID()
				.setParameters(getAD_PInstance_ID())
				.list();
	}*/
/**
	 * create Distribution Order to performance a Pick List
	 * @param outBoundOrderLine Out bound Line
	 * @return Quantity that was not covert for inventory
	 */
protected BigDecimal createDistributionOrder(MWMInOutBoundLine outBoundOrderLine) {
    WMRuleEngine engineRule = WMRuleEngine.get();
    List<MStorage> storageList = engineRule.getStorage(outBoundOrderLine, getWarehouseAreaTypeId(), getWarehouseSectionTypeId());
    int shipperId = 0;
    BigDecimal qtySupply = BigDecimal.ZERO;
    if (storageList != null && storageList.size() > 0) {
        //get the warehouse in transit
        MWarehouse[] wsts = MWarehouse.getInTransitForOrg(getCtx(), outBoundLocator.getAD_Org_ID());
        if (wsts == null || wsts.length == 0)
            throw new AdempiereException("@M_Warehouse_ID@ @IsInTransit@ @NotFound@");
        //Org Must be linked to BPartner
        MOrg org = MOrg.get(getCtx(), outBoundLocator.getAD_Org_ID());
        int partnerId = org.getLinkedC_BPartner_ID(get_TrxName());
        if (partnerId == 0)
            throw new NoBPartnerLinkedforOrgException(org);
        MBPartner partner = MBPartner.get(getCtx(), partnerId);
        if (orderDistribution == null) {
            orderDistribution = new MDDOrder(getCtx(), 0, get_TrxName());
            orderDistribution.setAD_Org_ID(outBoundLocator.getAD_Org_ID());
            orderDistribution.setC_BPartner_ID(partnerId);
            if (getDocumentTypeId() > 0) {
                orderDistribution.setC_DocType_ID(getDocumentTypeId());
            } else {
                orderDistribution.setC_DocType_ID(MDocType.getDocType(X_C_DocType.DOCBASETYPE_DistributionOrder));
            }
            orderDistribution.setM_Warehouse_ID(wsts[0].get_ID());
            if (getDocumentAction() != null)
                orderDistribution.setDocAction(getDocumentAction());
            else
                orderDistribution.setDocAction(X_DD_Order.DOCACTION_Prepare);
            MUser[] users = MUser.getOfBPartner(getCtx(), partner.getC_BPartner_ID(), get_TrxName());
            if (users == null || users.length == 0)
                throw new AdempiereException("@AD_User_ID@ @NotFound@ @Value@ - @C_BPartner_ID@ : " + partner.getValue() + " - " + partner.getName());
            orderDistribution.setAD_User_ID(users[0].getAD_User_ID());
            orderDistribution.setDateOrdered(getToday());
            orderDistribution.setDatePromised(getToday());
            orderDistribution.setM_Shipper_ID(shipperId);
            orderDistribution.setIsInDispute(false);
            orderDistribution.setIsInTransit(false);
            orderDistribution.setSalesRep_ID(getAD_User_ID());
            orderDistribution.saveEx();
        }
        storageList.stream().forEach(storage -> {
            MDDOrderLine orderLine = new MDDOrderLine(orderDistribution);
            orderLine.setM_Locator_ID(storage.getM_Locator_ID());
            orderLine.setM_LocatorTo_ID(outBoundLocator.getM_Locator_ID());
            orderLine.setC_UOM_ID(outBoundOrderLine.getC_UOM_ID());
            orderLine.setM_Product_ID(outBoundOrderLine.getM_Product_ID());
            orderLine.setDateOrdered(getToday());
            orderLine.setDatePromised(outBoundOrderLine.getPickDate());
            orderLine.setWM_InOutBoundLine_ID(outBoundOrderLine.getWM_InOutBoundLine_ID());
            orderLine.setIsInvoiced(false);
            orderLine.saveEx();
        });
    } else {
        qtySupply = outBoundOrderLine.getQtyToPick().subtract(qtySupply);
    }
    return qtySupply;
}
Also used : MBPartner(org.compiere.model.MBPartner) MStorage(org.compiere.model.MStorage) BigDecimal(java.math.BigDecimal) MWarehouse(org.compiere.model.MWarehouse) MDDOrderLine(org.eevolution.model.MDDOrderLine) WMRuleEngine(org.eevolution.engine.warehouse.WMRuleEngine) MOrg(org.compiere.model.MOrg) AdempiereException(org.adempiere.exceptions.AdempiereException) NoBPartnerLinkedforOrgException(org.eevolution.exceptions.NoBPartnerLinkedforOrgException) MDDOrder(org.eevolution.model.MDDOrder) MUser(org.compiere.model.MUser)

Example 8 with MOrg

use of org.compiere.model.MOrg in project adempiere by adempiere.

the class MRPUpdate method doIt.

//	prepare
/**
	 *  doIT - run process
	 */
protected String doIt() throws Exception {
    String result = null;
    ArrayList<Object> parameters = new ArrayList<Object>();
    StringBuffer whereClause = new StringBuffer(MResource.COLUMNNAME_ManufacturingResourceType + "=? AND AD_Client_ID=?");
    parameters.add(MResource.MANUFACTURINGRESOURCETYPE_Plant);
    parameters.add(m_AD_Client_ID);
    if (p_S_Resource_ID > 0) {
        whereClause.append(" AND S_Resource_ID=?");
        parameters.add(p_S_Resource_ID);
    }
    List<MResource> plants = new Query(getCtx(), MResource.Table_Name, whereClause.toString(), get_TrxName()).setParameters(parameters).list();
    if (plants.size() == 0) {
        // TODO: translate
        throw new AdempiereException("No plants found");
    }
    for (MResource plant : plants) {
        log.info("Run MRP to Plant: " + plant.getName());
        parameters = new ArrayList<Object>();
        whereClause = new StringBuffer("AD_Client_ID=?");
        parameters.add(m_AD_Client_ID);
        if (p_AD_Org_ID > 0) {
            whereClause.append(" AND AD_Org_ID=?");
            parameters.add(p_AD_Org_ID);
        }
        List<MOrg> organizations = new Query(getCtx(), MOrg.Table_Name, whereClause.toString(), get_TrxName()).setParameters(parameters).list();
        for (MOrg organization : organizations) {
            log.info("Run MRP to Organization: " + organization.getName());
            if (p_M_Warehouse_ID == 0) {
                MWarehouse[] ws = MWarehouse.getForOrg(getCtx(), organization.getAD_Org_ID());
                for (MWarehouse w : ws) {
                    log.info("Run MRP to Wharehouse: " + w.getName());
                    deleteRecords(m_AD_Client_ID, organization.getAD_Org_ID(), plant.getS_Resource_ID(), w.getM_Warehouse_ID());
                    createRecords(m_AD_Client_ID, organization.getAD_Org_ID(), plant.getS_Resource_ID(), w.getM_Warehouse_ID());
                    result = result + "<br>finish MRP to Warehouse " + w.getName();
                }
            } else {
                log.info("Run MRP to Wharehouse: " + p_M_Warehouse_ID);
                deleteRecords(m_AD_Client_ID, organization.getAD_Org_ID(), plant.getS_Resource_ID(), p_M_Warehouse_ID);
                createRecords(m_AD_Client_ID, organization.getAD_Org_ID(), plant.getS_Resource_ID(), p_M_Warehouse_ID);
            }
            result = result + "<br>finish MRP to Organization " + organization.getName();
        }
        result = result + "<br>finish MRP to Plant " + plant.getName();
    }
    if (Util.isEmpty(result, true)) {
        // TODO: translate
        return "No records found";
    }
    return Msg.getMsg(getCtx(), "ProcessOK");
}
Also used : MResource(org.compiere.model.MResource) Query(org.compiere.model.Query) ArrayList(java.util.ArrayList) MWarehouse(org.compiere.model.MWarehouse) MOrg(org.compiere.model.MOrg) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 9 with MOrg

use of org.compiere.model.MOrg in project adempiere by adempiere.

the class SearchServlet method outputOrgs.

/**
     * Output XML list of Organizations
     * 
     * @param ctx context
     * @param out printWriter
     * @param clientID client ID
     * @param orgID organization ID
     * @param includeAny whether 'ANY' should be added to beginning of the list
     */
private void outputOrgs(Properties ctx, PrintWriter out, int clientID, int orgID, boolean includeAny) {
    MClient client = MClient.get(ctx, clientID);
    out.println("<orgs clientID='" + clientID + "'>");
    if (includeAny) {
        out.println("<org id='-1'");
        if (clientID == 0)
            out.println(" selected='selected'");
        out.println(">ANY</org>");
    }
    if (client != null) {
        for (MOrg org : MOrg.getOfClient(client)) {
            out.print("<org id='" + org.getAD_Org_ID() + "'");
            if (orgID == org.getAD_Org_ID())
                out.print(" selected='selected'");
            out.println(">" + Util.maskHTML(org.getName()) + "</org>");
        }
    }
    out.println("</orgs>");
}
Also used : MOrg(org.compiere.model.MOrg) MClient(org.compiere.model.MClient)

Example 10 with MOrg

use of org.compiere.model.MOrg in project adempiere by adempiere.

the class ImportEmployee method fillIdValues.

/**
     * Fill values and validate employee data
     * This method create the dependences for Race , Department , Job , Job Type
     * Job Education , Career Level , Employee Type and Skill Type
     * @param importEmployee
     * @param trxName
     */
private void fillIdValues(X_I_HR_Employee importEmployee, String trxName) {
    StringBuffer stringError = new StringBuffer("");
    Integer orgId = 0;
    if (importEmployee.getAD_Org_ID() > 0)
        orgId = importEmployee.getAD_Org_ID();
    if (orgId <= 0)
        orgId = getId(MOrg.Table_Name, MOrg.COLUMNNAME_Value + "=?", trxName, importEmployee.getOrgValue());
    if (orgId > 0)
        importEmployee.setAD_Org_ID(orgId);
    Integer partnerId = getId(MBPartner.Table_Name, MBPartner.COLUMNNAME_Value + "=?", trxName, importEmployee.getBPartnerValue());
    if (partnerId > 0)
        importEmployee.setC_BPartner_ID(partnerId);
    else if (isCreatedBusinessPartner()) {
        if (getBusinessPartnerGroupId() > 0) {
            MBPartner partner = createPartnerFromEmployeeData(importEmployee);
            partnerId = partner.get_ID();
            importEmployee.setC_BPartner_ID(partnerId);
        } else
            stringError.append(" @C_BP_Group_ID@ @NotFound@");
    }
    //Set Race
    MHRRace race = null;
    if (importEmployee.getHR_Race_ID() > 0)
        race = MHRRace.getById(getCtx(), importEmployee.getHR_Race_ID());
    if (race != null && race.getHR_Race_ID() < 0 && importEmployee.getRaceValue() != null)
        race = MHRRace.getByValue(getCtx(), importEmployee.getRaceValue());
    if (race == null || race.getHR_Race_ID() < 0) {
        if (importEmployee.getRaceValue() != null && importEmployee.getRaceName() != null) {
            race = new MHRRace(getCtx(), importEmployee.getRaceValue(), importEmployee.getRaceName(), trxName);
            race.saveEx();
        }
    }
    if (race != null && race.getHR_Race_ID() > 0)
        importEmployee.setHR_Race_ID(race.getHR_Race_ID());
    //Set Organization Trx
    MOrg orgTrx = null;
    if (importEmployee.getAD_OrgTrx_ID() > 0)
        orgTrx = MOrg.get(getCtx(), importEmployee.getAD_OrgTrx_ID());
    if (orgTrx == null && importEmployee.getOrgTrxValue() != null) {
        int orgTrxId = getId(MOrg.Table_Name, MOrg.COLUMNNAME_Value + "=?", trxName, importEmployee.getOrgTrxValue());
        orgTrx = MOrg.get(getCtx(), orgTrxId);
    }
    if (orgTrx != null && orgTrx.getAD_Org_ID() > 0)
        importEmployee.setAD_OrgTrx_ID(orgTrx.getAD_Org_ID());
    //Set Project
    MProject project = null;
    if (importEmployee.getC_Project_ID() > 0)
        project = MProject.getById(getCtx(), importEmployee.getC_Project_ID());
    if (project == null && importEmployee.getProjectValue() != null)
        project = MProject.getByValue(getCtx(), importEmployee.getProjectValue());
    if (project != null && project.getC_Project_ID() > 0)
        importEmployee.setC_Project_ID(project.getC_Project_ID());
    //Set Department
    MHRDepartment department = null;
    if (importEmployee.getHR_Department_ID() > 0)
        department = MHRDepartment.getById(getCtx(), importEmployee.getHR_Department_ID());
    if (department == null && importEmployee.getDepartmentValue() != null)
        department = MHRDepartment.getByValue(getCtx(), importEmployee.getDepartmentValue());
    if (department == null || department.getHR_Department_ID() < 0) {
        if (importEmployee.getDepartmentValue() != null && importEmployee.getDepartmentName() != null) {
            department = new MHRDepartment(getCtx(), importEmployee.getDepartmentValue(), importEmployee.getDepartmentName(), trxName);
            department.saveEx();
        }
    }
    if (department != null && department.getHR_Department_ID() > 0)
        importEmployee.setHR_Department_ID(department.getHR_Department_ID());
    //Set Job
    MHRJob job = null;
    if (importEmployee.getHR_Job_ID() > 0)
        job = MHRJob.getById(getCtx(), importEmployee.getHR_Job_ID());
    if (job == null && importEmployee.getJobValue() != null)
        job = MHRJob.getByValue(getCtx(), importEmployee.getJobValue());
    if (job == null || job.getHR_Job_ID() < 0) {
        if (importEmployee.getJobValue() != null && importEmployee.getJobName() != null) {
            job = new MHRJob(getCtx(), importEmployee.getJobValue(), importEmployee.getJobName(), trxName);
            job.saveEx();
        }
    }
    if (job != null && job.getHR_Job_ID() > 0)
        importEmployee.setHR_Job_ID(job.getHR_Job_ID());
    //Set Job Education
    MHRJobEducation jobEducation = null;
    if (importEmployee.getHR_JobEducation_ID() > 0)
        jobEducation = new MHRJobEducation(getCtx(), importEmployee.getHR_JobEducation_ID(), trxName);
    if (jobEducation == null && importEmployee.getJobEducationValue() != null)
        jobEducation = MHRJobEducation.getByValue(getCtx(), importEmployee.getJobEducationValue());
    if (jobEducation == null || jobEducation.getHR_JobEducation_ID() < 0) {
        if (importEmployee.getJobEducationValue() != null && importEmployee.getJobEducationName() != null) {
            jobEducation = new MHRJobEducation(getCtx(), importEmployee.getJobEducationValue(), importEmployee.getJobEducationName(), trxName);
            jobEducation.saveEx();
        }
    }
    if (jobEducation != null && jobEducation.getHR_JobEducation_ID() > 0)
        importEmployee.setHR_JobEducation_ID(jobEducation.getHR_JobEducation_ID());
    // Set Carrer Level
    MHRCareerLevel careerLevel = null;
    if (importEmployee.getHR_CareerLevel_ID() > 0)
        careerLevel = new MHRCareerLevel(getCtx(), importEmployee.getHR_CareerLevel_ID(), trxName);
    if (careerLevel == null && importEmployee.getCareerLevelValue() != null)
        careerLevel = MHRCareerLevel.getByValue(getCtx(), importEmployee.getCareerLevelValue());
    if (careerLevel == null || careerLevel.getHR_CareerLevel_ID() < 0) {
        if (importEmployee.getCareerLevelValue() != null && importEmployee.getCareerLevelName() != null) {
            careerLevel = new MHRCareerLevel(getCtx(), importEmployee.getCareerLevelValue(), importEmployee.getCareerLevelName(), trxName);
            careerLevel.saveEx();
        }
    }
    if (careerLevel != null && careerLevel.getHR_CareerLevel_ID() > 0)
        importEmployee.setHR_CareerLevel_ID(careerLevel.getHR_CareerLevel_ID());
    // Set Job Type
    MHRJobType jobType = null;
    if (importEmployee.getHR_JobType_ID() > 0)
        jobType = MHRJobType.getById(getCtx(), importEmployee.getHR_JobType_ID());
    if (jobType == null && importEmployee.getJobTypeValue() != null)
        jobType = MHRJobType.getByValue(getCtx(), importEmployee.getJobTypeValue());
    if (jobType == null || jobType.getHR_JobType_ID() < 0) {
        if (importEmployee.getJobTypeValue() != null && importEmployee.getJobTypeName() != null) {
            jobType = new MHRJobType(getCtx(), importEmployee.getJobTypeValue(), importEmployee.getJobTypeName(), trxName);
            jobType.saveEx();
        }
    }
    if (jobType != null && jobType.getHR_JobType_ID() > 0)
        importEmployee.setHR_JobType_ID(jobType.getHR_JobType_ID());
    // Set Payroll
    MHRPayroll payroll = null;
    if (importEmployee.getHR_Payroll_ID() > 0)
        payroll = MHRPayroll.getById(getCtx(), importEmployee.getHR_Job_ID());
    if (payroll == null && importEmployee.getPayrollValue() != null)
        payroll = MHRPayroll.getByValue(getCtx(), importEmployee.getPayrollValue());
    if (payroll != null && payroll.getHR_Payroll_ID() > 0)
        importEmployee.setHR_Payroll_ID(payroll.getHR_Payroll_ID());
    // Set Activity
    MActivity activity = null;
    if (importEmployee.getC_Activity_ID() > 0)
        activity = MActivity.getById(getCtx(), importEmployee.getC_Activity_ID());
    if (activity == null && importEmployee.getActivityValue() != null)
        activity = MActivity.getByValue(getCtx(), importEmployee.getActivityValue());
    if (activity != null && activity.getC_Activity_ID() > 0)
        importEmployee.setC_Activity_ID(activity.getC_Activity_ID());
    // Set Campaign
    MCampaign campaign = null;
    if (importEmployee.getC_Campaign_ID() > 0)
        campaign = MCampaign.getById(getCtx(), importEmployee.getC_Campaign_ID());
    if (campaign == null && importEmployee.getCampaignValue() != null)
        campaign = MCampaign.getByValue(getCtx(), importEmployee.getCampaignValue());
    if (campaign != null && campaign.getC_Campaign_ID() > 0)
        importEmployee.setC_Campaign_ID(campaign.getC_Campaign_ID());
    // Set Sales Region
    MSalesRegion salesRegion = null;
    if (importEmployee.getC_SalesRegion_ID() > 0)
        salesRegion = MSalesRegion.getById(getCtx(), importEmployee.getC_SalesRegion_ID());
    if (salesRegion == null && importEmployee.getSalesRegionValue() != null)
        salesRegion = MSalesRegion.getByValue(getCtx(), importEmployee.getSalesRegionValue());
    if (salesRegion != null && salesRegion.getC_SalesRegion_ID() > 0)
        importEmployee.setC_SalesRegion_ID(salesRegion.getC_SalesRegion_ID());
    // Set Work Group
    MHRWorkGroup workGroup = null;
    if (importEmployee.getHR_WorkGroup_ID() > 0)
        workGroup = MHRWorkGroup.getById(getCtx(), importEmployee.getHR_WorkGroup_ID());
    if (workGroup == null && importEmployee.getWorkGroupValue() != null)
        workGroup = MHRWorkGroup.getByValue(getCtx(), importEmployee.getWorkGroupValue());
    if (workGroup != null && workGroup.getHR_WorkGroup_ID() > 0)
        importEmployee.setHR_WorkGroup_ID(workGroup.getHR_WorkGroup_ID());
    // Set Shift Group
    MHRShiftGroup shiftGroup = null;
    if (importEmployee.getHR_ShiftGroup_ID() > 0)
        shiftGroup = MHRShiftGroup.getById(getCtx(), importEmployee.getHR_WorkGroup_ID());
    if (shiftGroup == null && importEmployee.getShiftGroupValue() != null)
        shiftGroup = MHRShiftGroup.getByValue(getCtx(), importEmployee.getWorkGroupValue());
    if (shiftGroup != null && shiftGroup.getHR_ShiftGroup_ID() > 0)
        importEmployee.setHR_ShiftGroup_ID(shiftGroup.getHR_ShiftGroup_ID());
    // Set Degree
    MHRDegree degree = null;
    if (importEmployee.getHR_Degree_ID() > 0)
        degree = MHRDegree.getById(getCtx(), importEmployee.getHR_Degree_ID());
    if (degree == null && importEmployee.getDegreeValue() != null)
        degree = MHRDegree.getByValue(getCtx(), importEmployee.getDegreeValue());
    if (degree == null || degree.getHR_Degree_ID() < 0) {
        if (importEmployee.getDegreeValue() != null && importEmployee.getDegreeName() != null) {
            degree = new MHRDegree(getCtx(), importEmployee.getDegreeValue(), importEmployee.getDegreeName(), trxName);
            degree.saveEx();
        }
    }
    //	Set it
    if (degree != null && degree.getHR_Degree_ID() > 0)
        importEmployee.setHR_Degree_ID(degree.getHR_Degree_ID());
    // Set Grade
    MHRGrade grade = null;
    if (importEmployee.getHR_Grade_ID() > 0)
        grade = MHRGrade.getById(getCtx(), importEmployee.getHR_Grade_ID());
    if (grade == null && importEmployee.getGradeValue() != null)
        grade = MHRGrade.getByValue(getCtx(), importEmployee.getGradeValue());
    if (grade == null || grade.getHR_Grade_ID() < 0) {
        if (importEmployee.getGradeValue() != null && importEmployee.getGradeName() != null) {
            grade = new MHRGrade(getCtx(), importEmployee.getGradeValue(), importEmployee.getGradeName(), trxName);
            grade.saveEx();
        }
    }
    if (grade != null && grade.getHR_Grade_ID() > 0)
        importEmployee.setHR_Grade_ID(grade.getHR_Grade_ID());
    //Set Designation
    MHRDesignation designation = null;
    if (importEmployee.getHR_Designation_ID() > 0)
        designation = MHRDesignation.getById(getCtx(), importEmployee.getHR_Designation_ID());
    if (designation == null && importEmployee.getDesignationValue() != null)
        designation = MHRDesignation.getByValue(getCtx(), importEmployee.getDesignationValue());
    if (designation != null && designation.getHR_Designation_ID() > 0)
        importEmployee.setHR_Designation_ID(designation.getHR_Designation_ID());
    //Set Salary Structure
    MHRSalaryStructure salaryStructure = null;
    if (importEmployee.getHR_SalaryRange_ID() > 0)
        salaryStructure = MHRSalaryStructure.getById(getCtx(), importEmployee.getHR_SalaryStructure_ID());
    if (salaryStructure == null && importEmployee.getSalaryStructureValue() != null)
        salaryStructure = MHRSalaryStructure.getByValue(getCtx(), importEmployee.getSalaryStructureValue());
    if (salaryStructure != null && salaryStructure.getHR_SalaryStructure_ID() > 0)
        importEmployee.setHR_SalaryRange_ID(salaryStructure.getHR_SalaryStructure_ID());
    //Set Salary Range
    MHRSalaryRange salaryRange = null;
    if (importEmployee.getHR_SalaryRange_ID() > 0)
        salaryRange = MHRSalaryRange.getById(getCtx(), importEmployee.getHR_SalaryRange_ID());
    if (salaryRange == null && importEmployee.getSalaryRangeValue() != null)
        salaryRange = MHRSalaryRange.getByValue(getCtx(), importEmployee.getSalaryRangeValue());
    if (salaryRange != null && salaryRange.getHR_SalaryRange_ID() > 0)
        importEmployee.setHR_SalaryRange_ID(salaryRange.getHR_SalaryRange_ID());
    // Set Employee Type
    MHREmployeeType employeeType = null;
    if (importEmployee.getHR_EmployeeType_ID() > 0)
        employeeType = MHREmployeeType.getById(getCtx(), importEmployee.getHR_EmployeeType_ID());
    if (employeeType == null && importEmployee.getEmployeeTypeValue() != null)
        employeeType = MHREmployeeType.getByValue(getCtx(), importEmployee.getEmployeeTypeValue());
    if (employeeType == null || employeeType.getHR_EmployeeType_ID() < 0) {
        if (importEmployee.getEmployeeTypeValue() != null && importEmployee.getEmployeeTypeName() != null && payroll != null && payroll.getHR_Payroll_ID() > 0) {
            employeeType = new MHREmployeeType(getCtx(), importEmployee.getEmployeeTypeValue(), importEmployee.getEmployeeTypeName(), MHREmployeeType.WAGELEVEL_Daily, payroll.getHR_Payroll_ID(), trxName);
            employeeType.saveEx();
        }
    }
    if (employeeType != null && employeeType.getHR_EmployeeType_ID() > 0)
        importEmployee.setHR_EmployeeType_ID(employeeType.getHR_EmployeeType_ID());
    // Set Skill Type
    MHRSkillType skillType = null;
    if (importEmployee.getHR_SkillType_ID() > 0)
        skillType = MHRSkillType.getById(getCtx(), importEmployee.getHR_SkillType_ID());
    if (skillType == null && importEmployee.getSkillTypeValue() != null)
        skillType = MHRSkillType.getByValue(getCtx(), importEmployee.getSkillTypeValue());
    if (skillType == null || skillType.getHR_SkillType_ID() < 0) {
        if (importEmployee.getSkillTypeValue() != null && importEmployee.getSkillTypeName() != null) {
            skillType = new MHRSkillType(getCtx(), importEmployee.getSkillTypeValue(), importEmployee.getSkillTypeName(), trxName);
            skillType.saveEx();
        }
    }
    if (skillType != null && skillType.getHR_SkillType_ID() > 0)
        importEmployee.setHR_SkillType_ID(skillType.getHR_SkillType_ID());
    if (importEmployee.getAD_Org_ID() <= 0)
        stringError.append(" @AD_Org_ID@ @IsMandatory@");
    if (importEmployee.getC_BPartner_ID() <= 0)
        stringError.append(" @C_BPartner_ID@ @IsMandatory@,");
    if (importEmployee.getHR_Department_ID() <= 0)
        stringError.append(" @HR_Department_ID@ @NotFound@,");
    if (importEmployee.getHR_Job_ID() <= 0)
        stringError.append(" @HR_Job_ID@ @NotFound@,");
    if (importEmployee.getStartDate() == null)
        stringError.append(" @StartDate@ @IsMandatory@ ");
    if (!stringError.toString().isEmpty() && stringError.toString().length() > 0) {
        importEmployee.setI_ErrorMsg(Msg.parseTranslation(getCtx(), stringError.toString()));
        importEmployee.saveEx();
    }
    importEmployee.saveEx();
}
Also used : MHRPayroll(org.eevolution.model.MHRPayroll) MHRGrade(org.eevolution.model.MHRGrade) MActivity(org.compiere.model.MActivity) MHRDepartment(org.eevolution.model.MHRDepartment) MHRDesignation(org.eevolution.model.MHRDesignation) MHRRace(org.eevolution.model.MHRRace) MProject(org.compiere.model.MProject) MHREmployeeType(org.eevolution.model.MHREmployeeType) MHRJob(org.eevolution.model.MHRJob) MSalesRegion(org.compiere.model.MSalesRegion) MCampaign(org.compiere.model.MCampaign) MBPartner(org.compiere.model.MBPartner) MHRSalaryRange(org.eevolution.model.MHRSalaryRange) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MHRShiftGroup(org.eevolution.model.MHRShiftGroup) MHRWorkGroup(org.eevolution.model.MHRWorkGroup) MHRDegree(org.eevolution.model.MHRDegree) MOrg(org.compiere.model.MOrg) MHRSalaryStructure(org.eevolution.model.MHRSalaryStructure) MHRJobEducation(org.eevolution.model.MHRJobEducation) MHRJobType(org.eevolution.model.MHRJobType) MHRSkillType(org.eevolution.model.MHRSkillType) MHRCareerLevel(org.eevolution.model.MHRCareerLevel)

Aggregations

MOrg (org.compiere.model.MOrg)18 MBPartner (org.compiere.model.MBPartner)8 MWarehouse (org.compiere.model.MWarehouse)8 BigDecimal (java.math.BigDecimal)7 Query (org.compiere.model.Query)5 MDDOrder (org.eevolution.model.MDDOrder)5 MDDOrderLine (org.eevolution.model.MDDOrderLine)5 MOrgInfo (org.compiere.model.MOrgInfo)4 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 Timestamp (java.sql.Timestamp)3 AdempiereException (org.adempiere.exceptions.AdempiereException)3 MClient (org.compiere.model.MClient)3 MLocator (org.compiere.model.MLocator)3 SQLException (java.sql.SQLException)2 Vector (java.util.Vector)2 IDColumn (org.compiere.minigrid.IDColumn)2 MActivity (org.compiere.model.MActivity)2 MBPartnerLocation (org.compiere.model.MBPartnerLocation)2 MCampaign (org.compiere.model.MCampaign)2