Package org.compiere.model

Examples of org.compiere.model.MProduct


  private boolean save()
  {
    String errorString;
    //CHANGES START HERE 2010-09-17 rgliddon: Added checking of whether product has a cost
    int m_product_id  = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_Product_ID");
    MProduct prod = MProduct.get(Env.getCtx(), m_product_id);
   
    // Check that the product has a cost associated with it
    if (prod != null)
    {
      if (!prod.hasCost())
      {
        errorString = "Product must have a cost before it can be added to a price list.";
        statusBar.setStatusLine(errorString, true);
        ADialog.error(m_WindowNo, this, errorString);
        return false;
View Full Code Here


  private void action_loadBOM()
  {
    int M_Product_ID = getM_Product_ID();
    if (M_Product_ID == 0)
      return;
    MProduct M_Product = MProduct.get(getCtx(), M_Product_ID);
    DefaultMutableTreeNode parent = new DefaultMutableTreeNode(productSummary(M_Product, false));

    dataBOM.clear();

    if (isImplosion())
View Full Code Here

    MAcctSchema as = new MAcctSchema (
        Env.getCtx(),
        Integer.parseInt(Env.getCtx().getProperty("#AD_Client_ID")),
        "MAcctSchema"
      );
  MProduct prod = new MProduct(Env.getCtx(),bomline.getM_Product_ID(),"MProduct");
  //MCostElement e = MCostElement.
  MCost cost = MCost.get(prod, bomline.getM_AttributeSetInstance_ID(), as, 0,1000001);
  return cost;
  }
View Full Code Here

  public DefaultMutableTreeNode parent(MPPProductBOMLine bomline)
  {
    log.info("Parent(bomline) " );

    //System.out.println("-------------------------Parent:" + bom.getName());
    MProduct M_Product = MProduct.get(getCtx(), bomline.getM_Product_ID());
    MPPProductBOM bomproduct = new MPPProductBOM(getCtx(), bomline.getPP_Product_BOM_ID(), null);
    DefaultMutableTreeNode parent = new DefaultMutableTreeNode(productSummary(M_Product, false));

    Vector<Object> line = new Vector<Object>(17);
    line.add( new Boolean(false))//  0 Select
    line.add( new Boolean(true));   //  1 IsActive
    line.add( new Integer(bomline.getLine())); // 2 Line               
    line.add( (Timestamp) bomline.getValidFrom()); //  3 ValidDrom
    line.add( (Timestamp) bomline.getValidTo()); //  4 ValidTo
    KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(),M_Product.getName());
    line.add(pp); //  5 M_Product_ID
    KeyNamePair uom = new KeyNamePair(bomline.getC_UOM_ID(),bomline.getC_UOM().getUOMSymbol());
    line.add(uom); //  6 C_UOM_ID
    line.add(new Boolean(bomline.isQtyPercentage())); //  7 IsQtyPorcentage
    line.add((BigDecimal) bomline.getQtyBatch())//  8 BatchPercent
    line.add((BigDecimal) ((bomline.getQtyBOM()!=null) ? bomline.getQtyBOM() : new BigDecimal(0)))//  9 QtyBOM
    line.add(new Boolean(bomline.isCritical())); //  10 IsCritical                 
    line.add( (Integer) bomline.getLeadTimeOffset()); // 11 LTOffSet
    line.add( (BigDecimal) bomline.getAssay()); // 12 Assay
    line.add( (BigDecimal) (bomline.getScrap())); // 13 Scrap
    line.add( (String) bomline.getIssueMethod()); // 14 IssueMethod
    line.add( (String) bomline.getBackflushGroup())// 15 BackflushGroup
    line.add( (BigDecimal) bomline.getForecast()); // 16 Forecast

    /*CHANGES START HERE DOMINIC TARR 20081110*/
    MCost cost = getCostForBomLine(bomline);
    line.add( (BigDecimal) cost.getCurrentCostPrice()); //17 standard cost ***
    line.add( (BigDecimal) cost.getCurrentCostPriceLL()); //18 rolled up cost ***
    line.add( (BigDecimal) cost.getFutureCostPrice()); //19 future cost ***
    line.add( (BigDecimal.ZERO)); //20 standard cost ***
    line.add( (BigDecimal.ZERO)); //21 rolled up cost ***
    line.add( (BigDecimal.ZERO)); //22 future cost ***
    /*CHANGES END HERE DOMINIC TARR 20081110*/

    dataBOM.add(line);

    for (MPPProductBOM bom : getBOMs(bomproduct.getM_Product_ID(), false))
    {
      MProduct component = MProduct.get(getCtx(), bom.getM_Product_ID());
      return component(component, BigDecimal.ONE);
    }

    return parent;

View Full Code Here

    //vparent.setValue(m_product_id);
    DefaultMutableTreeNode parent = new DefaultMutableTreeNode(productSummary(bom));

    for (MPPProductBOMLine bomline : bom.getLines())
    {
      MProduct component = MProduct.get(getCtx(), bomline.getM_Product_ID());
      //System.out.println("Componente :" + component.getValue() + "[" + component.getName() + "]");
      //component(component);
      Vector<Object> line = new Vector<Object>(17);
      line.add( new Boolean(false))//  0 Select
      line.add( new Boolean(true));   //  1 IsActive
      line.add( new Integer(bomline.getLine())); // 2 Line               
      line.add( (Timestamp) bomline.getValidFrom()); //  3 ValidDrom
      line.add( (Timestamp) bomline.getValidTo()); //  4 ValidTo
      KeyNamePair pp = new KeyNamePair(component.getM_Product_ID(),component.getName());
      line.add(pp); //  5 M_Product_ID
      KeyNamePair uom = new KeyNamePair(bomline.getC_UOM_ID(),bomline.getC_UOM().getUOMSymbol());
      line.add(uom); //  6 C_UOM_ID
      line.add(new Boolean(bomline.isQtyPercentage())); //  7 IsQtyPercentage
      line.add((BigDecimal) bomline.getQtyBatch())//  8 BatchPercent
View Full Code Here

        //boolean isInvoiced = (C_InvoiceLine_ID != 0);
        //  Precision of Qty UOM
        int precision = 2;
        if (M_Product_ID != 0)
        {
          MProduct product = MProduct.get(Env.getCtx(), M_Product_ID);
          precision = product.getUOMPrecision();
        }
        QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_DOWN);
        //
        log.fine("Line QtyEntered=" + QtyEntered
            + ", Product=" + M_Product_ID
View Full Code Here

      if (bomline.isCoProduct())
      {
        continue;
      }
      //
      MProduct component = MProduct.get(getCtx(), bomline.getM_Product_ID());
      // get the rate for this resource    
      for (MCost cost : getCosts(component, element.get_ID()))
      {                
        BigDecimal qty = bomline.getQty(true);
       
        // ByProducts
        if (bomline.isByProduct())
        {
          cost.setCurrentCostPriceLL(Env.ZERO);
        }
       
        // 2010-07-30 rgliddon: Removed adding currentCostPriceLL to the cost price since
        // it was effectively doubling the cost figures.
        BigDecimal costPrice = cost.getCurrentCostPrice();
        BigDecimal componentCost = costPrice.multiply(qty);
        costPriceLL = costPriceLL.add(componentCost);
        log.info("CostElement: "+element.getName()
            + ", Component: "+component.getValue()
            + ", CostPrice: "+costPrice
            + ", Qty: " + qty
            + ", Cost: " + componentCost
            + " => Total Cost Element: " +  costPriceLL);
      } // for each cost
View Full Code Here

   *          pack does not have an SG value.
   */
  protected String doIt() throws Exception
  {
    X_Z_Packs     pack     = new X_Z_Packs(getCtx(), getRecord_ID(), get_TrxName());
    MProduct      product  = new MProduct(getCtx(), pack.getM_Product_ID(), get_TrxName());
    MPPProductBOM bom      = MPPProductBOM.get(product, getAD_Client_ID(), get_TrxName());
    MLocator      loc      = new MLocator(getCtx(), p_M_Locator_ID, get_TrxName());
    int           chargeID = getChargeID();
   
    // Error Checking.  An error results in an exception thrown which is caught
    // by SrvProcess which then rolls back any changes to the database made as
    // part of the get_TrxName() transaction.
    if (bom.is_new())
      throw new AdempiereUserError("@Error@ Bill Of Materials does not exist for "+
                                   product.getName());
    if (product.getVolume() == null || product.getVolume().doubleValue() <= 0)
      throw new AdempiereUserError("@Error@ Volume value for product "+product.getName()+
                                   " is zero or less.");
    if (!product.isVerified())
      throw new AdempiereUserError("@Error@ Product "+product.getName()+" is not verified");

    // Create the Inventory record
    MInventory inv = new MInventory(getCtx(), 0, get_TrxName());
    inv.setM_Warehouse_ID(loc.getM_Warehouse_ID());
    inv.setClientOrg(getAD_Client_ID(), Env.getAD_Org_ID(getCtx()));
View Full Code Here

                            MInventory    inv,
                            int           chargeID) throws Exception
  {
    MPPProductBOMLine[] bomLines = bom.getLines();
    MInventoryLine invLine;
    MProduct lineProduct;
    MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(),
                                                          pack.getM_AttributeSetInstance_ID(),
                                                          get_TrxName());
    BigDecimal sg = (BigDecimal)asi.get_Value("SG");
    BigDecimal vol;
    int asiID;
   
    // Make sure SG in the Attribute Set Instance has a value.  Abort if not.
    if (sg == null || sg.equals(BigDecimal.valueOf(0)))
      throw new AdempiereUserError("@Error@ SG value not set for Attribute Set Instance "+
                                   asi.getDescription());
   
    // Generate inventory lines from the BOM lines
    for (MPPProductBOMLine bomLine : bomLines)
    {
      lineProduct = new MProduct(getCtx(), bomLine.getM_Product_ID(), get_TrxName());
     
      // Only assign the Attribute Set Instance to lines where the product on
      // that line has a Finished Product Batch Number
      if (lineProduct.getAttributeSet() != null &&
          lineProduct.getAttributeSet().getName().equals("Finished Product Batch Number"))
        asiID = asi.getM_AttributeSetInstance_ID();
      else
        asiID = 0;
     
      invLine = new MInventoryLine(inv,
                                   p_M_Locator_ID,
                                   lineProduct.getM_Product_ID(),
                                   asiID,
                                   BigDecimal.ZERO,
                                   BigDecimal.ZERO);
     
      // Bulk line calculation = Qty x SG x Vol.  Other lines = Qty x QtyBOM.
      if ((Boolean)lineProduct.get_Value("IsBulk"))
      {
        vol = packedProduct.getVolume();
        invLine.setQtyInternalUse(pack.getQty().multiply(sg).multiply(vol));
      }
      else
View Full Code Here

    printLog("posting stdcost!");
    //    int M_CostType_ID = 1000001;
    //cost type is set on the accounting schema. when you call getCurrentCost it selects the current cost for the
    //default cost type for the accounting schema.
    MProduct product = new MProduct (getCtx(),f.getM_Product_ID(),getTrxName());
    BigDecimal cost = MCost.getCurrentCost product,
        p.getM_AttributeSetInstance_ID(),as, f.getAD_Org_ID(), //M_CostType_ID ,
        MCost.COSTINGMETHOD_StandardCosting,
        (BigDecimal) f.get_Value("qty"),
        p.getC_OrderLine_ID(),
View Full Code Here

TOP

Related Classes of org.compiere.model.MProduct

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.