new receipt formats
This commit is contained in:
@@ -43,19 +43,19 @@ using System.Text.Json;
|
||||
// ============================================================================
|
||||
// INVOICE RECEIPT - HTML PRINTER
|
||||
// ============================================================================
|
||||
var receipt = TestHelpers.BuildSampleInvoiceReceipt();
|
||||
var serializedReceipt = JsonSerializer.Serialize(receipt, new JsonSerializerOptions { WriteIndented = true });
|
||||
//var receipt = TestHelpers.BuildSampleInvoiceReceipt();
|
||||
//var serializedReceipt = JsonSerializer.Serialize(receipt, new JsonSerializerOptions { WriteIndented = true });
|
||||
|
||||
var converter = new InvoiceReceiptConverter(lineWidth: 48, bigFontLineWidth: 24);
|
||||
var printCommands = converter.Convert(serializedReceipt);
|
||||
//var converter = new InvoiceReceiptConverter(lineWidth: 48, bigFontLineWidth: 24);
|
||||
//var printCommands = converter.Convert(serializedReceipt);
|
||||
|
||||
TestHelpers.PrintCommandsToConsole(printCommands);
|
||||
//TestHelpers.PrintCommandsToConsole(printCommands);
|
||||
|
||||
var printer = await TestHelpers.CreateHtmlPrinterAsync();
|
||||
await TestHelpers.PrintCommandsToHtmlPrinterAsync(
|
||||
printer,
|
||||
printCommands,
|
||||
logoPath: "ristorante-klinglers.ch-logo_white_bg.png");
|
||||
//var printer = await TestHelpers.CreateHtmlPrinterAsync();
|
||||
//await TestHelpers.PrintCommandsToHtmlPrinterAsync(
|
||||
// printer,
|
||||
// printCommands,
|
||||
// logoPath: "ristorante-klinglers.ch-logo_white_bg.png");
|
||||
|
||||
|
||||
// ============================================================================
|
||||
@@ -112,17 +112,17 @@ await TestHelpers.PrintCommandsToHtmlPrinterAsync(
|
||||
// ============================================================================
|
||||
// KITCHEN RECEIPT - EPSON PRINTER
|
||||
// ============================================================================
|
||||
//var receipt = TestHelpers.BuildSampleKitchenReceiptNextDish();
|
||||
//var serializedReceipt = JsonSerializer.Serialize(receipt, new JsonSerializerOptions { WriteIndented = true });
|
||||
//var deserializedReceipt = JsonSerializer.Deserialize<KitchenReceipt>(serializedReceipt);
|
||||
var receipt = TestHelpers.BuildSampleKitchenReceipt();
|
||||
var serializedReceipt = JsonSerializer.Serialize(receipt, new JsonSerializerOptions { WriteIndented = true });
|
||||
var deserializedReceipt = JsonSerializer.Deserialize<KitchenReceipt>(serializedReceipt);
|
||||
|
||||
//var converter = new KitchenReceiptConverter(bigLineWidth: 18, lineWidth: 33);
|
||||
//var printCommands = converter.ConvertToPrintCommands(deserializedReceipt);
|
||||
var converter = new KitchenReceiptConverter(bigLineWidth: 18, lineWidth: 33);
|
||||
var printCommands = converter.ConvertToPrintCommands(deserializedReceipt);
|
||||
|
||||
//TestHelpers.PrintCommandsToConsole(printCommands);
|
||||
TestHelpers.PrintCommandsToConsole(printCommands);
|
||||
|
||||
//var printer = await TestHelpers.CreateEpsonPrinterAsync(paperWidth:TestHelpers.KitchenPaperWidth);
|
||||
//await TestHelpers.PrintCommandsToEpsonPrinterAsync(printer, printCommands, useDelay: true);
|
||||
var printer = await TestHelpers.CreateEpsonPrinterAsync(paperWidth: TestHelpers.KitchenPaperWidth);
|
||||
await TestHelpers.PrintCommandsToEpsonPrinterAsync(printer, printCommands, useDelay: true);
|
||||
|
||||
|
||||
// ============================================================================
|
||||
|
||||
@@ -48,7 +48,7 @@ public static class TestHelpers
|
||||
Address1 = "Münzplatz 3",
|
||||
Address2 = "CH-8001 Zürich",
|
||||
Phone = "043 321 22 22",
|
||||
ReceiptNumber = "1-81-202",
|
||||
ReceiptNumber = null,//"1-81-202",
|
||||
DateTime = new DateTime(2025, 12, 16, 14, 58, 0),
|
||||
Guests = 2,
|
||||
Total = 160.00m,
|
||||
@@ -211,11 +211,14 @@ public static class TestHelpers
|
||||
Address1 = "Münzplatz 3",
|
||||
Address2 = "CH-8001 Zürich",
|
||||
Phone = "043 321 22 22",
|
||||
ReceiptNumber = "1-81-202",
|
||||
ReceiptNumber = null,//"1-81-202",
|
||||
DateTime = new DateTime(2025, 12, 16, 14, 58, 0),
|
||||
Guests = 2,
|
||||
Total = 160.00m,
|
||||
Currency = "CHF"
|
||||
Currency = "CHF",
|
||||
TableNumber = "12",
|
||||
ThankYouMessage = "Thank you!"
|
||||
|
||||
};
|
||||
|
||||
// Add items
|
||||
@@ -308,9 +311,10 @@ public static class TestHelpers
|
||||
Removed = new List<string> { "Wasabi" },
|
||||
Added = new List<string> { "Extra Ginger" }
|
||||
},
|
||||
Comment = "No soy sauce"
|
||||
Comment = "No soy sauce",
|
||||
GuestId = 1
|
||||
});
|
||||
receipt.Gangs[0].Dishes.Add(new Dish(1, "Baby Spinach Salad with Truffl"));
|
||||
receipt.Gangs[0].Dishes.Add(new Dish(1, "Baby Spinach Salad with Truffl"){GuestId = 2});
|
||||
receipt.Gangs[0].Dishes.Add(new Dish(1, "Beef Tataki")
|
||||
{
|
||||
Modifications = new DishModifications
|
||||
@@ -318,20 +322,22 @@ public static class TestHelpers
|
||||
Removed = new List<string> { "Onion" },
|
||||
Added = new List<string> { "Extra Sauce" }
|
||||
},
|
||||
Comment = "Medium rare"
|
||||
Comment = "Medium rare",
|
||||
GuestId = 3
|
||||
});
|
||||
receipt.Gangs[0].Dishes.Add(new Dish(1, "Salmon Taco")
|
||||
{
|
||||
Modifications = new DishModifications
|
||||
{
|
||||
Added = new List<string> { "Extra Lime" }
|
||||
}
|
||||
},
|
||||
GuestId = 4
|
||||
});
|
||||
|
||||
receipt.Gangs[1].Dishes.Add(new Dish(1, "Avocado Sashimi"));
|
||||
receipt.Gangs[1].Dishes.Add(new Dish(1, "Baby Spinach Salad with Truffl"));
|
||||
receipt.Gangs[1].Dishes.Add(new Dish(1, "Beef Tataki"));
|
||||
receipt.Gangs[1].Dishes.Add(new Dish(1, "Salmon Taco"));
|
||||
receipt.Gangs[1].Dishes.Add(new Dish(1, "Avocado Sashimi") { GuestId = 2 });
|
||||
receipt.Gangs[1].Dishes.Add(new Dish(1, "Baby Spinach Salad with Truffl") { GuestId = 2 });
|
||||
receipt.Gangs[1].Dishes.Add(new Dish(1, "Beef Tataki") { GuestId = 3 });
|
||||
receipt.Gangs[1].Dishes.Add(new Dish(1, "Salmon Taco") { GuestId = 4 });
|
||||
|
||||
return receipt;
|
||||
}
|
||||
@@ -346,37 +352,37 @@ public static class TestHelpers
|
||||
WaiterName = "Mariano Amato",
|
||||
WaiterId = "32 (VK Restaurant)",
|
||||
TableNumber = "22",
|
||||
SpecialInstruction = "Next dish"
|
||||
SpecialInstruction = "Gang schicken"
|
||||
};
|
||||
|
||||
receipt.Gangs.Add(new Gang(2, "Gang"));
|
||||
|
||||
receipt.Gangs[0].Dishes.Add(new Dish(1, "Avocado Sashimi")
|
||||
{
|
||||
Modifications = new DishModifications
|
||||
{
|
||||
Removed = new List<string> { "Wasabi" },
|
||||
Added = new List<string> { "Extra Ginger" }
|
||||
},
|
||||
Comment = "No soy sauce"
|
||||
});
|
||||
receipt.Gangs[0].Dishes.Add(new Dish(1, "Baby Spinach Salad with Truffl"));
|
||||
receipt.Gangs[0].Dishes.Add(new Dish(1, "Beef Tataki")
|
||||
{
|
||||
Modifications = new DishModifications
|
||||
{
|
||||
Removed = new List<string> { "Onion" },
|
||||
Added = new List<string> { "Extra Sauce" }
|
||||
},
|
||||
Comment = "Medium rare"
|
||||
});
|
||||
receipt.Gangs[0].Dishes.Add(new Dish(1, "Salmon Taco")
|
||||
{
|
||||
Modifications = new DishModifications
|
||||
{
|
||||
Added = new List<string> { "Extra Lime" }
|
||||
}
|
||||
});
|
||||
// to dishes in next dish
|
||||
//receipt.Gangs[0].Dishes.Add(new Dish(1, "Avocado Sashimi")
|
||||
//{
|
||||
// Modifications = new DishModifications
|
||||
// {
|
||||
// Removed = new List<string> { "Wasabi" },
|
||||
// Added = new List<string> { "Extra Ginger" }
|
||||
// },
|
||||
// Comment = "No soy sauce"
|
||||
//});
|
||||
//receipt.Gangs[0].Dishes.Add(new Dish(1, "Baby Spinach Salad with Truffl"));
|
||||
//receipt.Gangs[0].Dishes.Add(new Dish(1, "Beef Tataki")
|
||||
//{
|
||||
// Modifications = new DishModifications
|
||||
// {
|
||||
// Removed = new List<string> { "Onion" },
|
||||
// Added = new List<string> { "Extra Sauce" }
|
||||
// },
|
||||
// Comment = "Medium rare"
|
||||
//});
|
||||
//receipt.Gangs[0].Dishes.Add(new Dish(1, "Salmon Taco")
|
||||
//{
|
||||
// Modifications = new DishModifications
|
||||
// {
|
||||
// Added = new List<string> { "Extra Lime" }
|
||||
// }
|
||||
//});
|
||||
|
||||
return receipt;
|
||||
}
|
||||
@@ -459,13 +465,23 @@ public static class TestHelpers
|
||||
EpsonPrinter printer,
|
||||
IEnumerable<PrintCommand> commands,
|
||||
bool useDelay = true,
|
||||
int delayMs = 500)
|
||||
int delayMs = 200)
|
||||
{
|
||||
await printer.FeedLinesAsync(1);
|
||||
await printer.SetCustomLineSpacing(22);
|
||||
|
||||
foreach (var command in commands)
|
||||
{
|
||||
if (command.IsCut)
|
||||
{
|
||||
await printer.FeedLinesAsync(10);
|
||||
if (useDelay) await Task.Delay(delayMs * 5);
|
||||
await printer.CutAsync(false);
|
||||
if (useDelay) await Task.Delay(delayMs);
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
await printer.SetBiggerFontTM220(command.IsBig, command.IsTall | command.IsBig, secondaryFont: false);
|
||||
if (useDelay) await Task.Delay(delayMs);
|
||||
|
||||
@@ -479,7 +495,7 @@ public static class TestHelpers
|
||||
if (useDelay) await Task.Delay(delayMs);
|
||||
}
|
||||
|
||||
await printer.FeedLinesAsync(5);
|
||||
await printer.FeedLinesAsync(10);
|
||||
if (useDelay) await Task.Delay(delayMs * 5);
|
||||
await printer.CutAsync();
|
||||
}
|
||||
@@ -493,6 +509,11 @@ public static class TestHelpers
|
||||
|
||||
foreach (var command in commands)
|
||||
{
|
||||
if (command.IsCut)
|
||||
{
|
||||
await printer.CutAsync(false);
|
||||
continue;
|
||||
}
|
||||
if (command.IsBig)
|
||||
await printer.SetFontSizeAsync(2, 1);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user