internal static Expression <Func <LotProductionResults, ProductionAdditiveInputs> > SelectAdditiveInputs(ILotUnitOfWork lotUnitOfWork) { var lotKey = LotProjectors.SelectLotKey <LotProductionResults>(); var lotProduct = ProductProjectors.SelectProduct(); var additiveLots = LotProjectors.SelectAdditiveLot(lotUnitOfWork); var additiveProduct = ProductProjectors.SelectAdditiveProduct(); var additiveLotKey = LotProjectors.SelectLotKey <AdditiveLot>(); return(r => new ProductionAdditiveInputs { ProductionDate = r.ProductionBegin, LotKeyReturn = lotKey.Invoke(r), LotProduct = lotProduct.Invoke(r.Production.ResultingChileLot.ChileProduct.Product), PickedAdditiveItems = r.Production.PickedInventory.Items.Select(i => new { Item = i, AdditiveLot = additiveLots.Invoke(i.Lot).FirstOrDefault() }) .Where(i => i.AdditiveLot != null) .Select(i => new ProductionPickedAdditive { LotKeyReturn = additiveLotKey.Invoke(i.AdditiveLot), TotalPoundsPicked = i.Item.Quantity * i.Item.PackagingProduct.Weight, AdditiveProduct = additiveProduct.Invoke(i.AdditiveLot.AdditiveProduct), UserResultEntered = r.Employee.UserName }) }); }
internal static IEnumerable <Expression <Func <PackSchedule, ProductionPacketReturn> > > SplitSelectProductionPacket(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate, ILotKey batchKey = null) { var packScheduleKey = SelectKey(); var companyHeader = CompanyProjectors.SelectHeader(); var workType = WorkTypeProjectors.Select(); var chileProduct = ProductProjectors.SelectProduct(); var productKeyName = ProductProjectors.SelectProductKeyName(); var productionBatchPredicate = batchKey != null?ProductionBatchPredicates.ByLotKey(batchKey) : b => true; return(ProductionBatchProjectors.SplitSelectProductionPacket(inventoryUnitOfWork, currentDate) .Select(b => Projector <PackSchedule> .To(p => new ProductionPacketReturn { Batches = p.ProductionBatches.Where(a => productionBatchPredicate.Invoke(a)).Select(a => b.Invoke(a)) })) .ToAppendedList(Projector <PackSchedule> .To(p => new ProductionPacketReturn { PackScheduleKeyReturn = packScheduleKey.Invoke(p), PSNum = p.PSNum, DateCreated = p.DateCreated, SummaryOfWork = p.SummaryOfWork }), Projector <PackSchedule> .To(p => new ProductionPacketReturn { ChileProduct = chileProduct.Invoke(p.ChileProduct.Product), PackagingProduct = productKeyName.Invoke(p.PackagingProduct.Product) }), Projector <PackSchedule> .To(p => new ProductionPacketReturn { ProductionLineDescription = p.ProductionLineLocation.Description, WorkType = workType.Invoke(p.WorkType), Customer = new[] { p.Customer }.Where(c => c != null).Select(c => companyHeader.Invoke(c.Company)).FirstOrDefault() }))); }
internal static IEnumerable <Expression <Func <ContractItem, ContractItemShipmentSummaryReturn> > > SplitSelectShipmentSummary() { var key = SelectKey(); var product = ProductProjectors.SelectProduct(); var packaging = ProductProjectors.SelectPackagingProduct(); var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment(); var total = SelectTotal(); var totalShipped = SelectTotalOrdered(o => o.Order.InventoryShipmentOrder.OrderStatus != OrderStatus.Void && (o.Order.InventoryShipmentOrder.ShipmentInformation.Status == ShipmentStatus.Shipped)); var totalPending = SelectTotalOrdered(o => o.Order.InventoryShipmentOrder.OrderStatus != OrderStatus.Void && (o.Order.InventoryShipmentOrder.ShipmentInformation.Status == ShipmentStatus.Unscheduled || o.Order.InventoryShipmentOrder.ShipmentInformation.Status == ShipmentStatus.Scheduled)); return(new List <Expression <Func <ContractItem, ContractItemShipmentSummaryReturn> > > { c => new ContractItemShipmentSummaryReturn { ContractItemKeyReturn = key.Invoke(c), BasePrice = c.PriceBase, ChileProduct = product.Invoke(c.ChileProduct.Product), PackagingProduct = packaging.Invoke(c.PackagingProduct), Treatment = treatment.Invoke(c.Treatment), CustomerProductCode = c.CustomerProductCode, }, c => new ContractItemShipmentSummaryReturn { TotalValue = total.Invoke(c) * (c.PriceBase + c.PriceFreight + c.PriceTreatment + c.PriceWarehouse - c.PriceRebate), TotalWeight = total.Invoke(c), TotalWeightShipped = totalShipped.Invoke(c), TotalWeightPending = totalPending.Invoke(c), TotalWeightRemaining = total.Invoke(c) - (totalShipped.Invoke(c) + totalPending.Invoke(c)) } }); }
internal static Expression <Func <SalesQuoteItem, SalesQuoteItemReturn> > Select() { var key = SelectKey(); var treatmentKey = InventoryTreatmentProjectors.SelectInventoryTreatmentKey(); var product = ProductProjectors.SelectProduct(); var packaging = ProductProjectors.SelectPackagingProduct(); return(Projector <SalesQuoteItem> .To(i => new SalesQuoteItemReturn { SalesQuoteItemKeyReturn = key.Invoke(i), Quantity = i.Quantity, CustomerProductCode = i.CustomerProductCode, PriceBase = i.PriceBase, PriceFreight = i.PriceFreight, PriceTreatment = i.PriceTreatment, PriceWarehouse = i.PriceWarehouse, PriceRebate = i.PriceRebate, InventoryTreatmentKeyReturn = treatmentKey.Invoke(i.Treatment), Product = product.Invoke(i.Product), Packaging = packaging.Invoke(i.PackagingProduct) })); }
private static Expression <Func <SalesOrderItem, IEnumerable <SalesOrderPickedItem>, CustomerContractOrderItemReturn> > SelectContractOrderItemFromPicked() { var key = SelectKey(); var contractItemKey = SelectContractItemKey(); var product = ProductProjectors.SelectProduct(); var packaging = ProductProjectors.SelectPackagingProduct(); var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment(); return((orderItem, pickedItems) => new CustomerContractOrderItemReturn { SalesOrderItemKeyReturn = key.Invoke(orderItem), ContractItemKeyReturn = contractItemKey.Invoke(orderItem), Product = product.Invoke(orderItem.InventoryPickOrderItem.Product), Packaging = packaging.Invoke(orderItem.InventoryPickOrderItem.PackagingProduct), Treatment = treatment.Invoke(orderItem.InventoryPickOrderItem.InventoryTreatment), TotalQuantityPicked = (int)(((int?)pickedItems.Sum(p => p.PickedInventoryItem.Quantity)) ?? 0), TotalWeightPicked = (int)(((int?)pickedItems.Sum(p => p.PickedInventoryItem.Quantity * p.PickedInventoryItem.PackagingProduct.Weight)) ?? 0), TotalPrice = orderItem.PriceBase + orderItem.PriceFreight + orderItem.PriceTreatment + orderItem.PriceWarehouse - orderItem.PriceRebate }); }