/// <summary>
 /// Parent Constructor
 /// </summary>
 /// <param name="line"></param>
 /// <param name="qty"></param>
 public MRfQResponseLineQty(MRfQResponseLine line, MRfQLineQty qty)
     : this(line.GetCtx(), 0, line.Get_TrxName())
 {
     SetClientOrg(line);
     SetC_RfQResponseLine_ID(line.GetC_RfQResponseLine_ID());
     SetC_RfQLineQty_ID(qty.GetC_RfQLineQty_ID());
 }
Пример #2
0
        /// <summary>
        /// Parent Constructor.
        /// Automatically saved if lines were created
        /// Saved automatically
        /// @param rfq
        /// </summary>
        /// <param name="rfq">rfq</param>
        /// <param name="subscriber">optional subscriber</param>
        /// <param name="C_BPartner_ID">bpartner</param>
        /// <param name="C_BPartner_Location_ID">bpartner location</param>
        /// <param name="AD_User_ID">bpartner user</param>
        public MRfQResponse(MRfQ rfq, MRfQTopicSubscriber subscriber,
                            int C_BPartner_ID, int C_BPartner_Location_ID, int AD_User_ID)
            : this(rfq.GetCtx(), 0, rfq.Get_TrxName())
        {
            SetClientOrg(rfq);
            SetC_RfQ_ID(rfq.GetC_RfQ_ID());
            SetC_Currency_ID(rfq.GetC_Currency_ID());
            SetName(rfq.GetName());
            _rfq = rfq;
            //	Subscriber info
            SetC_BPartner_ID(C_BPartner_ID);
            SetC_BPartner_Location_ID(C_BPartner_Location_ID);
            SetAD_User_ID(AD_User_ID);

            //	Create Lines
            MRfQLine[] lines = rfq.GetLines();
            for (int i = 0; i < lines.Length; i++)
            {
                if (!lines[i].IsActive())
                {
                    continue;
                }

                //	Product on "Only" list
                if (subscriber != null &&
                    !subscriber.IsIncluded(lines[i].GetM_Product_ID()))
                {
                    continue;
                }
                //
                if (Get_ID() == 0)      //	save Response
                {
                    Save();
                }

                MRfQResponseLine line = new MRfQResponseLine(this, lines[i]);
                //	line is not saved (dumped) if there are no Qtys
            }
        }
Пример #3
0
        /// <summary>
        /// Check if Response is Complete
        /// </summary>
        /// <returns>null if complere - error message otherwise</returns>
        public String CheckComplete()
        {
            if (IsComplete())
            {
                SetIsComplete(false);
            }
            MRfQ rfq = GetRfQ();

            //	Is RfQ Total valid
            String error = rfq.CheckQuoteTotalAmtOnly();

            if (error != null && error.Length > 0)
            {
                return(error);
            }

            //	Do we have Total Amount ?
            if (rfq.IsQuoteTotalAmt() || rfq.IsQuoteTotalAmtOnly())
            {
                Decimal amt = GetPrice();
                if (Env.ZERO.CompareTo(amt) >= 0)
                {
                    return("No Total Amount");
                }
            }

            //	Do we have an amount/qty for all lines
            if (rfq.IsQuoteAllLines())
            {
                MRfQResponseLine[] lines = GetLines(false);
                for (int i = 0; i < lines.Length; i++)
                {
                    MRfQResponseLine line = lines[i];
                    if (!line.IsActive())
                    {
                        return("Line " + line.GetRfQLine().GetLine()
                               + ": Not Active");
                    }
                    bool validAmt = false;
                    MRfQResponseLineQty[] qtys = line.GetQtys(false);
                    for (int j = 0; j < qtys.Length; j++)
                    {
                        MRfQResponseLineQty qty = qtys[j];
                        if (!qty.IsActive())
                        {
                            continue;
                        }
                        Decimal?amt = qty.GetNetAmt();
                        if (Env.ZERO.CompareTo(amt) < 0)
                        {
                            validAmt = true;
                            break;
                        }
                    }
                    if (!validAmt)
                    {
                        return("Line " + line.GetRfQLine().GetLine()
                               + ": No Amount");
                    }
                }
            }

            //	Do we have an amount for all line qtys
            if (rfq.IsQuoteAllQty())
            {
                MRfQResponseLine[] lines = GetLines(false);
                for (int i = 0; i < lines.Length; i++)
                {
                    MRfQResponseLine      line = lines[i];
                    MRfQResponseLineQty[] qtys = line.GetQtys(false);
                    for (int j = 0; j < qtys.Length; j++)
                    {
                        MRfQResponseLineQty qty = qtys[j];
                        if (!qty.IsActive())
                        {
                            return("Line " + line.GetRfQLine().GetLine()
                                   + " Qty=" + qty.GetRfQLineQty().GetQty()
                                   + ": Not Active");
                        }
                        Decimal?amt = qty.GetNetAmt();
                        if (amt == null || Env.ZERO.CompareTo(amt) >= 0)
                        {
                            return("Line " + line.GetRfQLine().GetLine()
                                   + " Qty=" + qty.GetRfQLineQty().GetQty()
                                   + ": No Amount");
                        }
                    }
                }
            }

            SetIsComplete(true);
            return(null);
        }