protected void ReturnLines(IList <CollectReportLine> lines, InvoiceDetailsForReturn detailsForReturn, List <IDictionary <string, object> > payments) { var insertTable = new List <IDictionary <string, object> >(); for (var i = 0; i < lines.Count; i++) { var line = lines[i]; var detailLine = detailsForReturn.Lines.FirstOrDefault(p => Utils.ToDecimal(p["IslemID"]) == line.IslemID); if (detailLine == null) { throw new B2CPackageCollectException(StringResource.InvoiceReturnDetailNotFound); } var insertRow = detailLine; for (var j = 0; j < 5; j++) { object type = string.Empty; object amount = 0; if (detailsForReturn.Lines.Count - 1 == i && j < payments.Count) { var paymentLine = payments[j]; type = paymentLine["PaymentType"]; amount = paymentLine["PaymentAmount"]; } insertRow.Add("PaymentType" + (j + 1), type); insertRow.Add("PaymentAmount" + (j + 1), amount); } insertRow.Remove("IslemID"); insertTable.Add(insertRow); } using (var db = new Db(true)) { db.SaveReturnInvoice(insertTable); db.UpdateCollectCompleted(lines.First().AlisverisID); db.Commit(); } RemoveFromDatasource(lines.First().AlisverisID); }
private decimal GetPartialPaymentAmount(IEnumerable <CollectReportLine> lines, InvoiceDetailsForReturn detailsForReturn) { var selectedLines = detailsForReturn.Lines.Where(p => lines.Any(r => r.IslemID == Utils.ToDecimal(p["IslemID"]))); decimal payment = 0; foreach (var line in selectedLines) { payment += (Utils.ToDecimal(line["ItemPrice"]) * Utils.ToDecimal(line["ItemAmount"])) - Utils.ToDecimal(line["DigerIndirim"]); } return(payment); }