// static TaxRateValue TaxRate { get; set; } public static string GetReceipt(Order order,ReceiptFormat format) { var totalAmount = 0d; string Template = ""; string lineTemplate = ""; if (format == ReceiptFormat.Html) { Template = HtmlTemplate; lineTemplate = HtmllineTemplate; } else { Template = TxtTemplate; lineTemplate = TxtlineTemplate; } var lines = new StringBuilder(); foreach (var line in order.Lines) { double thisAmount = OrderManager.CalculateAmount(line); lines.Append(string.Format(lineTemplate, line.Description, thisAmount.ToString("C"))); totalAmount += thisAmount; } var tax = totalAmount * TaxRate.Value; var result = new StringBuilder(string.Format(Template, order.Company, lines.ToString(), totalAmount.ToString("C"), tax.ToString("C"), (totalAmount + tax).ToString("C"))); return result.ToString(); }
public static double CalculateTotalAmount(Order order) { double totalAmount = 0d; foreach (var line in order.Lines) { totalAmount += OrderManager.CalculateAmount(line); } return totalAmount; }