public async Task <IOrderLedger> QueryUnallocated()
        {
            using (var dbContext = this._factory.Build())
            {
                var orders = await dbContext.Orders.AsNoTracking().ToArrayAsync();

                var portfolio = new OrderLedger
                {
                    Manager = string.Empty, Name = "Combined Portfolio", Orders = orders
                };

                return(portfolio);
            }
        }
예제 #2
0
        private ReceivedTransferMutation GetDifferenceRuleForIncompleteShipping(TransferOrderLine difference, int ReceivedFromWehkamp, int ShippedFromPFA, int storeID, string employeeNumber, int vendorID, DateTime receivedByWehkamp, int salesSlipNumber)
        {
            OrderLedger ledger = difference.OrderLine.OrderLedgers.FirstOrDefault(x => x.Status == (int)OrderLineStatus.ReceivedTransfer);

            var     product         = difference.OrderLine.Product;
            var     priceAssortment = product.VendorAssortments.FirstOrDefault(c => c.VendorID == vendorID).VendorPrices.FirstOrDefault();
            decimal markDown        = 0;

            if (priceAssortment.SpecialPrice.HasValue && priceAssortment.Price > priceAssortment.SpecialPrice.Value)
            {
                markDown = priceAssortment.Price.Value - priceAssortment.SpecialPrice.Value;
            }

            var productNumberParts = product.VendorItemNumber.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var artikelCode        = productNumberParts[0];
            var colorCode          = productNumberParts[1].PadLeft(3, '0');

            ReceivedTransferMutation datcolLine = new ReceivedTransferMutation
            {
                StoreNumber         = String.Format("{0} {1}", storeID, "01"),
                EmployeeNumber      = employeeNumber,
                ReceiptNumber       = salesSlipNumber,
                TransactionType     = "21",
                DateNotified        = receivedByWehkamp.ToString("yyyyMMddhhmm"),
                RecordType          = "01",
                SubType             = "02",
                NumberOfDifferences = QuantityHelper.GetNumberOfDifferences(difference.ReceivedFromWehkamp, difference.ShippedFromPFA),
                FixedField1         = "000000001+",
                FixedField2         = (int)Math.Round(markDown * 100),
                NumberOfSkus        = String.Format("{0}+", difference.ShippedFromPFA),
                FixedField3         = "000",
                FixedField4         = "000000000+",
                FixedField5         = "000",
                FixedField6         = 0,
                FixedField7         = "000",
                FixedField8         = (int)Math.Round(priceAssortment.Price.Value * 100),
                FixedField9         = "00",
                FixedField10        = "000" + ProductHelper.GetPFAItemNumber(artikelCode, colorCode, product.ProductID).ToUpper(),
                FixedField11        = "0000000" + BarcodeHelper.GetBarcode(product.ProductID),
                TransferNumber      = difference.OrderLine.Order.WebSiteOrderNumber,
                EmployeeNumber2     = employeeNumber,
                ScannedIndication   = 0
            };

            return(datcolLine);
        }
        public async Task <ILookup <string, IOrderLedger> > GetForClientAccount(IEnumerable <string> clientAccounts)
        {
            var filteredClientAccounts = clientAccounts?.Where(i => !string.IsNullOrWhiteSpace(i)).ToList();

            if (filteredClientAccounts == null || !filteredClientAccounts.Any())
            {
                return(new Dictionary <string, IOrderLedger>().ToLookup(i => i.Key, i => i.Value));
            }

            using (var dbContext = this._factory.Build())
            {
                var orderAllocations = dbContext.OrdersAllocation.Where(i => i.Live)
                                       .Where(i => filteredClientAccounts.Contains(i.ClientAccountId)).AsNoTracking().ToList();

                var orderAllocationOrderIds = orderAllocations.Select(i => i.OrderId).ToList();

                var orders = await dbContext.Orders.Where(i => i.Live)
                             .Where(i => orderAllocationOrderIds.Contains(i.ClientOrderId)).AsNoTracking()
                             .ToListAsync();

                var portfolios = new List <KeyValuePair <string, IOrderLedger> >();
                foreach (var clientAccount in filteredClientAccounts)
                {
                    var clientAccountsAllocs = orderAllocations.Where(
                        i => string.Equals(
                            i.ClientAccountId,
                            clientAccount,
                            StringComparison.InvariantCultureIgnoreCase)).ToList();

                    var clientAccountAllocOrderIds = clientAccountsAllocs.Select(i => i.OrderId).ToList();
                    var clientAccountOrders        =
                        orders.Where(i => clientAccountAllocOrderIds.Contains(i.ClientOrderId)).ToList();

                    var projectedOrders = this.MappedOrders(clientAccountOrders, clientAccountsAllocs);

                    var portfolio = new OrderLedger {
                        Name = clientAccount, Orders = projectedOrders
                    };

                    portfolios.Add(new KeyValuePair <string, IOrderLedger>(clientAccount, portfolio));
                }

                return(portfolios.ToLookup(i => i.Key, i => i.Value));
            }
        }