Example #1
0
        public void UninitializedBreakList_GetMinAmount()   //should always be 0 since there's 0 stock
        {
            var tmp = new BaseOrderable();

            foreach (int i in allRandIntRanges)
            {
                Assert.AreEqual(0L, tmp.GetMinimumAmountToFulfillInterval(i));
            }
        }
Example #2
0
        public void UninitializedBreakList_GetMaxOrderableQty()   //should always be 0 since there's 0 stock
        {
            var tmp = new BaseOrderable();

            Assert.AreEqual(0L, tmp.GetMaxOrderableQty());
            foreach (int i in allRandIntRanges)
            {
                Assert.AreEqual(0L, tmp.GetMaxOrderableQty(i));
            }
        }
Example #3
0
        public void UnitializedBreakList_GetUnitPrice()
        {
            var tmp = new BaseOrderable();

            Assert.AreEqual(0D, tmp.GetUnitPriceForQty(), DBL_PRECISION);
            foreach (int i in allRandIntRanges)
            {
                Assert.AreEqual(0D, tmp.GetUnitPriceForQty(i), DBL_PRECISION);
            }
        }
Example #4
0
        public void UnitializedBreakList_GetPriceBreak()
        {
            var tmp = new BaseOrderable();

            foreach (int i in allRandIntRanges)
            {
                var tmpPriceBreak = tmp.GetNearestBreakForQty(i);

                Assert.AreEqual(0L, tmpPriceBreak.qty);
                Assert.AreEqual(0D, tmpPriceBreak.unitPrice, DBL_PRECISION);
            }
        }
Example #5
0
        public ResolverMatrix(BaseOrderable part, long qty)
        {
            ID = part.ID;

            MaxOrderable  = part.GetMaxOrderableQty(qty);
            MinAdjustment = part.GetMinimumAmountToFulfillInterval(qty);

            UnitCost  = part.GetUnitPriceForQty(MaxOrderable);
            TotalCost = UnitCost * MaxOrderable;

            isMOQ1 = part.QtyInterval == 1;
        }
        public void ProcessLeftovers() {
            /*
                 * Theres a few logic reasons we're here:
                 * - We exhausted all stock in all parts < we can't do anything about this
                 * - We have a part with a minimum/interval that is larger than our remaining qty bucket < we can so something, sometimes
                 * 
                 * Here's some assumptions that aren't apparent
                 * -Every interval-ed part has already been fulfilled
                 * -The only spare we're going to be able to take from are parts with a minim of 1
                 */
            bool isAdjustmentPossible = false;

            ResolverMatrix bestResolutionTarget = _WorkingPartsBucket.Select(p => new ResolverMatrix(p, _RemainderQuantityBucket))
                                                       .OrderBy(p => p.MinAdjustment)
                                                       .FirstOrDefault();

            long miniumAdjustmentNeeded = bestResolutionTarget.MinAdjustment;

            //Any already ordered parts we can remove the adjustment from?
            // - needs to have enough orderable quantity to subtract from
            // - needs to not have a minimum
            ResolverMatrix bestDonorCandidate = _SelectedForResults.Where(matrixObj => {
                if (!matrixObj.isMOQ1)
                    return false;
                if (matrixObj.MaxOrderable < miniumAdjustmentNeeded)
                    return false;

                return true;

            })
            .OrderByDescending(matrixObj => matrixObj.UnitCost) //select from most expensive 
            .FirstOrDefault();

            isAdjustmentPossible = bestDonorCandidate != null;

            if (isAdjustmentPossible) { //lets adjust or outright remove the donor from the result set as needed
                _SelectedForResults.Remove(bestDonorCandidate);

                if (bestDonorCandidate.MaxOrderable > miniumAdjustmentNeeded) {
                    //we could just adjust the MaxOderable Value, but to make sure we capture all the pricing info, 
                    //we're going to recreate our object with it's new adjusted quantity

                    long newQty = bestDonorCandidate.MaxOrderable - miniumAdjustmentNeeded;
                    BaseOrderable originalDonorData = PartsListLibrary.Single(p => p.ID == bestDonorCandidate.ID);

                    _SelectedForResults.Add(new ResolverMatrix(originalDonorData, newQty));
                }

                _SelectedForResults.Add(bestResolutionTarget);
            }
        }
Example #7
0
        public void AutoIDGeneration()
        {
            string testIdName = "testIdName";

            var tmp = new BaseOrderable();

            Assert.AreNotEqual(String.Empty, tmp.ID);

            tmp.ID = null;
            Assert.AreNotEqual(String.Empty, tmp.ID);

            tmp.ID = null;
            Assert.IsTrue(Guid.TryParse(tmp.ID, out Guid throwAway));


            tmp.ID = testIdName;
            Assert.AreEqual(testIdName, tmp.ID);
        }
Example #8
0
        public void preflight()
        {
            testTarget = new BaseOrderable();

            testTarget.ID = "This is the Test Object?";

            testTarget.PriceBreakList = new List <PriceBreak>()
            {
                new PriceBreak {
                    qty = 1, unitPrice = 1.0
                },
                new PriceBreak {
                    qty = 10, unitPrice = 0.1
                },
                new PriceBreak {
                    qty = 100, unitPrice = 0.01
                },
                new PriceBreak {
                    qty = 1000, unitPrice = 0.001
                }
            };

            testTarget.QtyStock = 750;
        }
Example #9
0
 public bool AddOrderable(BaseOrderable toAdd)
 {
     throw new NotImplementedException();
 }
Example #10
0
        public void UnitializedBreakList_GetRequestedUnitPrice()
        {
            var tmp = new BaseOrderable();

            Assert.AreEqual(0D, tmp.GetCurrentReqestedUnitPrice(), DBL_PRECISION);
        }