internal static IResult <Expression <Func <InventoryShipmentOrder, bool> > > ParseToPredicate(this FilterInterWarehouseOrderParameters parameters)
        {
            var predicate = InventoryShipmentOrderPredicates.ByOrderType(InventoryShipmentOrderTypeEnum.InterWarehouseOrder);

            if (parameters != null)
            {
                if (parameters.OriginFacilityKey != null)
                {
                    var facilityKey = KeyParserHelper.ParseResult <IFacilityKey>(parameters.OriginFacilityKey);
                    if (!facilityKey.Success)
                    {
                        return(facilityKey.ConvertTo <Expression <Func <InventoryShipmentOrder, bool> > >());
                    }

                    predicate = predicate.And(InventoryShipmentOrderPredicates.ByOriginFacility(new FacilityKey(facilityKey.ResultingObject)).ExpandAll());
                }

                if (parameters.DestinationFacilityKey != null)
                {
                    var facilityKey = KeyParserHelper.ParseResult <IFacilityKey>(parameters.DestinationFacilityKey);
                    if (!facilityKey.Success)
                    {
                        return(facilityKey.ConvertTo <Expression <Func <InventoryShipmentOrder, bool> > >());
                    }

                    predicate = predicate.And(InventoryShipmentOrderPredicates.ByDestinationFacility(new FacilityKey(facilityKey.ResultingObject)).ExpandAll());
                }
            }

            return(new SuccessResult <Expression <Func <InventoryShipmentOrder, bool> > >(predicate));
        }
        public IResult <IInventoryShipmentOrderDetailReturn <IPickOrderDetailReturn <IPickOrderItemReturn>, IPickOrderItemReturn> > GetInterWarehouseOrder(string warehouseOrderKey)
        {
            if (warehouseOrderKey == null)
            {
                throw new ArgumentNullException("warehouseOrderKey");
            }

            var orderKeyResult = KeyParserHelper.ParseResult <IInventoryShipmentOrderKey>(warehouseOrderKey);

            if (!orderKeyResult.Success)
            {
                return(orderKeyResult.ConvertTo <IInventoryShipmentOrderDetailReturn <IPickOrderDetailReturn <IPickOrderItemReturn>, IPickOrderItemReturn> >());
            }

            var predicate = InventoryShipmentOrderPredicates.ByOrderType(InventoryShipmentOrderTypeEnum.InterWarehouseOrder);

            predicate = predicate.And(new InventoryShipmentOrderKey(orderKeyResult.ResultingObject).FindByPredicate).ExpandAll();
            var select = InventoryShipmentOrderProjectors.SplitSelectInventoryShipmentOrderDetail(_inventoryShipmentOrderUnitOfWork, _timeStamper.CurrentTimeStamp.Date, InventoryOrderEnum.TransWarehouseMovements);

            var order = _inventoryShipmentOrderUnitOfWork.InventoryShipmentOrderRepository.Filter(predicate).SplitSelect(select).FirstOrDefault();

            if (order == null)
            {
                return(new InvalidResult <IInventoryShipmentOrderDetailReturn <IPickOrderDetailReturn <IPickOrderItemReturn>, IPickOrderItemReturn> >(null, string.Format(UserMessages.InterWarehouseOrderNotFound, warehouseOrderKey)));
            }

            return(new SuccessResult <IInventoryShipmentOrderDetailReturn <IPickOrderDetailReturn <IPickOrderItemReturn>, IPickOrderItemReturn> >(order));
        }
Example #3
0
        internal IResult <IPendingOrderDetails> Get(DateTime startDate, DateTime endDate)
        {
            startDate = startDate.ToSimpleDate();
            endDate   = endDate.ToSimpleDate();

            if (startDate > endDate)
            {
                var tempDate = endDate;
                endDate   = startDate;
                startDate = tempDate;
            }

            var newStartDate = endDate.AddDays(1);
            var newEndDate   = endDate.AddDays(30);

            var byDateRange = InventoryShipmentOrderPredicates.ByShipmentDateRange(startDate, endDate);
            Expression <Func <InventoryShipmentOrder, bool> > customerOrder = o => o.OrderType == InventoryShipmentOrderTypeEnum.SalesOrder && o.OrderStatus != OrderStatus.Void;

            var scheduledAmount = GetOrderedWeight(_inventoryShipmentOrderUnitOfWork
                                                   .InventoryShipmentOrderRepository
                                                   .Filter(byDateRange.AndExpanded(customerOrder)));

            var shippedAmount = GetOrderedWeight(_inventoryShipmentOrderUnitOfWork
                                                 .InventoryShipmentOrderRepository
                                                 .Filter(byDateRange.AndExpanded(customerOrder).AndExpanded(o => o.ShipmentInformation.Status == ShipmentStatus.Shipped)));

            var remainingAmount = GetOrderedWeight(_inventoryShipmentOrderUnitOfWork
                                                   .InventoryShipmentOrderRepository
                                                   .Filter(byDateRange.AndExpanded(customerOrder).AndExpanded(o => o.ShipmentInformation.Status != ShipmentStatus.Shipped)));

            var newAmount = GetOrderedWeight(_inventoryShipmentOrderUnitOfWork
                                             .InventoryShipmentOrderRepository
                                             .Filter(InventoryShipmentOrderPredicates.ByShipmentDateRange(newStartDate, newEndDate).AndExpanded(customerOrder)));

            var pendingCustomerOrders = _inventoryShipmentOrderUnitOfWork
                                        .SalesOrderRepository
                                        .Filter(o => o.InventoryShipmentOrder.ShipmentInformation.Status != ShipmentStatus.Shipped && o.InventoryShipmentOrder.OrderStatus != OrderStatus.Void)
                                        .Select(SalesOrderProjectors.SelectPendingOrderDetails())
                                        .ToList();

            var pendingWarehouseOrders = _inventoryShipmentOrderUnitOfWork
                                         .InventoryShipmentOrderRepository
                                         .Filter(o => (o.OrderType == InventoryShipmentOrderTypeEnum.InterWarehouseOrder || o.OrderType == InventoryShipmentOrderTypeEnum.ConsignmentOrder) && o.ShipmentInformation.Status != ShipmentStatus.Shipped && o.OrderStatus != OrderStatus.Void)
                                         .Select(InventoryShipmentOrderProjectors.SelectPendingWarehouseOrder())
                                         .ToList();

            pendingWarehouseOrders.ForEach(o => o.Initialize());

            return(new SuccessResult <IPendingOrderDetails>(new PendingOrderDetails
            {
                Now = DateTime.Now.ToSimpleDate(),
                StartDate = startDate,
                EndDate = endDate,
                NewStartDate = newStartDate,
                NewEndDate = newEndDate,

                ScheduledAmount = (int)scheduledAmount,
                ShippedAmount = (int)shippedAmount,
                RemainingAmount = (int)remainingAmount,
                NewAmount = (int)newAmount,

                PendingCustomerOrders = pendingCustomerOrders,
                PendingWarehouseOrders = pendingWarehouseOrders
            }));
        }