public OrderDetailViewModel(RequestDetail requestDetail, ICollection<StockInformation> stockInformations, ICollection<ApprovedDetail> approvedDetails, Forcasting forcasting, ConsumptionSetting consumptionSetting)
 {
     _requestDetail = requestDetail;
     _stockInformations = stockInformations;
     _approvedDetails = approvedDetails;
     _forcasting = forcasting;
     _consumptionSetting = consumptionSetting;
     _hasManyActivity = getActivityViewModels().Count > 2;
     _hasManyManufacturer = getManufacturerViewModels().Count > 2;
     _hasExpiryDatePreference = getExpiryDateViewModels().Count > 2;
     _hasPhysicalStorePreference = getPhysicalStoreViewModels().Count > 2;
     _allowAdd = _hasManyActivity || _hasManyManufacturer || _hasExpiryDatePreference || _hasPhysicalStorePreference;
     _allowRemove = RequestedQuantity == 0;
     if (_requestDetail.ActivityGroup == null)
     {
         var stockInformation = _stockInformations.OrderBy(s => s.ExpiryDate).FirstOrDefault();
         if (stockInformation != null)
         {
             _requestDetail.ActivityGroup = stockInformation.Activity;
         }
     }
     if (_requestDetail.IsFirstLoad)
     {
         if (_requestDetail.RequestedQuantity >= AvailableQuantity)
         {
             _requestDetail.ApprovedQuantity = AvailableQuantity;
         }
     }
 }
        public void SplitRequest(OrderDetailViewModel orderDetailViewModel)
        {
            var newRequestDetail = new RequestDetail
                                       {
                                           Item = orderDetailViewModel.RequestDetail.Item,
                                           Unit = orderDetailViewModel.RequestDetail.Unit,
                                           RequestedQuantity = 0,
                                       };
            _request.RequestDetails.Add(newRequestDetail);
            var newOrderDetailViewModel = new OrderDetailViewModel(newRequestDetail,
                    _stockInformations.Where(s => s.Item.ItemID == newRequestDetail.Item.ItemID && s.Unit.UnitID == newRequestDetail.Unit.UnitID).ToList(), _approvedDetails.Where(s => s.Item.ItemID == newRequestDetail.Item.ItemID && s.Unit.UnitID == newRequestDetail.Unit.UnitID).ToList(),
                    _otherStockInformations.SingleOrDefault(s => s.Item == newRequestDetail.Item && s.Unit == newRequestDetail.Unit), _consumptionSetting);

            _orderDetails.Add(newOrderDetailViewModel);
            _orderDetails.Move(_orderDetails.IndexOf(newOrderDetailViewModel), _orderDetails.IndexOf(orderDetailViewModel) + 1);
        }