public static Expression <Func <ChileMaterialsReceived, ChileMaterialsReceivedRecapReturn> > SelectRecapReport()
        {
            var lotKey = LotProjectors.SelectLotKey <ChileMaterialsReceived>();

            return(Projector <ChileMaterialsReceived> .To(m => new ChileMaterialsReceivedRecapReturn
            {
                LotKeyReturn = lotKey.Invoke(m),
                DateReceived = m.DateReceived,
                LoadNumber = m.LoadNumber,
                EmployeeName = m.Employee.UserName,
                Supplier = m.Supplier.Name,
                Product = m.ChileProduct.Product.Name,
                PurchaseOrder = m.ChileLot.Lot.PurchaseOrderNumber,
                ShipperNumber = m.ChileLot.Lot.ShipperNumber,

                Items = m.Items
                        .OrderBy(i => i.ItemSequence)
                        .Select(i => new ChileMaterialsReceivedRecapItemReturn
                {
                    Tote = i.ToteKey,
                    Quantity = i.Quantity,
                    Packaging = i.PackagingProduct.Product.Name,
                    Weight = i.PackagingProduct.Weight *i.Quantity,
                    Variety = i.ChileVariety,
                    LocaleGrown = i.GrowerCode,
                    LocationDescription = i.Location.Description
                })
            }));
        }
Ejemplo n.º 2
0
        internal static Expression <Func <SampleOrder, SampleOrderMatchingSummaryReportReturn> > SelectMatchingSummaryReport(IKey <SampleOrderItem> itemKeyFilter = null)
        {
            var key        = SelectKey();
            var lotKey     = LotProjectors.SelectLotKey <Lot>();
            var itemFilter = itemKeyFilter == null?PredicateBuilder.True <SampleOrderItem>() : itemKeyFilter.FindByPredicate;

            return(Projector <SampleOrder> .To(s => new SampleOrderMatchingSummaryReportReturn
            {
                SampleOrderKeyReturn = key.Invoke(s),
                Company = new[] { s.RequestCustomer }.Where(c => c != null).Select(c => c.Company.Name).FirstOrDefault(),
                Contact = s.Request.Name,
                Items = s.Items
                        .Where(i => itemFilter.Invoke(i))
                        .Select(i => new SampleOrderMatchingItemReturn
                {
                    SampleMatch = i.CustomerProductName,
                    Spec = i.Spec,
                    Match = i.Match,
                    LotAttributes = new[] { i.Lot }.Where(c => c != null).SelectMany(l => l.Attributes),

                    OrderStatus = s.Status,
                    ProductName = new[] { i.Product }.Where(p => p != null).Select(p => p.Name).FirstOrDefault(),
                    LotKeyReturn = new[] { i.Lot }.Where(l => l != null).Select(l => lotKey.Invoke(l)).FirstOrDefault(),
                    Quantity = i.Quantity,
                    Description = i.Description,
                    Employee = s.Employee.UserName,
                    Received = s.DateReceived,
                    SampleDate = s.DateDue,
                    Completed = s.DateCompleted
                })
            }));
        }
        internal static Expression <Func <PickedInventoryItem, ProductionBatch, PickedForBatchTransactionReturn> > SelectTransaction(ILotUnitOfWork lotUnitOfWork)
        {
            var lotKey          = LotProjectors.SelectLotKey <Lot>();
            var batchLotKey     = LotProjectors.SelectLotKey <ProductionBatch>();
            var packScheduleKey = PackScheduleProjectors.SelectKey();

            var product   = LotProjectors.SelectDerivedProduct();
            var location  = LocationProjectors.SelectLocation();
            var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment();
            var packaging = ProductProjectors.SelectPackagingProduct();

            return(Projector <PickedInventoryItem, ProductionBatch> .To((i, b) => new PickedForBatchTransactionReturn
            {
                EmployeeName = i.PickedInventory.Employee.UserName,
                TimeStamp = i.PickedInventory.TimeStamp,

                TransactionType = InventoryTransactionType.PickedForBatch,
                Quantity = -i.Quantity,
                Weight = -i.Quantity * i.PackagingProduct.Weight,
                ToteKey = i.ToteKey,

                SourceLotVendorName = new[] { i.Lot.Vendor }.Where(v => v != null).Select(v => v.Name).FirstOrDefault(),
                SourceLotPurchaseOrderNumber = i.Lot.PurchaseOrderNumber,
                SourceLotShipperNumber = i.Lot.ShipperNumber,

                Product = product.Invoke(i.Lot),
                Packaging = packaging.Invoke(i.PackagingProduct),
                Location = location.Invoke(i.FromLocation),
                Treatment = treatment.Invoke(i.Treatment),

                SourceLotKeyReturn = lotKey.Invoke(i.Lot),
                DestinationLotKeyReturn = batchLotKey.Invoke(b),
                PackScheduleKeyReturn = packScheduleKey.Invoke(b.PackSchedule)
            }));
        }
Ejemplo n.º 4
0
        internal static IEnumerable <Expression <Func <Inventory, InventoryItemReturn> > > SplitSelectInventorySummary(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate)
        {
            if (inventoryUnitOfWork == null)
            {
                throw new ArgumentNullException("inventoryUnitOfWork");
            }

            currentDate = currentDate.Date;
            var inventoryKey      = SelectInventoryKey();
            var packagingProduct  = ProductProjectors.SelectPackagingProduct();
            var warehouseLocation = LocationProjectors.SelectLocation();
            var treament          = InventoryTreatmentProjectors.SelectInventoryTreatment();

            return(LotProjectors.SplitSelectLotSummary(inventoryUnitOfWork, currentDate)
                   .Select(p => p.Merge(Projector <Inventory> .To(n => new InventoryItemReturn {
            }), n => n.Lot))
                   .ToListWithModifiedElement(0, p => p.Merge(n => new InventoryItemReturn
            {
                InventoryKeyReturn = inventoryKey.Invoke(n),
                ToteKey = n.ToteKey,
                Quantity = n.Quantity
            }).ExpandAll())
                   .ToAppendedList(Projector <Inventory> .To(i => new InventoryItemReturn
            {
                PackagingReceived = packagingProduct.Invoke(i.Lot.ReceivedPackaging),
                PackagingProduct = packagingProduct.Invoke(i.PackagingProduct),
                Location = warehouseLocation.Invoke(i.Location),
                InventoryTreatment = treament.Invoke(i.Treatment)
            })));
        }
        internal static Expression <Func <LotProductionResults, ProductionRecapLot> > SelectProductionRecap(IQueryable <ProductionBatch> productionBatches)
        {
            var product        = ProductProjectors.SelectChileProductSummary();
            var location       = LocationProjectors.SelectLocation();
            var lotKey         = LotProjectors.SelectLotKey <ChileLotProduction>();
            var batchPredicate = ProductionBatchPredicates.ByLotKeyEntity <LotProductionResults>();
            var batchSelect    = PackScheduleProjectors.SelectProductionRecap();

            return(Projector <LotProductionResults> .To(p => new ProductionRecapLot
            {
                ProductionType = p.Production.ProductionType,
                LotProductionStatus = p.Production.ResultingChileLot.Lot.ProductionStatus,
                LotQualityStatus = p.Production.ResultingChileLot.Lot.QualityStatus,
                OutOfSpec = p.Production.ResultingChileLot.Lot.ProductSpecOutOfRange,
                ProductionBegin = p.ProductionBegin,
                ProductionEnd = p.ProductionEnd,
                ProductionLocation = location.Invoke(p.ProductionLineLocation),

                ChileProduct = product.Invoke(p.Production.ResultingChileLot.ChileProduct),
                LotKey = lotKey.Invoke(p.Production),
                TotalInputWeight = p.Production.PickedInventory.Items.Any() ? p.Production.PickedInventory.Items.Sum(i => i.Quantity *i.PackagingProduct.Weight) : 0.0,
                TotalOutputWeight = p.ResultItems.Any() ? p.ResultItems.Sum(i => i.Quantity *i.PackagingProduct.Weight) : 0.0,
                Shift = p.ShiftKey,

                ProductionBatch = productionBatches.Where(b => batchPredicate.Invoke(p, b)).Select(b => batchSelect.Invoke(b.PackSchedule)).FirstOrDefault(),
                UnresolvedDefects = p.Production.ResultingChileLot.Lot.LotDefects.Where(d => d.Resolution == null).Select(d => d.Description)
            }));
        }
        private static IEnumerable <Expression <Func <LotProductionResults, ProductionResultReturn> > > SplitSelectReturn()
        {
            var productionLocationKey = LocationProjectors.SelectLocationKey();
            var lotKey     = LotProjectors.SelectLotKey <LotProductionResults>();
            var productKey = ProductProjectors.SelectProductKey();

            return(new[]
            {
                SelectBase().Merge(r => new ProductionResultReturn
                {
                    LotKeyReturn = lotKey.Invoke(r),
                    DateTimeEntered = r.DateTimeEntered,
                    ProductionStartDate = r.ProductionBegin
                }).ExpandAll(),

                Projector <LotProductionResults> .To(r => new ProductionResultReturn
                {
                    User = r.Employee.UserName,
                    ProductionLocationKeyReturn = productionLocationKey.Invoke(r.ProductionLineLocation)
                }),

                Projector <LotProductionResults> .To(r => new ProductionResultReturn
                {
                    ChileProductName = r.Production.ResultingChileLot.ChileProduct.Product.Name,
                    ChileProductKeyReturn = productKey.Invoke(r.Production.ResultingChileLot.ChileProduct.Product)
                })
            });
        }
        internal static IEnumerable <Expression <Func <PickedInventoryItem, InventoryShipmentOrderItemAnalysisReturn> > > SplitSelectCOAItem()
        {
            var lotKey     = LotProjectors.SelectLotKey <Lot>();
            var loBac      = LotProjectors.SelectLoBac();
            var lotProduct = LotProjectors.SelectDerivedProduct();
            var treatment  = InventoryTreatmentProjectors.SelectInventoryTreatment();
            var attribute  = LotAttributeProjectors.Select();

            return(new Projectors <PickedInventoryItem, InventoryShipmentOrderItemAnalysisReturn>
            {
                i => new InventoryShipmentOrderItemAnalysisReturn
                {
                    LotKeyReturn = lotKey.Invoke(i.Lot),
                    TreatmentReturn = treatment.Invoke(i.Treatment),
                    Attributes = i.Lot.Attributes.Select(a => attribute.Invoke(a)),
                    Notes = i.Lot.Notes
                },
                i => new InventoryShipmentOrderItemAnalysisReturn
                {
                    ProductionDate = new [] { i.Lot.ChileLot }.Where(c => c != null && c.Production != null && c.Production.Results != null)
                    .Select(c => (DateTime?)c.Production.Results.ProductionEnd).FirstOrDefault(),
                },
                i => new InventoryShipmentOrderItemAnalysisReturn
                {
                    LoBac = loBac.Invoke(i.Lot),
                    LotProduct = lotProduct.Invoke(i.Lot),
                }
            });
        }
        internal static Expression <Func <PickedInventoryItem, PickedInventoryItemReturn> > SelectMillAndWetdownPickedItem(ILotUnitOfWork lotUnitOfWork)
        {
            if (lotUnitOfWork == null)
            {
                throw new ArgumentNullException("lotUnitOfWork");
            }

            var pickedInventoryItemKey = SelectKey();
            var inventoryKey           = SelectInventoryKey();
            var lotKey           = LotProjectors.SelectLotKey <Lot>();
            var lotProduct       = LotProjectors.SelectDerivedProduct();
            var packagingProduct = ProductProjectors.SelectPackagingProduct();
            var location         = LocationProjectors.SelectLocation();

            return(i => new PickedInventoryItemReturn
            {
                PickedInventoryItemKeyReturn = pickedInventoryItemKey.Invoke(i),
                InventoryKeyReturn = inventoryKey.Invoke(i),
                LotKeyReturn = lotKey.Invoke(i.Lot),
                LotDateCreated = i.LotDateCreated,
                ToteKey = i.ToteKey,
                QuantityPicked = i.Quantity,
                CustomerLotCode = i.CustomerLotCode,
                CustomerProductCode = i.CustomerProductCode,
                TotalWeightPicked = (int)(i.PackagingProduct.Weight * i.Quantity),

                LotProduct = lotProduct.Invoke(i.Lot),
                PackagingProduct = packagingProduct.Invoke(i.PackagingProduct),
                Location = location.Invoke(i.FromLocation)
            });
        }
        internal static IEnumerable <Expression <Func <PickedInventoryItem, PickSheetItemReturn> > > SplitSelectPickSheetItem()
        {
            var key              = SelectKey();
            var lotKey           = LotProjectors.SelectLotKey <Lot>();
            var locationKey      = LocationProjectors.SelectLocationKey();
            var loBac            = LotProjectors.SelectLoBac();
            var lotProduct       = LotProjectors.SelectDerivedProduct();
            var packagingProduct = ProductProjectors.SelectPackagingProduct();
            var treatment        = InventoryTreatmentProjectors.SelectInventoryTreatment();

            return(new Projectors <PickedInventoryItem, PickSheetItemReturn>
            {
                i => new PickSheetItemReturn
                {
                    LocationKeyReturn = locationKey.Invoke(i.FromLocation),
                    Description = i.FromLocation.Description,
                    PickedInventoryItemKeyReturn = key.Invoke(i),
                    LotKeyReturn = lotKey.Invoke(i.Lot),
                    Quantity = i.Quantity,
                    LoBac = loBac.Invoke(i.Lot),
                    CustomerProductCode = i.CustomerProductCode
                },
                i => new PickSheetItemReturn
                {
                    LotProduct = lotProduct.Invoke(i.Lot),
                    InventoryTreatment = treatment.Invoke(i.Treatment)
                },
                i => new PickSheetItemReturn
                {
                    PackagingProduct = packagingProduct.Invoke(i.PackagingProduct),
                    NetWeight = i.Quantity * i.PackagingProduct.Weight
                }
            });
        }
        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 Expression <Func <LotProductionResultItem, LotProductionResultItemKeyReturn> > SelectProductionResultItemKey()
 {
     return(LotProjectors.SelectLotKey <LotProductionResultItem>().Merge(i => new LotProductionResultItemKeyReturn
     {
         ProductionResultItemKey_Sequence = i.ResultItemSequence
     }));
 }
        internal static Expression <Func <InventoryTransaction, InventoryTransactionReturn> > Select(ILotUnitOfWork lotUnitOfWork)
        {
            var lotKey    = LotProjectors.SelectLotKey <Lot>();
            var product   = LotProjectors.SelectDerivedProduct();
            var location  = LocationProjectors.SelectLocation();
            var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment();
            var packaging = ProductProjectors.SelectPackagingProduct();

            return(Projector <InventoryTransaction> .To(t => new InventoryTransactionReturn
            {
                EmployeeName = t.Employee.UserName,
                TimeStamp = t.TimeStamp,

                TransactionType = t.TransactionType,
                SourceReference = t.SourceReference,
                Quantity = t.Quantity,
                Weight = t.Quantity * t.PackagingProduct.Weight,
                ToteKey = t.ToteKey,

                SourceLotVendorName = new [] { t.SourceLot.Vendor }.Where(v => v != null).Select(v => v.Name).FirstOrDefault(),
                SourceLotPurchaseOrderNumber = t.SourceLot.PurchaseOrderNumber,
                SourceLotShipperNumber = t.SourceLot.ShipperNumber,

                SourceLotPackagingReceived = packaging.Invoke(t.SourceLot.ReceivedPackaging),
                Product = product.Invoke(t.SourceLot),
                Packaging = packaging.Invoke(t.PackagingProduct),
                Location = location.Invoke(t.Location),
                Treatment = treatment.Invoke(t.Treatment),

                SourceLotKeyReturn = lotKey.Invoke(t.SourceLot),
                DestinationLotKeyReturn = new[] { t.DestinationLot }.Where(l => l != null).Select(l => lotKey.Invoke(l)).FirstOrDefault()
            }));
        }
Ejemplo n.º 13
0
        internal static IEnumerable <Expression <Func <ProductionBatch, ProductionPacketBatchReturn> > > SplitSelectProductionPacket(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate)
        {
            if (inventoryUnitOfWork == null)
            {
                throw new ArgumentNullException("inventoryUnitOfWork");
            }

            var lotKey       = LotProjectors.SelectLotKey <ProductionBatch>();
            var pickedItem   = PickedInventoryItemProjectors.SplitSelect(inventoryUnitOfWork, currentDate);
            var instructions = NotebookProjectors.Select();

            return(pickedItem.Select(p => Projector <ProductionBatch> .To(b => new ProductionPacketBatchReturn
            {
                PickedItems = b.Production.PickedInventory.Items.Select(i => p.Invoke(i))
            }))
                   .ToAppendedList(b => new ProductionPacketBatchReturn
            {
                LotKeyReturn = lotKey.Invoke(b),
                Notes = b.Production.ResultingChileLot.Lot.Notes,
                TargetParameters = new ProductionBatchTargetParametersReturn
                {
                    BatchTargetWeight = b.TargetParameters.BatchTargetWeight,
                    BatchTargetAsta = b.TargetParameters.BatchTargetAsta,
                    BatchTargetScoville = b.TargetParameters.BatchTargetScoville,
                    BatchTargetScan = b.TargetParameters.BatchTargetScan
                }
            },
                                   b => new ProductionPacketBatchReturn
            {
                Instructions = instructions.Invoke(b.InstructionNotebook)
            }));
        }
Ejemplo n.º 14
0
        internal static Expression <Func <SalesOrder, SalesOrderInvoiceReturn> > SelectCustomerOrderInvoice()
        {
            var contractKey       = ContractProjectors.SelectKey();
            var loBac             = LotProjectors.SelectLoBac();
            var salesOrderItemKey = SalesOrderItemProjectors.SelectKey();

            return(o => new SalesOrderInvoiceReturn
            {
                MovementNumber = o.InventoryShipmentOrder.MoveNum,
                InvoiceDateReturn = o.InvoiceDate,
                PONumber = o.InventoryShipmentOrder.PurchaseOrderNumber,
                FreightCharge = o.FreightCharge,
                InvoiceNotes = o.InvoiceNotes,
                CreditMemo = o.CreditMemo,

                Origin = o.InventoryShipmentOrder.SourceFacility.Name,
                ShipDate = o.InventoryShipmentOrder.ShipmentInformation.ShipmentDate,
                Broker = new[] { o.Broker }.Where(b => b != null).Select(b => b.Name).FirstOrDefault(),
                PaymentTerms = o.PaymentTerms,
                Freight = o.InventoryShipmentOrder.ShipmentInformation.FreightBillType,
                ShipVia = o.InventoryShipmentOrder.ShipmentInformation.ShipmentMethod,

                SoldTo = o.SoldTo,
                ShipTo = o.InventoryShipmentOrder.ShipmentInformation.ShipTo,

                PickedItems = o.SalesOrderPickedItems.Select(i => new SalesOrderInvoicePickedItemReturn
                {
                    SalesOrderItemKeyReturn = salesOrderItemKey.Invoke(i.SalesOrderItem),
                    ProductCode = i.PickedInventoryItem.Lot.ChileLot.ChileProduct.Product.ProductCode,
                    ProductName = i.PickedInventoryItem.Lot.ChileLot.ChileProduct.Product.Name,
                    ProductType = i.PickedInventoryItem.Lot.ChileLot.ChileProduct.ChileType.Description,

                    CustomerProductCode = i.PickedInventoryItem.CustomerProductCode,
                    PackagingName = i.PickedInventoryItem.PackagingProduct.Product.Name,
                    TreatmentNameShort = i.PickedInventoryItem.Treatment.ShortName,
                    QuantityShipped = i.PickedInventoryItem.Quantity,
                    NetWeight = i.PickedInventoryItem.PackagingProduct.Weight * i.PickedInventoryItem.Quantity,
                    LoBac = loBac.Invoke(i.PickedInventoryItem.Lot)
                }),
                OrderItems = o.SalesOrderItems.Select(i => new SalesOrderInvoiceOrderItemReturn
                {
                    ProductCode = i.InventoryPickOrderItem.Product.ProductCode,
                    ProductName = i.InventoryPickOrderItem.Product.Name,
                    PackagingName = i.InventoryPickOrderItem.PackagingProduct.Product.Name,
                    NetWeight = i.InventoryPickOrderItem.PackagingProduct.Weight * i.InventoryPickOrderItem.Quantity,

                    SalesOrderItemKeyReturn = salesOrderItemKey.Invoke(i),
                    ContractKeyReturn = new[] { i.ContractItem }.Where(n => n != null).Select(n => contractKey.Invoke(n.Contract)).FirstOrDefault(),
                    ContractId = new[] { i.ContractItem }.Where(n => n != null).Select(n => n.Contract.ContractId).FirstOrDefault(),
                    QuantityOrdered = i.InventoryPickOrderItem.Quantity,

                    PriceBase = i.PriceBase,
                    PriceFreight = i.PriceFreight,
                    PriceTreatment = i.PriceTreatment,
                    PriceWarehouse = i.PriceWarehouse,
                    PriceRebate = i.PriceRebate
                })
            });
        }
        internal static IEnumerable <Expression <Func <ProductionSchedule, ProductionScheduleReportReturn> > > SelectReport()
        {
            var batchLotKey     = LotProjectors.SelectLotKey <ProductionBatch>();
            var chileProduct    = ProductProjectors.SelectChileProductSummary();
            var packScheduleKey = PackScheduleProjectors.SelectKey();

            return(new Projectors <ProductionSchedule, ProductionScheduleReportReturn>
            {
                p => new ProductionScheduleReportReturn
                {
                    Timestamp = p.TimeStamp,
                    ProductionDate = p.ProductionDate,
                    ProductionLocation = p.ProductionLineLocation.Description,

                    ScheduledItems = p.ScheduledItems
                                     .Where(i => i.PackSchedule.ProductionBatches.Any(b => !b.ProductionHasBeenCompleted))
                                     .Select(i => new ProductionScheduleItemReportReturn
                    {
                        FlushBefore = i.FlushBefore,
                        FlushBeforeInstructions = i.FlushBeforeInstructions,

                        PackScheduleKeyReturn = packScheduleKey.Invoke(i.PackSchedule),
                        CustomerName = new[] { i.PackSchedule.Customer }.Where(c => c != null).Select(c => c.Company.Name).FirstOrDefault(),
                        WorkType = i.PackSchedule.WorkType.Description,

                        Instructions = i.PackSchedule.SummaryOfWork,
                        ProductionDeadline = i.PackSchedule.ProductionDeadline,
                        OrderNumber = i.PackSchedule.OrderNumber,

                        PackagingProduct = i.PackSchedule.PackagingProduct.Product.Name,

                        FlushAfter = i.FlushAfter,
                        FlushAfterInstructions = i.FlushAfterInstructions,

                        ChileProductReturn = chileProduct.Invoke(i.PackSchedule.ChileProduct)
                    })
                },
                p => new ProductionScheduleReportReturn
                {
                    ScheduledItems = p.ScheduledItems
                                     .Where(i => i.PackSchedule.ProductionBatches.Any(b => !b.ProductionHasBeenCompleted))
                                     .Select(i => new ProductionScheduleItemReportReturn
                    {
                        ProductionBatches = i.PackSchedule.ProductionBatches.Where(b => !b.ProductionHasBeenCompleted)
                                            .OrderBy(b => b.LotTypeId)
                                            .ThenBy(b => b.LotDateCreated)
                                            .ThenBy(b => b.LotDateSequence)
                                            .Select(b => new ProductionScheduleBatchReturn
                        {
                            LotKeyReturn = batchLotKey.Invoke(b)
                        }),

                        Granularity = i.PackSchedule.ChileProduct.Mesh,
                        Scan = i.PackSchedule.ProductionBatches.Where(b => !b.ProductionHasBeenCompleted).Average(b => (double?)b.TargetParameters.BatchTargetScan)
                    })
                },
            });
        }
Ejemplo n.º 16
0
        internal static Expression <Func <ProductionBatch, ScheduledProductionBatchReturn> > SelectScheduledProductionBatch()
        {
            var lotKey = LotProjectors.SelectLotKey <ProductionBatch>();

            return(b => new ScheduledProductionBatchReturn
            {
                OutputLotKeyReturn = lotKey.Invoke(b)
            });
        }
        internal static Expression <Func <ChileMaterialsReceivedItem, ChileMaterialsReceivedItemKeyReturn> > SelectKey()
        {
            var lotKey = LotProjectors.SelectLotKey <ChileMaterialsReceivedItem>();

            return(lotKey.Merge(i => new ChileMaterialsReceivedItemKeyReturn
            {
                ChileMaterialsReceivedKey_ItemSequence = i.ItemSequence
            }));
        }
        internal static Expression <Func <ChileMaterialsReceivedItem, DehydratedInputReturn> > SelectInput()
        {
            var lotKey = LotProjectors.SelectLotKey <ChileMaterialsReceivedItem>();

            return(SelectBase().Merge(i => new DehydratedInputReturn
            {
                LotKeyReturn = lotKey.Invoke(i),
                DehydratorName = i.ChileMaterialsReceived.Supplier.Name
            }));
        }
        internal static Expression <Func <PickedInventoryItem, PickedInventoryItemSelect> > ItemSelect()
        {
            var lotSelect = LotProjectors.LotSelect();

            return(Projector <PickedInventoryItem> .To(i => new PickedInventoryItemSelect
            {
                Item = i,
                LotSelect = lotSelect.Invoke(i.Lot),
            }));
        }
        internal static IEnumerable <Expression <Func <PickedInventoryItem, PickedInventoryItemReturn> > > SplitSelect(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate, ISalesUnitOfWork salesUnitOfWork = null)
        {
            if (inventoryUnitOfWork == null)
            {
                throw new ArgumentNullException("inventoryUnitOfWork");
            }

            var pickedInventoryItemKey = SelectKey();
            var inventoryKey           = SelectInventoryKey();
            var inventoryQuantity      = SelectInventoryQuantity();
            var treatment        = InventoryTreatmentProjectors.SelectInventoryTreatment();
            var location         = LocationProjectors.SelectLocation();
            var packagingProduct = ProductProjectors.SelectPackagingProduct();

            var results = LotProjectors.SplitSelectLotSummary(inventoryUnitOfWork, currentDate)
                          .Select(p => p.Merge((Expression <Func <PickedInventoryItem, PickedInventoryItemReturn> >)(n => new PickedInventoryItemReturn {
            }), n => n.Lot))
                          .ToListWithModifiedElement(0, p => p.Merge(i => new PickedInventoryItemReturn
            {
                PickedInventoryItemKeyReturn = pickedInventoryItemKey.Invoke(i),
                InventoryKeyReturn           = inventoryKey.Invoke(i),
                ToteKey             = i.ToteKey,
                QuantityPicked      = i.Quantity,
                CustomerLotCode     = i.CustomerLotCode,
                CustomerProductCode = i.CustomerProductCode
            }))
                          .ToAppendedList(i => new PickedInventoryItemReturn
            {
                PackagingProduct   = packagingProduct.Invoke(i.PackagingProduct),
                Location           = location.Invoke(i.FromLocation),
                InventoryTreatment = treatment.Invoke(i.Treatment),
            },
                                          i => new PickedInventoryItemReturn
            {
                PackagingReceived = packagingProduct.Invoke(i.Lot.ReceivedPackaging),
                Quantity          = inventoryQuantity.Invoke(i),
                CurrentLocation   = location.Invoke(i.CurrentLocation),
            });

            if (salesUnitOfWork != null)
            {
                var orderItemKey        = InventoryPickOrderItemProjectors.SelectKey();
                var customerPickedItems = salesUnitOfWork.SalesOrderPickedItemRepository.All();
                results.Add(i => new PickedInventoryItemReturn
                {
                    PickOrderItemKeyReturn = customerPickedItems
                                             .Where(c => c.DateCreated == i.DateCreated && c.Sequence == i.Sequence && c.ItemSequence == i.ItemSequence)
                                             .Select(c => orderItemKey.Invoke(c.SalesOrderItem.InventoryPickOrderItem))
                                             .FirstOrDefault()
                });
            }

            return(results.Select(p => p.ExpandAll()));
        }
        internal static IEnumerable <Expression <Func <PickedInventoryItem, BatchPickedInventoryItemReturn> > > SplitSelectBatch(IProductionUnitOfWork productionUnitOfWork, DateTime currentDate)
        {
            var batches = productionUnitOfWork.ProductionBatchRepository.All();
            var lotKey  = LotProjectors.SelectLotKey <ProductionBatch>();

            return(SplitSelect(productionUnitOfWork, currentDate)
                   .Select(p => p.Merge(i => new BatchPickedInventoryItemReturn {
            }))
                   .ToAppendedList(i => new BatchPickedInventoryItemReturn
            {
                NewLotKeyReturn = lotKey.Invoke(batches.FirstOrDefault(b => b.Production.PickedInventoryDateCreated == i.DateCreated && b.Production.PickedInventorySequence == i.Sequence))
            }));
        }
        internal static Expression <Func <PickedInventoryItem, PickedLotReturn> > SelectPickedLot()
        {
            var lotKey    = LotProjectors.SelectLotKey <Lot>();
            var attribute = LotAttributeProjectors.SelectParameter();

            return(i => new PickedLotReturn
            {
                LotKey = lotKey.Invoke(i.Lot),
                ToteKey = i.ToteKey,
                LotWeight = i.PackagingProduct.Weight * i.Quantity,
                LotAttributes = i.Lot.Attributes.Select(a => attribute.Invoke(a))
            });
        }
Ejemplo n.º 23
0
        internal static Expression <Func <ProductionBatch, ProductionBatchSummaryReturn> > SelectSummary()
        {
            var lotKey           = LotProjectors.SelectLotKey <ProductionBatch>();
            var packagingProduct = ProductProjectors.SelectPackagingProduct();

            return(b => new ProductionBatchSummaryReturn
            {
                PackagingProduct = packagingProduct.Invoke(b.PackSchedule.PackagingProduct),
                OutputLotKeyReturn = lotKey.Invoke(b),
                HasProductionBeenCompleted = b.ProductionHasBeenCompleted,
                BatchTargetWeight = b.TargetParameters.BatchTargetWeight,
                BatchTargetAsta = b.TargetParameters.BatchTargetAsta,
                BatchTargetScan = b.TargetParameters.BatchTargetScan,
                BatchTargetScoville = b.TargetParameters.BatchTargetScoville,
                Notes = b.Production.ResultingChileLot.Lot.Notes
            });
        }
Ejemplo n.º 24
0
        public static Expression <Func <Facility, InventoryCycleCountReturn> > SelectInventoryCycleCount(string groupName)
        {
            var lotKey     = LotProjectors.SelectLotKey <Lot>();
            var lotProduct = LotProjectors.SelectDerivedProduct();
            var packaging  = ProductProjectors.SelectPackagingProduct();
            var treatment  = InventoryTreatmentProjectors.SelectInventoryTreatment();

            return(Projector <Facility> .To(f => new InventoryCycleCountReturn
            {
                FacilityName = f.Name,
                GroupName = groupName,

                LocationsSelect = f.Locations
                                  .Where(l => l.Description.Contains(groupName))
                                  .Select(l => new InventoryCycleCountLocationSelect
                {
                    Location = l.Description,
                    InventorySelect = l.Inventory.Select(i => new InventoryCycleCountInventorySelect
                    {
                        LotKeyReturn = lotKey.Invoke(i.Lot),
                        ProductionDate = new [] { i.Lot.ChileLot }.Where(c => c != null && c.Production != null && c.Production.Results != null)
                        .Select(c => c.Production.Results.ProductionEnd).DefaultIfEmpty(i.LotDateCreated).FirstOrDefault(),
                        ProductSelect = lotProduct.Invoke(i.Lot),
                        PackagingSelect = packaging.Invoke(i.PackagingProduct),
                        TreatmentSelect = treatment.Invoke(i.Treatment),
                        Quantity = i.Quantity,
                        Weight = i.Quantity * i.PackagingProduct.Weight
                    }).Concat(l.PickedInventoryItems.Where(p => !p.PickedInventory.Archived).Select(p => new InventoryCycleCountInventorySelect
                    {
                        LotKeyReturn = lotKey.Invoke(p.Lot),
                        ProductionDate = new[] { p.Lot.ChileLot }.Where(c => c != null && c.Production != null && c.Production.Results != null)
                        .Select(c => c.Production.Results.ProductionEnd).DefaultIfEmpty(p.LotDateCreated).FirstOrDefault(),
                        ProductSelect = lotProduct.Invoke(p.Lot),
                        PackagingSelect = packaging.Invoke(p.PackagingProduct),
                        TreatmentSelect = treatment.Invoke(p.Treatment),
                        Quantity = p.Quantity,
                        Weight = p.Quantity *p.PackagingProduct.Weight
                    }))
                })
            }));
        }
        private static Expression <Func <ChileMaterialsReceived, ChileMaterialsReceivedReturn> > SelectBase()
        {
            var key          = LotProjectors.SelectLotKey <ChileMaterialsReceived>();
            var chileProduct = ProductProjectors.SelectChileProductSummary();
            var company      = CompanyProjectors.SelectSummary();
            var treatment    = InventoryTreatmentProjectors.SelectInventoryTreatment();

            return(Projector <ChileMaterialsReceived> .To(m => new ChileMaterialsReceivedReturn
            {
                DateReceived = m.DateReceived,
                LoadNumber = m.LoadNumber,
                PurchaseOrder = m.ChileLot.Lot.PurchaseOrderNumber,
                ShipperNumber = m.ChileLot.Lot.ShipperNumber,

                ChileProduct = chileProduct.Invoke(m.ChileProduct),
                Supplier = company.Invoke(m.Supplier),
                Treatment = treatment.Invoke(m.InventoryTreatment),

                LotKeyReturn = key.Invoke(m),
            }));
        }
Ejemplo n.º 26
0
        private static Expression <Func <ChileLotProduction, MillAndWetdownReturn> > SelectBase()
        {
            var lotKey                = LotProjectors.SelectLotKey <ChileLotProduction>();
            var productKey            = ProductProjectors.SelectProductKey();
            var productionLocationKey = LocationProjectors.SelectLocationKey();

            return(m => new MillAndWetdownReturn
            {
                OutputChileLotKeyReturn = lotKey.Invoke(m),
                ChileProductKeyReturn = productKey.Invoke(m.ResultingChileLot.ChileProduct.Product),
                ProductionLineLocationKeyReturn = productionLocationKey.Invoke(m.Results.ProductionLineLocation),

                ShiftKey = m.Results.ShiftKey,
                ProductionLineDescription = m.Results.ProductionLineLocation.Description,
                ChileProductName = m.ResultingChileLot.ChileProduct.Product.Name,

                ProductionBegin = m.Results.ProductionBegin,
                ProductionEnd = m.Results.ProductionEnd,
                TotalProductionTimeMinutes = EntityFunctions.DiffMinutes(m.Results.ProductionBegin, m.Results.ProductionEnd) ?? 0,
                TotalWeightProduced = m.Results.ResultItems.Any() ? (int)m.Results.ResultItems.Sum(i => i.PackagingProduct.Weight * i.Quantity) : 0,
                TotalWeightPicked = m.PickedInventory.Items.Any() ? (int)m.PickedInventory.Items.Sum(i => i.PackagingProduct.Weight * i.Quantity) : 0
            });
        }
        internal static Expression <Func <SampleOrderItem, SampleOrderItemReturn> > Select()
        {
            var key        = SelectKey();
            var lotKey     = LotProjectors.SelectLotKey <Lot>();
            var productKey = ProductProjectors.SelectProductKey();
            var spec       = SampleOrderItemSpecProjectors.Select();
            var match      = SampleOrderItemMatchProjectors.Select();

            return(i => new SampleOrderItemReturn
            {
                CustomerProductName = i.CustomerProductName,
                Quantity = i.Quantity,
                Description = i.Description,

                CustomerSpec = new[] { i.Spec }.Where(s => s != null).Select(s => spec.Invoke(s)).FirstOrDefault(),
                LabResults = new[] { i.Match }.Where(m => m != null).Select(m => match.Invoke(m)).FirstOrDefault(),

                SampleOrderItemKeyReturn = key.Invoke(i),
                LotKeyReturn = new[] { i.Lot }.Where(l => l != null).Select(l => lotKey.Invoke(l)).FirstOrDefault(),
                ProductKeyReturn = new[] { i.Product }.Where(p => p != null).Select(p => productKey.Invoke(p)).FirstOrDefault(),
                ProductType = new[] { i.Product }.Where(p => p != null).Select(p => (ProductTypeEnum?)p.ProductType).FirstOrDefault()
            });
        }
Ejemplo n.º 28
0
        internal static Expression <Func <InventoryAdjustmentItem, InventoryAdjustmentItemReturn> > Select(ILotUnitOfWork lotUnitOfWork)
        {
            var key = SelectKey();

            var inventoryProduct  = LotProjectors.SelectDerivedProduct();
            var lotKey            = LotProjectors.SelectLotKey <Lot>();
            var warehouseLocation = LocationProjectors.SelectLocation();
            var packagingProduct  = ProductProjectors.SelectPackagingProduct();
            var treatment         = InventoryTreatmentProjectors.SelectInventoryTreatment();

            return(i => new InventoryAdjustmentItemReturn
            {
                InventoryAdjustmentItemKeyReturn = key.Invoke(i),

                AdjustmentQuantity = i.QuantityAdjustment,
                InventoryProduct = inventoryProduct.Invoke(i.Lot),

                LotKeyReturn = lotKey.Invoke(i.Lot),
                Location = warehouseLocation.Invoke(i.Location),
                PackagingProduct = packagingProduct.Invoke(i.PackagingProduct),
                InventoryTreatment = treatment.Invoke(i.Treatment),
                ToteKey = i.ToteKey
            });
        }
Ejemplo n.º 29
0
        internal static Expression <Func <Inventory, Product> > InventoryToProduct(IInventoryUnitOfWork inventoryUnitOfWork)
        {
            var lotToProduct = LotProjectors.SelectProduct(inventoryUnitOfWork);

            return(i => lotToProduct.Invoke(i.Lot));
        }