// 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 async Task HandleReceiptFor(GarageTicket ticket, string emailAddress, ReceiptFormat receiptFormat) { if (ticket.Payment is ParkingPermit permit) { // Simplistic approach: parking permit does not generate receipt return; } var receiptContent = _contentBuilder.BuildContent(ticket); switch (receiptFormat) { case ReceiptFormat.Email: await _emailClient.EmailAsync(emailAddress, receiptContent); break; case ReceiptFormat.Print: await _deviceClient.PrintAsync(receiptContent); break; } }
internal TestData(string receipt, ReceiptFormat format = ReceiptFormat.Unknown, string station = null, decimal?qty = null, decimal?price = null, DateTime?date = null) { Receipt = receipt; Format = format; StationName = station; Qty = qty; Price = price; Date = date; }
private static FuelReceiptData ParseReceipt(Context ctx, ReceiptFormat format, ReceiptDataIn receiptInput) { switch (format) { case ReceiptFormat.Fuel_Abc: return(ctx.FuelReceiptParser.ParseReceipt(receiptInput)); default: throw new Exception(string.Format( "Unsupported receipt format. Input:\n{0}", receiptInput.RawText)); } }
public async Task CheckOutAsync(string ticketId, string emailAddress, ReceiptFormat receiptFormat) { var ticket = await _repository.FindAsync(ticketId); if (ticket == null) { throw new InvalidOperationException("Ticket not found"); } ticket.CheckOutTime = DateTime.Now; var processor = _factory.Create(ticket.Payment.GetType()); await processor.CheckOutAsync(ticket); await _receiptProvider.HandleReceiptAsync(ticket, emailAddress, receiptFormat); }