Package org.compiere.model

Examples of org.compiere.model.MInvoiceLine


        pp = (KeyNamePair) miniTable.getValueAt(i, 7); // RMA
        // If we have RMA
        if (pp != null)
          M_RMALine_ID = pp.getKey();
        int C_InvoiceLine_ID = 0;
        MInvoiceLine il = null;
        pp = (KeyNamePair) miniTable.getValueAt(i, 8); // InvoiceLine
        if (pp != null)
          C_InvoiceLine_ID = pp.getKey();
        if (C_InvoiceLine_ID != 0)
          il = new MInvoiceLine (Env.getCtx(), C_InvoiceLine_ID, trxName);
        //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
            + ", OrderLine=" + C_OrderLine_ID + ", InvoiceLine=" + C_InvoiceLine_ID);

        //  Credit Memo - negative Qty
        if (m_invoice != null && m_invoice.isCreditMemo() )
          QtyEntered = QtyEntered.negate();

        //  Create new InOut Line
        MInOutLine iol = new MInOutLine (inout);
        iol.setM_Product_ID(M_Product_ID, C_UOM_ID)//  Line UOM
        iol.setQty(QtyEntered);              //  Movement/Entered
        //
        MOrderLine ol = null;
        MRMALine rmal = null;
        if (C_OrderLine_ID != 0)
        {
          iol.setC_OrderLine_ID(C_OrderLine_ID);
          ol = new MOrderLine (Env.getCtx(), C_OrderLine_ID, trxName);
          if (ol.getQtyEntered().compareTo(ol.getQtyOrdered()) != 0)
          {
            iol.setMovementQty(QtyEntered
                .multiply(ol.getQtyOrdered())
                .divide(ol.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
            iol.setC_UOM_ID(ol.getC_UOM_ID());
          }
          iol.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID());
          iol.setDescription(ol.getDescription());
          //
          iol.setC_Project_ID(ol.getC_Project_ID());
          iol.setC_ProjectPhase_ID(ol.getC_ProjectPhase_ID());
          iol.setC_ProjectTask_ID(ol.getC_ProjectTask_ID());
          iol.setC_Activity_ID(ol.getC_Activity_ID());
          iol.setC_Campaign_ID(ol.getC_Campaign_ID());
          iol.setAD_OrgTrx_ID(ol.getAD_OrgTrx_ID());
          iol.setUser1_ID(ol.getUser1_ID());
          iol.setUser2_ID(ol.getUser2_ID());
        }
        else if (il != null)
        {
          if (il.getQtyEntered().compareTo(il.getQtyInvoiced()) != 0)
          {
            iol.setQtyEntered(QtyEntered
                .multiply(il.getQtyInvoiced())
                .divide(il.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
            iol.setC_UOM_ID(il.getC_UOM_ID());
          }
          iol.setDescription(il.getDescription());
          iol.setC_Project_ID(il.getC_Project_ID());
          iol.setC_ProjectPhase_ID(il.getC_ProjectPhase_ID());
          iol.setC_ProjectTask_ID(il.getC_ProjectTask_ID());
          iol.setC_Activity_ID(il.getC_Activity_ID());
          iol.setC_Campaign_ID(il.getC_Campaign_ID());
          iol.setAD_OrgTrx_ID(il.getAD_OrgTrx_ID());
          iol.setUser1_ID(il.getUser1_ID());
          iol.setUser2_ID(il.getUser2_ID());
        }

        // 25-09-2009 rgliddon: Made following if block independent from the
        // previous if-else block.
        if (M_RMALine_ID != 0)
        {
          rmal = new MRMALine(Env.getCtx(), M_RMALine_ID, trxName);
          iol.setM_RMALine_ID(M_RMALine_ID);
          iol.setQtyEntered(QtyEntered);
          iol.setDescription(rmal.getDescription());
          iol.setM_AttributeSetInstance_ID(rmal.getM_AttributeSetInstance_ID());
          iol.setC_Project_ID(rmal.getC_Project_ID());
          iol.setC_ProjectPhase_ID(rmal.getC_ProjectPhase_ID());
          iol.setC_ProjectTask_ID(rmal.getC_ProjectTask_ID());
          iol.setC_Activity_ID(rmal.getC_Activity_ID());
          iol.setAD_OrgTrx_ID(rmal.getAD_OrgTrx_ID());
          iol.setUser1_ID(rmal.getUser1_ID());
          iol.setUser2_ID(rmal.getUser2_ID());
        }

        //  Charge
        if (M_Product_ID == 0)
        {
          if (ol != null && ol.getC_Charge_ID() != 0)      //  from order
            iol.setC_Charge_ID(ol.getC_Charge_ID());
          else if (il != null && il.getC_Charge_ID() != 0//  from invoice
            iol.setC_Charge_ID(il.getC_Charge_ID());
          else if (rmal != null && rmal.getC_Charge_ID() != 0) // from rma
            iol.setC_Charge_ID(rmal.getC_Charge_ID());
        }
        // Set locator
        iol.setM_Locator_ID(M_Locator_ID);
        if (!iol.save())
          log.log(Level.SEVERE, "Line NOT created #" + i);
        //  Create Invoice Line Link
        else if (il != null)
        {
          il.setM_InOutLine_ID(iol.getM_InOutLine_ID());
          il.saveEx();
        }
      }   //   if selected
    }   //  for all rows

    /**
 
View Full Code Here


    ArrayList<DocLine> list = new ArrayList<DocLine>();
    //
    MInvoiceLine[] lines = invoice.getLines(false);
    for (int i = 0; i < lines.length; i++)
    {
      MInvoiceLine line = lines[i];
      if (line.isDescription())
        continue;
      DocLine docLine = new DocLine(line, this);
      //  Qty
      BigDecimal Qty = line.getQtyInvoiced();
      boolean cm = getDocumentType().equals(DOCTYPE_ARCredit)
        || getDocumentType().equals(DOCTYPE_APCredit);
      docLine.setQty(cm ? Qty.negate() : Qty, invoice.isSOTrx());
      //
      BigDecimal LineNetAmt = line.getLineNetAmt();
      BigDecimal PriceList = line.getPriceList();
      int C_Tax_ID = docLine.getC_Tax_ID();
      //  Correct included Tax
      if (isTaxIncluded() && C_Tax_ID != 0)
      {
        MTax tax = MTax.get(getCtx(), C_Tax_ID);
View Full Code Here

    double totalBase = 0;
    for (int i = 0; i < lcas.length; i++)
      totalBase += lcas[i].getBase().doubleValue();
   
    //  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)
View Full Code Here

TOP

Related Classes of org.compiere.model.MInvoiceLine

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.