Ejemplo n.º 1
0
        public IResult <ISalesOrderDetailReturn> GetSalesOrder(string salesOrderKey)
        {
            if (salesOrderKey == null)
            {
                throw new ArgumentNullException("salesOrderKey");
            }

            ISalesOrderDetailReturn salesOrder = null;
            var select = SalesOrderProjectors.SplitSelectDetail(_inventoryShipmentOrderUnitOfWork, _timeStamper.CurrentTimeStamp);

            var orderKeyResult = KeyParserHelper.ParseResult <ISalesOrderKey>(salesOrderKey);

            if (orderKeyResult.Success)
            {
                var orderKey = orderKeyResult.ResultingObject.ToSalesOrderKey();
                salesOrder = _inventoryShipmentOrderUnitOfWork.SalesOrderRepository.Filter(orderKey.FindByPredicate).SplitSelect(select).FirstOrDefault();
            }

            if (salesOrder == null)
            {
                int moveNum;
                if (int.TryParse(salesOrderKey, out moveNum))
                {
                    salesOrder = _inventoryShipmentOrderUnitOfWork.SalesOrderRepository.Filter(o => o.InventoryShipmentOrder.MoveNum == moveNum).SplitSelect(select).FirstOrDefault();
                }

                if (salesOrder == null)
                {
                    return(orderKeyResult.Success ? new InvalidResult <ISalesOrderDetailReturn>(null, string.Format(UserMessages.SalesOrderNotFound, salesOrderKey)) : orderKeyResult.ConvertTo <ISalesOrderDetailReturn>());
                }
            }

            return(new SuccessResult <ISalesOrderDetailReturn>(salesOrder));
        }
        internal IResult <ISalesOrderInvoice> Get(ISalesOrderKey orderKey)
        {
            var customerOrderKey = orderKey.ToSalesOrderKey();
            var predicate        = customerOrderKey.FindByPredicate;
            var select           = SalesOrderProjectors.SelectCustomerOrderInvoice();

            var invoice = _inventoryShipmentOrderUnitOfWork.SalesOrderRepository
                          .Filter(predicate)
                          .AsExpandable()
                          .Select(select)
                          .FirstOrDefault();

            if (invoice == null)
            {
                return(new InvalidResult <ISalesOrderInvoice>(null, string.Format(UserMessages.SalesOrderNotFound, customerOrderKey)));
            }

            invoice.Initialize();

            return(new SuccessResult <ISalesOrderInvoice>(invoice));
        }
Ejemplo n.º 3
0
        public IResult <IQueryable <ISalesOrderSummaryReturn> > GetSalesOrders(FilterSalesOrdersParameters parameters)
        {
            var parsedFiltersResult = parameters.ParseToPredicateBuilderFilters();

            if (!parsedFiltersResult.Success)
            {
                return(parsedFiltersResult.ConvertTo <IQueryable <ISalesOrderSummaryReturn> >());
            }

            var predicateResult = SalesOrderPredicateBuilder.BuildPredicate(_inventoryShipmentOrderUnitOfWork, parsedFiltersResult.ResultingObject);

            if (!predicateResult.Success)
            {
                return(predicateResult.ConvertTo <IQueryable <ISalesOrderSummaryReturn> >());
            }

            var select = SalesOrderProjectors.SplitSelectSummary();
            var query  = _inventoryShipmentOrderUnitOfWork.SalesOrderRepository.All()
                         .Where(predicateResult.ResultingObject)
                         .SplitSelect(select);

            return(new SuccessResult <IQueryable <ISalesOrderSummaryReturn> >(query));
        }
        public IResult <ISalesOrderAcknowledgementReturn> GetCustomerOrderAcknowledgement(string orderKey)
        {
            var orderKeyResult = KeyParserHelper.ParseResult <ISalesOrderKey>(orderKey);

            if (!orderKeyResult.Success)
            {
                return(orderKeyResult.ConvertTo <ISalesOrderAcknowledgementReturn>());
            }

            var predicate = new SalesOrderKey(orderKeyResult.ResultingObject).FindByPredicate;
            var select    = SalesOrderProjectors.SplitSelectAcknowledgement();

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

            if (order == null)
            {
                return(new InvalidResult <ISalesOrderAcknowledgementReturn>(null, string.Format(UserMessages.SalesOrderNotFound, orderKey)));
            }

            return(new SuccessResult <ISalesOrderAcknowledgementReturn>(order));
        }
Ejemplo n.º 5
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
            }));
        }