Package org.compiere.model

Examples of org.compiere.model.MCost


        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


    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*/

 
View Full Code Here

      int p = dataBOM.size();
      MutableTreeNode c = component(component,qty.multiply((BigDecimal) bomline.getQtyBOM()));
      parent.add(c);
      /*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 ***
      if(c.isLeaf()){
        line.add( bq.multiply(cost.getCurrentCostPrice())); //17 standard cost ***
        line.add( bq.multiply(cost.getCurrentCostPriceLL())); //18 rolled up cost ***
        line.add( bq.multiply(cost.getFutureCostPrice())); //19 future cost ***
     
      }else{
        line.add(BigDecimal.ZERO); //17 standard cost ***
        line.add(BigDecimal.ZERO); //18 rolled up cost ***
        line.add(BigDecimal.ZERO); //19 future cost ***
 
View Full Code Here

        continue;
      }
      final BigDecimal costPrice = baseCost.getCurrentCostPriceLL().multiply(bomline.getCostAllocationPerc());
      //
      // Get/Create Cost
      MCost cost = MCost.get(baseCost.getCtx(), baseCost.getAD_Client_ID(), baseCost.getAD_Org_ID(),
                  bomline.getM_Product_ID(),
                  baseCost.getM_CostType_ID(), baseCost.getC_AcctSchema_ID(),
                  baseCost.getM_CostElement_ID(),
                  0, // ASI
                  baseCost.get_TrxName());
      if (cost == null)
      {
        cost = new MCost (baseCost.getCtx(), 0, baseCost.get_TrxName());
        //cost.setAD_Client_ID(baseCost.getAD_Client_ID());
        cost.setAD_Org_ID(baseCost.getAD_Org_ID());
        cost.setM_Product_ID(bomline.getM_Product_ID());
        cost.setM_CostType_ID(baseCost.getM_CostType_ID());
        cost.setC_AcctSchema_ID(baseCost.getC_AcctSchema_ID());
        cost.setM_CostElement_ID(baseCost.getM_CostElement_ID());
        cost.setM_AttributeSetInstance_ID(0);
      }
      cost.setCurrentCostPriceLL(costPrice);
      cost.saveEx();
      costPriceTotal = costPriceTotal.add(costPrice);
    }
    // Update Base Cost:
    if(costPriceTotal.signum() != 0)
    {
View Full Code Here

   @param as acct schema
   *  @return true if created
   */
  private boolean createNew (MProduct product, MAcctSchema as)
  {
    MCost cost = MCost.get(product, 0, as, 0, m_ce.getM_CostElement_ID());
    if (cost.is_new())
      return cost.save();
    return false;
  //  createNew
View Full Code Here

      if (p_M_Product_Category_ID != 0)
        pstmt.setInt (2, p_M_Product_Category_ID);
      ResultSet rs = pstmt.executeQuery ();
      while (rs.next ())
      {
        MCost cost = new MCost (getCtx(), rs, get_TrxName());
        for (int i = 0; i < m_ass.length; i++)
        {
          //  Update Costs only for default Cost Type
          if (m_ass[i].getC_AcctSchema_ID() == cost.getC_AcctSchema_ID()
            && m_ass[i].getM_CostType_ID() == cost.getM_CostType_ID())
          {
            if (update (cost))
              counter++;
          }
        }
View Full Code Here

    if (to.equals(TO_AverageInvoice))
    {
      MCostElement ce = getCostElement(TO_AverageInvoice);
      if (ce == null)
        throw new AdempiereSystemError("CostElement not found: " + TO_AverageInvoice);
      MCost xCost = MCost.get(getCtx(), cost.getAD_Client_ID(), cost.getAD_Org_ID(), cost.getM_Product_ID(), cost.getM_CostType_ID(), cost.getC_AcctSchema_ID(), ce.getM_CostElement_ID(), cost.getM_AttributeSetInstance_ID());
      if (xCost != null)
        retValue = xCost.getCurrentCostPrice();
    }
    //  Average Invoice History
    else if (to.equals(TO_AverageInvoiceHistory))
    {
      MCostElement ce = getCostElement(TO_AverageInvoice);
      if (ce == null)
        throw new AdempiereSystemError("CostElement not found: " + TO_AverageInvoice);
      MCost xCost = MCost.get(getCtx(), cost.getAD_Client_ID(), cost.getAD_Org_ID(), cost.getM_Product_ID(), cost.getM_CostType_ID(), cost.getC_AcctSchema_ID(), ce.getM_CostElement_ID(), cost.getM_AttributeSetInstance_ID());
      if (xCost != null)
        retValue = xCost.getHistoryAverage();
    }
   
    //  Average PO
    else if (to.equals(TO_AveragePO))
    {
      MCostElement ce = getCostElement(TO_AveragePO);
      if (ce == null)
        throw new AdempiereSystemError("CostElement not found: " + TO_AveragePO);
      MCost xCost = MCost.get(getCtx(), cost.getAD_Client_ID(), cost.getAD_Org_ID(), cost.getM_Product_ID(), cost.getM_CostType_ID(), cost.getC_AcctSchema_ID(), ce.getM_CostElement_ID(), cost.getM_AttributeSetInstance_ID());
      if (xCost != null)
        retValue = xCost.getCurrentCostPrice();
    }
    //  Average PO History
    else if (to.equals(TO_AveragePOHistory))
    {
      MCostElement ce = getCostElement(TO_AveragePO);
      if (ce == null)
        throw new AdempiereSystemError("CostElement not found: " + TO_AveragePO);
      MCost xCost = MCost.get(getCtx(), cost.getAD_Client_ID(), cost.getAD_Org_ID(), cost.getM_Product_ID(), cost.getM_CostType_ID(), cost.getC_AcctSchema_ID(), ce.getM_CostElement_ID(), cost.getM_AttributeSetInstance_ID());
      if (xCost != null)
        retValue = xCost.getHistoryAverage();
    }
   
    //  FiFo
    else if (to.equals(TO_FiFo))
    {
      MCostElement ce = getCostElement(TO_FiFo);
      if (ce == null)
        throw new AdempiereSystemError("CostElement not found: " + TO_FiFo);
      MCost xCost = MCost.get(getCtx(), cost.getAD_Client_ID(), cost.getAD_Org_ID(), cost.getM_Product_ID(), cost.getM_CostType_ID(), cost.getC_AcctSchema_ID(), ce.getM_CostElement_ID(), cost.getM_AttributeSetInstance_ID());
      if (xCost != null)
        retValue = xCost.getCurrentCostPrice();
    }

    //  Future Std Costs
    else if (to.equals(TO_FutureStandardCost))
      retValue = cost.getFutureCostPrice();
   
    //  Last Inv Price
    else if (to.equals(TO_LastInvoicePrice))
    {
      MCostElement ce = getCostElement(TO_LastInvoicePrice);
      if (ce != null)
      {
        MCost xCost = MCost.get(getCtx(), cost.getAD_Client_ID(), cost.getAD_Org_ID(), cost.getM_Product_ID(), cost.getM_CostType_ID(), cost.getC_AcctSchema_ID(), ce.getM_CostElement_ID(), cost.getM_AttributeSetInstance_ID());
        if (xCost != null)
          retValue = xCost.getCurrentCostPrice();
      }
      if (retValue == null)
      {
        MProduct product = MProduct.get(getCtx(), cost.getM_Product_ID());
        MAcctSchema as = MAcctSchema.get(getCtx(), cost.getC_AcctSchema_ID());
        retValue = MCost.getLastInvoicePrice(product,
          cost.getM_AttributeSetInstance_ID(), cost.getAD_Org_ID(), as.getC_Currency_ID());       
      }
    }
   
    //  Last PO Price
    else if (to.equals(TO_LastPOPrice))
    {
      MCostElement ce = getCostElement(TO_LastPOPrice);
      if (ce != null)
      {
        MCost xCost = MCost.get(getCtx(), cost.getAD_Client_ID(), cost.getAD_Org_ID(), cost.getM_Product_ID(), cost.getM_CostType_ID(), cost.getC_AcctSchema_ID(), ce.getM_CostElement_ID(), cost.getM_AttributeSetInstance_ID());
        if (xCost != null)
          retValue = xCost.getCurrentCostPrice();
      }
      if (retValue == null)
      {
        MProduct product = MProduct.get(getCtx(), cost.getM_Product_ID());
        MAcctSchema as = MAcctSchema.get(getCtx(), cost.getC_AcctSchema_ID());
        retValue = MCost.getLastPOPrice(product,
          cost.getM_AttributeSetInstance_ID(), cost.getAD_Org_ID(), as.getC_Currency_ID());       
      }
    }
 
    //  FiFo
    else if (to.equals(TO_LiFo))
    {
      MCostElement ce = getCostElement(TO_LiFo);
      if (ce == null)
        throw new AdempiereSystemError("CostElement not found: " + TO_LiFo);
      MCost xCost = MCost.get(getCtx(), cost.getAD_Client_ID(), cost.getAD_Org_ID(), cost.getM_Product_ID(), cost.getM_CostType_ID(), cost.getC_AcctSchema_ID(), ce.getM_CostElement_ID(), cost.getM_AttributeSetInstance_ID());
      if (xCost != null)
        retValue = xCost.getCurrentCostPrice();
    }
   
    //  Old Std Costs
    else if (to.equals(TO_OldStandardCost))
      retValue = getOldCurrentCostPrice(cost);
View Full Code Here

TOP

Related Classes of org.compiere.model.MCost

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.