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
                })
            });
        }
Exemple #2
0
        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 <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 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)
            }));
        }
        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 <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()
            }));
        }
Exemple #7
0
        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()
            })));
        }
        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)
                })
            });
        }
Exemple #9
0
        internal static IEnumerable <Expression <Func <ContractItem, ContractItemReturn> > > Select()
        {
            var key       = SelectKey();
            var product   = ProductProjectors.SelectChileProductSummary();
            var packaging = ProductProjectors.SelectPackagingProduct();
            var treament  = InventoryTreatmentProjectors.SelectInventoryTreatment();

            return(new[]
            {
                Projector <ContractItem> .To(i => new ContractItemReturn
                {
                    ContractItemKeyReturn = key.Invoke(i),
                    Treatment = treament.Invoke(i.Treatment),

                    UseCustomerSpec = i.UseCustomerSpec,
                    CustomerProductCode = i.CustomerProductCode,
                    Quantity = i.Quantity,
                    PriceBase = i.PriceBase,
                    PriceFreight = i.PriceFreight,
                    PriceTreatment = i.PriceTreatment,
                    PriceWarehouse = i.PriceWarehouse,
                    PriceRebate = i.PriceRebate
                }),
                Projector <ContractItem> .To(i => new ContractItemReturn
                {
                    ChileProduct = product.Invoke(i.ChileProduct),
                    PackagingProduct = packaging.Invoke(i.PackagingProduct),
                })
            });
        }
        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)
            }));
        }
Exemple #11
0
        internal static IEnumerable <Expression <Func <InventoryPickOrderItem, InventoryPickOrderItemReturn> > > SplitSelect()
        {
            var key                   = SelectKey();
            var productKey            = ProductProjectors.SelectProductKey();
            var inventoryTreatmentKey = InventoryTreatmentProjectors.SelectInventoryTreatmentKey();
            var company               = CompanyProjectors.SelectHeader();

            return(new Projectors <InventoryPickOrderItem, InventoryPickOrderItemReturn>
            {
                i => new InventoryPickOrderItemReturn
                {
                    InventoryPickOrderItemKeyReturn = key.Invoke(i),
                    ProductKeyReturn = productKey.Invoke(i.Product),
                    ProductName = i.Product.Name,
                    ProductCode = i.Product.ProductCode,
                    TreatmentNameShort = i.InventoryTreatment.ShortName,
                    InventoryTreatmentKeyReturn = inventoryTreatmentKey.Invoke(i.InventoryTreatment),
                    Quantity = i.Quantity,
                    CustomerLotCode = i.CustomerLotCode,
                    CustomerProductCode = i.CustomerProductCode
                },
                i => new InventoryPickOrderItemReturn
                {
                    PackagingProductKeyReturn = productKey.Invoke(i.PackagingProduct.Product),
                    PackagingName = i.PackagingProduct.Product.Name,
                    PackagingWeight = i.PackagingProduct.Weight,
                    TotalWeight = i.PackagingProduct.Weight * i.Quantity
                },
                i => new InventoryPickOrderItemReturn
                {
                    Customer = new [] { i.Customer }.Where(c => c != null).Select(c => company.Invoke(c.Company)).FirstOrDefault()
                }
            });
        }
Exemple #12
0
        internal static IEnumerable <Expression <Func <PackSchedule, ScheduledPackScheduleReturn> > > SelectScheduled()
        {
            var key          = SelectKey();
            var ab           = SelectAverage(StaticAttributeNames.AB);
            var scoville     = SelectAverage(StaticAttributeNames.Scoville);
            var scan         = SelectAverage(StaticAttributeNames.Scan);
            var chileProduct = ProductProjectors.SelectChileProductSummary();

            return(new Projectors <PackSchedule, ScheduledPackScheduleReturn>
            {
                p => new ScheduledPackScheduleReturn
                {
                    PackScheduleKeyReturn = key.Invoke(p),

                    ProductionDeadline = p.ProductionDeadline,
                    Instructions = p.SummaryOfWork,

                    ChileProduct = chileProduct.Invoke(p.ChileProduct)
                },
                p => new ScheduledPackScheduleReturn
                {
                    AverageGranularity = p.ChileProduct.Mesh,
                    AverageAoverB = ab.Invoke(p),
                    AverageScoville = scoville.Invoke(p),
                    AverageScan = scan.Invoke(p),
                }
            });
        }
Exemple #13
0
        internal static IEnumerable <Expression <Func <PackSchedule, PackScheduleSummaryReturn> > > SplitSelectSummary()
        {
            var productionLocationKey = LocationProjectors.SelectLocationKey();
            var workTypeKey           = WorkTypeProjectors.SelectWorkTypeKey();
            var productKey            = ProductProjectors.SelectProductKey();
            var company = CustomerProjectors.SelectCompanyHeader();

            return(new[]
            {
                SelectBaseParameters().Merge(p => new PackScheduleSummaryReturn
                {
                    DateCreated = p.DateCreated,
                    ScheduledProductionDate = p.ScheduledProductionDate,
                    ProductionDeadline = p.ProductionDeadline,
                    OrderNumber = p.OrderNumber
                }).ExpandAll(),
                Projector <PackSchedule> .To(p => new PackScheduleSummaryReturn
                {
                    WorkTypeKeyReturn = workTypeKey.Invoke(p.WorkType),
                    ChileProductKeyReturn = productKey.Invoke(p.ChileProduct.Product),
                    ChileProductName = p.ChileProduct.Product.Name,
                }),
                Projector <PackSchedule> .To(p => new PackScheduleSummaryReturn
                {
                    ProductionLocationKeyReturn = productionLocationKey.Invoke(p.ProductionLineLocation),
                    Customer = new[] { p.Customer }.Where(c => c != null).Select(c => company.Invoke(c)).FirstOrDefault(),
                })
            });
        }
Exemple #14
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 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)
                    })
                },
            });
        }
        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()));
        }
Exemple #17
0
        internal static Expression <Func <InventoryPickOrderItem, PendingOrderItem> > SelectPending()
        {
            var packaging = ProductProjectors.SelectPackagingProduct();

            return(Projector <InventoryPickOrderItem> .To(i => new PendingOrderItem
            {
                QuantityOrdered = i.Quantity,
                PackagingProduct = packaging.Invoke(i.PackagingProduct),
                Product = i.Product.Name,
                Treatment = i.InventoryTreatment.ShortName
            }));
        }
        internal static IEnumerable <Expression <Func <ChileLot, LabReportChileLotReturn> > > SplitSelectLabReportChileLot(IQueryable <ProductionBatch> productionBatches, IQueryable <LotProductionResults> lotProdcutionResuls, IQueryable <ChileLotProduction> chileLotProduction)
        {
            var chileProductKey   = ProductProjectors.SelectProductKey();
            var packSchedule      = PackScheduleProjectors.SelectBaseWithCustomer();
            var productionResult  = LotProductionResultsProjectors.SelectBase();
            var attribute         = LotAttributeProjectors.Select <WeightedLotAttributeReturn>();
            var lotTotes          = PickedInventoryItemProjectors.SelectPickedLot();
            var customerAllowance = LotCustomerAllowanceProjectors.Select();

            return(new[]
            {
                SelectLotBase().Merge(Projector <ChileLot> .To(c => new LabReportChileLotReturn
                {
                    LoBac = c.AllAttributesAreLoBac
                }), c => c.Lot).ExpandAll(),

                Projector <ChileLot> .To(c => new LabReportChileLotReturn
                {
                    UnresolvedDefects = c.Lot.LotDefects.Where(d => d.Resolution == null).Select(d => d.Description),
                    WeightedAttributes = c.Lot.Attributes.Select(a => attribute.Invoke(a)),
                    CustomerAllowances = c.Lot.CustomerAllowances.Select(a => customerAllowance.Invoke(a))
                }),

                Projector <ChileLot> .To(c => new LabReportChileLotReturn
                {
                    WeightedAttributes = c.Lot.Attributes.Select(a => new WeightedLotAttributeReturn
                    {
                        HasResolvedDefects = c.Lot.AttributeDefects.Any(d => d.AttributeShortName == a.AttributeShortName) &&
                                             c.Lot.AttributeDefects.Where(d => d.AttributeShortName == a.AttributeShortName).All(d => d.LotDefect.Resolution != null)
                    })
                }),

                Projector <ChileLot> .To(c => new LabReportChileLotReturn
                {
                    ChileProductKeyReturn = chileProductKey.Invoke(c.ChileProduct.Product),
                    PackScheduleBaseReturn = productionBatches.Where(b => b.LotDateCreated == c.LotDateCreated && b.LotDateSequence == c.LotDateSequence && b.LotTypeId == c.LotTypeId)
                                             .Select(b => packSchedule.Invoke(b.PackSchedule)).FirstOrDefault()
                }),

                Projector <ChileLot> .To(c => new LabReportChileLotReturn
                {
                    ProductionResultBaseReturn = lotProdcutionResuls.Where(r => r.LotDateCreated == c.LotDateCreated && r.LotDateSequence == c.LotDateSequence && r.LotTypeId == c.LotTypeId)
                                                 .Select(r => productionResult.Invoke(r)).FirstOrDefault(),
                    PickedLots = chileLotProduction.Where(r => r.LotDateCreated == c.LotDateCreated && r.LotDateSequence == c.LotDateSequence && r.LotTypeId == c.LotTypeId)
                                 .SelectMany(r => r.PickedInventory.Items.Select(i => lotTotes.Invoke(i)))
                })
            });
        }
Exemple #19
0
        internal static IEnumerable <Expression <Func <PackSchedule, PackSchedulePickSheetReturn> > > SplitSelectPickSheet(IProductionUnitOfWork productionUnitOfWork, DateTime currentDate)
        {
            var product    = ProductProjectors.SelectProductKeyName();
            var pickedItem = PickedInventoryItemProjectors.SplitSelectBatch(productionUnitOfWork, currentDate);

            return(pickedItem.Select(p => Projector <PackSchedule> .To(a => new PackSchedulePickSheetReturn
            {
                PickedItems = a.ProductionBatches.SelectMany(b => b.Production.PickedInventory.Items.Select(i => p.Invoke(i)))
            }))
                   .ToAppendedList(SelectBase().Merge(p => new PackSchedulePickSheetReturn
            {
                SummaryOfWork = p.SummaryOfWork,
                DateCreated = p.DateCreated,
                ChileProduct = product.Invoke(p.ChileProduct.Product)
            }).ExpandAll()));
        }
Exemple #20
0
        internal static Expression <Func <Customer, IEnumerable <CustomerChileProductAttributeRangesReturn> > > SelectProductSpecs(bool onlyActive = false)
        {
            var customerKey = SelectKey();
            var productKey  = ProductProjectors.SelectChileProductSummary();
            var rangeSelect = CustomerProductAttributeRangeProjectors.Select();

            return(Projector <Customer> .To(c => c.ProductSpecs
                                            .Where(r => r.Active || !onlyActive)
                                            .GroupBy(r => r.ChileProduct)
                                            .Select(g => new CustomerChileProductAttributeRangesReturn
            {
                CustomerKeyReturn = customerKey.Invoke(c),
                ChileProduct = productKey.Invoke(g.Key),
                AttributeRanges = g.Select(r => rangeSelect.Invoke(r))
            })));
        }
        internal static Expression <Func <LotProductionResultItem, MillAndWetdownResultItemReturn> > SelectMillAndWetdownResultItem()
        {
            var key = SelectProductionResultItemKey();
            var warehouseLocation = LocationProjectors.SelectLocation();
            var packagingProduct  = ProductProjectors.SelectPackagingProduct();

            return(r => new MillAndWetdownResultItemReturn
            {
                ItemKeyReturn = key.Invoke(r),
                PackagingProduct = packagingProduct.Invoke(r.PackagingProduct),
                Location = warehouseLocation.Invoke(r.Location),

                QuantityProduced = r.Quantity,
                TotalWeightProduced = (int)(r.Quantity * r.PackagingProduct.Weight)
            });
        }
        internal static Expression <Func <LotProductionResultItem, ProductionResultItemReturn> > Select()
        {
            var key = SelectProductionResultItemKey();
            var packagingProduct  = ProductProjectors.SelectPackagingProduct();
            var warehouseLocation = LocationProjectors.SelectLocation();
            var treatment         = InventoryTreatmentProjectors.SelectInventoryTreatment();

            return(i => new ProductionResultItemReturn
            {
                LotProductionResultItemKeyReturn = key.Invoke(i),
                PackagingProduct = packagingProduct.Invoke(i.PackagingProduct),
                Location = warehouseLocation.Invoke(i.Location),
                Treatment = treatment.Invoke(i.Treatment),
                Quantity = i.Quantity
            });
        }
        internal static Expression <Func <ChileMaterialsReceivedItem, ChileMaterialsReceivedItemReturn> > Select()
        {
            var key = SelectKey();
            var packagingProduct = ProductProjectors.SelectPackagingProduct();
            var location         = LocationProjectors.SelectLocation();

            return(SelectBase().Merge(i => new ChileMaterialsReceivedItemReturn
            {
                ChileMaterialsReceivedItemKeyReturn = key.Invoke(i),
                Variety = i.ChileVariety,
                Quantity = i.Quantity,
                TotalWeight = (int)(i.Quantity * i.PackagingProduct.Weight),
                PackagingProduct = packagingProduct.Invoke(i.PackagingProduct),
                Location = location.Invoke(i.Location)
            }));
        }
Exemple #24
0
        internal static IEnumerable <Expression <Func <ProductionBatch, ProductionBatchDetailReturn> > > SplitSelectDetail(Data.Interfaces.UnitsOfWork.IProductionUnitOfWork productionUnitOfWork, DateTime currentDate)
        {
            if (productionUnitOfWork == null)
            {
                throw new ArgumentNullException("productionUnitOfWork");
            }

            var packScheduleKey      = PackScheduleProjectors.SelectKey();
            var productKey           = ProductProjectors.SelectProductKey();
            var chileProduct         = ProductProjectors.SelectChileProductWithIngredients();
            var workType             = WorkTypeProjectors.Select();
            var notebook             = NotebookProjectors.Select();
            var pickedChile          = PickedInventoryProjectors.SelectPickedChileInventoryItem(productionUnitOfWork);
            var pickedPackaging      = PickedInventoryProjectors.SelectPickedPackagingInventoryItem(productionUnitOfWork);
            var pickedAdditve        = PickedInventoryProjectors.SelectPickedAdditiveInventoryItem(productionUnitOfWork);
            var pickedItemProjectors = PickedInventoryItemProjectors.SplitSelect(productionUnitOfWork, currentDate);

            return(new[]
            {
                SelectSummary().Merge(b => new ProductionBatchDetailReturn
                {
                    HasProductionBeenCompleted = b.ProductionHasBeenCompleted,
                }).ExpandAll(),
                Projector <ProductionBatch> .To(b => new ProductionBatchDetailReturn
                {
                    PackScheduleKeyReturn = packScheduleKey.Invoke(b.PackSchedule),
                    ChileProductKeyReturn = productKey.Invoke(b.Production.ResultingChileLot.ChileProduct.Product),
                    ChileProductName = b.Production.ResultingChileLot.ChileProduct.Product.Name,
                    ChileProductWithIngredients = chileProduct.Invoke(b.Production.ResultingChileLot.ChileProduct)
                }),
                Projector <ProductionBatch> .To(b => new ProductionBatchDetailReturn
                {
                    WorkType = workType.Invoke(b.PackSchedule.WorkType),
                    InstructionsNotebook = notebook.Invoke(b.InstructionNotebook)
                }),
                Projector <ProductionBatch> .To(b => new ProductionBatchDetailReturn
                {
                    PickedChileItems = pickedChile.Invoke(b.Production.PickedInventory),
                    PickedPackagingItems = pickedPackaging.Invoke(b.Production.PickedInventory),
                    PickedAdditiveItems = pickedAdditve.Invoke(b.Production.PickedInventory)
                })
            }.ToAppendedList(pickedItemProjectors.Select(p => Projector <ProductionBatch> .To(b => new ProductionBatchDetailReturn
            {
                PickedInventoryItems = b.Production.PickedInventory.Items.Select(i => p.Invoke(i))
            }))));
        }
Exemple #25
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
            });
        }
        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),
            }));
        }
Exemple #28
0
        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)
            }));
        }
Exemple #29
0
        internal static IEnumerable <Expression <Func <PackSchedule, PackScheduleDetailReturn> > > SplitSelectDetail()
        {
            var productKey        = ProductProjectors.SelectProductKey();
            var productionBatches = ProductionBatchProjectors.SelectSummary();

            return(SplitSelectSummary().Select(ConvertSummaryToDetail)
                   .ToListWithModifiedElement(0, e => e.Merge(p => new PackScheduleDetailReturn
            {
                SummaryOfWork = p.SummaryOfWork,
            }).ExpandAll())
                   .ToAppendedList(
                       Projector <PackSchedule> .To(p => new PackScheduleDetailReturn
            {
                PackagingProductKeyReturn = productKey.Invoke(p.PackagingProduct.Product),
                PackagingProductName = p.PackagingProduct.Product.Name,
                PackagingWeight = p.PackagingProduct.Weight,
            }),
                       Projector <PackSchedule> .To(p => new PackScheduleDetailReturn
            {
                ProductionBatches = p.ProductionBatches.Select(b => productionBatches.Invoke(b))
            })));
        }
        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()
            });
        }