internal GetInventoryCommand(IInventoryUnitOfWork inventoryUnitOfWork)
 {
     if (inventoryUnitOfWork == null)
     {
         throw new ArgumentNullException("inventoryUnitOfWork");
     }
     _inventoryUnitOfWork = inventoryUnitOfWork;
 }
Beispiel #2
0
 internal ReceiveInventoryConductor(IInventoryUnitOfWork inventoryUnitOfWork)
 {
     if (inventoryUnitOfWork == null)
     {
         throw new ArgumentNullException("inventoryUnitOfWork");
     }
     _inventoryUnitOfWork = inventoryUnitOfWork;
 }
 public RequsitionInfoBusiness(IProductionUnitOfWork productionDb, IInventoryUnitOfWork inventoryDb)
 {
     this._productionDb          = productionDb;
     requsitionInfoRepository    = new RequsitionInfoRepository(this._productionDb);
     this._inventoryDb           = inventoryDb;
     _warehouseStockInfoBusiness = new WarehouseStockInfoBusiness(this._inventoryDb);
     itemBusiness = new ItemBusiness(this._inventoryDb);
 }
 internal CreateInventoryAdjustmentItemCommand(IInventoryUnitOfWork inventoryUnitOfWork)
 {
     if (inventoryUnitOfWork == null)
     {
         throw new ArgumentNullException("inventoryUnitOfWork");
     }
     _inventoryUnitOfWork = inventoryUnitOfWork;
 }
Beispiel #5
0
 public InventoryBaseRepository(IInventoryUnitOfWork inventoryUnitOfWork)
 {
     if (inventoryUnitOfWork == null)
     {
         throw new ArgumentNullException("DbContext is not assigned");
     }
     this._inventoryUnitOfWork = inventoryUnitOfWork;
     dbSet = this._inventoryUnitOfWork.Db.Set <T>();
 }
        private readonly IInventoryUnitOfWork _inventoryDb;                                // database
        public ProductionStockDetailBusiness(IProductionUnitOfWork productionDb, IInventoryUnitOfWork inventoryDb)
        {
            this._productionDb = productionDb;
            this._inventoryDb  = inventoryDb;

            _productionStockDetailRepository = new ProductionStockDetailRepository(this._productionDb);
            _productionStockInfoRepository   = new ProductionStockInfoRepository(this._productionDb);
            _productionStockInfoBusiness     = new ProductionStockInfoBusiness(this._productionDb);
            _requsitionInfoBusiness          = new RequsitionInfoBusiness(this._productionDb, this._inventoryDb);
            _requsitionDetailBusiness        = new RequsitionDetailBusiness(this._productionDb);
            _itemBusiness = new ItemBusiness(this._inventoryDb);
        }
Beispiel #7
0
        private readonly IProductionUnitOfWork _productionDb;                           // database;

        public WarehouseStockDetailBusiness(IInventoryUnitOfWork inventoryDb, IItemBusiness itemBusiness, IWarehouseStockInfoBusiness warehouseStockInfoBusiness, IProductionUnitOfWork productionDb)
        {
            this._inventoryDb = inventoryDb;
            _itemBusiness     = itemBusiness;
            warehouseStockDetailRepository = new WarehouseStockDetailRepository(this._inventoryDb);
            _warehouseStockInfoBusiness    = warehouseStockInfoBusiness;
            warehouseStockInfoRepository   = new WarehouseStockInfoRepository(this._inventoryDb);

            this._productionDb        = productionDb;
            _requsitionInfoBusiness   = new RequsitionInfoBusiness(this._productionDb, this._inventoryDb);
            _requsitionDetailBusiness = new RequsitionDetailBusiness(this._productionDb);
        }
Beispiel #8
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)
            })));
        }
 private readonly UnitRepository unitRepository;     // table
 public UnitBusiness(IInventoryUnitOfWork inventoryDb)
 {
     this._inventoryDb = inventoryDb;
     unitRepository    = new UnitRepository(this._inventoryDb);
 }
 private readonly ItemTypeRepository itemTypeRepository; // table
 public ItemTypeBusiness(IInventoryUnitOfWork inventoryDb)
 {
     this._inventoryDb  = inventoryDb;
     itemTypeRepository = new ItemTypeRepository(this._inventoryDb);
 }
 public WarehouseStockDetailRepository(IInventoryUnitOfWork inventoryUnitOfWork) : base(inventoryUnitOfWork)
 {
 }
 public ItemRepository(IInventoryUnitOfWork inventoryUnitOfWork) : base(inventoryUnitOfWork)
 {
 }
 public WarehouseRepository(IInventoryUnitOfWork inventoryUnitOfWork) : base(inventoryUnitOfWork)
 {
 }
Beispiel #14
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)
            }));
        }
Beispiel #15
0
 internal static IResult <Expression <Func <Inventory, bool> > > BuildPredicate(IInventoryUnitOfWork inventoryUnitOfWork, PredicateBuilderFilters filters, IEnumerable <Expression <Func <Inventory, bool> > > predicates)
 {
     return(BuildPredicate(inventoryUnitOfWork, filters, predicates == null ? null : predicates.ToArray()));
 }
        internal static IEnumerable <Expression <Func <InventoryShipmentOrder, InventoryShipmentOrderDetailBaseReturn> > > SplitSelectInventoryShipmentOrderDetailBase(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate, InventoryOrderEnum inventoryOrder, ISalesUnitOfWork salesUnitOfWork = null)
        {
            if (inventoryUnitOfWork == null)
            {
                throw new ArgumentNullException("inventoryUnitOfWork");
            }

            var pickedInventory = PickedInventoryProjectors.SplitSelectDetail(inventoryUnitOfWork, currentDate, salesUnitOfWork);
            var shipmentInfo    = ShipmentInformationProjectors.SelectDetail(inventoryOrder);

            return(new Projectors <InventoryShipmentOrder, InventoryShipmentOrderDetailBaseReturn>
            {
                SelectShipmentOrderBase().Merge(o => new InventoryShipmentOrderDetailBaseReturn
                {
                    PurchaseOrderNumber = o.PurchaseOrderNumber,
                    DateOrderReceived = o.DateReceived,
                    OrderRequestedBy = o.RequestedBy,
                    OrderTakenBy = o.TakenBy
                }),
                { pickedInventory, s => i => new InventoryShipmentOrderDetailBaseReturn
                  {
                      PickedInventory = s.Invoke(i.PickedInventory)
                  } },
                i => new InventoryShipmentOrderDetailBaseReturn
                {
                    Shipment = shipmentInfo.Invoke(i.ShipmentInformation)
                }
            });
        }
        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()));
        }
Beispiel #18
0
        internal static Expression <Func <Inventory, Product> > InventoryToProduct(IInventoryUnitOfWork inventoryUnitOfWork)
        {
            var lotToProduct = LotProjectors.SelectProduct(inventoryUnitOfWork);

            return(i => lotToProduct.Invoke(i.Lot));
        }
Beispiel #19
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()
            })));
        }
Beispiel #20
0
 internal static Expression <Func <PackSchedule, ProductionPacketReturn> > SelectProductionPacket(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate, ILotKey batchKey = null)
 {
     return(SplitSelectProductionPacket(inventoryUnitOfWork, currentDate, batchKey).Merge());
 }
Beispiel #21
0
 public SuppliersController(IInventoryUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
        internal static IEnumerable <Expression <Func <InventoryShipmentOrder, InventoryShipmentOrderDetailReturn> > > SplitSelectInventoryShipmentOrderDetail(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate, InventoryOrderEnum inventoryOrder)
        {
            if (inventoryUnitOfWork == null)
            {
                throw new ArgumentNullException("inventoryUnitOfWork");
            }

            var pickOrder = InventoryPickOrderProjectors.SplitSelectDetails();

            return(new Projectors <InventoryShipmentOrder, InventoryShipmentOrderDetailReturn>
            {
                { SplitSelectInventoryShipmentOrderDetailBase(inventoryUnitOfWork, currentDate, inventoryOrder), p => p.Translate().To <InventoryShipmentOrderDetailReturn>() },
                { pickOrder, s => i => new InventoryShipmentOrderDetailReturn
                  {
                      PickOrder = s.Invoke(i.InventoryPickOrder),
                  } }
            });
        }
 private readonly WarehouseRepository warehouseRepository; // table
 public WarehouseBusiness(IInventoryUnitOfWork inventoryDb)
 {
     this._inventoryDb   = inventoryDb;
     warehouseRepository = new WarehouseRepository(this._inventoryDb);
 }
Beispiel #24
0
        internal static IEnumerable <Expression <Func <Inventory, PickableInventoryItemReturn> > > SplitSelectPickableInventorySummary(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate,
                                                                                                                                       IEnumerable <Expression <Func <Inventory, bool> > > validForPicking, bool includeAllowances)
        {
            if (inventoryUnitOfWork == null)
            {
                throw new ArgumentNullException("inventoryUnitOfWork");
            }

            var selectValidForPicking = validForPicking.Aggregate(PredicateBuilder.True <Inventory>(), (c, n) => c.And(n)).ExpandAll();

            var projectors = SplitSelectInventorySummary(inventoryUnitOfWork, currentDate)
                             .Select(p => p.Merge(Projector <Inventory> .To(n => new PickableInventoryItemReturn {
            })))
                             .ToAppendedList(Projector <Inventory> .To(n => new PickableInventoryItemReturn
            {
                ValidForPicking = selectValidForPicking.Invoke(n)
            }));

            if (includeAllowances)
            {
                var contractAllowance      = LotContractAllowanceProjectors.SelectContractKey();
                var customerOrderAllowance = LotCustomerOrderAllowanceProjectors.SelectCustomerOrderKey();
                var customerAllowance      = LotCustomerAllowanceProjectors.SelectCustomerKey();

                projectors = projectors.ToAppendedList(Projector <Inventory> .To(i => new PickableInventoryItemReturn
                {
                    ContractAllowances      = i.Lot.ContractAllowances.Select(a => contractAllowance.Invoke(a)),
                    CustomerOrderAllowances = i.Lot.SalesOrderAllowances.Select(a => customerOrderAllowance.Invoke(a)),
                    CustomerAllowances      = i.Lot.CustomerAllowances.Select(a => customerAllowance.Invoke(a))
                }));
            }

            return(projectors);
        }
Beispiel #25
0
 internal static IEnumerable <Expression <Func <ProductionBatch, ProductionPacketReturn> > > SplitSelectProductionPacketFromBatch(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate, ILotKey batchKey)
 {
     return(PackScheduleProjectors.SplitSelectProductionPacket(inventoryUnitOfWork, currentDate, batchKey)
            .Select(b => Projector <ProductionBatch> .To(a => b.Invoke(a.PackSchedule))));
 }
        internal static Expression <Func <Inventory, bool> > ByProductKey(IKey <Product> productKey, IInventoryUnitOfWork inventoryUnitOfWork)
        {
            var inventoryToProduct  = InventoryProjectors.InventoryToProduct(inventoryUnitOfWork);
            var productKeyPredicate = productKey.FindByPredicate;

            return(i => productKeyPredicate.Invoke(inventoryToProduct.Invoke(i)));
        }
Beispiel #27
0
        internal static IResult <Expression <Func <Inventory, bool> > > BuildPredicate(IInventoryUnitOfWork inventoryUnitOfWork, PredicateBuilderFilters filters, params Expression <Func <Inventory, bool> >[] predicates)
        {
            if (inventoryUnitOfWork == null)
            {
                throw new ArgumentNullException("inventoryUnitOfWork");
            }

            var predicate = PredicateBuilder.True <Inventory>();

            if (predicates != null)
            {
                predicate = predicates.Aggregate(predicate, (c, p) => c.And(p.ExpandAll()));
            }

            return(ApplyFilters(predicate, filters, inventoryUnitOfWork));
        }
        internal static Expression <Func <Inventory, bool> > ByProductType(ProductTypeEnum productType, IInventoryUnitOfWork inventoryUnitOfWork)
        {
            var inventoryToProduct = InventoryProjectors.InventoryToProduct(inventoryUnitOfWork);

            return(i => inventoryToProduct.Invoke(i).ProductType == productType);
        }
Beispiel #29
0
        private static IResult <Expression <Func <Inventory, bool> > > ApplyFilters(Expression <Func <Inventory, bool> > predicate, PredicateBuilderFilters filters, IInventoryUnitOfWork inventoryUnitOfWork)
        {
            if (filters != null)
            {
                if (filters.LotKey != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByLotKey(filters.LotKey.ToLotKey()).ExpandAll());
                }

                if (filters.ProductKey != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByProductKey(filters.ProductKey.ToProductKey(), inventoryUnitOfWork).ExpandAll());
                }

                if (filters.FacilityKey != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByFacilityKey(filters.FacilityKey.ToFacilityKey()).ExpandAll());
                }

                if (filters.ProductType != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByProductType(filters.ProductType.Value, inventoryUnitOfWork).ExpandAll());
                }

                if (filters.LotType != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByLotType(filters.LotType.Value).ExpandAll());
                }

                if (filters.HoldType != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByLotHoldType(filters.HoldType.Value).ExpandAll());
                }

                if (filters.ToteKey != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByToteKey(filters.ToteKey).ExpandAll());
                }

                if (filters.AdditiveTypeKey != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByAdditiveTypeKey(filters.AdditiveTypeKey.ToAdditiveTypeKey()).ExpandAll());
                }

                if (filters.TreatmentKey != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByTreatment(filters.TreatmentKey.ToInventoryTreatmentKey()).ExpandAll());
                }

                if (filters.PackagingKey != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByPackaging(filters.PackagingKey.ToPackagingProductKey()).ExpandAll());
                }

                if (filters.PackagingReceivedKey != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByPackagingReceived(filters.PackagingReceivedKey.ToPackagingProductKey()).ExpandAll());
                }

                if (filters.LocationKey != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByLocationKey(filters.LocationKey.ToLocationKey()).ExpandAll());
                }

                if (filters.LocationGroupName != null)
                {
                    predicate = predicate.And(InventoryPredicates.ByLocationDescription(filters.LocationGroupName).ExpandAll());
                }
            }

            return(new SuccessResult <Expression <Func <Inventory, bool> > >(predicate.ExpandAll()));
        }
        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))
                  } }
            });
        }