public List <InvoiceDetailViewModel> RetrieveInvoiceDetail(int invoiceID)
        {
            List <InvoiceDetail>          result       = _invoiceDetailRepository.GetMany(x => x.InvoiceId == invoiceID).ToList();
            List <InvoiceDetailViewModel> mappedResult = new List <InvoiceDetailViewModel>();

            Map(result, mappedResult);
            foreach (var itemMappedResult in mappedResult)
            {
                if (itemMappedResult.FeePctg == null)
                {
                    itemMappedResult.FeePctg = 0;
                }
            }
            return(mappedResult);
        }
        public List <ReturnViewModel> GetReturnListDetail(int salesReturnID, int invoiceID)
        {
            List <ReturnViewModel> result            = new List <ReturnViewModel>();
            List <InvoiceDetail>   listInvoiceDetail = _invoiceDetailRepository.GetMany(x => x.InvoiceId == invoiceID).ToList();

            if (salesReturnID > 0)
            {
                List <SalesReturnDetail> listDetail = this.RetrieveSalesReturnDetail(salesReturnID);
                if (listDetail != null && listDetail.Count > 0)
                {
                    int[] sparepartIDs = listInvoiceDetail.Select(x => x.SPKDetailSparepartDetail.SPKDetailSparepart.SparepartId).Distinct().ToArray();
                    foreach (var sparepartID in sparepartIDs)
                    {
                        if (listDetail.Where(x => x.InvoiceDetail.SPKDetailSparepartDetail.SPKDetailSparepart.SparepartId == sparepartID).Count() > 0)
                        {
                            result.Add(new ReturnViewModel
                            {
                                SparepartId   = sparepartID,
                                SparepartName = _sparepartRepository.GetById(sparepartID).Name,
                                ReturQty      = listDetail.Where(x => x.InvoiceDetail.SPKDetailSparepartDetail.SPKDetailSparepart.SparepartId == sparepartID).Count(),
                                ReturQtyLimit = listInvoiceDetail.Where(x => x.SPKDetailSparepartDetail.SPKDetailSparepart.SparepartId == sparepartID).Count(),
                                SparepartCode = _sparepartRepository.GetById(sparepartID).Code,
                                UnitName      = _sparepartRepository.GetById(sparepartID).UnitReference.Name,
                                SubTotalFee   = (listDetail.Where(x => x.InvoiceDetail.SPKDetailSparepartDetail.SPKDetailSparepart.SparepartId == sparepartID).Sum(x => x.InvoiceDetail.SubTotalPrice)).AsDecimal()
                            });
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public IEnumerable <InvoiceDetail> GetInvoiceDetails(Func <InvoiceDetail, bool> where)
 {
     if (@where == null)
     {
         throw new ArgumentException("where");
     }
     return(_roleRepository.GetMany(where));
 }
Exemplo n.º 4
0
        public List <InvoiceSparepartViewModel> GetInvoiceSparepartList(int invoiceID)
        {
            List <InvoiceSparepartViewModel> result            = new List <InvoiceSparepartViewModel>();
            List <InvoiceDetail>             listInvoiceDetail = _invoiceDetailRepository.GetMany(x => x.InvoiceId == invoiceID).ToList();

            foreach (InvoiceDetail invoiceDetail in listInvoiceDetail)
            {
                double itemPrice = 0;

                if (invoiceDetail.SPKDetailSparepartDetail.SparepartManualTransactionId > 0)
                {
                    itemPrice = decimal.ToDouble(invoiceDetail.SPKDetailSparepartDetail.SparepartManualTransaction.Price);
                }
                else if (invoiceDetail.SPKDetailSparepartDetail.PurchasingDetailId > 0)
                {
                    itemPrice = decimal.ToDouble(invoiceDetail.SPKDetailSparepartDetail.PurchasingDetail.Price);
                }

                result.Add(new InvoiceSparepartViewModel
                {
                    SparepartName    = invoiceDetail.SPKDetailSparepartDetail.SPKDetailSparepart.Sparepart.Name,
                    Qty              = invoiceDetail.SPKDetailSparepartDetail.SPKDetailSparepart.TotalQuantity,
                    SubTotalPrice    = decimal.ToDouble(invoiceDetail.SPKDetailSparepartDetail.SPKDetailSparepart.TotalPrice),
                    SparepartCode    = invoiceDetail.SPKDetailSparepartDetail.SPKDetailSparepart.Sparepart.Code,
                    UnitCategoryName = invoiceDetail.SPKDetailSparepartDetail.SPKDetailSparepart.Sparepart.UnitReference.Name,
                    ItemPrice        = itemPrice
                });
            }

            //int[] sparepartIDs = listInvoiceDetail.Select(x => x.SPKDetailSparepartDetail.SPKDetailSparepart.SparepartId).Distinct().ToArray();
            //foreach (var sparepartID in sparepartIDs)
            //{
            //    result.Add(new InvoiceSparepartViewModel
            //    {
            //        SparepartName = _sparepartRepository.GetById(sparepartID).Name,
            //        Qty = listInvoiceDetail.Where(x => x.SPKDetailSparepartDetail.SPKDetailSparepart.SparepartId == sparepartID).Count(),
            //        SubTotalPrice = listInvoiceDetail.Where(x => x.SPKDetailSparepartDetail.SPKDetailSparepart.SparepartId == sparepartID).Sum(x => x.SubTotalPrice),
            //        SparepartCode = _sparepartRepository.GetById(sparepartID).Code,
            //        UnitCategoryName = _sparepartRepository.GetById(sparepartID).UnitReference.Name
            //    });
            //}
            return(result);
        }
        private List <InvoiceSparepartViewModel> GetInvoiceSparepartList(int invoiceID)
        {
            List <InvoiceSparepartViewModel> result            = new List <InvoiceSparepartViewModel>();
            List <InvoiceDetail>             listInvoiceDetail = _invoiceDetailRepository.GetMany(x => x.InvoiceId == invoiceID).ToList();

            int[] sparepartIDs = listInvoiceDetail.Select(x => x.SPKDetailSparepartDetail.SPKDetailSparepart.SparepartId).Distinct().ToArray();

            foreach (var sparepartID in sparepartIDs)
            {
                Sparepart            sparepart = _sparepartRepository.GetById(sparepartID);
                List <InvoiceDetail> listInvoiceDetailFilter = listInvoiceDetail.Where(x => x.SPKDetailSparepartDetail.SPKDetailSparepart.SparepartId == sparepartID).ToList();
                result.Add(new InvoiceSparepartViewModel
                {
                    SparepartName    = sparepart.Name,
                    Qty              = listInvoiceDetailFilter.Count(),
                    NominalFee       = listInvoiceDetailFilter.Sum(x => x.FeePctg > 0 ? (100 / (100 + x.FeePctg)) * x.SubTotalPrice : 0),
                    SubTotalPrice    = listInvoiceDetailFilter.Sum(x => x.SubTotalPrice),
                    SparepartCode    = sparepart.Code,
                    UnitCategoryName = sparepart.UnitReference.Name,
                });
            }
            return(result);
        }