예제 #1
0
 /// <summary>
 /// Parent Constructor.
 /// Also creates qtys if RfQ Qty
 /// Is saved if there are qtys(!)
 /// </summary>
 /// <param name="response">response</param>
 /// <param name="line">line</param>
 public MRfQResponseLine(MRfQResponse response, MRfQLine line)
     : base(response.GetCtx(), 0, response.Get_TrxName())
 {
     SetClientOrg(response);
     SetC_RfQResponse_ID(response.GetC_RfQResponse_ID());
     //
     SetC_RfQLine_ID(line.GetC_RfQLine_ID());
     //
     SetIsSelectedWinner(false);
     SetIsSelfService(false);
     //
     MRfQLineQty[] qtys = line.GetQtys();
     for (int i = 0; i < qtys.Length; i++)
     {
         if (qtys[i].IsActive() && qtys[i].IsRfQQty())
         {
             if (Get_ID() == 0)  //	save this line
             {
                 Save();
             }
             MRfQResponseLineQty qty = new MRfQResponseLineQty(this, qtys[i]);
             qty.Save();
         }
     }
 }
        /// <summary>
        /// Compare based on net amount
        /// throws exception if the arguments' types prevent them from
        ///  being compared by this Comparator.
        /// </summary>
        /// <param name="o1">the first object to be compared.</param>
        /// <param name="o2">the second object to be compared.</param>
        /// <returns>a negative integer, zero, or a positive integer as the
        /// first argument is less than, equal to, or greater than the
        /// second. </returns>
        public new int Compare(PO o1, PO o2)
        {
            if (o1 == null)
            {
                throw new ArgumentException("o1 = null");
            }
            if (o2 == null)
            {
                throw new ArgumentException("o2 = null");
            }
            MRfQResponseLineQty q1 = null;
            MRfQResponseLineQty q2 = null;

            if (o1 is MRfQResponseLineQty)//instanceof
            {
                q1 = (MRfQResponseLineQty)o1;
            }
            else
            {
                throw new Exception("ClassCast--o1");
            }
            if (o2 is MRfQResponseLineQty)//instanceof
            {
                q2 = (MRfQResponseLineQty)o2;
            }
            else
            {
                throw new Exception("ClassCast--o2");
            }
            //
            if (!q1.IsValidAmt())
            {
                return(-99);
            }
            if (!q2.IsValidAmt())
            {
                return(+99);
            }
            Decimal?net1 = q1.GetNetAmt();

            if (net1 == null)
            {
                return(-9);
            }
            Decimal?net2 = q2.GetNetAmt();

            if (net2 == null)
            {
                return(+9);
            }
            return(net1.Value.CompareTo(net2.Value));
        }
예제 #3
0
        /// <summary>
        /// Get active Response Qtys of this RfQ Qty
        /// </summary>
        /// <param name="onlyValidAmounts">only valid amounts</param>
        /// <returns>array of response line qtys</returns>
        public MRfQResponseLineQty[] GetResponseQtys(bool onlyValidAmounts)
        {
            List <MRfQResponseLineQty> list = new List <MRfQResponseLineQty>();
            DataTable   dt  = null;
            String      sql = "SELECT * FROM C_RfQResponseLineQty WHERE C_RfQLineQty_ID=" + GetC_RfQLineQty_ID() + " AND IsActive='Y'";
            IDataReader idr = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql, null, Get_TrxName());
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    MRfQResponseLineQty qty = new MRfQResponseLineQty(GetCtx(), dr, Get_TrxName());
                    if (onlyValidAmounts && !qty.IsValidAmt())
                    {
                        ;
                    }
                    else
                    {
                        list.Add(qty);
                    }
                }
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                if (idr != null)
                {
                    idr.Close();
                }
                dt = null;
            }

            MRfQResponseLineQty[] retValue = new MRfQResponseLineQty[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
예제 #4
0
 /// <summary>
 /// After Save
 /// </summary>
 /// <param name="newRecord"></param>
 /// <param name="success">success</param>
 /// <returns>success</returns>
 protected override bool AfterSave(bool newRecord, bool success)
 {
     if (!IsActive())
     {
         GetQtys(false);
         for (int i = 0; i < _qtys.Length; i++)
         {
             MRfQResponseLineQty qty = _qtys[i];
             if (qty.IsActive())
             {
                 qty.SetIsActive(false);
                 qty.Save();
             }
         }
     }
     return(success);
 }
 /// <summary>
 /// Is Net Amount equal ?
 /// </summary>
 /// <param name="obj">the reference object with which to compare.</param>
 /// <returns>true if Net Amount equal</returns>
 public override bool Equals(Object obj)
 {
     if (obj is MRfQResponseLineQty)
     {
         MRfQResponseLineQty cmp = (MRfQResponseLineQty)obj;
         if (!cmp.IsValidAmt() || !IsValidAmt())
         {
             return(false);
         }
         Decimal?cmpNet = cmp.GetNetAmt();
         if (cmpNet == null)
         {
             return(false);
         }
         Decimal?net = cmp.GetNetAmt();
         if (net == null)
         {
             return(false);
         }
         return(cmpNet.Value.CompareTo(net) == 0);
     }
     return(false);
 }
예제 #6
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);
        }