Beispiel #1
0
 public static IQueryable <Batch> FilterByStatus(this IQueryable <Batch> pLstObjBatches, BatchStatusFilterEnum pEnmStatus)
 {
     return(pEnmStatus != BatchStatusFilterEnum.ALL ?
            pLstObjBatches.Where(x => x.Unsold == (pEnmStatus == BatchStatusFilterEnum.UNSOLD)) :
            pLstObjBatches);
 }
Beispiel #2
0
        public static IList <ReportBatchDTO> ToDTO(this IQueryable <Batch> pLstObjBatches, BatchStatusFilterEnum pEnum = BatchStatusFilterEnum.ALL)
        {
            var lLstBatches = pLstObjBatches.ToList();

            if (pEnum != BatchStatusFilterEnum.SOLD)
            {
                lLstBatches.AddRange(
                    GetReturnsAsNotSold(pLstObjBatches.SelectMany(x => x.GoodsReturns).Where(x => !x.Removed).ToList()));
            }


            return(lLstBatches.Where(x => x.Quantity > 0).Select(b => new ReportBatchDTO()
            {
                AuctionId = b.AuctionId,
                AuctionFolio = b.AuctionId > 0 ? b.Auction.Folio : string.Empty,
                BatchId = !b.Unsold ? b.Id : 0,
                BatchNumber = b.Number,
                SellerCode = b.SellerId != null && b.SellerId > 0 ? b.Seller.Code : string.Empty,
                Seller = b.SellerId != null && b.SellerId > 0 ? b.Seller.Name : string.Empty,
                BuyerCode = b.BuyerId != null && b.BuyerId > 0  ? b.Buyer.Code : string.Empty,
                Buyer = b.BuyerId != null && b.BuyerId > 0 ? b.Buyer.Name : string.Empty,
                BuyerClass = b.BuyerClassificationId != null && b.BuyerClassificationId > 0 ? b.BuyerClassification.Number.ToString() : string.Empty,
                ItemTypeCode = b.ItemTypeId > 0 ? b.ItemType.Code : string.Empty,
                ItemType = b.ItemTypeId > 0 ? b.ItemType.Name : string.Empty,
                PerPrice = b.SellType,
                Available = b.Quantity,
                Quantity = b.Quantity,
                Returned = b.GoodsReturns.Where(x => !x.Removed).Select(y => (int?)y.Quantity).Sum() ?? 0,
                Delivered = (b.GoodsIssues.Where(x => !x.Removed).Select(y => (int?)y.Quantity).Sum() ?? 0) - (b.GoodsReturns.Where(x => !x.Removed).Select(y => (int?)y.Quantity).Sum() ?? 0),
                Weight = !b.Unsold ? b.Weight - (b.GoodsReturns.Where(x => !x.Removed && !x.Delivered).Select(y => (float?)y.Weight).Sum() ?? 0) : b.Weight,
                AverageWeight = b.AverageWeight,
                Price = b.Price,
                Amount = !b.Unsold ? b.Amount : 0,
                Unsold = b.Unsold,
                UnsoldMotiveId = (int)b.UnsoldMotive,
                Gender = b.Gender
            })
                   .AsEnumerable()
                   .Select(b =>
            {
                b.AverageWeight = !b.Unsold ?(b.Quantity - b.Returned) > 0 ? b.Weight / (b.Quantity - b.Returned) : 0 : b.AverageWeight;
                b.Available = (b.Quantity - b.Delivered - b.Returned);
                b.Weight = !b.Unsold ? ((b.Quantity - b.Returned) * b.AverageWeight): b.Weight;
                b.Quantity = !b.Unsold ? (b.Quantity - b.Returned) : b.Quantity;
                b.Amount = !b.Unsold ? (b.PerPrice ? (b.Price * (b.Quantity)) : b.Price * Convert.ToDecimal(b.Weight)) : 0;
                b.Unsold = b.Quantity == 0 || b.Unsold ? true : false;

                return b;
            })
                   .ToList());
        }
Beispiel #3
0
 public IList <ReportBatchDTO> GetBatchesByBuyer(DateTime?pDtmStartDate, DateTime?pDtmEndDate, string pStrAuctionFolio, string pStrBuyerCardCode, BatchStatusFilterEnum pEnmStatus)
 {
     return(GetBatchesList()
            .FilterByStartDate(pDtmStartDate)
            .FilterByEndDate(pDtmEndDate)
            .FilterByAuction(pStrAuctionFolio)
            .FilterByBuyer(pStrBuyerCardCode)
            .FilterByStatus(pEnmStatus)
            .ToDTO(pEnmStatus));
 }