public OrderLine GetOrderLine(StoreOrderLineModel orderLineModel, int wmsQuantityOnHand, int productID, decimal price, decimal?specialPrice, Product p = null) { OrderLine line = null; if (wmsQuantityOnHand == 0) { return(line); //shortcircuit here because no stock is available in the wms } int quantityToShip = Math.Min(orderLineModel.Quantity, wmsQuantityOnHand); if (quantityToShip == 0) { return(line); //shortcircuit here in case of input mistakes } line = new OrderLine() { ProductID = productID, Product = p, Price = (double)Math.Min(price, specialPrice.Try(c => c.Value, decimal.MaxValue)) * orderLineModel.Quantity, Quantity = quantityToShip, OrderLedgers = new List <OrderLedger>() }; return(line); }
public void Order_Line_Quantity_Should_Decrease_To_Wms_Quantity_If_Wms_Quantity_Is_Less_Than_Requested() { StoreOrderLineModel model = new StoreOrderLineModel() { Size_Code = "10", Art_Number = "111111", Color_Code = "100", Quantity = 4 }; StoreOrderHelper help = new StoreOrderHelper(); Assert.AreEqual(help.GetOrderLine(model, 3, 1, 10m, null).Quantity, 3, "Should return null"); }
public void Order_Line_With_No_Quantity_When_WMS_Has_No_Quantity_Should_Return_Null() { StoreOrderLineModel model = new StoreOrderLineModel() { Size_Code = "10", Art_Number = "111111", Color_Code = "100", Quantity = 0 }; StoreOrderHelper help = new StoreOrderHelper(); Assert.IsNull(help.GetOrderLine(model, 1, 1, 10m, null), "Should return null"); }