Example #1
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))
                }
            });
        }
Example #2
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 <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)
            }));
        }
Example #4
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 <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()
            }));
        }
        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 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
                }
            });
        }
Example #8
0
        internal static Expression <Func <TreatmentOrder, TreatmentOrderSummaryReturn> > SelectSummary()
        {
            var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment();

            return(InventoryShipmentOrderProjectors.SelectInventoryShipmentOrderSummary().Merge(Projector <TreatmentOrder> .To(t => new TreatmentOrderSummaryReturn
            {
                Returned = t.Returned,
                InventoryTreatment = treatment.Invoke(t.Treatment)
            }), t => t.InventoryShipmentOrder));
        }
        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 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
            });
        }
Example #11
0
        internal static IEnumerable <Expression <Func <TreatmentOrder, TreatmentOrderDetailReturn> > > SplitSelectDetail(ITreatmentOrderUnitOfWork treatmentOrderUnitOfWork, DateTime currentDate)
        {
            if (treatmentOrderUnitOfWork == null)
            {
                throw new ArgumentNullException("treatmentOrderUnitOfWork");
            }

            var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment();

            return(new Projectors <TreatmentOrder, TreatmentOrderDetailReturn>
            {
                { InventoryShipmentOrderProjectors.SplitSelectInventoryShipmentOrderDetail(treatmentOrderUnitOfWork, currentDate, InventoryOrderEnum.Treatments), p => p.Translate().To <TreatmentOrder, TreatmentOrderDetailReturn>(t => t.InventoryShipmentOrder) },
                t => new TreatmentOrderDetailReturn
                {
                    Returned = t.Returned,
                    InventoryTreatment = treatment.Invoke(t.Treatment)
                }
            });
        }
        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),
            }));
        }
Example #14
0
        private static Expression <Func <SalesOrderItem, IEnumerable <SalesOrderPickedItem>, CustomerContractOrderItemReturn> > SelectContractOrderItemFromPicked()
        {
            var key             = SelectKey();
            var contractItemKey = SelectContractItemKey();

            var product   = ProductProjectors.SelectProduct();
            var packaging = ProductProjectors.SelectPackagingProduct();
            var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment();

            return((orderItem, pickedItems) => new CustomerContractOrderItemReturn
            {
                SalesOrderItemKeyReturn = key.Invoke(orderItem),
                ContractItemKeyReturn = contractItemKey.Invoke(orderItem),

                Product = product.Invoke(orderItem.InventoryPickOrderItem.Product),
                Packaging = packaging.Invoke(orderItem.InventoryPickOrderItem.PackagingProduct),
                Treatment = treatment.Invoke(orderItem.InventoryPickOrderItem.InventoryTreatment),

                TotalQuantityPicked = (int)(((int?)pickedItems.Sum(p => p.PickedInventoryItem.Quantity)) ?? 0),
                TotalWeightPicked = (int)(((int?)pickedItems.Sum(p => p.PickedInventoryItem.Quantity * p.PickedInventoryItem.PackagingProduct.Weight)) ?? 0),
                TotalPrice = orderItem.PriceBase + orderItem.PriceFreight + orderItem.PriceTreatment + orderItem.PriceWarehouse - orderItem.PriceRebate
            });
        }
Example #15
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
            });
        }