Exemplo n.º 1
0
  /**
   * Find if this product as component
   *
   * @param M_Product_ID ID Component
   */
  public void component(int M_Product_ID, BigDecimal qtyRequiered) throws Exception {

    if (LevelNo == p_LevelNo) return;

    String value =
        DB.getSQLValueString(
            get_TrxName(), "SELECT Value FROM M_Product WHERE M_Product_ID=?", M_Product_ID);

    final StringBuilder whereClause =
        new StringBuilder(MPPProductBOM.COLUMNNAME_Value)
            .append("=? AND ")
            .append(MPPProductBOM.COLUMNNAME_M_Product_ID)
            .append("=?");
    List<MPPProductBOM> boms =
        new Query(getCtx(), MPPProductBOM.Table_Name, whereClause.toString(), get_TrxName())
            .setClient_ID()
            .setOnlyActiveRecords(true)
            .setParameters(value, M_Product_ID)
            .list();

    boolean level = false;
    for (MPPProductBOM bom : boms) {
      if (bom.isValidFromTo(p_DateTrx)) {
        if (!level) LevelNo += 1;
        level = true;
        parentExplotion(bom.get_ID(), qtyRequiered);
        LevelNo -= 1;
      }
    }
  }
Exemplo n.º 2
0
  /** Action: Fill Tree with all nodes */
  private void loadBOM() throws Exception {
    int count = 0;
    if (p_M_Product_ID == 0) raiseError("Error: ", "Product ID not found");

    MProduct product = new MProduct(getCtx(), p_M_Product_ID, get_TrxName());
    X_T_BOMLine tboml = new X_T_BOMLine(ctx, 0, null);
    tboml.setAD_Org_ID(product.getAD_Org_ID());
    tboml.setPP_Product_BOM_ID(0);
    tboml.setPP_Product_BOMLine_ID(0);
    tboml.setSel_Product_ID(p_M_Product_ID);
    tboml.setM_Product_ID(p_M_Product_ID);
    tboml.setSel_Product_ID(p_M_Product_ID);
    tboml.setDateTrx(p_DateTrx);
    tboml.setImplosion(false);
    tboml.setLevelNo(0);
    tboml.setLevels("0");
    tboml.setQtyBOM(Env.ONE);
    tboml.setQtyRequired(p_QtyRequiered);
    tboml.setM_Warehouse_ID(p_M_Warehouse_ID);
    tboml.setSeqNo(0);
    tboml.setAD_PInstance_ID(AD_PInstance_ID);
    tboml.saveEx();

    final String whereClause = MPPProductBOM.COLUMNNAME_M_Product_ID + "=?";
    List<MPPProductBOM> boms =
        new Query(getCtx(), X_PP_Product_BOM.Table_Name, whereClause, get_TrxName())
            .setClient_ID()
            .setOnlyActiveRecords(true)
            .setParameters(p_M_Product_ID)
            .list();

    for (MPPProductBOM bom : boms) {
      if (bom.isValidFromTo(p_DateTrx)) {
        parentExplotion(bom.get_ID(), p_QtyRequiered);
        ++count;
      }
    }

    if (count == 0) raiseError("Error: ", "Product is not a BOM");
  }