public ReceiveTreatmentOrderConductor(ITreatmentOrderUnitOfWork treatmentOrderUnitOfWork) { if (treatmentOrderUnitOfWork == null) { throw new ArgumentNullException("treatmentOrderUnitOfWork"); } _treatmentOrderUnitOfWork = treatmentOrderUnitOfWork; }
internal static IEnumerable <Expression <Func <TreatmentOrder, TreatmentOrderDetailReturn> > > SplitSelectDetail(ITreatmentOrderUnitOfWork treatmentOrderUnitOfWork, DateTime currentDate) { if (treatmentOrderUnitOfWork == null) { throw new ArgumentNullException("treatmentOrderUnitOfWork"); } var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment(); return(new Projectors <TreatmentOrder, TreatmentOrderDetailReturn> { { InventoryShipmentOrderProjectors.SplitSelectInventoryShipmentOrderDetail(treatmentOrderUnitOfWork, currentDate, InventoryOrderEnum.Treatments), p => p.Translate().To <TreatmentOrder, TreatmentOrderDetailReturn>(t => t.InventoryShipmentOrder) }, t => new TreatmentOrderDetailReturn { Returned = t.Returned, InventoryTreatment = treatment.Invoke(t.Treatment) } }); }
private static Expression <Func <Inventory, bool> > ValidForTreatmentOrder(IInventoryTreatmentKey treatment, ITreatmentOrderUnitOfWork unitOfWork) { var lotsAreEqual = LotProjectors.SelectLotsAreEqual(); var validTreatment = treatment.ToInventoryTreatmentKey().FindByPredicate .Or(Data.Models.StaticRecords.StaticInventoryTreatments.NoTreatment.ToInventoryTreatmentKey().FindByPredicate); var treatmentOrders = unitOfWork.TreatmentOrderRepository.All(); var lots = unitOfWork.LotRepository.All(); return(i => lots .Where(l => lotsAreEqual.Invoke(i.Lot, l)) .SelectMany(l => l.Inventory.Select(n => n.Treatment).Concat(l.PickedInventory.Select(p => p.Treatment))) .Concat(treatmentOrders .Where(o => o.InventoryShipmentOrder.OrderStatus != OrderStatus.Void && o.InventoryShipmentOrder.PickedInventory.Items.Any(l => lotsAreEqual.Invoke(l.Lot, i.Lot))) .Select(o => o.Treatment)) .All(t => validTreatment.Invoke(t))); }
internal static IInventoryValidator ForTreatmentOrder(IFacilityKey sourceFacility, IInventoryTreatmentKey treatmentKey, ITreatmentOrderUnitOfWork unitOfWork) { var facilityKey = sourceFacility.ToFacilityKey(); var facilityPredicate = facilityKey.FindByPredicate; return(new PickedInventoryValidator(i => i.Location.Facility, i => i.Lot.Inventory.Select(n => n.Treatment)) { { i => i.Location.Active, i => new InvalidResult(string.Format(UserMessages.InventoryInactiveLocation, i.ToInventoryKey())), false }, { i => !i.Location.Locked, i => new InvalidResult(string.Format(UserMessages.InventoryLocationLocked, i.ToInventoryKey())), false }, { i => i.Lot.QualityStatus != LotQualityStatus.Rejected, i => new InvalidResult(string.Format(UserMessages.CannotPickLotQualityState, i.ToLotKey(), i.Lot.QualityStatus)), false }, { i => facilityPredicate.Invoke(i.Location.Facility), i => new InvalidResult(string.Format(UserMessages.SourceLocationMustBelongToFacility, facilityKey)) }, { ValidForTreatmentOrder(treatmentKey, unitOfWork), i => new InvalidResult(string.Format(UserMessages.LotConflictingInventoryTreatment, i.ToLotKey())) } }); }