Пример #1
0
 /**
  * Set Product
  *
  * @param product product
  */
 public void setProduct(MProduct product) {
   Services.get(IOrderLineBL.class)
       .setM_Product_ID(
           InterfaceWrapperHelper.create(this, de.metas.interfaces.I_C_OrderLine.class),
           product.getM_Product_ID(),
           true);
 } // setProduct
Пример #2
0
 /**
  * Set Product
  *
  * @param product product
  */
 public void setProduct(MProduct product) {
   m_product = product;
   if (m_product != null) {
     setM_Product_ID(m_product.getM_Product_ID());
     setC_UOM_ID(m_product.getC_UOM_ID());
   } else {
     setM_Product_ID(0);
     setC_UOM_ID(0);
   }
   setM_AttributeSetInstance_ID(0);
 } //	setProduct
Пример #3
0
  /**
   * Add Product
   *
   * @param element panel
   * @param product product
   */
  private void addProduct(CPanel element, MProduct product) {
    Insets ii = new Insets(2, 4, 2, 4);
    int M_Product_ID = product.getM_Product_ID();
    CPanel pe = new CPanel();
    pe.setBorder(BorderFactory.createLineBorder(Color.BLUE, 1));
    pe.setLayout(new GridBagLayout());

    //	Product Value - Price
    pe.add(
        new JLabel(product.getValue()),
        new GridBagConstraints(
            0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, ii, 0, 0));
    String formatted = "";
    if (m_M_PriceList_Version_ID != 0) {
      MProductPrice pp =
          MProductPrice.get(Env.getCtx(), m_M_PriceList_Version_ID, M_Product_ID, null);
      if (pp != null) {
        BigDecimal price = pp.getPriceStd();
        formatted = m_price.format(price);
      } else formatted = "-";
    }
    pe.add(
        new JLabel(formatted, JLabel.RIGHT),
        new GridBagConstraints(
            1, 0, 1, 1, .5, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, ii, 0, 0));

    //	Product Name - Qty
    pe.add(
        new JLabel(product.getName()),
        new GridBagConstraints(
            0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, ii, 0, 0));
    formatted = "";
    if (m_M_Warehouse_ID != 0) {
      BigDecimal qty = MStorage.getQtyAvailable(m_M_Warehouse_ID, M_Product_ID, 0, null);
      if (qty == null) formatted = "-";
      else formatted = m_qty.format(qty);
    }
    pe.add(
        new JLabel(formatted, JLabel.RIGHT),
        new GridBagConstraints(
            1, 1, 1, 1, .5, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, ii, 0, 0));
    //
    element.add(pe);
  } //	addProduct
Пример #4
0
  /**
   * Get Product from Cache
   *
   * @param ctx context
   * @param S_Resource_ID resource ID
   * @param trxName
   * @return MProduct or null if not found
   */
  public static MProduct forS_Resource_ID(Properties ctx, int S_Resource_ID, String trxName) {
    if (S_Resource_ID <= 0) {
      return null;
    }

    // Try Cache
    if (trxName == null) {
      for (MProduct p : s_cache.values()) {
        if (p.getS_Resource_ID() == S_Resource_ID) {
          return p;
        }
      }
    }
    // Load from DB
    MProduct p =
        new Query(ctx, Table_Name, COLUMNNAME_S_Resource_ID + "=?", trxName)
            .setParameters(new Object[] {S_Resource_ID})
            .firstOnly();
    if (p != null && trxName == null) {
      s_cache.put(p.getM_Product_ID(), p);
    }
    return p;
  }