new receipt formats
This commit is contained in:
@@ -394,7 +394,7 @@ public class EpsonPrinter : IEpsonPrinter
|
||||
await SendRawAsync(EpsonCommands.FeedLines((byte)lines));
|
||||
}
|
||||
|
||||
public async Task CutAsync()
|
||||
public async Task CutAsync(bool fullCut=true)
|
||||
{
|
||||
_logger?.LogInformation("Cutting paper");
|
||||
await SendRawAsync(EpsonCommands.CutPaperFull);
|
||||
|
||||
@@ -322,11 +322,17 @@ public class HtmlPrinter : IEpsonPrinter
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task CutAsync()
|
||||
public Task CutAsync(bool fullCut = true)
|
||||
{
|
||||
EnsureConnected();
|
||||
_logger?.LogInformation("HtmlPrinter: Cutting paper");
|
||||
WriteHtmlFile();
|
||||
if(fullCut)
|
||||
WriteHtmlFile();
|
||||
else
|
||||
{
|
||||
// add scissors icon for partial cut
|
||||
_content.AppendLine("<div class=\"cut\"><span class=\"scissors\">✂️</span></div>");
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ public interface IEpsonPrinter : IAsyncDisposable
|
||||
/// <summary>
|
||||
/// Cut the paper
|
||||
/// </summary>
|
||||
Task CutAsync();
|
||||
Task CutAsync(bool fullCut=true);
|
||||
|
||||
/// <summary>
|
||||
/// Load an image from a file path into the printer buffer
|
||||
|
||||
@@ -35,6 +35,12 @@ public class TM_U220IITranslated : IPrinter
|
||||
{
|
||||
foreach (var command in commands)
|
||||
{
|
||||
if (command.IsCut)
|
||||
{
|
||||
await _printer.CutAsync(false);
|
||||
await Task.Delay(200);
|
||||
continue;
|
||||
}
|
||||
await _printer.SetBiggerFontTM220(command.IsBig, command.IsTall | command.IsBig);
|
||||
await Task.Delay(200);
|
||||
await _printer.SetRedColor(command.IsRed);
|
||||
|
||||
@@ -6,7 +6,7 @@ public class FinalReceipt
|
||||
public string Address1 { get; set; }
|
||||
public string Address2 { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string ReceiptNumber { get; set; }
|
||||
public string? ReceiptNumber { get; set; }
|
||||
public DateTime DateTime { get; set; }
|
||||
public int Guests { get; set; }
|
||||
public List<FinalReceiptItem> Items { get; set; } = new List<FinalReceiptItem>();
|
||||
|
||||
@@ -27,7 +27,12 @@ public class ReceiptConverter
|
||||
commands.Add(new PrintCommand("Debitorenrechnung"));
|
||||
}
|
||||
// FinalReceipt info
|
||||
string receiptLine = $"Rechnung Nr. {finalReceipt.ReceiptNumber}".PadRight(_lineWidth/2)+$"{finalReceipt.DateTime:HH:mm dd.MM.yyyy}".PadLeft(_lineWidth/2);
|
||||
string receiptLine = "";
|
||||
if (finalReceipt.ReceiptNumber != null)
|
||||
receiptLine += $"Rechnung Nr. {finalReceipt.ReceiptNumber}".PadRight(_lineWidth / 2);
|
||||
else
|
||||
receiptLine += $"".PadRight(_lineWidth / 2);
|
||||
receiptLine += $"{finalReceipt.DateTime:HH:mm dd.MM.yyyy}".PadLeft(_lineWidth / 2);
|
||||
commands.Add(new PrintCommand(receiptLine,isBold:true));
|
||||
commands.Add(new PrintCommand($"Guests: {finalReceipt.Guests}"));
|
||||
commands.Add(new PrintCommand(""));
|
||||
|
||||
@@ -12,6 +12,8 @@ public class InvoiceReceipt
|
||||
public List<ReceiptItem> Items { get; set; } = new List<ReceiptItem>();
|
||||
public decimal Total { get; set; }
|
||||
public string Currency { get; set; }
|
||||
public string TableNumber { get; set; }
|
||||
public string ThankYouMessage { get; set; }
|
||||
}
|
||||
|
||||
public class ReceiptItem
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using Inspectron.Epson.PrintServer.Printers.Utils.FinalRecipe;
|
||||
|
||||
namespace Inspectron.Epson.PrintServer.Printers.Utils.InvoiceReceipt;
|
||||
|
||||
public class ReceiptConverter
|
||||
@@ -24,7 +26,13 @@ public class ReceiptConverter
|
||||
commands.Add(new PrintCommand(""));
|
||||
|
||||
// InvoiceReceipt info
|
||||
string receiptLine = $"Rechnung Nr. {invoiceReceipt.ReceiptNumber}".PadRight(_lineWidth/2)+$"{invoiceReceipt.DateTime:HH:mm dd.MM.yyyy}".PadLeft(_lineWidth/2);
|
||||
string receiptLine = "";
|
||||
if (invoiceReceipt.ReceiptNumber != null)
|
||||
receiptLine += $"Rechnung Nr. {invoiceReceipt.ReceiptNumber}".PadRight(_lineWidth / 2);
|
||||
else
|
||||
receiptLine += $"".PadRight(_lineWidth / 2);
|
||||
receiptLine += $"{invoiceReceipt.DateTime:HH:mm dd.MM.yyyy}".PadLeft(_lineWidth / 2);
|
||||
|
||||
commands.Add(new PrintCommand(receiptLine,isBold:true));
|
||||
commands.Add(new PrintCommand($"Guests: {invoiceReceipt.Guests}"));
|
||||
commands.Add(new PrintCommand(""));
|
||||
@@ -59,6 +67,8 @@ public class ReceiptConverter
|
||||
// Total
|
||||
string totalLine = $"Summe: {invoiceReceipt.Total:F2} {invoiceReceipt.Currency}";
|
||||
commands.Add(new PrintCommand(Center(totalLine, true), true, true));
|
||||
commands.Add(new PrintCommand(Center($"Tisch: {invoiceReceipt.TableNumber}",false), false));
|
||||
commands.Add(new PrintCommand(Center(invoiceReceipt.ThankYouMessage, false)));
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class KitchenReceiptConverter
|
||||
|
||||
|
||||
// Gangs
|
||||
|
||||
|
||||
foreach (Gang gang in kitchenReceipt.Gangs)
|
||||
{
|
||||
|
||||
@@ -55,6 +55,13 @@ public class KitchenReceiptConverter
|
||||
{
|
||||
PrintDish(dish, commands);
|
||||
}
|
||||
|
||||
if (gang != kitchenReceipt.Gangs.Last())
|
||||
{
|
||||
commands.Add(new PrintCommand(""){IsCut = true});
|
||||
commands.Add(new PrintCommand(""));
|
||||
commands.Add(new PrintCommand(""));
|
||||
}
|
||||
}
|
||||
|
||||
if (kitchenReceipt.Gangs.Count > 0)
|
||||
@@ -96,7 +103,11 @@ public class KitchenReceiptConverter
|
||||
private static void PrintDish(Dish dish, List<PrintCommand> commands)
|
||||
{
|
||||
string dishLine = $"{dish.Number}x {dish.Name}";
|
||||
commands.Add(new PrintCommand(dishLine){IsTall = true});
|
||||
string guestInfo = dish.GuestId.HasValue ? $"{dish.GuestId.Value} " : "";
|
||||
|
||||
//todo: add word wrap if guest id is present and guestInfo + dish line too long. add spaces in front of continued lines to align with dish name start position
|
||||
|
||||
commands.Add(new PrintCommand(guestInfo+dishLine) {IsTall = true});
|
||||
// Modifications
|
||||
if (dish.Modifications != null && (dish.Modifications.Removed.Any() || dish.Modifications.Added.Any()))
|
||||
{
|
||||
|
||||
@@ -80,6 +80,8 @@
|
||||
|
||||
public Dish(){}
|
||||
|
||||
public int? GuestId { get; set; }
|
||||
|
||||
public Dish(int number, string name)
|
||||
{
|
||||
Number = number;
|
||||
|
||||
@@ -8,6 +8,7 @@ public class PrintCommand
|
||||
public bool IsBold { get; set; }
|
||||
public bool IsRed { get; set; }
|
||||
public int? SetLineSpacing { get; set; }=null;
|
||||
public bool IsCut { get; set; }
|
||||
public PrintCommand(string text, bool isBig = false, bool isBold = false)
|
||||
{
|
||||
Text = text;
|
||||
|
||||
Reference in New Issue
Block a user