internal static IEnumerable <Expression <Func <InventoryShipmentOrder, InventoryShipmentOrderPickSheetReturn> > > SplitSelectPickSheet()
        {
            var key           = SelectKey();
            var item          = PickedInventoryItemProjectors.SplitSelectPickSheetItem().Merge(); //Necessary to avoid likely EF-Split bug in subsequent group selection. -RI 2015/04/15
            var customerNotes = CustomerProjectors.SelectNotes();
            var shipment      = ShipmentInformationProjectors.SelectShipmentInformation();

            return(new Projectors <InventoryShipmentOrder, InventoryShipmentOrderPickSheetReturn>
            {
                o => new InventoryShipmentOrderPickSheetReturn
                {
                    OrderType = o.OrderType,
                    InventoryShipmentOrderKeyReturn = key.Invoke(o),
                    MovementNumber = o.MoveNum,
                    PurchaseOrderNumber = o.PurchaseOrderNumber,
                    ShipmentInformation = shipment.Invoke(o.ShipmentInformation)
                },
                o => new InventoryShipmentOrderPickSheetReturn
                {
                    CustomerNotes = o.InventoryPickOrder.Items.Select(i => i.Customer).Distinct()
                                    .Where(c => c != null && c.Notes.Any())
                                    .Select(c => customerNotes.Invoke(c))
                },
                o => new InventoryShipmentOrderPickSheetReturn
                {
                    Items = o.PickedInventory.Items.Select(i => item.Invoke(i))
                }
            });
        }
Exemple #2
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)
            }));
        }
        internal static IEnumerable <Expression <Func <InventoryShipmentOrder, InventoryShipmentOrderBillOfLadingReturn> > > SplitSelectBillOfLading()
        {
            var key      = SelectKey();
            var item     = PickedInventoryItemProjectors.SplitSelectPackingListItem();
            var shipment = ShipmentInformationProjectors.SelectShipmentInformation();

            return(new Projectors <InventoryShipmentOrder, InventoryShipmentOrderBillOfLadingReturn>
            {
                o => new InventoryShipmentOrderBillOfLadingReturn
                {
                    OrderType = o.OrderType,
                    SourceFacilityLabelName = o.SourceFacility.ShippingLabelName,
                    SourceFacilityAddress = o.SourceFacility.Address,
                    InventoryShipmentOrderKeyReturn = key.Invoke(o),
                    MoveNum = o.MoveNum,
                    ShipmentInformation = shipment.Invoke(o.ShipmentInformation),
                    PurchaseOrderNumber = o.PurchaseOrderNumber
                },
                o => new InventoryShipmentOrderBillOfLadingReturn
                {
                    TotalQuantity = o.PickedInventory.Items.Any() ? o.PickedInventory.Items.Sum(i => i.Quantity) : 0,
                    PalletWeight = o.PickedInventory.Items.Any() ? o.PickedInventory.Items.Sum(i => i.Quantity * (i.PackagingProduct.PalletWeight)) : 0,
                    TotalGrossWeight = o.PickedInventory.Items.Any() ? o.PickedInventory.Items.Sum(i => i.Quantity * (i.PackagingProduct.Weight + i.PackagingProduct.PackagingWeight)) : 0,
                    TotalNetWeight = o.PickedInventory.Items.Any() ? o.PickedInventory.Items.Sum(i => i.Quantity * i.PackagingProduct.Weight) : 0,
                },
                { item, p => Projector <InventoryShipmentOrder> .To(o => new InventoryShipmentOrderBillOfLadingReturn
                    {
                        Items = o.PickedInventory.Items.Select(i => p.Invoke(i))
                    }) }
            });
        }
        internal static IEnumerable <Expression <Func <InventoryShipmentOrder, InventoryShipmentOrderPackingListReturn> > > SplitSelectPackingList()
        {
            var key  = SelectKey();
            var item = PickedInventoryItemProjectors.SplitSelectPackingListItem();

            return(new Projectors <InventoryShipmentOrder, InventoryShipmentOrderPackingListReturn>
            {
                o => new InventoryShipmentOrderPackingListReturn
                {
                    OrderType = o.OrderType,
                    InventoryShipmentOrderKeyReturn = key.Invoke(o),
                    MovementNumber = o.MoveNum,
                    ShipmentDate = o.ShipmentInformation.ShipmentDate,
                    PurchaseOrderNumber = o.PurchaseOrderNumber,
                    ShipFromOrSoldToShippingLabel = o.ShipmentInformation.ShipFrom,
                    ShipToShippingLabel = o.ShipmentInformation.ShipTo
                },
                o => new InventoryShipmentOrderPackingListReturn
                {
                    TotalQuantity = o.PickedInventory.Items.Any() ? o.PickedInventory.Items.Sum(i => i.Quantity) : 0,
                    PalletQuantity = o.ShipmentInformation.PalletQuantity,
                    PalletWeight = o.ShipmentInformation.PalletWeight,
                    ItemSumPalletWeight = o.PickedInventory.Items.Any() ? o.PickedInventory.Items.Sum(i => i.Quantity * (i.PackagingProduct.PalletWeight)) : 0,
                    TotalGrossWeight = o.PickedInventory.Items.Any() ? o.PickedInventory.Items.Sum(i => i.Quantity * (i.PackagingProduct.Weight + i.PackagingProduct.PackagingWeight)) : 0,
                    TotalNetWeight = o.PickedInventory.Items.Any() ? o.PickedInventory.Items.Sum(i => i.Quantity * i.PackagingProduct.Weight) : 0,
                },
                { item, p => Projector <InventoryShipmentOrder> .To(o => new InventoryShipmentOrderPackingListReturn
                    {
                        Items = o.PickedInventory.Items.Select(i => p.Invoke(i))
                    }) }
            });
        }
Exemple #5
0
        internal static Expression <Func <ChileLotProduction, MillAndWetdownReturn> > SelectDetail(ILotUnitOfWork lotUnitOfWork)
        {
            var resultItem = LotProductionResultItemProjectors.SelectMillAndWetdownResultItem();
            var pickedItem = PickedInventoryItemProjectors.SelectMillAndWetdownPickedItem(lotUnitOfWork);

            return(SelectBase().Merge(m => new MillAndWetdownReturn
            {
                ResultItems = m.Results.ResultItems.Select(i => resultItem.Invoke(i)),
                PickedItems = m.PickedInventory.Items.Select(i => pickedItem.Invoke(i))
            }));
        }
        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 #7
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 #8
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))
            }))));
        }
        internal static Expression <Func <InventoryShipmentOrder, PendingWarehouseOrderDetail> > SelectPendingWarehouseOrder()
        {
            var orderItemSelect  = InventoryPickOrderItemProjectors.SelectPickPending();
            var pickedItemSelect = PickedInventoryItemProjectors.ItemSelect();

            return(Projector <InventoryShipmentOrder> .To(o => new PendingWarehouseOrderDetail
            {
                From = o.SourceFacility.Name,
                To = new[] { o.DestinationFacility }.Where(f => f != null).Select(f => f.Name).FirstOrDefault(),
                DateRecd = o.DateReceived,
                ShipmentDate = o.ShipmentInformation.ShipmentDate,
                MoveNum = o.MoveNum,
                Status = o.OrderStatus,

                Items = o.InventoryPickOrder.Items.Select(i => orderItemSelect.Invoke(i)),
                PickedItemSelect = o.PickedInventory.Items.Select(i => pickedItemSelect.Invoke(i))
            }));
        }
        internal static IEnumerable <Expression <Func <PickedInventory, PickedInventoryReturn> > > SplitSelectDetail(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate, ISalesUnitOfWork salesUnitOfWork = null)
        {
            if (inventoryUnitOfWork == null)
            {
                throw new ArgumentNullException("inventoryUnitOfWork");
            }

            var attributeNames = AttributeNameProjectors.SelectActiveAttributeNames(inventoryUnitOfWork);
            var itemSelector   = PickedInventoryItemProjectors.SplitSelect(inventoryUnitOfWork, currentDate, salesUnitOfWork);

            return(new Projectors <PickedInventory, PickedInventoryReturn>
            {
                SelectBase().Merge(i => new PickedInventoryReturn
                {
                    AttributeNamesAndTypes = attributeNames.Invoke()
                }),
                { itemSelector, s => i => new PickedInventoryReturn
                  {
                      PickedInventoryItems = i.Items.Select(m => s.Invoke(m))
                  } }
            });
        }
        internal static IEnumerable <Expression <Func <InventoryShipmentOrder, InventoryShipmentOrderCertificateOfAnalysisReturn> > > SplitSelectCertificateOfAnalysisReturn()
        {
            var key  = SelectKey();
            var item = PickedInventoryItemProjectors.SplitSelectCOAItem();

            return(new Projectors <InventoryShipmentOrder, InventoryShipmentOrderCertificateOfAnalysisReturn>
            {
                o => new InventoryShipmentOrderCertificateOfAnalysisReturn
                {
                    OrderKeyReturn = key.Invoke(o),
                    MovementNumber = o.MoveNum,
                    PurchaseOrderNumber = o.PurchaseOrderNumber,
                    ShipmentDate = o.ShipmentInformation.ShipmentDate,
                    OrderType = o.OrderType,
                    DestinationName = new[] { o.DestinationFacility }.Where(f => f != null).Select(f => f.Name).FirstOrDefault()
                },
                { item, p => Projector <InventoryShipmentOrder> .To(o => new InventoryShipmentOrderCertificateOfAnalysisReturn
                    {
                        _Items = o.PickedInventory.Items.Where(i => i.Lot.ChileLot != null).Select(i => p.Invoke(i))
                    }) }
            });
        }