/// <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)); }
/// <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); }
/// <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); }