public static List <Report_GetSaleInvoice_Result> GetSaleByInvoiceId(string _saleInvoiceId) { List <Report_GetSaleInvoice_Result> _si = new List <Report_GetSaleInvoice_Result>(); using (AprosysAccountingEntities db = new AprosysAccountingEntities()) { _si = db.Report_GetSaleInvoice(_saleInvoiceId).ToList(); } //Partial Credit var PartialPayments = BL_CreditSales.GetAllPartialPayments().GroupBy(x => x.InvoiceNum).ToDictionary(x => x.Key); foreach (var item in _si) { if (item.IsSalesCredit.GetValueOrDefault() > 0) { item.PAID = 0; if (PartialPayments.ContainsKey(item.InvoiceNo)) { item.PAID = PartialPayments[item.InvoiceNo].Sum(x => x.Amount); } } } return(_si); }