Search in sources :

Example 1 with X_I_Product_BOM

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

the class ImportProductBOM method doIt.

@Override
protected String doIt() throws Exception {
    if (m_DeleteOldImported) {
        int no = 0;
        for (X_I_Product_BOM bom : getRecords(true, false)) {
            bom.deleteEx(true);
            no++;
        }
        log.fine("Delete Old Impored =" + no);
    }
    fillIDValues();
    importRecords();
    return "Imported: " + imported;
}
Also used : X_I_Product_BOM(org.eevolution.model.X_I_Product_BOM)

Example 2 with X_I_Product_BOM

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

the class ImportProductBOM method importRecords.

/**
	 * import the I_Product_BOM records to PP_ProductBOM table
	 */
private void importRecords() {
    for (X_I_Product_BOM importBOM : getRecords(false, m_IsImportOnlyNoErrors)) {
        isImported = false;
        MPPProductBOM bom = getMPPProductBOM(importBOM);
        MPPProductBOMLine bomLine = null;
        if (bom != null)
            bomLine = importBOMLine(bom, importBOM);
        if (bomLine != null) {
            importBOM.setPP_Product_BOMLine_ID(bomLine.getPP_Product_BOMLine_ID());
            importBOM.setPP_Product_BOM_ID(bom.get_ID());
            imported++;
            isImported = true;
        }
        importBOM.setI_IsImported(isImported);
        importBOM.setProcessed(isImported);
        importBOM.saveEx();
    }
}
Also used : X_I_Product_BOM(org.eevolution.model.X_I_Product_BOM) MPPProductBOM(org.eevolution.model.MPPProductBOM) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine)

Example 3 with X_I_Product_BOM

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

the class ImportProductBOM method fillIDValues.

/**
	 * fill IDs values based on Search Key
	 **/
private void fillIDValues() {
    for (X_I_Product_BOM importBOM : getRecords(false, m_IsImportOnlyNoErrors)) {
        // Validate Organization
        int AD_Org_ID = 0;
        if (importBOM.getAD_Org_ID() > 0)
            AD_Org_ID = getID(MOrg.Table_Name, "AD_Org_ID = ?", new Object[] { importBOM.getAD_Org_ID() });
        if (AD_Org_ID < 0 && importBOM.getOrgValue() != null) {
            AD_Org_ID = getID(MOrg.Table_Name, "Value = ?", new Object[] { importBOM.getOrgValue() });
            importBOM.setAD_Org_ID(AD_Org_ID);
        } else
            importBOM.setAD_Org_ID(AD_Org_ID);
        // Validate Product
        int M_Product_ID = 0;
        if (importBOM.getM_Product_ID() > 0)
            M_Product_ID = getID(MProduct.Table_Name, "M_Product_ID=?", new Object[] { importBOM.getM_Product_ID() });
        if (M_Product_ID <= 0 && importBOM.getProductValue() != null) {
            M_Product_ID = getID(MProduct.Table_Name, "Value=?", new Object[] { importBOM.getProductValue() });
        }
        // header
        importBOM.setM_Product_ID(M_Product_ID);
        // Validate Component
        int M_Component_ID = 0;
        if (importBOM.getM_BOMProduct_ID() > 0)
            M_Component_ID = getID(MProduct.Table_Name, "M_Product_ID=?", new Object[] { importBOM.getM_BOMProduct_ID() });
        if (M_Component_ID <= 0 && importBOM.getProduct_BOM_Value() != null) {
            M_Component_ID = getID(MProduct.Table_Name, "Value=?", new Object[] { importBOM.getProduct_BOM_Value() });
        }
        // lines
        importBOM.setM_BOMProduct_ID(M_Component_ID);
        // Validate UOM
        int C_UOM_ID = 0;
        if (importBOM.getC_UOM_ID() > 0)
            C_UOM_ID = getID(MUOM.Table_Name, "C_UOM_ID=?", new Object[] { importBOM.getC_UOM_ID() });
        if (C_UOM_ID <= 0 && importBOM.getX12DE355() != null) {
            C_UOM_ID = getID(MUOM.Table_Name, "X12DE355=?", new Object[] { importBOM.getX12DE355() });
        }
        // uom code
        importBOM.setC_UOM_ID(C_UOM_ID);
        StringBuffer err = new StringBuffer("");
        if (importBOM.getAD_Org_ID() < 0)
            err.append(" @AD_Org_ID@ @NotFound@,");
        if (importBOM.getM_Product_ID() <= 0)
            err.append(" @M_Product_ID@ @NotFound@,");
        if (importBOM.getM_BOMProduct_ID() <= 0)
            err.append(" @M_ProductBOM_ID@ @NotFound@");
        if (importBOM.getDocumentNo() == null)
            err.append(" @FillMandatory@ @DocumentNo@");
        if (err.toString() != null && err.toString().length() > 0) {
            importBOM.setI_ErrorMsg(Msg.parseTranslation(getCtx(), err.toString()));
        }
        importBOM.saveEx();
    }
}
Also used : X_I_Product_BOM(org.eevolution.model.X_I_Product_BOM)

Aggregations

X_I_Product_BOM (org.eevolution.model.X_I_Product_BOM)3 MPPProductBOM (org.eevolution.model.MPPProductBOM)1 MPPProductBOMLine (org.eevolution.model.MPPProductBOMLine)1