Examples of MLandedCostAllocation


Examples of org.compiere.model.MLandedCostAllocation

   
    //  Create New
    MInvoiceLine il = new MInvoiceLine (getCtx(), C_InvoiceLine_ID, getTrxName());
    for (int i = 0; i < lcas.length; i++)
    {
      MLandedCostAllocation lca = lcas[i];
      if (lca.getBase().signum() == 0)
        continue;
      double percent = lca.getBase().doubleValue() / totalBase;
      String desc = il.getDescription();
      if (desc == null)
        desc = percent + "%";
      else
        desc += " - " + percent + "%";
      if (line.getDescription() != null)
        desc += " - " + line.getDescription();
     
      //  Accounting
      ProductCost pc = new ProductCost (Env.getCtx(),
        lca.getM_Product_ID(), lca.getM_AttributeSetInstance_ID(), getTrxName());
      BigDecimal drAmt = null;
      BigDecimal crAmt = null;
      if (dr)
        drAmt = lca.getAmt();
      else
        crAmt = lca.getAmt();
      FactLine fl = fact.createLine (line, pc.getAccount(ProductCost.ACCTTYPE_P_CostAdjustment, as),
        getC_Currency_ID(), drAmt, crAmt);
      fl.setDescription(desc);
      fl.setM_Product_ID(lca.getM_Product_ID());
     
      //  Cost Detail - Convert to AcctCurrency
      BigDecimal allocationAmt =  lca.getAmt();
      if (getC_Currency_ID() != as.getC_Currency_ID())
        allocationAmt = MConversionRate.convert(getCtx(), allocationAmt,
          getC_Currency_ID(), as.getC_Currency_ID(),
          getDateAcct(), getC_ConversionType_ID(),
          getAD_Client_ID(), getAD_Org_ID());
      if (allocationAmt.scale() > as.getCostingPrecision())
        allocationAmt = allocationAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP);
      if (!dr)
        allocationAmt = allocationAmt.negate();
      // AZ Goodwill
      // use createInvoice to create/update non Material Cost Detail
      MCostDetail.createInvoice(as, lca.getAD_Org_ID(),
          lca.getM_Product_ID(), lca.getM_AttributeSetInstance_ID(),
          C_InvoiceLine_ID, lca.getM_CostElement_ID(),
          allocationAmt, lca.getQty(),
          desc, getTrxName());
      // end AZ
    }
   
    log.config("Created #" + lcas.length);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.