public List <TaxItem> AddDinerTaxItems(Check Check) { foreach (var Id in Check.items.Select(x => x.DinerId).Distinct()) { double itemTotal = 0; TaxItem taxItem = new TaxItem(); foreach (var row in Check.items.Where(y => y.DinerId == Id)) { itemTotal += row.Price; } taxItem.PartyId = 0; taxItem.DinerId = Id; taxItem.ItemTotal = itemTotal; taxItem.TaxAmount = Math.Round((itemTotal * Check.CheckTaxPercentage), 2); taxItem.TaxPercent = Check.CheckTaxPercentage; taxItem.Diviser = 1; dinerTaxItems.Add(taxItem); } return(dinerTaxItems); }
public List<TaxItem> AddPartyTaxItems(Check Check) { foreach (var Id in Check.items.Select(x => x.PartyId).Distinct()) { double itemTotal = 0; TaxItem taxItem = new TaxItem(); foreach (var row in Check.items.Where(y => y.PartyId == Id)) { itemTotal += row.Price; } taxItem.PartyId = Id; taxItem.DinerId = 0; taxItem.ItemTotal = itemTotal; taxItem.TaxAmount = Math.Round((itemTotal * Check.CheckTaxPercentage), 2); taxItem.TaxPercent = Check.CheckTaxPercentage; taxItem.Diviser = 1; partyTaxItems.Add(taxItem); } return partyTaxItems; }