/// <summary>
        /// Load Invoice Line
        /// </summary>
        /// <param name="inout">shipment/receipt</param>
        /// <returns>DocLine Array</returns>
        private DocLine[] LoadLines(MInOut inout)
        {
            List <DocLine> list = new List <DocLine>();

            MInOutLine[] lines = inout.GetLines(false);
            for (int i = 0; i < lines.Length; i++)
            {
                MInOutLine line = lines[i];
                if (line.IsDescription() ||
                    line.GetM_Product_ID() == 0 ||
                    Env.Signum(line.GetMovementQty()) == 0)
                {
                    log.Finer("Ignored: " + line);
                    continue;
                }
                //	PO Matching
                if (_MatchRequirementR.Equals(X_M_InOut.MATCHREQUIREMENTR_PurchaseOrder) ||
                    _MatchRequirementR.Equals(X_M_InOut.MATCHREQUIREMENTR_PurchaseOrderAndInvoice))
                {
                    Decimal poDiff = line.GetMatchPODifference();
                    if (Env.Signum(poDiff) != 0)
                    {
                        _matchProblem += "; Line=" + line.GetLine()
                                         + " PO Match diff=" + poDiff;
                    }
                    else if (!line.IsMatchPOPosted())
                    {
                        _matchProblem += "; PO Match not posted for Line=" + line.GetLine();
                    }
                }
                //	Inv Matching
                else if (_MatchRequirementR.Equals(X_M_InOut.MATCHREQUIREMENTR_Invoice) ||
                         _MatchRequirementR.Equals(X_M_InOut.MATCHREQUIREMENTR_PurchaseOrderAndInvoice))
                {
                    Decimal invDiff = line.GetMatchInvDifference();
                    if (Env.Signum(invDiff) != 0)
                    {
                        _matchProblem += "; Line=" + line.GetLine()
                                         + " PO Match diff=" + invDiff;
                    }
                    else if (!line.IsMatchInvPosted())
                    {
                        _matchProblem += "; Inv Match not posted for Line=" + line.GetLine();
                    }
                }

                DocLine docLine = new DocLine(line, this);
                Decimal Qty     = line.GetMovementQty();
                docLine.SetQty(Qty, GetDocumentType().Equals(MDocBaseType.DOCBASETYPE_MATERIALDELIVERY));    //  sets Trx and Storage Qty
                //
                log.Fine(docLine.ToString());
                list.Add(docLine);
            }

            //	Return Array
            DocLine[] dls = new DocLine[list.Count];
            dls = list.ToArray();
            return(dls);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load Document Details
        /// </summary>
        /// <returns>error message or null</returns>
        public override String LoadDocumentDetails()
        {
            SetC_Currency_ID(NO_CURRENCY);
            _issue = (MProjectIssue)GetPO();
            SetDateDoc(_issue.GetMovementDate());
            SetDateAcct(_issue.GetMovementDate());

            //	Pseudo Line
            _line = new DocLine(_issue, this);
            _line.SetQty(_issue.GetMovementQty(), true);    //  sets Trx and Storage Qty

            //	Pseudo Line Check
            if (_line.GetM_Product_ID() == 0)
            {
                log.Warning(_line.ToString() + " - No Product");
            }
            log.Fine(_line.ToString());
            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load Invoice Line
        /// </summary>
        /// <param name="move"></param>
        /// <returns>document lines (DocLine_Material)</returns>
        private DocLine[] LoadLines(MMovement move)
        {
            List <DocLine> list = new List <DocLine>();

            MMovementLine[] lines = move.GetLines(false);
            for (int i = 0; i < lines.Length; i++)
            {
                MMovementLine line    = lines[i];
                DocLine       docLine = new DocLine(line, this);
                docLine.SetQty(line.GetMovementQty(), false);
                //
                log.Fine(docLine.ToString());
                list.Add(docLine);
            }

            //	Return Array
            DocLine[] dls = new DocLine[list.Count];
            dls = list.ToArray();
            return(dls);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Load Invoice Line
        /// </summary>
        /// <param name="inventory"></param>
        /// <returns>DocLine Array</returns>
        private DocLine[] LoadLines(MInventory inventory)
        {
            List <DocLine> list = new List <DocLine>();

            MInventoryLine[] lines = inventory.GetLines(false);
            for (int i = 0; i < lines.Length; i++)
            {
                MInventoryLine line = lines[i];
                //	nothing to post
                if (line.GetQtyBook().CompareTo(line.GetQtyCount()) == 0 &&
                    Env.Signum(line.GetQtyInternalUse()) == 0)
                {
                    continue;
                }
                //
                DocLine docLine = new DocLine(line, this);
                Decimal Qty     = line.GetQtyInternalUse();
                if (Env.Signum(Qty) != 0)
                {
                    Qty = Decimal.Negate(Qty);          //	Internal Use entered positive
                }
                else
                {
                    Decimal QtyBook  = line.GetQtyBook();
                    Decimal QtyCount = line.GetQtyCount();
                    Qty = Decimal.Subtract(QtyCount, QtyBook);
                }
                docLine.SetQty(Qty, false);             // -5 => -5
                //
                log.Fine(docLine.ToString());
                list.Add(docLine);
            }

            //	Return Array
            DocLine[] dls = new DocLine[list.Count];
            dls = list.ToArray();
            return(dls);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Load Invoice Line
        /// </summary>
        /// <param name="invoice">invoice</param>
        /// <returns>DocLine Array</returns>
        private DocLine[] LoadLines(MInvoice invoice)
        {
            List <DocLine> list = new List <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
                Decimal Qty = line.GetQtyInvoiced();
                bool    cm  = GetDocumentType().Equals(MDocBaseType.DOCBASETYPE_ARCREDITMEMO) ||
                              GetDocumentType().Equals(MDocBaseType.DOCBASETYPE_APCREDITMEMO);
                docLine.SetQty(cm ? Decimal.Negate(Qty) : Qty, invoice.IsSOTrx());
                //
                Decimal LineNetAmt = line.GetLineNetAmt();
                Decimal 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);
                    if (!tax.IsZeroTax())
                    {
                        Decimal LineNetAmtTax = tax.CalculateTax(LineNetAmt, true, GetStdPercision());
                        log.Fine("LineNetAmt=" + LineNetAmt + " - Tax=" + LineNetAmtTax);
                        LineNetAmt = Decimal.Subtract(LineNetAmt, LineNetAmtTax);
                        for (int t = 0; t < _taxes.Length; t++)
                        {
                            if (_taxes[t].GetC_Tax_ID() == C_Tax_ID)
                            {
                                _taxes[t].AddIncludedTax(LineNetAmtTax);
                                break;
                            }
                        }
                        Decimal PriceListTax = tax.CalculateTax(PriceList, true, GetStdPercision());
                        PriceList = Decimal.Subtract(PriceList, PriceListTax);
                    }
                }                                              //	correct included Tax

                docLine.SetAmount(LineNetAmt, PriceList, Qty); //	qty for discount calc
                if (docLine.IsItem())
                {
                    _allLinesService = false;
                }
                else
                {
                    _allLinesItem = false;
                }
                //
                log.Fine(docLine.ToString());
                list.Add(docLine);
            }

            //	Convert to Array
            DocLine[] dls = new DocLine[list.Count];
            dls = list.ToArray();

            //	Included Tax - make sure that no difference
            if (IsTaxIncluded())
            {
                for (int i = 0; i < _taxes.Length; i++)
                {
                    if (_taxes[i].IsIncludedTaxDifference())
                    {
                        Decimal diff = _taxes[i].GetIncludedTaxDifference();
                        for (int j = 0; j < dls.Length; j++)
                        {
                            if (dls[j].GetC_Tax_ID() == _taxes[i].GetC_Tax_ID())
                            {
                                dls[j].SetLineNetAmtDifference(diff);
                                break;
                            }
                        } //	for all lines
                    }     //	tax difference
                }         //	for all taxes
            }             //	Included Tax difference

            //	Return Array
            return(dls);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Load Invoice Line
        /// </summary>
        /// <param name="prod">production</param>
        /// <returns> DoaLine Array</returns>
        private DocLine[] LoadLines(X_M_Production prod)
        {
            List <DocLine> list = new List <DocLine>();
            //	Production
            //	-- ProductionPlan
            //	-- -- ProductionLine	- the real level
            String sqlPP = "SELECT * FROM M_ProductionPlan pp "
                           + "WHERE pp.M_Production_ID=@param1 "
                           + "ORDER BY pp.Line";
            IDataReader idrPP = null;

            String sqlPL = "SELECT * FROM M_ProductionLine pl "
                           + "WHERE pl.M_ProductionPlan_ID=@param2 "
                           + "ORDER BY pl.Line";
            IDataReader idrPL = null;

            try
            {
                SqlParameter[] param = new SqlParameter[1];
                param[0] = new SqlParameter("@param1", Get_ID());
                idrPP    = DataBase.DB.ExecuteReader(sqlPP, param, GetTrx());
                //idrPP.setInt(1, get_ID());
                //ResultSet rsPP = idrPP.executeQuery();
                while (idrPP.Read())
                {
                    int M_Product_ID        = Utility.Util.GetValueOfInt(idrPP["M_Product_ID"]);
                    int M_ProductionPlan_ID = Utility.Util.GetValueOfInt(idrPP["M_ProductionPlan_ID"]);
                    //
                    try
                    {
                        param    = new SqlParameter[1];
                        param[0] = new SqlParameter("@param2", M_ProductionPlan_ID);
                        idrPL    = DataBase.DB.ExecuteReader(sqlPL, param, GetTrx());
                        //idrPL.setInt(1, M_ProductionPlan_ID);
                        //ResultSet rsPL = idrPL.executeQuery();
                        while (idrPL.Read())
                        {
                            X_M_ProductionLine line = new X_M_ProductionLine(GetCtx(), idrPL, GetTrx());
                            if (Env.Signum(line.GetMovementQty()) == 0)
                            {
                                log.Info("LineQty=0 - " + line);
                                continue;
                            }
                            DocLine docLine = new DocLine(line, this);
                            docLine.SetQty(line.GetMovementQty(), false);
                            //	Identify finished BOM Product
                            docLine.SetProductionBOM(line.GetM_Product_ID() == M_Product_ID);
                            //
                            log.Fine(docLine.ToString());
                            list.Add(docLine);
                        }
                        idrPL.Close();
                    }
                    catch (Exception ee)
                    {
                        if (idrPL != null)
                        {
                            idrPL.Close();
                            idrPL = null;
                        }
                        log.Log(Level.SEVERE, sqlPL, ee);
                    }
                }
                idrPP.Close();
            }
            catch (Exception e)
            {
                if (idrPP != null)
                {
                    idrPP.Close();
                    idrPP = null;
                }
                log.Log(Level.SEVERE, sqlPP, e);
            }
            //	Return Array
            DocLine[] dl = new DocLine[list.Count];
            dl = list.ToArray();
            return(dl);
        }