internal static Expression <Func <LotSalesOrderAllowance, LotCustomerOrderAllowanceReturn> > Select()
        {
            var customerOrderKeyReturn = SalesOrderProjectors.SelectKey();
            var customerKey            = CustomerProjectors.SelectKey();

            return(a => new LotCustomerOrderAllowanceReturn
            {
                SalesOrderKeyReturn = customerOrderKeyReturn.Invoke(a.SalesOrder),
                OrderNumber = a.SalesOrder.InventoryShipmentOrder.MoveNum,
                CustomerKeyReturn = customerKey.Invoke(a.SalesOrder.Customer),
                CustomerName = a.SalesOrder.Customer.Company.Name
            });
        }
        internal static IEnumerable <Expression <Func <InventoryShipmentOrder, InternalOrderAcknowledgementReturn> > > SplitSelectAcknowledgement(IQueryable <SalesOrder> salesOrders)
        {
            var key           = SelectKey();
            var shipment      = ShipmentInformationProjectors.SelectShipmentInformation();
            var pickOrderItem = InventoryPickOrderItemProjectors.SplitSelect();
            var customerNotes = CustomerProjectors.SelectNotes();
            var salesOrder    = SalesOrderProjectors.SelectWarehouseAcknowlegement();

            return(new Projectors <InventoryShipmentOrder, InternalOrderAcknowledgementReturn>
            {
                o => new InternalOrderAcknowledgementReturn
                {
                    InventoryShipmentOrderKeyReturn = key.Invoke(o),
                    MovementNumber = o.MoveNum,
                    OrderType = o.OrderType,
                    PurchaseOrderNumber = o.PurchaseOrderNumber,
                    DateReceived = o.DateReceived,
                    RequestedBy = o.RequestedBy,
                    TakenBy = o.TakenBy,
                    OriginFacility = o.SourceFacility.Name
                },
                o => new InternalOrderAcknowledgementReturn
                {
                    ShipmentInformation = shipment.Invoke(o.ShipmentInformation)
                },
                { pickOrderItem, p => Projector <InventoryShipmentOrder> .To(o => new InternalOrderAcknowledgementReturn
                    {
                        PickOrderItems = o.InventoryPickOrder.Items.Select(i => p.Invoke(i))
                    }) },
                o => new InternalOrderAcknowledgementReturn
                {
                    TotalQuantity = o.InventoryPickOrder.Items.Select(i => i.Quantity).DefaultIfEmpty(0).Sum(),
                    NetWeight = o.InventoryPickOrder.Items.Select(i => i.Quantity * i.PackagingProduct.Weight).DefaultIfEmpty(0).Sum(),
                    TotalGrossWeight = o.InventoryPickOrder.Items.Select(i => i.Quantity * (i.PackagingProduct.Weight + i.PackagingProduct.PackagingWeight)).DefaultIfEmpty(0).Sum(),
                    PalletWeight = o.InventoryPickOrder.Items.Select(i => i.Quantity * (i.PackagingProduct.PalletWeight)).DefaultIfEmpty(0).Sum(),
                    EstimatedShippingWeight = o.InventoryPickOrder.Items.Select(i => i.Quantity * (i.PackagingProduct.Weight + i.PackagingProduct.PackagingWeight + i.PackagingProduct.PalletWeight)).DefaultIfEmpty(0).Sum()
                },
                o => new InternalOrderAcknowledgementReturn
                {
                    CustomerNotes = o.InventoryPickOrder.Items.Select(i => i.Customer).Distinct()
                                    .Where(c => c != null && c.Notes.Any())
                                    .Select(c => customerNotes.Invoke(c))
                },
                o => new InternalOrderAcknowledgementReturn
                {
                    SalesOrder = salesOrders.Where(c => c.DateCreated == o.DateCreated && c.Sequence == o.Sequence)
                                 .Select(c => salesOrder.Invoke(c)).FirstOrDefault()
                }
            });
        }
예제 #3
0
        internal static Expression <Func <Contract, ContractOrdersReturn> > SelectContractOrders(ISalesUnitOfWork salesUnitOfWork)
        {
            if (salesUnitOfWork == null)
            {
                throw new ArgumentNullException("salesUnitOfWork");
            }

            var key = SelectKey();
            var contractOrderPredicate = CustomerOrderPredicates.ByContract();
            var contractOrder          = SalesOrderProjectors.SelectCustomerContractOrder();

            var customerOrders = salesUnitOfWork.SalesOrderRepository.All();

            return(c => new ContractOrdersReturn
            {
                ContracKeyReturn = key.Invoke(c),
                Orders = customerOrders.Where(o => contractOrderPredicate.Invoke(o, c)).Select(o => contractOrder.Invoke(o, c))
            });
        }